problem
stringlengths
26
131k
labels
class label
2 classes
I'm not able to input my file in Python : I have a document called workbook1.txt on my desktop and I'm not able to open it in python i=open('C/Users/rrmenon/Desktop/workbook1.txt', 'r') Traceback (most recent call last): File "<pyshell#22>", line 1, in <module> i=open('C/Users/rrmenon/Desktop/workbook1.txt', 'r') IOError: [Errno 2] No such file or directory: 'C/Users/rrmenon/Desktop/workbook1.txt'
0debug
What's the difference between actual arguments, format arguments, dummy arguments and actual and formal parameters? : <p>I think some mentioned above are just synonyms but which ones? Also correct me if I'm wrong: In a function lets say the main function, the data between parenthesis is parameters/arguments?</p>
0debug
if user input dopes not equal alphabet print error message : <p>I am in my first weeks of coding and am trying to solve an issue in my code</p> <p>the challenge: how to inform user that his input is not in the alphabet and subsequently return him to the input line without continuing the code.</p> <p>the code i have</p> <pre><code>import random import re print(" _______\\__") print(" (_. _ ._ _/") print(" '-' \__. /") print(" / /") print(" / / .--. .--.") print(" ( ( / '' \/ '' \ || || /\ |\ | _____ |\ /| /\ |\ |") print(" \ \_.' \ ) ||--|| /__\ | \ | | ___ | \/ | /__\ | \ |") print(" || _ './ || || / \ | \| |____| | | / \| \|") print(" |\ \ ___.'\ /") print(" '-./ .' \ |/") print(" \| / )|\'") print(" |/ // \\") print(" |\ __// \\__") print(" //\\ /__/ \__|") print(" .--_/ \_--.") print(" /__/ \__\'") name_user = str(input("What is your name?:")) print("Hello,", name_user, "lets play HangMan, try to guess the word i have challenged you with?") word_list = ["fireboard", "identical", "chocolate", "christmas", "beautiful", "happiness", "wednesday", "challenge", "celebrate"] random_pick = random.choice(word_list) random_pick_a = re.sub("[a-z]","*", random_pick) random_pick_list_a = list(random_pick_a) print(random_pick) count = 0 def main_function(): global count while count &lt;= 9: user_input = str(input("type a letter:")) for i, c in enumerate(random_pick): if c == user_input.casefold(): random_pick_list_a[i] = user_input.casefold() random_pick_list_b = ''.join(random_pick_list_a) if random_pick_list_b == random_pick: print("done") exit() else: continue else: if user_input.casefold() not in random_pick: count = count+1 print(count) if count == 10: print("sorry") exit() print(random_pick_list_b) main_function() </code></pre>
0debug
getting an string input through char* : I am completely confused about a taking an string input in C++. char str[4]; cin>>str; cout<<str; works. but the char* str; cin>>str; cout<<str; doesn't work. why?
0debug
static int calc_add_mv(RV34DecContext *r, int dir, int val) { int mul = dir ? -r->mv_weight2 : r->mv_weight1; return (val * mul + 0x2000) >> 14; }
1threat
Simple way to replace string in javscript with wildcards : Is there a simple way to replace something in a string in javascript with a wildcard but also use the wildcard in the resulting string: So for example i have the String: loop(10) { // do something } an i want to replace the "loop" with a real for loop like this for(i=0; i<10; i++) { // do something } but to do this i with a simple .replace i would need a wildcard. Obviously there is a solution to this problem but it seems very costly to me.
0debug
DBeaver not showing dbms_output : <p>I'm using dbeaver version 5.1.3. When I use the DBMS_OUTPUT.PUT_LINE method for oracle pl/sql it's output not shown anywhere. It has a output tab. It's also blank.</p> <p><a href="https://i.stack.imgur.com/y8kkT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/y8kkT.png" alt="enter image description here"></a></p>
0debug
how do i Copy Query in power query To another Work Book : I have a Query that i Made in one of my Work Book and now i Need to repeat it in many Other Work Book as well, How can i Copy it to Wall pg my Work Book?
0debug
Crop the image with outline in java : I have a captured image, the image consists of a table. I want to crop the table out of that image. [This is a sample image.][1] Can someone suggest what can be done? I have to use it in android. [1]: https://i.stack.imgur.com/HQepo.jpg
0debug
Forwarding from a futures::Stream to a futures::Sink : <p>I am currently trying to wrap my head around the tokio &amp; futures primitives and ecosystem.</p> <p>I started doing some work from the <a href="https://github.com/swindon-rs/tk-http/blob/abfdb50a00ab90b4f01b23ff8dbefe6e83331d9c/examples/websockets.rs" rel="noreferrer">tk-http websockets example</a>, and wanted to do more processing on the received data rather than echoing it back. A first step seemed to be to replace the .forward() call with some kind of loop.</p> <p>It seemed to me that <code>stream.forward(sink)</code> is equivalent to <code>stream.fold(sink, |out_, item| { out.send(item).and_then(Sink::flush) })</code>, however doing this (<a href="https://gitlab.com/remram44/rs-web/commit/b1edd5a68ddb676b6a912576bdf08600cbeab96e" rel="noreferrer">commit</a>) the stream is not polled at all. However the same change from the Tokio example works fine (<a href="https://gitlab.com/remram44/rs-web/commit/5345a3e7f5f4e4ec81791d5e7e0474154329bd0e" rel="noreferrer">example</a>).</p> <p>Furthermore, it seems that outputting something on the sink first makes the forwarding work fine (<a href="https://gitlab.com/remram44/rs-web/commit/d690039fde5d4d6ab35f0f0a13be3ef46c84807b" rel="noreferrer">commit</a>), so maybe the sink doesn't get registered with the event loop for some reason until a send happen? Did I miss something? Is it possible it is a bug in tk-http?</p>
0debug
Why can you use new Image but not new Div or new Span? : <p>In examples I've seen <code>new Image()</code> to create a new HTML image element but when I try <code>new Div()</code> there is no support. Is there a reason for this or any plan in the future to add it?</p> <p>Example: </p> <pre><code>var image = new Image(); var div = new Div(); // error </code></pre>
0debug
When can we say that the protocol is completely RESTful? : I am currently studying about REST interfaces for directory services, i have a great confusion on RESTful interfaces . when can we say that the design is completely RESTful or not?
0debug
Collect Senders Email Addresses From Specific Folder At Thunderbird : <p>as my title mentioned I am searching for a solution to get all email addresses that I have received from people and saved inside a certain folder in my Thunderbird. </p> <p>I need them for marketing purposes, because those email addresses belong to people I have done business with.</p> <p>Thanks for help.</p> <p>Best RS</p>
0debug
Why .RData when .R is sufficient : <p>Say, if we can save and load an exact same data from <code>.R</code> files, then why came the need for <code>.RData</code>. I tried figuring out some explanation from <a href="https://stat.ethz.ch/pipermail/r-help/2003-October/039909.html" rel="nofollow noreferrer">[R] foo.RData or foo.r?</a>. So, I stumbled upon few queries:</p> <ul> <li>Does <code>.RData</code> <strong>saves</strong> <strong>only final result</strong> or complete code just a <code>.R</code> scripts?</li> <li>What is their exact relevance? Which one to prefer over other and when?</li> </ul>
0debug
What is Debugger PIN when I run the flask app python : <ul> <li>Debugger is active!</li> <li>Debugger PIN: 620-122-212</li> </ul> <p>I see this when I run the flask app and i'm trying to understand where it will get used?</p> <p>Please let me know!</p>
0debug
static inline int32_t mipsdsp_add_i32(int32_t a, int32_t b, CPUMIPSState *env) { int32_t temp; temp = a + b; if (MIPSDSP_OVERFLOW(a, b, temp, 0x80000000)) { set_DSPControl_overflow_flag(1, 20, env); } return temp; }
1threat
C# how do i calculate and add to the string odd and even parity from a binary string : <p>How do i calculate and add to the string odd and even parity from a binary string:</p> <p>26-Bit Wiegand Format:</p> <p>Bit 1 = Even Parity over Bits 2 - 13</p> <p>Bits 26 Odd parity over bits 14 to 25</p> <p>Ex: binary string: 1111 1011 0111 0111 1111 1010</p> <p>after odd and even calculation: X 1111 1011 0111 0111 1111 1010 Y</p>
0debug
cxBarEditItem will not accept adding items : <p>My cxBarEditItem1 has properties : combobox.</p> <p>However when I begin to write :</p> <blockquote> <p>cxBarEditItem1.Properties.Items.Add ...</p> </blockquote> <p>Delphi shows me it's an error. It seems 'items' do not exist. </p> <p>What am I doing wrong ? How can I fill it ?</p>
0debug
What to use instead of WCF in .NET Core? : <p>Windows 10, .Net Core 3.1 </p> <p>How to do the processes communication on the same computer in .NET Core 3.1? I used WCF for these purposes when I used .NET Framwork earlier, but .NET Core hasn't WCF. I would not want to use the file system and <code>FileSystemWatcher</code> or write windows services for these purposes...</p>
0debug
Database connection failed from load runner : i am using vugen 1 version . i want to connect it to oracke 11g . could you please mention the complete process for it as i did performance of web applications earlier. Thanks.
0debug
An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue : <p>Any reason why this error popped up when I tried bundling an application: I have tried installing gem install mysql2 -v '0.3.21' as they recommend but it cant install properly. Also I am running this on macOS High Sierra. Sorry for my bad wording for this question because its my first time working with ruby.</p> <pre><code> To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/mkmf.log current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2 make "DESTDIR=" clean current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2 make "DESTDIR=" compiling infile.c compiling client.c client.c:439:3: error: use of undeclared identifier 'my_bool' my_bool res = mysql_read_query_result(client); ^ client.c:441:19: error: use of undeclared identifier 'res' return (void *)(res == 0 ? Qtrue : Qfalse); ^ client.c:762:3: error: use of undeclared identifier 'my_bool' my_bool boolval; ^ client.c:793:7: error: use of undeclared identifier 'boolval' boolval = (value == Qfalse ? 0 : 1); ^ client.c:794:17: error: use of undeclared identifier 'boolval' retval = &amp;boolval; ^ client.c:797:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'? case MYSQL_SECURE_AUTH: ^~~~~~~~~~~~~~~~~ MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here MYSQL_DEFAULT_AUTH, ^ client.c:798:7: error: use of undeclared identifier 'boolval' boolval = (value == Qfalse ? 0 : 1); ^ client.c:799:17: error: use of undeclared identifier 'boolval' retval = &amp;boolval; ^ client.c:830:38: error: use of undeclared identifier 'boolval' wrapper-&gt;reconnect_enabled = boolval; ^ client.c:1185:38: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'? return _mysql_client_options(self, MYSQL_SECURE_AUTH, value); ^~~~~~~~~~~~~~~~~ MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here MYSQL_DEFAULT_AUTH, ^ 10 errors generated. make: *** [client.o] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21 for inspection. Results logged to /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/gem_make.out An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.21' --source 'http://rubygems.org/'` succeeds before bundling. </code></pre>
0debug
Merge two dataframes with multi-index : <p>I have seen several posts about this but I could not get my head around how merge, join and concat would deal with this. How can I merge two dataframes to find matching indexes?</p> <p>in:</p> <pre><code>import pandas as pd import numpy as np row_x1 = ['a1','b1','c1'] row_x2 = ['a2','b2','c2'] row_x3 = ['a3','b3','c3'] row_x4 = ['a4','b4','c4'] index_arrays = [np.array(['first', 'first', 'second', 'second']), np.array(['one','two','one','two'])] df1 = pd.DataFrame([row_x1,row_x2,row_x3,row_x4], columns=list('ABC'), index=index_arrays) print(df1) </code></pre> <p>out:</p> <pre><code> A B C first one a1 b1 c1 two a2 b2 c2 second one a3 b3 c3 two a4 b4 c4 </code></pre> <p>in:</p> <pre><code>row_y1 = ['d1','e1','f1'] row_y2 = ['d2','e2','f2'] df2 = pd.DataFrame([row_y1,row_y2], columns=list('DEF'), index=['first','second']) print(df2) </code></pre> <p>out</p> <pre><code> D E F first d1 e1 f1 second d2 e2 f2 </code></pre> <p>in other words, how can I merge them to achieve df3 (as follows)?</p> <p>in</p> <pre><code>row_x1 = ['a1','b1','c1'] row_x2 = ['a2','b2','c2'] row_x3 = ['a3','b3','c3'] row_x4 = ['a4','b4','c4'] row_y1 = ['d1','e1','f1'] row_y2 = ['d2','e2','f2'] row_z1 = row_x1 + row_y1 row_z2 = row_x2 + row_y1 row_z3 = row_x3 + row_y2 row_z4 = row_x4 + row_y2 df3 = pd.DataFrame([row_z1,row_z2,row_z3,row_z4], columns=list('ABCDEF'), index=index_arrays) print(df3) </code></pre> <p>out</p> <pre><code> A B C D E F first one a1 b1 c1 d1 e1 f1 two a2 b2 c2 d1 e1 f1 second one a3 b3 c3 d2 e2 f2 two a4 b4 c4 d2 e2 f2 </code></pre>
0debug
How to take a sample of a data set in R : <p>So I have this dataset with 18 variables and about 10,000,000 observations. The set is way to large for my computer to handle so I need to take a smaller sample of the data to analyze it. However, I don't want just a random sample. One of my variables "tip_level" is a factor with two levels, "high" and "low". Is there a way to take a sample of 100,000 observations where 50,000 are "high" and 50,000 are "low" of the variable?</p>
0debug
how to get check box value to database by Codeignter? : Sir,I have one problem with checkbox in codeigniter,i really donot able to understand how to implement the code. please help me to implement . My code will be ,Suppose I have 3 check box(like : Item 1 ,Item 2,Item 3) and when I will checked the check box then 1 will insert to Database other wise 0 will insert . Please describe me in details.
0debug
static int nbd_co_writev_1(NbdClientSession *client, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { struct nbd_request request; struct nbd_reply reply; ssize_t ret; request.type = NBD_CMD_WRITE; if (!bdrv_enable_write_cache(client->bs) && (client->nbdflags & NBD_FLAG_SEND_FUA)) { request.type |= NBD_CMD_FLAG_FUA; } request.from = sector_num * 512; request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); ret = nbd_co_send_request(client, &request, qiov, offset); if (ret < 0) { reply.error = -ret; } else { nbd_co_receive_reply(client, &request, &reply, NULL, 0); } nbd_coroutine_end(client, &request); return -reply.error; }
1threat
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type) { QVirtioPCIDevice *dev = NULL; qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev); dev->vdev.bus = &qvirtio_pci; return dev; }
1threat
yuv2rgb_full_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha) { const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], *abuf0 = hasAlpha ? abuf[0] : NULL, *abuf1 = hasAlpha ? abuf[1] : NULL; int yalpha1 = 4096 - yalpha; int uvalpha1 = 4096 - uvalpha; int i; int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4; int err[4] = {0}; if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8) step = 1; for (i = 0; i < dstW; i++) { int Y = ( buf0[i] * yalpha1 + buf1[i] * yalpha ) >> 10; int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha-(128 << 19)) >> 10; int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha-(128 << 19)) >> 10; int A; if (hasAlpha) { A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha + (1<<18)) >> 19; if (A & 0x100) A = av_clip_uint8(A); } yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err); dest += step; } c->dither_error[0][i] = err[0]; c->dither_error[1][i] = err[1]; c->dither_error[2][i] = err[2]; }
1threat
Configuring Tensorflow to use all CPU's : <p>Reading : <a href="https://www.tensorflow.org/versions/r0.10/resources/faq.html" rel="noreferrer">https://www.tensorflow.org/versions/r0.10/resources/faq.html</a> it states : </p> <blockquote> <p>Does TensorFlow make use of all the devices (GPUs and CPUs) available on my machine?</p> <p>TensorFlow supports multiple GPUs and CPUs. See the how-to documentation on using GPUs with TensorFlow for details of how TensorFlow assigns operations to devices, and the CIFAR-10 tutorial for an example model that uses multiple GPUs.</p> <p>Note that TensorFlow only uses GPU devices with a compute capability greater than 3.5.</p> </blockquote> <p>Does this mean Tensorflow can automatically make use of all CPU's on given machine or does it ned to be explicitly configured ?</p>
0debug
ImportError: No module named model_selection : <p>I am trying to use <code>train_test_split</code> function and write:</p> <pre><code>from sklearn.model_selection import train_test_split </code></pre> <p>and this causes </p> <pre><code>ImportError: No module named model_selection </code></pre> <p>Why? And how to overcome?</p>
0debug
Open modal in js : <p>Hello I am trying to use the modal from the following website(first example): <a href="http://jquerymodal.com/" rel="nofollow noreferrer">http://jquerymodal.com/</a> </p> <p>Is there a way to open the modal using js? As I am opening the modal if the form on my page was field correctly.</p> <p>Thanks in advance!</p>
0debug
php forum outputs string of text, how to find source of said string? : <p>I'm working on a site which is a simple php forum, and every so often it'll insert an alert/error div on the page, e.g., "Error! You can't do that because of this," or whatever.</p> <p>How do I search each of the files on my server for the string "Error! You can't do that because of this"? Asked differently, how do I find the source of the various errors when they arise, you know, without having to manually look at every single .php file on the server; thanks.</p>
0debug
static void create_cps(MaltaState *s, const char *cpu_model, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { Error *err = NULL; s->cps = g_new0(MIPSCPSState, 1); object_initialize(s->cps, sizeof(MIPSCPSState), TYPE_MIPS_CPS); qdev_set_parent_bus(DEVICE(s->cps), sysbus_get_default()); object_property_set_str(OBJECT(s->cps), cpu_model, "cpu-model", &err); object_property_set_int(OBJECT(s->cps), smp_cpus, "num-vp", &err); object_property_set_bool(OBJECT(s->cps), true, "realized", &err); if (err != NULL) { error_report("%s", error_get_pretty(err)); exit(1); } sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->cps), 0, 0, 1); *i8259_irq = get_cps_irq(s->cps, 2); *cbus_irq = NULL; }
1threat
RIBY ON RAILS ActiveRecord::SubclassNotFound in CarsController#create Invalid single-table inheritance type: Race Car is not a subclass of Car : [HELP HERE RUBY ON RAILS ActiveRecord::SubclassNotFound in CarsController#create][1] [1]: https://i.stack.imgur.com/qAYZh.png
0debug
Can we have a 2 different textStyle inside styles.xml? : <p>I wanted to my title to have italic and bold at the same time. How can i achieve this on styles.xml? or is it possible to achieve this within styles.xml only?</p>
0debug
Why did kotlin drop the "new" keyword? : <p>Why did kotlin drop the <strong>new</strong> keyword ? It makes it harder to see the difference between a function call and an object allocation.</p>
0debug
static void qnull_destroy_obj(QObject *obj) { assert(0); }
1threat
shrinkResources true can't be used on Instant Apps Feature? : <p>When I try to shrink my Feature APK size, I use <code>shrinkResources true</code> in my feature Build Gradle. However it complaints <code>Error:Resource shrinker cannot be used for libraries.</code></p> <p>This article ask us to use it <a href="https://medium.com/jet-stories/make-your-app-instant-33855ab5d02b" rel="noreferrer">https://medium.com/jet-stories/make-your-app-instant-33855ab5d02b</a></p> <p>Did I do something wrong or is this really not supported by Instant Apps?</p>
0debug
Best of static method and non static method : <p>I have Util classes where i have many methods to be used in all over project. My question is - considering memory heap, performance what is best to use a static method by class reference or non static method called by object of that class. For example:</p> <pre><code>public class Utilities { private static Utilities utils; public static Utilities getInstance() { if (utils == null) utils = new Utilities(); return utils; } public static void someMethod() { } public void someMethod2() { } } </code></pre> <p>and</p> <pre><code>public static void main(String[] args) { Utilities.someMethod(); Utilities.getInstance().someMethod2(); } </code></pre> <p>Which is correct way for my requirement?</p>
0debug
static void qmp_input_free(Visitor *v) { QmpInputVisitor *qiv = to_qiv(v); while (!QSLIST_EMPTY(&qiv->stack)) { StackObject *tos = QSLIST_FIRST(&qiv->stack); QSLIST_REMOVE_HEAD(&qiv->stack, node); qmp_input_stack_object_free(tos); } qobject_decref(qiv->root); g_free(qiv); }
1threat
VISIAL STUDIO can not show folder of cpp files : win7 visual studio 2017 I have used vs2017 to open a vs 2010 MFC project. It could be opened well in the first time. however, afterwards, it reminds me to do some update. After that, the file can not be load in resourse view. [enter image description here][1] How to reconfig vs to show the resourse view? [1]: https://i.stack.imgur.com/bShfq.jpg
0debug
How to convert an image to a string using javascript? : <pre><code>&lt;input type="file" id="picture"&gt; </code></pre> <p>I would like to convert the image uploaded to the html input to a string. How can I do that using JavaScript?</p> <p>Thanks in advance.</p>
0debug
How to run a migration in production : <p>I am new to migrations and I can't find out what to do to get my changes onto the LiveDB.</p> <p>So on dev when I add to my model I do</p> <pre><code>PM&gt; add-migration &lt;name&gt; PM&gt; update-database </code></pre> <p>But what do I do on live? I was HOPING that I could just publish\deploy to live and the migration would run and update the schema, but I guess not :)</p> <p>The Live SQL server is off in its own world I have no access to it from my dev box to just change the connectionstring and doing an update-database again.</p> <p>What do you guys do, where's the docs?</p> <p>Thanks, Steve</p>
0debug
static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[pkt->stream_index]; AVIOContext *pb = s->pb; AVFrame *frame; int* first_pkt = s->priv_data; int width, height, h_chroma_shift, v_chroma_shift; int i; char buf2[Y4M_LINE_MAX + 1]; uint8_t *ptr, *ptr1, *ptr2; frame = (AVFrame *)pkt->data; if (*first_pkt) { *first_pkt = 0; if (yuv4_generate_header(s, buf2) < 0) { av_log(s, AV_LOG_ERROR, "Error. YUV4MPEG stream header write failed.\n"); return AVERROR(EIO); } else { avio_write(pb, buf2, strlen(buf2)); } } avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC); width = st->codecpar->width; height = st->codecpar->height; ptr = frame->data[0]; switch (st->codecpar->format) { case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV411P: case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUV444P: break; case AV_PIX_FMT_GRAY16: case AV_PIX_FMT_YUV420P9: case AV_PIX_FMT_YUV422P9: case AV_PIX_FMT_YUV444P9: case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_YUV422P10: case AV_PIX_FMT_YUV444P10: case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV422P12: case AV_PIX_FMT_YUV444P12: case AV_PIX_FMT_YUV420P14: case AV_PIX_FMT_YUV422P14: case AV_PIX_FMT_YUV444P14: case AV_PIX_FMT_YUV420P16: case AV_PIX_FMT_YUV422P16: case AV_PIX_FMT_YUV444P16: width *= 2; break; default: av_log(s, AV_LOG_ERROR, "The pixel format '%s' is not supported.\n", av_get_pix_fmt_name(st->codecpar->format)); return AVERROR(EINVAL); } for (i = 0; i < height; i++) { avio_write(pb, ptr, width); ptr += frame->linesize[0]; } if (st->codecpar->format != AV_PIX_FMT_GRAY8 && st->codecpar->format != AV_PIX_FMT_GRAY16) { av_pix_fmt_get_chroma_sub_sample(st->codecpar->format, &h_chroma_shift, &v_chroma_shift); width = AV_CEIL_RSHIFT(width, h_chroma_shift); height = AV_CEIL_RSHIFT(height, v_chroma_shift); ptr1 = frame->data[1]; ptr2 = frame->data[2]; for (i = 0; i < height; i++) { avio_write(pb, ptr1, width); ptr1 += frame->linesize[1]; } for (i = 0; i < height; i++) { avio_write(pb, ptr2, width); ptr2 += frame->linesize[2]; } } return 0; }
1threat
static int decode_band_hdr(IVI4DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx) { int plane, band_num, indx, transform_id, scan_indx; int i; int quant_mat; plane = get_bits(&ctx->gb, 2); band_num = get_bits(&ctx->gb, 4); if (band->plane != plane || band->band_num != band_num) { av_log(avctx, AV_LOG_ERROR, "Invalid band header sequence!\n"); return AVERROR_INVALIDDATA; } band->is_empty = get_bits1(&ctx->gb); if (!band->is_empty) { if (get_bits1(&ctx->gb)) skip_bits(&ctx->gb, 16); band->is_halfpel = get_bits(&ctx->gb, 2); if (band->is_halfpel >= 2) { av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported mv resolution: %d!\n", band->is_halfpel); return AVERROR_INVALIDDATA; } #if IVI4_STREAM_ANALYSER if (!band->is_halfpel) ctx->uses_fullpel = 1; #endif band->checksum_present = get_bits1(&ctx->gb); if (band->checksum_present) band->checksum = get_bits(&ctx->gb, 16); indx = get_bits(&ctx->gb, 2); if (indx == 3) { av_log(avctx, AV_LOG_ERROR, "Invalid block size!\n"); return AVERROR_INVALIDDATA; } band->mb_size = 16 >> indx; band->blk_size = 8 >> (indx >> 1); band->inherit_mv = get_bits1(&ctx->gb); band->inherit_qdelta = get_bits1(&ctx->gb); band->glob_quant = get_bits(&ctx->gb, 5); if (!get_bits1(&ctx->gb) || ctx->frame_type == FRAMETYPE_INTRA) { transform_id = get_bits(&ctx->gb, 5); if (transform_id >= FF_ARRAY_ELEMS(transforms) || !transforms[transform_id].inv_trans) { av_log_ask_for_sample(avctx, "Unimplemented transform: %d!\n", transform_id); return AVERROR_PATCHWELCOME; } if ((transform_id >= 7 && transform_id <= 9) || transform_id == 17) { av_log_ask_for_sample(avctx, "DCT transform not supported yet!\n"); return AVERROR_PATCHWELCOME; } if (transform_id < 10 && band->blk_size < 8) { av_log(avctx, AV_LOG_ERROR, "wrong transform size!\n"); return AVERROR_INVALIDDATA; } #if IVI4_STREAM_ANALYSER if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10) ctx->uses_haar = 1; #endif band->inv_transform = transforms[transform_id].inv_trans; band->dc_transform = transforms[transform_id].dc_trans; band->is_2d_trans = transforms[transform_id].is_2d_trans; band->transform_size= (transform_id < 10) ? 8 : 4; scan_indx = get_bits(&ctx->gb, 4); if ((scan_indx>4 && scan_indx<10) != (band->blk_size==4)) { av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n"); return AVERROR_INVALIDDATA; } if (scan_indx == 15) { av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n"); return AVERROR_INVALIDDATA; } band->scan = scan_index_to_tab[scan_indx]; quant_mat = get_bits(&ctx->gb, 5); if (quant_mat == 31) { av_log(avctx, AV_LOG_ERROR, "Custom quant matrix encountered!\n"); return AVERROR_INVALIDDATA; } if (quant_mat > 21) { av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix encountered!\n"); return AVERROR_INVALIDDATA; } band->quant_mat = quant_mat; } if (ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_BLK_HUFF, &band->blk_vlc, avctx)) return AVERROR_INVALIDDATA; band->rvmap_sel = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 3) : 8; band->num_corr = 0; if (get_bits1(&ctx->gb)) { band->num_corr = get_bits(&ctx->gb, 8); if (band->num_corr > 61) { av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n", band->num_corr); return AVERROR_INVALIDDATA; } for (i = 0; i < band->num_corr * 2; i++) band->corr[i] = get_bits(&ctx->gb, 8); } } if (band->blk_size == 8) { band->intra_base = &ivi4_quant_8x8_intra[quant_index_to_tab[band->quant_mat]][0]; band->inter_base = &ivi4_quant_8x8_inter[quant_index_to_tab[band->quant_mat]][0]; } else { band->intra_base = &ivi4_quant_4x4_intra[quant_index_to_tab[band->quant_mat]][0]; band->inter_base = &ivi4_quant_4x4_inter[quant_index_to_tab[band->quant_mat]][0]; } band->intra_scale = NULL; band->inter_scale = NULL; align_get_bits(&ctx->gb); if (!band->scan) { av_log(avctx, AV_LOG_ERROR, "band->scan not set\n"); return AVERROR_INVALIDDATA; } return 0; }
1threat
opts_start_optional(Visitor *v, bool *present, const char *name, Error **errp) { OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v); assert(ov->repeated_opts == NULL); *present = (lookup_distinct(ov, name, NULL) != NULL); }
1threat
Change return to be next/done key in Xamarin Forms Shared Project : <p>Is it possible to change the text in the 'return' key on the keyboard to be either 'next' or 'done'? I have a login form with username and password. I want the return key to say 'next' when on the username field and then 'done' when on the password field but haven't seen anyway of doing this. This is for a shared project, android and iOS. </p> <p><a href="https://i.stack.imgur.com/wFmSO.png"><img src="https://i.stack.imgur.com/wFmSO.png" alt="Username"></a></p> <p><a href="https://i.stack.imgur.com/n9Ucy.png"><img src="https://i.stack.imgur.com/n9Ucy.png" alt="Password"></a></p>
0debug
How would I animate the width of a button based on percentage, and the same for it's backgroundColor? : <p>I have some <code>&lt;AnimatedButton /&gt;</code></p> <p>I want to animate it to go from 100% width to 40% width depending on a prop that is a boolean called <code>isFullWidth</code>.</p> <p>I have:</p> <pre><code>class AnimatedButton extends Component { constructor(props) { super(props); this.state = { width: new Animated.Value(100) }; } toggleWidth() { const endWidth = this.props.isFullWidth ? 40 : 100; Animated.timing(this.state.width, { toValue: endWidth, duration: 200, easing: Easing.linear, }).start(); } render() { &lt;TouchableOpacity style={{ width: `${this.state.width}%` }} onPress={this.props.onPress} &gt; // more stuff &lt;/TouchableOpacity&gt; } } </code></pre> <p>The problem is that it just jumps into the appropriate percentage without animating. I tried setting the width to just <code>this.state.animatedValue</code> and rather than use percentage, just use pixels, e.g. 150 to 400 and back, and it works fine as expected.</p> <p>Same question applies for going from say <code>rgba(220, 100, 50, 0.8)</code> to <code>rgba(30, 70, 30, 1.0)</code> and back?</p>
0debug
i want to replace fetch with axios : fetch(API_ENDPOINT + "signup", { method: 'POST', headers: { 'Content-Type': 'multipart/form-data' }, body: data }) .then(response => response.json()) .then(response => { console.log(response); dispatch({ type: SIGNUP_SUCCESS }); dispatch({ type: LOGIN_SUCCESS, payload: response }); navigator.resetTo({ screen: 'carapp.Phone', animated: true }); }).catch(error => console.log(error));
0debug
static int is_async_return(const QObject *data) { if (data && qobject_type(data) == QTYPE_QDICT) { return qdict_haskey(qobject_to_qdict(data), "__mon_async"); } return 0; }
1threat
Using element + element with after pseudo element : Trying to achieve a simple effect in a chat app, where if a user messages, after his username should always appear a `:` but if a bot messages, his message will have a class of .bot and i would like to override that `user:after` to have different after content .user:after { content: ": "; } .user:after + .bot { content: "=> "; } Is this possible at all? Or should i pursue a different approach. Codepen for reference: http://codepen.io/knuxus/pen/zBwWBr?editors=1100
0debug
Swift: Dismiss view1 then show a view2 : I want to dismiss a loader view then present an `UIDocumentInteractionController`. I found an objective-c solution but I want the Swift 3 one. This is the objective-c code taken from this [answer]: // Does not break [viewController1 dismissViewControllerAnimated:YES completion:^{ [self presentViewController:viewController2 animated:YES completion:NULL]; }]; I translated like this in Swift 3: self.dismiss(animated: false, completion:{ self.docController = UIDocumentInteractionController(url: destinationUrl!) self.docController!.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true) }) Still now it works but I want to be sure that the `completion:^{` in objective-c means `completion:{` in Swift 3. [answer]: http://stackoverflow.com/questions/14453001/meaning-of-warning-while-a-presentation-is-in-progress/17120065#17120065
0debug
React Why Unmount Component Slow : <p>I have a component that wraps a bunch of ReactList components. ReactList component is a component that does infinite scrolling ie only load what's on viewport. It has couple of modes: simple and uniform. I'm using simple which just loads and loads as you scroll down (making the scrollable page longer). Uniform loads and removes the above section that is now out of viewport. I tried using uniform mode, and if it worked I wouldn't even need to ask what I'm about to, but it's super buggy and defeats the purpose. Simple on the other hand is super fast scrolling and loading is equally fast.</p> <p>I broken down my list into few groups where user can click and it will load that ReactList component. If the scrollable page is short, ie, user hasn't scrolled all the way down, changing between the group of lists is fast enough. ~2s. However, if the page is scrolled all the way down, and trying to change list takes ~6s.</p> <p>I noticed that the page is fully loaded too, ie nothing more to load. So okay, I think maybe if I change the key for the wrapper parent component and just remount the component, it should be fast right? Nope. The component that reloads is short, only one viewport length, but it takes around ~5s.</p> <p>I noticed changing out of the fully loaded list component page to just regular single line text "Hello world" component still took around the same amount! ~5s. What's up with that?</p> <p><strong>QUESTION: Why is unmounting a long page with many small components in a list take so long to just unmount?</strong></p> <p>Sorry I realize this is long and full of text but I thought I should explain my situation.</p>
0debug
Filling json file in a specific html table columns depended on objects value : <p>How to fill a json file in html table where an object value of the file must be filled in a specific column? i.e: I have the following json file:</p> <pre><code>[{"id":1,"num":"5","day":1}, {"id":1,"num":"5","day":4}, {"id":2,"num":"6","day":5}, {"id":3,"num":"8","day":4}, {"id":3,"num":"8","day":7}, .... ] </code></pre> <p>then I want to fill it in html table like that:</p> <h2>id|day1|day2|day3|day4|day5|day6|day7|</h2> <h2>1|5|0|0|5|0|0|0|0|</h2> <h2>2|0|0|0|0|6|0|0|0|</h2> <h2>3|0|0|0|8|0|0|0|8|</h2> <p>...</p> <p>TIA</p>
0debug
why can't android urlEncode like everyone else? : I am having to do stupid s**t like this to get urlEncoding to work like other libraries (iOS, Javascript..) because `java.net.URLEncoder` is buggy or not written to standard encoding: URLEncoder.encode(normalizeString(str), StandardCharsets.UTF_8.displayName()) .replace("+", "%20") .replace("%40", "@") .replace("*", "%2A"); `+` and `*` are not percent encoded while `@` is. and...now it's encoding forward slash `/`. wtf! is there a good explanation for this? Am I using the wrong Charset? TIA
0debug
How to use greater or less than sign in c# mysql update statement : I'm trying to set expiry status of a particular item in the database through my c# winforms application. So far, I've tried this MySqlCommand comm = new MySqlCommand("update items set Expiry = 'Yes' where ExpiryDate > "+ DateTime.Now.ToShortTimeString()+");",connection); comm.ExecuteNonQuery(); But I'm having issues with it Thanks
0debug
it happen red caution:"Cannot resolve symbol 'mBlockLayoutRequests'"when i open ListView source code" : it happen red caution:"Cannot resolve symbol 'mBlockLayoutRequests'"when i open ListView source code,look it picture:http://i.stack.imgur.com/8K2Dw.png .but i can find it in AdapterView that is inherited by ListView,look it picture http://i.stack.imgur.com/3uVW7.png boolean mBlockLayoutRequests = false; when i click it ,it tip "Cannot find declaration to go to ", is it a error ? if it is a error ,what should i do for fix this error ?
0debug
Convert BMP file to pdf : I want to convert a file format bmp to pdf in visual studio using visual basic technologieand I'am used the PdfSharp library to do this . I recieved the following error : An unhandled exception of type 'System.IO.FileNotFoundException' occurred in PdfSharp-wpf.dll Additional information: The file 'E:\...\bin\Debug\-1493104802' does not exist. Any Solution ?
0debug
What regex syntax is this, and how do I make it run on .NET? : <p>I'm looking for a suitable regex for hyperlinks. </p> <p>I found a link to this website: <a href="https://mathiasbynens.be/demo/url-regex" rel="nofollow">https://mathiasbynens.be/demo/url-regex</a>, which has several choices. (There are too many to list here.)</p> <p>However, these do not seem to be compatible with .NET's Regex syntax. I tried using the "cowboy" pattern vs several hyperlinks, e.g. <a href="http://www.cnn.com" rel="nofollow">http://www.cnn.com</a>, but no match results. </p> <p>What syntax are these, and how do I get these to work with .NET? If these require manual tweaking, then just showing how to get the "cowboy" pattern to run will suffice.</p>
0debug
VM in virtualbox is already locked for a session (or being unlocked) : <p>My VM in virtualbox can not start due to this error, I don't want to destroy it and reinstall it again, anyway to recover it ?</p> <p>There was an error while executing <code>VBoxManage</code>, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.</p> <pre><code>Command: ["modifyvm", "319fcce3-e8ff-4b6f-a641-3aee1df6543f", "--natpf1", "delete", "ssh"] Stderr: VBoxManage: error: The machine 'centos64_c6402_1454036461345_59755' is already locked for a session (or being unlocked) VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports VBoxManage: error: Context: "LockMachine(a-&gt;session, LockType_Write)" at line 493 of file VBoxManageModifyVM.cpp </code></pre>
0debug
static uint64_t build_channel_report_mcic(void) { uint64_t mcic; mcic = MCIC_SC_CP | MCIC_VB_WP | MCIC_VB_MS | MCIC_VB_PM | MCIC_VB_IA | MCIC_VB_FP | MCIC_VB_GR | MCIC_VB_CR | MCIC_VB_ST | MCIC_VB_AR | MCIC_VB_PR | MCIC_VB_FC | MCIC_VB_CT | MCIC_VB_CC; if (s390_has_feat(S390_FEAT_VECTOR)) { mcic |= MCIC_VB_VR; } if (s390_has_feat(S390_FEAT_GUARDED_STORAGE)) { mcic |= MCIC_VB_GS; } return mcic; }
1threat
Getting error after i put Async function in useEffect : <p>In the useEffect function, If i just mention the getResults function variable, the app doesn't crash, but when i call it as i'm doing in code below, i get these errors : </p> <blockquote> <p>react-dom.development.js:21857 Uncaught TypeError: destroy is not a function</p> </blockquote> <p>and</p> <blockquote> <p>Consider adding an error boundary to your tree to customize error handling behavior.</p> </blockquote> <pre><code> function App() { const [foods, setFoods] = useState([]); const [isLoaded, setIsLoaded] = useState(false); useEffect(() =&gt; getResponse()); const getResponse = async () =&gt; { const response = await fetch(sampleRequest); const data = await response.json(); setFoods(data.hits); }; let query = "Tomato"; let sampleRequest = `https://api.edamam.com/search?q=${query}&amp;app_id=${"1811484f"}&amp;app_key=${"9cac93361efc99e2ebfbb8a453882af8"}`; return ( &lt;div className="App"&gt; &lt;div className="main"&gt; &lt;div className="navbars"&gt; {" "} &lt;Navbars&gt;&lt;/Navbars&gt; &lt;/div&gt; &lt;div className="listings"&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;/div&gt; &lt;div className="footer"&gt; &lt;h5&gt;Made By YoYo Strangler in 2019&lt;/h5&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ); } export default App; </code></pre>
0debug
Add property to interface typescript : <p>So I'm working on an Angular Project and created this interface to be able to show some data:</p> <pre><code>export interface UserData { name: string, vorname: string, strasse: string, plz: string, ort: string, handynummer: string, telefonnummer: string, } </code></pre> <p>If I want to show add more Data in my database, i would have to add these datapoint to this interface, is there a way to create a interface dynamically, or create it in the Components Constructor?</p>
0debug
void do_info_vnc(void) { if (vnc_state == NULL) term_printf("VNC server disabled\n"); else { term_printf("VNC server active on: "); term_print_filename(vnc_state->display); term_printf("\n"); if (vnc_state->csock == -1) term_printf("No client connected\n"); else term_printf("Client connected\n"); } }
1threat
static int cris_mmu_translate_page(struct cris_mmu_result_t *res, CPUState *env, uint32_t vaddr, int rw, int usermode) { unsigned int vpage; unsigned int idx; uint32_t lo, hi; uint32_t tlb_vpn, tlb_pfn = 0; int tlb_pid, tlb_g, tlb_v, tlb_k, tlb_w, tlb_x; int cfg_v, cfg_k, cfg_w, cfg_x; int set, match = 0; uint32_t r_cause; uint32_t r_cfg; int rwcause; int mmu = 1; int vect_base; r_cause = env->sregs[SFR_R_MM_CAUSE]; r_cfg = env->sregs[SFR_RW_MM_CFG]; switch (rw) { case 2: rwcause = CRIS_MMU_ERR_EXEC; mmu = 0; break; case 1: rwcause = CRIS_MMU_ERR_WRITE; break; default: case 0: rwcause = CRIS_MMU_ERR_READ; break; } vect_base = (mmu + 1) * 4; vpage = vaddr >> 13; #if 0 for (set = 0; set < 4; set++) { for (idx = 0; idx < 16; idx++) { lo = env->tlbsets[mmu][set][idx].lo; hi = env->tlbsets[mmu][set][idx].hi; tlb_vpn = EXTRACT_FIELD(hi, 13, 31); tlb_pfn = EXTRACT_FIELD(lo, 13, 31); printf ("TLB: [%d][%d] hi=%x lo=%x v=%x p=%x\n", set, idx, hi, lo, tlb_vpn, tlb_pfn); } } #endif idx = vpage & 15; for (set = 0; set < 4; set++) { lo = env->tlbsets[mmu][set][idx].lo; hi = env->tlbsets[mmu][set][idx].hi; tlb_vpn = EXTRACT_FIELD(hi, 13, 31); tlb_pfn = EXTRACT_FIELD(lo, 13, 31); D(printf("TLB[%d][%d] v=%x vpage=%x -> pfn=%x lo=%x hi=%x\n", i, idx, tlb_vpn, vpage, tlb_pfn, lo, hi)); if (tlb_vpn == vpage) { match = 1; break; } } res->bf_vec = vect_base; if (match) { cfg_w = EXTRACT_FIELD(r_cfg, 19, 19); cfg_k = EXTRACT_FIELD(r_cfg, 18, 18); cfg_x = EXTRACT_FIELD(r_cfg, 17, 17); cfg_v = EXTRACT_FIELD(r_cfg, 16, 16); tlb_pid = EXTRACT_FIELD(hi, 0, 7); tlb_pfn = EXTRACT_FIELD(lo, 13, 31); tlb_g = EXTRACT_FIELD(lo, 4, 4); tlb_v = EXTRACT_FIELD(lo, 3, 3); tlb_k = EXTRACT_FIELD(lo, 2, 2); tlb_w = EXTRACT_FIELD(lo, 1, 1); tlb_x = EXTRACT_FIELD(lo, 0, 0); if (!tlb_g && tlb_pid != (env->pregs[PR_PID] & 0xff)) { D(printf ("tlb: wrong pid %x %x pc=%x\n", tlb_pid, env->pregs[PR_PID], env->pc)); match = 0; res->bf_vec = vect_base; } else if (rw == 1 && cfg_w && !tlb_w) { D(printf ("tlb: write protected %x lo=%x\n", vaddr, lo)); match = 0; res->bf_vec = vect_base + 3; } else if (cfg_v && !tlb_v) { D(printf ("tlb: invalid %x\n", vaddr)); set_field(&r_cause, rwcause, 8, 9); match = 0; res->bf_vec = vect_base + 1; } res->prot = 0; if (match) { res->prot |= PAGE_READ; if (tlb_w) res->prot |= PAGE_WRITE; if (tlb_x) res->prot |= PAGE_EXEC; } else D(dump_tlb(env, mmu)); env->sregs[SFR_RW_MM_TLB_HI] = hi; env->sregs[SFR_RW_MM_TLB_LO] = lo; } if (!match) { idx = vpage & 15; set = 0; env->sregs[SFR_RW_MM_TLB_SEL] = 0; set_field(&env->sregs[SFR_RW_MM_TLB_SEL], idx, 0, 4); set_field(&env->sregs[SFR_RW_MM_TLB_SEL], set, 4, 5); set_field(&r_cause, rwcause, 8, 2); set_field(&r_cause, vpage, 13, 19); set_field(&r_cause, env->pregs[PR_PID], 0, 8); env->sregs[SFR_R_MM_CAUSE] = r_cause; D(printf("refill vaddr=%x pc=%x\n", vaddr, env->pc)); } D(printf ("%s rw=%d mtch=%d pc=%x va=%x vpn=%x tlbvpn=%x pfn=%x pid=%x" " %x cause=%x sel=%x sp=%x %x %x\n", __func__, rw, match, env->pc, vaddr, vpage, tlb_vpn, tlb_pfn, tlb_pid, env->pregs[PR_PID], r_cause, env->sregs[SFR_RW_MM_TLB_SEL], env->regs[R_SP], env->pregs[PR_USP], env->ksp)); res->pfn = tlb_pfn; return !match; }
1threat
How to get week number from date input in javascript? : <p>I am trying to get the week number of current date / specific date falls in. Any suggestions for logic building will be helpful.</p>
0debug
C++ WriteFile doesnt work and returns 5 ( GetLastError() ), even tho i have admin permition : <p>Ok so, im making this programm that lets me access and write in a usb device. Im having this problem that, when i try to run the WriteFile( hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped ); it doenst work and returns 5 if i do the GetLastErrror(). If consulted manny foruns in the web and pretty much they all say that i need to run it as admin, but im admin and i set the compiler to run as admin, and the project too... so what am i doing wrong? Hanny help would be much appreciated!</p>
0debug
node http-server not serving updated html files : <p>I am building out a front-end web app with angular (mostly ui-router) and doing local development by serving the html files through node <a href="https://github.com/indexzero/http-server" rel="noreferrer">http-server</a>. I have noticed that http-server isn't serving my static html files when I make updates, which is challenging to my local development.</p> <p>I have http-server installed globally with <code>npm install http-server -g</code> and start it up by going to the root project folder and running <code>http-server</code>. It defaults to localhost:8080- the two ways that seem to work is changing the port number after each update or going through chrome incognito mode.</p> <p>Is there a way to use http-server normally without having to change the port or using incognito mode?</p> <p>If it is relevant, I am using MBP v. 10.11.3</p> <p>Thank you!</p>
0debug
How to limit for 10 results the array.filter? : <p>I have big array, I want to make an autocomplete search, but I want to display only 10 results, so stop iterating through the array by the time there were found 10 results. I have made this:</p> <pre><code>let items = array.filter(r =&gt; r.indexOf(term)!=-1); console.log(items.length) // lots of items, need to be limited to 10 </code></pre> <p>It works but I don't know how to stop the <code>array.filter</code> by the time it reaches the desired limit.</p>
0debug
nth-child returning source, not the expected target(s) : I'm trying to sharpen my jQuery skills by learning to use `nth-child` selector but with little luck. I'm sure I'm just doing something slightly wrong, and I will have a follow up question to this again regarding nth-child, so any help is appreciated. I would have thought my code below would have select "Saab" and "Audi" in the pulldown menu, but what it does is return the "source" `select` element, `select#carsmenu`. What am I doing wrong? <script> $(document).ready(function() { console.log($('#carsmenu:nth-child(odd)').prop('selected', true)); }); </script> <select multiple id="carsmenu"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select>
0debug
int net_init_l2tpv3(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { const NetdevL2TPv3Options *l2tpv3; NetL2TPV3State *s; NetClientState *nc; int fd = -1, gairet; struct addrinfo hints; struct addrinfo *result = NULL; char *srcport, *dstport; nc = qemu_new_net_client(&net_l2tpv3_info, peer, "l2tpv3", name); s = DO_UPCAST(NetL2TPV3State, nc, nc); s->queue_head = 0; s->queue_tail = 0; s->header_mismatch = false; assert(opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3); l2tpv3 = opts->u.l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { s->ipv6 = l2tpv3->ipv6; } else { s->ipv6 = false; } if ((l2tpv3->has_offset) && (l2tpv3->offset > 256)) { error_report("l2tpv3_open : offset must be less than 256 bytes"); goto outerr; } if (l2tpv3->has_rxcookie || l2tpv3->has_txcookie) { if (l2tpv3->has_rxcookie && l2tpv3->has_txcookie) { s->cookie = true; } else { goto outerr; } } else { s->cookie = false; } if (l2tpv3->has_cookie64 || l2tpv3->cookie64) { s->cookie_is_64 = true; } else { s->cookie_is_64 = false; } if (l2tpv3->has_udp && l2tpv3->udp) { s->udp = true; if (!(l2tpv3->has_srcport && l2tpv3->has_dstport)) { error_report("l2tpv3_open : need both src and dst port for udp"); goto outerr; } else { srcport = l2tpv3->srcport; dstport = l2tpv3->dstport; } } else { s->udp = false; srcport = NULL; dstport = NULL; } s->offset = 4; s->session_offset = 0; s->cookie_offset = 4; s->counter_offset = 4; s->tx_session = l2tpv3->txsession; if (l2tpv3->has_rxsession) { s->rx_session = l2tpv3->rxsession; } else { s->rx_session = s->tx_session; } if (s->cookie) { s->rx_cookie = l2tpv3->rxcookie; s->tx_cookie = l2tpv3->txcookie; if (s->cookie_is_64 == true) { s->offset += 8; s->counter_offset += 8; } else { s->offset += 4; s->counter_offset += 4; } } memset(&hints, 0, sizeof(hints)); if (s->ipv6) { hints.ai_family = AF_INET6; } else { hints.ai_family = AF_INET; } if (s->udp) { hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; s->offset += 4; s->counter_offset += 4; s->session_offset += 4; s->cookie_offset += 4; } else { hints.ai_socktype = SOCK_RAW; hints.ai_protocol = IPPROTO_L2TP; } gairet = getaddrinfo(l2tpv3->src, srcport, &hints, &result); if ((gairet != 0) || (result == NULL)) { error_report( "l2tpv3_open : could not resolve src, errno = %s", gai_strerror(gairet) ); goto outerr; } fd = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (fd == -1) { fd = -errno; error_report("l2tpv3_open : socket creation failed, errno = %d", -fd); goto outerr; } if (bind(fd, (struct sockaddr *) result->ai_addr, result->ai_addrlen)) { error_report("l2tpv3_open : could not bind socket err=%i", errno); goto outerr; } if (result) { freeaddrinfo(result); } memset(&hints, 0, sizeof(hints)); if (s->ipv6) { hints.ai_family = AF_INET6; } else { hints.ai_family = AF_INET; } if (s->udp) { hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; } else { hints.ai_socktype = SOCK_RAW; hints.ai_protocol = IPPROTO_L2TP; } result = NULL; gairet = getaddrinfo(l2tpv3->dst, dstport, &hints, &result); if ((gairet != 0) || (result == NULL)) { error_report( "l2tpv3_open : could not resolve dst, error = %s", gai_strerror(gairet) ); goto outerr; } s->dgram_dst = g_new0(struct sockaddr_storage, 1); memcpy(s->dgram_dst, result->ai_addr, result->ai_addrlen); s->dst_size = result->ai_addrlen; if (result) { freeaddrinfo(result); } if (l2tpv3->has_counter && l2tpv3->counter) { s->has_counter = true; s->offset += 4; } else { s->has_counter = false; } if (l2tpv3->has_pincounter && l2tpv3->pincounter) { s->has_counter = true; s->pin_counter = true; } else { s->pin_counter = false; } if (l2tpv3->has_offset) { s->offset += l2tpv3->offset; } if ((s->ipv6) || (s->udp)) { s->header_size = s->offset; } else { s->header_size = s->offset + sizeof(struct iphdr); } s->msgvec = build_l2tpv3_vector(s, MAX_L2TPV3_MSGCNT); s->vec = g_new(struct iovec, MAX_L2TPV3_IOVCNT); s->header_buf = g_malloc(s->header_size); qemu_set_nonblock(fd); s->fd = fd; s->counter = 0; l2tpv3_read_poll(s, true); snprintf(s->nc.info_str, sizeof(s->nc.info_str), "l2tpv3: connected"); return 0; outerr: qemu_del_net_client(nc); if (fd >= 0) { close(fd); } if (result) { freeaddrinfo(result); } return -1; }
1threat
PHP (7.2.23) Update version not working when installing composer in PHP Storm editor : - **I'm installing a project from git. When I try to install composer it shows message that require php 7.2 your version 7.1.1** - But my php version is 7.2.23, I have checked it locally from : http://localhost/dashboard/phpinfo.php - **Error message from php storm editor :** - Problem 1 - **This package requires php ^7.2 but your PHP version (7.1.1) does not satisfy that requirement. Problem 2**
0debug
static void blend_image_rgb(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y) { blend_image_packed_rgb(ctx, dst, src, 0, x, y, 0); }
1threat
Assign first item of queue to int : <p>I am trying to assign the first item of a queue to an int</p> <pre><code>queue&lt;int&gt; q; int cur = q.pop(); </code></pre> <p>put it gives me an error </p> <pre><code>Types 'int' and 'void' are not compatible </code></pre>
0debug
How to install older version of Typescript? : <p>I recently installed Typescript 1.8 and found too many breaking issues. So for the time being I would like to install 1.7. Where can I get a link to down this?</p>
0debug
Hi all,how can i add node in firebase when deleted the root node : [enter image description here][1] [1]: https://i.stack.imgur.com/vJODI.png Thanks All
0debug
Another git process seems to be running and thus cant commit : <p>I was committing my git process and thought that it would be okay if I ignore comments so I used this code</p> <pre><code>git commit filename </code></pre> <p>Bash was strange and thus i closed the console now when I use proper command </p> <pre><code>git commit -m"THIRD COMMIT" filename </code></pre> <p>It give the following response:</p> <p>Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier:</p> <p>what should I do?</p>
0debug
How should I handle `deposed` resources in Terraform? : <p>I am struggling to understand how I should handle <code>deposed</code> resources found in my TF state. </p> <p>In particular, when running an apply, I am now getting some errors like the below: </p> <pre><code>Error applying plan: 11 error(s) occurred: * aws_instance.mongo-replica-01 (deposed #0): Error terminating instance: InvalidInstanceID.NotFound: The instance ID 'i-0f0bdc2c16e922fbc' does not exist status code: 400, request id: 71b98708-cb06-4f11-ad14-8d3d160fbc1a * aws_instance.mongo-replica-01 (deposed #1): Error terminating instance: InvalidInstanceID.NotFound: The instance ID 'i-080ef01dc84c09685' does not exist status code: 400, request id: 07c96f82-1e32-4944-a1d6-ab0e6306b82e * aws_instance.mongo-replica-02 (deposed #1): Error terminating instance: InvalidInstanceID.NotFound: The instance ID 'i-085b997daac742c1e' does not exist status code: 400, request id: 20ff2b73-39c9-4d49-af41-f4ec542ec782 * aws_instance.mongo-replica-02 (deposed #0): Error terminating instance: InvalidInstanceID.NotFound: The instance ID 'i-00bc7fd15b04a3688' does not exist status code: 400, request id: cdea3c4f-9bec-496a-aedd-bcfbf0a706d2 </code></pre> <p>The AWS EC2 instances in question do not exist indeed, but TF errors out when trying to delete them (presumably because they don't exist) and still keeps them in the state. </p> <p>I tried using the <code>terraform state</code> command in an attempt to remove the <code>deposed</code> resources, but it only allows me to delete the whole resource, not just the <code>deposed</code> instance of it... </p> <p>Am I expected to, simply, manually go in the terraform state file and delete the deposed sections??</p>
0debug
static int open_input_stream(HTTPContext *c, const char *info) { char buf[128]; char input_filename[1024]; AVFormatContext *s = NULL; int buf_size, i, ret; int64_t stream_pos; if (c->stream->feed) { strcpy(input_filename, c->stream->feed->feed_filename); buf_size = FFM_PACKET_SIZE; if (av_find_info_tag(buf, sizeof(buf), "date", info)) { if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0) { http_log("Invalid date specification '%s' for stream\n", buf); return ret; } } else if (av_find_info_tag(buf, sizeof(buf), "buffer", info)) { int prebuffer = strtol(buf, 0, 10); stream_pos = av_gettime() - prebuffer * (int64_t)1000000; } else stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000; } else { strcpy(input_filename, c->stream->feed_filename); buf_size = 0; if (av_find_info_tag(buf, sizeof(buf), "date", info)) { if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0) { http_log("Invalid date specification '%s' for stream\n", buf); return ret; } } else stream_pos = 0; } if (!input_filename[0]) { http_log("No filename was specified for stream\n"); return AVERROR(EINVAL); } ret = avformat_open_input(&s, input_filename, c->stream->ifmt, &c->stream->in_opts); if (ret < 0) { http_log("Could not open input '%s': %s\n", input_filename, av_err2str(ret)); return ret; } if (buf_size > 0) { ret = ffio_set_buf_size(s->pb, buf_size); if (ret < 0) { http_log("Failed to set buffer size\n"); return ret; } } s->flags |= AVFMT_FLAG_GENPTS; c->fmt_in = s; if (strcmp(s->iformat->name, "ffm") && (ret = avformat_find_stream_info(c->fmt_in, NULL)) < 0) { http_log("Could not find stream info for input '%s'\n", input_filename); avformat_close_input(&s); return ret; } c->pts_stream_index = 0; for(i=0;i<c->stream->nb_streams;i++) { if (c->pts_stream_index == 0 && c->stream->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { c->pts_stream_index = i; } } if (c->fmt_in->iformat->read_seek) av_seek_frame(c->fmt_in, -1, stream_pos, 0); c->start_time = cur_time; c->first_pts = AV_NOPTS_VALUE; return 0; }
1threat
Android Game Development Engine needed? : <p>I am new to Android / Android Game Development. I wrote a few basic Apps in Android Studio and want to make an 2D game like Flappybird/Crossyroad/Jetpack Joyride.</p> <p>What exactly do I have to do for this (download,install,learn)? </p> <p>Do I need an Engine, what exactly is an Engine, so dont I need Android Studio anymore. </p> <p>Do I have to programm in Java? (I heared that an Engine can be in C# but how can this works fine on android[which is Java based? ]) </p>
0debug
asp.net core in Docker container vs Azure App service : <p>We can obviously now deploy our asp.net core apps into docker container. I went through docs about 'how to do it' but i couldn't find some proper explanation about 'why to do it'?</p> <p>Could anyone explain why would one choose deploying asp.net core app to docker container instead of azure app service?</p>
0debug
Gitlab : List all the projects and all the groups : <p>What is the easiest method to list all the projects and groups in Gitlab using my private token.</p>
0debug
Can we use the JQuery , java scripts in Windowform using C# : <p>Please give me the detailed information about this " can we use the JQuery, Java Script, bootstrap in Windowform application using C#" </p>
0debug
pass mutliple variable value into url in python : I ahve below code to get data using url. I pass ticker value from text file and its successful and its;works (part-1) but as code per part-2, when I pass multiple value using multiple variable by raw_input(), its give **error "TypeError: not enough arguments for format string"** Part-1 ticker = line.strip(); url = "http://ichart.finance.yahoo.com/table.csv?s=%s.ns&a=08&b=08&c=2015&d=08&e=08&f=2016&g=d&ignore=.csv" % ticker r = requests.get(url) Part-2 ticker = line.strip(); url = "http://ichart.finance.yahoo.com/table.csv?s=%s.ns&a=%s&b=%s&c=%s&d=%s&e=%s&f=%s&g=d&ignore=.csv" %ticker %a %b %c %d %e %f r = requests.get(url)
0debug
how to do a function activate when some variable change in java : I need to activate a function when a variable change, it will be to do an update. EX: public class Main{ private a = 1; private ch = false; private update(){ if(a % 2 == 0){ch = true;} } public static void main(String[] args){ a = 2; } }
0debug
Javascript function declaration with same arguments : <p>I am learning javascript myself. I found if I declare a function with same arguments it just working fine:</p> <pre><code>function func(a, b, a){ return b; } alert(func(1,2,3)); </code></pre> <p>But if I do this :</p> <pre><code>function func(a, b, a = 5){ return b; } alert(func(1,2,3)); //Firebug error - SyntaxError: duplicate argument names not allowed in this context </code></pre> <p>Then its not working anymore. What is the logic behind that it was working for first equation but not for second one ?</p>
0debug
static av_cold int avisynth_load_library(void) { avs_library.library = LoadLibrary(AVISYNTH_LIB); if (!avs_library.library) return AVERROR_UNKNOWN; #define LOAD_AVS_FUNC(name, continue_on_fail) \ avs_library.name = \ (void *)GetProcAddress(avs_library.library, #name); \ if (!continue_on_fail && !avs_library.name) \ goto fail; LOAD_AVS_FUNC(avs_bit_blt, 0); LOAD_AVS_FUNC(avs_clip_get_error, 0); LOAD_AVS_FUNC(avs_create_script_environment, 0); LOAD_AVS_FUNC(avs_delete_script_environment, 0); LOAD_AVS_FUNC(avs_get_audio, 0); LOAD_AVS_FUNC(avs_get_error, 1); LOAD_AVS_FUNC(avs_get_frame, 0); LOAD_AVS_FUNC(avs_get_version, 0); LOAD_AVS_FUNC(avs_get_video_info, 0); LOAD_AVS_FUNC(avs_invoke, 0); LOAD_AVS_FUNC(avs_release_clip, 0); LOAD_AVS_FUNC(avs_release_value, 0); LOAD_AVS_FUNC(avs_release_video_frame, 0); LOAD_AVS_FUNC(avs_take_clip, 0); #ifdef USING_AVISYNTH LOAD_AVS_FUNC(avs_bits_per_pixel, 1); LOAD_AVS_FUNC(avs_get_height_p, 1); LOAD_AVS_FUNC(avs_get_pitch_p, 1); LOAD_AVS_FUNC(avs_get_read_ptr_p, 1); LOAD_AVS_FUNC(avs_get_row_size_p, 1); LOAD_AVS_FUNC(avs_is_yv24, 1); LOAD_AVS_FUNC(avs_is_yv16, 1); LOAD_AVS_FUNC(avs_is_yv411, 1); LOAD_AVS_FUNC(avs_is_y8, 1); #endif #undef LOAD_AVS_FUNC atexit(avisynth_atexit_handler); return 0; fail: FreeLibrary(avs_library.library); return AVERROR_UNKNOWN; }
1threat
pandas assign with new column name as string : <p>I recently discovered pandas <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.assign.html" rel="noreferrer">"assign" method</a> which I find very elegant. My issue is that the name of the new column is assigned as keyword, so it cannot have spaces or dashes in it. </p> <pre><code>df = DataFrame({'A': range(1, 11), 'B': np.random.randn(10)}) df.assign(ln_A = lambda x: np.log(x.A)) A B ln_A 0 1 0.426905 0.000000 1 2 -0.780949 0.693147 2 3 -0.418711 1.098612 3 4 -0.269708 1.386294 4 5 -0.274002 1.609438 5 6 -0.500792 1.791759 6 7 1.649697 1.945910 7 8 -1.495604 2.079442 8 9 0.549296 2.197225 9 10 -0.758542 2.302585 </code></pre> <p>but what if I want to name the new column "ln(A)" for example? E.g. </p> <pre><code>df.assign(ln(A) = lambda x: np.log(x.A)) df.assign("ln(A)" = lambda x: np.log(x.A)) File "&lt;ipython-input-7-de0da86dce68&gt;", line 1 df.assign(ln(A) = lambda x: np.log(x.A)) SyntaxError: keyword can't be an expression </code></pre> <p>I know I could rename the column right after the .assign call, but I want to understand more about this method and its syntax.</p>
0debug
Change Carthage Swift version : <p>Is it possible to change Carthage Swift version used to build the frameworks?</p> <p>I'm trying to migrate my project to swift 3 (on Xcode 8 beta), and the third party libraries are the only thing that stops my project from compiling. While using specific branches for swift 3, Carthage throws errors about the new Swift syntax.</p> <p>Any help will be appreciated!</p>
0debug
void spapr_iommu_init(void) { QLIST_INIT(&spapr_tce_tables); spapr_register_hypercall(H_PUT_TCE, h_put_tce); }
1threat
How to resize image in angular 2 before uploading it to server? : <p>I want to resize image with size of 74 x 74, I am using ng2-uploader directive to upload image. If there is any other directive I can use to achieve my requirement please suggest me. Thanks</p>
0debug
How to get bitcoins for testing? : <p>I'm trying to test bitcoin and I would like to win 1 bitcoins or even 0.00001 just to see how is it to receive and send money. I visited many faucets, I filled surveys, I watched ads but I never get my payment in bitcoins ! Do you know a website which really sends a micro sum of bitcoins just for me to test ?</p> <p>Windows 7 / Firefox 50.0</p>
0debug
static uint32_t slow_bar_readl(void *opaque, target_phys_addr_t addr) { AssignedDevRegion *d = opaque; uint32_t *in = (uint32_t *)(d->u.r_virtbase + addr); uint32_t r; r = *in; DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r); return r; }
1threat
Can you animate a svg "background-image"? : <p>I want to center a svg-image horzontal and vertical responsive to my window. So I decided to integrate the image in a div background. Now when i want to add stroke-dasharray's and animations with stroke-dashoffset to my svg it doesn't work.</p> <p>Is this posibble to animate a svg background image?</p> <p>The svg-image consists only out of many lines. <strong>Here my svg file (there are much more lines with only different x and y values):</strong></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1920 1200" xml:space="preserve"&gt; &lt;g id="Layer_1"&gt; &lt;line class="path" stroke-linecap="round" fill="none" stroke="#FFFFFF" stroke-width="3" stroke-miterlimit="10" x1="960" y1="600" x2="2346.139" y2="-42.064"/&gt; &lt;/g&gt; &lt;/svg&gt;</code></pre> </div> </div> </p> <p><strong>And here my Html and Css files:</strong></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>html, body { padding: 0; margin: 0; height: 100%; width: 100%; background-color: red; } .Container { position: relative; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 100%; height: 100%; background-image: url(Space.svg); background-size: cover; background-position: center; } .path { stroke-dasharray: 20; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;body&gt; &lt;div class="Container"&gt; &lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p>
0debug
using Ruby do little changes to run the program : for every line of code a description is given what to do i have completed half of the program and stuck in self object and onwards program so please complete it so that it works. class Person #have a first_name and last_name attribute with public accessors #attr_accessor attr_accessor :first_name , :last_name #have a class attribute called `people` that holds an array of objects @@people = [] #have an `initialize` method to initialize each instance def initialize(first_name,last_name)#should take 2 parameters for first_name and last_name @first_name = first_name @last_name = last_name #assign those parameters to instance variables #add the created instance (self) to people class variable end #have a `search` method to locate all people with a matching `last_name` def self.search(last_name) #accept a `last_name` parameter #search the `people` class attribute for instances with the same `last_name` #return a collection of matching instances end #have a `to_s` method to return a formatted string of the person's name def to_s #return a formatted string as `first_name(space)last_name` end end p1 = Person.new("John", "Smith") p2 = Person.new("John", "Doe") p3 = Person.new("Jane", "Smith") p4 = Person.new("Cool", "Dude") puts Person.search("Smith") # Should print out # => John Smith # => Jane Smith
0debug
static uint32_t vmsvga_value_read(void *opaque, uint32_t address) { uint32_t caps; struct vmsvga_state_s *s = opaque; DisplaySurface *surface = qemu_console_surface(s->vga.con); uint32_t ret; switch (s->index) { case SVGA_REG_ID: ret = s->svgaid; break; case SVGA_REG_ENABLE: ret = s->enable; break; case SVGA_REG_WIDTH: ret = surface_width(surface); break; case SVGA_REG_HEIGHT: ret = surface_height(surface); break; case SVGA_REG_MAX_WIDTH: ret = SVGA_MAX_WIDTH; break; case SVGA_REG_MAX_HEIGHT: ret = SVGA_MAX_HEIGHT; break; case SVGA_REG_DEPTH: ret = s->depth; break; case SVGA_REG_BITS_PER_PIXEL: ret = (s->depth + 7) & ~7; break; case SVGA_REG_PSEUDOCOLOR: ret = 0x0; break; case SVGA_REG_RED_MASK: ret = surface->pf.rmask; break; case SVGA_REG_GREEN_MASK: ret = surface->pf.gmask; break; case SVGA_REG_BLUE_MASK: ret = surface->pf.bmask; break; case SVGA_REG_BYTES_PER_LINE: ret = s->bypp * s->new_width; break; case SVGA_REG_FB_START: { struct pci_vmsvga_state_s *pci_vmsvga = container_of(s, struct pci_vmsvga_state_s, chip); ret = pci_get_bar_addr(&pci_vmsvga->card, 1); break; } case SVGA_REG_FB_OFFSET: ret = 0x0; break; case SVGA_REG_VRAM_SIZE: ret = s->vga.vram_size; break; case SVGA_REG_FB_SIZE: ret = s->vga.vram_size; break; case SVGA_REG_CAPABILITIES: caps = SVGA_CAP_NONE; #ifdef HW_RECT_ACCEL caps |= SVGA_CAP_RECT_COPY; #endif #ifdef HW_FILL_ACCEL caps |= SVGA_CAP_RECT_FILL; #endif #ifdef HW_MOUSE_ACCEL if (dpy_cursor_define_supported(s->vga.con)) { caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_CURSOR_BYPASS; } #endif ret = caps; break; case SVGA_REG_MEM_START: { struct pci_vmsvga_state_s *pci_vmsvga = container_of(s, struct pci_vmsvga_state_s, chip); ret = pci_get_bar_addr(&pci_vmsvga->card, 2); break; } case SVGA_REG_MEM_SIZE: ret = s->fifo_size; break; case SVGA_REG_CONFIG_DONE: ret = s->config; break; case SVGA_REG_SYNC: case SVGA_REG_BUSY: ret = s->syncing; break; case SVGA_REG_GUEST_ID: ret = s->guest; break; case SVGA_REG_CURSOR_ID: ret = s->cursor.id; break; case SVGA_REG_CURSOR_X: ret = s->cursor.x; break; case SVGA_REG_CURSOR_Y: ret = s->cursor.x; break; case SVGA_REG_CURSOR_ON: ret = s->cursor.on; break; case SVGA_REG_HOST_BITS_PER_PIXEL: ret = (s->depth + 7) & ~7; break; case SVGA_REG_SCRATCH_SIZE: ret = s->scratch_size; break; case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: ret = 0; break; default: if (s->index >= SVGA_SCRATCH_BASE && s->index < SVGA_SCRATCH_BASE + s->scratch_size) { ret = s->scratch[s->index - SVGA_SCRATCH_BASE]; break; } printf("%s: Bad register %02x\n", __func__, s->index); ret = 0; break; } if (s->index >= SVGA_SCRATCH_BASE) { trace_vmware_scratch_read(s->index, ret); } else if (s->index >= SVGA_PALETTE_BASE) { trace_vmware_palette_read(s->index, ret); } else { trace_vmware_value_read(s->index, ret); } return ret; }
1threat
Does SQL have a condition like 'IS UNIQUE'? : <p>Wherever I was looking for, I've never heard about that any SQL implementations would have an <code>IS UNIQUE</code> "command". Did I miss something? If I'm right, what is the reason?</p> <p>In other words, why I can't state in SQL that a certain command, such as <code>INSERT INTO</code> (<em>especially</em> that) can be done only if a value is or is not considered UNIQUE?</p>
0debug
Encoding error, ISO-8859-1 : `import requests` `test = requests.get("https://www.hipstercode.com/")` `outfile = open("./settings.txt", "w") test.encoding = 'ISO-8859-1'` `outfile.write(str(test.text))` The error that i'm getting is: File `"C:/Users/Bamba/PycharmProjects/Requests/Requests/Requests.py", line 8, in <module> outfile.write(str(test.text)) File "C:\Users\Bamba\AppData\Local\Programs\Python\Python35\lib\encodings\cp1255.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\xef' in position 0: character maps to <undefined>`
0debug
Does tensorflow map_fn support taking more than one tensor? : <p>Does tf.map_fn support taking more than one tensors as is supported by python's native map function (example provided below)?</p> <pre><code>a = [1,2,3,4] b = [17,12,11,10] print(map(lambda x,y:x+y, a,b)) # ==&gt; [18, 14, 14, 14] </code></pre>
0debug
golang json doesn't parse fields with tag of embedded structure correctly : <pre><code>package main import ( "encoding/json" "fmt" ) type InnerData struct { M int64 `josn:"m"` N int64 `json:"n"` } //JSONData is a json data example type JSONData struct { Hello string `json:"hello"` Data InnerData `json:"data"` } func main() { v := JSONData{Hello: "world", Data: InnerData{N: 100000, M: 123456}} mashaled, err := json.Marshal(&amp;v) if err != nil { fmt.Println(err) return } fmt.Println(string(mashaled)) } </code></pre> <p>Noted the field M in InnerData has a tag m, so the expected result is :{"hello":"world","data":{"m":123456,"n":100000}}. While I have </p> <pre><code>{"hello":"world","data":{"M":123456,"n":100000}} </code></pre> <p>Does anyone know how to fix the problem, or where am I wrong?</p>
0debug
void helper_movl_crN_T0(int reg) { env->cr[reg] = T0; switch(reg) { case 0: cpu_x86_update_cr0(env); break; case 3: cpu_x86_update_cr3(env); break; } }
1threat