problem
stringlengths
26
131k
labels
class label
2 classes
void cpu_loop(CPUX86State *env) { CPUState *cs = CPU(x86_env_get_cpu(env)); int trapnr; abi_ulong pc; target_siginfo_t info; for(;;) { cpu_exec_start(cs); trapnr = cpu_x86_exec(cs); cpu_exec_end(cs); switch(trapnr) { case 0x80: env->regs[R_EAX] = do_syscall(env, env->regs[R_EAX], env->regs[R_EBX], env->regs[R_ECX], env->regs[R_EDX], env->regs[R_ESI], env->regs[R_EDI], env->regs[R_EBP], 0, 0); break; #ifndef TARGET_ABI32 case EXCP_SYSCALL: env->regs[R_EAX] = do_syscall(env, env->regs[R_EAX], env->regs[R_EDI], env->regs[R_ESI], env->regs[R_EDX], env->regs[10], env->regs[8], env->regs[9], 0, 0); break; #endif case EXCP0B_NOSEG: case EXCP0C_STACK: info.si_signo = TARGET_SIGBUS; info.si_errno = 0; info.si_code = TARGET_SI_KERNEL; info._sifields._sigfault._addr = 0; queue_signal(env, info.si_signo, &info); break; case EXCP0D_GPF: #ifndef TARGET_X86_64 if (env->eflags & VM_MASK) { handle_vm86_fault(env); } else #endif { info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; info.si_code = TARGET_SI_KERNEL; info._sifields._sigfault._addr = 0; queue_signal(env, info.si_signo, &info); } break; case EXCP0E_PAGE: info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; if (!(env->error_code & 1)) info.si_code = TARGET_SEGV_MAPERR; else info.si_code = TARGET_SEGV_ACCERR; info._sifields._sigfault._addr = env->cr[2]; queue_signal(env, info.si_signo, &info); break; case EXCP00_DIVZ: #ifndef TARGET_X86_64 if (env->eflags & VM_MASK) { handle_vm86_trap(env, trapnr); } else #endif { info.si_signo = TARGET_SIGFPE; info.si_errno = 0; info.si_code = TARGET_FPE_INTDIV; info._sifields._sigfault._addr = env->eip; queue_signal(env, info.si_signo, &info); } break; case EXCP01_DB: case EXCP03_INT3: #ifndef TARGET_X86_64 if (env->eflags & VM_MASK) { handle_vm86_trap(env, trapnr); } else #endif { info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; if (trapnr == EXCP01_DB) { info.si_code = TARGET_TRAP_BRKPT; info._sifields._sigfault._addr = env->eip; } else { info.si_code = TARGET_SI_KERNEL; info._sifields._sigfault._addr = 0; } queue_signal(env, info.si_signo, &info); } break; case EXCP04_INTO: case EXCP05_BOUND: #ifndef TARGET_X86_64 if (env->eflags & VM_MASK) { handle_vm86_trap(env, trapnr); } else #endif { info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; info.si_code = TARGET_SI_KERNEL; info._sifields._sigfault._addr = 0; queue_signal(env, info.si_signo, &info); } break; case EXCP06_ILLOP: info.si_signo = TARGET_SIGILL; info.si_errno = 0; info.si_code = TARGET_ILL_ILLOPN; info._sifields._sigfault._addr = env->eip; queue_signal(env, info.si_signo, &info); break; case EXCP_INTERRUPT: break; case EXCP_DEBUG: { int sig; sig = gdb_handlesig(cs, TARGET_SIGTRAP); if (sig) { info.si_signo = sig; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, &info); } } break; default: pc = env->segs[R_CS].base + env->eip; EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n", (long)pc, trapnr); abort(); } process_pending_signals(env); } }
1threat
How to retrieve multiple keys in Firebase? : <p>Considering this data structure:</p> <pre><code>{ "users":{ "user-1":{ "groups":{ "group-key-1":true, "group-key-3":true } } }, "groups":{ "group-key-1":{ "name":"My group 1" }, "group-key-2":{ "name":"My group 2" }, "group-key-3":{ "name":"My group 3" }, "group-key-4":{ "name":"My group 4" }, } } </code></pre> <p>I could get the groups of a particular user with:</p> <pre><code>firebase.database().ref('users/user-1/groups').on(...) </code></pre> <p>Which would give me this object:</p> <pre><code>{ "group-key-1":true, "group-key-3":true } </code></pre> <p>So now I want to retrieve the info for those groups.</p> <p>My initial instinct would be to loop those keys and do this:</p> <pre><code>var data = snapshot.val() var keys = Object.keys(data) for (var i = 0; i &lt; keys.length; i++) { firebase.database().ref('groups/' + keys[i]).on(...) } </code></pre> <p>Is this the appropriate way to call multiple keys on the same endpoint in Firebase?</p> <p>Does Firebase provide a better way to solve this problem?</p>
0debug
Can you speed up this algorithm? C# / C++ : <p>Hey I've been working on something from time to time and it has become relatively large now (and slow). However I managed to pinpoint the bottleneck after close up measuring of performance in function of time.</p> <p>Say I want to "permute" the string "ABC". What I mean by "permute" is not quite a permutation but rather a continuous substring set following this pattern:</p> <pre><code>A AB ABC B BC C </code></pre> <p>I have to check for every substring if it is contained within another string S2 so I've done some quick'n dirty literal implementation as follows:</p> <pre><code>for (int i = 0; i &lt;= strlen1; i++) { for (int j = 0; j &lt;= strlen2- i; j++) { sub = str1.Substring(i, j); if (str2.Contains(sub)) {do stuff} else break; </code></pre> <p>This was very slow initially but once I realised that if the first part doesnt exist, there is no need to check for the subsequent ones meaning that if sub isn't contained within str2, i can call break on the inner loop.</p> <p>Ok this gave blazing fast results but calculating my algorithm complexity I realised that in worst case this will be N^4 ? I forgot that str.contains() and str.substr() both have their own complexities (N or N^2 I forgot which).</p> <p>The fact that I have a huge amount of calls on those inside a 2nd for loop makes it perform rather.. well N^4 ~ said enough.</p> <p>However I calculated the average run-time of this both mathematically using probability theory to evaluate the probability of growth of the substring in a pool of randomly generated strings (this was my base line) measuring when the probability became > 0.5 (50%)</p> <p>This showed an exponential relationship between the number of different characters and the string length (roughly) which means that in the scenarios I use my algorithm the length of string1 wont (most probably) never exceed 7</p> <p>Thus the average complexity would be ~O(N * M) where N is string length1 and M is string length 2. Due to the fact that I've tested N in function of constant M, I've gotten linear growth ~O(N) (not bad opposing to the N^4 eh?)</p> <p>I did time testing and plotted a graph which showed nearly perfect linear growth so I got my actual results matching my mathematical predictions (yay!)</p> <p>However, this was NOT taking into account the cost of string.contains() and string.substring() which made me wonder if this could be optimized even further?</p> <p>I've been also thinking of making this in C++ because I need rather low-level stuff? What do you guys think? I have put a great time into analysing this hope I've elaborated everything clear enough :)!</p>
0debug
Setting train array dimensions for face recognition for python : <p>I'm trying to find an equivalent code for python to set the following dimensions that I set in R:</p> <pre><code>dim(train_array) = c(28, 28, 1, ncol(train_x)) </code></pre> <p>train_x is a matrix of 28 by 28 resized (grey scale) olivetti face images digitized into 784 (28 * 28) pixel rows (each row is labeled pixel.1, pixel.2, and so on) and 15 columns. Is there any python package that does the same function as dim() for R in python?</p>
0debug
static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track) { const char *hdlr, *descr = NULL, *hdlr_type = NULL; int64_t pos = avio_tell(pb); if (!track) { hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0"; if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) { hdlr_type = "vide"; descr = "VideoHandler"; } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) { hdlr_type = "soun"; descr = "SoundHandler"; } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl"; else hdlr_type = "text"; descr = "SubtitleHandler"; } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) { hdlr_type = "hint"; descr = "HintHandler"; } } avio_wb32(pb, 0); ffio_wfourcc(pb, "hdlr"); avio_wb32(pb, 0); avio_write(pb, hdlr, 4); ffio_wfourcc(pb, hdlr_type); avio_wb32(pb ,0); avio_wb32(pb ,0); avio_wb32(pb ,0); if (!track || track->mode == MODE_MOV) avio_w8(pb, strlen(descr)); avio_write(pb, descr, strlen(descr)); if (track && track->mode != MODE_MOV) avio_w8(pb, 0); return update_size(pb, pos); }
1threat
explain the functioning of memset(arr, 10, n*sizeof(arr[0])) ? : why memset(arr, 10, n*sizeof(arr[0])) gives the answer Array after memset() 168430090 168430090 168430090 168430090 168430090 168430090 168430090 168430090 168430090 168430090
0debug
Angularjs ui bootstrap: how to vertical center modal component? : <p>Recently I am learning angularjs. I have used bootstrap before. With jquery, I can easily change the position of the modal component position to make it vertical align. Now with angularjs, it seems not very easy to do that. Here is a plunker link of ui bootstrap modal, Does anyone know how to make it vertical align?</p> <p><a href="http://plnkr.co/edit/TvLQkPh0cs4McxfLpE9u?p=preview" rel="noreferrer">ui bootstrap modal component</a></p> <p>1.index.html </p> <pre><code> &lt;!doctype html&gt; &lt;html ng-app="ui.bootstrap.demo"&gt; &lt;head&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"&gt;&lt;/script&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"&gt;&lt;/script&gt; &lt;script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.1.js"&gt;&lt;/script&gt; &lt;script src="example.js"&gt;&lt;/script&gt; &lt;link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-controller="ModalDemoCtrl"&gt; &lt;script type="text/ng-template" id="myModalContent.html"&gt; &lt;div class="modal-header"&gt; &lt;h3 class="modal-title"&gt;I'm a modal!&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; This is modal body &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn btn-primary" type="button" ng-click="ok()"&gt;OK&lt;/button&gt; &lt;button class="btn btn-warning" type="button" ng-click="cancel()"&gt;Cancel&lt;/button&gt; &lt;/div&gt; &lt;/script&gt; &lt;button type="button" class="btn btn-default" ng-click="open()"&gt;Open me!&lt;/button&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>2.example.js</p> <pre><code> angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']); angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function($scope, $uibModal, $log) { $scope.items = ['item1', 'item2', 'item3']; $scope.animationsEnabled = true; $scope.open = function(size) { var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'myModalContent.html', controller: 'ModalInstanceCtrl', size: size, resolve: { items: function() { return $scope.items; } } }); }; }); angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function($scope, $uibModalInstance, items) { $scope.ok = function() { $uibModalInstance.close($scope.selected.item); }; $scope.cancel = function() { $uibModalInstance.dismiss('cancel'); }; }); </code></pre>
0debug
Get PM or AM from string date C# : <p>I have this string as a date and I want to add the AM/PM to the end.</p> <p>From 10-17-2018 00:00:00</p> <p>To 10-17-2018 00:00:00 AM</p> <p>How is possible? Thanks a lot!</p>
0debug
static int write_trailer(AVFormatContext *s){ NUTContext *nut= s->priv_data; AVIOContext *bc= s->pb; while(nut->header_count<3) write_headers(s, bc); avio_flush(bc); ff_nut_free_sp(nut); av_freep(&nut->stream); av_freep(&nut->time_base); return 0; }
1threat
Selection sort in c : Is following c code is written according to selection sort algorithm? I'm little bit confused about it. However, it gives correct results. #include<stdio.h> int main() { int n; printf("Enter size of array: "); scanf("%d",&n); int a[n],i=0,j,min; while(i<n) { printf("Enter no. %d:",i+1); scanf("%d",&a[i]); i++; } for(i=0;i<n;i++) { for(j=i,min=a[i];j<n;j++) { if(a[j]<min) min=a[j]; else continue; a[j]=a[i]; a[i]=min; } } for(i=0;i<n;i++) printf("%d ",a[i]); return 0; } >
0debug
Laravel: String data, right truncated: 1406 Data too long for column : <p>I have a table with a column 'hotel'. The project is created in Laravel 5.4, so I used Migrations. </p> <pre><code> $table-&gt;string('hotel', 50); </code></pre> <p>This is MYSQL VARCHAR (50). It was working good, because when I was developing I used short hotel names like <em>"HILTON NEW YORK 5</em>"*. </p> <p>Now the project is on production and customer asked why they can't input long hotel names. I've tested it with such a mock hotel name as <em>"Long long long long long long long long long and very-very-very long hotel name 5 stars"</em></p> <p>It gave me an error:</p> <blockquote> <p>"SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'hotel' at row 1"</p> </blockquote> <p>I've opened database in my Sequel Pro and changed it</p> <ul> <li>first to VARCHAR (255) </li> <li>then to TEXT</li> </ul> <p>After each change I tested it with the same "Long long long long long long long long long and very-very-very long hotel name 5 starts" and get the same error (see above).</p> <p>I've checked the type of column with </p> <pre><code>SHOW FIELDS FROM table_name </code></pre> <p>and it gave me </p> <blockquote> <p>Field | Type</p> <p>hotel | text</p> </blockquote> <p>so the type of the field is 'text' indeed (65 535 characters). </p> <p>Maybe it's somehow connected with Laravel Migration file (see above) where I set VARCHAR (50) in the beginning? But I can't re-run migration on production, because the table has data now. </p> <p>Would appreciate any help.</p> <hr> <p><strong>UPDATE:</strong> I discovered that it actually saves that long hotel name in the DB. But user still gets this annoying mistake every time after submitting the form...</p>
0debug
PHP Array Readable : <p>I have an Array format.</p> <pre><code>Array ( [0] =&gt; Array ( [order_id] =&gt; 1 ) [1] =&gt; Array ( [order_id] =&gt; 11 ) [2] =&gt; Array ( [order_id] =&gt; 12 ) ) </code></pre> <p>It should to be changed the array format to be like this format:</p> <pre><code>[1,11,12]; </code></pre> <p>Please help. Thank you in advanced.</p>
0debug
How to prevent function from modifying? : <p>I have the next def:</p> <pre><code>def get_smth return @mySmth end </code></pre> <p>how to make that there should be no way to modify the content through it or through the object it returns?</p> <p>I thought about getters and setters, but is it a solution?</p>
0debug
I am trying to select one attribute which is having same id's : [enter image description here][1] [1]: https://i.stack.imgur.com/YkA2J.png I am trying to select one attribute which is having same id's. I used nht-of-type , still not able to select that .could you please help me, i am adding screenshot for reference
0debug
How to implement optimization of INNER JOINS (push down) for Mongo Storage Plugin in Apache Drill? : <p>I would like to extend the <a href="https://drill.apache.org/docs/mongodb-storage-plugin/" rel="noreferrer">Apache Drill Mongo Storage Plugin</a> to push down INNER JOINs. Therefore I would like to rewrite <code>INNER JOIN</code> into the mongo aggregation pipeline.</p> <p>How do we need to start to implement the rewrite in <a href="https://drill.apache.org/" rel="noreferrer">Apache Drill</a>.</p> <p>Here is a SQL example:</p> <pre><code>SELECT * FROM `mymongo.db`.`test` `test` INNER JOIN `mymongo.db`.`test2` `test2` ON (`test`.`id` = `test2`.`fk`) WHERE `test2`.`date` = '09.05.2017' </code></pre> <p>I have found the <a href="https://github.com/apache/drill/blob/master/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoPushDownFilterForScan.java" rel="noreferrer">push down</a> of <code>WHERE</code> clauses in the Mongo Storage Plugin. But I am still struggling to do the same for <code>INNER JOINS</code>. How would the constuctor of <code>public class MongoPushDownInnerJoinScan extends StoragePluginOptimizerRule</code> look like? Which equivalent of <code>MongoGroupScan</code> (<a href="https://github.com/apache/drill/blob/master/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java" rel="noreferrer"><code>AbstractGroupScan</code></a>) would I have to implement? Any help would be very much appreciated.</p>
0debug
static void test_qemu_strtoull_trailing(void) { const char *str = "123xxx"; char f = 'X'; const char *endptr = &f; uint64_t res = 999; int err; err = qemu_strtoull(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 123); g_assert(endptr == str + 3); }
1threat
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format); const AVComponentDescriptor *c; unsigned i, nb_planes = 0; int pixelstep[MAX_PLANES] = { 0 }; if (!desc->name) return AVERROR(EINVAL); if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA)) return AVERROR(ENOSYS); for (i = 0; i < desc->nb_components; i++) { c = &desc->comp[i]; if (c->depth_minus1 != 8 - 1) return AVERROR(ENOSYS); if (c->plane >= MAX_PLANES) return AVERROR(ENOSYS); if (pixelstep[c->plane] != 0 && pixelstep[c->plane] != c->step_minus1 + 1) return AVERROR(ENOSYS); pixelstep[c->plane] = c->step_minus1 + 1; if (pixelstep[c->plane] >= 8) return AVERROR(ENOSYS); nb_planes = FFMAX(nb_planes, c->plane + 1); } if ((desc->log2_chroma_w || desc->log2_chroma_h) && nb_planes < 3) return AVERROR(ENOSYS); memset(draw, 0, sizeof(*draw)); draw->desc = desc; draw->format = format; draw->nb_planes = nb_planes; memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep)); draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w; draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h; for (i = 0; i < ((desc->nb_components - 1) | 1); i++) draw->comp_mask[desc->comp[i].plane] |= 1 << (desc->comp[i].offset_plus1 - 1); return 0; }
1threat
How to add 'src' folder at solution root : <p>This is going to sound like a silly question, but Visual Studio does not seem to let me do this simple organization which I see all the time on github.</p> <p>I start with new empty solution.</p> <p>I then want to add a "src" folder which will contain project multiple projects. If I right click and select "Add Folder" VS adds a virtual folder, not an actual folder.</p> <p>If I use Windows Explorer to create a new folder in the desired location, VS ignores it and does not let me "Add to solution"</p> <p>If I add a project, it adds the project at the root, not in the desired folder. </p> <p>So, how do I add this folder?</p>
0debug
static void pic_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned int size) { struct etrax_pic *fs = opaque; D(printf("%s addr=%x val=%x\n", __func__, addr, value)); if (addr == R_RW_MASK) { fs->regs[R_RW_MASK] = value; pic_update(fs); } }
1threat
Split column into 2 with '-' delimiter : Would need to split a column into 2, with a given delimiter. Excel file does not have a header in the columns. example input file and outfile s are attached.
0debug
i am getting error "java.nio.charset.MalformedInputException: Input length = 1" in scala : scala> val lines = scala.io.Source.fromFile("1.pdf").getLines java.nio.charset.MalformedInputException: Input length = 1
0debug
static void term_exit(void) { tcsetattr(0, TCSANOW, &oldtty); }
1threat
Total delay is for 60 secs and each check with 5 secs interval : Total sleep time should be 60 secs and each check should be in 5 secs interval. How should I use count variable to trace the count of the total execution ```import time def test(a): count=0 while True: if a < 10: print("ok") return True count = count+1 time.sleep(5) if(count == 12): return False print(test(a=40)) ``` the while loop should stop executing after 60 secs and return false, the each check interval is 5 secs. I am confused that where should I increment the count, before time.sleep(5) or after time.sleep(5). what will be the solution to see that the time.sleep is been executed for 12 times and it has been 60 secs of waiting and return false
0debug
how can I access the __zone_symbol__value on the ZoneAwarePromise in Angular 2 : <p>I am receiving a ZoneAwarePromise and when I logged it to the console I found that it contains a __zone_symbol__value I was wondering if it's possible to set a variable equal to that __zone_symbol__value?</p>
0debug
int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = data; SliceInfo si; int i; int slice_count; const uint8_t *slices_hdr = NULL; int last = 0; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict = *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr = NULL; *data_size = sizeof(AVFrame); } return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; }else slice_count = avctx->slice_count; if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); return -1; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; for(i = 0; i < slice_count; i++){ int offset = get_slice_offset(avctx, slices_hdr, i); int size; if(i+1 == slice_count) size = buf_size - offset; else size = get_slice_offset(avctx, slices_hdr, i+1) - offset; if(offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); break; } r->si.end = s->mb_width * s->mb_height; if(i+1 < slice_count){ init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) size = get_slice_offset(avctx, slices_hdr, i+2) - offset; else size = buf_size - offset; }else r->si.end = si.start; } last = rv34_decode_slice(r, r->si.end, buf + offset, size); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(last) break; } if(last && s->current_picture_ptr){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict = *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } s->current_picture_ptr = NULL; } return buf_size; }
1threat
void migrate_fd_error(MigrationState *s) { trace_migrate_fd_error(); assert(s->to_dst_file == NULL); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); notifier_list_notify(&migration_state_notifiers, s); }
1threat
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header) { uint8_t rps_predict = 0; int delta_poc; int k0 = 0; int k1 = 0; int k = 0; int i; if (rps != sps->st_rps && sps->nb_st_rps) rps_predict = get_bits1(gb); if (rps_predict) { const ShortTermRPS *rps_ridx; int delta_rps; unsigned abs_delta_rps; uint8_t use_delta_flag = 0; uint8_t delta_rps_sign; if (is_slice_header) { unsigned int delta_idx = get_ue_golomb_long(gb) + 1; if (delta_idx > sps->nb_st_rps) { "Invalid value of delta_idx in slice header RPS: %d > %d.\n", delta_idx, sps->nb_st_rps); rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx]; rps->rps_idx_num_delta_pocs = rps_ridx->num_delta_pocs; } else rps_ridx = &sps->st_rps[rps - sps->st_rps - 1]; delta_rps_sign = get_bits1(gb); abs_delta_rps = get_ue_golomb_long(gb) + 1; if (abs_delta_rps < 1 || abs_delta_rps > 32768) { "Invalid value of abs_delta_rps: %d\n", abs_delta_rps); delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps; for (i = 0; i <= rps_ridx->num_delta_pocs; i++) { int used = rps->used[k] = get_bits1(gb); if (!used) use_delta_flag = get_bits1(gb); if (used || use_delta_flag) { if (i < rps_ridx->num_delta_pocs) delta_poc = delta_rps + rps_ridx->delta_poc[i]; else delta_poc = delta_rps; rps->delta_poc[k] = delta_poc; if (delta_poc < 0) k0++; else k1++; k++; rps->num_delta_pocs = k; rps->num_negative_pics = k0; if (rps->num_delta_pocs != 0) { int used, tmp; for (i = 1; i < rps->num_delta_pocs; i++) { delta_poc = rps->delta_poc[i]; used = rps->used[i]; for (k = i - 1; k >= 0; k--) { tmp = rps->delta_poc[k]; if (delta_poc < tmp) { rps->delta_poc[k + 1] = tmp; rps->used[k + 1] = rps->used[k]; rps->delta_poc[k] = delta_poc; rps->used[k] = used; if ((rps->num_negative_pics >> 1) != 0) { int used; k = rps->num_negative_pics - 1; for (i = 0; i < rps->num_negative_pics >> 1; i++) { delta_poc = rps->delta_poc[i]; used = rps->used[i]; rps->delta_poc[i] = rps->delta_poc[k]; rps->used[i] = rps->used[k]; rps->delta_poc[k] = delta_poc; rps->used[k] = used; k--; } else { unsigned int prev, nb_positive_pics; rps->num_negative_pics = get_ue_golomb_long(gb); nb_positive_pics = get_ue_golomb_long(gb); if (rps->num_negative_pics >= HEVC_MAX_REFS || nb_positive_pics >= HEVC_MAX_REFS) { av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n"); rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics; if (rps->num_delta_pocs) { prev = 0; for (i = 0; i < rps->num_negative_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; prev -= delta_poc; rps->delta_poc[i] = prev; rps->used[i] = get_bits1(gb); prev = 0; for (i = 0; i < nb_positive_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; prev += delta_poc; rps->delta_poc[rps->num_negative_pics + i] = prev; rps->used[rps->num_negative_pics + i] = get_bits1(gb); return 0;
1threat
HTML PHP: IF li element clicked, ORDERBY DESC or ASC : <p>I have a ascending and descending list element within my html. If the user clicks on the ascending li I wish for the products in my SQLi to be shown in ascending order, if descending, descending order. </p> <p>This is what I have come up with, but does not work.</p> <pre><code>&lt;ul align ="center"&gt; &lt;li name="asc" onclick="AscendingProds()"&gt;&lt;a&gt;Ascending to Descending&lt;/a&gt;&lt;/li&gt; &lt;li name="desc" onclick="DescendingProds()"&gt;&lt;a&gt;Descending to Ascending&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;?php AscendingProds(){ $results = $mysqli-&gt;query("SELECT prds ORDER BY price ASC"); } DescendingProds(){ $results = $mysqli-&gt;query("SELECT prds ORDER BY price DESC"); } </code></pre>
0debug
static uint64_t pxa2xx_lcdc_read(void *opaque, hwaddr offset, unsigned size) { PXA2xxLCDState *s = (PXA2xxLCDState *) opaque; int ch; switch (offset) { case LCCR0: return s->control[0]; case LCCR1: return s->control[1]; case LCCR2: return s->control[2]; case LCCR3: return s->control[3]; case LCCR4: return s->control[4]; case LCCR5: return s->control[5]; case OVL1C1: return s->ovl1c[0]; case OVL1C2: return s->ovl1c[1]; case OVL2C1: return s->ovl2c[0]; case OVL2C2: return s->ovl2c[1]; case CCR: return s->ccr; case CMDCR: return s->cmdcr; case TRGBR: return s->trgbr; case TCR: return s->tcr; case 0x200 ... 0x1000: ch = (offset - 0x200) >> 4; if (!(ch >= 0 && ch < PXA_LCDDMA_CHANS)) goto fail; switch (offset & 0xf) { case DMA_FDADR: return s->dma_ch[ch].descriptor; case DMA_FSADR: return s->dma_ch[ch].source; case DMA_FIDR: return s->dma_ch[ch].id; case DMA_LDCMD: return s->dma_ch[ch].command; default: goto fail; } case FBR0: return s->dma_ch[0].branch; case FBR1: return s->dma_ch[1].branch; case FBR2: return s->dma_ch[2].branch; case FBR3: return s->dma_ch[3].branch; case FBR4: return s->dma_ch[4].branch; case FBR5: return s->dma_ch[5].branch; case FBR6: return s->dma_ch[6].branch; case BSCNTR: return s->bscntr; case PRSR: return 0; case LCSR0: return s->status[0]; case LCSR1: return s->status[1]; case LIIDR: return s->liidr; default: fail: hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset); } return 0; }
1threat
static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) { int pw = w, ph = h; Jpeg2000TgtNode *res, *t, *t2; int32_t tt_size; tt_size = tag_tree_size(w, h); if (tt_size == -1) return NULL; t = res = av_mallocz_array(tt_size, sizeof(*t)); if (!res) return NULL; while (w > 1 || h > 1) { int i, j; pw = w; ph = h; w = (w + 1) >> 1; h = (h + 1) >> 1; t2 = t + pw * ph; for (i = 0; i < ph; i++) for (j = 0; j < pw; j++) t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)]; t = t2; } t[0].parent = NULL; return res; }
1threat
void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) { CPUState *cs = CPU(x86_env_get_cpu(env)); target_ulong addr; uint32_t event_inj; uint32_t int_ctl; cpu_svm_check_intercept_param(env, SVM_EXIT_VMRUN, 0); if (aflag == 2) { addr = env->regs[R_EAX]; } else { addr = (uint32_t)env->regs[R_EAX]; } qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmrun! " TARGET_FMT_lx "\n", addr); env->vm_vmcb = addr; stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.gdtr.base), env->gdt.base); stl_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.gdtr.limit), env->gdt.limit); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.idtr.base), env->idt.base); stl_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.idtr.limit), env->idt.limit); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.cr0), env->cr[0]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.cr2), env->cr[2]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.cr3), env->cr[3]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.cr4), env->cr[4]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.dr6), env->dr[6]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.dr7), env->dr[7]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.efer), env->efer); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.rflags), cpu_compute_eflags(env)); svm_save_seg(env, env->vm_hsave + offsetof(struct vmcb, save.es), &env->segs[R_ES]); svm_save_seg(env, env->vm_hsave + offsetof(struct vmcb, save.cs), &env->segs[R_CS]); svm_save_seg(env, env->vm_hsave + offsetof(struct vmcb, save.ss), &env->segs[R_SS]); svm_save_seg(env, env->vm_hsave + offsetof(struct vmcb, save.ds), &env->segs[R_DS]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.rip), env->eip + next_eip_addend); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.rsp), env->regs[R_ESP]); stq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb, save.rax), env->regs[R_EAX]); env->intercept = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept)); env->intercept_cr_read = lduw_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept_cr_read)); env->intercept_cr_write = lduw_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept_cr_write)); env->intercept_dr_read = lduw_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept_dr_read)); env->intercept_dr_write = lduw_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept_dr_write)); env->intercept_exceptions = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.intercept_exceptions )); env->hflags |= HF_SVMI_MASK; env->tsc_offset = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.tsc_offset)); env->gdt.base = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.gdtr.base)); env->gdt.limit = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.gdtr.limit)); env->idt.base = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.idtr.base)); env->idt.limit = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.idtr.limit)); stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), 0); cpu_x86_update_cr0(env, ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cr0))); cpu_x86_update_cr4(env, ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cr4))); cpu_x86_update_cr3(env, ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cr3))); env->cr[2] = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cr2)); int_ctl = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.int_ctl)); env->hflags2 &= ~(HF2_HIF_MASK | HF2_VINTR_MASK); if (int_ctl & V_INTR_MASKING_MASK) { env->v_tpr = int_ctl & V_TPR_MASK; env->hflags2 |= HF2_VINTR_MASK; if (env->eflags & IF_MASK) { env->hflags2 |= HF2_HIF_MASK; } } cpu_load_efer(env, ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.efer))); env->eflags = 0; cpu_load_eflags(env, ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rflags)), ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK)); CC_OP = CC_OP_EFLAGS; svm_load_seg_cache(env, env->vm_vmcb + offsetof(struct vmcb, save.es), R_ES); svm_load_seg_cache(env, env->vm_vmcb + offsetof(struct vmcb, save.cs), R_CS); svm_load_seg_cache(env, env->vm_vmcb + offsetof(struct vmcb, save.ss), R_SS); svm_load_seg_cache(env, env->vm_vmcb + offsetof(struct vmcb, save.ds), R_DS); env->eip = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rip)); env->regs[R_ESP] = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rsp)); env->regs[R_EAX] = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rax)); env->dr[7] = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.dr7)); env->dr[6] = ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.dr6)); cpu_x86_set_cpl(env, ldub_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cpl))); switch (ldub_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.tlb_ctl))) { case TLB_CONTROL_DO_NOTHING: break; case TLB_CONTROL_FLUSH_ALL_ASID: tlb_flush(cs, 1); break; } env->hflags2 |= HF2_GIF_MASK; if (int_ctl & V_IRQ_MASK) { CPUState *cs = CPU(x86_env_get_cpu(env)); cs->interrupt_request |= CPU_INTERRUPT_VIRQ; } event_inj = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.event_inj)); if (event_inj & SVM_EVTINJ_VALID) { uint8_t vector = event_inj & SVM_EVTINJ_VEC_MASK; uint16_t valid_err = event_inj & SVM_EVTINJ_VALID_ERR; uint32_t event_inj_err = ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.event_inj_err)); qemu_log_mask(CPU_LOG_TB_IN_ASM, "Injecting(%#hx): ", valid_err); switch (event_inj & SVM_EVTINJ_TYPE_MASK) { case SVM_EVTINJ_TYPE_INTR: cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int = 0; env->exception_next_eip = -1; qemu_log_mask(CPU_LOG_TB_IN_ASM, "INTR"); do_interrupt_x86_hardirq(env, vector, 1); break; case SVM_EVTINJ_TYPE_NMI: cs->exception_index = EXCP02_NMI; env->error_code = event_inj_err; env->exception_is_int = 0; env->exception_next_eip = env->eip; qemu_log_mask(CPU_LOG_TB_IN_ASM, "NMI"); cpu_loop_exit(cs); break; case SVM_EVTINJ_TYPE_EXEPT: cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int = 0; env->exception_next_eip = -1; qemu_log_mask(CPU_LOG_TB_IN_ASM, "EXEPT"); cpu_loop_exit(cs); break; case SVM_EVTINJ_TYPE_SOFT: cs->exception_index = vector; env->error_code = event_inj_err; env->exception_is_int = 1; env->exception_next_eip = env->eip; qemu_log_mask(CPU_LOG_TB_IN_ASM, "SOFT"); cpu_loop_exit(cs); break; } qemu_log_mask(CPU_LOG_TB_IN_ASM, " %#x %#x\n", cs->exception_index, env->error_code); } }
1threat
Decoding structured JSON arrays with circe in Scala : <p>Suppose I need to decode JSON arrays that look like the following, where there are a couple of fields at the beginning, some arbitrary number of homogeneous elements, and then some other field:</p> <pre><code>[ "Foo", "McBar", true, false, false, false, true, 137 ] </code></pre> <p>I don't know why anyone would choose to encode their data like this, but people do weird things, and suppose in this case I just have to deal with it.</p> <p>I want to decode this JSON into a case class like this:</p> <pre><code>case class Foo(firstName: String, lastName: String, age: Int, stuff: List[Boolean]) </code></pre> <p>We can write something like this:</p> <pre><code>import cats.syntax.either._ import io.circe.{ Decoder, DecodingFailure, Json } implicit val fooDecoder: Decoder[Foo] = Decoder.instance { c =&gt; c.focus.flatMap(_.asArray) match { case Some(fnJ +: lnJ +: rest) =&gt; rest.reverse match { case ageJ +: stuffJ =&gt; for { fn &lt;- fnJ.as[String] ln &lt;- lnJ.as[String] age &lt;- ageJ.as[Int] stuff &lt;- Json.fromValues(stuffJ.reverse).as[List[Boolean]] } yield Foo(fn, ln, age, stuff) case _ =&gt; Left(DecodingFailure("Foo", c.history)) } case None =&gt; Left(DecodingFailure("Foo", c.history)) } } </code></pre> <p>…which works:</p> <pre><code>scala&gt; fooDecoder.decodeJson(json"""[ "Foo", "McBar", true, false, 137 ]""") res3: io.circe.Decoder.Result[Foo] = Right(Foo(Foo,McBar,137,List(true, false))) </code></pre> <p>But ugh, that's horrible. Also the error messages are completely useless:</p> <pre><code>scala&gt; fooDecoder.decodeJson(json"""[ "Foo", "McBar", true, false ]""") res4: io.circe.Decoder.Result[Foo] = Left(DecodingFailure(Int, List())) </code></pre> <p>Surely there's a way to do this that doesn't involve switching back and forth between cursors and <code>Json</code> values, throwing away history in our error messages, and just generally being an eyesore?</p> <hr> <p>Some context: questions about writing custom JSON array decoders like this in circe come up fairly often (e.g. <a href="https://gitter.im/circe/circe?at=59b53d19b59d55b823db2b" rel="noreferrer">this morning</a>). The specific details of how to do this are likely to change in an upcoming version of circe (although the API will be similar; see <a href="https://github.com/travisbrown/circe-algebra" rel="noreferrer">this experimental project</a> for some details), so I don't really want to spend a lot of time adding an example like this to the documentation, but it comes up enough that I think it does deserve a Stack Overflow Q&amp;A.</p>
0debug
static void load_asl(GArray *sdts, AcpiSdtTable *sdt) { AcpiSdtTable *temp; GError *error = NULL; GString *command_line = g_string_new(iasl); gint fd; gchar *out, *out_err; gboolean ret; int i; fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error); g_assert_no_error(error); close(fd); g_string_append_printf(command_line, " -p %s ", sdt->asl_file); for (i = 0; i < 2; ++i) { temp = &g_array_index(sdts, AcpiSdtTable, i); g_string_append_printf(command_line, "-e %s ", temp->aml_file); } g_string_append_printf(command_line, "-d %s", sdt->aml_file); g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error); g_assert_no_error(error); ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl, &sdt->asl_len, &error); g_assert(ret); g_assert_no_error(error); g_assert(sdt->asl_len); g_free(out); g_free(out_err); g_string_free(command_line, true); }
1threat
static int get_physical_address_data(CPUState *env, target_phys_addr_t *physical, int *prot, target_ulong address, int rw, int mmu_idx) { unsigned int i; uint64_t context; int is_user = (mmu_idx == MMU_USER_IDX || mmu_idx == MMU_USER_SECONDARY_IDX); if ((env->lsu & DMMU_E) == 0) { *physical = ultrasparc_truncate_physical(address); *prot = PAGE_READ | PAGE_WRITE; return 0; } switch(mmu_idx) { case MMU_USER_IDX: case MMU_KERNEL_IDX: context = env->dmmu.mmu_primary_context & 0x1fff; break; case MMU_USER_SECONDARY_IDX: case MMU_KERNEL_SECONDARY_IDX: context = env->dmmu.mmu_secondary_context & 0x1fff; break; case MMU_NUCLEUS_IDX: context = 0; break; } for (i = 0; i < 64; i++) { if (ultrasparc_tag_match(&env->dtlb[i], address, context, physical)) { if (((env->dtlb[i].tte & 0x4) && is_user) || (!(env->dtlb[i].tte & 0x2) && (rw == 1))) { uint8_t fault_type = 0; if ((env->dtlb[i].tte & 0x4) && is_user) { fault_type |= 1; } if (env->dmmu.sfsr & 1) env->dmmu.sfsr = 2; env->dmmu.sfsr |= (is_user << 3) | ((rw == 1) << 2) | 1; env->dmmu.sfsr |= (fault_type << 7); env->dmmu.sfar = address; env->exception_index = TT_DFAULT; #ifdef DEBUG_MMU printf("DFAULT at 0x%" PRIx64 "\n", address); #endif return 1; } *prot = PAGE_READ; if (env->dtlb[i].tte & 0x2) *prot |= PAGE_WRITE; TTE_SET_USED(env->dtlb[i].tte); return 0; } } #ifdef DEBUG_MMU printf("DMISS at 0x%" PRIx64 "\n", address); #endif env->dmmu.tag_access = (address & ~0x1fffULL) | context; env->exception_index = TT_DMISS; return 1; }
1threat
Add a class when click on button : <p>I have a block which has some elements. I did that elements will get new styles if I add a some class to this block. SO, can you help me with code in jQuery which add a class to my "infoBlock".</p> <p>Ihave a but need </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>li { list-style-type: none; } .infoBlock { display: block; width: 520px; height: 280px; background: #fff; margin: 50px 0 0 225px; position: relative; } .infoBlock .more { width: 180px; height: 40px; display: inline-block; background: #5795f9; text-decoration: none; font: bold 16px Helvetica; text-transform: uppercase; padding: 10px ; text-align: center; margin: 20px 0 0 0; color: #fff; } .infoBlock .person{ display: inline-block; width: 25%; } .infoBlock .person img { width: 80%; margin: 20px 0 0 20px; } .infoBlock .person ul { margin: 20px 0 0 20px; } .infoBlock .person .risk { text-transform: uppercase; color: #a6a6a6; font: bold 15px Helvetica; } .infoBlock .person .level { margin: 10px 0 0 ; color: #ff8080; font: bold 14px Helvetica; } .infoBlock .personDescription { display: inline-block; width: 74%; position: absolute; margin: 20px 0 0 20px; } .infoBlock .personDescription .name{ font:bold 20px Helvetica; color: #a6a6a6; margin: 0 0 20px; } .infoBlock .personDescription .position { font: bold 15px Helvetica; color: #5795f9; margin: 0 0 25px; } .infoBlock .personDescription .description { font: bold 14px Helvetica; color: #a6a6a6; } .infoBlock .personDescription .description span { color: #5795f9; } .infoBlock .personDescription .description .black { color: #000; } .infoBlock .fullInfo { display: none; } /* //////////////////////////// */ .infoBlock.f { height: 480px; } .infoBlock.f .fullInfo { display: block; } .infoBlock.f .person ul{ position: absolute; margin: -115px 0 0 450px; } .infoBlock.f .personDescription .description { display: none; } .infoBlock.f .border { width: 80%; height: 1px; background-color: #a4a4a4; margin: 10px 0 0 20px; position: absolute; } .infoBlock.f .personDescription .more{ display: none; } .infoBlock.f .fullInfo { position: absolute; margin: 25px 0 0 25px; } .infoBlock.f .fullInfo .infoMenu li:hover { color: #5795f9; } .infoBlock.f .fullInfo .infoMenu li{ display: inline; margin:0 30px 0 0; color: #a6a6a6; font: bold 14px Helvetica; cursor: pointer; } .infoBlock.f .fullInfo .scheme .schemeNumber { margin: 20px 0 8px 30px; font: bold 15px Arial; color: #000; } .infoBlock.f .fullInfo .scheme .chance { margin:0 0 10px 30px; font: 16px Arial; font-weight: 200; color: #000; } .infoBlock.f .fullInfo .scheme table { margin: 0 0 10px 28px; } .infoBlock.f .fullInfo .scheme table p { font: bold 15px Helvetica; } .infoBlock.f .fullInfo .scheme table .type { color: #a5a5a5; font: 15px Helvetica; } .infoBlock.f .fullInfo .scheme .problem { font: 16px Arial; color: #a5a5a5; margin: 0 0 20px 30px; } .infoBlock.f .fullInfo .scheme .more { margin: 0 0 0 30px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class = "infoBlock"&gt; &lt;div class = "person"&gt; &lt;img src="img/1.jpg" alt = ""&gt; &lt;ul&gt; &lt;li&gt;&lt;p class = "risk"&gt;авыаыа:&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p class = "level"&gt;Висоцуацуацуааукий&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class = "personDescription"&gt; &lt;h2 class = "name"&gt;Василенко&lt;br&gt; Василь Антипович&lt;/h2&gt; &lt;h4 class = "position"&gt;Авыпукпуфппук&lt;/h4&gt; &lt;p class = "description"&gt;АВаываывавыпкупк &lt;span&gt;2х схем&lt;br&gt;&lt;/span&gt; на сумму більш ніж &lt;span class = "black"&gt;3 млн. грн&lt;span&gt;&lt;/p&gt; &lt;a href="#" class = "more" &gt;докладніше&lt;/a&gt; &lt;/div&gt; &lt;div class = "fullInfo"&gt; &lt;ul class = "infoMenu"&gt; &lt;li&gt;Схеми&lt;/li&gt; &lt;li&gt;Зв'язки&lt;/li&gt; &lt;li&gt;Додаткова інформація&lt;/li&gt; &lt;/ul&gt; &lt;div class = "scheme"&gt; &lt;h3 class = "schemeNumber"&gt;Схема №1.1&lt;/h3&gt; &lt;p class = "chance"&gt;Вірогідність - 93%&lt;/p&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt;Тип:&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class = "type"&gt;авыавыавыавыа&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p class = "problem"&gt;Квартира площею 123 кв. м записана&lt;br&gt; на Василенко М.В. (теща)&lt;/p&gt; &lt;a href="#" class = "more f" &gt;докладніше&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
python for k, g in iterpools.groupby(str): list(g) will change in the 'if' statement : <p>As a newbie, I try to practice the function of groupby and see the result. However, I find a weird phenomenon。</p> <pre><code> str = 'hieeelalaooo' for k, g in groupby(str): print(list(k), list(g)) if True: print(list(k), list(g)) </code></pre> <p>The result shows that list(g) will change in the 'if' statement like below:</p> <pre><code>`['h'] ['h'] ['h'] [] ['i'] ['i'] ['i'] [] ['e'] ['e', 'e', 'e'] ['e'] [] ....` </code></pre> <p>I just can't get it. In my intuition, list(g) should be unchanged rather than becoming a empty list. Could anyone please explain the underlying logic for such change? I am really appreciated for your help.</p>
0debug
Use CAPABILITY_AUTO_EXPAND for nested stacks on CloudFormation : <p>I am trying to use nested stack and when my ChangeSet is being executed, I got this error:</p> <p><code>Requires capabilities : [CAPABILITY_AUTO_EXPAND]</code></p> <p>I went and create a pipeline with cloudformation.</p> <p>This can be use to create a pipeline:</p> <pre><code>Configuration: ActionMode: CHANGE_SET_REPLACE ChangeSetName: changeset RoleArn: ?? Capabilities: CAPABILITY_IAM StackName: appsync-graphql TemplatePath: BuildArtifact::output.yaml </code></pre> <p>This can’t:</p> <pre><code>Configuration: ActionMode: CHANGE_SET_REPLACE ChangeSetName: changeset RoleArn: ?? Capabilities: - CAPABILITY_IAM - CAPABILITY_AUTO_EXPAND StackName: appsync-graphql TemplatePath: BuildArtifact::output.yaml </code></pre> <p>The error was: “Value of property Configuration must be an object with String (or simple type) properties”</p> <p>This is the closest docs that I find: <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html" rel="noreferrer">https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html</a></p> <p>It said: <code>Type: Array of strings</code> for capabilites, and the aws cli docs says similarly, but doesn’t give an example.</p> <p>So I ran out of ideas about what else to try to have CAPABILITY_AUTO_EXPAND capability.</p>
0debug
static void test_qemu_strtoul_full_empty(void) { const char *str = ""; unsigned long res = 999; int err; err = qemu_strtoul(str, NULL, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); }
1threat
Making Sense of 'No Shadowed Variable' tslint Warning : <p>I have a function that checks for the current stage in a sequential stream, based on a particular discipline that is passed in, and, according to that value, assigns the next value in my Angular 2 app. It looks something like this:</p> <pre><code>private getNextStageStep(currentDisciplineSelected) { const nextStageStep = ''; if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 1') { const nextStageStep = 'step 2'; } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 2') { const nextStageStep = 'step 3'; } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 3') { const nextStageStep = 'step 4'; } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 4') { const nextStageStep = 'step 5'; } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 5') { const nextStageStep = 'step 6'; } return nextStageStep; } </code></pre> <p>What I'm doing here is returning the value of "nextStageStep", because that's what I'll be then passing in order for the correct stage step to happen.</p> <p>Right now, my tslint is underlining each of the "nextStageStep" variable occurrences with the warning "no shadowed variables". If I remove the line where I initialize to an empty string that warning goes away, but then I get the error, "Cannot find nextStageStep" showing up in my return statement.</p> <p>What is the issue with the original shadowed variable warning, and is there an alternative way to write this, and/or should I simply ignore the tslint warning in this situation?</p>
0debug
Is it possible to combine three strings in java using operator? : <p>can anyone help to concatenate three strings in java? For example, if there are three strings a=this b=is c=march then the result has to be concatenated as "this is march"</p>
0debug
Primeng - how to use styleClass? : <p>I want to use the <code>styleClass</code> property of the <code>Togglebutton</code> component. As described in <a href="https://stackoverflow.com/a/45499931/3063719">another post</a>, I thought it is straight forward by using:</p> <pre><code>styleClass="test" </code></pre> <p>In my css-file I then set some attributes, like </p> <pre><code>.test { background: red; } </code></pre> <p>But this does not work. Working with <code>style</code> is perfectly clear by using <code>[style]="{'background':'red'}"</code> No problem with that. But <code>styleClass</code> does not work. <a href="https://www.primefaces.org/primeng/#/togglebutton" rel="noreferrer">Here is the component</a>. Any idea how to use <code>styleClass</code>?</p>
0debug
void qmp_block_stream(const char *device, bool has_base, const char *base, bool has_backing_file, const char *backing_file, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, Error **errp) { BlockDriverState *bs; BlockDriverState *base_bs = NULL; Error *local_err = NULL; const char *base_name = NULL; if (!has_on_error) { on_error = BLOCKDEV_ON_ERROR_REPORT; } bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) { return; } if (has_base) { base_bs = bdrv_find_backing_image(bs, base); if (base_bs == NULL) { error_set(errp, QERR_BASE_NOT_FOUND, base); return; } base_name = base; } if (base_bs == NULL && has_backing_file) { error_setg(errp, "backing file specified, but streaming the " "entire chain"); return; } base_name = has_backing_file ? backing_file : base_name; stream_start(bs, base_bs, base_name, has_speed ? speed : 0, on_error, block_job_cb, bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; } trace_qmp_block_stream(bs, bs->job); }
1threat
NEON_TYPE4(s8, int8_t) NEON_TYPE4(u8, uint8_t) NEON_TYPE2(s16, int16_t) NEON_TYPE2(u16, uint16_t) NEON_TYPE1(s32, int32_t) NEON_TYPE1(u32, uint32_t) #undef NEON_TYPE4 #undef NEON_TYPE2 #undef NEON_TYPE1 #define NEON_UNPACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.i = (val); \ dest = conv_u.v; \ } while(0) #define NEON_PACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.v = (val); \ dest = conv_u.i; \ } while(0) #define NEON_DO1 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); #define NEON_DO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); #define NEON_DO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); \ NEON_FN(vdest.v3, vsrc1.v3, vsrc2.v3); \ NEON_FN(vdest.v4, vsrc1.v4, vsrc2.v4); #define NEON_VOP_BODY(vtype, n) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_DO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_VOP_ENV(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(CPUState *env, uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_PDO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc2.v1, vsrc2.v2); #define NEON_PDO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc1.v3, vsrc1.v4); \ NEON_FN(vdest.v3, vsrc2.v1, vsrc2.v2); \ NEON_FN(vdest.v4, vsrc2.v3, vsrc2.v4); \ #define NEON_POP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_PDO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP1(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg) \ { \ vtype vsrc1; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg); \ NEON_DO##n; \ NEON_PACK(vtype, arg, vdest); \ return arg; \ #define NEON_USAT(dest, src1, src2, type) do { \ uint32_t tmp = (uint32_t)src1 + (uint32_t)src2; \ if (tmp != (type)tmp) { \ SET_QC(); \ dest = ~0; \ } else { \ dest = tmp; \ }} while(0) #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint8_t) NEON_VOP_ENV(qadd_u8, neon_u8, 4) #undef NEON_FN #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint16_t) NEON_VOP_ENV(qadd_u16, neon_u16, 2) #undef NEON_FN #undef NEON_USAT
1threat
@Input and other decorators and inheritance : <p>I don't really understand how object binding works, so if anyone could explain if I can use @Input() inside a base class, or better: decorators and inheritance. For example if each form should receive a customer I have a base class:</p> <pre><code>export class AbstractCustomerForm{ @Input() customer; ... } </code></pre> <p>and then I extend this class in an actual component:</p> <pre><code>export AwesomeCustomerForm extends AbstractCustomerForm implements OnInit{ ngOnInit(){ if(this.customer) doSomething(); } } </code></pre> <p>but this won't work, customer will never get set :(</p>
0debug
long do_sigreturn(CPUX86State *env) { struct sigframe *frame; abi_ulong frame_addr = env->regs[R_ESP] - 8; target_sigset_t target_set; sigset_t set; int eax, i; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_sigreturn\n"); #endif if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; if (__get_user(target_set.sig[0], &frame->sc.oldmask)) goto badframe; for(i = 1; i < TARGET_NSIG_WORDS; i++) { if (__get_user(target_set.sig[i], &frame->extramask[i - 1])) goto badframe; } target_to_host_sigset_internal(&set, &target_set); do_sigprocmask(SIG_SETMASK, &set, NULL); if (restore_sigcontext(env, &frame->sc, &eax)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return eax; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
1threat
Python iterating through list of lists of class objects, returns that object is not iterable? : I have an initial class: class foo: def __init__(self, a, b): self.a = a self.b = b And another class which uses the foo class: class bar: def __init__(self, foos): self.foos = sorted(foos, key=attrgetter('a')) where foos is a list of foo. I now want to take a list of list of foo, something that looks like lofoos = [[foo1, foo2, foo3], [foo4, foo5, foo6] ...] and I want to use the map function to do this: list(map(lambda foos: bar(foos), lofoos)) But this returns the error: TypeError: iter() returned non-iterator of type 'foo'. Is there an easy solution to this?
0debug
a simple question about def function (if word starts with "pre" return "valid) : I am a beginner. Could you please help me to check what's wrong with my code. Thank you very much!!! question: ask people to enter a word, if it starts with "pre" return "valid". otherwise, print "not valid". def word_fun(word): word = input("enter a word: ").lower() if word.startswith("pre") and word.isalpha: print("valid") else: print("not valid") word_fun(word)
0debug
In C programming, can a string be outputted after a variable? (One line with printf) : Trying to print a string before and after a variable. Does C have the capability to use one statement to display this output? This works: float value = 5; printf("\nThe value of %f", value"); printf(" is greater than zero."); This is the desire (one statement) float value = 5; printf("\nThe value of %f", value, " is greater than zero."); (Second string does not display)
0debug
static void xics_common_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc->reset = xics_common_reset; }
1threat
How to remove date format from a line in a txt files using a java scrip : I have a .txt file with thousands of line. Each line starts with a different date e.g. 07/23/1999. I want to write a program to be able to delete the date from each line. I'll be using a BufferedReader/writer and scanner. How can I find this type of date and deleted? Thanks in advance.
0debug
What's the right way to rotate an object around a point in three.js? : <p>Most tutorials/questions about three.js suggest the way to rotate an object around a point using three.js is to create a parent object at the position you want to rotate around, attach your object, and then move the child. Then when the parent is rotated the child rotates around the point. Eg;</p> <pre class="lang-js prettyprint-override"><code>//Make a pivot var pivot = new THREE.Object3D(); //Make an object var object = new THREE.Mesh( new THREE.BoxGeometry(2,2,2), new THREE.MeshBasicMaterial() ); //Add object to pivot pivot.add(object); //Move object away from pivot object.position.set(new THREE.Vector3(5,0,0)); //rotate the object 90 degrees around pivot pivot.rotation.y = Math.PI / 2; </code></pre> <p>This works but it's incredibly limiting - if you want to rotate an object around a different point you can't because an object can't have two parents.</p> <p>The next method that works is applying a rotated matrix to the object's position, e.g.;</p> <pre class="lang-js prettyprint-override"><code>//Make an object var object = new THREE.Mesh( new THREE.BoxGeometry(2,2,2), new THREE.MeshBasicMaterial() ); //Move the object object.position.set(new THREE.Vector3(5,0,0); //Create a matrix var matrix = new THREE.Matrix4(); //Rotate the matrix matrix.makeRotationY(Math.PI / 2); //rotate the object using the matrix object.position.applyMatrix4(matrix); </code></pre> <p>Again, this works, but there doesn't appear to be a way to set the point of rotation. It's always the origin of the world. </p> <p>Another option is a utility method in sceneUtils to detach a child from a parent object and another method to attach a new parent, but the documentation for that warns against using it, and it's never used in any example code.</p> <p>Ultimately I want to be able to make a cube follow an S shaped path, but without this (seemingly) basic thing I'm finding it rather difficult.</p> <p>tl;dr I want to rotate a three.js object around a series of different points. What would be a good way to approach that?</p>
0debug
static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_S12NSE0: case ARMMMUIdx_S12NSE1: case ARMMMUIdx_S1NSE0: case ARMMMUIdx_S1NSE1: case ARMMMUIdx_S1E2: case ARMMMUIdx_S2NS: return false; case ARMMMUIdx_S1E3: case ARMMMUIdx_S1SE0: case ARMMMUIdx_S1SE1: return true; default: g_assert_not_reached(); } }
1threat
static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t * const buf, int buf_size) { H264ParseContext *p = s->priv_data; H2645NAL nal = { NULL }; int buf_index, next_avc; unsigned int pps_id; unsigned int slice_type; int state = -1, got_reset = 0; int q264 = buf_size >=4 && !memcmp("Q264", buf, 4); int field_poc[2]; int ret; s->pict_type = AV_PICTURE_TYPE_I; s->key_frame = 0; s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; ff_h264_sei_uninit(&p->sei); p->sei.frame_packing.frame_packing_arrangement_cancel_flag = -1; if (!buf_size) return 0; buf_index = 0; next_avc = p->is_avc ? 0 : buf_size; for (;;) { const SPS *sps; int src_length, consumed, nalsize = 0; if (buf_index >= next_avc) { nalsize = get_nalsize(p->nal_length_size, buf, buf_size, &buf_index, avctx); if (nalsize < 0) break; next_avc = buf_index + nalsize; } else { buf_index = find_start_code(buf, buf_size, buf_index, next_avc); if (buf_index >= buf_size) break; if (buf_index >= next_avc) continue; } src_length = next_avc - buf_index; state = buf[buf_index]; switch (state & 0x1f) { case H264_NAL_SLICE: case H264_NAL_IDR_SLICE: if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) { if (src_length > 60) src_length = 60; } else { if (src_length > 1000) src_length = 1000; } break; } consumed = ff_h2645_extract_rbsp(buf + buf_index, src_length, &nal, 1); if (consumed < 0) break; buf_index += consumed; ret = init_get_bits8(&nal.gb, nal.data, nal.size); if (ret < 0) goto fail; get_bits1(&nal.gb); nal.ref_idc = get_bits(&nal.gb, 2); nal.type = get_bits(&nal.gb, 5); switch (nal.type) { case H264_NAL_SPS: ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps, 0); break; case H264_NAL_PPS: ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps, nal.size_bits); break; case H264_NAL_SEI: ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx); break; case H264_NAL_IDR_SLICE: s->key_frame = 1; p->poc.prev_frame_num = 0; p->poc.prev_frame_num_offset = 0; p->poc.prev_poc_msb = p->poc.prev_poc_lsb = 0; case H264_NAL_SLICE: get_ue_golomb_long(&nal.gb); slice_type = get_ue_golomb_31(&nal.gb); s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5]; if (p->sei.recovery_point.recovery_frame_cnt >= 0) { s->key_frame = 1; } pps_id = get_ue_golomb(&nal.gb); if (pps_id >= MAX_PPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id); goto fail; } if (!p->ps.pps_list[pps_id]) { av_log(avctx, AV_LOG_ERROR, "non-existing PPS %u referenced\n", pps_id); goto fail; } av_buffer_unref(&p->ps.pps_ref); av_buffer_unref(&p->ps.sps_ref); p->ps.pps = NULL; p->ps.sps = NULL; p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]); if (!p->ps.pps_ref) goto fail; p->ps.pps = (const PPS*)p->ps.pps_ref->data; if (!p->ps.sps_list[p->ps.pps->sps_id]) { av_log(avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", p->ps.pps->sps_id); goto fail; } p->ps.sps_ref = av_buffer_ref(p->ps.sps_list[p->ps.pps->sps_id]); if (!p->ps.sps_ref) goto fail; p->ps.sps = (const SPS*)p->ps.sps_ref->data; sps = p->ps.sps; if (p->ps.sps->ref_frame_count <= 1 && p->ps.pps->ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I) s->key_frame = 1; p->poc.frame_num = get_bits(&nal.gb, sps->log2_max_frame_num); s->coded_width = 16 * sps->mb_width; s->coded_height = 16 * sps->mb_height; s->width = s->coded_width - (sps->crop_right + sps->crop_left); s->height = s->coded_height - (sps->crop_top + sps->crop_bottom); if (s->width <= 0 || s->height <= 0) { s->width = s->coded_width; s->height = s->coded_height; } switch (sps->bit_depth_luma) { case 9: if (sps->chroma_format_idc == 3) s->format = AV_PIX_FMT_YUV444P9; else if (sps->chroma_format_idc == 2) s->format = AV_PIX_FMT_YUV422P9; else s->format = AV_PIX_FMT_YUV420P9; break; case 10: if (sps->chroma_format_idc == 3) s->format = AV_PIX_FMT_YUV444P10; else if (sps->chroma_format_idc == 2) s->format = AV_PIX_FMT_YUV422P10; else s->format = AV_PIX_FMT_YUV420P10; break; case 8: if (sps->chroma_format_idc == 3) s->format = AV_PIX_FMT_YUV444P; else if (sps->chroma_format_idc == 2) s->format = AV_PIX_FMT_YUV422P; else s->format = AV_PIX_FMT_YUV420P; break; default: s->format = AV_PIX_FMT_NONE; } avctx->profile = ff_h264_get_profile(sps); avctx->level = sps->level_idc; if (sps->frame_mbs_only_flag) { p->picture_structure = PICT_FRAME; } else { if (get_bits1(&nal.gb)) { p->picture_structure = PICT_TOP_FIELD + get_bits1(&nal.gb); } else { p->picture_structure = PICT_FRAME; } } if (nal.type == H264_NAL_IDR_SLICE) get_ue_golomb_long(&nal.gb); if (sps->poc_type == 0) { p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb); if (p->ps.pps->pic_order_present == 1 && p->picture_structure == PICT_FRAME) p->poc.delta_poc_bottom = get_se_golomb(&nal.gb); } if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { p->poc.delta_poc[0] = get_se_golomb(&nal.gb); if (p->ps.pps->pic_order_present == 1 && p->picture_structure == PICT_FRAME) p->poc.delta_poc[1] = get_se_golomb(&nal.gb); } field_poc[0] = field_poc[1] = INT_MAX; ff_h264_init_poc(field_poc, &s->output_picture_number, sps, &p->poc, p->picture_structure, nal.ref_idc); if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) { got_reset = scan_mmco_reset(s, &nal.gb, avctx); if (got_reset < 0) goto fail; } p->poc.prev_frame_num = got_reset ? 0 : p->poc.frame_num; p->poc.prev_frame_num_offset = got_reset ? 0 : p->poc.frame_num_offset; if (nal.ref_idc != 0) { if (!got_reset) { p->poc.prev_poc_msb = p->poc.poc_msb; p->poc.prev_poc_lsb = p->poc.poc_lsb; } else { p->poc.prev_poc_msb = 0; p->poc.prev_poc_lsb = p->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0]; } } if (sps->pic_struct_present_flag) { switch (p->sei.picture_timing.pic_struct) { case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: s->repeat_pict = 0; break; case SEI_PIC_STRUCT_FRAME: case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: s->repeat_pict = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: s->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: s->repeat_pict = 3; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: s->repeat_pict = 5; break; default: s->repeat_pict = p->picture_structure == PICT_FRAME ? 1 : 0; break; } } else { s->repeat_pict = p->picture_structure == PICT_FRAME ? 1 : 0; } if (p->picture_structure == PICT_FRAME) { s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; if (sps->pic_struct_present_flag) { switch (p->sei.picture_timing.pic_struct) { case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: s->field_order = AV_FIELD_TT; break; case SEI_PIC_STRUCT_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: s->field_order = AV_FIELD_BB; break; default: s->field_order = AV_FIELD_PROGRESSIVE; break; } } else { if (field_poc[0] < field_poc[1]) s->field_order = AV_FIELD_TT; else if (field_poc[0] > field_poc[1]) s->field_order = AV_FIELD_BB; else s->field_order = AV_FIELD_PROGRESSIVE; } } else { if (p->picture_structure == PICT_TOP_FIELD) s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD; else s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD; if (p->poc.frame_num == p->last_frame_num && p->last_picture_structure != AV_PICTURE_STRUCTURE_UNKNOWN && p->last_picture_structure != AV_PICTURE_STRUCTURE_FRAME && p->last_picture_structure != s->picture_structure) { if (p->last_picture_structure == AV_PICTURE_STRUCTURE_TOP_FIELD) s->field_order = AV_FIELD_TT; else s->field_order = AV_FIELD_BB; } else { s->field_order = AV_FIELD_UNKNOWN; } p->last_picture_structure = s->picture_structure; p->last_frame_num = p->poc.frame_num; } av_freep(&nal.rbsp_buffer); return 0; } } if (q264) { av_freep(&nal.rbsp_buffer); return 0; } av_log(avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size); fail: av_freep(&nal.rbsp_buffer); return -1; }
1threat
simplest python equivalent to R's gsub : <p>Is there a simple/one-line python equivalent to R's <code>gsub</code> function?</p> <pre><code>strings = c("Important text, !Comment that could be removed", "Other String") gsub("(,[ ]*!.*)$", "", strings) # [1] "Important text" "Other String" </code></pre>
0debug
static void loop_filter(H264Context *h, int start_x, int end_x){ MpegEncContext * const s = &h->s; uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize, mb_x, mb_y; const int end_mb_y= s->mb_y + FRAME_MBAFF; const int old_slice_type= h->slice_type; const int pixel_shift = h->pixel_shift; if(h->deblocking_filter) { for(mb_x= start_x; mb_x<end_x; mb_x++){ for(mb_y=end_mb_y - FRAME_MBAFF; mb_y<= end_mb_y; mb_y++){ int mb_xy, mb_type; mb_xy = h->mb_xy = mb_x + mb_y*s->mb_stride; h->slice_num= h->slice_table[mb_xy]; mb_type= s->current_picture.mb_type[mb_xy]; h->list_count= h->list_counts[mb_xy]; if(FRAME_MBAFF) h->mb_mbaff = h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type); s->mb_x= mb_x; s->mb_y= mb_y; dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; if (MB_FIELD) { linesize = h->mb_linesize = s->linesize * 2; uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; if(mb_y&1){ dest_y -= s->linesize*15; dest_cb-= s->uvlinesize*7; dest_cr-= s->uvlinesize*7; } } else { linesize = h->mb_linesize = s->linesize; uvlinesize = h->mb_uvlinesize = s->uvlinesize; } backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0); if(fill_filter_caches(h, mb_type)) continue; h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.qscale_table[mb_xy]); h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.qscale_table[mb_xy]); if (FRAME_MBAFF) { ff_h264_filter_mb (h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize); } else { ff_h264_filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize); } } } } h->slice_type= old_slice_type; s->mb_x= 0; s->mb_y= end_mb_y - FRAME_MBAFF; h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale); h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale); }
1threat
python logging performance comparison and options : <p>I am researching high performance logging in Python and so far have been disappointed by the performance of the python standard logging module - but there seem to be no alternatives. Below is a piece of code to performance test 4 different ways of logging:</p> <pre><code>import logging import timeit import time import datetime from logutils.queue import QueueListener, QueueHandler import Queue import threading tmpq = Queue.Queue() def std_manual_threading(): start = datetime.datetime.now() logger = logging.getLogger() hdlr = logging.FileHandler('std_manual.out', 'w') logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) def logger_thread(f): while True: item = tmpq.get(0.1) if item == None: break logging.info(item) f = open('manual.out', 'w') lt = threading.Thread(target=logger_thread, args=(f,)) lt.start() for i in range(100000): tmpq.put("msg:%d" % i) tmpq.put(None) lt.join() print datetime.datetime.now() - start def nonstd_manual_threading(): start = datetime.datetime.now() def logger_thread(f): while True: item = tmpq.get(0.1) if item == None: break f.write(item+"\n") f = open('manual.out', 'w') lt = threading.Thread(target=logger_thread, args=(f,)) lt.start() for i in range(100000): tmpq.put("msg:%d" % i) tmpq.put(None) lt.join() print datetime.datetime.now() - start def std_logging_queue_handler(): start = datetime.datetime.now() q = Queue.Queue(-1) logger = logging.getLogger() hdlr = logging.FileHandler('qtest.out', 'w') ql = QueueListener(q, hdlr) # Create log and set handler to queue handle root = logging.getLogger() root.setLevel(logging.DEBUG) # Log level = DEBUG qh = QueueHandler(q) root.addHandler(qh) ql.start() for i in range(100000): logging.info("msg:%d" % i) ql.stop() print datetime.datetime.now() - start def std_logging_single_thread(): start = datetime.datetime.now() logger = logging.getLogger() hdlr = logging.FileHandler('test.out', 'w') logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) for i in range(100000): logging.info("msg:%d" % i) print datetime.datetime.now() - start if __name__ == "__main__": """ Conclusion: std logging about 3 times slower so for 100K lines simple file write is ~1 sec while std logging ~3. If threads are introduced some overhead causes to go to ~4 and if QueueListener and events are used with enhancement for thread sleeping that goes to ~5 (probably because log records are being inserted into queue). """ print "Testing" #std_logging_single_thread() # 3.4 std_logging_queue_handler() # 7, 6, 7 (5 seconds with sleep optimization) #nonstd_manual_threading() # 1.08 #std_manual_threading() # 4.3 </code></pre> <ol> <li>The nonstd_manual_threading option works best since there is no overhead of the logging module but obviously you miss out on a lot of features such as formatters, filters and the nice interface</li> <li>The std_logging in a single thread is the next best thing but still about 3 times slower than nonstd manual threading. </li> <li>The std_manual_threading option dumps messages into a threadsafe queue and in a separate thread uses the standard logging module. That comes out to be about 25% higher than option 2, probably due to context switching costs.</li> <li>Finally, the option using "logutils"'s QueueHandler comes out to be the most expensive. I tweaked the code of logutils/queue.py's _monitor method to sleep for 10 millis after processing 500 messages as long as there are less than 100K messages in the queue. That brings the runtime down from 7 seconds to 5 seconds (probably due to avoiding context switching costs).</li> </ol> <p>My question is, why is there so much performance overhead with the logging module and are there any alternatives? Being a performance sensitive app does it even make sense to use the logging module?</p> <p>p.s.: I have profiled the different scenarios and seems like LogRecord creation is expensive.</p>
0debug
Passing arguments to npm script in package.json : <p>Is there a way to pass arguments inside of the package.json command?</p> <p>My script:</p> <pre><code>"scripts": { "test": "node mytest.js $1 $2 | node_modules/tap-difflet/bin/tap-difflet" } </code></pre> <p>cli <code>npm run test 8080 production</code></p> <p>Then on <code>mytest.js</code> I'd like to get the arguments with <code>process.argv</code></p>
0debug
Error:Your requirements could not be resolved to an installable set of packages.(on server) : <p>I am using laravel 5.3 for my project.Now I am setting it up to the server.</p> <p>The problem occured when doing so.And i am stuck at this point of error.</p> <p>WHEN I run </p> <blockquote> <p>composer install --no-dev</p> </blockquote> <p>command following error occurs:</p> <pre><code> Problem 1 - Installation request for fgrosse/phpasn1 1.5.2 -&gt; satisfiable by fgrosse/phpasn1[1.5.2]. - fgrosse/phpasn1 1.5.2 requires ext-gmp * -&gt; the requested PHP extension gmp is missing from your system. Problem 2 - Installation request for mdanter/ecc v0.4.2 -&gt; satisfiable by mdanter/ecc[v0.4.2]. - mdanter/ecc v0.4.2 requires ext-gmp * -&gt; the requested PHP extension gmp is missing from your system. Problem 3 - Installation request for pusher/pusher-php-server 2.6.3 -&gt; satisfiable by pusher/pusher-php-server[2.6.3]. - pusher/pusher-php-server 2.6.3 requires ext-curl * -&gt; the requested PHP extension curl is missing from your system. Problem 4 - pusher/pusher-php-server 2.6.3 requires ext-curl * -&gt; the requested PHP extension curl is missing from your system. - laravel-notification-channels/pusher-push-notifications 1.0.2 requires pusher/pusher-php-server 2.6.* -&gt; satisfiable by pusher/pusher-php-server[2.6.3]. - Installation request for laravel-notification-channels/pusher-push-notifications 1.0.2 -&gt; satisfiable by laravel-notification-channels/pusher-push-notifications[1.0.2]. To enable extensions, verify that they are enabled in your .ini files: - /etc/php/7.0/cli/php.ini - /etc/php/7.0/cli/conf.d/10-mysqlnd.ini - /etc/php/7.0/cli/conf.d/10-opcache.ini - /etc/php/7.0/cli/conf.d/10-pdo.ini - /etc/php/7.0/cli/conf.d/20-calendar.ini - /etc/php/7.0/cli/conf.d/20-ctype.ini - /etc/php/7.0/cli/conf.d/20-exif.ini - /etc/php/7.0/cli/conf.d/20-fileinfo.ini - /etc/php/7.0/cli/conf.d/20-ftp.ini - /etc/php/7.0/cli/conf.d/20-gettext.ini - /etc/php/7.0/cli/conf.d/20-iconv.ini - /etc/php/7.0/cli/conf.d/20-json.ini - /etc/php/7.0/cli/conf.d/20-mbstring.ini - /etc/php/7.0/cli/conf.d/20-mysqli.ini - /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini - /etc/php/7.0/cli/conf.d/20-phar.ini - /etc/php/7.0/cli/conf.d/20-posix.ini - /etc/php/7.0/cli/conf.d/20-readline.ini - /etc/php/7.0/cli/conf.d/20-shmop.ini - /etc/php/7.0/cli/conf.d/20-sockets.ini - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini - /etc/php/7.0/cli/conf.d/20-sysvsem.ini - /etc/php/7.0/cli/conf.d/20-sysvshm.ini - /etc/php/7.0/cli/conf.d/20-tokenizer.ini You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode. </code></pre> <p>`</p>
0debug
static void dec_null(DisasContext *dc) { qemu_log ("unknown insn pc=%x opc=%x\n", dc->pc, dc->opcode); dc->abort_at_next_insn = 1;
1threat
How to create a new project on Github, then push the project from my computer : <p>I cannot find the walkthrough I used to check when pushing a new project with git command. I remember logging on to GitHub.com, creating a project. Then do git init, git -add something.. THen i cannot remember the rest of the operations. Can someone give me the list or if the page with the walkthrough URL still exists perhaps send me the link?</p> <p>Searching on GitHub.com and Git-Scm.com</p> <p>git init git add *</p> <p>I expected a new GitHub repo with all files in a folder pushed up to it. The manual is complicated.</p>
0debug
static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) { int dc = (block[0] + 32) >> 6; __asm__ volatile( "movd %0, %%mm0 \n\t" "pshufw $0, %%mm0, %%mm0 \n\t" "pxor %%mm1, %%mm1 \n\t" "psubw %%mm0, %%mm1 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm1, %%mm1 \n\t" ::"r"(dc) ); __asm__ volatile( "movd %0, %%mm2 \n\t" "movd %1, %%mm3 \n\t" "movd %2, %%mm4 \n\t" "movd %3, %%mm5 \n\t" "paddusb %%mm0, %%mm2 \n\t" "paddusb %%mm0, %%mm3 \n\t" "paddusb %%mm0, %%mm4 \n\t" "paddusb %%mm0, %%mm5 \n\t" "psubusb %%mm1, %%mm2 \n\t" "psubusb %%mm1, %%mm3 \n\t" "psubusb %%mm1, %%mm4 \n\t" "psubusb %%mm1, %%mm5 \n\t" "movd %%mm2, %0 \n\t" "movd %%mm3, %1 \n\t" "movd %%mm4, %2 \n\t" "movd %%mm5, %3 \n\t" :"+m"(*(uint32_t*)(dst+0*stride)), "+m"(*(uint32_t*)(dst+1*stride)), "+m"(*(uint32_t*)(dst+2*stride)), "+m"(*(uint32_t*)(dst+3*stride)) ); }
1threat
obtain the index of elements in a list that satisfy a condition : <p>I am trying to index the positions of a list of integers to obtain the position of the intergers that are >0.</p> <p>This is my list:</p> <pre><code>paying=[0,0,0,1,0,3,4,0,5] </code></pre> <p>And this is the desired output:</p> <pre><code>[3,5,6,8] rdo=paying[paying&gt;0] </code></pre> <p>and tried:</p> <pre><code>rdo=paying.index(paying&gt;0) </code></pre> <p>The output is in both cases </p> <pre><code>typeerror &gt; not suported between instances of list and int </code></pre>
0debug
static void uart_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { UartState *s = (UartState *)opaque; DB_PRINT(" offset:%x data:%08x\n", offset, (unsigned)value); offset >>= 2; switch (offset) { case R_IER: s->r[R_IMR] |= value; break; case R_IDR: s->r[R_IMR] &= ~value; break; case R_IMR: break; case R_CISR: s->r[R_CISR] &= ~value; break; case R_TX_RX: switch (s->r[R_MR] & UART_MR_CHMODE) { case NORMAL_MODE: uart_write_tx_fifo(s, (uint8_t *) &value, 1); break; case LOCAL_LOOPBACK: uart_write_rx_fifo(opaque, (uint8_t *) &value, 1); break; } break; default: s->r[offset] = value; } switch (offset) { case R_CR: uart_ctrl_update(s); break; case R_MR: uart_parameters_setup(s); break; } }
1threat
static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); sPAPRPHBClass *spc = SPAPR_PCI_HOST_BRIDGE_CLASS(klass); dc->props = spapr_phb_vfio_properties; spc->finish_realize = spapr_phb_vfio_finish_realize; }
1threat
How to remove QueryDict from Dictionary in python2.7? : <p>This is my dictionary</p> <pre><code>&lt;QueryDict: {u'karnataka': [u'bangalore', u'tumkur']}&gt; </code></pre> <p>I want to remove the QueryDict and i want as </p> <pre><code>{u'karnataka': [u'bangalore', u'tumkur']} </code></pre>
0debug
static av_cold int bfi_decode_init(AVCodecContext *avctx) { BFIContext *bfi = avctx->priv_data; avctx->pix_fmt = AV_PIX_FMT_PAL8; bfi->dst = av_mallocz(avctx->width * avctx->height); return 0; }
1threat
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) { BdrvDirtyBitmap *bm; BlockDirtyInfoList *list = NULL; BlockDirtyInfoList **plist = &list; QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) { BlockDirtyInfo *info = g_malloc0(sizeof(BlockDirtyInfo)); BlockDirtyInfoList *entry = g_malloc0(sizeof(BlockDirtyInfoList)); info->count = bdrv_get_dirty_count(bs, bm); info->granularity = ((int64_t) BDRV_SECTOR_SIZE << hbitmap_granularity(bm->bitmap)); entry->value = info; *plist = entry; plist = &entry->next; } return list; }
1threat
Is it possible for a NavigationLink to perform an action in addition to navigating to another view? : <p>I'm trying to create a button that not only navigates to another view, but also run a function at the same time. I tried embedding both a NavigationLink and a Button into a Stack, but I'm only able to click on the Button.</p> <pre><code> ZStack { NavigationLink(destination: TradeView(trade: trade)) { TradeButton() } Button(action: { print("Hello world!") //this is the only thing that runs }) { TradeButton() } } </code></pre>
0debug
list of tuples to list of dictionary : I have a list like [ [('a' , 'b'), ('c' , 'd')] , [('e' , 'f') , ('g' , 'h')] ]. I want the output to be like a list of dictionaries [ {'a' : 'b', 'c' : 'd' } , {'e' : 'f' , 'g' : 'h'} ]. How to parse it to get the output?
0debug
(Python) Returning specific values in a string of different format : How do I make python automatically searches a certain specific type of data (e.g date) in a string of different format ? For example, For unix values such as -rwxr-xr-x 1 user usergrp 1632 Feb 26 11:03 Desktop/Application, it should return 26 Feb 19 For values such as Desktop/Application,1632,26/02, it should search out for “26/02” and return 26 Feb 19 For values such as 26/02/19 - Desktop/Application - 1632, it should search out for “26/02/19” and return 26 Feb 19 Appreciate all help provided, thank you everyone!
0debug
In Perl, how to deference temp hash passed as argument? : In Perl, how to deference temporary hash passed as argument to function? MyFunct({ Param1 => “knob1”, Param2 => “knob2” }); # this part never seems to work... sub MyFunct { my %param = %{shift()}; my $p1 = $param{Param1}; print “p1: $p1\n”; }
0debug
ListVew doesn't show anything : I try to retrieve data from firebase and use an adapter to show them in listview. Everything is ok with retrieving data, I checked through debugger, however nothing is shown. Here is *resource_layout.xml* <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/borders"> <ListView android:id="@+id/listViewBooks" android:layout_weight="1" android:layout_height="0dp" android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" /> </RelativeLayout> *resource_item.xml* ?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> <TextView android:id="@+id/author" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> <TextView android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> </LinearLayout> *ResourceAdapter.java* public class ResourceAdapter extends ArrayAdapter<Books> { private Activity context; private List<Books> bookList; public ResourceAdapter(Activity context, List<Books> bookList){ super(context, R.layout.resource_item, bookList); this.context = context; this.bookList = bookList; } @NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View listViewItem = inflater.inflate(R.layout.resource_item, null, true); TextView textViewName = (TextView) listViewItem.findViewById(R.id.name); TextView textViewAuthor = (TextView) listViewItem.findViewById(R.id.author); TextView textViewDate = (TextView) listViewItem.findViewById(R.id.date); Books book = bookList.get(position); textViewName.setText(book.getName()); textViewAuthor.setText(book.getAuthor()); textViewDate.setText(String.valueOf(book.getDate())); return listViewItem; } } *Resource.Java* public class Resource extends AppCompatActivity { DatabaseReference databaseBooks; ListView listViewBooks; List<Books> bookList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.resource_layout); databaseBooks = FirebaseDatabase.getInstance().getReference("books"); bookList = new ArrayList<>(); listViewBooks = (ListView) findViewById(R.id.listViewBooks); } @Override protected void onStart() { super.onStart(); databaseBooks.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { bookList.clear(); for (DataSnapshot bookSnapshot : dataSnapshot.getChildren()){ Books book = bookSnapshot.getValue(Books.class); bookList.add(book); } ResourceAdapter adapter = new ResourceAdapter(Resource.this, bookList); listViewBooks.setAdapter(adapter); } @Override public void onCancelled(DatabaseError databaseError) { } }); } }
0debug
Read txt with delimeter and multiple spaces : <p>I have a text file where the delimiter is '&amp;'. However, the first column is text and may contain spaces as well - How can I properly read it ? The text looks like</p> <pre><code>selection according to criteria A &amp; 2312 </code></pre> <p>some other selection according to criteria B &amp; 345</p> <p>Please note that the text in first column can contain more than one word (ie more spaces from one to another line). I ve tried something</p> <pre><code>char ch; ch="&amp;"; ifstream filein; filein.open("selection.txt"); while (1) { data &gt;&gt; c1 &gt;&gt; char &gt;&gt;c2 ; cut1.push_back(c1); cut2.push_back(c2); if (!data.good()) break; } </code></pre> <p>but this does not work... </p> <p>thanks in advance</p>
0debug
static void rtas_ibm_slot_error_detail(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { sPAPRPHBState *sphb; sPAPRPHBClass *spc; int option; uint64_t buid; if ((nargs != 8) || (nret != 1)) { goto param_error_exit; } buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); sphb = find_phb(spapr, buid); if (!sphb) { goto param_error_exit; } spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb); if (!spc->eeh_set_option) { goto param_error_exit; } option = rtas_ld(args, 7); switch (option) { case RTAS_SLOT_TEMP_ERR_LOG: case RTAS_SLOT_PERM_ERR_LOG: break; default: goto param_error_exit; } rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND); return; param_error_exit: rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); }
1threat
Error: Cannot implicitly convert type 'void' to 'System.Threading.Thread' : <p>The following code demonstrate two ways of creating a thread that does the same job, but only one works while the other doesn't. The difference, from what I see, is declaration of a variable - could someone help explain why this leads to <code>Error: Cannot implicitly convert type 'void' to 'System.Threading.Thread'</code>?</p> <pre><code>public MainWindow() { InitializeComponent(); // Runs OK new Thread(() =&gt; { MessageBox.Show("foo");}).Start(); // Error: Cannot implicitly convert type 'void' to 'System.Threading.Thread' Thread t = new Thread(() =&gt; { MessageBox.Show("foo”); }).Start(); } </code></pre>
0debug
Import excel data using angular js : <p>I am currently working on a web-application using angularjs.I want to import data from excel sheet using angularjs and add it into the ng-grid.Please give me possible solutions.</p>
0debug
GKMinmaxStrategist doesn't return any moves : <p>I have the following code in my <code>main.swift</code>:</p> <pre><code>let strategist = GKMinmaxStrategist() strategist.gameModel = position strategist.maxLookAheadDepth = 1 strategist.randomSource = nil let move = strategist.bestMoveForActivePlayer() </code></pre> <p>...where <code>position</code> is an instance of my <code>GKGameModel</code> subclass <code>Position</code>. After this code is run, <code>move</code> is <code>nil</code>. <code>bestMoveForPlayer(position.activePlayer!)</code> also results in <code>nil</code> (but <code>position.activePlayer!</code> results in a <code>Player</code> object).</p> <p>However,</p> <pre><code>let moves = position.gameModelUpdatesForPlayer(position.activePlayer!)! </code></pre> <p>results in a non-empty array of possible moves. From Apple's documentation (about <code>bestMoveForPlayer(_:)</code>):</p> <blockquote> <p>Returns nil if the player is invalid, the player is not a part of the game model, or the player has no valid moves available.</p> </blockquote> <p>As far as I know, none of this is the case, but the function still returns <code>nil</code>. What could be going on here?</p> <p>If it can be of any help, here's my implementation of the <code>GKGameModel</code> protocol:</p> <pre><code>var players: [GKGameModelPlayer]? = [Player.whitePlayer, Player.blackPlayer] var activePlayer: GKGameModelPlayer? { return playerToMove } func setGameModel(gameModel: GKGameModel) { let position = gameModel as! Position pieces = position.pieces ply = position.ply reloadLegalMoves() } func gameModelUpdatesForPlayer(thePlayer: GKGameModelPlayer) -&gt; [GKGameModelUpdate]? { let player = thePlayer as! Player let moves = legalMoves(ofPlayer: player) return moves.count &gt; 0 ? moves : nil } func applyGameModelUpdate(gameModelUpdate: GKGameModelUpdate) { let move = gameModelUpdate as! Move playMove(move) } func unapplyGameModelUpdate(gameModelUpdate: GKGameModelUpdate) { let move = gameModelUpdate as! Move undoMove(move) } func scoreForPlayer(thePlayer: GKGameModelPlayer) -&gt; Int { let player = thePlayer as! Player var score = 0 for (_, piece) in pieces { score += piece.player == player ? 1 : -1 } return score } func isLossForPlayer(thePlayer: GKGameModelPlayer) -&gt; Bool { let player = thePlayer as! Player return legalMoves(ofPlayer: player).count == 0 } func isWinForPlayer(thePlayer: GKGameModelPlayer) -&gt; Bool { let player = thePlayer as! Player return isLossForPlayer(player.opponent) } func copyWithZone(zone: NSZone) -&gt; AnyObject { let copy = Position(withPieces: pieces.map({ $0.1 }), playerToMove: playerToMove) copy.setGameModel(self) return copy } </code></pre> <p>If there's any other code I should show, let me know.</p>
0debug
i can't find my saved android sdk in preference in eclipse : <p>I'm at chapter 2 of android application development for dummies:prepping your development headquarters, and in a step it tells me to set sdk location but it can't find it but i did the step to put it in my environmental variable. How do i find it.</p>
0debug
What is the difference between Copy Files vs Publish Artifact task in VSTS? : <p>In my <code>Copy Files</code> task, I am copying the required files to the file share location from which I will be doing the deployment. What is the use of publishing artifact step? Or it is obsolete in my case. I am confused about the what values should be put in the boxes. </p> <p><a href="https://i.stack.imgur.com/ELF1R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ELF1R.png" alt="enter image description here"></a></p>
0debug
Preemptive Priority CPU scheduling Algorithm : <p>Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period and the available tasks are scheduled in order of priority, with the highest priority task scheduled first. Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st milliseconds and task preemptions are allowed, the first instance of T3 completes its execution at the end of ______________ milliseconds.</p> <p>========================================================================</p> <p><strong>My Take</strong> - I took that beginning of 1st ms means all the process arrives at time = 1 and 0 to 1 time is IDLE. and when I take the gantt chart I get answer as 13, whereas answer = 12 </p>
0debug
static int cdg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { GetByteContext gb; int buf_size = avpkt->size; int ret; uint8_t command, inst; uint8_t cdg_data[CDG_DATA_SIZE]; AVFrame *frame = data; CDGraphicsContext *cc = avctx->priv_data; bytestream2_init(&gb, avpkt->data, avpkt->size); ret = ff_reget_buffer(avctx, cc->frame); if (ret) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } if (!avctx->frame_number) memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height); command = bytestream2_get_byte(&gb); inst = bytestream2_get_byte(&gb); inst &= CDG_MASK; bytestream2_skip(&gb, 2); bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data)); if ((command & CDG_MASK) == CDG_COMMAND) { switch (inst) { case CDG_INST_MEMORY_PRESET: if (!(cdg_data[1] & 0x0F)) memset(cc->frame->data[0], cdg_data[0] & 0x0F, cc->frame->linesize[0] * CDG_FULL_HEIGHT); break; case CDG_INST_LOAD_PAL_LO: case CDG_INST_LOAD_PAL_HIGH: if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) { av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n"); return AVERROR(EINVAL); } cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO); break; case CDG_INST_BORDER_PRESET: cdg_border_preset(cc, cdg_data); break; case CDG_INST_TILE_BLOCK_XOR: case CDG_INST_TILE_BLOCK: if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) { av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n"); return AVERROR(EINVAL); } ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR); if (ret) { av_log(avctx, AV_LOG_ERROR, "tile is out of range\n"); return ret; } break; case CDG_INST_SCROLL_PRESET: case CDG_INST_SCROLL_COPY: if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) { av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n"); return AVERROR(EINVAL); } ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); if (ret) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY); av_frame_unref(cc->frame); ret = av_frame_ref(cc->frame, frame); if (ret < 0) return ret; break; default: break; } if (!frame->data[0]) { ret = av_frame_ref(frame, cc->frame); if (ret < 0) return ret; } *got_frame = 1; } else { *got_frame = 0; buf_size = 0; } return buf_size; }
1threat
list.remove(x): x not in list not understood : <p>I'm beginning to learn Python and I'm trying to create a function that removes vowels from a given string. This is my Code :</p> <pre><code>def anti_vowel(text): li = [] for l in text: li.append(l) while 'a' in li: li.remove('a') while 'A' in li: li.remove('A') while 'A' in li: li.remove('e') while 'e' in li: li.remove('E') while 'E' in li: li.remove('i') while 'i' in li: li.remove('I') while 'I' in li: li.remove('o') while 'o' in li: li.remove('O') while 'u' in li: li.remove('u') while 'U' in li: li.remove('U') return "".join(li) </code></pre> <p>I get the "list.remove(x): x not in list" error when I try to run it. I know this error's been already asked about here but I didn't really get the answers in those specific cases. thanks for reading and please help :)</p>
0debug
iOS: Launch image gets wrinkled in the center during a call/recording/hot-spot session : <p>I use a set of launch images for my app and noticed that when I'm having a call, recording a voice note or sharing my Internet connection and put that activity in the background and launch my app, the launch screen is wrinkled in the center. Is there anything I can do to make the image look ok or is it just a standard iOS behavior?</p> <p><a href="https://i.stack.imgur.com/8KtXi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8KtXi.png" alt="enter image description here"></a></p>
0debug
Move a marker between 2 coordinates following driving directions : <p>I want to move a marker from one Latlng to another. I have used this code to move the marker smoothly based on Distance and Time.</p> <pre><code>public void animateMarker(final LatLng toPosition, final boolean hideMarker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = googleMap.getProjection(); Point startPoint = proj.toScreenLocation(cabMarker.getPosition()); final LatLng startLatLng = proj.fromScreenLocation(startPoint); final Interpolator interpolator = new LinearInterpolator(); handler.post(new Runnable() { @Override public void run() { Location prevLoc = new Location("service Provider"); prevLoc.setLatitude(startLatLng.latitude); prevLoc.setLongitude(startLatLng.longitude); Location newLoc = new Location("service Provider"); newLoc.setLatitude(toPosition.latitude); newLoc.setLongitude(toPosition.longitude); System.out.println("Locations ---- " + prevLoc + "-" + newLoc); float bearing = prevLoc.bearingTo(newLoc); long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / CAB_TRACK_INTERVAL); double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude; double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude; cabMarker.setPosition(new LatLng(lat, lng)); cabMarker.setRotation(bearing + 90); if (t &lt; 1.0) { // Post again 16ms later. handler.postDelayed(this, 16); } else { if (hideMarker) { cabMarker.setVisible(false); } else { cabMarker.setVisible(true); } } } }); } </code></pre> <p>But the problem is marker wont move on driving directions but in a straight line from A to B. Is it possible to get around 10 road midpoints in between A and B and then and move it along that path? </p>
0debug
Python - checking for an ip address (and nothing after it) : <p>I'm trying to create a Python (2.7) function that will take a string and return true if its input is an ip address, possibly with a slash in the end, but false otherwise. It needs to return a false value if the string is not just an ip address, but an ip address followed by some sort of path. It doesn't matter if the address is a valid IP or not (999.999.999.999 can be considered an ip address for that matter).</p> <p>eg: "124.131.141.248" - true "124.131.141.248/" - true "124.131.141.248/bla" - false "hello world" - false</p> <p>I've tried searching for a solution but most solutions include just checking for a valid IP address, disregarding my other needs.</p> <p>Any help would be appreciated.</p> <p>Thanks,</p>
0debug
static int disas_vfp_insn(CPUARMState * env, DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask; int dp, veclen; TCGv addr; TCGv tmp; TCGv tmp2; if (!arm_feature(env, ARM_FEATURE_VFP)) return 1; if (!s->vfp_enabled) { if ((insn & 0x0fe00fff) != 0x0ee00a10) return 1; rn = (insn >> 16) & 0xf; if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC && rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0) return 1; } dp = ((insn & 0xf00) == 0xb00); switch ((insn >> 24) & 0xf) { case 0xe: if (insn & (1 << 4)) { rd = (insn >> 12) & 0xf; if (dp) { int size; int pass; VFP_DREG_N(rn, insn); if (insn & 0xf) return 1; if (insn & 0x00c00060 && !arm_feature(env, ARM_FEATURE_NEON)) return 1; pass = (insn >> 21) & 1; if (insn & (1 << 22)) { size = 0; offset = ((insn >> 5) & 3) * 8; } else if (insn & (1 << 5)) { size = 1; offset = (insn & (1 << 6)) ? 16 : 0; } else { size = 2; offset = 0; } if (insn & ARM_CP_RW_BIT) { tmp = neon_load_reg(rn, pass); switch (size) { case 0: if (offset) tcg_gen_shri_i32(tmp, tmp, offset); if (insn & (1 << 23)) gen_uxtb(tmp); else gen_sxtb(tmp); break; case 1: if (insn & (1 << 23)) { if (offset) { tcg_gen_shri_i32(tmp, tmp, 16); } else { gen_uxth(tmp); } } else { if (offset) { tcg_gen_sari_i32(tmp, tmp, 16); } else { gen_sxth(tmp); } } break; case 2: break; } store_reg(s, rd, tmp); } else { tmp = load_reg(s, rd); if (insn & (1 << 23)) { if (size == 0) { gen_neon_dup_u8(tmp, 0); } else if (size == 1) { gen_neon_dup_low16(tmp); } for (n = 0; n <= pass * 2; n++) { tmp2 = tcg_temp_new_i32(); tcg_gen_mov_i32(tmp2, tmp); neon_store_reg(rn, n, tmp2); } neon_store_reg(rn, n, tmp); } else { switch (size) { case 0: tmp2 = neon_load_reg(rn, pass); tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8); tcg_temp_free_i32(tmp2); break; case 1: tmp2 = neon_load_reg(rn, pass); tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16); tcg_temp_free_i32(tmp2); break; case 2: break; } neon_store_reg(rn, pass, tmp); } } } else { if ((insn & 0x6f) != 0x00) return 1; rn = VFP_SREG_N(insn); if (insn & ARM_CP_RW_BIT) { if (insn & (1 << 21)) { rn >>= 1; switch (rn) { case ARM_VFP_FPSID: if (IS_USER(s) && arm_feature(env, ARM_FEATURE_VFP3)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPEXC: if (IS_USER(s)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPINST: case ARM_VFP_FPINST2: if (IS_USER(s) || arm_feature(env, ARM_FEATURE_VFP3)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPSCR: if (rd == 15) { tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); tcg_gen_andi_i32(tmp, tmp, 0xf0000000); } else { tmp = tcg_temp_new_i32(); gen_helper_vfp_get_fpscr(tmp, cpu_env); } break; case ARM_VFP_MVFR0: case ARM_VFP_MVFR1: if (IS_USER(s) || !arm_feature(env, ARM_FEATURE_MVFR)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; default: return 1; } } else { gen_mov_F0_vreg(0, rn); tmp = gen_vfp_mrs(); } if (rd == 15) { gen_set_nzcv(tmp); tcg_temp_free_i32(tmp); } else { store_reg(s, rd, tmp); } } else { tmp = load_reg(s, rd); if (insn & (1 << 21)) { rn >>= 1; switch (rn) { case ARM_VFP_FPSID: case ARM_VFP_MVFR0: case ARM_VFP_MVFR1: break; case ARM_VFP_FPSCR: gen_helper_vfp_set_fpscr(cpu_env, tmp); tcg_temp_free_i32(tmp); gen_lookup_tb(s); break; case ARM_VFP_FPEXC: if (IS_USER(s)) return 1; tcg_gen_andi_i32(tmp, tmp, 1 << 30); store_cpu_field(tmp, vfp.xregs[rn]); gen_lookup_tb(s); break; case ARM_VFP_FPINST: case ARM_VFP_FPINST2: store_cpu_field(tmp, vfp.xregs[rn]); break; default: return 1; } } else { gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rn); } } } } else { op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); if (dp) { if (op == 15) { rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1); } else { VFP_DREG_N(rn, insn); } if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) { rd = VFP_SREG_D(insn); } else { VFP_DREG_D(rd, insn); } if (op == 15 && (((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) { rm = VFP_SREG_M(insn); } else { VFP_DREG_M(rm, insn); } } else { rn = VFP_SREG_N(insn); if (op == 15 && rn == 15) { VFP_DREG_D(rd, insn); } else { rd = VFP_SREG_D(insn); } rm = VFP_SREG_M(insn); } veclen = s->vec_len; if (op == 15 && rn > 3) veclen = 0; delta_m = 0; delta_d = 0; bank_mask = 0; if (veclen > 0) { if (dp) bank_mask = 0xc; else bank_mask = 0x18; if ((rd & bank_mask) == 0) { veclen = 0; } else { if (dp) delta_d = (s->vec_stride >> 1) + 1; else delta_d = s->vec_stride + 1; if ((rm & bank_mask) == 0) { delta_m = 0; } else { delta_m = delta_d; } } } if (op == 15) { switch (rn) { case 16: case 17: gen_mov_F0_vreg(0, rm); break; case 8: case 9: gen_mov_F0_vreg(dp, rd); gen_mov_F1_vreg(dp, rm); break; case 10: case 11: gen_mov_F0_vreg(dp, rd); gen_vfp_F1_ld0(dp); break; case 20: case 21: case 22: case 23: case 28: case 29: case 30: case 31: gen_mov_F0_vreg(dp, rd); break; case 4: case 5: case 6: case 7: if (dp || !arm_feature(env, ARM_FEATURE_VFP_FP16)) { return 1; } default: gen_mov_F0_vreg(dp, rm); break; } } else { gen_mov_F0_vreg(dp, rn); gen_mov_F1_vreg(dp, rm); } for (;;) { switch (op) { case 0: gen_vfp_F1_mul(dp); gen_mov_F0_vreg(dp, rd); gen_vfp_add(dp); break; case 1: gen_vfp_mul(dp); gen_vfp_F1_neg(dp); gen_mov_F0_vreg(dp, rd); gen_vfp_add(dp); break; case 2: gen_vfp_F1_mul(dp); gen_mov_F0_vreg(dp, rd); gen_vfp_neg(dp); gen_vfp_add(dp); break; case 3: gen_vfp_mul(dp); gen_vfp_F1_neg(dp); gen_mov_F0_vreg(dp, rd); gen_vfp_neg(dp); gen_vfp_add(dp); break; case 4: gen_vfp_mul(dp); break; case 5: gen_vfp_mul(dp); gen_vfp_neg(dp); break; case 6: gen_vfp_add(dp); break; case 7: gen_vfp_sub(dp); break; case 8: gen_vfp_div(dp); break; case 10: case 11: case 12: case 13: if (!arm_feature(env, ARM_FEATURE_VFP4)) { return 1; } if (dp) { TCGv_ptr fpst; TCGv_i64 frd; if (op & 1) { gen_helper_vfp_negd(cpu_F0d, cpu_F0d); } frd = tcg_temp_new_i64(); tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(dp, rd)); if (op & 2) { gen_helper_vfp_negd(frd, frd); } fpst = get_fpstatus_ptr(0); gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d, cpu_F1d, frd, fpst); tcg_temp_free_ptr(fpst); tcg_temp_free_i64(frd); } else { TCGv_ptr fpst; TCGv_i32 frd; if (op & 1) { gen_helper_vfp_negs(cpu_F0s, cpu_F0s); } frd = tcg_temp_new_i32(); tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(dp, rd)); if (op & 2) { gen_helper_vfp_negs(frd, frd); } fpst = get_fpstatus_ptr(0); gen_helper_vfp_muladds(cpu_F0s, cpu_F0s, cpu_F1s, frd, fpst); tcg_temp_free_ptr(fpst); tcg_temp_free_i32(frd); } break; case 14: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; n = (insn << 12) & 0x80000000; i = ((insn >> 12) & 0x70) | (insn & 0xf); if (dp) { if (i & 0x40) i |= 0x3f80; else i |= 0x4000; n |= i << 16; tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32); } else { if (i & 0x40) i |= 0x780; else i |= 0x800; n |= i << 19; tcg_gen_movi_i32(cpu_F0s, n); } break; case 15: switch (rn) { case 0: break; case 1: gen_vfp_abs(dp); break; case 2: gen_vfp_neg(dp); break; case 3: gen_vfp_sqrt(dp); break; case 4: tmp = gen_vfp_mrs(); tcg_gen_ext16u_i32(tmp, tmp); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env); tcg_temp_free_i32(tmp); break; case 5: tmp = gen_vfp_mrs(); tcg_gen_shri_i32(tmp, tmp, 16); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env); tcg_temp_free_i32(tmp); break; case 6: tmp = tcg_temp_new_i32(); gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); gen_mov_F0_vreg(0, rd); tmp2 = gen_vfp_mrs(); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; case 7: tmp = tcg_temp_new_i32(); gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); tcg_gen_shli_i32(tmp, tmp, 16); gen_mov_F0_vreg(0, rd); tmp2 = gen_vfp_mrs(); tcg_gen_ext16u_i32(tmp2, tmp2); tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; case 8: gen_vfp_cmp(dp); break; case 9: gen_vfp_cmpe(dp); break; case 10: gen_vfp_cmp(dp); break; case 11: gen_vfp_F1_ld0(dp); gen_vfp_cmpe(dp); break; case 15: if (dp) gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env); break; case 16: gen_vfp_uito(dp, 0); break; case 17: gen_vfp_sito(dp, 0); break; case 20: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_shto(dp, 16 - rm, 0); break; case 21: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_slto(dp, 32 - rm, 0); break; case 22: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_uhto(dp, 16 - rm, 0); break; case 23: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_ulto(dp, 32 - rm, 0); break; case 24: gen_vfp_toui(dp, 0); break; case 25: gen_vfp_touiz(dp, 0); break; case 26: gen_vfp_tosi(dp, 0); break; case 27: gen_vfp_tosiz(dp, 0); break; case 28: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_tosh(dp, 16 - rm, 0); break; case 29: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_tosl(dp, 32 - rm, 0); break; case 30: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_touh(dp, 16 - rm, 0); break; case 31: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_toul(dp, 32 - rm, 0); break; default: return 1; } break; default: return 1; } if (op == 15 && (rn >= 8 && rn <= 11)) ; else if (op == 15 && dp && ((rn & 0x1c) == 0x18)) gen_mov_vreg_F0(0, rd); else if (op == 15 && rn == 15) gen_mov_vreg_F0(!dp, rd); else gen_mov_vreg_F0(dp, rd); if (veclen == 0) break; if (op == 15 && delta_m == 0) { while (veclen--) { rd = ((rd + delta_d) & (bank_mask - 1)) | (rd & bank_mask); gen_mov_vreg_F0(dp, rd); } break; } veclen--; rd = ((rd + delta_d) & (bank_mask - 1)) | (rd & bank_mask); if (op == 15) { rm = ((rm + delta_m) & (bank_mask - 1)) | (rm & bank_mask); gen_mov_F0_vreg(dp, rm); } else { rn = ((rn + delta_d) & (bank_mask - 1)) | (rn & bank_mask); gen_mov_F0_vreg(dp, rn); if (delta_m) { rm = ((rm + delta_m) & (bank_mask - 1)) | (rm & bank_mask); gen_mov_F1_vreg(dp, rm); } } } } break; case 0xc: case 0xd: if ((insn & 0x03e00000) == 0x00400000) { rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; if (dp) { VFP_DREG_M(rm, insn); } else { rm = VFP_SREG_M(insn); } if (insn & ARM_CP_RW_BIT) { if (dp) { gen_mov_F0_vreg(0, rm * 2); tmp = gen_vfp_mrs(); store_reg(s, rd, tmp); gen_mov_F0_vreg(0, rm * 2 + 1); tmp = gen_vfp_mrs(); store_reg(s, rn, tmp); } else { gen_mov_F0_vreg(0, rm); tmp = gen_vfp_mrs(); store_reg(s, rd, tmp); gen_mov_F0_vreg(0, rm + 1); tmp = gen_vfp_mrs(); store_reg(s, rn, tmp); } } else { if (dp) { tmp = load_reg(s, rd); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm * 2); tmp = load_reg(s, rn); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm * 2 + 1); } else { tmp = load_reg(s, rd); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm); tmp = load_reg(s, rn); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm + 1); } } } else { rn = (insn >> 16) & 0xf; if (dp) VFP_DREG_D(rd, insn); else rd = VFP_SREG_D(insn); if ((insn & 0x01200000) == 0x01000000) { offset = (insn & 0xff) << 2; if ((insn & (1 << 23)) == 0) offset = -offset; if (s->thumb && rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~2); } else { addr = load_reg(s, rn); } tcg_gen_addi_i32(addr, addr, offset); if (insn & (1 << 20)) { gen_vfp_ld(s, dp, addr); gen_mov_vreg_F0(dp, rd); } else { gen_mov_F0_vreg(dp, rd); gen_vfp_st(s, dp, addr); } tcg_temp_free_i32(addr); } else { int w = insn & (1 << 21); if (dp) n = (insn >> 1) & 0x7f; else n = insn & 0xff; if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) { return 1; } if (n == 0 || (rd + n) > 32 || (dp && n > 16)) { return 1; } if (rn == 15 && w) { return 1; } if (s->thumb && rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~2); } else { addr = load_reg(s, rn); } if (insn & (1 << 24)) tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2)); if (dp) offset = 8; else offset = 4; for (i = 0; i < n; i++) { if (insn & ARM_CP_RW_BIT) { gen_vfp_ld(s, dp, addr); gen_mov_vreg_F0(dp, rd + i); } else { gen_mov_F0_vreg(dp, rd + i); gen_vfp_st(s, dp, addr); } tcg_gen_addi_i32(addr, addr, offset); } if (w) { if (insn & (1 << 24)) offset = -offset * n; else if (dp && (insn & 1)) offset = 4; else offset = 0; if (offset != 0) tcg_gen_addi_i32(addr, addr, offset); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; default: return 1; } return 0; }
1threat
SQL Server - LIKE Command Not Working on host : hi everyone i have this query SELECT * FROM Takhfif WHERE TakhfifName LIKE '%keyword%' AND CityID=2" this is an example i have dynamic version of this code. However this code is working great on local but not working in host! my local Sql Server is 2014 and the host sql server is 2012 if this code not working on sql server 2012 what code should i use for a exact search?!
0debug
Lay website out with HTML then style with CSS after? : <p>I was just curious if it was better to lay out your website/webpages by using HTML first and then style it with CSS afterwards or is it best to style it as you're working on it?</p>
0debug
Decoder's weights of Autoencoder with tied weights in Keras : <p>I have implemented a tied weights Auto-encoder in Keras and have successfully trained it. </p> <p>My goal is to use only the decoder part of the Auto-encoder as the last layer of another network, to fine tune both the network and the decoder.</p> <p>Thing is, as you can see below from the summary, the decoder has no parameters with my tied weights implementation, so there is nothing to be fine tuned. (<code>decoder.get_weights()</code> returns <code>[]</code>)</p> <p>My question is: Should I change the implementation of the tied weights, so that the tied layer can still hold weights, that is the transposed weights of the encoder? If yes, how? </p> <p>Or am I just way off?</p> <p>Below is the summary of the autoencoder model as well as the class of the tied Dense layer (slightly modified from <a href="https://github.com/nanopony/keras-convautoencoder/blob/master/autoencoder_layers.py" rel="noreferrer">https://github.com/nanopony/keras-convautoencoder/blob/master/autoencoder_layers.py.</a>)</p> <hr> <pre><code>Layer (type) Output Shape Param # Connected to ==================================================================================================== encoded (Dense) (None, Enc_dim) 33000 dense_input_1[0][0] ____________________________________________________________________________________________________ tieddense_1 (TiedtDense) (None, Out_Dim) 0 encoded[0][0] ==================================================================================================== Total params: 33,000 Trainable params: 33,000 Non-trainable params: 0 ________________________________________________________________________ class TiedtDense(Dense): def __init__(self, output_dim, master_layer, init='glorot_uniform', activation='linear', weights=None, W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, input_dim=None, **kwargs): self.master_layer = master_layer super(TiedtDense, self).__init__(output_dim, **kwargs) def build(self, input_shape): assert len(input_shape) &gt;= 2 input_dim = input_shape[-1] self.input_dim = input_dim self.W = tf.transpose(self.master_layer.W) self.b = K.zeros((self.output_dim,)) self.params = [self.b] self.regularizers = [] if self.W_regularizer: self.W_regularizer.set_param(self.W) self.regularizers.append(self.W_regularizer) if self.b_regularizer: self.b_regularizer.set_param(self.b) self.regularizers.append(self.b_regularizer) if self.activity_regularizer: self.activity_regularizer.set_layer(self) self.regularizers.append(self.activity_regularizer) if self.initial_weights is not None: self.set_weights(self.initial_weights) del self.initial_weights </code></pre>
0debug
static void cond_broadcast(pthread_cond_t *cond) { int ret = pthread_cond_broadcast(cond); if (ret) die2(ret, "pthread_cond_broadcast"); }
1threat
ERROR C2039: 'vector': is not a member of 'std' : <p>I am new to C++ and I am trying to make a little dungeon crawler game. Currently I have multiple vectors declared in my header files but they seem to give multiple errors. I have tried searching for this problem on StackOverflow but the answers don't really seem to work.</p> <p>Here is one of my header files: (Hero.h)</p> <pre><code>#pragma once class Hero { public: Hero(); std::string name; int experience; int neededExperience; int health; int strength; int level; int speed; std::vector&lt;Item&gt; items = std::vector&lt;Item&gt;(); void levelUp(); private: }; </code></pre> <p>Here is my .cpp file: (Hero.cpp)</p> <pre><code>#include "stdafx.h" #include &lt;vector&gt; #include "Hero.h" #include "Item.h" Hero::Hero() { } void Hero::levelUp() { }; </code></pre> <p>Like I said I am new to C++ so there might be a lot more wrong with my code than I know. This is just a test.</p> <p>Below are the errors that are shown in the Error list of Visual Studio 2015:</p> <pre><code>Error C2039 'vector': is not a member of 'std' CPPAssessment hero.h 13 Error C2143 syntax error: missing ';' before '&lt;' CPPAssessment hero.h 13 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int CPPAssessment hero.h 13 Error C2238 unexpected token(s) preceding ';' hero.h 13 </code></pre>
0debug
IndexOutOfBounds: Why does low keep going past high : <p>I keep getting an IndexOutOfBounds error for the if statement down below and I don't know why. low is initially 0, high is set to 24, and the size of the ArrayList is 25. </p> <pre><code> for(int i = low + 1; low &lt;= high; i++){ if(list.get(i).compareTo(list.get(pivIndex)) &lt; 0){ //this line E temp = list.get(pivIndex); list.remove(pivIndex); list.add(pivIndex, list.get(i)); list.remove(i); list.add(i, temp); } } </code></pre>
0debug
static int check_refcounts_l1(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l1_table_offset, int l1_size, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l1_table, l2_offset, l1_size2; int i, refcount, ret; l1_size2 = l1_size * sizeof(uint64_t); inc_refcounts(bs, res, refcount_table, refcount_table_size, l1_table_offset, l1_size2); if (l1_size2 == 0) { l1_table = NULL; } else { l1_table = g_malloc(l1_size2); if (bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2) != l1_size2) goto fail; for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); } for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { if (check_copied) { refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if (refcount < 0) { fprintf(stderr, "Can't get refcount for l2_offset %" PRIx64 ": %s\n", l2_offset, strerror(-refcount)); goto fail; } if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: l2_offset=%" PRIx64 " refcount=%d\n", l2_offset, refcount); res->corruptions++; } } l2_offset &= ~QCOW_OFLAG_COPIED; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_offset, s->cluster_size); if (l2_offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not " "cluster aligned; L1 entry corrupted\n", l2_offset); res->corruptions++; } ret = check_refcounts_l2(bs, res, refcount_table, refcount_table_size, l2_offset, check_copied); if (ret < 0) { goto fail; } } } g_free(l1_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; g_free(l1_table); return -EIO; }
1threat
QComboBox - Select no entry : <p>I have a QComboBox on my ui and set the model like this:</p> <pre><code>QStringListModel* model = new QStringListModel; QStringList stringlist; stringlist &lt;&lt; "Test1" &lt;&lt; "Test2" &lt;&lt; "Test3"; model-&gt;setStringList(stringlist); ui-&gt;comboBox-&gt;setModel(model); </code></pre> <p>Now I want to change the current index to be none (so that I get a blank combo box).</p> <p>I already tried setting the current index to -1 with <code>ui-&gt;comboBox-&gt;setCurrentIndex(-1);</code>, but that results to an index aout of range exeption in qlist:</p> <pre><code>ASSERT failure in QList&lt;T&gt;::operator[]: "index out of range", file F:/Qt/5.4/mingw491_32/include/QtCore/qlist.h, line 486 </code></pre>
0debug
Ruby Data Types : <p>Which two of these three expressions are equal? Why?</p> <pre class="lang-rb prettyprint-override"><code>{ "city" =&gt; "Miami", "state" =&gt; "Florida" } { :city =&gt; "Miami", :state =&gt; "Florida" } { city: "Miami", state: "Florida" } </code></pre>
0debug
int qemu_ftruncate64(int fd, int64_t length) { LARGE_INTEGER li; LONG high; HANDLE h; BOOL res; if ((GetVersion() & 0x80000000UL) && (length >> 32) != 0) return -1; h = (HANDLE)_get_osfhandle(fd); li.HighPart = 0; li.LowPart = SetFilePointer (h, 0, &li.HighPart, FILE_CURRENT); if (li.LowPart == 0xffffffffUL && GetLastError() != NO_ERROR) return -1; high = length >> 32; if (!SetFilePointer(h, (DWORD) length, &high, FILE_BEGIN)) return -1; res = SetEndOfFile(h); SetFilePointer(h, li.LowPart, &li.HighPart, FILE_BEGIN); return res ? 0 : -1; }
1threat
static void lsp2lpc(int16_t *lpc) { int f1[LPC_ORDER / 2 + 1]; int f2[LPC_ORDER / 2 + 1]; int i, j; for (j = 0; j < LPC_ORDER; j++) { int index = (lpc[j] >> 7) & 0x1FF; int offset = lpc[j] & 0x7f; int temp1 = cos_tab[index] << 16; int temp2 = (cos_tab[index + 1] - cos_tab[index]) * ((offset << 8) + 0x80) << 1; lpc[j] = -(av_sat_dadd32(1 << 15, temp1 + temp2) >> 16); } f1[0] = 1 << 28; f1[1] = (lpc[0] << 14) + (lpc[2] << 14); f1[2] = lpc[0] * lpc[2] + (2 << 28); f2[0] = 1 << 28; f2[1] = (lpc[1] << 14) + (lpc[3] << 14); f2[2] = lpc[1] * lpc[3] + (2 << 28); for (i = 2; i < LPC_ORDER / 2; i++) { f1[i + 1] = f1[i - 1] + MULL2(f1[i], lpc[2 * i]); f2[i + 1] = f2[i - 1] + MULL2(f2[i], lpc[2 * i + 1]); for (j = i; j >= 2; j--) { f1[j] = MULL2(f1[j - 1], lpc[2 * i]) + (f1[j] >> 1) + (f1[j - 2] >> 1); f2[j] = MULL2(f2[j - 1], lpc[2 * i + 1]) + (f2[j] >> 1) + (f2[j - 2] >> 1); } f1[0] >>= 1; f2[0] >>= 1; f1[1] = ((lpc[2 * i] << 16 >> i) + f1[1]) >> 1; f2[1] = ((lpc[2 * i + 1] << 16 >> i) + f2[1]) >> 1; } for (i = 0; i < LPC_ORDER / 2; i++) { int64_t ff1 = f1[i + 1] + f1[i]; int64_t ff2 = f2[i + 1] - f2[i]; lpc[i] = av_clipl_int32(((ff1 + ff2) << 3) + (1 << 15)) >> 16; lpc[LPC_ORDER - i - 1] = av_clipl_int32(((ff1 - ff2) << 3) + (1 << 15)) >> 16; } }
1threat
static int gxf_probe(AVProbeData *p) { static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc}; static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2}; if (p->buf_size < 16) return 0; if (!memcmp(p->buf, startcode, sizeof(startcode)) && !memcmp(&p->buf[16 - sizeof(endcode)], endcode, sizeof(endcode))) return AVPROBE_SCORE_MAX; return 0; }
1threat
static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, int64_t speed, int64_t granularity, int64_t buf_size, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockDriverCompletionFunc *cb, void *opaque, Error **errp, const BlockJobDriver *driver, bool is_none_mode, BlockDriverState *base) { MirrorBlockJob *s; if (granularity == 0) { BlockDriverInfo bdi; if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } } assert ((granularity & (granularity - 1)) == 0); if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && !bdrv_iostatus_is_enabled(bs)) { error_set(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; } s = block_job_create(driver, bs, speed, cb, opaque, errp); if (!s) { return; } s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->target = target; s->is_none_mode = is_none_mode; s->base = base; s->granularity = granularity; s->buf_size = MAX(buf_size, granularity); s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity); bdrv_set_enable_write_cache(s->target, true); bdrv_set_on_error(s->target, on_target_error, on_target_error); bdrv_iostatus_enable(s->target); s->common.co = qemu_coroutine_create(mirror_run); trace_mirror_start(bs, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co, s); }
1threat
Change Checkout Form text "Billing Details" for specific product : How can I change the text "Billing Details" in the checkout page only for a specific product?
0debug