problem
stringlengths
26
131k
labels
class label
2 classes
Mongo Atlas: Connection authentication failed with custom databases : <p>I am trying the Mongo Atlas Cloud. I create a cluster and i am trying a connection with the mongo shell: (same problem with mongo drivers)</p> <pre><code>mongo mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=****-Cluster-shard-0 --ssl --username ***** --password ***** </code></pre> <p>this is the connection string in the documentation. And this is the error:</p> <pre><code>MongoDB shell version: 3.2.7 connecting to: mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=***-Cluster-shard-0 2016-07-07T01:31:17.535-0300 I NETWORK [thread1] Starting new replica set monitor for ***-Cluster-shard-0/***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017 2016-07-07T01:31:17.535-0300 I NETWORK [ReplicaSetMonitorWatcher] starting 2016-07-07T01:31:20.084-0300 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20 @(auth):6:1 @(auth):1:2 exception: login failed </code></pre> <p>I can connect to the database only when i use admin database "/admin?" in the connection string. </p> <p>THE PROBLEM:</p> <p>I need to connect to a custom database with the console or mongo drivers.</p> <p>PD: i protect my data with "***"</p>
0debug
BottomSheetBehaviour: The view is not associated with BottomSheetBehavior : <p>I am using Google Design Support Library 25.0.0 In my activity I have a relative layout with </p> <pre><code>app:layout_behavior="android.support.design.widget.BottomSheetBehavior" </code></pre> <p>Now when I reference it for adding BottomSheetBehaviour, I get the error</p> <pre><code>java.lang.IllegalArgumentException: The view is not associated with BottomSheetBehavior </code></pre> <p>Here is the layout:</p> <pre><code>&lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/maps_colayout" xmlns:app="http://schemas.android.com/tools" android:fitsSystemWindows="true" android:background="@color/white"&gt; ... &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="280dp" android:layout_gravity="bottom" android:id="@+id/rl_bottomsheet" android:background="#F3F3F3" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"&gt; ... &lt;/RelativeLayout&gt; </code></pre> <p></p> <p>And here is the activity relevant code:</p> <pre><code>CoordinatorLayout colayout = (CoordinatorLayout) findViewById(R.id.maps_colayout); View bottomSheet = colayout.findViewById(R.id.rl_bottomsheet); BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet); behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { // React to state change } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { // React to dragging events } }); </code></pre>
0debug
int32_t helper_fstoi(CPUSPARCState *env, float32 src) { int32_t ret; clear_float_exceptions(env); ret = float32_to_int32_round_to_zero(src, &env->fp_status); check_ieee_exceptions(env); return ret; }
1threat
C++: Cannot copy line from an input file to an output file : <p>This is a home work question, so if you are not a fan of those I understand. Here is my code:</p> <pre><code>#include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { fstream myfile1("datafile1.txt"); //this just has a bunch of names in it fstream myfile2("cmdfile1.txt"); //has commands like "add bobby bilbums" ofstream outputFile("outfile1.txt"); //I want to take the "add bobby" command and copy the name into this new file. string line; if (myfile1.is_open() &amp;&amp; myfile2.is_open()) //so I open both files { if (myfile2, line == "add"); //If myfile2 has an "add" in it { outputFile.is_open(); //open outputfile outputFile &lt;&lt; line &lt;&lt; endl; //input the line with add in it till the end of that line. } } cout &lt;&lt; "\nPress Enter..."; // press enter and then everything closes out. cin.ignore(); outputFile.close(); myfile2.close(); myfile1.close(); return 0; } </code></pre> <p>Problem is, though the outputFile is always empty. It never copies any lines from cmdfile1 into the output file. Does anyone know what I am missing here? </p>
0debug
remove item object javascript : <p>I have the following object:</p> <pre><code>[{ "id": 2, "price": 2000, "name": "Mr Robot T1", "image": "http://placehold.it/270x335" }, { "id": 1, "price": 1000, "name": "Mr Robot T2", "image": "http://placehold.it/270x335" }] </code></pre> <p>and what I want is to remove the first item (id = 1) and the result is:</p> <pre><code>[{ "id": 2, "price": 2000, "name": "Mr Robot T1", "image": "http://placehold.it/270x335" }] </code></pre> <p>as it could do?</p>
0debug
why does this line ignored by java? : <p>i am writing a program to provide a menu for the user .. after he enters a number i use switch to decide which parameter should the user enter . Anyway, in one case ( case 1 ) i need to inputs from the user . but after the user enter the first input the program breaks the switch and go to do what is after the switch . </p> <p>code : </p> <p>the case 1 : </p> <pre><code> case 1: System.out.println("Enter the Amount :"); currentAccount.debit(scanner.nextDouble()); System.out.println("Want anything else(yes/no)?"); String input=scanner.nextLine(); if(input.equalsIgnoreCase("no")){ isFinished=true; currentAccount=null; System.out.println("SignedOut successfully"); } break; </code></pre> <p>output:</p> <pre><code>Choose an opearation: 1.withdraw. 2.deposit. 3.transaction history. 1 Enter the Amount : 100 Debit amount exceeded account balance. Want anything else(yes/no)? --------- Mhd Bank --------- logined as : -------------------------------- Choose an opearation: 1.withdraw. 2.deposit. 3.transaction history. </code></pre>
0debug
Writing CSV Rows to a Dataframe : I am using the csv library to read specific rows from several files I have. The problem I am having is saving those rows into a dataframe. I am getting an indexing error that I can't solve. The current version of the code finds the column names (which is on the third row) and then starts finding the data I need (which starts on the sixth row and continues until it hits a blank row). Finding the column names works fine, but when I try to append the data to it, I get the error: "InvalidIndexError: Reindexing only valid with uniquely valued Index objects" The code I currently have is as follows: i=0 import csv import pandas as pd df = pd.DataFrame() with open('C:/Users/sword/Anaconda3/envs/exceltest/RF_SubjP02_Free_STATIC_TR01.csv', 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') for row in csvreader: if csvreader.line_num == 3: #this is for the column names print(row) df = pd.DataFrame(columns = row) df.columns = row if csvreader.line_num >= 6: #this is for the data if row: #checks for blank row if i<10: #just printing the top ten rows for debugging purposes, theres thousands I need print(i) i+=1 df.append(row) #this is where I get the indexing error else: # breaks out of loop if break print(df) #for double checking if it worked
0debug
stream reader over regex loop? : <p>how I can apply stream reader over regex loop </p> <p>please help i dont know</p> <pre><code> string Value =pattern search; var match = Regex.Match(File.ReadAllText(patch ) , Value); while (match.Success) { doing regex code loop } </code></pre> <p>please give me a hand</p>
0debug
How to stop bokeh from opening a new tab in Jupyter Notebook? : <p>First of all, before this is tagged as duplicate, I have read the other solutions and unfortunately none of them worked for me.</p> <p>My problem is that I want to display a bokeh plot in Juypter Notebook (and only in Jupyter Notebook), not in a new tab/window.</p> <p>In the official documentation <a href="http://bokeh.pydata.org/en/latest/docs/user_guide/notebook.html#inline-plots" rel="noreferrer">here</a> I am told that I only need to change</p> <pre><code>output_file </code></pre> <p>to </p> <pre><code>output_notebook </code></pre> <p>Even though the plot <strong>is</strong> now displayed inline if I do that, bokeh won't stop also opening a new tab and needlessly displaying the plot there.</p> <p>Since I'm gonna create lots of plots in my project, it'd be very nice to not always have to close this new tab and return to notebook, but just have it stop creating new tabs, just as it would work with e.g. matplotlib.</p> <p>What confuses me is that if I load up the <a href="https://hub.mybinder.org/user/bokeh-bokeh-notebooks-obozp12q/notebooks/tutorial/02%20-%20Styling%20and%20Theming.ipynb" rel="noreferrer">official tutorial</a> and enter code there, for example</p> <pre><code>import numpy as np x = np.linspace(0, 10, 100) y = np.exp(x) p = figure() p.line(x, y) show(p) </code></pre> <p>there is no new tab opened. If I now run the same code locally on my machine's Juypter Notebook, it <strong>does</strong> open up a new tab.</p> <p>I've been trying for a while now to fix this, any help would be very much appreciated.</p> <p>Thanks in advance, Vincent</p>
0debug
Python "Str to Int" within a list of lists...How? : I want to convert an element "str" to "int" within a list of list. list = [['2003', '12', '5'], ['2004', '10', '7']] to [['2003', '12', 5], ['2004', '10', 7]]
0debug
void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp) { v->type_str(v, name, obj, errp); }
1threat
how to create empty file in python : <p>I would like to create an empty file in Python. But I have difficulty creating one..Below is the Python code I used to create but it gives me error:</p> <pre><code>gdsfile = "/home/hha/temp.gds" if not (os.path.isfile(gdsfile)): os.system(touch gdsfile) </code></pre> <p>Error I got: File "/home/hha/bin/test.py", line 29 os.system(touch gdsfile) ^ SyntaxError: invalid syntax</p> <p>But from the command line, I am able to create new file using: touch </p> <p>Thank you very much for your help Howard</p>
0debug
Windows Batch FOR loop : <p>I'm trying to write a batch script that would loop through each line from the output of another command. I am having trouble getting it to work. This is one example:</p> <blockquote> <p>FOR %i in ('wmic useraccount get name') DO ECHO %i</p> </blockquote> <p>The command <strong>wmic useraccount get name</strong> gives me a list of users each on a separate line. What am I doing wrong? Thanks.</p>
0debug
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
0debug
static inline int ape_decode_value_3900(APEContext *ctx, APERice *rice) { unsigned int x, overflow; int tmpk; overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970); if (overflow == (MODEL_ELEMENTS - 1)) { tmpk = range_decode_bits(ctx, 5); overflow = 0; } else tmpk = (rice->k < 1) ? 0 : rice->k - 1; if (tmpk <= 16 || ctx->fileversion < 3910) { if (tmpk > 23) { av_log(ctx->avctx, AV_LOG_ERROR, "Too many bits: %d\n", tmpk); return AVERROR_INVALIDDATA; } x = range_decode_bits(ctx, tmpk); } else if (tmpk <= 32) { x = range_decode_bits(ctx, 16); x |= (range_decode_bits(ctx, tmpk - 16) << 16); } else { av_log(ctx->avctx, AV_LOG_ERROR, "Too many bits: %d\n", tmpk); return AVERROR_INVALIDDATA; } x += overflow << tmpk; update_rice(rice, x); if (x & 1) return (x >> 1) + 1; else return -(x >> 1); }
1threat
how to let the h and cpp talk to each other? : I am trying to Creating and Using a Static Library using the official examples https://msdn.microsoft.com/en-us/library/ms235627.aspx but i find the cpp file just can not get connected with the class definitions in the h file. I get the error messages: ...is not a class or namespace everywhere? Could you help me with this? this is the c file #include "MathFuncsLib.h" #include "stdafx.h" #include <stdexcept> using namespace std; namespace MathFuncs { double MyMathFuncs::Add(double a, double b) { return a + b; } double MyMathFuncs::Subtract(double a, double b) { return a - b; } double MyMathFuncs::Multiply(double a, double b) { return a * b; } double MyMathFuncs::Divide(double a, double b) { return a / b; } } this is the h file #pragma once namespace MathFuncs { class MyMathFuncs { public: // Returns a + b static double Add(double a, double b); // Returns a - b static double Subtract(double a, double b); // Returns a * b static double Multiply(double a, double b); // Returns a / b static double Divide(double a, double b); }; }
0debug
Update UIlable automatically : I'm trying to update an UILable based on the numbers inserted in an UITextField. UITextField, lets say 45 was inserted A function that does (45 * 2) UILable will now becomes 90 I am having trouble exporting values from the function and updating the UILable. Thanks for the help
0debug
Error handling with Node.js, Async and Formidable : <p>In the following snippet I would like to validate the fields in the first async method. </p> <p>If they are not valid I would like to return an error to the user immediately. </p> <p>How do I do that?</p> <pre><code>var form = new formidable.IncomingForm(); async1.series([ function (callback) { form.parse(req); form.on('field', function (name, val) { // Get the fields }); form.on('fileBegin', function (name, file) { if (file.name !== "") { file.path = __dirname + '/upload/' + file.name; } }); callback(); }, function (callback) { form.on('file', function (name, file) { try { // Do something with the file using the fields retrieved from first async method } catch (err) { logger.info(err); } }); callback(); } ], function (err) { //the upload failed, there is nothing we can do, send a 500 if (err === "uploadFailed") { return res.send(500); } if (err) { throw err; } return res.status(200); }); </code></pre>
0debug
Error when use Pointer-to-Pointer : <p>I am using Visual Studio 2013. Today, i did some research on pointer, i found error when try to point to a pointer from the orther. Error occured at this line: char *cPP = &cP; when try to read address of cP and put on cPP. Visual Studio announced:</p> <pre><code>a value of type "char **" cannot be used to initialize an entity of type "char *" </code></pre> <p>Can you explain this?</p> <h2>And how can i fix this error?</h2> <pre><code>#define stop __asm nop int main() { char a = 'A'; char *cP = &amp;a; char *cPP = &amp;cP; stop return 0; } </code></pre>
0debug
Using StackExchange.Redis in a ASP.NET Core Controller : <p>I'd like to use Redis features such as bitfields and hashfields from an MVC controller. I understand there's <a href="https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed" rel="noreferrer">built in caching support</a> in ASP.NET core but this only supports basic GET and SET commands, not the commands that I need in my application. I know how to use StackExchange.Redis from a normal (eg. console) application, but I'm not sure how to set it up in an ASP site.</p> <p>Where should I put all the connection initialisation code so that I can have access to it afterwards from a controller? Is this something I would use dependency injection for?</p>
0debug
How to compare words in a string/python dictionary? : <p>I have a dictionary item in the form</p> <pre><code> {"value for money": ["rescheduled", "cost", "low", "high", "simplicity", "booking", "price-performance", "satisfied", "satisfaction", "pricing", "prices"]} </code></pre> <p>I need to check whether the a string like "I love simplicity" contains any word from this dictionary.</p> <p>Can't figure how to define the code for this.</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
how to remove properties via mapped type in TypeScript : <p>Here is the code </p> <pre><code>class A { x = 0; y = 0; visible = false; render() { } } type RemoveProperties&lt;T&gt; = { readonly [P in keyof T]: T[P] extends Function ? T[P] : never//; }; var a = new A() as RemoveProperties&lt;A&gt; a.visible // never a.render() // ok! </code></pre> <p>I want to remove " visible / x / y " properties via RemoveProperties ,but I can only replace it with never</p>
0debug
static abi_long do_connect(int sockfd, abi_ulong target_addr, socklen_t addrlen) { void *addr; if (addrlen < 0) return -TARGET_EINVAL; addr = alloca(addrlen); target_to_host_sockaddr(addr, target_addr, addrlen); return get_errno(connect(sockfd, addr, addrlen)); }
1threat
How to implement these github examples? : <p>All,</p> <p>I am new to github and its a bit confusing to say the least. This link shows a bunch of animated menu styles, but I have no clue how to use their code on my sites. For example the 10th one down "Adrian". Where would I get all the code I need? I just signed up for an account. Thanks </p> <p><a href="http://tympanus.net/Development/LineMenuStyles/" rel="nofollow">http://tympanus.net/Development/LineMenuStyles/</a></p>
0debug
Function in C programming xcode "C99" : <p>This is the first time I try to use a function in C. I have checked the internet and do not understand why my compiler (xcode) are complaining</p> <pre><code>#include &lt;stdio.h&gt; int upp2(int argc, const char * argv[]) { float kronor; float valutakurs = 0.1; float svar = 0; printf("Mata in antal svenska kronor: "); scanf("%f",&amp;kronor); svar = square(kronor, valutakurs); return 0; } float square(float x, float y){ float p ; p = x * x ; return ( p ) ; } </code></pre>
0debug
What's the best/proper way to set up my database : <p>I have a database, image below, and I feel that there must be an efficient way to add separate books for each child. For example... there may be 50 clubbers in the database. Each clubber will be in their own book and to make it simple, each book has 10 sections a clubber must complete. I was thinking of making a table for each child with the 10 sections, but that would end up with over 50 tables in my database. I also thought of creating a table called book and just having that table contain the 10 sections, but the problem with that is each child may be in one of 8 different books. So one table called book wouldn't work either. </p> <p>Does anyone have a good suggestion on how to set this up in the database? My ultimate goal is to have each child linked to one of the 8 books that is available. Then the database will track which section each child is in for their certain book. So... today clubber A could finish section 1 and 2 in book 1, but clubber B might only finish section 1 in book 2. I'm wanting to pull this information from the database to see where each clubber is in their books... but... I first need to set the database up correctly.</p> <p>Should I create 8 separate tables for each of the books and have the table data be section 1... section 2...? Or should I create one table and list 8 books in it and then link that to another table that has the section info? Or is there an even better way?</p> <p>Thanks for any help<img src="https://i.stack.imgur.com/oem72.jpg" alt="![mydatabase"> </p>
0debug
Python .append not working when found within a for, if else : <p>Working on a list creator to generate assignments for a sound crew. Creating 4 lists and adding people to the various lists based on the training they have recieved and the jobs they are capable of doing. I have one base list with all of the people included. The .append works for that list, but for all lists with conditions the names are not appending.</p> <p>I tried changing my for from for str in addto to other things but nothing has worked so far.</p> <pre><code>my_list = [] stage_list = [] mic_list = [] all_list = [] def addto_list(): addto = input() for str in addto: input("Can he do stage?(y/n): ") if input == "y": stage_list.append(addto) else: break for str in addto: input("Can he do mic?(y/n): ") if input == "y": mic_list.append(addto) else: break for str in addto: input("Can he do sound?(y/n): ") if input == "y": all_list.append(addto) else: break my_list.append(addto) </code></pre> <p>The results I want are when I answer y for any of the conditional statements then the name append to the list. But when I do that the list still appears blank. For example I run the code</p> <pre><code>addto_list() Input: Jack Can he do stage: y can he do mic: y can he do sound: y print(my_list) return: Jack print(mic_list) return: [] blank when it should say Jack </code></pre>
0debug
static int rv10_decode_packet(AVCodecContext *avctx, uint8_t *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int i, mb_count, mb_pos, left; init_get_bits(&s->gb, buf, buf_size*8); #if 0 for(i=0; i<buf_size*8 && i<200; i++) printf("%d", get_bits1(&s->gb)); printf("\n"); return 0; #endif if(s->codec_id ==CODEC_ID_RV10) mb_count = rv10_decode_picture_header(s); else mb_count = rv20_decode_picture_header(s); if (mb_count < 0) { av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n"); return -1; } if (s->mb_x >= s->mb_width || s->mb_y >= s->mb_height) { av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y); return -1; } mb_pos = s->mb_y * s->mb_width + s->mb_x; left = s->mb_width * s->mb_height - mb_pos; if (mb_count > left) { av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n"); return -1; } if (s->mb_x == 0 && s->mb_y == 0) { if(MPV_frame_start(s, avctx) < 0) return -1; } #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif if(s->codec_id== CODEC_ID_RV10){ if(s->mb_y==0) s->first_slice_line=1; }else{ s->first_slice_line=1; s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y; } if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; ff_set_qscale(s, s->qscale); s->rv10_first_dc_coded[0] = 0; s->rv10_first_dc_coded[1] = 0; s->rv10_first_dc_coded[2] = 0; s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; ff_init_block_index(s); for(i=0;i<mb_count;i++) { int ret; ff_update_block_index(s); #ifdef DEBUG printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); #endif s->dsp.clear_blocks(s->block[0]); s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; ret=ff_h263_decode_mb(s, s->block); if (ret == SLICE_ERROR) { av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); return -1; } ff_h263_update_motion_val(s); MPV_decode_mb(s, s->block); if(s->loop_filter) ff_h263_loop_filter(s); if (++s->mb_x == s->mb_width) { s->mb_x = 0; s->mb_y++; ff_init_block_index(s); } if(s->mb_x == s->resync_mb_x) s->first_slice_line=0; if(ret == SLICE_END) break; } return buf_size; }
1threat
static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, Error **errp) { NBDClient *client = req->client; int valid_flags; g_assert(qemu_in_coroutine()); assert(client->recv_coroutine == qemu_coroutine_self()); if (nbd_receive_request(client->ioc, request, errp) < 0) { return -EIO; } trace_nbd_co_receive_request_decode_type(request->handle, request->type, nbd_cmd_lookup(request->type)); if (request->type != NBD_CMD_WRITE) { req->complete = true; } if (request->type == NBD_CMD_DISC) { return -EIO; } if ((request->from + request->len) < request->from) { error_setg(errp, "integer overflow detected, you're probably being attacked"); return -EINVAL; } if (request->type == NBD_CMD_READ || request->type == NBD_CMD_WRITE) { if (request->len > NBD_MAX_BUFFER_SIZE) { error_setg(errp, "len (%" PRIu32" ) is larger than max len (%u)", request->len, NBD_MAX_BUFFER_SIZE); return -EINVAL; } req->data = blk_try_blockalign(client->exp->blk, request->len); if (req->data == NULL) { error_setg(errp, "No memory"); return -ENOMEM; } } if (request->type == NBD_CMD_WRITE) { if (nbd_read(client->ioc, req->data, request->len, errp) < 0) { error_prepend(errp, "reading from socket failed: "); return -EIO; } req->complete = true; trace_nbd_co_receive_request_payload_received(request->handle, request->len); } if (request->from + request->len > client->exp->size) { error_setg(errp, "operation past EOF; From: %" PRIu64 ", Len: %" PRIu32 ", Size: %" PRIu64, request->from, request->len, (uint64_t)client->exp->size); return request->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL; } valid_flags = NBD_CMD_FLAG_FUA; if (request->type == NBD_CMD_READ && client->structured_reply) { valid_flags |= NBD_CMD_FLAG_DF; } else if (request->type == NBD_CMD_WRITE_ZEROES) { valid_flags |= NBD_CMD_FLAG_NO_HOLE; } if (request->flags & ~valid_flags) { error_setg(errp, "unsupported flags for command %s (got 0x%x)", nbd_cmd_lookup(request->type), request->flags); return -EINVAL; } return 0; }
1threat
MvcBuildViews true causes "'/temp' is not a valid IIS application" error : <p>After setting <code>MvcBuildViews</code> to <code>true</code> in my <code>.csproj</code> file in order to have the views compile during build, I get the following error:</p> <blockquote> <p>'/temp' is not a valid IIS application</p> </blockquote> <p>I presume that the '/temp' that this is referring to is the path where the views will be compiled. Here's the relevant section in the <code>.csproj</code> file:</p> <pre><code>&lt;Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"&gt; &lt;AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /&gt; &lt;/Target&gt; </code></pre> <p>I use full IIS to serve up this MVC 5 website on my local machine (haven't tried this on a remote server yet). Do I need to set something up in IIS to make <code>MvcBuildViews</code> work correctly?</p>
0debug
bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) { int i; for (i = 0; i < qiov->niov; i++) { if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) { return false; } if (qiov->iov[i].iov_len % bs->buffer_alignment) { return false; } } return true; }
1threat
int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size) { AVPacketSideData *sd, *tmp; int i; for (i = 0; i < st->nb_side_data; i++) { sd = &st->side_data[i]; if (sd->type == type) { av_freep(&sd->data); sd->data = data; sd->size = size; return 0; } } tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) { return AVERROR(ENOMEM); } st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = type; sd->data = data; sd->size = size; return 0; }
1threat
static int dx2_decode_slice_rgb(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8]) { int x, y; int width = frame->width; int stride = frame->linesize[0]; uint8_t *dst = frame->data[0] + stride * line; for (y = 0; y < left && get_bits_left(gb) > 16; y++) { for (x = 0; x < width; x++) { dst[x * 3 + 0] = decode_sym(gb, lru[0]); dst[x * 3 + 1] = decode_sym(gb, lru[1]); dst[x * 3 + 2] = decode_sym(gb, lru[2]); } dst += stride; } return y; }
1threat
MemoryRegionSection memory_region_find(MemoryRegion *address_space, hwaddr addr, uint64_t size) { AddressSpace *as = memory_region_to_address_space(address_space); AddrRange range = addrrange_make(int128_make64(addr), int128_make64(size)); FlatRange *fr = address_space_lookup(as, range); MemoryRegionSection ret = { .mr = NULL, .size = 0 }; if (!fr) { return ret; } while (fr > as->current_map->ranges && addrrange_intersects(fr[-1].addr, range)) { --fr; } ret.mr = fr->mr; range = addrrange_intersection(range, fr->addr); ret.offset_within_region = fr->offset_in_region; ret.offset_within_region += int128_get64(int128_sub(range.start, fr->addr.start)); ret.size = int128_get64(range.size); ret.offset_within_address_space = int128_get64(range.start); ret.readonly = fr->readonly; return ret; }
1threat
static void dump_aml_files(test_data *data, bool rebuild) { AcpiSdtTable *sdt; GError *error = NULL; gchar *aml_file = NULL; gint fd; ssize_t ret; int i; for (i = 0; i < data->tables->len; ++i) { const char *ext = data->variant ? data->variant : ""; sdt = &g_array_index(data->tables, AcpiSdtTable, i); g_assert(sdt->aml); if (rebuild) { uint32_t signature = cpu_to_le32(sdt->header.signature); aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, (gchar *)&signature, ext); fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); } else { fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); g_assert_no_error(error); } g_assert(fd >= 0); ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); g_assert(ret == sizeof(AcpiTableHeader)); ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); g_assert(ret == sdt->aml_len); close(fd); if (aml_file) { g_free(aml_file); } } }
1threat
in python3: most efficient way to modify each element in multiple lists together? : Let's say I have 3 lists ``` a = [1.12, 2.23, 3.34] b = [2.12, 3.23, 4.34] c = [3.12, 4.23, 5.34] ``` my goal is to round the numbers down to 1 decimal. so I have this custom function: ``` import math def round_down(n, decimals=0): multiplier = 10 ** decimals return math.floor(n * multiplier) / multiplier ``` May I ask what is the most efficient way of operating on each element in each object? In this easy example I could write a loop for each of the 3 objects, such as: ``` for i in np.range(len(a)): a[i] = round_down(a[i], decimals=1) ``` However, in my work, I have many more lists of various lengths and I really don't want to code them one by one. Is there a way to iterate through a list of objects? or process them in parallel? Thank you so much! Jerry
0debug
Angular UI modal with Bootstrap 4 : <p>Bootstrap 3 modal works fine: <a href="https://jsfiddle.net/qLy7gk3f/4/" rel="noreferrer">https://jsfiddle.net/qLy7gk3f/4/</a></p> <p>But Bootstrap 4 modal doesn't: <a href="https://jsfiddle.net/qLy7gk3f/3/" rel="noreferrer">https://jsfiddle.net/qLy7gk3f/3/</a></p> <p>The code is identical:</p> <pre><code>$scope.click = function() { $uibModal.open({ templateUrl: "modal.html", controller: "modal", scope: $scope }); } </code></pre> <p>How can I get AngularUI modals to work with Bootstrap 4?</p>
0debug
static always_inline target_phys_addr_t get_pgaddr (target_phys_addr_t sdr1, int sdr_sh, target_phys_addr_t hash, target_phys_addr_t mask) { return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask); }
1threat
static void gen_mtc0(DisasContext *ctx, TCGv arg, int reg, int sel) { const char *rn = "invalid"; if (sel != 0) check_insn(ctx, ISA_MIPS32); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } switch (reg) { case 0: switch (sel) { case 0: gen_helper_mtc0_index(cpu_env, arg); rn = "Index"; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_mvpcontrol(cpu_env, arg); rn = "MVPControl"; CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf0"; CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf1"; CP0_CHECK(ctx->vp); rn = "VPControl"; default: goto cp0_unimplemented; } case 1: switch (sel) { case 0: rn = "Random"; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpecontrol(cpu_env, arg); rn = "VPEControl"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf0(cpu_env, arg); rn = "VPEConf0"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf1(cpu_env, arg); rn = "VPEConf1"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_yqmask(cpu_env, arg); rn = "YQMask"; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule)); rn = "VPESchedule"; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack)); rn = "VPEScheFBack"; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeopt(cpu_env, arg); rn = "VPEOpt"; default: goto cp0_unimplemented; } switch (sel) { case 0: gen_helper_mtc0_entrylo0(cpu_env, arg); rn = "EntryLo0"; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcstatus(cpu_env, arg); rn = "TCStatus"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcbind(cpu_env, arg); rn = "TCBind"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcrestart(cpu_env, arg); rn = "TCRestart"; CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tchalt(cpu_env, arg); rn = "TCHalt"; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tccontext(cpu_env, arg); rn = "TCContext"; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschedule(cpu_env, arg); rn = "TCSchedule"; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschefback(cpu_env, arg); rn = "TCScheFBack"; default: goto cp0_unimplemented; } switch (sel) { case 0: gen_helper_mtc0_entrylo1(cpu_env, arg); rn = "EntryLo1"; case 1: CP0_CHECK(ctx->vp); rn = "GlobalNumber"; default: goto cp0_unimplemented; } switch (sel) { case 0: gen_helper_mtc0_context(cpu_env, arg); rn = "Context"; case 1: rn = "ContextConfig"; goto cp0_unimplemented; CP0_CHECK(ctx->ulri); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); rn = "UserLocal"; default: goto cp0_unimplemented; } case 5: switch (sel) { case 0: gen_helper_mtc0_pagemask(cpu_env, arg); rn = "PageMask"; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_pagegrain(cpu_env, arg); rn = "PageGrain"; ctx->bstate = BS_STOP; default: goto cp0_unimplemented; } case 6: switch (sel) { case 0: gen_helper_mtc0_wired(cpu_env, arg); rn = "Wired"; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf0(cpu_env, arg); rn = "SRSConf0"; check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf1(cpu_env, arg); rn = "SRSConf1"; check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf2(cpu_env, arg); rn = "SRSConf2"; check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf3(cpu_env, arg); rn = "SRSConf3"; case 5: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf4(cpu_env, arg); rn = "SRSConf4"; default: goto cp0_unimplemented; } case 7: switch (sel) { case 0: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_hwrena(cpu_env, arg); ctx->bstate = BS_STOP; rn = "HWREna"; default: goto cp0_unimplemented; } case 8: switch (sel) { case 0: rn = "BadVAddr"; case 1: rn = "BadInstr"; rn = "BadInstrP"; default: goto cp0_unimplemented; } case 9: switch (sel) { case 0: gen_helper_mtc0_count(cpu_env, arg); rn = "Count"; default: goto cp0_unimplemented; } case 10: switch (sel) { case 0: gen_helper_mtc0_entryhi(cpu_env, arg); rn = "EntryHi"; default: goto cp0_unimplemented; } case 11: switch (sel) { case 0: gen_helper_mtc0_compare(cpu_env, arg); rn = "Compare"; default: goto cp0_unimplemented; } case 12: switch (sel) { case 0: save_cpu_state(ctx, 1); gen_helper_mtc0_status(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Status"; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_intctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "IntCtl"; check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "SRSCtl"; check_insn(ctx, ISA_MIPS32R2); gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap)); ctx->bstate = BS_STOP; rn = "SRSMap"; default: goto cp0_unimplemented; } case 13: switch (sel) { case 0: save_cpu_state(ctx, 1); gen_helper_mtc0_cause(cpu_env, arg); rn = "Cause"; default: goto cp0_unimplemented; } case 14: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC)); rn = "EPC"; default: goto cp0_unimplemented; } case 15: switch (sel) { case 0: rn = "PRid"; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_ebase(cpu_env, arg); rn = "EBase"; default: goto cp0_unimplemented; } case 16: switch (sel) { case 0: gen_helper_mtc0_config0(cpu_env, arg); rn = "Config"; ctx->bstate = BS_STOP; case 1: rn = "Config1"; gen_helper_mtc0_config2(cpu_env, arg); rn = "Config2"; ctx->bstate = BS_STOP; gen_helper_mtc0_config3(cpu_env, arg); rn = "Config3"; ctx->bstate = BS_STOP; gen_helper_mtc0_config4(cpu_env, arg); rn = "Config4"; ctx->bstate = BS_STOP; case 5: gen_helper_mtc0_config5(cpu_env, arg); rn = "Config5"; ctx->bstate = BS_STOP; case 6: rn = "Config6"; case 7: rn = "Config7"; default: rn = "Invalid config selector"; goto cp0_unimplemented; } case 17: switch (sel) { case 0: gen_helper_mtc0_lladdr(cpu_env, arg); rn = "LLAddr"; case 1: CP0_CHECK(ctx->mrp); gen_helper_mtc0_maar(cpu_env, arg); rn = "MAAR"; CP0_CHECK(ctx->mrp); gen_helper_mtc0_maari(cpu_env, arg); rn = "MAARI"; default: goto cp0_unimplemented; } case 18: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchlo, arg, sel); rn = "WatchLo"; default: goto cp0_unimplemented; } case 19: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchhi, arg, sel); rn = "WatchHi"; default: goto cp0_unimplemented; } case 20: switch (sel) { case 0: #if defined(TARGET_MIPS64) check_insn(ctx, ISA_MIPS3); gen_helper_mtc0_xcontext(cpu_env, arg); rn = "XContext"; #endif default: goto cp0_unimplemented; } case 21: CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6)); switch (sel) { case 0: gen_helper_mtc0_framemask(cpu_env, arg); rn = "Framemask"; default: goto cp0_unimplemented; } case 22: rn = "Diagnostic"; case 23: switch (sel) { case 0: gen_helper_mtc0_debug(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Debug"; case 1: rn = "TraceControl"; ctx->bstate = BS_STOP; goto cp0_unimplemented; rn = "TraceControl2"; ctx->bstate = BS_STOP; goto cp0_unimplemented; ctx->bstate = BS_STOP; rn = "UserTraceData"; ctx->bstate = BS_STOP; goto cp0_unimplemented; ctx->bstate = BS_STOP; rn = "TraceBPC"; goto cp0_unimplemented; default: goto cp0_unimplemented; } case 24: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC)); rn = "DEPC"; default: goto cp0_unimplemented; } case 25: switch (sel) { case 0: gen_helper_mtc0_performance0(cpu_env, arg); rn = "Performance0"; case 1: rn = "Performance1"; goto cp0_unimplemented; rn = "Performance2"; goto cp0_unimplemented; rn = "Performance3"; goto cp0_unimplemented; 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; } case 26: switch (sel) { case 0: gen_helper_mtc0_errctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "ErrCtl"; default: goto cp0_unimplemented; } case 27: switch (sel) { case 0 ... 3: rn = "CacheErr"; default: goto cp0_unimplemented; } case 28: switch (sel) { case 0: case 6: gen_helper_mtc0_taglo(cpu_env, arg); rn = "TagLo"; case 1: case 5: case 7: gen_helper_mtc0_datalo(cpu_env, arg); rn = "DataLo"; default: goto cp0_unimplemented; } case 29: switch (sel) { case 0: case 6: gen_helper_mtc0_taghi(cpu_env, arg); rn = "TagHi"; case 1: case 5: case 7: gen_helper_mtc0_datahi(cpu_env, arg); rn = "DataHi"; default: rn = "invalid sel"; goto cp0_unimplemented; } case 30: switch (sel) { case 0: tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC)); rn = "ErrorEPC"; default: goto cp0_unimplemented; } case 31: switch (sel) { case 0: gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE)); rn = "DESAVE"; case 2 ... 7: CP0_CHECK(ctx->kscrexist & (1 << sel)); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_KScratch[sel-2])); rn = "KScratch"; default: goto cp0_unimplemented; } ctx->bstate = BS_STOP; default: goto cp0_unimplemented; } trace_mips_translate_c0("mtc0", rn, reg, sel); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); ctx->bstate = BS_STOP; } return; cp0_unimplemented: qemu_log_mask(LOG_UNIMP, "mtc0 %s (reg %d sel %d)\n", rn, reg, sel); }
1threat
Show hiden table on parent row click : I have rows but one row one row is hidden and I need to show them when I click on parent row link .btn-link ... I have html: <tr> <td><a href="#" class="btn-link"> <i class="fa fa-plus-circle" aria-hidden="true"></i> Details </a> </td> <td> </td> <td><span class="text-muted"><i class="fa fa-clock-o"></i> 2017-01-04</span></td> <td>£46.00</td> <td class="text-center"> <div class="label label-table label-success">Paid</div> </td> </tr> <tr class="showDetails"> <td colspan="20"> <table id="" class="table-responsive" cellspacing="0" width="100%"> <thead> <tr> <th>Name</th> <th>Price</th> <th>Recipient</th> <th>Expiry</th> <th>Status</th> </tr> </thead> <tbody> <tr> <td class="col-lg-6"> <p class="detailCell">Three Course Italian Meal for Two with Prosecco at Michelin Recommended Mele e Pere, Soho</p> </td> <td>46.00</td> <td>No recipient</td> <td>Mar 11, 2017</td> <td><span class="label label-warning">Paid</span></td> </tr> </tbody> </table> </td> </tr> so when I click on 'details' - class="btn-link" I need to show the next row who has class "showDetails" and who is hidden: so I write: $( ".btn-link" ).click(function() { $(this).closest('tr.showDetails').show(); }); of cource: .showDetails {display:none;} On click nothing happend. WHy my code wont work and please help me to solve this. Also how to toggle on next click so on one click to open .showDetails row on next to hide that row...
0debug
static void test_hash_digest(void) { size_t i; g_assert(qcrypto_init(NULL) == 0); for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) { int ret; char *digest; size_t digestsize; digestsize = qcrypto_hash_digest_len(i); g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i])); ret = qcrypto_hash_digest(i, INPUT_TEXT, strlen(INPUT_TEXT), &digest, NULL); g_assert(ret == 0); g_assert(g_str_equal(digest, expected_outputs[i])); g_free(digest); } }
1threat
uint64_t blk_mig_bytes_remaining(void) { return blk_mig_bytes_total() - blk_mig_bytes_transferred(); }
1threat
How to create a Image Dataset just like MNIST dataset? : <p>I have 10000 BMP images of some handwritten digits. If i want to feed the datas to a neural network what do i need to do ? For MNIST dataset i just had to write</p> <pre><code>(X_train, y_train), (X_test, y_test) = mnist.load_data() </code></pre> <p>I am using Keras library in python . How can i create such dataset ?</p>
0debug
Is there an actual 8-bit integer data type in C++ : <p>In c++, specifically the cstdint header file, there are types for 8-bit integers which turn out to be of the char data type with a typedef. Could anyone suggest an actual 8-bit integer type?</p>
0debug
Jquery ajax POST method not working : I am trying to execute the ajax operation. the call is working fine but the problem I am having is that I am getting an empty string as a response. there is no error in the console. all I get is an empty string. Even when I change the dataType to JSON, I still get the same response. Javascript Code: $.ajax({ url: "data/saveCart.php", method: "POST", data: { cartItem:item }, dataType: "text", success: function(data){ console.log(data); } }); PHP code: if(isset($_POST['cartItem'])) { echo "AJAX successful"; } else { echo "AJAX failed"; }
0debug
Bash: How to leave a process running even after it's user logs out : <p>The only way i've heard of is using the cron, but id rather do it ad hoc. Is there another way in bash?</p>
0debug
expand an array of arrays to an array of objects : <p>I have an array of arrays and I need to make the first member in each nested array into a key, and make an array of objects from the rest. Where each odd member after the first is key and an even member is value.</p> <p>See the example: note that the original nested arrays always have an odd number or members (or even after you remove the first member to make it our new key) </p> <pre><code>//ORIGINAL var arr = [ [first, a, b, c, d],[second, e, f, g, h, i, j],[third,...] ] // DESIRED RESULT var obj = [ {first: [{a:b}, {c:d}]}, {second: [{e:f}, {g:h}, {i:j}]}, {third: ...} ] </code></pre>
0debug
How to use requestReview (SKStore​Review​Controller) to show review popup in the current viewController after a random period of time : <p>I've read about this new feature available in iOS 10.3 and thought it will be more flexible and out of the box. But after I read the <a href="https://developer.apple.com/reference/storekit/skstorereviewcontroller?language=objc" rel="noreferrer">docs</a> I found out that you need to decide the time to show it and the viewController who calls it. Is there any way I can make it trigger after a random period of time in any viewController is showing at that moment? </p>
0debug
Configure different timeouts in gunicorn for different endpoints? : <p>Gunicorn allows configuring a timeout for requests, as demonstrated in their documentation below. This seems to be a global configuration for the entire application.</p> <p>Is it possible to configure different timeouts for different endpoints? Perhaps overriding the default timeout on url endpoints that are known to take a long time?</p> <p><a href="http://docs.gunicorn.org/en/stable/settings.html#timeout" rel="noreferrer">http://docs.gunicorn.org/en/stable/settings.html#timeout</a></p> <blockquote> <p>timeout</p> <p>-t INT, --timeout INT</p> <p>30</p> <p>Workers silent for more than this many seconds are killed and restarted.</p> <p>Generally set to thirty seconds. Only set this noticeably higher if you’re sure of the repercussions for sync workers. For the non sync workers it just means that the worker process is still communicating and is not tied to the length of time required to handle a single request.</p> </blockquote>
0debug
Sammy.js cache and scroll position when going back in history : <p>I don't know if anyone is still using Sammy.js, but I found it perfectly suits my needs for a lightweight routing and templating library. If anyone has other ideas, please let me know.</p> <p>My problem is that when I have a long page and I scroll down, click on a link on this page and go back, the whole page is reloaded (in Sammy, the GET route is called) and it jumps to the top of the page.</p> <p>My question is: Is there a way to have Sammy cache the page and maintain the scroll position when going back in the history?</p> <p>Thanks in advance.</p>
0debug
loan payment project in Python : I am learning Python and am stuck. I am trying to find the loan payment amount. I currently have: def myMonthlyPayment(Principal, annual_r, n): years = n r = ( annual_r / 100 ) / 12 MonthlyPayment = (Principal * (r * ( 1 + r ) ** years / (( 1 + r ) ** (years - 1)))) return MonthlyPayment n=(input('Please enter number of years of loan')) annual_r=(input('Please enter the interest rate')) Principal=(input('Please enter the amount of loan')) However, when I run, I am off by small amount. If anyone can point to my error, it would be great. I am using Python 3.4.
0debug
static void spatial_compose97i(IDWTELEM *buffer, int width, int height, int stride){ dwt_compose_t cs; spatial_compose97i_init(&cs, buffer, height, stride); while(cs.y <= height) spatial_compose97i_dy(&cs, buffer, width, height, stride); }
1threat
Check the User Whether Exist in Azure AD from WPF application : <p>I have a WPF application and its authentication is AzureAD. If any new user comes then first we will add that user in Azure AD and after that we will add the same user to our WPF application. While adding that user to WPF we need to verify that user is present in Azure</p> <p>Steps 1. Network Admin creating a user in Azure AD 2. Our project Admin add that user to our client in Azure 3. Project Admin login to our WPF application using azure authentication and adding this user 4. At that time we need to recheck the new user is present in azureAD.</p> <p>It means project admin login to WPF application using Azure authentication [His userid, ticket, clientid etc are available] and he trying to check a user present it Azure AD [New users name is available, but password will not know by this Admin]. </p> <p>Please help me to write a c# code for solving this problem.</p>
0debug
I want to write a function that prints a sum : I just started python a few weeks ago and I want to write a function that opens a file, counts and adds up the characters in each line and prints that those equal the total number of characters in the file. For example, given a file test1.txt: lineLengths('test1.txt') The output should be: 15+20+23+24+0=82 (+0 optional) This is what I have so far: def lineLengths(filename): f=open(filename) lines=f.readlines() f.close() answer=[] for aline in lines: count=len(aline) It does what I want it to do, but I don't know how include all of the numbers added together when I have the function print.
0debug
Use a different user.email and user.name for Git config based upon remote clone URL : <p>I configure my global <code>~/.gitconfig</code> properties <code>user.name</code> and <code>user.email</code> like this:</p> <p></p> <pre><code>git config --global user.email "mkobit@example.com" git config --global user.name "mkobit" </code></pre> <p>This is the default configuration I want for working on personal projects, open source stuff, etc.</p> <p>When I am working on a project from a specific domain, a corporate domain for example, I am configuring it for each repository when I clone it so that it uses a different <code>user.name</code>/<code>user.email</code>:</p> <pre><code>git clone ssh://git@git.mycorp.com:1234/groupA/projectA.git cd projectA git config user.email "mkobit@mycorp.com" git config user.name "m.kobit" </code></pre> <p>One decent option would be to setup an alias for cloning these kinds of repositories:</p> <pre><code>git config --global alias.clonecorp 'clone \ -c user.name="m.kobit" -c user.email="mkobit@mycorp.com"' git clonecorp ssh://git@git.mycorp.com:1234/groupA/projectA.git </code></pre> <p>Both of these can be error prone because they both depend on me being smart and following the right steps. Evidence shows that this is near-guaranteed for me to screw-up sometime.</p> <p>Is there a way to configure Git such that repositories from a certain domain (the <code>mycorp.com</code> in this example) will be configured a certain way? </p>
0debug
void qio_channel_socket_listen_async(QIOChannelSocket *ioc, SocketAddress *addr, QIOTaskFunc callback, gpointer opaque, GDestroyNotify destroy) { QIOTask *task = qio_task_new( OBJECT(ioc), callback, opaque, destroy); SocketAddress *addrCopy; addrCopy = QAPI_CLONE(SocketAddress, addr); trace_qio_channel_socket_listen_async(ioc, addr); qio_task_run_in_thread(task, qio_channel_socket_listen_worker, addrCopy, (GDestroyNotify)qapi_free_SocketAddress); }
1threat
what is the $row variable in php? and whats the duty of $row variable in php? : function getCats() { global $con; $get_cats = "select * from categories"; //select from database $run_cats = mysqli_query($con, $get_cats); // while($row_cats = mysqli_fetch_array($run_cats)) { $cat_id = $row_cats['cat_id']; $cat_title = $row_cats['cat_title']; echo"<li><a href='#'>$cat_title</a></li>"; } }
0debug
Formatting date from JSON response - only shows January? : <p>I am trying to get the right date to display but no matter what I do, or the date, it changes the month to January. What am I doing wrong?</p> <pre><code> private static String formatDate(String dateFormat) { String jsonDate = "yyyy-mm-dd'T'HH:mm:ss'Z'"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(jsonDate, Locale.getDefault()); try { Date parsedDate = simpleDateFormat.parse(dateFormat); String parsedDatePattern = "MM dd y"; SimpleDateFormat formatJsonDate = new SimpleDateFormat(parsedDatePattern, Locale.getDefault()); return formatJsonDate.format(parsedDate); } catch (ParseException e) { Log.e(LOG_TAG, "~*&amp;~*&amp;~*&amp;Error parsing JSON date: ", e); return ""; } } </code></pre>
0debug
PHP & HTML - echo li tag without break line : <p>i have this code:</p> <pre><code> &lt;ol&gt; &lt;?php foreach ($articles as $article) { ?&gt; &lt;li&gt; &lt;img src="public_html/images/example.jpg" height="250" width="250"&gt; &lt;br /&gt; &lt;a href="public_html/article.php?id=&lt;?php echo $article['article_id'];?&gt;"&gt; &lt;?php echo $article['article_title'];?&gt; &lt;/a&gt; - &lt;small&gt; posted &lt;?php echo date('l jS', $article['article_timestamp'])?&gt; &lt;/small&gt; &lt;/li&gt; &lt;?php } ?&gt; &lt;/ol&gt; </code></pre> <p>now it's print my in this way: </p> <pre><code>img title img title ... </code></pre> <p>and i want it's print my like this: </p> <pre><code>img img img ... title title title </code></pre> <p>i try to break line or use in div tag but it's don't work. how can I do this?</p> <p>thank's</p>
0debug
Event Handlers in React Stateless Components : <p>Trying to figure out an optimal way to create event handlers in React stateless components. I could do something like this:</p> <pre><code>const myComponent = (props) =&gt; { const myHandler = (e) =&gt; props.dispatch(something()); return ( &lt;button onClick={myHandler}&gt;Click Me&lt;/button&gt; ); } </code></pre> <p>The drawback here being that every time this component is rendered, a new "myHandler" function is created. Is there a better way to create event handlers in stateless components that can still access the component properties?</p>
0debug
raw_co_writev_flags(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags) { void *buf = NULL; BlockDriver *drv; QEMUIOVector local_qiov; int ret; if (bs->probed && sector_num == 0) { QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512); QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512); if (nb_sectors == 0) { return 0; } buf = qemu_try_blockalign(bs->file->bs, 512); if (!buf) { ret = -ENOMEM; goto fail; } ret = qemu_iovec_to_buf(qiov, 0, buf, 512); if (ret != 512) { ret = -EINVAL; goto fail; } drv = bdrv_probe_all(buf, 512, NULL); if (drv != bs->drv) { ret = -EPERM; goto fail; } qemu_iovec_init(&local_qiov, qiov->niov + 1); qemu_iovec_add(&local_qiov, buf, 512); qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512); qiov = &local_qiov; } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); ret = bdrv_co_pwritev(bs->file->bs, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE, qiov, flags); fail: if (qiov == &local_qiov) { qemu_iovec_destroy(&local_qiov); } qemu_vfree(buf); return ret; }
1threat
How to assign one variable value to new variable value in Javascirpt Angular2 : I trying to creating a new dynamic array. I assigned one dynamic variable value to another new variable and pushing new array. But updating last array variable value. How to do without setTimout(function()) Code ---- for(let i=0;i<allItems.length;i++){ let categories = allItems[i].categories; for(let j=0;j<categories.length;j++){ let categoryId = categories[j].id; //console.log("categories[j].id ", categoryId); allItems[i]['categoryId'] = categoryId; reitems.push(allItems[i]); } } My Json Value: -------------- [{ "itemName" : "3 SS Finish Baskets", "itemDesc" : "3 SS Finish Baskets", "itemId" : 1, "unitId" : 2, "categories" : [ { "id" : 1, "text" : "single room" }, { "id" : 2, "text" : "Foyer/Living" } ] }, { .... }] Output ------ [{ "itemName" : "3 SS Finish Baskets", "categoryId " : 2 }, { "itemName" : "3 SS Finish Baskets", "categoryId " : 2 }] Expecting Output ---------------- [{ "itemName" : "3 SS Finish Baskets", "categoryId " 1 }, { "itemName" : "3 SS Finish Baskets", "categoryId " 2 }]
0debug
syntax error, unexpected keyword_end, expecting ')' : <p>I have a script called <code>import.rb</code> which will import json content from url to drafts directory.</p> <pre><code>require 'fileutils' require 'json' # Load JSON data from source # (Assuming the data source is a json file on your file system) data = JSON.parse('https://script.google.com/macros/s/AKfycbyHFt1Yz96q91-D6eP4uWtRCcF_lzG2WM-sjrpZIr3s02HrICBQ/exec') # Proceed to create post files if the value array is not empty array = data["user"] if array &amp;&amp; !array.empty? # create the `_drafts` directory if it doesn't exist already drafts_dir = File.expand_path('./_drafts', __dir__) FileUtils.mkdir_p(posts_dir) unless Dir.exist?(drafts_dir) # iterate through the array and generate draft-files for each entry # where entry.first will be the "content" and entry.last the "title" array.each do |entry| File.open(File.join(drafts_dir, entry.last), 'wb') do |draft| draft.puts("---\n---\n\n#{entry.first}" end end end </code></pre> <p>When I run <code>ruby _scripts/import.rb</code> I get <code>_scripts/import.rb:20: syntax error, unexpected keyword_end, expecting ')' end</code> error. I changed line from recommended form to <code>data = JSON.parse('https://script.google.com/macros/s/AKfycbyHFt1Yz96q91-D6eP4uWtRCcF_lzG2WM-sjrpZIr3s02HrICBQ/exec')</code>. Original was <code>data = JSON.parse(File.read(your_json_source.json))</code>. Please assist me.</p>
0debug
minimac2_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistMinimac2State *s = opaque; trace_milkymist_minimac2_memory_read(addr, value); addr >>= 2; switch (addr) { case R_MDIO: { int mdio_di = (s->regs[R_MDIO] & MDIO_DI); s->regs[R_MDIO] = value; if (mdio_di) { s->regs[R_MDIO] |= mdio_di; } else { s->regs[R_MDIO] &= ~mdio_di; } minimac2_update_mdio(s); } break; case R_TXCOUNT: s->regs[addr] = value; if (value > 0) { minimac2_tx(s); } break; case R_STATE0: case R_STATE1: s->regs[addr] = value; update_rx_interrupt(s); break; case R_SETUP: case R_COUNT0: case R_COUNT1: s->regs[addr] = value; break; default: error_report("milkymist_minimac2: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
1threat
I need help for my form validation.I dont get error msgs all at once but appears only at the first text of name 'first name' : my Html code:<body> <img id="logo2" src="logo2.jpg"> <div id="request-container"> <h2>REQUEST A DEMO</h2> <div id="request"> <p>First Name *</p> <input id="1" type="text"> <span id="empty"></span> <p>Last Name *</p> <input id="2" type="text"> <span id="empty"></span> <p>Email *</p> <input id="3" type="email"> <span id="empty"></span> <p>Phone *</p> <input id="4" type="tel"> <span id="empty"></span> <p>Company Name *</p> <input id="5" type="text"> <span id="empty"></span> <p>Company Website *</p> <input id="6" type="email"> <span id="empty"></span> <p>Country *</p> <select id="country"> <option></option> <option>India</option> <option>USA</option> <option>Canade</option> <option>Australia</option> <option>China</option> <option>South Africa</option> <option>Russia</option> <option>Germany</option> </select> <span id="empty"></span> <div id="demo" onclick="return validateForm()">Schedule a Demo!</div> </div> </div> My Javascript code: <script type="text/javascript"> function validateForm() { var ok=true; var first=document.getElementById('1').value; var last=document.getElementById('2').value; var email=document.getElementById('3').value; var phone=document.getElementById('4').value; var company=document.getElementById('5').value; var website=document.getElementById('6').value; if (first == "" || first== null) { document.getElementById('empty').innerHTML="This field is required"; ok=false; } if (last == ""|| last== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (email == ""|| email== null) { document.getElementById('empty').innerHTML="This field is required"; ok=false; } if (phone == "" || phone==null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (company == ""|| company== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (website == ""|| website== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } return ok; } document.getElementById('demo').onclick = function () { validateForm(); } </script>
0debug
How to set "Selection" scope of search & replace in VS 2015 : <p>When I select a text block in text editor and open the search &amp; replace window (Ctrl+H), the search &amp; replace scope is set to "Selection" automatically in VS 2013 and the olders. </p> <p>In VS 2015, the scope is always set to "Current document".</p> <p>I've not found any information about this change. Does anybody know it is a bug or a feature (and can it be re-configured to the former behavior somehow)?</p>
0debug
How to specify the size of the icon on the Marker in Google Maps V2 Android : <p>In may app i use Map from Google Maps V2 and in this map i am trying to add markers each Marker with an icon, but the marker is taking the size of the icon which is making the icon looks flue. How can i specify the size of the marker in <strong>dp</strong> so that i can control how it looks like on the map</p>
0debug
Updating Visual Studio 2015 extensions end up disabled : <p>I have a machine with seems to repeat the following pattern with VS2015 (including all patches).</p> <ol> <li>Install an extension and it's fine, works perfectly.</li> <li>The developer of the extension releases a new update.</li> <li>Update extension, which means VS2015 needs to be restarted.</li> <li>Restart VS2015, look in the extensions and notice that the (updated) extension is now disabled.</li> </ol> <p>I've tried clearing the MEF cache, but that doesn't seem to help. The only way I've found to resolve this is to </p> <ol> <li>Delete the extension</li> <li>Restart VS2015</li> <li>Notice the extension is still there as disabled</li> <li>Delete it again</li> <li>Restart VS2015 (it's now removed)</li> <li>Install the extension from fresh from the Extension manager.</li> </ol> <p>I have another machine which doesn't experience this, and also the activity.xml file doesn't get updated unless there is a loading issue (where you get the error pop-up).</p> <p>The first time I noticed this was when I installed Mads Kristensen's Web extensions pack (which included all of his components) and caused all the pre-installed components to be disabled, so I uninstalled that and deleted all the components that were bundled under that, as it looked like it didn't detect the component were already there and created a duplicate behind the scenes, but now it seems this is happening for all 3rd party components.</p> <p>Has anyone got any ideas what I can try to resolve this and possibly what could be causing this?</p> <p>I'm hoping there is a file somewhere in the VS folder that is logging the issue.</p>
0debug
ssize_t iov_send_recv(int sockfd, struct iovec *iov, size_t offset, size_t bytes, bool do_sendv) { int iovlen; ssize_t ret; size_t diff; struct iovec *last_iov; iovlen = 1; last_iov = iov; bytes += offset; while (last_iov->iov_len < bytes) { bytes -= last_iov->iov_len; last_iov++; iovlen++; } diff = last_iov->iov_len - bytes; last_iov->iov_len -= diff; while (iov->iov_len <= offset) { offset -= iov->iov_len; iov++; iovlen--; } iov->iov_base = (char *) iov->iov_base + offset; iov->iov_len -= offset; { #if defined CONFIG_IOVEC && defined CONFIG_POSIX struct msghdr msg; memset(&msg, 0, sizeof(msg)); msg.msg_iov = iov; msg.msg_iovlen = iovlen; do { if (do_sendv) { ret = sendmsg(sockfd, &msg, 0); } else { ret = recvmsg(sockfd, &msg, 0); } } while (ret == -1 && errno == EINTR); #else struct iovec *p = iov; ret = 0; while (iovlen > 0) { int rc; if (do_sendv) { rc = send(sockfd, p->iov_base, p->iov_len, 0); } else { rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0); } if (rc == -1) { if (errno == EINTR) { continue; } if (ret == 0) { ret = -1; } break; } if (rc == 0) { break; } ret += rc; iovlen--, p++; } #endif } iov->iov_base = (char *) iov->iov_base - offset; iov->iov_len += offset; last_iov->iov_len += diff; return ret; }
1threat
Ajax success function not executing after getting response : <p>Following is my code:</p> <pre><code>$(".simpleCart_shelfItem button").click(function() { $(this).prop('disabled', true); $(this).addClass('disabled'); $(this).html("Adding &amp;nbsp;&amp;nbsp;&lt;i class='icon-spinner9 spin'&gt;&lt;/i&gt;"); var action = "add"; var queryString = "action="+action+"&amp;pid="+this.value; $.ajax({ url: "add_cart", data: queryString, type: "POST", success:function(data){ if(data == 1) { $(this).prop('disabled', false); $(this).removeClass('disabled'); $(this).html("Added In Cart"); } }, error:function (){} }); }); </code></pre> <p>I am having 6 products on a page. If a user click on Add To Cart button for a particular product then this code will execute and send request to server.</p> <p>The code is executing fine, i am even getting the response.</p> <p>Problem is this even after getting the response the success function is not executuing i.e this code is not executing..</p> <pre><code>$(this).prop('disabled', false); $(this).removeClass('disabled'); $(this).html("Added In Cart"); </code></pre> <p>It only executes the code which it was meant on entering the click function i.e this code:</p> <pre><code>$(this).prop('disabled', true); $(this).addClass('disabled'); $(this).html("Adding &amp;nbsp;&amp;nbsp;&lt;i class='icon-spinner9 spin'&gt;&lt;/i&gt;"); </code></pre> <p>And then it freezez on the above code.</p> <p>The success function is not being executed.</p>
0debug
sql server Same City and same Salary record Finding : This is my Qurey for finding matching Record But Same Salary Condition Not Working i i want Multiple Same City And Multiple Same Salary Record select distinct t1.Name,t1.Salary,t1.City from Test t1 , test t2 where t1.City=t2.City and t1.Salary<>t2.Salary
0debug
Merge 3 Excel files into 1 excel file. (xlsx) : Hello i am parsing some data into a excel sheet and i am generating 3 excel sheets(Compliance1.xls,Compliance2.xls,Compliance3.xls) by using the below code: owb.SaveAs(Input_File+@"\Compliance1.xls",Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); i want one excel sheet to be generated with 3 of compliance sheets in it please help me asap
0debug
static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, uint64_t *slptep, uint32_t *slpte_level, bool *reads, bool *writes) { dma_addr_t addr = vtd_get_slpt_base_from_context(ce); uint32_t level = vtd_get_level_from_context_entry(ce); uint32_t offset; uint64_t slpte; uint32_t ce_agaw = vtd_get_agaw_from_context_entry(ce); uint64_t access_right_check; if (iova & ~((1ULL << MIN(ce_agaw, VTD_MGAW)) - 1)) { VTD_DPRINTF(GENERAL, "error: iova 0x%"PRIx64 " exceeds limits", iova); return -VTD_FR_ADDR_BEYOND_MGAW; } access_right_check = is_write ? VTD_SL_W : VTD_SL_R; while (true) { offset = vtd_iova_level_offset(iova, level); slpte = vtd_get_slpte(addr, offset); if (slpte == (uint64_t)-1) { VTD_DPRINTF(GENERAL, "error: fail to access second-level paging " "entry at level %"PRIu32 " for iova 0x%"PRIx64, level, iova); if (level == vtd_get_level_from_context_entry(ce)) { return -VTD_FR_CONTEXT_ENTRY_INV; } else { return -VTD_FR_PAGING_ENTRY_INV; } } *reads = (*reads) && (slpte & VTD_SL_R); *writes = (*writes) && (slpte & VTD_SL_W); if (!(slpte & access_right_check)) { VTD_DPRINTF(GENERAL, "error: lack of %s permission for " "iova 0x%"PRIx64 " slpte 0x%"PRIx64, (is_write ? "write" : "read"), iova, slpte); return is_write ? -VTD_FR_WRITE : -VTD_FR_READ; } if (vtd_slpte_nonzero_rsvd(slpte, level)) { VTD_DPRINTF(GENERAL, "error: non-zero reserved field in second " "level paging entry level %"PRIu32 " slpte 0x%"PRIx64, level, slpte); return -VTD_FR_PAGING_ENTRY_RSVD; } if (vtd_is_last_slpte(slpte, level)) { *slptep = slpte; *slpte_level = level; return 0; } addr = vtd_get_slpte_addr(slpte); level--; } }
1threat
read an string array as property name? : <pre><code>newDesign = { color: 'blue', shape: 'round' } oldDesign = { color: 'yellow', shape: 'triangle' } </code></pre> <p>I want to compare this two design to see if their field is changed, so I write these:</p> <pre><code>fields = [ 'color', 'shape' ] for (let field in fields) { if (oldDesign.field !== newDesign.field) console.log('changed') } </code></pre> <p>However, looks like I can't read the value of fields by using oldDesign.field.</p> <p>Is there a way to to this? Thank you.</p>
0debug
Clear React Native TextInput : <p>Working through the Redux AddTodo example in React Native. The first AddTodo example below uses state to store the TextInput value and works fine.</p> <pre><code>class AddTodo extends React.Component{ constructor(props){ super(props); this.state = { todoText: "" }; } update(e){ if(this.state.todoText.trim()) this.props.dispatch(addTodo(this.state.todoText)); this.setState({todoText: "" }); } render(){ return( &lt;TextInput value = {this.state.todoText} onSubmitEditing = { (e)=&gt; { this.update(e); } } onChangeText = { (text) =&gt; {this.setState({todoText: text}) } } /&gt; ); } } </code></pre> <p>However following a few of the Redux examples, the following code is much shorter and also works except that the <code>TextInput</code> <code>value</code> is not cleared after submitting</p> <pre><code>let AddTodo = ({ dispatch }) =&gt; { return ( &lt;TextInput onSubmitEditing = { e =&gt; { dispatch(addTodo(e.nativeEvent.text)) } } /&gt; ) } </code></pre> <p>Is there any way I can clear the InputText value from onSubmitEditing?</p>
0debug
I'm having a problem with nested loop c++ : I am a noobe in c++ ans I'm having problem with nested loops. Could you please help me and tell me where I'm mistaking main() { int n, sum=0; printf("ENTER NUMBER:"); scanf("%i",n); while(n>0) { sum+=n; n--; } printf("\n sum is:",sum); return 0; } Thank you in advance.
0debug
How can I move a window to another session in tmux? : <p>In tmux, how can I move a window from a session to another session?</p> <p>ex. move window:4 in session [0] to session [4] .</p>
0debug
void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length) { int i, j, left; align_get_bits(gb); left = get_bits_left(gb) >> 3; l->bytestream_start = l->bytestream = gb->buffer + get_bits_count(gb) / 8; l->bytestream_end = l->bytestream_start + left; l->range = 0x80; l->low = *l->bytestream >> 1; l->hash_shift = FFMAX(l->scale - 8, 0); for (i = j = 0; i < 256; i++) { unsigned r = i << l->hash_shift; while (l->prob[j + 1] <= r) j++; l->range_hash[i] = j; } l->hash_shift += 23; }
1threat
how to make my android app doesn't work in certain android phones : I have a strange question a little bit but I really need your help, can I make my android app doesn't work on certain Android phones ? for example I don't want my app to work on Samsung J5 2016 Phones, can I do that? I will be thankful for your help.
0debug
If we want use S3 to host Python packages, how can we tell pip where to find the newest version? : <p>we are trying to come up with a solution to have AWS S3 to host and distribute our Python packages. </p> <p>Basically what we want to do is using "python3 setup.py bdist_wheel" to create a wheel. Upload it to S3. Then any server or any machine can do "pip install $<a href="http://path/on/s3" rel="noreferrer">http://path/on/s3</a>". (including a virtualenv in AWS lambda) (We've looked into Pypicloud and thought it's an overkill.)</p> <p>Creating package and installing from S3 work fine. There is only one issue here: we will release new code and give them different versions. If we host our code on Pypi, you can upgrade some packages to their newest version by calling "pip install package --upgrade". </p> <p>But if you host your packages on S3, how do you let pip know there's a newer version exists? How do you roll back to an older version by simply giving pip the version number? Is there a way to let pip know where to look for different version of wheels on S3?</p>
0debug
Date format problem in c#? while retriving data from excel : Below is the image of my code please have a look on it. I am trying to retrive data from excel sheet and storing it into database table through sql bulkcopy. Error: The date format is:05-01-2019 It insert 2019-05-01 (database) incorrect correct date is=2019-01-05 When date is greater than 12 it stores in correct format. 2019-12-25(database)correct Excel(25-12-2019) [1]: https://i.stack.imgur.com/NWyHK.png
0debug
Launching my webview app when my website url cliks or open : <p>I have a website and WebView app based on it. my website link is like <a href="http://website.in/" rel="nofollow noreferrer">http://website.in/</a>. when the user tries to open this link and associated links like <a href="http://website.in/post_name/" rel="nofollow noreferrer">http://website.in/post_name/</a>, I want android to show him a chooser dialog where he can choose option to open that link using my application when he installed the app. please give me the code for android studio.</p>
0debug
Write a MATLAB code to compute and determine the convergence rate : Write a MATLAB code to compute and determine the convergence rate of : (exp(h)-(1+h+1/2*h^2))/h with h=1/2, 1/2^2,..., 1/2^10 my code was: h0=(0.5)^i; TOL=10^(-8); N=10; i=1; flag=0; table=zeros(30,1); table(1)=h0 while i < N h=(exp(h0)-(1+h0+0.5*h0^2))/h0; table (i+1)=h; if abs(h-h0)< TOL flag=1; break; end i=i+1; h0=h; end if flag==1 h else error('failed'); end The answer I received does not make quite any sense. Please help.
0debug
How do I print DIV content of HTML to printer with Javascript only? : <p>I needed to print the content of HTML div. For that I have added a button. I am trying to call a function onclick of button to print the div content using Javascript.</p>
0debug
valarray with arithmetic operations return type : <p>When I write a simple arithmetic expression with <code>valarray</code> and assign the result to <code>auto</code> I get a segfault when I try to access the result on gcc.</p> <pre><code>#include &lt;iostream&gt; #include &lt;valarray&gt; using std::ostream; using std::valarray; ostream&amp; operator&lt;&lt;(ostream&amp;os, const valarray&lt;double&gt;&amp;vs) { os &lt;&lt; "["; for(auto&amp;v : vs) os &lt;&lt; v &lt;&lt; " "; return os &lt;&lt; "]"; } int main() { valarray&lt;double&gt; a{ 1.0, 2.0, 3.0, 4.0 }; std::cout &lt;&lt; "a: " &lt;&lt; a &lt;&lt; "\n"; valarray&lt;double&gt; b{ 2.0, 4.0, 6.0, 8.0 }; std::cout &lt;&lt; "b: " &lt;&lt; b &lt;&lt; "\n"; valarray&lt;double&gt; c{ 2.0, 1.5, 0.5, 0.25 }; std::cout &lt;&lt; "c: " &lt;&lt; c &lt;&lt; "\n"; valarray&lt;double&gt; x = ( a + b ) / 2; std::cout &lt;&lt; "x: " &lt;&lt; x &lt;&lt; "\n"; // this still works: auto y = ( a + b ) / 2; // The following will result in a segfault: std::cout &lt;&lt; "y:" &lt;&lt; y &lt;&lt; "\n"; } </code></pre> <p>The <a href="http://www.cplusplus.com/reference/valarray/valarray/operators/" rel="noreferrer">reference</a> says that the implementation may choose that the return type of the arithmetic operation overloads may not be a <code>valarray</code>-value but something that "behaves like it":</p> <blockquote> <p>The operators returning a valarray by value are allowed to return an object of a different type instead. Such a type is required to be implicitly convertible to valarray and be supported as argument for all functions taking valarray&amp; arguments. This allows copy-on-write implementations.</p> </blockquote> <p>Well, my <code>operator&lt;&lt;</code> should call for that "implicit conversion", shouldnt it?</p> <p>So why do I get a segfault?</p> <pre><code>$ ./valarray01.cpp.x a: [1 2 3 4 ] b: [2 4 6 8 ] c: [2 1.5 0.5 0.25 ] x: [1.5 3 4.5 6 ] Segmentation fault (core dumped) </code></pre> <blockquote> <p>gcc version 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~14.04) </p> </blockquote> <p>I got sceptical when I tried <em>clang</em> (on linux, so probably gcc's stdlib) and... it works:</p> <blockquote> <p>clang version 3.9.1-svn288847-1~exp1 (branches/release_39)</p> </blockquote> <pre><code>$ ./valarray01.cpp.x a: [1 2 3 4 ] b: [2 4 6 8 ] c: [2 1.5 0.5 0.25 ] x: [1.5 3 4.5 6 ] y:[1.5 3 4.5 6 ] </code></pre> <p>Well, before I file a gcc-bug... am I doing something wrong? Is my <code>auto</code> evil? Or is it really gcc?</p>
0debug
Replace vector of vector with flat memory structure : <p>I have the following type:</p> <pre><code>std::vector&lt;std::vector&lt;int&gt;&gt; indicies </code></pre> <p>where the size of the inner vector is always 2. The problem is, that vectors are non-contiguous in memory. I would like to replace the inner vector with something contiguous so that I can cast the flattened array:</p> <pre><code>int *array_a = (int *) &amp;(a[0][0]) </code></pre> <p>It would be nice if the new type has the [] operator, so that I don't have to change the whole code. (I could also implement it myself if necessary). My ideas are either:</p> <pre><code>std::vector&lt;std::array&lt;int, 2&gt;&gt; </code></pre> <p>or </p> <pre><code>std::vector&lt;std::pair&lt;int, int&gt;&gt; </code></pre> <p>How do these look in memory? I wrote a small test:</p> <pre><code>#include &lt;iostream&gt; #include &lt;array&gt; #include &lt;vector&gt; int main(int argc, char *argv[]) { using namespace std; vector&lt;array&lt;int, 2&gt;&gt; a(100); cout &lt;&lt; sizeof(array&lt;int, 2&gt;) &lt;&lt; endl; for(auto i = 0; i &lt; 10; i++){ for(auto j = 0; j &lt; 2; j++){ cout &lt;&lt; "a[" &lt;&lt; i &lt;&lt; "][" &lt;&lt; j &lt;&lt; "] " &lt;&lt;&amp;(a[i][j]) &lt;&lt; endl; } } return 0; } </code></pre> <p>which results in:</p> <pre><code>8 a[0][0] 0x1b72c20 a[0][1] 0x1b72c24 a[1][0] 0x1b72c28 a[1][1] 0x1b72c2c a[2][0] 0x1b72c30 a[2][1] 0x1b72c34 a[3][0] 0x1b72c38 a[3][1] 0x1b72c3c a[4][0] 0x1b72c40 a[4][1] 0x1b72c44 a[5][0] 0x1b72c48 a[5][1] 0x1b72c4c a[6][0] 0x1b72c50 a[6][1] 0x1b72c54 a[7][0] 0x1b72c58 a[7][1] 0x1b72c5c a[8][0] 0x1b72c60 a[8][1] 0x1b72c64 a[9][0] 0x1b72c68 a[9][1] 0x1b72c6c </code></pre> <p>It seems to work in this case. Is this behavior in the standard or just a lucky coincidence? Is there a better way to do this?</p>
0debug
UIButton press not working with an IF statement (XCODE/SWIFT) : I am currently trying to get an IF statement working only when the user presses on the UIButton which will then run the `self.eslTopics.isHidden = false` in order to show my UIPickerView, what is the correct syntax of writing the if statement? i currently have a button called "showwheel" which is meant to change the pickerview UI from hidden = true to False. if showWheel{ self.eslTopics.isHidden = false } XCode is trying to throw an error "**Optional type 'UIButton!' cannot be used as a boolean; test for '!= nil' instead, Replace 'showWheel' with '(showWheel != nil)'**" which also doesnt make sence or work? Any ideas?
0debug
Angular 6 RXJS Import Syntax? : <p>I'm migrating an Angular 5 app to the latest CLI and Angular 6 RC and all of my Observable imports are broken. I see that Angular 6 changes the way the imports work, but I can't find any definite reference as to how the syntax works.</p> <p>I had this in 5 and it worked fine:</p> <pre><code>import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import 'rxjs/add/observable/throw'; </code></pre> <p>Now with the new syntax I see that </p> <pre><code>import { Observable, Subject, throwError} from 'rxjs'; import { map } from 'rxjs/operators'; </code></pre> <p>The first two lines compile, but I can't figure out how to get catch and throw for example. .map() also throws a build error when used in code.</p> <p>Anybody have a reference to how this is supposed to work?</p>
0debug
how can I cache ID tokens from cognito for subsequent hits to API gateway? : how to implement this scenario in AWS? the user hits a API endpoint in API gateway, Cognito is used for verification. the user passes access id (after successful Cognito verification) to API gateway, then once the access token is exchanged with id token, can the id token be cached in API gateway or elastic cache for subsequent API hits to avoid the overhead of token exchange for each call?
0debug
How to install jenkins plugins from command line? : <p>Is there any option to install jenkins plugins from command line ?</p> <p>I found a command for this after a bit google search : </p> <pre><code>java -jar /var/lib/jenkins/jenkins.war -s http://127.0.0.1:8080/ install-plugin ${Plugin_Name} </code></pre> <p>But it's not working.</p>
0debug
Creating sequence of lists from content of one list : <p>Trying to solve the following problem:</p> <p>I have a large collection which I will represent by the following example list:</p> <pre><code>lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] </code></pre> <p>How do I splice up this list and return a sequence of delimited strings for every four elements in the list?</p> <p>Desired output:</p> <pre><code>1, 2, 3, 4 5, 6, 7, 8 9, 10, 11, 12 13, 14, 15, 16 </code></pre>
0debug
Angular 2 template driven form with ngFor inputs : <p>Is it possible to create input fields with a ngFor in a template driven form and use something like #name="ngModel" to be able to use name.valid in another tag?</p> <p>Right now we have a dynamic list of products with a quantity field and a add to cart button in a table. I want to make the whole thing a form with a add all button at the end like this:</p> <pre><code>&lt;form #form="ngForm"&gt; &lt;div *ngFor="item in items"&gt; &lt;input name="product-{{item.id}}" [(ngModel)]="item.qty" #????="ngModel" validateQuantity&gt; &lt;button (click)="addItemToCart(item)" [disabled]="!????.valid"&gt;Add to cart&lt;/button&gt; &lt;/div&gt; &lt;button (click)="addAll()" [disabled]="!form.valid"&gt;Add all&lt;/button&gt; &lt;/form&gt; </code></pre> <p>But how can i generate a new variable name per row for the ngModel?</p>
0debug
How do I insert one value into one column? : <p>I need to get a value from a field on front end application that is connected to the DB. The thing is I would like to insert the single value entered into One column in a table that has multiple columns.</p>
0debug
Infinite Recursion in Java? : <p>Obviously the following recursion in Java will cause stack overflow error:</p> <pre><code>public class XXX { public static void main(String[] args) { main(null); } } </code></pre> <p>But what if I catch this error and invoke the function again?</p> <pre><code>public class XXX { public static void main(String[] args) { try { main(null); } catch(StackOverflowError E) { main(null); } } } </code></pre> <p>how does it perform then??</p>
0debug
void s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word) { if (kvm_enabled()) { kvm_s390_io_interrupt(cpu, subchannel_id, subchannel_nr, io_int_parm, io_int_word); } else { cpu_inject_io(cpu, subchannel_id, subchannel_nr, io_int_parm, io_int_word); } }
1threat
Kotlin sorting nulls last : <p>What would be a Kotlin way of sorting list of objects by nullable field with nulls last? </p> <p>Kotlin object to sort: </p> <pre><code>@JsonInclude(NON_NULL) data class SomeObject( val nullableField: String? ) </code></pre> <p>Analogue to below Java code:</p> <pre class="lang-java prettyprint-override"><code>@Test public void name() { List&lt;SomeObject&gt; sorted = Stream.of(new SomeObject("bbb"), new SomeObject(null), new SomeObject("aaa")) .sorted(Comparator.comparing(SomeObject::getNullableField, Comparator.nullsLast(Comparator.naturalOrder()))) .collect(toList()); assertEquals("aaa", sorted.get(0).getNullableField()); assertNull(sorted.get(2).getNullableField()); } @Getter @AllArgsConstructor private static class SomeObject { private String nullableField; } </code></pre>
0debug
How to use docker deploy in docker-compose 3? : <p>When I make command <code>sudo docker stack deploy -c docker-compose.yml test</code></p> <pre><code>Ignoring unsupported options: build, external_links, links, restart Updating service test_cache (id: me2vh1lffrl4ppzomphin167la) Updating service test_lb (id: ycnne1ifpt517wdbfdg1g5tlup) Updating service test_media (id: rr3ural9hjz0mw6hjx7n2vywm) Creating service test_web Error response from daemon: rpc error: code = 3 desc = ContainerSpec: image reference must be provided </code></pre> <p>And I get this error - <strong>Error response from daemon: rpc error: code = 3 desc = ContainerSpec: image reference must be provided</strong></p> <p>But I create image for this container.</p>
0debug
nodejs push is not a function : <p>I have difficulty making a collection of a class</p> <p>Match example</p> <p>and matches</p> <p>matches is a collection of match</p> <p>my class match:</p> <pre><code>const uuid = require("uuid"); // Match class is a single game Match structure class Match { constructor(players) { this.id = uuid.v4().toString(); this.players = players; } // Match rest methods... // I.E: isMatchEnded, isMatchStarted ... } module.exports = Match; </code></pre> <p>my class Matches</p> <pre><code>class Matches { constructor() { this.matches = {}; } addMatch(match) { this.matches.push(match); } // Matches rest methods... } module.exports = Matches; </code></pre> <p>my main:</p> <pre><code> const matches = new Matches(); const queue = new Queue(); queue.addPlayer(new Player(1,'spt',970)); queue.addPlayer(new Player(2,'test2',1000)); queue.addPlayer(new Player(3,'test3',1050)); queue.addPlayer(new Player(4,'test4',70)); const playerOne = queue.players.find((playerOne) =&gt; playerOne.mmr === 970); const players = queue.searching(playerOne); if(players){ const match = new Match(players); matches.addMatch(match); } console.log(matches); </code></pre> <p>But I am getting this error:</p> <pre><code>Matches.js:7 this.matches.push(match); ^ TypeError: this.matches.push is not a function </code></pre>
0debug
Why Array of ArrayLists Does't work in Java? : <p>I'm using an Array of ArrayLists of Integer in Java but it can't run. Every time I get the message "Note: Goal.java uses unchecked or unsafe operations." and "Note: Recompile with -Xlint:unchecked for details." after compile and when I want to run it message "Exception in thread "main" java.lang.NullPointerException" appears.</p> <p>the code is (All is in main method) : </p> <pre><code>int v = 8; ArrayList&lt;Integer&gt;[] adj = new ArrayList[11]; adj[0].add(21); </code></pre> <p>and the error belongs to the last line. searched a lot but nothing ! plz help, stuck for hours now.</p>
0debug