problem
stringlengths
26
131k
labels
class label
2 classes
String Operation - Get Data into table formate : string = {"Id":"048f7de7-81a4-464d-bd6d-df3be3b1e7e8","RecordType":20,"CreationTime":"2019-10-08T12:12:32","Operation":"SetScheduledRefresh","OrganizationId":"39b03722-b836-496a-85ec-850f0957ca6b","UserType":0,"UserAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/76.0.3809.132 Safari\/537.36","ItemName":"ASO Daily Statistics","Schedules":{"RefreshFrequency":"Daily","TimeZone":"E. South America Standard Time","Days":["All"],"Time":["07:30:00","10:30:00","13:30:00","16:30:00","19:30:00","22:30:00"]},"IsSuccess":true,"ActivityId":"4e8b4514-24be-4ba5-a7d3-a69e8cb8229e"} output = ------------------------------------------------------------------ ID | RecordType | CreationTime 048f7de7-81a4-464d-bd6d-df3be3b1e7e8 | 20 | 2019-10-08T12:12:32 An so on..
0debug
Binary Tree - In Order Sorting - : I have a quick question in a binary tree assignment. I am not sure how to fix the function to sort the binary tree in order and print it. Your feedback is much appreciated. **Error** Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method inOrder(Node) in the type BinaryTree is not applicable for the arguments () at BinaryTreeTester.main(BinaryTreeTester.java:21) **Method Declaration** // This function should sort the tree in order and print it public void inOrder(Node current) { if (current != null) { inOrder(current.left); System.out.println(current.data); inOrder(current.right); } } **Code** BinaryTree t1 = new BinaryTree(); // Test insert functions t1.insert(100); t1.insert(50); t1.insert(175); t1.insert(200); t1.insert(150); // Test displayInOrder and displayPreOrder System.out.println("InOrder: "); t1.inOrder(); // this is the line that causes the error What I understand from this error, is that since the method inOrder(Node)requires a parameter of type Node, the statement "t1.inOrder()" causes an issue since no parameter is used. I cannot alter the code file and can only workaround the function itself. Any advice on how to fix this?
0debug
"sls dynamodb start" throws spawn java ENOENT : <p>running on Mac, I've created a basic serverless service using the aws-nodejs template:</p> <pre><code>serverless create --template aws-nodejs --path TestService </code></pre> <p>After that I used the following commands to add serverless local:</p> <pre><code>npm install serverless-dynamodb-local serverless dynamodb install </code></pre> <p>No matter what I do, I can't get dynamodb-local to start. When I run </p> <pre><code>serverless dynamodb start </code></pre> <p>I get the following error:</p> <pre><code>Error: spawn java ENOENT at _errnoException (util.js:992:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9) </code></pre> <p>Running <code>java --version</code> gives me the following info:</p> <pre><code>Java 10.0.2 2018-07-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode) </code></pre> <p>I'm using Node 8.11.4 with serverless 1.30.1. Aws-sdk is also installed and I've setup my profile.</p> <p>Thanks</p>
0debug
How to set color for imageview in Android : <p>I want set icon into <code>ImageView</code> and i downloaded icons from this site : <a href="http://www.flaticon.com/" rel="noreferrer">FlatIcon</a><br> Now i want set color to this icons but when use <code>setBackground</code> just add color for background and not set to icons!<br> When use <code>NavigationView</code> i can set color to icons with this code : <code>app:itemIconTint="@color/colorAccent"</code>.<br></p> <p>How can i set color to icons into <code>ImageView</code> such as <code>itemIconTint</code> ? Thanks all &lt;3</p>
0debug
why is python my dictionary coming up a type error (ie srt) ? python 3 : <p>Hello currently I am learning how to program and I am currently learning python. However, I have been having issues with a program that is supposed to change dictionary values. when the program is run it comes up with this error:</p> <pre><code> Traceback (most recent call last): File "d:\programs\ailens.py", line 15, in &lt;module&gt; ailen['color'] = 'green' TypeError: 'str' object does not support item assignment </code></pre> <p>what did i do wrong with my code: </p> <pre><code>ailens = {'color': 'green', 'spead':'slow' ,'points': 5 } for ailen in ailens: if ailen == 'slow': ailen['color'] = 'yellow' ailen['spead'] = 'medium' ailen['points'] ='10' elif ailen == 'medium': ailen['color'] = 'red' ailen['spead'] = 'fast' ailen['ponits'] = '15' else: ailen['color'] = 'green' ailen['spead'] = 'slow' ailen['spead'] = 5 print(ailen) </code></pre>
0debug
static void h261_loop_filter_c(uint8_t *src, int stride){ int x,y,xy,yz; int temp[64]; for(x=0; x<8; x++){ temp[x ] = 4*src[x ]; temp[x + 7*8] = 4*src[x + 7*stride]; } for(y=1; y<7; y++){ for(x=0; x<8; x++){ xy = y * stride + x; yz = y * 8 + x; temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride]; } } for(y=0; y<8; y++){ src[ y*stride] = (temp[ y*8] + 2)>>2; src[7+y*stride] = (temp[7+y*8] + 2)>>2; for(x=1; x<7; x++){ xy = y * stride + x; yz = y * 8 + x; src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4; } } }
1threat
void nbd_client_new(NBDExport *exp, int csock, void (*close_fn)(NBDClient *)) { NBDClient *client; client = g_malloc0(sizeof(NBDClient)); client->refcount = 1; client->exp = exp; client->sock = csock; client->can_read = true; if (nbd_send_negotiate(client)) { shutdown(client->sock, 2); close_fn(client); return; } client->close = close_fn; qemu_co_mutex_init(&client->send_lock); nbd_set_handlers(client); if (exp) { QTAILQ_INSERT_TAIL(&exp->clients, client, next); nbd_export_get(exp); } }
1threat
My script is not functioning like it had before. why? : My code was working fine until today(what it does now is nothing) and I didn't edit it at all today any idea what might have happened? my code is this: loop { Send {1} Send {2} Numpad0:: ExitApp Return }
0debug
What is the best way to handle updates after a user stops typing? : <p>I have a child component form and I'm passing and updateDraft function once the user stops typing. Is this the best way to handle it? </p> <pre><code>const updateTimer = (props) =&gt; { if (this.timeout) clearTimeout(this.timeout) this.timeout = setTimeout(() =&gt; { props.updateDraft }, 5000) }; const Form = (props) =&gt; { return( &lt;Input type="text" onKeyUp={updateTimer(props)} onChange={props.onChange} /&gt; ) } </code></pre>
0debug
C++, Opengl - How to draw How to draw square on the button at the center? : How to draw a square on the button at the center (like stop button)? In this code that I try it be like a rectangle and full of the button. How can I solve this problem? [This is my code.][2] [This is my code.][3] <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> void ButtonDraw(Button *b) { if(b) { /* * We will indicate that the mouse cursor is over the button by changing its * colour. */ if (b->highlighted) glColor3f(0.7f,0.7f,0.8f); else glColor3f(0.6f,0.6f,0.6f); /* * draw background for the button. */ glBegin(GL_QUADS); glVertex2i( b->x , b->y ); glVertex2i( b->x , b->y+b->h ); glVertex2i( b->x+b->w, b->y+b->h ); glVertex2i( b->x+b->w, b->y ); glEnd(); /*draw red square on the button*/ glBegin(GL_QUADS); glColor3f(1.0f, 0.0f, 0.0f); glVertex2i(b->x, b->y); glVertex2i(b->x+b->w, b->y); glVertex2i(b->x+b->w, b->y + b->h); glVertex2i(b->x, b->y + b->h); glEnd(); /* * Draw an outline around the button with width 3 */ glLineWidth(3); } } <!-- end snippet --> [2]: https://i.stack.imgur.com/bYeeR.png [3]: https://i.stack.imgur.com/aEQJF.png
0debug
am a newbie working on a simple project am getting wierd errors .using django : what are this errorsFile "C:\Users\Admin\Projects\trydjango\musicyltd\restaurants\views.py", line 25, in contact return render(request, "contact.html", context) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\shortcuts.py", line 36, in render content = loader.render_to_string(template_name, context, request, using=using) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\loader.py", line 62, in render_to_string return template.render(context, request) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\backends\django.py", line 63, in render reraise(exc, self.backend) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\backends\django.py", line 84, in reraise raise new from exc django.template.exceptions.TemplateDoesNotExist: base.html [25/Apr/2018 13:54:27] "GET /contact/ HTTP/1.1" 500 120949
0debug
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) { SWFContext *swf = s->priv_data; AVIOContext *pb = s->pb; AVStream *vst = NULL, *ast = NULL, *st = 0; int tag, len, i, frame, v; for(;;) { uint64_t pos = avio_tell(pb); tag = get_swf_tag(pb, &len); if (tag < 0) return AVERROR(EIO); if (tag == TAG_VIDEOSTREAM) { int ch_id = avio_rl16(pb); len -= 2; for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) goto skip; } avio_rl16(pb); avio_rl16(pb); avio_rl16(pb); avio_r8(pb); vst = av_new_stream(s, ch_id); if (!vst) return -1; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb)); av_set_pts_info(vst, 16, 256, swf->frame_rate); vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; len -= 8; } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) { int sample_rate_code; for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) goto skip; } avio_r8(pb); v = avio_r8(pb); swf->samples_per_frame = avio_rl16(pb); ast = av_new_stream(s, -1); if (!ast) return -1; ast->codec->channels = 1 + (v&1); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15); ast->need_parsing = AVSTREAM_PARSE_FULL; sample_rate_code= (v>>2) & 3; if (!sample_rate_code) return AVERROR(EIO); ast->codec->sample_rate = 11025 << (sample_rate_code-1); av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); len -= 4; } else if (tag == TAG_VIDEOFRAME) { int ch_id = avio_rl16(pb); len -= 2; for(i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) { frame = avio_rl16(pb); av_get_packet(pb, pkt, len-2); pkt->pos = pos; pkt->pts = frame; pkt->stream_index = st->index; return pkt->size; } } } else if (tag == TAG_STREAMBLOCK) { for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) { if (st->codec->codec_id == CODEC_ID_MP3) { avio_skip(pb, 4); av_get_packet(pb, pkt, len-4); } else { av_get_packet(pb, pkt, len); } pkt->pos = pos; pkt->stream_index = st->index; return pkt->size; } } } else if (tag == TAG_JPEG2) { for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_id == CODEC_ID_MJPEG && st->id == -2) break; } if (i == s->nb_streams) { vst = av_new_stream(s, -2); if (!vst) return -1; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_MJPEG; av_set_pts_info(vst, 64, 256, swf->frame_rate); vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; st = vst; } avio_rl16(pb); av_new_packet(pkt, len-2); avio_read(pb, pkt->data, 4); if (AV_RB32(pkt->data) == 0xffd8ffd9 || AV_RB32(pkt->data) == 0xffd9ffd8) { pkt->size -= 4; avio_read(pb, pkt->data, pkt->size); } else { avio_read(pb, pkt->data + 4, pkt->size - 4); } pkt->pos = pos; pkt->stream_index = st->index; return pkt->size; } skip: avio_skip(pb, len); } return 0; }
1threat
DeviceState *ssi_create_slave(SSIBus *bus, const char *name) { DeviceState *dev; dev = qdev_create(&bus->qbus, name); qdev_init(dev); return dev; }
1threat
How to change the border color of bootstrap table using inline css : <p>Although <code>inline css</code> is not recommended but I just want to test it in one special case and hence want to override the default border color of a <code>bootstrap table</code> to white. But the following does not work. It still displays the default border color of a bootstrap table. How can it be achieved or what are other alternatives <strong>without</strong> using javascript or <strong>without</strong> messing around with default bootstrap css?</p> <pre><code>&lt;table class="table table-bordered" style="border-color:white;"&gt; ... ... &lt;/table&gt; </code></pre>
0debug
Java - why can't I use anonymous arrays as any other anonymous class? : I am writing on my IDE the following new String() // no compilation fail new Object() // no compilation fail new int[]{1,2,3,4} // compilation fails why arrays can't be anonymous as other objects? I can see I can use them anonymously when we talk about passing them as method params, however I was expecting them to behave as any other object even for this case.
0debug
static void raven_realize(PCIDevice *d, Error **errp) { RavenPCIState *s = RAVEN_PCI_DEVICE(d); char *filename; int bios_size = -1; d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[0x34] = 0x00; memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE, &error_abort); memory_region_set_readonly(&s->bios, true); memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE), &s->bios); vmstate_register_ram_global(&s->bios); if (s->bios_name) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); if (filename) { if (s->elf_machine != EM_NONE) { bios_size = load_elf(filename, NULL, NULL, NULL, NULL, NULL, 1, s->elf_machine, 0); } if (bios_size < 0) { bios_size = get_image_size(filename); if (bios_size > 0 && bios_size <= BIOS_SIZE) { hwaddr bios_addr; bios_size = (bios_size + 0xfff) & ~0xfff; bios_addr = (uint32_t)(-BIOS_SIZE); bios_size = load_image_targphys(filename, bios_addr, bios_size); } } } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load bios image '%s'\n", s->bios_name); } g_free(filename); } }
1threat
How to schedule a eclipse java program to run daily at 8 PM? : <p>Can anyone please help me in scheduling to run a eclipse java program daily at 8 PM?</p> <p>I used various methods such as codepro, quartz but i don't know how it works?</p>
0debug
issue with apostrophes in a function with div.innerHTML : <p>This code make an error. Probably the problem is with location.href apostrophes.</p> <pre><code>div.innerHTML ='&lt;div id="link"&gt;\ &lt;input type="button" onclick="location.href='http://www.google.com';"/&gt;\ &lt;/div&gt;'; </code></pre>
0debug
Extract Substrings using regex Java : <p>I have a string that has several NP( ), In between "NP(' and ')' is the data I want. But i want just NP data inside not the first NP outside</p> <p>How can I write a regex to extract "(DT a) (NN sign)" , "(DT the) (NN facade)" from the following text? I wnt for each text that contain NP to extract just inside NP data..I hope I explained well the problem</p> <pre><code> (ROOT (NP (NP (DT a) (NN sign)) (PP (IN on) (NP (NP (DT the) (NN facade)) (PP (IN of) (NP (DT the) (NN building))))))) </code></pre>
0debug
how can I use differents android.R.layout in the same listView : it's my first app in android I search for help I cant use different layout in the same listView with a default ArrayAdapter like (select_dialog_singlechoice && simple_list_item_1)[enter image description here][1] [1]: https://i.stack.imgur.com/E8ZBO.png
0debug
numpy undefined symbol: PyFPE_jbuf : <p>I am trying to use the One Million Song Dataset, for this i had to install python tables, numpy, cython, hdf5, numexpr, and so. </p> <p>Yesterday i managed to install all i needed, and after having some troubles with hdf5, i downloaded the precompiled binary packages and saved them in my /bin folder, and the respective libraries in /lib , after that i tested this python script : <code>http://labrosa.ee.columbia.edu/millionsong/sites/default/files/tutorial1.py.txt</code></p> <p>and it worked fine, to be clear the way i made it work was to first run the script and start installing the needed dependencies, but today i restarted my laptop and it didn't work, now it throws me this error on the console :</p> <pre><code>python2.7 script.py </code></pre> <p>returns : </p> <pre><code>import numpy as np # get it at: http://numpy.scipy.org/ from . import random from .mtrand import * ImportError: /home/francisco/.local/lib/python2.7/site-packages/numpy/random/mtrand.so: undefined symbol: PyFPE_jbuf </code></pre> <p>seems to me that there is a missing variable in such file, my guess is that the script is looking for the numpy library in the wrong place, since i made so many failed installations maybe i broke something and it only worked out because it was loaded in the temporal memory of the computer. </p> <p>I tried installing Anaconda, and i created a new environment and installed the packaged with the anaconda package manager, and even thought i listed all packaged and it returns : </p> <pre><code># packages in environment at /home/francisco/anaconda2/envs/Music: # biopython 1.66 np110py27_0 cython 0.23.4 &lt;pip&gt; hdf5 1.8.15.1 2 mkl 11.3.1 0 numexpr 2.5 np110py27_0 numpy 1.10.4 py27_1 openssl 1.0.2g 0 pillow 3.1.1 &lt;pip&gt; pip 8.1.1 py27_0 pytables 3.2.2 np110py27_1 python 2.7.11 0 python-ldap 2.4.25 &lt;pip&gt; readline 6.2 2 reportlab 3.3.0 &lt;pip&gt; requirements 0.1 &lt;pip&gt; setuptools 20.3 py27_0 sqlite 3.9.2 0 tables 3.2.2 &lt;pip&gt; tk 8.5.18 0 wheel 0.29.0 py27_0 zlib 1.2.8 0 </code></pre> <p>i still get the same error. I really need help and don't know what else to try. Thanks. </p>
0debug
Should we be using two GraphQL tiers? : <p>I work on a project that uses a single GraphQL schema to expose data from REST APIs to various clients. The schema design is "owned" by the front-end teams, and is shaped to represent the universe as they see it. This neatly decouples the UI from the API tier, and is working fairly well. Some (poorly designed but essential) APIs are relatively complex, and require domain knowledge (aka business logic) to compose the data into a form that maps to the UI schema, but that business logic is changing, as legacy APIs are pulled apart and rewritten - the problem therefore is twofold:</p> <ol> <li>We have unwanted business logic in the resolvers that populate GraphQL query responses</li> <li>When an API team produce a new version of their service, and wants it to be called, the UI team are not necessarily ready to update their resolvers to call it</li> </ol> <p>I am considering introducing a second GraphQL instance that acts as the domain model, which will be owned by the API teams, and abstracts the details of how to call each API, and compose raw data to be consumed by the UI schema. It does introduce a small performance overhead, but on the plus side, decouples the Schema from the API implementation detail.</p> <p>In researching this approach I have not found examples of this being attempted elsewhere so wondered if I'd missed any, or if this represents an anti-pattern that should be avoided? </p>
0debug
Cannot watch Kotlin variable in android studio : <p>I am not able to get android studio display the value of a calculation in the watches window.</p> <p>I use Kotlin for development and when i try to add a value to watches, i get a message which says "An exception occurs during evaluate expression".</p> <p>e.g.</p> <pre><code> val model = MyModel() val pos = model.position </code></pre> <p>Now if I add <code>model.position</code> to watches, then it gives the above error and the value of the expression is not displayed.</p> <p>How can I fix this?</p>
0debug
Elasticsearch 7 : Root mapping definition has unsupported parameters (mapper_parsing_exception) : <p>When trying to insert the following mapping in Elasticsearch 7</p> <pre><code>PUT my_index/items/_mapping { "settings":{ }, "mappings":{ "items":{ "properties":{ "products":{ "properties":{ "classification":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } }, "original_text":{ "type":"text", "store":false, "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } } } }, "title":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } }, "analyzer":"autocomplete" }, "image":{ "properties":{ "type":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } }, "location":{ "type":"text", "store":false, "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } } } } } } } } </code></pre> <p>I get an error of the form:</p> <pre><code>{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "Root mapping definition has unsupported parameters: </code></pre> <p>What is causing this error?</p>
0debug
SwiftLint: Exclude file for specific rule : <p>I'm trying to do something like this in my .swiftlint.yml file:</p> <pre><code>force_cast: severity: warning # explicitly excluded: - Dog.swift </code></pre> <p>I have this code and I don't like the force_try warning I'm getting for it:</p> <pre><code>let cell = tableView.dequeueReusableCellWithIdentifier(Constants.dogViewCellReuseIdentifier, forIndexPath: indexPath) as! DogViewCell </code></pre> <p>I want to suppress the warning for this file by excluding this file from the rule.</p> <p>Is there a way to do that ?</p>
0debug
how to use <%= link_to%> passing id of asociated object : I want to go to show.html.erb which is aview file just to show the specific comment. and comment is associated under article. how to use <%= link_to 'Show Comment ? %> # this is show action in comments controller which may have route like /articles/3/comments/2 2and 3 as id # commentcontroller def show @article =Article.find(params[:id]) end
0debug
Akka Http Performance tuning : <p>I am performing Load testing on Akka-http framework(version: 10.0), I am using <a href="https://github.com/wg/wrk" rel="noreferrer">wrk</a> tool. wrk command: </p> <p><code>wrk -t6 -c10000 -d 60s --timeout 10s --latency http://localhost:8080/hello</code></p> <p>first run without any blocking call,</p> <pre><code>object WebServer { implicit val system = ActorSystem("my-system") implicit val materializer = ActorMaterializer() implicit val executionContext = system.dispatcher def main(args: Array[String]) { val bindingFuture = Http().bindAndHandle(router.route, "localhost", 8080) println( s"Server online at http://localhost:8080/\nPress RETURN to stop...") StdIn.readLine() // let it run until user presses return bindingFuture .flatMap(_.unbind()) // trigger unbinding from the port .onComplete(_ =&gt; system.terminate()) // and shutdown when done } } object router { implicit val executionContext = WebServer.executionContext val route = path("hello") { get { complete { "Ok" } } } } </code></pre> <p>output of wrk:</p> <pre><code> Running 1m test @ http://localhost:8080/hello 6 threads and 10000 connections Thread Stats Avg Stdev Max +/- Stdev Latency 4.22ms 16.41ms 2.08s 98.30% Req/Sec 9.86k 6.31k 25.79k 62.56% Latency Distribution 50% 3.14ms 75% 3.50ms 90% 4.19ms 99% 31.08ms 3477084 requests in 1.00m, 477.50MB read Socket errors: connect 9751, read 344, write 0, timeout 0 Requests/sec: 57860.04 Transfer/sec: 7.95MB </code></pre> <p>Now if i add a future call in the route and run the test again.</p> <pre><code>val route = path("hello") { get { complete { Future { // Blocking code Thread.sleep(100) "OK" } } } } </code></pre> <p>Output, of wrk:</p> <pre><code>Running 1m test @ http://localhost:8080/hello 6 threads and 10000 connections Thread Stats Avg Stdev Max +/- Stdev Latency 527.07ms 491.20ms 10.00s 88.19% Req/Sec 49.75 39.55 257.00 69.77% Latency Distribution 50% 379.28ms 75% 632.98ms 90% 1.08s 99% 2.07s 13744 requests in 1.00m, 1.89MB read Socket errors: connect 9751, read 385, write 38, timeout 98 Requests/sec: 228.88 Transfer/sec: 32.19KB </code></pre> <p>As you can see with future call only <strong>13744 requests are being served</strong>.</p> <p>After following <a href="http://doc.akka.io/docs/akka-http/current/scala/http/handling-blocking-operations-in-akka-http-routes.html#solution-dedicated-dispatcher-for-blocking-operations" rel="noreferrer">Akka documentation</a>, I added a separate dispatcher thread pool for the route which creates max, of <strong>200 threads</strong>.</p> <pre><code>implicit val executionContext = WebServer.system.dispatchers.lookup("my-blocking-dispatcher") // config of dispatcher my-blocking-dispatcher { type = Dispatcher executor = "thread-pool-executor" thread-pool-executor { // or in Akka 2.4.2+ fixed-pool-size = 200 } throughput = 1 } </code></pre> <p>After the above change, the performance improved a bit</p> <pre><code>Running 1m test @ http://localhost:8080/hello 6 threads and 10000 connections Thread Stats Avg Stdev Max +/- Stdev Latency 127.03ms 21.10ms 504.28ms 84.30% Req/Sec 320.89 175.58 646.00 60.01% Latency Distribution 50% 122.85ms 75% 135.16ms 90% 147.21ms 99% 190.03ms 114378 requests in 1.00m, 15.71MB read Socket errors: connect 9751, read 284, write 0, timeout 0 Requests/sec: 1903.01 Transfer/sec: 267.61KB </code></pre> <p>In the <strong>my-blocking-dispatcher config</strong> if I increase the pool size above 200 the performance is same.</p> <p>Now, what other parameters or config should I use to increase the performance while using future call.So that app gives the maximum throughput.</p>
0debug
non-static method loadUrl(String) cannot be referenced from a static context : <pre><code>WebView.loadUrl(additionalData.optString("targeturl")); </code></pre> <p>how to debug error non-static method loadUrl(String) cannot be referenced from a static context</p>
0debug
Retrieving Headers from 302 (redirect) response in angular 4.3+ : <p>I have spent around 24 hours searching and trying different solutions found on stack overflow and other various sources to no avail. </p> <p>Here is my problem statement. </p> <p>With SPA apps you apparently need to use implicit grants when utilizing JWTs. This is fine, however, the only way I can retrieve this JWT is by either making a POST or GET request with payload or url Params containing specific information (client id, token type, etc). The endpoint (on success) responds with a 302 status and a Location header containing the access token I need to make API requests. </p> <p>From what I have seen so far, there does not seem to be a way in Angular to intercept a 302 redirect. I have tried creating my own interceptor service (the closest I have gotten was the 200 response after the page was redirected). </p> <p>I have tried putting the “observe: ‘response’” option in my get/post requests but again the Location header is not present and it never shows the 302 (even though I can see it in my debug console). </p> <p>I have verified it is NOT a CORS issue because on the proxy the expose headers option is set to the location value. </p> <p>The only thing that I can do to get it to work is by using an iframe and listening on the iframe for the redirect. But I do not want to do this as it is clunky and not always reliable. </p> <p>Can anyone out there tell me is there a way to catch, intercept, or view the location header on a 302 response of a GET/POST request using Angular’s Httpclient? Is there some kind of plugin or node module I can download to help me achieve this? </p>
0debug
Why is argparse not parsing my boolean flag correctly? : <p>I am trying to use the argparse module to make my Python program accept flexible command-line arguments. I want to pass a simple boolean flag, and saying <code>True</code> or <code>False</code> to execute the appropriate branch in my code. </p> <p>Consider the following. </p> <pre><code>import argparse parser = argparse.ArgumentParser(prog='test.py',formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-boolflag', type=bool, default=True) parser.add_argument('-intflag' , type=int, default=3) args = parser.parse_args() boolflag = args.boolflag intflag = args.intflag print ("Bool Flag is ", boolflag) print ("Int Flag is ", intflag) </code></pre> <p>When I tried to execute it with <code>python scrap.py -boolflag False -intflag 314</code> I got the result</p> <pre><code>Bool Flag is True Int Flag is 314 </code></pre> <p>Why is this?!! The intflag seems to be parsed correctly, yet the boolean flag is invariably parsed as <code>True</code> even if I mention explicitly in the command-line arguments that I want it to be <code>False</code>. </p> <p>Where am I going wrong? </p>
0debug
static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) { TeletextContext *ctx = avctx->priv_data; AVSubtitle *sub = data; int ret = 0; if (!ctx->vbi) { if (!(ctx->vbi = vbi_decoder_new())) return AVERROR(ENOMEM); if (!vbi_event_handler_add(ctx->vbi, VBI_EVENT_TTX_PAGE, handler, ctx)) { vbi_decoder_delete(ctx->vbi); ctx->vbi = NULL; return AVERROR(ENOMEM); } } if (avctx->pkt_timebase.den && pkt->pts != AV_NOPTS_VALUE) ctx->pts = av_rescale_q(pkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); if (pkt->size) { int lines; const int full_pes_size = pkt->size + 45; if (full_pes_size < 184 || full_pes_size > 65504 || full_pes_size % 184 != 0) return AVERROR_INVALIDDATA; ctx->handler_ret = pkt->size; if (data_identifier_is_teletext(*pkt->data)) { if ((lines = slice_to_vbi_lines(ctx, pkt->data + 1, pkt->size - 1)) < 0) return lines; av_dlog(avctx, "ctx=%p buf_size=%d lines=%u pkt_pts=%7.3f\n", ctx, pkt->size, lines, (double)pkt->pts/90000.0); if (lines > 0) { #ifdef DEBUG int i; av_log(avctx, AV_LOG_DEBUG, "line numbers:"); for(i = 0; i < lines; i++) av_log(avctx, AV_LOG_DEBUG, " %d", ctx->sliced[i].line); av_log(avctx, AV_LOG_DEBUG, "\n"); #endif vbi_decode(ctx->vbi, ctx->sliced, lines, 0.0); ctx->lines_processed += lines; } } ctx->pts = AV_NOPTS_VALUE; ret = ctx->handler_ret; } if (ret < 0) return ret; if (ctx->nb_pages) { int i; sub->format = ctx->format_id; sub->start_display_time = 0; sub->end_display_time = ctx->sub_duration; sub->num_rects = 0; sub->pts = ctx->pages->pts; if (ctx->pages->sub_rect->type != SUBTITLE_NONE) { sub->rects = av_malloc(sizeof(*sub->rects)); if (sub->rects) { sub->num_rects = 1; sub->rects[0] = ctx->pages->sub_rect; } else { ret = AVERROR(ENOMEM); } } else { av_log(avctx, AV_LOG_DEBUG, "sending empty sub\n"); sub->rects = NULL; } if (!sub->rects) subtitle_rect_free(&ctx->pages->sub_rect); for (i = 0; i < ctx->nb_pages - 1; i++) ctx->pages[i] = ctx->pages[i + 1]; ctx->nb_pages--; if (ret >= 0) *data_size = 1; } else *data_size = 0; return ret; }
1threat
localiztion in android Studio : In Android Studio, I'm attempting to localize to Arabic, How can i translate true and false to Arabic words?` <string name="Chocolate_cream_order_summary">"كريمة الشكولاته: "</string> `
0debug
How to implement a re-try logic in RestAssured for a failed REST call : <p>I am using RestAssured for firing API calls and wanted to implement a retry logic if the REST calls fails. </p> <p>The requirement is because we are getting intermittent 500 response codes for certain APIs which usually work upon a re-try.</p> <p>I have implemented the following code but it does not seem to work - </p> <pre><code>HttpClientConfig.HttpClientFactory htc = new HttpClientConfig.HttpClientFactory() { @Override public HttpClient createHttpClient() { DefaultHttpClient d = new DefaultHttpClient(); d.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(restRetryCount, true)); return d; } }; RestAssuredConfig rac = RestAssured.config().httpClient(HttpClientConfig.httpClientConfig().httpClientFactory(htc)); </code></pre> <p>Moreover, since RestAssured does not cater the HTTPClient level logging, I tried enabling the logging for the apache httpclient using the java.util.logging but that also <em>does not seem to be working either</em>.</p> <p>Created a custom.logging.properties file with - </p> <pre><code># Enables the header wire and context logging org.apache.http.level = FINEST org.apache.http.wire.level = SEVERE # Enables the context logging for connection management &amp; request execution org.apache.http.impl.conn.level = FINEST org.apache.http.impl.client.level = FINEST org.apache.http.client.level = FINEST </code></pre> <p>and wrote the following for initiating the logging - </p> <pre><code>public static Logger initiateHttpTrafficLogging(){ Logger log = Logger.getLogger("httptraffic.log"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream is = loader.getResourceAsStream("custom.logging.properties"); try{ LogManager.getLogManager().readConfiguration(is); log.setLevel(Level.FINEST); log.addHandler(new ConsoleHandler()); log.setUseParentHandlers(false); log.info("Initiating HTTP Traffic logging ::\n\n"); } catch (IOException ie){ Assert.fail("ERROR: Could not load the loggin properties !!!", ie.fillInStackTrace()); } return log; } </code></pre> <p>Could anyone please provide me some direction as to where I am going wrong or any pointers to resolve this issue.</p> <p>Appreciate your responses. Thanks.</p>
0debug
Converting string "s" to binary : <pre><code>public class test1 { String testVar = "s"; String binary; int decimal; public test1() { decimal = Integer.parseInt(testVar.trim(), 16 ); System.out.println(decimal); } </code></pre> <p>here is my code, It seems that this works with other letters but when its an string value "s", Error shows up</p> <blockquote> <p>Exception in thread "main" java.lang.NumberFormatException: For input string: "s"</p> </blockquote>
0debug
static void pci_vpb_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pci_vpb_realize; dc->reset = pci_vpb_reset; dc->vmsd = &pci_vpb_vmstate; dc->props = pci_vpb_properties; dc->cannot_destroy_with_object_finalize_yet = true; }
1threat
int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcemb_tlb_t *tlb; target_phys_addr_t raddr; int i, ret, zsel, zpr, pr; ret = -1; raddr = -1; pr = msr_pr; for (i = 0; i < env->nb_tlb; i++) { tlb = &env->tlb[i].tlbe; if (ppcemb_tlb_check(env, tlb, &raddr, address, env->spr[SPR_40x_PID], 0, i) < 0) continue; zsel = (tlb->attr >> 4) & 0xF; zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n", __func__, i, zsel, zpr, rw, tlb->attr); } #endif switch (zpr) { case 0x2: if (pr != 0) goto check_perms; case 0x3: ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; ret = 0; break; case 0x0: if (pr != 0) { ctx->prot = 0; ret = -2; break; } case 0x1: check_perms: ctx->prot = tlb->prot; ctx->prot |= PAGE_EXEC; ret = check_prot(ctx->prot, rw, access_type); break; } if (ret >= 0) { ctx->raddr = raddr; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access granted " ADDRX " => " REGX " %d %d\n", __func__, address, ctx->raddr, ctx->prot, ret); } #endif return 0; } } #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access refused " ADDRX " => " REGX " %d %d\n", __func__, address, raddr, ctx->prot, ret); } #endif return ret; }
1threat
static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit) { ByteIOContext *pb = s->pb; PVAContext *pvactx = s->priv_data; int length, streamid; int64_t res; pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit); while (*pos < pos_limit) { res = AV_NOPTS_VALUE; url_fseek(pb, *pos, SEEK_SET); pvactx->continue_pes = 0; if (read_part_of_packet(s, &res, &length, &streamid, 0)) { (*pos)++; continue; } if (streamid - 1 != stream_index || res == AV_NOPTS_VALUE) { *pos = url_ftell(pb) + length; continue; } break; } pvactx->continue_pes = 0; return res; }
1threat
static bool run_poll_handlers(AioContext *ctx, int64_t max_ns) { bool progress; int64_t end_time; assert(ctx->notify_me); assert(qemu_lockcnt_count(&ctx->list_lock) > 0); assert(ctx->poll_disable_cnt == 0); trace_run_poll_handlers_begin(ctx, max_ns); end_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + max_ns; do { progress = run_poll_handlers_once(ctx); } while (!progress && qemu_clock_get_ns(QEMU_CLOCK_REALTIME) < end_time); trace_run_poll_handlers_end(ctx, progress); return progress; }
1threat
static void numa_node_parse_cpus(int nodenr, const char *cpus) { char *endptr; unsigned long long value, endvalue; value = strtoull(cpus, &endptr, 10); if (*endptr == '-') { endvalue = strtoull(endptr+1, &endptr, 10); } else { endvalue = value; } if (!(endvalue < MAX_CPUMASK_BITS)) { endvalue = MAX_CPUMASK_BITS - 1; fprintf(stderr, "A max of %d CPUs are supported in a guest\n", MAX_CPUMASK_BITS); } bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); }
1threat
Should I avoid using Dependency Injection and IoC? : <p>In my mid-size project I used static classes for repositories, services etc. and it actually worked very well, even if the most of programmers will expect the opposite. My codebase was very compact, clean and easy to understand. Now I tried to rewrite everything and use <code>IoC</code> (Invertion of Control) and I was absolutely disappointed. I have to manually initialize dozen of dependencies in every class, controller etc., add more projects for interfaces and so on. I really don't see any benefits in my project and it seems that it causes more problems than solves. I found the following drawbacks in <code>IoC</code>/<code>DI</code>:</p> <ul> <li>much bigger codesize</li> <li>ravioli-code instead of spaghetti-code</li> <li>slower performance, need to initialize all dependencies in constructor even if the method I want to call has only one dependency</li> <li>harder to understand when no IDE is used</li> <li>some errors are pushed to run-time</li> <li>adding additional dependency (DI framework itself)</li> <li>new staff have to learn DI first in order to work with it</li> <li>a lot of boilerplate code, which is bad for creative people (for example copy instances from constructor to properties...)</li> </ul> <p>We do not test the entire codebase, but only certain methods and use real database. So, should Dependency Injection be avoided when no mocking is required for testing?</p>
0debug
static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { int async_ret; BlockDriverAIOCB *acb; async_ret = NOT_DONE; qemu_aio_wait_start(); acb = bdrv_aio_read(bs, sector_num, buf, nb_sectors, bdrv_rw_em_cb, &async_ret); if (acb == NULL) { qemu_aio_wait_end(); return -1; } while (async_ret == NOT_DONE) { qemu_aio_wait(); } qemu_aio_wait_end(); return async_ret; }
1threat
Google sign-in error with Firebase Auth UI after upgrade : <p>I was using an older version of firebase auth ui successfully but after upgrading to the latest releases I receive the following error while trying to login with Google:</p> <pre><code>E/AuthUI: A sign-in error occurred. com.firebase.ui.auth.FirebaseUiException: Code: 10, message: 10: at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:106) at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onActivityResult(AuthMethodPickerActivity.java:225) at android.app.Activity.dispatchActivityResult(Activity.java:7235) at android.app.ActivityThread.deliverResults(ActivityThread.java:4320) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367) at android.app.ActivityThread.-wrap19(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) </code></pre> <p>Facebook and email sign in is fine.</p> <p>I am using these dependencies in my app gradle:</p> <pre><code>implementation 'com.google.android.gms:play-services-auth:15.0.1' implementation 'com.firebaseui:firebase-ui-auth:4.0.0' implementation 'com.google.firebase:firebase-auth:16.0.1' implementation 'com.android.support:customtabs:27.1.1' implementation 'com.android.support:cardview-v7:27.1.1' implementation 'com.facebook.android:facebook-login:4.32.0' implementation 'com.google.firebase:firebase-config:16.0.0' implementation 'com.google.firebase:firebase-core:16.0.0' implementation 'com.google.firebase:firebase-database:16.0.1' </code></pre> <p>And the following in my project level gradle:</p> <pre><code>classpath 'com.google.gms:google-services:4.0.1' </code></pre> <p>Login activity:</p> <pre><code>public class ActivityLoginView extends ActivityBase { // Misc public static final int RC_SIGN_IN = 100; public static final String TAG = "ActivityLoginView"; public ActivityLoginViewModel activityLoginViewModel; private static final String PRIVACY_POLICY_URL = "https://www.editedout.com/pages/privacy"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activityLoginViewModel = new ActivityLoginViewModel(this); if (!activityLoginViewModel.isGooglePlayServicesAvailable()) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("No Google Play Services"); alertDialog.setMessage("This app requires Google Play Services to be installed and enabled"); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); System.exit(0); } }); alertDialog.show(); } else { FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser(); // See if user is logged in already if (currentUser != null) { // User already signed in if (!BuildConfig.DEBUG) { Crashlytics.setUserIdentifier(currentUser.getUid()); Crashlytics.setUserName(currentUser.getDisplayName()); Crashlytics.setUserEmail(currentUser.getEmail()); } activityLoginViewModel.saveUserToFirebase(); } else { startActivityForResult( AuthUI.getInstance().createSignInIntentBuilder() .setTheme(R.style.LoginTheme) .setLogo(R.drawable.loginlogo) .setAvailableProviders(getSelectedProviders()) .setPrivacyPolicyUrl(PRIVACY_POLICY_URL) .setIsSmartLockEnabled(!BuildConfig.DEBUG) .build(), RC_SIGN_IN); } } } public void startMain() { if (SPManager.getBoolean(this, SPManager.kOnBoardShown)) { Intent intent = new Intent(this, ActivityHomePage.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } else { startActivity(ActivityOnBoard.newIntent(this)); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { handleSignInResponse(resultCode, data); } } private void handleSignInResponse(int resultCode, Intent data) { IdpResponse response = IdpResponse.fromResultIntent(data); // Successfully signed in if (resultCode == RESULT_OK) { activityLoginViewModel.saveUserToFirebase(); } else { // Sign in failed if (response == null) { // User pressed back button showSnackbar(R.string.sign_in_cancelled); return; } if (response.getError().getErrorCode() == ErrorCodes.NO_NETWORK) { showSnackbar(R.string.no_internet_connection); return; } showSnackbar(R.string.unknown_error); Log.e(TAG, "Sign-in error: ", response.getError()); } } private List&lt;AuthUI.IdpConfig&gt; getSelectedProviders() { List&lt;AuthUI.IdpConfig&gt; selectedProviders = new ArrayList&lt;&gt;(); selectedProviders.add(new AuthUI.IdpConfig.GoogleBuilder() .build()); selectedProviders.add(new AuthUI.IdpConfig.FacebookBuilder() .build()); selectedProviders.add(new AuthUI.IdpConfig.EmailBuilder() .setRequireName(true) .setAllowNewAccounts(true) .build()); //selectedProviders // .add(new AuthUI.IdpConfig.PhoneBuilder().build()); return selectedProviders; } public void showSnackbar(@StringRes int errorMessageRes) { View parentLayout = findViewById(android.R.id.content); Snackbar.make(parentLayout, errorMessageRes, Snackbar.LENGTH_LONG).show(); } @Override public void onBackPressed() { finishAffinity(); } </code></pre>
0debug
void backup_start(BlockDriverState *bs, BlockDriverState *target, int64_t speed, MirrorSyncMode sync_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockCompletionFunc *cb, void *opaque, Error **errp) { int64_t len; assert(bs); assert(target); assert(cb); if (bs == target) { error_setg(errp, "Source and target cannot be the same"); 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"); len = bdrv_getlength(bs); if (len < 0) { error_setg_errno(errp, -len, "unable to get length for '%s'", BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed, cb, opaque, errp); if (!job) { bdrv_op_block_all(target, job->common.blocker); job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->target = target; job->sync_mode = sync_mode; job->common.len = len; job->common.co = qemu_coroutine_create(backup_run); qemu_coroutine_enter(job->common.co, job);
1threat
Select pound sign and all the text after it in url : How do I remove a URL's pound sign and the text after it with jQuery on click? For example, the URL is http://www.website.com/home#content I want the whole *#content* text to be removed.
0debug
Nuxt + Vuex - How do I break down a Vuex module into separate files? : <p>In the Nuxt documentation (<a href="https://nuxtjs.org/guide/vuex-store/#module-files" rel="noreferrer">here</a>) it says 'You can optionally break down a module file into separate files: <code>state.js</code>, <code>actions.js</code>, <code>mutations.js</code> and <code>getters.js</code>.'</p> <p>I can't seem to find any examples of how this is done - lots of breaking down the Vuex store at the root level into <code>state.js</code>, <code>actions.js</code>, <code>mutations.js</code> and <code>getters.js</code>, and into individual module files, but nothing about breaking the modules themselves down.</p> <p>So currently I have:</p> <pre><code> ├── assets ├── components └── store ├── moduleOne.js ├── moduleTwo.js └── etc... </code></pre> <p>And what I would like to have is:</p> <pre><code> ├── assets ├── components └── store └── moduleOne └── state.js └── getters.js └── mutations.js └── actions.js └── moduleTwo └── etc... </code></pre> <p>To try this out, in <code>/store/moduleOne/state.js</code> I have:</p> <pre><code>export const state = () =&gt; { return { test: 'test' } }; </code></pre> <p>and in <code>/store/moduleOne/getters.js</code> I have:</p> <pre><code>export const getters = { getTest (state) { return state.test; } } </code></pre> <p>In my component I'm accessing this with <code>$store.getters['moduleOne/getters/getTest']</code></p> <p>However using the debugger and Vue devtools, it seems like state isn't accessible in the getters file - it seems to be looking for a state in the local file, so <code>state.test</code> is undefined.</p> <p>Attempting to import <code>state</code> from my <code>state.js</code> file into my <code>getters.js</code> file doesn't seem to work either.</p> <p>Does anyone have an example of how they've managed to break the store down like this in Nuxt?</p>
0debug
why this code takes one less input from standard input? : <p>Giving input as: <pre>Input: 3 1 2 3 4 5 6 7 8 9 10 11 12 Expected Output: 1 2 3 4 5 6 7 8 9 10 11 12 </pre> But it is giving the Output- <pre> 1 2 3 4 5 6 7 </pre> Why it is not giving the last line ? Is there any mistake in my code?</p> <pre><code>#include &lt;iostream&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; using namespace std; int main() { int t; cin&gt;&gt;t; while(t--) { string str; getline(cin,str,'\n'); cout&lt;&lt;str&lt;&lt;endl; } return 0; } </code></pre>
0debug
How to sorting by date string with mat-sort-header? : <p>I have a case table constructed with <code>angular.material</code> and I need to add sorting by date. But my date is a <code>string</code> type, and so sorting incorrectly. How to overriding default <code>mat-sort-header</code> behavior. And it's possible?</p> <pre><code>&lt;div class="example-container mat-elevation-z8"&gt; &lt;mat-table #table [dataSource]="dataSource" matSort&gt; &lt;!-- Reg Date Column --&gt; &lt;ng-container matColumnDef="regDate"&gt; &lt;mat-header-cell *matHeaderCellDef mat-sort-header&gt; Reg Date &lt;/mat-header-cell&gt; &lt;mat-cell *matCellDef="let element"&gt; {{element.regDate}} &lt;/mat-cell&gt; &lt;/ng-container&gt; &lt;mat-header-row *matHeaderRowDef="displayedColumns"&gt;&lt;/mat-header-row&gt; &lt;mat-row *matRowDef="let row; columns: displayedColumns;"&gt;&lt;/mat-row&gt; &lt;/mat-table&gt; &lt;/div&gt; </code></pre> <p>And on TS side:</p> <pre><code>sort: MatSort; @ViewChild(MatSort) set appBacon(sort : MatSort) { this.sort = sort; this.dataSource.sort = this.sort; } dataSource = new MatTableDataSource([]); </code></pre>
0debug
ImageView in ListView briefly shows previous image on scroll with RecycleElement enabled : <p>I have a list of the following class:</p> <pre><code>public class Set { public string IconUrl { get; set; } } </code></pre> <p>This list is bound to a ListView:</p> <pre><code>&lt;ListView ItemsSource="{Binding Sets}"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ViewCell&gt; &lt;ViewCell.View&gt; &lt;Image Source="{Binding IconUrl}" /&gt; &lt;/ViewCell.View&gt; &lt;/ViewCell&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <p>When the view loads and the user starts scrolling, the cells are reused and the Image briefly shows the previous image before the new image is downloaded and rendered.</p> <p>Is there a way to prevent this kind of behavior without disabling RecycleElement?</p>
0debug
Beginner trying to program simple change calculator : <p>I'm new to coding and need to write a program for C# the goal is to write a program that prompts the user to enter an amount including decimals. and the program gives the user back the remander as money. ie...</p> <p>quater dimes nickle pennie</p>
0debug
Why the gradle war task is skipped? : <p>I am a new convert to gradle. Most of the tasks work fine. However I see that the war task is always skipped. When I run in the debug mode, I see the following logs -</p> <blockquote> <p>09:12:34.889 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :war 09:12:34.889 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':war' 09:12:34.889 [INFO] <strong>[org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter] Skipping task ':war' as task onlyIf is false.</strong> 09:12:34.889 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':war' 09:12:34.889 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :war SKIPPED</p> </blockquote> <p>I am not sure why onlyIf is false. I did search on internet. But I did not find anything related.</p> <p>Here is my gradle file -</p> <pre><code>buildscript { ext { springBootVersion = '2.0.0.M2' } repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } // Apply the java-library plugin to add support for Java Library apply plugin: 'java-library' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'war' apply plugin: 'checkstyle' apply plugin: 'pmd' apply plugin: 'findbugs' apply plugin: 'jacoco' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { jcenter() mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { compile('org.springframework.boot:spring-boot-starter') compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.retry:spring-retry:1.2.1.RELEASE") compile("org.springframework.data:spring-data-cassandra:2.0.0.M4") compile("io.reactivex.rxjava2:rxjava:2.1.1") //compile("javax.persistence:persistence-api:1.0.2") //compile("org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("com.zaxxer:HikariCP:2.6.0") // Test Dependencies testCompile("org.springframework.boot:spring-boot-starter-test") testCompile("org.powermock:powermock-mockito-release-full:1.6.4") testCompile("org.mockito:mockito-core:2.0.3-beta") testCompile("org.cassandraunit:cassandra-unit:3.1.3.2") testCompile("org.cassandraunit:cassandra-unit-spring:2.2.2.1") testCompile("com.h2database:h2:1.4.196") // This dependency is exported to consumers, that is to say found on their compile classpath. api 'org.apache.commons:commons-math3:3.6.1' // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation 'com.google.guava:guava:21.0' testImplementation 'junit:junit:4.12' } </code></pre> <p>Here is the image of my project structure -</p> <p><a href="https://i.stack.imgur.com/mNn3u.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mNn3u.png" alt="enter image description here"></a></p> <p>If you could help me with generating the war file that would be great.</p>
0debug
static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) { AVFrame *pic = data; int i, j; int aligned_width = FFALIGN(avctx->width, 64); uint8_t *src_line; uint8_t *dst = buf; if (buf_size < 4 * aligned_width * avctx->height) { av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); return AVERROR(ENOMEM); } avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->data[0]; for (i = 0; i < avctx->height; i++) { uint16_t *src = (uint16_t *)src_line; for (j = 0; j < avctx->width; j++) { uint32_t pixel; uint16_t r = *src++ >> 6; uint16_t g = *src++ >> 6; uint16_t b = *src++ >> 4; if (avctx->codec_id == CODEC_ID_R210) pixel = (r << 20) | (g << 10) | b >> 2; else pixel = (r << 22) | (g << 12) | b; if (avctx->codec_id == CODEC_ID_AVRP) bytestream_put_le32(&dst, pixel); else bytestream_put_be32(&dst, pixel); } dst += (aligned_width - avctx->width) * 4; src_line += pic->linesize[0]; } return 4 * aligned_width * avctx->height; }
1threat
How to "Delete derived data" in Xcode8? : <p>In Xcode7 you click Window -> Projects and select the projects that you want the derived data to be deleted.</p> <p>But with <strong>Xcode8 beta 2</strong> the project menu no longer exists under the Windows menu. Are there any quick methods to delete the derived data through Xcode8 interface?</p>
0debug
Need clarification on cmd, powershell, developer command prompt etc : <p>those things all have a window for me to type commands in. it has been a while but i still don't know what are the differences. can someone clarify please? Thanks.</p>
0debug
static void test_visitor_out_struct_nested(TestOutputVisitorData *data, const void *unused) { int64_t value = 42; Error *err = NULL; UserDefNested *ud2; QObject *obj; QDict *qdict, *dict1, *dict2, *dict3, *userdef; const char *string = "user def string"; const char *strings[] = { "forty two", "forty three", "forty four", "forty five" }; ud2 = g_malloc0(sizeof(*ud2)); ud2->string0 = g_strdup(strings[0]); ud2->dict1.string1 = g_strdup(strings[1]); ud2->dict1.dict2.userdef1 = g_malloc0(sizeof(UserDefOne)); ud2->dict1.dict2.userdef1->string = g_strdup(string); ud2->dict1.dict2.userdef1->base = g_new0(UserDefZero, 1); ud2->dict1.dict2.userdef1->base->integer = value; ud2->dict1.dict2.string2 = g_strdup(strings[2]); ud2->dict1.has_dict3 = true; ud2->dict1.dict3.userdef2 = g_malloc0(sizeof(UserDefOne)); ud2->dict1.dict3.userdef2->string = g_strdup(string); ud2->dict1.dict3.userdef2->base = g_new0(UserDefZero, 1); ud2->dict1.dict3.userdef2->base->integer = value; ud2->dict1.dict3.string3 = g_strdup(strings[3]); visit_type_UserDefNested(data->ov, &ud2, "unused", &err); g_assert(!err); obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QDICT); qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 2); g_assert_cmpstr(qdict_get_str(qdict, "string0"), ==, strings[0]); dict1 = qdict_get_qdict(qdict, "dict1"); g_assert_cmpint(qdict_size(dict1), ==, 3); g_assert_cmpstr(qdict_get_str(dict1, "string1"), ==, strings[1]); dict2 = qdict_get_qdict(dict1, "dict2"); g_assert_cmpint(qdict_size(dict2), ==, 2); g_assert_cmpstr(qdict_get_str(dict2, "string2"), ==, strings[2]); userdef = qdict_get_qdict(dict2, "userdef1"); g_assert_cmpint(qdict_size(userdef), ==, 2); g_assert_cmpint(qdict_get_int(userdef, "integer"), ==, value); g_assert_cmpstr(qdict_get_str(userdef, "string"), ==, string); dict3 = qdict_get_qdict(dict1, "dict3"); g_assert_cmpint(qdict_size(dict3), ==, 2); g_assert_cmpstr(qdict_get_str(dict3, "string3"), ==, strings[3]); userdef = qdict_get_qdict(dict3, "userdef2"); g_assert_cmpint(qdict_size(userdef), ==, 2); g_assert_cmpint(qdict_get_int(userdef, "integer"), ==, value); g_assert_cmpstr(qdict_get_str(userdef, "string"), ==, string); QDECREF(qdict); qapi_free_UserDefNested(ud2); }
1threat
Sed awk text formating : I would like to filter and order text files with soemthing like awk or sed. It does not need to be a single command, a small bash script should be fine too. # home=address01 name=name01 info=info01 number=number01 company=company01 # name=name02 company=company02 info=info02 home=home02 # company=company03 home=address03 name=name03 info=info03 info=info032 number=number03 company=company032 # .... I only need name, number, and info. There is always exactly one name, but there can be 0,1 or 2 number and info. The # is the only thing which is consistent and always on the same spot. output should be: name01, number01, , info01, name02, , ,info02, name03,number03, , info03, info032 Thanks for your help!
0debug
static void spapr_msi_setmsg(PCIDevice *pdev, hwaddr addr, bool msix, unsigned req_num) { unsigned i; MSIMessage msg = { .address = addr, .data = 0 }; if (!msix) { msi_set_message(pdev, msg); trace_spapr_pci_msi_setup(pdev->name, 0, msg.address); return; } for (i = 0; i < req_num; ++i) { msg.address = addr | (i << 2); msix_set_message(pdev, i, msg); trace_spapr_pci_msi_setup(pdev->name, i, msg.address); } }
1threat
Organizing functions with inter dependencies; : <p>I would like to write a set of cpp functions for importing from a file type into a data structure which has inter dependencies to each other. As I don't need any member variables to remember anything after importing the file, is it a good idea to create a class with just static functions or create a namespace and put all functions into it without class. </p>
0debug
Julia - how does @inline work? When to use function vs. macro? : <p>I have many small functions I would like to inline, for example to test flags for some condition:</p> <pre><code>const COND = UInt(1&lt;&lt;BITS_FOR_COND) function is_cond(flags::UInt) return flags &amp; COND != 0 end </code></pre> <p>I could also make a macro: </p> <pre><code>macro IS_COND(flags::UInt) return :(flags &amp; COND != 0) end </code></pre> <p>My motivation is many similar macro functions in the C code I am working with:</p> <pre><code>#define IS_COND(flags) ((flags) &amp; COND) </code></pre> <p>I repeatedly timed the function, macro, function defined with @inline, and the expression by itself, but none are consistently faster than the others across many runs. The generated code for the function call in 1) and 3) are much longer than for the expression in 4), but I don't know how to compare 2) since <code>@code_llvm</code> etc. don't work on other macros.</p> <pre><code>1) for j=1:10 @time for i::UInt=1:10000 is_cond(i); end end 2) for j=1:10 @time for i::UInt=1:10000 @IS_COND(i); end end 3) for j=1:10 @time for i::UInt=1:10000 is_cond_inlined(i); end end 4) for j=1:10 @time for i::UInt=1:10000 i &amp; COND != 0; end end </code></pre> <p>Questions: What is the purpose of <code>@inline</code>? I see from the sparse documentation that it appends the symbol <code>:inline</code> to the expression <code>:meta</code>, but what does that do, exactly? Is there any reason to prefer a function or macro for this kind of task?</p> <p>My understanding is that a C macro function just substitutes the literal text of the macro at compile time, so the resulting code has no jumps and is therefore more efficient than a regular function call. (Safety is another issue, but let's assume the programmers know what they're doing.) A Julia macro has intermediate steps like parsing its arguments, so it's not obvious to me whether 2) should be faster than a 1). Ignoring for the moment that in this case the difference in performance is negligible, what technique results in the most efficient code?</p>
0debug
static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh, uint32_t fid, uint64_t faddr, uint32_t e) { SeiContainer *sei_cont; S390pciState *s = S390_PCI_HOST_BRIDGE( object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL)); if (!s) { return; } sei_cont = g_malloc0(sizeof(SeiContainer)); sei_cont->fh = fh; sei_cont->fid = fid; sei_cont->cc = cc; sei_cont->pec = pec; sei_cont->faddr = faddr; sei_cont->e = e; QTAILQ_INSERT_TAIL(&s->pending_sei, sei_cont, link); css_generate_css_crws(0); }
1threat
How to multiply a double array and a double together in java : I'm new to this site, and am working on a school assignment, but got stuck. I was wondering if there is any way to multiply a double []array by a double? for(int i = 0; i <= speed.length; i++) double [] mph = speed[i] * 1.15; That is my code, but when I compile it in java, it says "Incompatible types: double cannot be converted to double[]" How do I fix this?
0debug
void timer_free(QEMUTimer *ts) { g_free(ts); }
1threat
How to listen to route changes in react router v4? : <p>I have a couple of buttons that acts as routes. Everytime the route is changed, I want to make sure the button that is active changes.</p> <p>Is there a way to listen to route changes in react router v4?</p>
0debug
static int aiff_read_header(AVFormatContext *s) { int ret, size, filesize; int64_t offset = 0, position; uint32_t tag; unsigned version = AIFF_C_VERSION1; AVIOContext *pb = s->pb; AVStream * st; AIFFInputContext *aiff = s->priv_data; ID3v2ExtraMeta *id3v2_extra_meta = NULL; filesize = get_tag(pb, &tag); if (filesize < 0 || tag != MKTAG('F', 'O', 'R', 'M')) return AVERROR_INVALIDDATA; tag = avio_rl32(pb); if (tag == MKTAG('A', 'I', 'F', 'F')) version = AIFF; else if (tag != MKTAG('A', 'I', 'F', 'C')) return AVERROR_INVALIDDATA; filesize -= 4; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); while (filesize > 0) { size = get_tag(pb, &tag); if (size == AVERROR_EOF && offset > 0 && st->codecpar->block_align) { av_log(s, AV_LOG_WARNING, "header parser hit EOF\n"); goto got_sound; } if (size < 0) return size; filesize -= size + 8; switch (tag) { case MKTAG('C', 'O', 'M', 'M'): st->nb_frames = get_aiff_header(s, size, version); if (st->nb_frames < 0) return st->nb_frames; if (offset > 0) goto got_sound; break; case MKTAG('I', 'D', '3', ' '): position = avio_tell(pb); ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, size); if (id3v2_extra_meta) if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0) { ff_id3v2_free_extra_meta(&id3v2_extra_meta); return ret; } ff_id3v2_free_extra_meta(&id3v2_extra_meta); if (position + size > avio_tell(pb)) avio_skip(pb, position + size - avio_tell(pb)); break; case MKTAG('F', 'V', 'E', 'R'): version = avio_rb32(pb); break; case MKTAG('N', 'A', 'M', 'E'): get_meta(s, "title" , size); break; case MKTAG('A', 'U', 'T', 'H'): get_meta(s, "author" , size); break; case MKTAG('(', 'c', ')', ' '): get_meta(s, "copyright", size); break; case MKTAG('A', 'N', 'N', 'O'): get_meta(s, "comment" , size); break; case MKTAG('S', 'S', 'N', 'D'): aiff->data_end = avio_tell(pb) + size; offset = avio_rb32(pb); avio_rb32(pb); offset += avio_tell(pb); if (st->codecpar->block_align && !pb->seekable) goto got_sound; if (!pb->seekable) { av_log(s, AV_LOG_ERROR, "file is not seekable\n"); return -1; } avio_skip(pb, size - 8); break; case MKTAG('w', 'a', 'v', 'e'): if ((uint64_t)size > (1<<30)) return -1; if (ff_get_extradata(s, st->codecpar, pb, size) < 0) return AVERROR(ENOMEM); if ( (st->codecpar->codec_id == AV_CODEC_ID_QDMC || st->codecpar->codec_id == AV_CODEC_ID_QDM2) && size>=12*4 && !st->codecpar->block_align) { st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4); aiff->block_duration = AV_RB32(st->codecpar->extradata+9*4); } else if (st->codecpar->codec_id == AV_CODEC_ID_QCELP) { char rate = 0; if (size >= 25) rate = st->codecpar->extradata[24]; switch (rate) { case 'H': st->codecpar->block_align = 17; break; case 'F': default: st->codecpar->block_align = 35; } aiff->block_duration = 160; st->codecpar->bit_rate = st->codecpar->sample_rate * (st->codecpar->block_align << 3) / aiff->block_duration; } break; case MKTAG('C','H','A','N'): if(ff_mov_read_chan(s, pb, st, size) < 0) return AVERROR_INVALIDDATA; break; case 0: if (offset > 0 && st->codecpar->block_align) goto got_sound; default: if (size & 1) size++; avio_skip(pb, size); } } got_sound: if (!st->codecpar->block_align && st->codecpar->codec_id == AV_CODEC_ID_QCELP) { av_log(s, AV_LOG_WARNING, "qcelp without wave chunk, assuming full rate\n"); st->codecpar->block_align = 35; } else if (!st->codecpar->block_align) { av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n"); return -1; } avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); st->start_time = 0; st->duration = st->nb_frames * aiff->block_duration; avio_seek(pb, offset, SEEK_SET); return 0; }
1threat
i want to sort by name : this code i used for sort int values.But now i want to sort Strings.This is my code. public class Comparable5 { public static void main(String[] args) { TreeSet ts=new TreeSet(); ts.add(new Student1(2,"Thilan")); ts.add(new Student1(1,"Kamal")); ts.add(new Student1(3,"Nimal")); System.out.println(ts); } } class Student1 implements Comparable<Student>{ int id; String name; public Student1(int id,String name){ this.id=id; this.name=name; } @Override public String toString() { return this.id+":"+this.name; } @Override public int compareTo(Student o) { if (o.name.equals(this.name)) { return -1; } else if(o.name.equals(this.name)){ return +1; } else{ return 0; } } } i'm trying to sort names using Comparable Interface.In here i used equals method.But i unable to do sorting.in here i had used a constructor that has two parameter.I have already done sorting ids.but i'm unable to do that to names(String).how i sort Strings using compareTo method in Comparable interface.
0debug
Reshape numpy (n,) vector to (n,1) vector : <p>So it is easier for me to think about vectors as column vectors when I need to do some linear algebra. Thus I prefer shapes like (n,1). </p> <p>Is there significant memory usage difference between shapes (n,) and (n,1)? </p> <p>What is preferred way? </p> <p>And how to reshape (n,) vector into (n,1) vector. Somehow b.reshape((n,1)) doesn't do the trick. </p> <pre><code>a = np.random.random((10,1)) b = np.ones((10,)) b.reshape((10,1)) print(a) print(b) [[ 0.76336295] [ 0.71643237] [ 0.37312894] [ 0.33668241] [ 0.55551975] [ 0.20055153] [ 0.01636735] [ 0.5724694 ] [ 0.96887004] [ 0.58609882]] [ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] </code></pre>
0debug
How to index a list with a TensorFlow tensor? : <p>Assume a list with non concatenable objects which needs to be accessed via a look up table. So the list index will be a tensor object but this is not possible.</p> <pre><code> tf_look_up = tf.constant(np.array([3, 2, 1, 0, 4])) index = tf.constant(2) list = [0,1,2,3,4] target = list[tf_look_up[index]] </code></pre> <p>This will bring out the following error message. </p> <pre><code> TypeError: list indices must be integers or slices, not Tensor </code></pre> <p>Is the a way/workaround to index lists with tensors?</p>
0debug
This async method lacks 'await' operators and will run synchronously : <p>my program has 3 warnings of the following statement:</p> <blockquote> <p>This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.</p> </blockquote> <p>What is the warning try to tell me? What should I do? </p> <p>This is my code: Is it running using multi-threading?</p> <pre><code>static void Main(string[] args) { Task task1 = new Task(Work1); Task task2 = new Task(Work2); Task task3 = new Task(Work3); task1.Start(); task2.Start(); task3.Start(); Console.ReadKey(); } static async void Work1() { Console.WriteLine("10 started"); Thread.Sleep(10000); Console.WriteLine("10 completed"); } static async void Work2() { Console.WriteLine("3 started"); Thread.Sleep(3000); Console.WriteLine("3 completed"); } static async void Work3() { Console.WriteLine("5 started"); Thread.Sleep(5000); Console.WriteLine("5 completed"); } </code></pre>
0debug
How to center the image in bootstrap 4? : <p>I am new to Bootstrap 4, earlier in Bootstrap 3 we use class "center-block", now I am not able to find this in new version.</p>
0debug
Is there any mechanism in C to take password from user, like we have in JAVA as password field : <p>Password, while typing should not be visible(stars should be visible instead of characters). Can it be done in C, as we have in JAVA.</p>
0debug
static void piix3_ide_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->no_hotplug = 1; k->init = pci_piix_ide_initfn; k->exit = pci_piix_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1; k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->no_user = 1; }
1threat
Could not find method android() for arguments in Android Studio project : <p>I am trying to do a grade sync on my android studio project and I keep getting this error in the title. My build.gradle file is </p> <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } android { compileSdkVersion 24 buildToolsVersion '24.0.0' } dependencies { } </code></pre> <p>My error message is</p> <pre><code>Gradle sync failed: Could not find method android() for arguments [build_aiwlctiq29euo9devcma4v4r7$_run_closure3@22efc0bc] on root project 'MyRadio </code></pre> <p>I have looked online and tried multiple solutions but nothing seems to work. What does this even mean? Any help would be appreciated.</p>
0debug
how to do a "Save as" window with tkinter? : <p><br/> There is some way to create a save window as without having to do it from scratch in python (tkinter)? <br/> </p> <pre><code>from tkinter import * </code></pre>
0debug
static int vc1_decode_p_mb(VC1Context *v, DCTELEM block[6][64]) { MpegEncContext *s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int cbp; int mqdiff, mquant; int ttmb = v->ttfrm; int status; static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, offset_table[6] = { 0, 1, 3, 7, 15, 31 }; int mb_has_coeffs = 1; int dmv_x, dmv_y; int index, index1; int val, sign; int first_block = 1; int dst_idx, off; int skipped, fourmv; mquant = v->pq; if (v->mv_type_is_raw) fourmv = get_bits1(gb); else fourmv = v->mv_type_mb_plane[mb_pos]; if (v->skip_is_raw) skipped = get_bits1(gb); else skipped = v->s.mbskip_table[mb_pos]; s->dsp.clear_blocks(s->block[0]); if (!fourmv) { if (!skipped) { GET_MVDATA(dmv_x, dmv_y); s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16; vc1_pred_mv(s, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]); if (s->mb_intra && !mb_has_coeffs) { GET_MQUANT(); s->ac_pred = get_bits(gb, 1); cbp = 0; } else if (mb_has_coeffs) { if (s->mb_intra) s->ac_pred = get_bits(gb, 1); cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); } else { mquant = v->pq; cbp = 0; } s->current_picture.qscale_table[mb_pos] = mquant; if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) ttmb = get_vlc2(gb, vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); if(!s->mb_intra) vc1_mc_1mv(v); dst_idx = 0; for (i=0; i<6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); v->mb_type[0][s->block_index[i]] = s->mb_intra; if(s->mb_intra) { v->a_avail = v->c_avail = 0; if(i == 2 || i == 3 || s->mb_y) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; if(i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; vc1_decode_intra_block(v, block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); vc1_inv_trans(block[i], 8, 8); for(j = 0; j < 64; j++) block[i][j] += 128; s->dsp.put_pixels_clamped(block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); if(v->pq >= 9 && v->overlap) { if(v->a_avail) s->dsp.h263_v_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale); if(v->c_avail) s->dsp.h263_h_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale); } } else if(val) { vc1_decode_p_block(v, block[i], i, mquant, ttmb, first_block); if(!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; s->dsp.add_pixels_clamped(block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); } } } else { s->mb_intra = 0; for(i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0; s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP; s->current_picture.qscale_table[mb_pos] = 0; vc1_pred_mv(s, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]); vc1_mc_1mv(v); return 0; } } else { if (!skipped ) { int intra_count = 0, coded_inter = 0; int is_intra[6], is_coded[6]; cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); for (i=0; i<6; i++) { val = ((cbp >> (5 - i)) & 1); s->dc_val[0][s->block_index[i]] = 0; s->mb_intra = 0; if(i < 4) { dmv_x = dmv_y = 0; s->mb_intra = 0; mb_has_coeffs = 0; if(val) { GET_MVDATA(dmv_x, dmv_y); } vc1_pred_mv(s, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]); if(!s->mb_intra) vc1_mc_4mv_luma(v, i); intra_count += s->mb_intra; is_intra[i] = s->mb_intra; is_coded[i] = mb_has_coeffs; } if(i&4){ is_intra[i] = (intra_count >= 3); is_coded[i] = val; } if(i == 4) vc1_mc_4mv_chroma(v); v->mb_type[0][s->block_index[i]] = is_intra[i]; if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i]; } dst_idx = 0; GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; { int intrapred = 0; for(i=0; i<6; i++) if(is_intra[i]) { if(((s->mb_y || (i==2 || i==3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]]) || ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) { intrapred = 1; break; } } if(intrapred)s->ac_pred = get_bits(gb, 1); else s->ac_pred = 0; } if (!v->ttmbf && coded_inter) ttmb = get_vlc2(gb, vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 12); for (i=0; i<6; i++) { dst_idx += i >> 2; off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); s->mb_intra = is_intra[i]; if (is_intra[i]) { v->a_avail = v->c_avail = 0; if(i == 2 || i == 3 || s->mb_y) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; if(i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset); vc1_inv_trans(block[i], 8, 8); for(j = 0; j < 64; j++) block[i][j] += 128; s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); if(v->pq >= 9 && v->overlap) { if(v->a_avail) s->dsp.h263_v_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale); if(v->c_avail) s->dsp.h263_h_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale); } } else if(is_coded[i]) { status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); if(!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); } } return status; } else MB { s->mb_intra = 0; for (i=0; i<6; i++) v->mb_type[0][s->block_index[i]] = 0; for (i=0; i<4; i++) { vc1_pred_mv(s, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]); vc1_mc_4mv_luma(v, i); } vc1_mc_4mv_chroma(v); s->current_picture.qscale_table[mb_pos] = 0; return 0; } } return -1; }
1threat
static void avc_loopfilter_cb_or_cr_intra_edge_hor_msa(uint8_t *data_cb_or_cr, uint8_t alpha_in, uint8_t beta_in, uint32_t img_width) { v16u8 alpha, beta; v16u8 is_less_than; v8i16 p0_or_q0, q0_or_p0; v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org; v16i8 zero = { 0 }; v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0; v16u8 is_less_than_alpha, is_less_than_beta; v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r; alpha = (v16u8) __msa_fill_b(alpha_in); beta = (v16u8) __msa_fill_b(beta_in); p1_or_q1_org = LOAD_UB(data_cb_or_cr - (img_width << 1)); p0_or_q0_org = LOAD_UB(data_cb_or_cr - img_width); q0_or_p0_org = LOAD_UB(data_cb_or_cr); q1_or_p1_org = LOAD_UB(data_cb_or_cr + img_width); p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org); p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org); q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org); is_less_than_alpha = (p0_asub_q0 < alpha); is_less_than_beta = (p1_asub_p0 < beta); is_less_than = is_less_than_beta & is_less_than_alpha; is_less_than_beta = (q1_asub_q0 < beta); is_less_than = is_less_than_beta & is_less_than; is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than); if (!__msa_test_bz_v(is_less_than)) { p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org); p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org); q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org); q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org); AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0); AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0); p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0); q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0); p0_or_q0_org = __msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than); q0_or_p0_org = __msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than); STORE_UB(q0_or_p0_org, data_cb_or_cr); STORE_UB(p0_or_q0_org, data_cb_or_cr - img_width); } }
1threat
Spotify API: INVALID_APP_ID : <p>I am currently working on an android app which is implementing the Spotify API. I have all of the code connecting my app to spotify using the tutorial and have been working on my app for sometime now. When I play a song through my app after authenticating the user, it works perfectly, that is on my emulator. When I switch it over to my phone it didn't work and gave me an INVALID_APP_ID error in the android response. When I uninstalled spotify off my phone and then tried to login to spotify through my app, I was then able to play music from my phone without any crashes. So my question is how do I fix that? Here is my code for authenticating a user: </p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); // Check if result comes from the correct activity if (requestCode == requestcode) { AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent); if (response.getType() == AuthenticationResponse.Type.TOKEN) { Config playerConfig = new Config(this, response.getAccessToken(), client_id); token = response.getAccessToken(); Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() { @Override public void onInitialized(Player player) { mPlayer = player; mPlayer.addConnectionStateCallback(.this); mPlayer.addPlayerNotificationCallback(.this); } @Override public void onError(Throwable throwable) { Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage()); } }); } } } </code></pre>
0debug
static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s) { int copy_count; uint8_t *end_ptr; if (s->cirrus_srccounter > 0) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { cirrus_bitblt_common_patterncopy(s, false); the_end: s->cirrus_srccounter = 0; cirrus_bitblt_reset(s); } else { do { (*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0, s->cirrus_blt_width, 1); s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch; s->cirrus_srccounter -= s->cirrus_blt_srcpitch; if (s->cirrus_srccounter <= 0) goto the_end; end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; copy_count = s->cirrus_srcptr_end - end_ptr; memmove(s->cirrus_bltbuf, end_ptr, copy_count); s->cirrus_srcptr = s->cirrus_bltbuf + copy_count; s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; } while (s->cirrus_srcptr >= s->cirrus_srcptr_end); } } }
1threat
how to start a method from a class to another class android studio : how do i start getdata() method to another class. I want to show the output to a listview which is in another java class **tab1Background.java** public class tab1Background extends Activity{ ListView lv; lv = (ListView) findViewById(R.id.lv); ....some code here public void getdata() { ....some code here } } **tab1report.java** public class tab1report extends Fragment { ....some code here }
0debug
static void cirrus_update_memory_access(CirrusVGAState *s) { unsigned mode; if ((s->sr[0x17] & 0x44) == 0x44) { goto generic_io; } else if (s->cirrus_srcptr != s->cirrus_srcptr_end) { goto generic_io; } else { if ((s->gr[0x0B] & 0x14) == 0x14) { goto generic_io; } else if (s->gr[0x0B] & 0x02) { goto generic_io; } mode = s->gr[0x05] & 0x7; if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) { map_linear_vram(s); s->cirrus_linear_write[0] = cirrus_linear_mem_writeb; s->cirrus_linear_write[1] = cirrus_linear_mem_writew; s->cirrus_linear_write[2] = cirrus_linear_mem_writel; } else { generic_io: unmap_linear_vram(s); s->cirrus_linear_write[0] = cirrus_linear_writeb; s->cirrus_linear_write[1] = cirrus_linear_writew; s->cirrus_linear_write[2] = cirrus_linear_writel; } } }
1threat
int load_vmstate(const char *name) { BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn; QEMUFile *f; int ret; bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) { continue; } if (!bdrv_can_snapshot(bs)) { error_report("Device '%s' is writable but does not support snapshots.", bdrv_get_device_name(bs)); return -ENOTSUP; } } bs = bdrv_snapshots(); if (!bs) { error_report("No block device supports snapshots"); return -EINVAL; } qemu_aio_flush(); bs1 = NULL; while ((bs1 = bdrv_next(bs1))) { if (bdrv_can_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { switch(ret) { case -ENOTSUP: error_report("%sSnapshots not supported on device '%s'", bs != bs1 ? "Warning: " : "", bdrv_get_device_name(bs1)); break; case -ENOENT: error_report("%sCould not find snapshot '%s' on device '%s'", bs != bs1 ? "Warning: " : "", name, bdrv_get_device_name(bs1)); break; default: error_report("%sError %d while activating snapshot on '%s'", bs != bs1 ? "Warning: " : "", ret, bdrv_get_device_name(bs1)); break; } if (bs == bs1) return 0; } } } ret = bdrv_snapshot_find(bs, &sn, name); if ((ret >= 0) && (sn.vm_state_size == 0)) return -EINVAL; f = qemu_fopen_bdrv(bs, 0); if (!f) { error_report("Could not open VM state file"); return -EINVAL; } ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { error_report("Error %d while loading VM state", ret); return ret; } return 0; }
1threat
"Idiot Check" in JavaScript (.toLowerCase and .toUpperCase) : <p>In my code, "SiAff" won't be the correct answer... I want to use ".toLowerCase" and ".toUpperCase", but I don't know how to do that. Any help would be appreciate</p> <pre><code>var Que = prompt("What's my name") if (Que == "Siaff") { document.write("Correct!") } else { document.write("Wrong!") } </code></pre>
0debug
def get_max_sum (n): res = list() res.append(0) res.append(1) i = 2 while i<n + 1: res.append(max(i, (res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))) i = i + 1 return res[n]
0debug
static int srt_get_duration(uint8_t **buf) { int i, duration = 0; for (i=0; i<2 && !duration; i++) { int s_hour, s_min, s_sec, s_hsec, e_hour, e_min, e_sec, e_hsec; if (sscanf(*buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d", &s_hour, &s_min, &s_sec, &s_hsec, &e_hour, &e_min, &e_sec, &e_hsec) == 8) { s_min += 60*s_hour; e_min += 60*e_hour; s_sec += 60*s_min; e_sec += 60*e_min; s_hsec += 1000*s_sec; e_hsec += 1000*e_sec; duration = e_hsec - s_hsec; } *buf += strcspn(*buf, "\n") + 1; } return duration; }
1threat
Dynamic import named export using Webpack : <p>Using webpack, if I want to code-split an entire module, I can change</p> <p><code>import Module from 'module'</code></p> <p>at the top of my file to</p> <p><code>import('module').then(Module =&gt; {...</code></p> <p>when I need to use the module (<a href="https://webpack.js.org/api/module-methods/#import-" rel="noreferrer">docs</a>). Is it possible to do this but with just a single named export? That is, how could I code-split the following:</p> <p><code>import {namedExport} from 'module'</code></p>
0debug
static av_always_inline void decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7) { VP8Context *s = avctx->priv_data; VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr]; int mb_y = td->thread_mb_pos >> 16; int mb_x, mb_xy = mb_y * s->mb_width; int num_jobs = s->num_jobs; VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame; VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)]; VP8Macroblock *mb; uint8_t *dst[3] = { curframe->tf.f->data[0] + 16 * mb_y * s->linesize, curframe->tf.f->data[1] + 8 * mb_y * s->uvlinesize, curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize }; if (mb_y == 0) prev_td = td; else prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs]; if (mb_y == s->mb_height - 1) next_td = td; else next_td = &s->thread_data[(jobnr + 1) % num_jobs]; if (s->mb_layout == 1) mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1); else { if (prev_frame && s->segmentation.enabled && !s->segmentation.update_map) ff_thread_await_progress(&prev_frame->tf, mb_y, 0); mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2; memset(mb - 1, 0, sizeof(*mb)); AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101); } if (!is_vp7 || mb_y == 0) memset(td->left_nnz, 0, sizeof(td->left_nnz)); s->mv_min.x = -MARGIN; s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { if (prev_td != td) { if (threadnr != 0) { check_thread_pos(td, prev_td, mb_x + (is_vp7 ? 2 : 1), mb_y - (is_vp7 ? 2 : 1)); } else { check_thread_pos(td, prev_td, mb_x + (is_vp7 ? 2 : 1) + s->mb_width + 3, mb_y - (is_vp7 ? 2 : 1)); } } s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 * s->linesize + 64, s->linesize, 4); s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64, dst[2] - dst[1], 2); if (!s->mb_layout) decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy, prev_frame && prev_frame->seg_map ? prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); if (!mb->skip) decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz, is_vp7); if (mb->mode <= MODE_I4x4) intra_predict(s, td, dst, mb, mb_x, mb_y, is_vp7); else inter_predict(s, td, dst, mb, mb_x, mb_y); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN); if (!mb->skip) { idct_mb(s, td, dst, mb); } else { AV_ZERO64(td->left_nnz); AV_WN64(s->top_nnz[mb_x], 0); if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { td->left_nnz[8] = 0; s->top_nnz[mb_x][8] = 0; } } if (s->deblock_filter) filter_level_for_mb(s, mb, &td->filter_strength[mb_x], is_vp7); if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) { if (s->filter.simple) backup_mb_border(s->top_border[mb_x + 1], dst[0], NULL, NULL, s->linesize, 0, 1); else backup_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2], s->linesize, s->uvlinesize, 0); } prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2); dst[0] += 16; dst[1] += 8; dst[2] += 8; s->mv_min.x -= 64; s->mv_max.x -= 64; if (mb_x == s->mb_width + 1) { update_pos(td, mb_y, s->mb_width + 3); } else { update_pos(td, mb_y, mb_x); } } }
1threat
def find_angle(a,b): c = 180 - (a + b) return c
0debug
Save X,Y and Z data in database : <p>I want to know what is the best way to save X and Y and Z points in a database, However the amount of data might be huge. I tried to save them as a text and the convert to numbers, It worked but i want to know if there is a better way.</p>
0debug
how can i be able to check weather particular username or password is correct or the session is created after getting autharised : how can i be able to check weather particular username or password is correct or the session is created after getting autharised private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { final String uid=jTextField1.getText(); String pass = new String(jPasswordField1.getPassword()); //server Config Properties prop=new Properties(); prop.put("mail.smtp.auth","true"); prop.put("mail.smtp.starttls.enable","true"); prop.put("mail.smtp.host","smtp.gmail.com"); prop.put("mail.smtp.port","587"); //client Authentication Authenticator auth=new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(uid,pass); } }; //Session Creation Session session= Session.getInstance(prop,auth); try{ String to=JOptionPane.showInputDialog("To :"); String sub=JOptionPane.showInputDialog("Subject :"); String data=JOptionPane.showInputDialog("Compose :"); //Message Creation Message msg=new MimeMessage(session); msg.setFrom(new InternetAddress(uid)); msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to)); msg.setSubject(sub); msg.setText(data); //sending msg Transport.send(msg); JOptionPane.showMessageDialog(null,"sent !"); // TODO add your handling code here: } catch (MessagingException ex) { Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex); } }
0debug
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector) { if (bitmap) { return hbitmap_get(bitmap->bitmap, sector); } else { return 0; } }
1threat
How do I have a sprite fade in onto the scene Swift? : <p>I would like my sprite to fade onto the scene rather than just plainly appear. How can I do this?</p>
0debug
how to build multiple language website using pure html, js, jquery? : <p>i am using html to build pages. The problem is how to build multiple language switch? Language translate is not issue, i have the terms. However, I don't know how to switch btw every page through the language button/dropdown list on the menu bar? If there is a existing example or template, that would be even better. Thanks in advance.</p>
0debug
static void test_submit_co(void) { WorkerTestData data; Coroutine *co = qemu_coroutine_create(co_test_cb); qemu_coroutine_enter(co, &data); g_assert_cmpint(active, ==, 1); g_assert_cmpint(data.ret, ==, -EINPROGRESS); qemu_aio_flush(); g_assert_cmpint(active, ==, 0); g_assert_cmpint(data.ret, ==, 0); }
1threat
Run IO computations in parallel in Java8 : <p>I'm familiar with functional programming languages, usually in Scala and Javascript. I'm working on a Java8 project and not sure how I am supposed to run through a list/stream of item, and perform some side-effect for each of them in parallel, using a custom thread pool, and return an object on which it's possible to listen for completion (wether it's a success or failure).</p> <p>Currently I have the following code, it seems to work (I'm using Play framework Promise implementation as return) but it seems not ideal because ForkJoinPool is not meant to be used for IO intensive computations in the first place.</p> <pre><code>public static F.Promise&lt;Void&gt; performAllItemsBackup(Stream&lt;Item&gt; items) { ForkJoinPool pool = new ForkJoinPool(3); ForkJoinTask&lt;F.Promise&lt;Void&gt;&gt; result = pool .submit(() -&gt; { try { items.parallel().forEach(performSingleItemBackup); return F.Promise.&lt;Void&gt;pure(null); } catch (Exception e) { return F.Promise.&lt;Void&gt;throwing(e); } }); try { return result.get(); } catch (Exception e) { throw new RuntimeException("Unable to get result", e); } } </code></pre> <p>Can someone give me a more idiomatic implementation of the above function? Ideally not using the ForkJoinPool, using a more standard return type, and most recent Java8 APIs? Not sure what I'm supposed to use between CompletableFuture, CompletionStage, ForkJoinTask...</p>
0debug
Checking if String is an int : <p>I'm trying to enter the format of </p> <blockquote> <p>"prog1 1 all file1" </p> </blockquote> <p>the first input has to be a argv[1] should be an int.</p> <p>So i need a way to determine if argv[1] is entered as a string "xxx" ( "prog1 xxx" ) it should return "NO PHRASE LENGTH" but its returning "INVALID PHRASE LENGTH". </p> <p>I see there is a isdigit() function but im not sure how i would use that.</p> <pre><code>int main(int argc, char *argv[]){ try{ if(argc == 1){ cout &lt;&lt; "NO PHRASE LENGTH" &lt;&lt; endl; exit(1); } else if((stoi(argv[1])) &lt;= 0 ){ cout &lt;&lt; "INVALID PHRASE LENGTH" &lt;&lt; endl; exit(1); } else if(argc == 2){ cout &lt;&lt; "NO MODE" &lt;&lt; endl; exit(1); } else if(!(std::string(argv[2]) == "all") &amp;&amp; !(std::string(argv[2]) == "top")){ cout &lt;&lt; "INVALID MODE" &lt;&lt; endl; } else if(argc == 3){ cout &lt;&lt; "NO FILES GIVEN" &lt;&lt; endl; } else if(argc &gt;= 4){ ifstream f; for(int i = 4; i &lt; argc; i--){ f.open( argv[i] ); if( ! f.good() ) { cout &lt;&lt; "BAD FILE " &lt;&lt; argv[i] &lt;&lt; endl; exit(1); } //cout &lt;&lt; "OK" &lt;&lt; endl; //f.close(); } } else return 0; } catch(exception e){ }} </code></pre>
0debug
static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, int apply_defdispwin, HEVCSPS *sps) { VUI *vui = &sps->vui; int sar_present; av_log(avctx, AV_LOG_DEBUG, "Decoding VUI\n"); sar_present = get_bits1(gb); if (sar_present) { uint8_t sar_idx = get_bits(gb, 8); if (sar_idx < FF_ARRAY_ELEMS(vui_sar)) vui->sar = vui_sar[sar_idx]; else if (sar_idx == 255) { vui->sar.num = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16); } else av_log(avctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", sar_idx); } vui->overscan_info_present_flag = get_bits1(gb); if (vui->overscan_info_present_flag) vui->overscan_appropriate_flag = get_bits1(gb); vui->video_signal_type_present_flag = get_bits1(gb); if (vui->video_signal_type_present_flag) { vui->video_format = get_bits(gb, 3); vui->video_full_range_flag = get_bits1(gb); vui->colour_description_present_flag = get_bits1(gb); if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) sps->pix_fmt = AV_PIX_FMT_YUVJ420P; if (vui->colour_description_present_flag) { vui->colour_primaries = get_bits(gb, 8); vui->transfer_characteristic = get_bits(gb, 8); vui->matrix_coeffs = get_bits(gb, 8); if (vui->colour_primaries >= AVCOL_PRI_NB) vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; if (vui->transfer_characteristic >= AVCOL_TRC_NB) vui->transfer_characteristic = AVCOL_TRC_UNSPECIFIED; if (vui->matrix_coeffs >= AVCOL_SPC_NB) vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; } } vui->chroma_loc_info_present_flag = get_bits1(gb); if (vui->chroma_loc_info_present_flag) { vui->chroma_sample_loc_type_top_field = get_ue_golomb_long(gb); vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_long(gb); } vui->neutra_chroma_indication_flag = get_bits1(gb); vui->field_seq_flag = get_bits1(gb); vui->frame_field_info_present_flag = get_bits1(gb); vui->default_display_window_flag = get_bits1(gb); if (vui->default_display_window_flag) { vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2; if (apply_defdispwin && avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) { av_log(avctx, AV_LOG_DEBUG, "discarding vui default display window, " "original values are l:%u r:%u t:%u b:%u\n", vui->def_disp_win.left_offset, vui->def_disp_win.right_offset, vui->def_disp_win.top_offset, vui->def_disp_win.bottom_offset); vui->def_disp_win.left_offset = vui->def_disp_win.right_offset = vui->def_disp_win.top_offset = vui->def_disp_win.bottom_offset = 0; } } vui->vui_timing_info_present_flag = get_bits1(gb); if (vui->vui_timing_info_present_flag) { vui->vui_num_units_in_tick = get_bits_long(gb, 32); vui->vui_time_scale = get_bits_long(gb, 32); vui->vui_poc_proportional_to_timing_flag = get_bits1(gb); if (vui->vui_poc_proportional_to_timing_flag) vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb); vui->vui_hrd_parameters_present_flag = get_bits1(gb); if (vui->vui_hrd_parameters_present_flag) decode_hrd(gb, 1, sps->max_sub_layers); } vui->bitstream_restriction_flag = get_bits1(gb); if (vui->bitstream_restriction_flag) { vui->tiles_fixed_structure_flag = get_bits1(gb); vui->motion_vectors_over_pic_boundaries_flag = get_bits1(gb); vui->restricted_ref_pic_lists_flag = get_bits1(gb); vui->min_spatial_segmentation_idc = get_ue_golomb_long(gb); vui->max_bytes_per_pic_denom = get_ue_golomb_long(gb); vui->max_bits_per_min_cu_denom = get_ue_golomb_long(gb); vui->log2_max_mv_length_horizontal = get_ue_golomb_long(gb); vui->log2_max_mv_length_vertical = get_ue_golomb_long(gb); } }
1threat
static void gen_mfc0(DisasContext *ctx, TCGv arg, int reg, int sel) { const char *rn = "invalid"; if (sel != 0) check_insn(ctx, ISA_MIPS32); switch (reg) { case 0: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Index)); rn = "Index"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_mvpcontrol(arg, cpu_env); rn = "MVPControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_mvpconf0(arg, cpu_env); rn = "MVPConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_mvpconf1(arg, cpu_env); rn = "MVPConf1"; break; case 4: CP0_CHECK(ctx->vp); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_VPControl)); rn = "VPControl"; break; default: goto cp0_unimplemented; } break; case 1: switch (sel) { case 0: CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6)); gen_helper_mfc0_random(arg, cpu_env); rn = "Random"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_VPEControl)); rn = "VPEControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_VPEConf0)); rn = "VPEConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_VPEConf1)); rn = "VPEConf1"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load64(arg, offsetof(CPUMIPSState, CP0_YQMask)); rn = "YQMask"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load64(arg, offsetof(CPUMIPSState, CP0_VPESchedule)); rn = "VPESchedule"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load64(arg, offsetof(CPUMIPSState, CP0_VPEScheFBack)); rn = "VPEScheFBack"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_VPEOpt)); rn = "VPEOpt"; break; default: goto cp0_unimplemented; } break; case 2: switch (sel) { case 0: { TCGv_i64 tmp = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUMIPSState, CP0_EntryLo0)); #if defined(TARGET_MIPS64) if (ctx->rxi) { tcg_gen_shri_tl(arg, tmp, CP0EnLo_XI); tcg_gen_deposit_tl(tmp, tmp, arg, 30, 2); } #endif gen_move_low32(arg, tmp); tcg_temp_free_i64(tmp); } rn = "EntryLo0"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tcstatus(arg, cpu_env); rn = "TCStatus"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tcbind(arg, cpu_env); rn = "TCBind"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tcrestart(arg, cpu_env); rn = "TCRestart"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tchalt(arg, cpu_env); rn = "TCHalt"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tccontext(arg, cpu_env); rn = "TCContext"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tcschedule(arg, cpu_env); rn = "TCSchedule"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mfc0_tcschefback(arg, cpu_env); rn = "TCScheFBack"; break; default: goto cp0_unimplemented; } break; case 3: switch (sel) { case 0: { TCGv_i64 tmp = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUMIPSState, CP0_EntryLo1)); #if defined(TARGET_MIPS64) if (ctx->rxi) { tcg_gen_shri_tl(arg, tmp, CP0EnLo_XI); tcg_gen_deposit_tl(tmp, tmp, arg, 30, 2); } #endif gen_move_low32(arg, tmp); tcg_temp_free_i64(tmp); } rn = "EntryLo1"; break; case 1: CP0_CHECK(ctx->vp); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_GlobalNumber)); rn = "GlobalNumber"; break; default: goto cp0_unimplemented; } break; case 4: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_Context)); tcg_gen_ext32s_tl(arg, arg); rn = "Context"; break; case 1: rn = "ContextConfig"; goto cp0_unimplemented; case 2: CP0_CHECK(ctx->ulri); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); tcg_gen_ext32s_tl(arg, arg); rn = "UserLocal"; break; default: goto cp0_unimplemented; } break; case 5: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_PageMask)); rn = "PageMask"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_PageGrain)); rn = "PageGrain"; break; case 2: CP0_CHECK(ctx->sc); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_SegCtl0)); tcg_gen_ext32s_tl(arg, arg); rn = "SegCtl0"; break; case 3: CP0_CHECK(ctx->sc); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_SegCtl1)); tcg_gen_ext32s_tl(arg, arg); rn = "SegCtl1"; break; case 4: CP0_CHECK(ctx->sc); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_SegCtl2)); tcg_gen_ext32s_tl(arg, arg); rn = "SegCtl2"; break; default: goto cp0_unimplemented; } break; case 6: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Wired)); rn = "Wired"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSConf0)); rn = "SRSConf0"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSConf1)); rn = "SRSConf1"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSConf2)); rn = "SRSConf2"; break; case 4: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSConf3)); rn = "SRSConf3"; break; case 5: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSConf4)); rn = "SRSConf4"; break; default: goto cp0_unimplemented; } break; case 7: switch (sel) { case 0: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_HWREna)); rn = "HWREna"; break; default: goto cp0_unimplemented; } break; case 8: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_BadVAddr)); tcg_gen_ext32s_tl(arg, arg); rn = "BadVAddr"; break; case 1: CP0_CHECK(ctx->bi); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_BadInstr)); rn = "BadInstr"; break; case 2: CP0_CHECK(ctx->bp); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_BadInstrP)); rn = "BadInstrP"; break; default: goto cp0_unimplemented; } break; case 9: switch (sel) { case 0: if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_mfc0_count(arg, cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Count"; break; default: goto cp0_unimplemented; } break; case 10: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EntryHi)); tcg_gen_ext32s_tl(arg, arg); rn = "EntryHi"; break; default: goto cp0_unimplemented; } break; case 11: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Compare)); rn = "Compare"; break; default: goto cp0_unimplemented; } break; case 12: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Status)); rn = "Status"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_IntCtl)); rn = "IntCtl"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSCtl)); rn = "SRSCtl"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_SRSMap)); rn = "SRSMap"; break; default: goto cp0_unimplemented; } break; case 13: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Cause)); rn = "Cause"; break; default: goto cp0_unimplemented; } break; case 14: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC)); tcg_gen_ext32s_tl(arg, arg); rn = "EPC"; break; default: goto cp0_unimplemented; } break; case 15: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_PRid)); rn = "PRid"; break; case 1: check_insn(ctx, ISA_MIPS32R2); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EBase)); tcg_gen_ext32s_tl(arg, arg); rn = "EBase"; break; case 3: check_insn(ctx, ISA_MIPS32R2); CP0_CHECK(ctx->cmgcr); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_CMGCRBase)); tcg_gen_ext32s_tl(arg, arg); rn = "CMGCRBase"; break; default: goto cp0_unimplemented; } break; case 16: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config0)); rn = "Config"; break; case 1: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config1)); rn = "Config1"; break; case 2: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config2)); rn = "Config2"; break; case 3: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config3)); rn = "Config3"; break; case 4: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config4)); rn = "Config4"; break; case 5: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config5)); rn = "Config5"; break; case 6: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config6)); rn = "Config6"; break; case 7: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Config7)); rn = "Config7"; break; default: goto cp0_unimplemented; } break; case 17: switch (sel) { case 0: gen_helper_mfc0_lladdr(arg, cpu_env); rn = "LLAddr"; break; case 1: CP0_CHECK(ctx->mrp); gen_helper_mfc0_maar(arg, cpu_env); rn = "MAAR"; break; case 2: CP0_CHECK(ctx->mrp); gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_MAARI)); rn = "MAARI"; break; default: goto cp0_unimplemented; } break; case 18: switch (sel) { case 0 ... 7: gen_helper_1e0i(mfc0_watchlo, arg, sel); rn = "WatchLo"; break; default: goto cp0_unimplemented; } break; case 19: switch (sel) { case 0 ...7: gen_helper_1e0i(mfc0_watchhi, arg, sel); rn = "WatchHi"; break; default: goto cp0_unimplemented; } break; case 20: switch (sel) { case 0: #if defined(TARGET_MIPS64) check_insn(ctx, ISA_MIPS3); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_XContext)); tcg_gen_ext32s_tl(arg, arg); rn = "XContext"; break; #endif default: goto cp0_unimplemented; } break; case 21: CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6)); switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Framemask)); rn = "Framemask"; break; default: goto cp0_unimplemented; } break; case 22: tcg_gen_movi_tl(arg, 0); rn = "'Diagnostic"; break; case 23: switch (sel) { case 0: gen_helper_mfc0_debug(arg, cpu_env); rn = "Debug"; break; case 1: rn = "TraceControl"; goto cp0_unimplemented; case 2: rn = "TraceControl2"; goto cp0_unimplemented; case 3: rn = "UserTraceData"; goto cp0_unimplemented; case 4: rn = "TraceBPC"; goto cp0_unimplemented; default: goto cp0_unimplemented; } break; case 24: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC)); tcg_gen_ext32s_tl(arg, arg); rn = "DEPC"; break; default: goto cp0_unimplemented; } break; case 25: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_Performance0)); rn = "Performance0"; break; case 1: rn = "Performance1"; goto cp0_unimplemented; case 2: rn = "Performance2"; goto cp0_unimplemented; case 3: rn = "Performance3"; goto cp0_unimplemented; case 4: rn = "Performance4"; goto cp0_unimplemented; case 5: rn = "Performance5"; goto cp0_unimplemented; case 6: rn = "Performance6"; goto cp0_unimplemented; case 7: rn = "Performance7"; goto cp0_unimplemented; default: goto cp0_unimplemented; } break; case 26: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_ErrCtl)); rn = "ErrCtl"; break; default: goto cp0_unimplemented; } break; case 27: switch (sel) { case 0 ... 3: tcg_gen_movi_tl(arg, 0); rn = "CacheErr"; break; default: goto cp0_unimplemented; } break; case 28: switch (sel) { case 0: case 2: case 4: case 6: { TCGv_i64 tmp = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUMIPSState, CP0_TagLo)); gen_move_low32(arg, tmp); tcg_temp_free_i64(tmp); } rn = "TagLo"; break; case 1: case 3: case 5: case 7: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_DataLo)); rn = "DataLo"; break; default: goto cp0_unimplemented; } break; case 29: switch (sel) { case 0: case 2: case 4: case 6: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_TagHi)); rn = "TagHi"; break; case 1: case 3: case 5: case 7: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_DataHi)); rn = "DataHi"; break; default: goto cp0_unimplemented; } break; case 30: switch (sel) { case 0: tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC)); tcg_gen_ext32s_tl(arg, arg); rn = "ErrorEPC"; break; default: goto cp0_unimplemented; } break; case 31: switch (sel) { case 0: gen_mfc0_load32(arg, offsetof(CPUMIPSState, CP0_DESAVE)); rn = "DESAVE"; break; case 2 ... 7: CP0_CHECK(ctx->kscrexist & (1 << sel)); tcg_gen_ld_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_KScratch[sel-2])); tcg_gen_ext32s_tl(arg, arg); rn = "KScratch"; break; default: goto cp0_unimplemented; } break; default: goto cp0_unimplemented; } trace_mips_translate_c0("mfc0", rn, reg, sel); return; cp0_unimplemented: qemu_log_mask(LOG_UNIMP, "mfc0 %s (reg %d sel %d)\n", rn, reg, sel); gen_mfc0_unimplemented(ctx, arg); }
1threat
document.body.style.height = "100%"; : <p>I want to get a handle on the html tag to change the Background image but I'm running into: "TypeError: document.html is undefined" error.</p> <p>My code:</p> <pre><code> function init(){ document.html.style.background ="url('175541_DSC_0291.JPG') no-repeat center center"; } window.onload = function(){ init(); } </code></pre> <p>I lurked around for similar questions, closest I found was using the body tag instead. It works when I change the html object to body. </p> <p>Additionally, I can easily set the html background to what I want in my CSS file, but I want to do it with JavaScript. Any ideas as to what's going on?</p> <p>Thanks in advance, George</p>
0debug
static ssize_t qio_channel_websock_decode_payload(QIOChannelWebsock *ioc, Error **errp) { size_t i; size_t payload_len; uint32_t *payload32; if (!ioc->payload_remain) { error_setg(errp, "Decoding payload but no bytes of payload remain"); return -1; } if (ioc->encinput.offset < ioc->payload_remain) { payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4); } else { payload_len = ioc->payload_remain; } if (payload_len == 0) { return QIO_CHANNEL_ERR_BLOCK; } ioc->payload_remain -= payload_len; payload32 = (uint32_t *)ioc->encinput.buffer; for (i = 0; i < payload_len / 4; i++) { payload32[i] ^= ioc->mask.u; } for (i *= 4; i < payload_len; i++) { ioc->encinput.buffer[i] ^= ioc->mask.c[i % 4]; } buffer_reserve(&ioc->rawinput, payload_len); buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len); buffer_advance(&ioc->encinput, payload_len); return payload_len; }
1threat
ng-content select bound variable : <p>I'm trying to create a form builder using angular 2. An very basic example is as follows:</p> <pre><code>this.fields = [{name: 'Name', type: 'text'}, {name: 'Age', type: 'number'}]; </code></pre> <p>But I also want to support custom elements like:</p> <pre><code>this.fields = [ {name: 'Name', type: text}, {name: 'Age', type: 'custom', customid: 'Ctl1'}, {name: 'Whatever', type: 'custom', customid: 'Ctl2'} ]; // template: &lt;super-form [fields]="fields"&gt; &lt;Ctl1&gt;&lt;input type="number" ...&gt;&lt;Ctl1&gt; &lt;Ctl2&gt;&lt;whaterver-control ...&gt;&lt;Ctl2&gt; &lt;/super-form&gt; </code></pre> <p>In my form builder component I then have something like:</p> <pre><code>&lt;div *ngFor="let f of fields"&gt; &lt;div [ngSwitch]="f.type"&gt; &lt;span *ngSwitchWhen="'custom'"&gt; &lt;ng-content select="f.customid"&gt;&lt;/ng-content&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>But given that I'm here this obviously does not work. Is this an ng2 limitation? If so, I guess I could hard code say 5 optional content elements and check if they are specified and not have dynamic selects but this is a hack.</p> <p>Cheers</p>
0debug
static int wv_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; WVContext *wc = s->priv_data; AVStream *st; int ret; wc->block_parsed = 0; for (;;) { if ((ret = wv_read_block_header(s, pb, 0)) < 0) return ret; if (!AV_RN32(wc->extra)) avio_skip(pb, wc->blksize - 24); else break; } st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_WAVPACK; st->codec->channels = wc->chan; st->codec->channel_layout = wc->chmask; st->codec->sample_rate = wc->rate; st->codec->bits_per_coded_sample = wc->bpp; avpriv_set_pts_info(st, 64, 1, wc->rate); st->start_time = 0; st->duration = wc->samples; if (s->pb->seekable) { int64_t cur = avio_tell(s->pb); wc->apetag_start = ff_ape_parse_tag(s); if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) ff_id3v1_read(s); avio_seek(s->pb, cur, SEEK_SET); } return 0; }
1threat
static void niagara_init(MachineState *machine) { NiagaraBoardState *s = g_new(NiagaraBoardState, 1); DriveInfo *dinfo = drive_get_next(IF_PFLASH); MemoryRegion *sysmem = get_system_memory(); sparc64_cpu_devinit(machine->cpu_model, "Sun UltraSparc T1", NIAGARA_PROM_BASE); memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram", NIAGARA_HV_RAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL, "sun4v-partition.ram", machine->ram_size); memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, &s->partition_ram); memory_region_allocate_system_memory(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram); memory_region_allocate_system_memory(&s->md_rom, NULL, "sun4v-md.rom", NIAGARA_MD_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom); memory_region_allocate_system_memory(&s->hv_rom, NULL, "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom); memory_region_allocate_system_memory(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX); memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom); add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE); add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE); add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE); add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE); add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET); add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET); if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); int size = blk_getlength(blk); if (size > 0) { memory_region_allocate_system_memory(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size); memory_region_add_subregion(get_system_memory(), NIAGARA_VDISK_BASE, &s->vdisk_ram); dinfo->is_default = 1; rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1); } else { fprintf(stderr, "qemu: could not load ram disk '%s'\n", blk_bs(blk)->filename); exit(1); } } serial_mm_init(sysmem, NIAGARA_UART_BASE, 0, NULL, 115200, serial_hds[0], DEVICE_BIG_ENDIAN); empty_slot_init(NIAGARA_IOBBASE, NIAGARA_IOBSIZE); sun4v_rtc_init(NIAGARA_RTC_BASE); }
1threat