problem
stringlengths
26
131k
labels
class label
2 classes
Calculate percentage for a column with certain condition of rows : <p>I have a following dataframe:</p> <pre><code> sleep health count prop 1 7 Good 100 NA 2 7 Normal 75 NA 3 7 Bad 25 NA 4 8 Good 125 NA 5 8 Normal 75 NA 6 8 Bad 25 NA </code></pre> <p>I want to fill the <code>prop</code> column with each percentage of <code>count</code> based on <code>sleep</code> group. For instance, the first 3 rows <code>prop</code> should be 0.5, 0.375, and 0.125 then the last 3 rows <code>prop</code> are 0.555, 0.333, and 0.111 respectively.</p> <p>This can be done manually by separating the data frame by <code>sleep</code> first then use <code>prop.table(prop)</code> for each, but since there are numerous <code>sleep</code> group I can't find a succinct way to do this. Any thoughts?</p>
0debug
The definition of graph in C : <p>I set the definition of adjacency list node like this:</p> <pre><code>typedef struct node_type{ int data; struct node_type *link; }node; </code></pre> <p>The definition of adjacency list:</p> <pre><code>typedef node *list; </code></pre> <p>The definition of graph:( A graph is an array of adjacency lists)</p> <pre><code>typedef struct graph_type{ int no_of_vertex; list *array; }graph; </code></pre> <p>Was it a correct definition anyway?</p>
0debug
Conditional expression : <p>so I'm studying for my exam and I do not understand how can I solve this conditional expression. I know that if the expression 1 is true, I do the expression 2, and if it is false, I do the expression 3. Can someone help me understanding what I need to do in the first expression?</p> <pre><code>int A = -1, B = -2, C = -3; int X = 1; (X = B != C) ? (A = (~C) - A--) : (++C + (~A)); printf(" A = %d B = %d C = %d X = %d\n", A, B, C, X); </code></pre>
0debug
Need solution for insert multiple rows in table from comma separated string. I am able to insert in table with one column. : Declare @Var varchar(MAX) Set @Var = '1,2,3' DECLARE @XML AS XML DECLARE @Delimiter AS CHAR(1) =',' SET @XML = CAST(('<X>'+REPLACE(@Var,@Delimiter ,'</X><X>')+'</X>') AS XML) Declare @Var1 nvarchar(MAX) Set @Var1 = '10,11,12' DECLARE @XML1 AS XML DECLARE @Delimiter1 AS CHAR(1) =',' SET @XML1 = CAST(('<X>'+REPLACE(@Var1,@Delimiter1 ,'</X><X>')+'</X>') AS XML) DECLARE @temp TABLE (ID INT,ID1 INT); INSERT INTO @temp (ID,ID1) values (SELECT N.value('.', 'INT') AS ID FROM @XML.nodes('X') AS T(N), SELECT N1.value('.', 'INT') AS ID1 FROM @XML1.nodes('X') AS T(N1)) select * from @temp
0debug
static void sdl_switch(DisplayChangeListener *dcl, DisplaySurface *new_surface) { PixelFormat pf = qemu_pixelformat_from_pixman(new_surface->format); if (new_surface) { surface = new_surface; } if (!scaling_active) { do_sdl_resize(surface_width(surface), surface_height(surface), 0); } else if (real_screen->format->BitsPerPixel != surface_bits_per_pixel(surface)) { do_sdl_resize(real_screen->w, real_screen->h, surface_bits_per_pixel(surface)); } if (guest_screen != NULL) { SDL_FreeSurface(guest_screen); } #ifdef DEBUG_SDL printf("SDL: Creating surface with masks: %08x %08x %08x %08x\n", pf.rmask, pf.gmask, pf.bmask, pf.amask); #endif guest_screen = SDL_CreateRGBSurfaceFrom (surface_data(surface), surface_width(surface), surface_height(surface), surface_bits_per_pixel(surface), surface_stride(surface), pf.rmask, pf.gmask, pf.bmask, pf.amask); }
1threat
How can I access an API's that has an integer as its object : PLEASE HELP ANYONE!! how do you access an API's response with an integer as its object, example data.results.0; When I try this, it brings up an error in my console log of (Uncaught SyntaxError: Unexpected number)... please help... Please I am just starting to learn HTML and Java.
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags) { unsigned int e1, e2; uint32_t *p; e1 = (addr << 16) | (limit & 0xffff); e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000); e2 |= flags; p = ptr; p[0] = tswapl(e1); p[1] = tswapl(e2); }
1threat
Why do I get a malformed JSON in request body in this cURL call? : <p>I have been trying to call the CloudFlare API v4, using an example provided in their own documentation.</p> <p>This is the code of the example</p> <pre><code>curl -X PUT "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" \ -H "X-Auth-Email: user@example.com" \ -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \ -H "Content-Type: application/json" \ --data '{"id":"372e67954025e0ba6aaa6d586b9e0b59","type":"A","name":"example.com","content":"1.2.3.4","proxiable":true,"proxied":false,"ttl":120,"locked":false,"zone_id":"023e105f4ecef8ad9ca31a8372d0c353","zone_name":"example.com","created_on":"2014-01-01T05:20:00.12345Z","modified_on":"2014-01-01T05:20:00.12345Z","data":{}}' </code></pre> <p>Which can also be found at <a href="https://api.cloudflare.com/#dns-records-for-a-zone-dns-record-details" rel="noreferrer">Update DNS Records</a></p> <p>Using Windows cmd.exe to run this command, i need to make it single line first, so i removed the "\" and reformatted it (twice) making sure I altered no part in the process.</p> <p>This is the same code in one line :</p> <pre><code>curl -X PUT "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" -H "X-Auth-Email: user@example.com" -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" -H "Content-Type: application/json" --data '{"id":"372e67954025e0ba6aaa6d586b9e0b59","type":"A","name":"example.com","content":"1.2.3.4","proxiable":true,"proxied":false,"ttl":120,"locked":false,"zone_id":"023e105f4ecef8ad9ca31a8372d0c353","zone_name":"example.com","created_on":"2014-01-01T05:20:00.12345Z","modified_on":"2014-01-01T05:20:00.12345Z","data":{}}' </code></pre> <p>When i run this single-liner in cmd, it works but i get a malformed JSON in request body, however, a visual check, formatting on notepad++ and a run through the JSON validator are all positive, this JSON (copied from the CloudFlare documentation) is not malformed.</p> <p>Error Message</p> <pre><code>{"success":false,"errors":[{"code":6007,"message":"Malformed JSON in request body"}],"messages":[],"result":null} </code></pre> <p>Googling this error message or the error code gives me nothing and this same command works on a pc running linux of my boss.</p> <p>Can someone tell me if this is a known bug, if the JSON really is malformed or if something else comes to mind ?</p> <p>Thank you</p>
0debug
static void flat_print_section_header(WriterContext *wctx) { FlatContext *flat = wctx->priv; AVBPrint *buf = &flat->section_header[wctx->level]; int i; av_bprint_clear(buf); for (i = 1; i <= wctx->level; i++) { if (flat->hierarchical || !(wctx->section[i]->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER))) av_bprintf(buf, "%s%s", wctx->section[i]->name, flat->sep_str); } }
1threat
What's the good http status code to return on expired password? : <p>When a password is expired what rest api should return? I mean: username and password are correct, but expired.</p> <p><a href="https://tools.ietf.org/html/rfc7235#section-6.2" rel="noreferrer">Here</a> I found that</p> <blockquote> <p>The mechanisms for expiring or revoking credentials can be specified as part of an authentication scheme definition.</p> </blockquote> <p>Is there a specification about what's the right and/or correct http status code for expired credentials? Is http status code good to handle with credentials expiration?</p>
0debug
static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *request) { NBDClient *client = req->client; uint32_t command; ssize_t rc; g_assert(qemu_in_coroutine()); client->recv_coroutine = qemu_coroutine_self(); nbd_update_can_read(client); rc = nbd_receive_request(client->ioc, request); if (rc < 0) { if (rc != -EAGAIN) { rc = -EIO; } goto out; } TRACE("Decoding type"); command = request->type & NBD_CMD_MASK_COMMAND; if (command != NBD_CMD_WRITE) { req->complete = true; } if (command == NBD_CMD_DISC) { TRACE("Request type is DISCONNECT"); rc = -EIO; goto out; } if ((request->from + request->len) < request->from) { LOG("integer overflow detected, you're probably being attacked"); rc = -EINVAL; goto out; } if (command == NBD_CMD_READ || command == NBD_CMD_WRITE) { if (request->len > NBD_MAX_BUFFER_SIZE) { LOG("len (%" PRIu32" ) is larger than max len (%u)", request->len, NBD_MAX_BUFFER_SIZE); rc = -EINVAL; goto out; } req->data = blk_try_blockalign(client->exp->blk, request->len); if (req->data == NULL) { rc = -ENOMEM; goto out; } } if (command == NBD_CMD_WRITE) { TRACE("Reading %" PRIu32 " byte(s)", request->len); if (read_sync(client->ioc, req->data, request->len) != request->len) { LOG("reading from socket failed"); rc = -EIO; goto out; } req->complete = true; } if (request->from + request->len > client->exp->size) { LOG("operation past EOF; From: %" PRIu64 ", Len: %" PRIu32 ", Size: %" PRIu64, request->from, request->len, (uint64_t)client->exp->size); rc = command == NBD_CMD_WRITE ? -ENOSPC : -EINVAL; goto out; } if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) { LOG("unsupported flags (got 0x%x)", request->type & ~NBD_CMD_MASK_COMMAND); rc = -EINVAL; goto out; } rc = 0; out: client->recv_coroutine = NULL; nbd_update_can_read(client); return rc; }
1threat
I am trying to print numbers from 1 to 10 in sequential order with two different threads, but output is not always same : <p>This is how my code looks like, What is wrong with the code? I want to print numbers in 1, 2,3,4,....10 but the output is 2,1,3,4,6...and it changes every time or is their any better way to implement this</p> <pre><code>class Th1 extends Thread{ public void run (){ try{ for (int i=1; i&lt;=10; i+=2){ System.out.println ("VALUE OF ODD : "+i); Thread.sleep (1000); } }catch (InterruptedException ie){ System.out.println (ie); } } }; class Th2 implements Runnable{ public void run (){ try{ for (int j=2; j&lt;=10; j+=2){ System.out.println ("VALUE OF EVEN : "+j); Thread.sleep (1000); } }catch (InterruptedException ie){ System.out.println (ie); } } }; class ThDemo6{ public static void main (String [] args) { Th1 t1=new Th1 ();// object of Thread class Th2 t2=new Th2 ();// object of Runnable class Thread t=new Thread (t2);// Runnable is converted into Thread object System.out.println ("BEFORE START T1 IS : "+t1.isAlive ()); System.out.println ("BEFORE START T2 IS : "+t.isAlive ()); t1.start (); t.start (); System.out.println ("AFTER START T1 IS : "+t1.isAlive ()); System.out.println ("AFTER START T2 IS : "+t.isAlive ()); try { t1.join ();// to make thread to join together for getting performance t.join (); } catch (InterruptedException ie) { System.out.println (ie); } System.out.println ("AFTER JOINING T1 IS : "+t1.isAlive ()); System.out.println ("AFTER JOINING T2 IS : "+t.isAlive ()); } } </code></pre>
0debug
How to implement a magnifying glass in the index list of an UITableView? : <p>I want to implement a magnifying glass in the index list of an UITableView in Swift. Here is how it should look like:</p> <p><a href="https://i.stack.imgur.com/42qlW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/42qlW.jpg" alt=""></a> Is there a simple way to achieve it? The magnifying glass should be a button. By pressing this button something like</p> <pre class="lang-swift prettyprint-override"><code>tableView.scroll(to: .top, animated: true) </code></pre> <p>should be executed...</p> <p>Thanks for your help!</p>
0debug
Run atexit() when python process is killed : <p>I have a python process which runs in background, and I would like it to generate some output only when the script is terminated.</p> <pre><code>def handle_exit(): print('\nAll files saved in ' + directory) generate_output() atexit.register(handle_exit) </code></pre> <p>Calling raising a <code>KeyboardInterupt</code> exception and <code>sys.exit()</code> calls <code>handle_exit()</code> properly, but if I were to do <code>kill {PID}</code> from the terminal it terminates the script without calling handle_exit().</p> <p>Is there a way to terminate the process that is running in the background, and still have it run <code>handle_exit()</code> before terminating?</p>
0debug
how to retrieve the id just created in the database in laravel? : <p>how do I retrieve the id that was just created in the database, when I press the save button, the data is created, and I want to retrieve the id from that data</p> <p>this my controller code</p> <pre><code>$cart= new cart; $cart-&gt;user_id = $request-&gt;user_id; $cart&gt;vendor_name = $request-&gt;vendor_name; $cart-&gt;save(); </code></pre> <p>I want to retrieve the id of the data just created</p>
0debug
How to change all value inside a JSON string php : <p>I want to change the date value from "<strong>15/03/2019 07:18:57</strong>" to this: "<strong>1552634337</strong>". </p> <p>Here is the code:</p> <pre><code>&lt;?php $dtime = DateTime::createFromFormat("d/m/Y G:i:s", "15/03/2019 07:18:57"); echo $timestamp = $dtime-&gt;getTimestamp(); ?&gt; </code></pre> <p>but I want to do this to all the values ​​of "date".</p> <p>json:</p> <pre><code>[{ "id": "6326", "type": "0", "date": "15/03/2019 07:18:57", "message": "test", "count": 17 }, { "id": "6326", "type": "0", "date": "15/03/2019 07:18:57", "message": "test", "count": 17 }] </code></pre> <p>THANKS!</p>
0debug
How can one Docker container call another Docker container : <p>I have two Docker containers</p> <ol> <li>A Web API</li> <li>A Console Application that calls Web API</li> </ol> <p>Now, on my local web api is local host and Console application has no problem calling the API.However, I have no idea when these two things are Dockerized, how can I possibly make the Url of Dockerized API available to Dockerized Console application?</p> <p>i don't think i need a Docker Compose because I am passing the Url of API as an argument of the API so its just the matter of making sure that the <code>Dockerized API's</code> url is accessible by <code>Dockerized Console</code></p> <p>Any ideas?</p>
0debug
objective c NSDictionary from NSString : @interface users : NSObject { NSString *_id; NSString *logo; NSNumber *longtitude; NSNumber *latitude; } I have NSString: NSString *requestReply = {"status":1,"result":[{"id":"150","latitude":"31.7512103","longitude":"35.208157700000015","logo":"http://admin.t-club.co.il/upload/LOGO/150/694.jpg"},{"id":"145","latitude":"31.246028","longitude":"34.80849480000006","logo":"http://admin.t-club.co.il/upload/LOGO/145/689.jpg",},{"id":"37","latitude":"29.5593765","longitude":"34.95099419999997","logo":"http://admin.t-club.co.il/upload/LOGO/37/190.jpg",},{"id":"84","latitude":"29.5512331","longitude":"34.95264959999997","logo":"http://admin.t-club.co.il/upload/LOGO/84/483.jpg"}],"error":0} How can I make array from class users with data from string that I have?
0debug
HTML tables i need advice : I have to make a webpage for a school homework and in that page i have to put a floor plan using tables and if the user clicks on the name of the room a webpage with information and details about that room should open I have this PDF file with the mass of each room(sorry it's in german) https://www.docdroid.net/zd7QMku/grundriss.pdf.html [This is how the floor plan should look like][1] [1]: https://i.stack.imgur.com/ieb1R.png The problem is that i don't even know how many rows and cols are needed can you help me?
0debug
Creating jks keystore with openssl : <p>does anybody know how to create a jks keystore? I've been looking for ages how to create a jsk keystore for my sava program but every website gives different tutorials.</p> <p>thx for help Steff</p>
0debug
Vue Cli 3.0 where is the config file? : <p>I've seen it mentioned in docs, etc the vue.config.js file. And also noted previously these are handled in the webpack config file, etc in 2.0. But I can't find either file in my project folder created with vue cli 3.0... Where is the config files and why isn't it anywhere in the top level folders, etc?</p>
0debug
Crypto++ on Omnet++ : Can you help me with the steps to link/import crypto++ library to OMNeT++ framework properly, please. I use omnet++ 5.0/inetmanet 3.0 version (Windows 10). Best regards, Hajji
0debug
How do I use a paremeter to index an array in rust? : <p>I'm trying to create a function that will take a parameter and use it as an index for an array rust will not let me do this and because of this I'm hoping to find an alternative method to achieve the same results.</p> <p>although I'm not a 100% I believe that rust is not letting me run the code because it believes that the parameter I'm using might go beyond the lens of the array and for this I tried using the <code>get()</code> function:</p> <pre class="lang-rust prettyprint-override"><code>array.get(foo).unwrap(); </code></pre> <p>however this still doesn't fix my current error.</p> <p>Sample code to reproduce error:</p> <pre class="lang-rust prettyprint-override"><code>fn example(foo: u32) { let mut array: [u32; 3] = [0,0,0]; array[foo] = 9; } fn main() { example(1); } </code></pre> <p>The program fails to run with the complier giving me the error</p> <pre><code>array[foo] = 9 ^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` </code></pre> <p>This is my first time writing a problem on stack overflow so if i messed the formatting somewhere, sorry.</p>
0debug
Hello Friends,Help required reading to jmeter(HTTP SAMPLE GOING FAILED IF JUST AN EMBEDED RESOURCE COULD NOT FIND LIKE CSS) : "When asking the HTTP samplers to download embedded resources it will fail the entire request if any of the embedded resources fetching has failed (for example a CSS which doesn't exists). I would like to have an option to ignore such errors. For example, I would like to use JMeter to generate a load which tests a switch I wrote - but if it fails for embedded resources I can't tell if the reason to the error was my switch or something else (a 404 errors on embedded resources are very common). I would like to be able to run a full success scenario using JMeter w/o my switch, then to plug-in the switch and see the difference." **how to fix it acutally got this link but unable to fix it due to newer to JMETER** ======================================================================== "https://bz.apache.org/bugzilla/show_bug.cgi?id=44301"
0debug
Why do I get clone is not a function? : <p>WHy is clone not a function in JS? How do I clone?</p> <pre><code>const standardhours = { "09" : '9AM', "10" : '10AM', "11" : '11AM', "12" : 'Noon', "13" : '1PM', "14" : '2PM', "15" : '3PM', "16" : '4PM', "17" : '5PM', "18" : '6PM', "19" : '7PM' }; var availablehours = { "09" : '9AM', "10" : '10AM', "11" : '11AM', "12" : 'Noon', "13" : '1PM', "14" : '2PM', "15" : '3PM', "16" : '4PM', "17" : '5PM', "18" : '6PM', "19" : '7PM' }; availablehours = clone(standardhours); </code></pre>
0debug
How to pass variable value to HMTL data-type : I have a variable declared: var fburl = data.results[0].alias; How can I pass the var value to the HTML data-type? Example: var myurl = data.results[0].alias; <div class="myclass" data-url="value in myurl"></div>
0debug
how can i send Response from c# class file to MVCcontroller : If my condition fails as `rdr.HasRows == true` how can i responde my controller its fails public Employee DeleteEmpById(int key) { try { SqlCommand cmd = new SqlCommand("Sp_GetEmployeeById", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmpId", key); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows == true) { } else ////Here what i mention when rdr.HasRows fals } **Controller** public ActionResult DeleteById(int id) { var x = ObjRepo.DeleteEmpById(id); return View(x); }
0debug
static always_inline void gen_qemu_stg (TCGv t0, TCGv t1, int flags) { TCGv tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_helper_1_1(helper_g_to_memory, tmp, t0); tcg_gen_qemu_st64(tmp, t1, flags); tcg_temp_free(tmp); }
1threat
How to select data from mysql database by date : <p>I have an DB Table with a column appointment_date [<strong>type</strong>: <strong>date</strong>], I want select all the data matching with today's date.</p>
0debug
static int parse_tag(AVFormatContext *s, const uint8_t *buf) { int genre; if (!(buf[0] == 'T' && buf[1] == 'A' && buf[2] == 'G')) return -1; get_string(s, "title", buf + 3, 30); get_string(s, "artist", buf + 33, 30); get_string(s, "album", buf + 63, 30); get_string(s, "date", buf + 93, 4); get_string(s, "comment", buf + 97, 30); if (buf[125] == 0 && buf[126] != 0) av_metadata_set2(&s->metadata, "track", av_d2str(buf[126]), AV_METADATA_DONT_STRDUP_VAL); genre = buf[127]; if (genre <= ID3v1_GENRE_MAX) av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0); return 0; }
1threat
static int qemu_peek_byte(QEMUFile *f) { if (f->is_write) { abort(); } if (f->buf_index >= f->buf_size) { qemu_fill_buffer(f); if (f->buf_index >= f->buf_size) { return 0; } } return f->buf[f->buf_index]; }
1threat
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema : <p>I have this simple helloworld react app created from an online course, however I get this error:</p> <blockquote> <p>Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'postcss'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsO utputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? } For typos: please correct them.<br> For loader options: webpack 2 no longer allows custom properties in configuration. Loaders should be updated to allow passing options via loader options in module.rules. Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader: plugins: [ new webpack.LoaderOptionsPlugin({ // test: /.xxx$/, // may apply this only for some modules options: { postcss: ... } }) ] - configuration.resolve has an unknown property 'root'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins ?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? } - configuration.resolve.extensions[0] should not be empty.</p> </blockquote> <p>My webpack file is:</p> <pre><code>// work with all paths in a cross-platform manner const path = require('path'); // plugins covered below const { ProvidePlugin } = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); // configure source and distribution folder paths const srcFolder = 'src'; const distFolder = 'dist'; // merge the common configuration with the environment specific configuration module.exports = { // entry point for application entry: { 'app': path.join(__dirname, srcFolder, 'ts', 'app.tsx') }, // allows us to require modules using // import { someExport } from './my-module'; // instead of // import { someExport } from './my-module.ts'; // with the extensions in the list, the extension can be omitted from the // import from path resolve: { // order matters, resolves left to right extensions: ['', '.js', '.ts', '.tsx', '.json'], // root is an absolute path to the folder containing our application // modules root: path.join(__dirname, srcFolder, 'ts') }, module: { loaders: [ // process all TypeScript files (ts and tsx) through the TypeScript // preprocessor { test: /\.tsx?$/,loader: 'ts-loader' }, // processes JSON files, useful for config files and mock data { test: /\.json$/, loader: 'json' }, // transpiles global SCSS stylesheets // loader order is executed right to left { test: /\.scss$/, exclude: [path.join(__dirname, srcFolder, 'ts')], loaders: ['style', 'css', 'postcss', 'sass'] }, // process Bootstrap SCSS files { test: /\.scss$/, exclude: [path.join(__dirname, srcFolder, 'scss')], loaders: ['raw', 'sass'] } ] }, // configuration for the postcss loader which modifies CSS after // processing // autoprefixer plugin for postcss adds vendor specific prefixing for // non-standard or experimental css properties postcss: [ require('autoprefixer') ], plugins: [ // provides Promise and fetch API for browsers which do not support // them new ProvidePlugin({ 'Promise': 'es6-promise', 'fetch': 'imports?this=&gt;global!exports?global.fetch!whatwg-fetch' }), // copies image files directly when they are changed new CopyWebpackPlugin([{ from: path.join(srcFolder, 'images'), to: path.join('..', 'images') }]), // copies the index.html file, and injects a reference to the output JS // file, app.js new HtmlWebpackPlugin({ template: path.join(__dirname, srcFolder, 'index.html'), filename: path.join('..', 'index.html'), inject: 'body', }) ], // output file settings // path points to web server content folder where the web server will serve // the files from file name is the name of the files, where [name] is the // name of each entry point output: { path: path.join(__dirname, distFolder, 'js'), filename: '[name].js', publicPath: '/js' }, // use full source maps // this specific setting value is required to set breakpoints in they // TypeScript source in the web browser for development other source map devtool: 'source-map', // use the webpack dev server to serve up the web application devServer: { // files are served from this folder contentBase: 'dist', // support HTML5 History API for react router historyApiFallback: true, // listen to port 5000, change this to another port if another server // is already listening on this port port: 5000, // proxy requests to the JSON server REST service proxy: { '/widgets': { // server to proxy target: 'http://0.0.0.0:3010' } } } }; </code></pre>
0debug
"Safari cannot open the page because the address is invalid" message appears when I try to launch my app from a website : <p><strong>Device : iPhone 5 / iOS 9.3</strong> </p> <p>I have an <strong>iOS app</strong> which I need to launch from a <strong>website</strong>. I was able to do it via custom URL scheme.</p> <p>When I click the "<strong>Open App</strong>" button in the website, an alert dialog appears that says "<strong>Safari wants to open MyApp</strong>" with OK &amp; Cancel buttons.</p> <p>Clicking <strong>OK</strong> : everything is just fine. The app gets launched from the website perfectly.</p> <p>Clicking <strong>Cancel</strong> : First time, it just dismisses preventing the app being launched, which is correct.</p> <p>When I click on the "<strong>Open App</strong>" button once again from the website, I expect the same "Safari wants to launch MyApp" alert dialog to appear <strong>once again</strong>, <strong>which is not happening.</strong> </p> <p><strong>Instead</strong>, it shows a dialog that says "<strong>Cannot Open Page - Safari cannot open the page because the address is invalid</strong>" with an OK button.</p> <p>My assumption was, every time when you click on that link in the website (that can launch the app via custom url scheme), I should be prompted with "safari wants to open MyApp" alert dialog all the time. </p> <p>What am I missing here ? Appreciate your help in advance.</p>
0debug
static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQcow2State *s = bs->opaque; int offset_in_cluster, n1; int ret; unsigned int cur_bytes; uint64_t cluster_offset = 0; uint64_t bytes_done = 0; QEMUIOVector hd_qiov; uint8_t *cluster_data = NULL; qemu_iovec_init(&hd_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); while (bytes != 0) { cur_bytes = MIN(bytes, INT_MAX); if (s->crypto) { cur_bytes = MIN(cur_bytes, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } ret = qcow2_get_cluster_offset(bs, offset, &cur_bytes, &cluster_offset); if (ret < 0) { goto fail; } offset_in_cluster = offset_into_cluster(s, offset); qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes); switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: if (bs->backing) { n1 = qcow2_backing_read1(bs->backing->bs, &hd_qiov, offset, cur_bytes); if (n1 > 0) { QEMUIOVector local_qiov; qemu_iovec_init(&local_qiov, hd_qiov.niov); qemu_iovec_concat(&local_qiov, &hd_qiov, 0, n1); BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_preadv(bs->backing, offset, n1, &local_qiov, 0); qemu_co_mutex_lock(&s->lock); qemu_iovec_destroy(&local_qiov); if (ret < 0) { goto fail; } } } else { qemu_iovec_memset(&hd_qiov, 0, 0, cur_bytes); } break; case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_ZERO_ALLOC: qemu_iovec_memset(&hd_qiov, 0, 0, cur_bytes); break; case QCOW2_CLUSTER_COMPRESSED: ret = qcow2_decompress_cluster(bs, cluster_offset); if (ret < 0) { goto fail; } qemu_iovec_from_buf(&hd_qiov, 0, s->cluster_cache + offset_in_cluster, cur_bytes); break; case QCOW2_CLUSTER_NORMAL: if ((cluster_offset & 511) != 0) { ret = -EIO; goto fail; } if (bs->encrypted) { assert(s->crypto); if (!cluster_data) { cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); if (cluster_data == NULL) { ret = -ENOMEM; goto fail; } } assert(cur_bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); qemu_iovec_reset(&hd_qiov); qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); } BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_preadv(bs->file, cluster_offset + offset_in_cluster, cur_bytes, &hd_qiov, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } if (bs->encrypted) { assert(s->crypto); assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0); if (qcrypto_block_decrypt(s->crypto, (s->crypt_physical_offset ? cluster_offset + offset_in_cluster : offset), cluster_data, cur_bytes, NULL) < 0) { ret = -EIO; goto fail; } qemu_iovec_from_buf(qiov, bytes_done, cluster_data, cur_bytes); } break; default: g_assert_not_reached(); ret = -EIO; goto fail; } bytes -= cur_bytes; offset += cur_bytes; bytes_done += cur_bytes; } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); qemu_iovec_destroy(&hd_qiov); qemu_vfree(cluster_data); return ret; }
1threat
static av_cold int targa_encode_close(AVCodecContext *avctx) { av_frame_free(&avctx->coded_frame); return 0; }
1threat
Python - Code keeps returning an unwanted "None" statement : <p>My code below is returning an unwanted "None" statement. I have searched other questions in hopes to find a solution but I cant seem to figure it out. Any help would be appreciated.</p> <pre><code>def int_mult(no1,no2): try: no3 = int(no1) no3 = int(no2) except ValueError: return print("Error: Invalid Argument Type") no1 = int(round(no1)) no2 = int(round(no2)) return (no1 * no2) print (int_mult(4.49,"apple")) </code></pre>
0debug
static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, long width, long height, long lumStride, long chromStride, long dstStride, long vertLumPerChroma) { long y; const x86_reg chromWidth= width>>1; for (y=0; y<height; y++) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a", 2) \n\t" PREFETCH" 32(%2, %%"REG_a") \n\t" PREFETCH" 32(%3, %%"REG_a") \n\t" "movq (%2, %%"REG_a"), %%mm0 \n\t" "movq %%mm0, %%mm2 \n\t" "movq (%3, %%"REG_a"), %%mm1 \n\t" "punpcklbw %%mm1, %%mm0 \n\t" "punpckhbw %%mm1, %%mm2 \n\t" "movq (%1, %%"REG_a",2), %%mm3 \n\t" "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" "movq %%mm3, %%mm4 \n\t" "movq %%mm5, %%mm6 \n\t" "punpcklbw %%mm0, %%mm3 \n\t" "punpckhbw %%mm0, %%mm4 \n\t" "punpcklbw %%mm2, %%mm5 \n\t" "punpckhbw %%mm2, %%mm6 \n\t" MOVNTQ" %%mm3, (%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth) : "%"REG_a ); #else #if ARCH_ALPHA && HAVE_MVI #define pl2yuy2(n) \ y1 = yc[n]; \ y2 = yc2[n]; \ u = uc[n]; \ v = vc[n]; \ __asm__("unpkbw %1, %0" : "=r"(y1) : "r"(y1)); \ __asm__("unpkbw %1, %0" : "=r"(y2) : "r"(y2)); \ __asm__("unpkbl %1, %0" : "=r"(u) : "r"(u)); \ __asm__("unpkbl %1, %0" : "=r"(v) : "r"(v)); \ yuv1 = (u << 8) + (v << 24); \ yuv2 = yuv1 + y2; \ yuv1 += y1; \ qdst[n] = yuv1; \ qdst2[n] = yuv2; int i; uint64_t *qdst = (uint64_t *) dst; uint64_t *qdst2 = (uint64_t *) (dst + dstStride); const uint32_t *yc = (uint32_t *) ysrc; const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride); const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc; for (i = 0; i < chromWidth; i += 8) { uint64_t y1, y2, yuv1, yuv2; uint64_t u, v; __asm__("ldq $31,64(%0)" :: "r"(yc)); __asm__("ldq $31,64(%0)" :: "r"(yc2)); __asm__("ldq $31,64(%0)" :: "r"(uc)); __asm__("ldq $31,64(%0)" :: "r"(vc)); pl2yuy2(0); pl2yuy2(1); pl2yuy2(2); pl2yuy2(3); yc += 4; yc2 += 4; uc += 4; vc += 4; qdst += 4; qdst2 += 4; } y++; ysrc += lumStride; dst += dstStride; #elif HAVE_FAST_64BIT int i; uint64_t *ldst = (uint64_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i += 2) { uint64_t k, l; k = yc[0] + (uc[0] << 8) + (yc[1] << 16) + (vc[0] << 24); l = yc[2] + (uc[1] << 8) + (yc[3] << 16) + (vc[1] << 24); *ldst++ = k + (l << 32); yc += 4; uc += 2; vc += 2; } #else int i, *idst = (int32_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i++) { #if HAVE_BIGENDIAN *idst++ = (yc[0] << 24)+ (uc[0] << 16) + (yc[1] << 8) + (vc[0] << 0); #else *idst++ = yc[0] + (uc[0] << 8) + (yc[1] << 16) + (vc[0] << 24); #endif yc += 2; uc++; vc++; } #endif #endif if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) { usrc += chromStride; vsrc += chromStride; } ysrc += lumStride; dst += dstStride; } #if COMPILE_TEMPLATE_MMX __asm__(EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
1threat
I don't understand why all the data gets printed in the arrange method correctly but does not get printed in the print method. : In tree class there is a method called arrange().When i print any node value within the arrange ()method the value comes to be accurate but when i use the method print() in tree class i get a null pointer exception, please help!! public class Node { Node lnode; Node rnode; int data; public Node(String d) { data=Integer.parseInt(d); this.rnode=null; this.lnode=null; } } public class tree { public void arrange(String s[],int n,Node r) { Node root=new Node(s[0]); for(int i=1;i<n;i++) { r=root; if(Integer.parseInt(s[i])>root.data&&root.rnode==null) { root.rnode=new Node(s[i]); } else if(Integer.parseInt(s[i])<root.data&&root.lnode==null) root.lnode=new Node(s[i]); while(!(r.rnode==null)&&(Integer.parseInt(s[i]))>r.data) { r=r.rnode; if(Integer.parseInt(s[i])>r.data&&r.rnode==null) r.rnode=new Node(s[i]); else if(Integer.parseInt(s[i])<r.data&&r.lnode==null) r.lnode=new Node(s[i]); } while(!(r.lnode==null)&&(Integer.parseInt(s[i]))<r.data) { r=r.lnode; if(Integer.parseInt(s[i])>r.data&&r.rnode==null) r.rnode=new Node(s[i]); else if(Integer.parseInt(s[i])<r.data&&r.lnode==null) r.lnode=new Node(s[i]); } } **System.out.println(root.rnode.data);** } public void print(Node r) { System.out.println(r.rnode.data); } }
0debug
Angular 2 Failed to execute open on XMLHttpRequest: Invalid URL : <p>I'm trying to call a service, it's works in DHC, but when I try to call in my angular 2 project, it crash, the method request is POST, receive an object from body who has a email and password, and the response is a token, that I will use in the entire project for authorization. </p> <p>Here is my code. </p> <pre><code>import { Injectable } from '@angular/core'; import { Http, Response, Headers, Request ,RequestOptions ,RequestMethod } from '@angular/http'; import {Observable} from 'rxjs/Rx'; import 'rxjs/add/operator/map'; @Injectable() export class LoginService { constructor(private http:Http) { } getToken(){ var baseUrl = "xxx.xxx.x.xxx:xxxx/project/v1/admin/login"; var headers = new Headers(); headers.append("Content-Type", 'application/json'); var options = new RequestOptions({ headers: headers }); var objeto = {'email': 'xxxxxx', 'pass':'xxxx' } var body2 = JSON.stringify(objeto); var xhr = new XMLHttpRequest(); return this.http .post(baseUrl, body2, options) .map((response: Response) =&gt; response.json()) .subscribe( data =&gt; console.log('Success uploading the opinion '+ data, data), error =&gt; console.error(`Error: ${error}`) ); } } </code></pre> <p>I try to implement XMLHttp Request call from angular 2, but the error is the same, I don't know if I can using it in angular 2, here is the method </p> <pre><code>return Observable.fromPromise(new Promise((resolve, reject) =&gt; { // let formData: any = new FormData(); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { resolve(JSON.parse(xhr.response)); } else { reject(xhr.response); } } } xhr.open("POST", baseUrl, true); xhr.send(body2); })); </code></pre> <h1>Help :( and thank you</h1>
0debug
Interacting with external program : <p>During my work I need to perform some routine actions in program. So I'm looking for a way to automate the process. The program/script have to be able to run an external program (executable file in windows 10) and press on couple of buttons. Would like to hear suggestions from you. Sorry for a lame question.</p>
0debug
Pandas "diff()" with string : <p>How can I flag a row in a dataframe every time a column change its string value?</p> <p>Ex:</p> <p>Input</p> <pre><code>ColumnA ColumnB 1 Blue 2 Blue 3 Red 4 Red 5 Yellow # diff won't work here with strings.... only works in numerical values dataframe['changed'] = dataframe['ColumnB'].diff() ColumnA ColumnB changed 1 Blue 0 2 Blue 0 3 Red 1 4 Red 0 5 Yellow 1 </code></pre>
0debug
void page_set_flags(target_ulong start, target_ulong end, int flags) { PageDesc *p; target_ulong addr; start = start & TARGET_PAGE_MASK; end = TARGET_PAGE_ALIGN(end); if (flags & PAGE_WRITE) flags |= PAGE_WRITE_ORG; for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) { p = page_find_alloc(addr >> TARGET_PAGE_BITS); if (!p) return; if (!(p->flags & PAGE_WRITE) && (flags & PAGE_WRITE) && p->first_tb) { tb_invalidate_phys_page(addr, 0, NULL); } p->flags = flags; } }
1threat
static int IRQ_get_next(OpenPICState *opp, IRQQueue *q) { if (q->next == -1) { IRQ_check(opp, q); } return q->next; }
1threat
How to Convert Jupyter Notebook to Wordpress suitable HTML : <p>This week I made a Jupyter notebook that would be a great post for my blog. I already found that you can export this notebook to a simplified HTML format that can be embedded on a webpage with this command: </p> <pre><code>jupyter nbconvert mynotebook.ipynb --to html --template basic </code></pre> <p>However, I would like to change some simple things. For example: every title now end with the "end of line character", and there is no clear difference between input and output. </p> <p>On the NBConvert documentation page of Jupyter I can't find anything about changing templates (<a href="https://ipython.org/ipython-doc/3/notebook/nbconvert.html" rel="noreferrer">https://ipython.org/ipython-doc/3/notebook/nbconvert.html</a>). They only say </p> <blockquote> <p>"IPython provides a few templates for some output formats, and these can be specified via an additional --template argument."</p> </blockquote> <p>Is it possible to specify your own template? And where can I find the "basic" template that I want to adjust?</p>
0debug
import sys def solve(a,n): mx = -sys.maxsize - 1 for j in range(1,n): if (mx > a[j]): return False mx = max(mx,a[j - 1]) return True
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Is there any sample for @angular-libphonenumber with angular 2 or higher? : <p>I am trying to create a directive for formatting and validating the phone numbers in my angualr 4 application, was looking for some guidance to getting started.</p>
0debug
Different compilation results not using extern in C vs in C++ : <p>When I declare a global variable in two different source files and only define it in one of the source files, I get different results compiling for C++ than for C. See the following example:</p> <h1>main.c</h1> <pre><code>#include &lt;stdio.h&gt; #include "func.h" // only contains declaration of void print(); int def_var = 10; int main() { printf("%d\n", def_var); return 0; } </code></pre> <h1>func.c</h1> <pre><code>#include &lt;stdio.h&gt; #include "func.h" /* extern */int def_var; // extern needed for C++ but not for C? void print() { printf("%d\n", def_var); } </code></pre> <p>I compile with the following commands:</p> <pre><code>gcc/g++ -c main.c -o main.o gcc/g++ -c func.c -o func.o gcc/g++ main.o func.o -o main </code></pre> <p>g++/clang++ complain about <code>multiple definition of def_var</code> (this is the behaviour I expected, when not using extern). gcc/clang compile just fine. (using gcc 7.3.1 and clang 5.0)</p> <p>According to <a href="http://en.cppreference.com/w/c/language/extern" rel="noreferrer">this link</a>:</p> <blockquote> <p>A tentative definition is a declaration that may or may not act as a definition. If an actual external definition is found earlier or later in the same translation unit, then the tentative definition just acts as a declaration. </p> </blockquote> <p>So my variable <code>def_var</code> should be defined at the end of each translation unit and then result in multiple definitions (as it is done for C++). Why is that not the case when compiling with gcc/clang?</p>
0debug
How to see my next data and previous data in C# without database and listbox? : i have 3 button. There are prev, next and add. i have a text file with 6 lines. So as the form load, it's only display 3 lines ascending text, the other 3 lines is appear when i click next button. But i don't know how to make it appear. This is my next button code private void next_Click(object sender, EventArgs e) { string[] baca; baca = System.IO.File.ReadAllLines(@path.Text); nama.Text = baca[3]; npm.Text = baca[4]; alamat.Text = baca[5]; } i want it to display another next lines with only 1 next button.
0debug
why program to delete nth node in linked list is running infintely? : #include<stdio.h> #include<stdlib.h> struct node{ int data; struct node* next; }; void insert(int x); void print(); void deletenode(int n); struct node* head; //global declaration int main(){ int n,m; insert(5); insert(9); insert(2); insert(3); //list is 3,2,9,5; print(); printf("enter the node position you want to delete"); scanf("%d",&n); calling deletenode function to delete the node deltenode(n); again printing the list after deletion of nth node print(); guys this program is running efficiently when i am not using deletenode function and printing the linked list correctly but after using deletenode function when i am using print function it printing infinitely i think there should be no mistake in print function because it is working fine when i am using it above deletenode but after using it below deletenode printing infinitely i am entering or parsing all the valid values so i am not making any special case in any function my delete funtion is void deletenode(int n){ struct node *temp,*temp1; temp=head; for(int i=0;i<=n-2;i++){ temp=temp->next; } temp1=temp->next; temp=temp1->next; free(temp1); } my print function is void print(){ struct node* temp; temp=head; while(temp!=NULL) { printf("%d",temp->data); temp=temp->next; } GUYS I KNOW MY PROGRAM IS NOT EFFICIENT IN TERM OF MANY THINGS AS I AM A BEGINNER BUT CAN YOU PLEASE TELL ME WHY THIS IS HAPPENING WHERE IS MY ERROR IN THE PROGRAM i will learn a lot when i get to know from my errors my insert function is void insert(int x){ struct node *temp=(struct node*)malloc(sizeof(head)); temp->data=x; temp->next=head; head=temp; }
0debug
No “Proceed Anyway” option on NET::ERR_CERT_INVALID in Chrome on MacOS : <p>I try to get my local development in Chrome back running, but Chrome prevents that, with the message that the certificate is invalid. Even though it could not be the date of the certificate, as you can see in the screenshot of it:</p> <p><a href="https://i.stack.imgur.com/EDHew.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EDHew.png" alt="enter image description here"></a></p> <p>I just wonder why there is no advanced > option to proceed anyway to see the website and being able to locally develop the app.</p> <p>A few more things to mention:</p> <ul> <li>The local development runs on <a href="https://local.app.somecompany.com:4200/" rel="noreferrer">https://local.app.somecompany.com:4200/</a>. It can't be just localhost, because otherwise our authentication http-only cookies won't work in Chrome.</li> <li>Therefore the host file under etc/hosts was adjusted to point to the localhost IP adress (127.0.0.1).</li> <li>The certificate was generated with openssl according to this <a href="https://medium.com/@rubenvermeulen/running-angular-cli-over-https-with-a-trusted-certificate-4a0d5f92747a" rel="noreferrer">tutorial</a> and this <a href="https://github.com/RubenVermeulen/generate-trusted-ssl-certificate" rel="noreferrer">repo</a></li> <li>The certificate works for a colleague with the exact same Chrome version but with a MacOS version 10.14.6 (mine right now is MacOS 10.15.1)</li> <li>The chrome flag(chrome://flags/#allow-insecure-localhost) does not change anything</li> <li>Also works in firefox on my laptop.</li> </ul> <p>Can't find anything online that helped me to solve this so far, so I would be extremly thankful, if anyone has some more ideas what I could try!?</p> <p>Specs:</p> <ul> <li>OS: MacOS 10.15.1</li> <li>Chrome: 78.0.3904.97</li> </ul>
0debug
how to use int[] in android java : <p>first i'm sorry ,i'm a newbie at this,so i confuse about java lang..</p> <p>if i have a function like this..</p> <pre><code>public static void sendRcOverrideMsg(drone, int[] rcOutputs) { msg_rc_channels_override msg = new msg_rc_channels_override(); msg.chan1_raw = (short) rcOutputs[0]; msg.chan2_raw = (short) rcOutputs[1]; msg.chan3_raw = (short) rcOutputs[2]; msg.chan4_raw = (short) rcOutputs[3]; msg.chan5_raw = (short) rcOutputs[4]; msg.chan6_raw = (short) rcOutputs[5]; msg.chan7_raw = (short) rcOutputs[6]; msg.chan8_raw = (short) rcOutputs[7]; msg.target_system = drone.getSysid(); msg.target_component = drone.getCompid(); drone.getMavClient().sendMessage(msg, null); } </code></pre> <p>how can i call that function.. i already call like this : </p> <p>sendRCOverrideMsg(drone, "//what should i fill in this int[]").. sry before, thanks, hopefully somebody can helm me at this.</p>
0debug
Trying to loop an action that will search through a specific range and look for a value in any cell in that range then paste a "y" in the active cell : Trying to loop an action that will search through a specific range and look for a value in any cell in that range then paste a "y" in the active cell This is what I have so far The range=rng.offset(1,0) is not working I need it to start at the set range and go down one row each loop[enter image description here][1] [1]: https://i.stack.imgur.com/VuAfW.jpg
0debug
I can't C# my errors : I get two errors "Cannot assign to 'C' because it's a 'foreach iteration variable" and "Syntax error, value expected" I don't really know where my error is? I can get some fresh on eyes to ID my deficiency. int[] numDictionary = new int[] { 5, 5, 5, 7, 7, 7, 9, 7, 9, 9, 9, 1 }; IDictionary<int, int> count = new SortedDictionary<int, int>(); count = new SortedDictionary<int, int>(); //int SortedDictionary = count; foreach (var c in numDictionary) { if (c > 0) { c = count; } count[c] = c[] + 1; } Console.WriteLine(count); Console.ReadKey();
0debug
Solve a Maze backtracking in C : I am trying to solve a maze using backtracking in c. Let me start with the rules of the maze . To solve the maze the following rules : - You begin from the position of S and need to go towards E - You can only go on '.' path - Convert all the '.' into '#' including S and E The input consists of a m x n matrix : Input example: 11 11 +-+-+-+-+-+ S.|...|...| +.+.+.+-+.+ |.|.|.....| +.+-+-+-+.+ |...|.|...| +.+.+.+.+-+ |.|...|.|.| +.+-+.+.+.+ |...|.....E +-+-+-+-+-+ Expected solution : +-+-+-+-+-+ ##|...|...| +#+.+.+-+.+ |#|.|.....| +#+-+-+-+.+ |###|.|...| +.+#+.+.+-+ |.|###|.|.| +.+-+#+.+.+ |...|###### +-+-+-+-+-+ I am trying really hard to solve it but for some reason my program doesn't go back once I reached a point in the maze from where I can't go further.It just go in all the directions where it sees a '.' My idea was to start from the position of S and using at each recursion step the old position that we were. I will go in all the direction from the position where I am standing if the position that I am looking at is a '.' and if that point was not my old position. I also think that I have a problem when i reach a point where it was a crossroad when I backtrack. For example: +-+-+-+-+-+ ##|...|...| +#+.+.+-+.+ |#|.|.....| +#+-+-+-+.+ |0##|.|...| +.+#+.+.+-+ |.|###|.|.| +.+-+#+.+.+ |..1|###### +-+-+-+-+-+ Imagine that I am in the position 0. And I backtracked from 1 changing back the # into '.'.How can I make a statement saying that you have 2 # possibilities to go back , yet you should stop? My code : #include <stdio.h> #include <stdlib.h> void *safeMalloc(int n) { void *p = malloc(n); if (p == NULL) { printf("Error: malloc(%d) failed. Out of memory?\n", n); exit(EXIT_FAILURE); } return p; } char ** readMatrix(int m,int n,int* startI,int* startJ,int* endI,int* endJ){ char **arr = safeMalloc(m*sizeof(char *)); int row; for (row=0; row < m; row++) { arr[row] = safeMalloc(n*sizeof(char)); } int i,j; for(i=0;i<m;i++){ for(j=0;j<m;j++){ scanf(" %c",&arr[i][j]); if(arr[i][j]=='S'){ *startI=i; *startJ=j; } if(arr[i][j]=='E'){ *endI=i; *endJ=j; } } getchar(); } return arr; } void printNumber(char **arr,int m,int n){ int i,j; for(i=0;i<m;i++){ for(j=0;j<n;j++){ printf("%c", arr[i][j]); } printf("\n"); } } void findPath(char** arr,int m,int n,int startI,int startJ,int endI,int endJ,int oldI,int oldJ){ int i=startI,j=startJ; int stepsPossible=4; //going up if(i-1>=0){ if((arr[i-1][j]=='.') && ((i-1!=oldI) || (j!=oldJ))){ arr[i][j]='#'; oldI=i; oldJ=j; findPath(arr,m,n,i-1,j,endI,endJ,oldI,oldJ); }else{ stepsPossible--; } } //going right if(j+1<n){ if((arr[i][j+1]=='.') && ((i!= oldI) || (j+1!=oldJ))){ arr[i][j]='#'; oldI=i; oldJ=j; findPath(arr,m,n,i,j+1,endI,endJ,oldI,oldJ); }else{ stepsPossible--; } } //going left if(j-1>=0){ if((arr[i][j-1]=='.') && ((i!= oldI) || (j-1!=oldJ))){ arr[i][j]='#'; oldI=i; oldJ=j; findPath(arr,m,n,i,j-1,endI,endJ,oldI,oldJ); }else{ stepsPossible--; } } //going down if(i+1<m){ if((arr[i+1][j]=='.') && ((i+1!= oldI) || (j!=oldJ))){ arr[i][j]='#'; oldI=i; oldJ=j; findPath(arr,m,n,i+1,j,endI,endJ,oldI,oldJ); }else{ stepsPossible--; } } //if the next block is E then we can stop. if((arr[i-1][j]=='E') || (arr[i][j+1]=='E') || (arr[i][j-1]=='E') || (arr[i+1][j]=='E')){ if(arr[i-1][j]=='E'){ arr[i-1][j]='#'; } if(arr[i][j+1]=='E'){ arr[i][j+1]='#'; } if(arr[i][j-1]=='E'){ arr[i][j-1]='#'; } if(arr[i+1][j]=='E'){ arr[i+1][j]='#'; } return; } if(stepsPossible==0){ if(arr[i-1][j]=='#'){ arr[i][j]='.'; oldI=i; oldJ=j; findPath(arr,m,n,i-1,j,endI,endJ,oldI,oldJ); }else{ return; } if(arr[i][j+1]=='#' ){ arr[i][j]='.'; oldI=i; oldJ=j; findPath(arr,m,n,i,j+1,endI,endJ,oldI,oldJ); }else{ return; } if(arr[i][j-1]=='#' ){ arr[i][j]='.'; oldI=i; oldJ=j; findPath(arr,m,n,i,j-1,endI,endJ,oldI,oldJ); }else{ return; } if(arr[i+1][j]=='#' ){ arr[i][j]='.'; oldI=i; oldJ=j; findPath(arr,m,n,i+1,j,endI,endJ,oldI,oldJ); }else{ return; } } } int main() { int m,n; scanf("%d %d",&m,&n); int startI,startJ,endI,endJ; char** arr; arr=readMatrix(m,n,&startI,&startJ,&endI,&endJ); findPath(arr,m,n,startI,startJ,endI,endJ,startI,startJ); printNumber(arr,m,n); return 0; }
0debug
why this show undefined in javaScript : <body> <html> <body> <p id="demo">Click the button to change the text in this paragraph.</p> <button onclick="myFunction()">Try it</button> <p id="para"></p> <script> var len ; function myFunction() { len = document.getElementById("demo").value() ; document.getElementById("demo").innerHTML = "Hello World"; document.getElementById("para").innerHTML = len ; } </script> </body> </html> I don't understand why this is saying that the len is undefined. Please help.
0debug
static int get_sot(Jpeg2000DecoderContext *s, int n) { Jpeg2000TilePart *tp; uint16_t Isot; uint32_t Psot; uint8_t TPsot; if (bytestream2_get_bytes_left(&s->g) < 8) Isot = bytestream2_get_be16u(&s->g); if (Isot) { avpriv_request_sample(s->avctx, "Support for more than one tile"); return AVERROR_PATCHWELCOME; } Psot = bytestream2_get_be32u(&s->g); TPsot = bytestream2_get_byteu(&s->g); bytestream2_get_byteu(&s->g); if (Psot > bytestream2_get_bytes_left(&s->g) + n + 2) { av_log(s->avctx, AV_LOG_ERROR, "Psot %d too big\n", Psot); } if (TPsot >= FF_ARRAY_ELEMS(s->tile[Isot].tile_part)) { avpriv_request_sample(s->avctx, "Support for %d components", TPsot); return AVERROR_PATCHWELCOME; } tp = s->tile[s->curtileno].tile_part + TPsot; tp->tile_index = Isot; tp->tp_len = Psot; tp->tp_idx = TPsot; if (JPEG2000_SOD == bytestream2_get_be16(&s->g)) { bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_len - n - 4); bytestream2_skip(&s->g, tp->tp_len - n - 4); } else { av_log(s->avctx, AV_LOG_ERROR, "SOD marker not found \n"); } return 0; }
1threat
Java exercise- family member : Hello my friends first of all sorry for my english :) I hang out in a question. I write a program that gives the how type of family members. forexample ; 0-3 age -baby 3-12-child 12-31 young etc. for this I used "if" this is my code ; Scanner keybord = new Scanner(System.in); int age = klavye.nextInt(); age =klavye.nextInt(); age =klavye.nextInt(); int count = 0, count1 = 0, count2 = 0, count3 = 0, count4 = 0; System.out.println("Enter the age of the family member : "); if (age >= 0 && age <= 3); count++; if(age >=4 && age <= 12); count1++; if (age >= 13 && age <= 30); count2++; if (age >= 31 && age <= 49); count3++; if (age >=50 && age <= 120); count4++; System.out.println(count+" "+ count3); // this to try to work "count" when i write 3 times "49" i want show count3 = 3 but showed just 1. Where is the problem ?
0debug
PyCharm change working directory of console : <p>How do I change the default working directory when I open a new Python Console? I have multiple projects open in my PyCharm view and the Python Console seems to be defaulting to an arbitrary one. Of course I can work around by modifying sys.path but I want a definite solution :) </p>
0debug
Two different soft with same ApplicationData folder : I have two different software that need to exchange data. This first one is a service, the second one is a guid. I want to use ApplicationData folder for this purpose. Is there a way to get the same path using `Environment.SpecialFolder.ApplicationData`for this two software ? Thanks for your help !
0debug
static void blockdev_mirror_common(BlockDriverState *bs, BlockDriverState *target, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, bool has_unmap, bool unmap, Error **errp) { if (!has_speed) { speed = 0; } if (!has_on_source_error) { on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_on_target_error) { on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_granularity) { granularity = 0; } if (!has_buf_size) { buf_size = 0; } if (!has_unmap) { unmap = true; } if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); return; } if (granularity & (granularity - 1)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2"); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { return; } if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_MIRROR_TARGET, errp)) { return; } if (target->blk) { error_setg(errp, "Cannot mirror to an attached block device"); return; } if (!bs->backing && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } mirror_start(bs, target, has_replaces ? replaces : NULL, speed, granularity, buf_size, sync, on_source_error, on_target_error, unmap, block_job_cb, bs, errp); }
1threat
Can someone tell me how to make this class FULLY immutable? : public final class Test { private final Date date; public Test() { date = new Date(); } public Test(Date date) { this.date = date; } public Date getDate() { return date; } public String toString() { return"Test:[date=" + date.toString() + "]"; } }
0debug
Understanding dictionary flashcard game errors : <p>I have defined a variable (show_definition) and have a dictionary (glossary).</p> <p>My end goal is to provide the user with a random definition of an unknown word, the user to answer in their head then provide them with an answer after the input of a button.</p> <pre><code>def show_definition(): """ Show the user a random defintion and ask them to define it. Show the flashcard when the user presses return. """ random_defin = choice(list(glossary.values())) print('Define: ', random_defin) input('Press return to see the definition') print(glossary.values()[random.defin]) </code></pre> <p>The first part works intially choosing a random value from the dictionary however I am completely misunderstanding how to then find the key which correlates to the value getting this error.</p> <p>TypeError: 'dict_values' object is not subscriptable. </p> <p>What am I not understanding here?</p>
0debug
static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { value &= 0x3fff; if (env->cp15.c15_cpar != value) { tb_flush(env); env->cp15.c15_cpar = value; } }
1threat
Tensorflow: Can't understand ctc_beam_search_decoder() output sequence : <p>I am using Tensorflow's <code>tf.nn.ctc_beam_search_decoder()</code> to decode the output of a RNN doing some many-to-many mapping (i.e., multiple softmax outputs for each network cell).</p> <p>A simplified version of the network's output and the Beam search decoder is:</p> <pre><code>import numpy as np import tensorflow as tf batch_size = 4 sequence_max_len = 5 num_classes = 3 y_pred = tf.placeholder(tf.float32, shape=(batch_size, sequence_max_len, num_classes)) y_pred_transposed = tf.transpose(y_pred, perm=[1, 0, 2]) # TF expects dimensions [max_time, batch_size, num_classes] logits = tf.log(y_pred_transposed) sequence_lengths = tf.to_int32(tf.fill([batch_size], sequence_max_len)) decoded, log_probabilities = tf.nn.ctc_beam_search_decoder(logits, sequence_length=sequence_lengths, beam_width=3, merge_repeated=False, top_paths=1) decoded = decoded[0] decoded_paths = tf.sparse_tensor_to_dense(decoded) # Shape: [batch_size, max_sequence_len] with tf.Session() as session: tf.global_variables_initializer().run() softmax_outputs = np.array([[[0.1, 0.1, 0.8], [0.8, 0.1, 0.1], [0.8, 0.1, 0.1], [0.8, 0.1, 0.1], [0.8, 0.1, 0.1]], [[0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7]], [[0.1, 0.7, 0.2], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7]], [[0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7], [0.1, 0.2, 0.7]]]) decoded_paths = session.run(decoded_paths, feed_dict = {y_pred: softmax_outputs}) print(decoded_paths) </code></pre> <p>The output in this case is:</p> <pre><code>[[0] [1] [1] [1]] </code></pre> <p>My understanding is that the output tensor should be of dimensions <code>[batch_size, max_sequence_len]</code>, with each row containing the indices of the relevant classes in the found path.</p> <p>In this case I would expect the output to be similar to:</p> <pre><code>[[2, 0, 0, 0, 0], [2, 2, 2, 2, 2], [1, 2, 2, 2, 2], [2, 2, 2, 2, 2]] </code></pre> <p>What am I not understanding about how <code>ctc_beam_search_decoder</code> works?</p>
0debug
static void sun4m_fdc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->props = sun4m_fdc_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); }
1threat
Javascript/jquery : Count monday in a given date range : please help me to count the Monday in a given date range using javascript or jquery, date range like (2016-02-22 to 2016-02-29). I searched a lot but in the last I got nothing. Thanks in advance
0debug
Is it possible to have multiple virtual machines in a vmware so that i can form a local network? : <p>I'm trying to setup a distributed system for my development test and learning. I have a vmware workstation and would like to install multiple machines(at least 2) and form a network, so that I can install HDP, Cassandra and do some testing. I know it could be a memory overhead but just want to see the possibility? </p> <p>Thanks, Ash</p>
0debug
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) { if (*spec <= '9' && *spec >= '0') return strtol(spec, NULL, 0) == st->index; else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || *spec == 't') { enum AVMediaType type; switch (*spec++) { case 'v': type = AVMEDIA_TYPE_VIDEO; break; case 'a': type = AVMEDIA_TYPE_AUDIO; break; case 's': type = AVMEDIA_TYPE_SUBTITLE; break; case 'd': type = AVMEDIA_TYPE_DATA; break; case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; } if (type != st->codec->codec_type) return 0; if (*spec++ == ':') { int i, index = strtol(spec, NULL, 0); for (i = 0; i < s->nb_streams; i++) if (s->streams[i]->codec->codec_type == type && index-- == 0) return i == st->index; return 0; } return 1; } else if (*spec == 'p' && *(spec + 1) == ':') { int prog_id, i, j; char *endptr; spec += 2; prog_id = strtol(spec, &endptr, 0); for (i = 0; i < s->nb_programs; i++) { if (s->programs[i]->id != prog_id) continue; if (*endptr++ == ':') { int stream_idx = strtol(endptr, NULL, 0); return stream_idx >= 0 && stream_idx < s->programs[i]->nb_stream_indexes && st->index == s->programs[i]->stream_index[stream_idx]; } for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) if (st->index == s->programs[i]->stream_index[j]) return 1; } return 0; } else if (!*spec) return 1; av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); return AVERROR(EINVAL); }
1threat
understand the pointer pointer in c++ to get the function call : <p>I am little confused about the pointer statement in the following code. The purpose of the pointer is to access the virtual function from virtual table.here is link of the article. <a href="http://kaisar-haque.blogspot.com/2008/07/c-accessing-virtual-table.html" rel="nofollow noreferrer">http://kaisar-haque.blogspot.com/2008/07/c-accessing-virtual-table.html</a></p> <pre><code>1 #include &lt;iostream&gt; 2 3 using namespace std; 4 5 //a simple class 6 class X 7 { 8 public: 9 //fn is a simple virtual function 10 virtual void fn() 11 { 12 cout &lt;&lt; "n = " &lt;&lt; n &lt;&lt; endl; 13 } 14 15 //a member variable 16 int n; 17 }; 18 19 int main() 20 { 21 //create an object (obj) of class X 22 X *obj = new X(); 23 obj-&gt;n = 10; 24 25 //get the virtual table pointer of object obj 26 int* vptr = *(int**)obj; 27 28 // we shall call the function fn, but first the following assembly code 29 // is required to make obj as 'this' pointer as we shall call 30 // function fn() directly from the virtual table 31 __asm 32 { 33 mov ecx, obj 34 } 35 36 //function fn is the first entry of the virtual table, so it's vptr[0] 37 ( (void (*)()) vptr[0] )(); 38 39 //the above is the same as the following 40 //obj-&gt;fn(); 41 42 return 0; 43 } 44 </code></pre> <p>so, i want to know the how to understand the line number 26.</p>
0debug
How to pass a PHP string as JS function parameter? : <p>I have this PHP code who send an URL as argument to a JS function :</p> <pre><code>&lt;?php $url="www.google.com"; echo '&lt;input type="submit" name="btnfone" onclick="window.open('.$url.')" class="btn-style2" value="Viewmap"/&gt;'; ?&gt; </code></pre> <p>When I test it, nothing append. But if I change the URL with an integer</p> <pre><code>$url=1234; </code></pre> <p>Then the argument is interpreted.</p> <p>What's the solution ?</p>
0debug
static void unterminated_dict_comma(void) { QObject *obj = qobject_from_json("{'abc':32,", NULL); g_assert(obj == NULL); }
1threat
how to use a condition while creating a table in sql : I'd like to create a table with a condition create table TOTO ( Id int not null, zip as (if(zip > '00999' and zip < '96000') then zip) , PRIMARY KEY (Id) ); All I get is an error message. Do you know how to do that with the "zip" in type char ? Thank you for your help !
0debug
array function C / C++ : I have tried to look for the solution to my problem but I didnt find anything so this is my question I want to do a function that return an array in C/C++, for example: #include "iostream" #include "string" using namespace std; void minus(float v1[3], float v2[3], float v3[3][3]); int main() { float a[3] = {1,0,0}; float b[3] = {3,2,5}; float c[3]; minus(a,b,c); cout << c[0] << "C1" << endl; cout << c[1] << "C2" << endl; cout << c[2] << "C3" << endl; cin.get(); return 0; } void minus(float v1[3], float v2[3], float v3[3]) { int i; float aux; for (i = 0; i < 2; i++) { v3[i]=v1[i]-v2[i]; return; } } The error is "[Error] cannot convert 'float*' to 'float (*)[3]' for argument '3' to 'void rectavector(float*, float*, float (*)[3])'" I dont understand this error. I am returning v3 per reference
0debug
Sorting Multidimensional slices in golang : Wanted to sort a nested slice (asc to desc) based on int values ,however the slice remains unaffected. Below is the short snippet of what I was trying. ``` type Rooms struct { type string total string } CombinedRooms := make([][]Rooms) // sort by price for i, _ := range CombinedRooms { sort.Slice(CombinedRooms[i], func(j, k int) bool { netRateJ, _ := strconv.Atoi(CombinedRooms[i][j].Total) netRateK, _ := strconv.Atoi(CombinedRooms[i][k].Total) return netRateJ < netRateK }) } ``` The Slice CombinedRooms remains unaffected even after the sorting func.
0debug
When does AWS CloudWatch create new log streams? : <p>AWS CloudWatch has Log Groups and Log streams. A log group seems reasonable to me: Each product (e.g. each Lambda function, each Sagemaker endpoint) has its own log group.</p> <p>But then there are log streams. <strong>When does AWS CloudWatch create new log streams?</strong> Can I search all log streams of a log group?</p>
0debug
Bootstrap4 Responsive Table - Fixed first column : <p>I'm creating a schedule table with events and hours, so I need to fix the first column when table is horizontally scrolling. This will help users to see the hour of the event more easily. I'm using Bootstrap 4. Screenshot of the table: <a href="http://prntscr.com/japkbc" rel="noreferrer">http://prntscr.com/japkbc</a>.</p> <p>Best Regards</p>
0debug
please help me to access all this characters json by react.js : please help me how to access this all characters ---------------- data: [ { "url": "https://www.anapioficeandfire.com/api/characters/823", "name": "Petyr Baelish", "culture": "Valemen", "born": "In 268 AC, at the Fingers", "died": "", "titles": [ "Master of coin (formerly)", "Lord Paramount of the Trident", "Lord of Harrenhal", "Lord Protector of the Vale" ], "aliases": [ "Littlefinger" ], "father": "", "mother": "", "spouse": "https://www.anapioficeandfire.com/api/characters/688", "allegiances": [ "https://www.anapioficeandfire.com/api/houses/10", "https://www.anapioficeandfire.com/api/houses/11" ], "books": [ "https://www.anapioficeandfire.com/api/books/1", ], "povBooks": [], "tvSeries": [ "Season 1", "Season 2", "Season 3", "Season 4", "Season 5" ], "playedBy": [ "Aidan Gillen" ] } ] render() { var { data } = this.state; return ( <div> <h1>Sample data block</h1> {this.state.data.map(function(item, i) { return <h3 key={'data-'+ i}>{data.title}</h3> })} </div> ); }
0debug
how to get multiple chekcbox names using selenium : Kindly help me for below url for above question? http://www.javascriptsource.com/forms/check-uncheck-multiple-checkboxes.html
0debug
MultiIndex Slicing requires the index to be fully lexsorted : <p>I have a data frame with index (<code>year</code>, <code>foo</code>), where I would like to select the X largest observations of <code>foo</code> where <code>year == someYear</code>.</p> <p>My approach was </p> <pre><code>df.sort_index(level=[0, 1], ascending=[1, 0], inplace=True) df.loc[pd.IndexSlice[2002, :10], :] </code></pre> <p>but I get</p> <pre><code>KeyError: 'MultiIndex Slicing requires the index to be fully lexsorted tuple len (2), lexsort depth (0)' </code></pre> <p>I tried different variants of sorting (e.g. <code>ascending = [0, 0]</code>), but they all resulted in some sort of error.</p> <p>If I only wanted the <code>xth</code> row, I could <code>df.groupby(level=[0]).nth(x)</code> after sorting, but since I want a set of rows, that doesn't feel quite efficient.</p> <p>What's the best way to select these rows? Some data to play with:</p> <pre><code> rank_int rank year foo 2015 1.381845 2 320 1.234795 2 259 1.148488 199 2 0.866704 2 363 0.738022 2 319 </code></pre>
0debug
How do I Mock RouterStateSnapshot for a Router Guard Jasmine test : <p>I have a simple router guard and I am trying to test the <code>canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot )</code>. I can create the ActivatedRouteSnapshot like this <code>new ActivatedRouteSnapshot()</code> but I cannot figure out how to create a mocked <code>RouterStateSnapshot</code>.</p> <p>Per the code I tried...</p> <pre><code>let createEmptyStateSnapshot = function( urlTree: UrlTree, rootComponent: Type&lt;any&gt;){ const emptyParams = {}; const emptyData = {}; const emptyQueryParams = {}; const fragment = ''; const activated = new ActivatedRouteSnapshot(); const state = new RouterStateSnapshot(new TreeNode&lt;ActivatedRouteSnapshot&gt;(activated, [])); return { state: state, activated: activated } } </code></pre> <p>But <code>import {TreeNode} from "@angular/router/src/utils/tree";</code> seems to need to be transpiled or something because I get...</p> <blockquote> <p>Uncaught SyntaxError: Unexpected token export at webpack:///~/@angular/router/src/utils/tree.js:8:0 &lt;- test.bundle.ts:72431</p> </blockquote>
0debug
why it result in a NullPointerException when Object is null? : <p>when objec is null:</p> <pre><code>if(object != null &amp;&amp; object.string.equals("")) { System.out.println("no error"); } </code></pre> <p>it will result in NullPointerException, and why if it checks the first result is false, it still check the second instead of stop check and print "no error"? sorry for my bad english -_-#</p>
0debug
Hello! I can't seem to figure out this nested loop pattern C++ : //DrawTriangle("VOTE", true) E TE OTE VOTE I figured out: //DrawTriangle("VOTE", false) VOTE OTE TE E Here's what I got so far: cout << "Please enter your WORD: "; cin >> word; cout << endl; int wordLength = word.length(); //UP TRI WORD if (trDirection == 1) { //UP TRI TO DO } //DOWN TRI WORD else if (trDirection == 2) { for (int row = 0; row <= wordLength; row++) { for (int i = row; i < wordLength; i++) { cout << word[i]; } cout << endl; } } } I appreciate any and all help with this. Thanks.
0debug
One-to-many relation in Room : <p>I've been using SugarDB for most of my projects in the past. It was easy to use and satisfied most of my requirements but since that project has been abandoned, decided to look at alternatives and Room seems like the best option.</p> <p>However, some basic things are quite confusing in Room. My Object uses Gson to populate data from a webservice, and as such as links to other objects. As an example, consider the classes below:</p> <pre><code>@Entity public class TestModel { @PrimaryKey(autoGenerate = true) private int id; private String name; private String age; private List&lt;Book&gt; issuedBooks; } public class Book { private String title; private int ISBN; } </code></pre> <p>Now if my first class is annotated as the Entity, will this automatically treat classes referenced inside it as entities as well?</p> <p>If I save an object of TestModel, will it save the list of Books with it to the database?</p>
0debug
HTML input on firefox is not displaying text that set as black : <p><a href="http://secure.gethope.net" rel="nofollow">On Firefox text color in inout is not visible </a></p> <p>while text is visible on other browsers. </p>
0debug
static void init_proc_750cx (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_7xx(env); spr_register(env, SPR_L2CR, "L2CR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, NULL, 0x00000000); gen_tbl(env); gen_spr_thrm(env); spr_register(env, SPR_SDA, "SDA", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(env); gen_high_BATs(env); init_excp_750cx(env); env->dcache_line_size = 32; env->icache_line_size = 32; ppc6xx_irq_init(env); }
1threat
update using get the records from html form code not working : <p><a href="https://i.stack.imgur.com/6tTre.jpg" rel="nofollow noreferrer">This is the php code thats getting the record from view </a></p> <p><a href="https://i.stack.imgur.com/YBZqI.jpg" rel="nofollow noreferrer">the html code</a></p> <p><a href="https://i.stack.imgur.com/ocCXA.jpg" rel="nofollow noreferrer">the update code which z not working</a></p>
0debug
static int16_t long_term_filter(DSPContext *dsp, int pitch_delay_int, const int16_t* residual, int16_t *residual_filt, int subframe_size) { int i, k, tmp, tmp2; int sum; int L_temp0; int L_temp1; int64_t L64_temp0; int64_t L64_temp1; int16_t shift; int corr_int_num, corr_int_den; int ener; int16_t sh_ener; int16_t gain_num,gain_den; int16_t sh_gain_num, sh_gain_den; int gain_num_square; int16_t gain_long_num,gain_long_den; int16_t sh_gain_long_num, sh_gain_long_den; int16_t best_delay_int, best_delay_frac; int16_t delayed_signal_offset; int lt_filt_factor_a, lt_filt_factor_b; int16_t * selected_signal; const int16_t * selected_signal_const; int16_t sig_scaled[SUBFRAME_SIZE + RES_PREV_DATA_SIZE]; int16_t delayed_signal[ANALYZED_FRAC_DELAYS][SUBFRAME_SIZE+1]; int corr_den[ANALYZED_FRAC_DELAYS][2]; tmp = 0; for(i=0; i<subframe_size + RES_PREV_DATA_SIZE; i++) tmp |= FFABS(residual[i]); if(!tmp) shift = 3; else shift = av_log2(tmp) - 11; if (shift > 0) for (i = 0; i < subframe_size + RES_PREV_DATA_SIZE; i++) sig_scaled[i] = residual[i] >> shift; else for (i = 0; i < subframe_size + RES_PREV_DATA_SIZE; i++) sig_scaled[i] = residual[i] << -shift; gain_num = 0; ener = dsp->scalarproduct_int16(sig_scaled + RES_PREV_DATA_SIZE, sig_scaled + RES_PREV_DATA_SIZE, subframe_size); if (ener) { sh_ener = FFMAX(av_log2(ener) - 14, 0); ener >>= sh_ener; corr_int_num = 0; best_delay_int = pitch_delay_int - 1; for (i = pitch_delay_int - 1; i <= pitch_delay_int + 1; i++) { sum = dsp->scalarproduct_int16(sig_scaled + RES_PREV_DATA_SIZE, sig_scaled + RES_PREV_DATA_SIZE - i, subframe_size); if (sum > corr_int_num) { corr_int_num = sum; best_delay_int = i; } } if (corr_int_num) { corr_int_den = dsp->scalarproduct_int16(sig_scaled - best_delay_int + RES_PREV_DATA_SIZE, sig_scaled - best_delay_int + RES_PREV_DATA_SIZE, subframe_size); for (k = 0; k < ANALYZED_FRAC_DELAYS; k++) { ff_acelp_interpolate(&delayed_signal[k][0], &sig_scaled[RES_PREV_DATA_SIZE - best_delay_int], ff_g729_interp_filt_short, ANALYZED_FRAC_DELAYS+1, 8 - k - 1, SHORT_INT_FILT_LEN, subframe_size + 1); } tmp = corr_int_den; for (k = 0; k < ANALYZED_FRAC_DELAYS; k++) { sum = dsp->scalarproduct_int16(&delayed_signal[k][1], &delayed_signal[k][1], subframe_size - 1); corr_den[k][0] = sum + delayed_signal[k][0 ] * delayed_signal[k][0 ]; corr_den[k][1] = sum + delayed_signal[k][subframe_size] * delayed_signal[k][subframe_size]; tmp = FFMAX3(tmp, corr_den[k][0], corr_den[k][1]); } sh_gain_den = av_log2(tmp) - 14; if (sh_gain_den >= 0) { sh_gain_num = FFMAX(sh_gain_den, sh_ener); delayed_signal_offset = 1; best_delay_frac = 0; gain_den = corr_int_den >> sh_gain_den; gain_num = corr_int_num >> sh_gain_num; gain_num_square = gain_num * gain_num; for (k = 0; k < ANALYZED_FRAC_DELAYS; k++) { for (i = 0; i < 2; i++) { int16_t gain_num_short, gain_den_short; int gain_num_short_square; sum = dsp->scalarproduct_int16(&delayed_signal[k][i], sig_scaled + RES_PREV_DATA_SIZE, subframe_size); gain_num_short = FFMAX(sum >> sh_gain_num, 0); gain_num_short_square = gain_num_short * gain_num_short; gain_den_short = corr_den[k][i] >> sh_gain_den; tmp = MULL(gain_num_short_square, gain_den, FRAC_BITS); tmp2 = MULL(gain_num_square, gain_den_short, FRAC_BITS); if (tmp > tmp2) { gain_num = gain_num_short; gain_den = gain_den_short; gain_num_square = gain_num_short_square; delayed_signal_offset = i; best_delay_frac = k + 1; } } } L64_temp0 = (int64_t)gain_num_square << ((sh_gain_num << 1) + 1); L64_temp1 = ((int64_t)gain_den * ener) << (sh_gain_den + sh_ener); if (L64_temp0 < L64_temp1) gain_num = 0; } } } if (!gain_num) { memcpy(residual_filt, residual + RES_PREV_DATA_SIZE, subframe_size * sizeof(int16_t)); return 0; } if (best_delay_frac) { ff_acelp_interpolate(residual_filt, &sig_scaled[RES_PREV_DATA_SIZE - best_delay_int + delayed_signal_offset], ff_g729_interp_filt_long, ANALYZED_FRAC_DELAYS + 1, 8 - best_delay_frac, LONG_INT_FILT_LEN, subframe_size + 1); sum = dsp->scalarproduct_int16(residual_filt, sig_scaled + RES_PREV_DATA_SIZE, subframe_size); if (sum < 0) { gain_long_num = 0; sh_gain_long_num = 0; } else { tmp = FFMAX(av_log2(sum) - 14, 0); sum >>= tmp; gain_long_num = sum; sh_gain_long_num = tmp; } sum = dsp->scalarproduct_int16(residual_filt, residual_filt, subframe_size); tmp = FFMAX(av_log2(sum) - 14, 0); sum >>= tmp; gain_long_den = sum; sh_gain_long_den = tmp; L_temp0 = gain_num * gain_num; L_temp0 = MULL(L_temp0, gain_long_den, FRAC_BITS); L_temp1 = gain_long_num * gain_long_num; L_temp1 = MULL(L_temp1, gain_den, FRAC_BITS); tmp = ((sh_gain_long_num - sh_gain_num) << 1) - (sh_gain_long_den - sh_gain_den); if (tmp > 0) L_temp0 >>= tmp; else L_temp1 >>= -tmp; if (L_temp1 > L_temp0) { selected_signal = residual_filt; gain_num = gain_long_num; gain_den = gain_long_den; sh_gain_num = sh_gain_long_num; sh_gain_den = sh_gain_long_den; } else selected_signal = &delayed_signal[best_delay_frac-1][delayed_signal_offset]; if (shift > 0) for (i = 0; i < subframe_size; i++) selected_signal[i] <<= shift; else for (i = 0; i < subframe_size; i++) selected_signal[i] >>= -shift; selected_signal_const = selected_signal; } else selected_signal_const = residual + RES_PREV_DATA_SIZE - (best_delay_int + 1 - delayed_signal_offset); #ifdef G729_BITEXACT tmp = sh_gain_num - sh_gain_den; if (tmp > 0) gain_den >>= tmp; else gain_num >>= -tmp; if (gain_num > gain_den) lt_filt_factor_a = MIN_LT_FILT_FACTOR_A; else { gain_num >>= 2; gain_den >>= 1; lt_filt_factor_a = (gain_den << 15) / (gain_den + gain_num); } #else L64_temp0 = ((int64_t)gain_num) << (sh_gain_num - 1); L64_temp1 = ((int64_t)gain_den) << sh_gain_den; lt_filt_factor_a = FFMAX((L64_temp1 << 15) / (L64_temp1 + L64_temp0), MIN_LT_FILT_FACTOR_A); #endif lt_filt_factor_b = 32767 - lt_filt_factor_a + 1; ff_acelp_weighted_vector_sum(residual_filt, residual + RES_PREV_DATA_SIZE, selected_signal_const, lt_filt_factor_a, lt_filt_factor_b, 1<<14, 15, subframe_size); return 1; }
1threat
Ruby- Issues with opening an image using .system and .exec : My goal is to make a program that can open image files in the default image viewer (in this case, the Windows 10 Photos app) and close them again at specific user input. The following line has been giving me heaps of problems and confusions: `Kernel.system('full_path_to_image')` I attempted the same with `.exec`, but it simply returns the format error (Errno::ENOEXEC) Simply entering the file path as a command into the Command Interpreter works just fine, even if it's done by using `Kernel.system('cmd')` to open an instance of the intepreter, _then_ entering the file path. I've read some other answers to questions that talked about shell expansion, and avoiding the shell entirely by using the multi-argument version of `.system`, but I couldn't get that to work and I feel that I'm missing something obvious, or doing something wrong here. Is it even possible to do what I want to do? (If the info is of any use, my file path contains backslashes, not standard slashes, although replacing them doesn't seem to change anything anyway.)
0debug
C# JSON Deserialization Errror : All..I have a simple JSON file { "code": 0, "message": "success", "items": [ { "item_id": "1186247000000062086", "name": "18 Holes", "unit": "Each", "status": "active", "source": "user", "is_linked_with_zohocrm": false, "zcrm_product_id": "", "description": "", "rate": 25, "tax_id": "", "tax_name": "", "tax_percentage": 0, "purchase_description": "", "purchase_rate": 0, "is_combo_product": false, "item_type": "inventory", "product_type": "goods", "stock_on_hand": 10000000, "available_stock": 10000000, "actual_available_stock": 10000000, "sku": "1", "upc": "", "ean": "", "isbn": "", "part_number": "", "reorder_level": 0, "image_name": "", "image_type": "", "created_time": "2018-02-17T08:13:25-0800", "last_modified_time": "2018-02-17T08:13:25-0800" } ], "page_context": { "page": 1, "per_page": 200, "has_more_page": false, "report_name": "Items", "applied_filter": "Status.All", "custom_fields": [], "sort_column": "name", "sort_order": "A" } } I have used the following code to place it into a dd box var Products = JsonConvert.DeserializeObject<dynamic>(responseString.ToString()); List<SelectListItem> Product_List = new List<SelectListItem>(); foreach (var item in Products) { Product_List.Add(new SelectListItem() { Text = item.items.name, Value = "1" }); } ViewBag.Product = Product_List; return View(); Seems simple, but I keep getting the following error. 'Newtonsoft.Json.Linq.JProperty' does not contain a definition for 'items' I have used this in the exact same way for a different JSON record with success...any thoughts?
0debug
Way to know the width of the text in SKLabelNode : <p>Is there a way to know the width of a "SKLabelNode" in Sprite Kit ? </p> <p>OR I should use SKSpriteNode then use text inside it </p>
0debug
is there any way to restict the data into table if it is already present : I have an sp which when triggered, data will be inserted into the data. if the data being inserted is already present oin the table, I don't want the data to be inserted into the table. is there anyway i could use a logic to restrict the data into table. my query is declare @ident int = IDENT_CURRENT( 'SADEV.RO_Transcript.ETQueueCtrl' ) insert into SADEV.RO_Transcript.ETQueueCtrl ([STU_ID],[STU_ORD_SEQ_NUM],[CreatedDate],[LastUpdatedDate],[ETQueueCtrlStatusCd],[ErrorFl]) select STU_ID ,STU_ORD_SEQ_NUM ,getdate() ,getdate() ,[ETQueueCtrlStatusCd] = 'N' ,'N' from srdb_sr2_qa.dbo.SR0ROT rt where STU_ORD_TYP_CD = 'A' and ORD_DLVY_MTHD_CD = 'ET' and STU_ORD_STAT_CD = 'C' --and convert(varchar(1),STU_ORD_XPDT_FL) = @stu_ord_xpdt_fl and case when @stu_ord_xpdt_fl = 'y' then GETDATE() else case when ORD_PEND_INST_CD = '' then STU_ORD_SBM_DT+ DATEADD (mi,480,STU_ORD_SBM_TM) else LAST_UPD_DT+ DATEADD (mi,480,LAST_UPD_TM) end end <= GETDATE() select et.ETQueueCtrlID, ro.STU_ID, ro.STU_ORD_SEQ_NUM, ty.CAREER_CD, ty.CAREER_SUFX_CD from SADEV.RO_Transcript.ETQueueCtrl et join srdb_sr2_qa.dbo.SR0ROT ro on et.STU_ID = ro.STU_ID and et.STU_ORD_SEQ_NUM = ro.STU_ORD_SEQ_NUM left join srdb_sr2_qa.dbo.SR0TYT ty on ro.STU_ID = ty.STU_ID where et.ETQueueCtrlID > @ident
0debug
SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, qemu_irq irq, int baudbase, CharDriverState *chr, int ioregister) { SerialState *s; int s_io_memory; s = qemu_mallocz(sizeof(SerialState)); if (!s) return NULL; s->irq = irq; s->base = base; s->it_shift = it_shift; s->baudbase= baudbase; s->tx_timer = qemu_new_timer(vm_clock, serial_tx_done, s); if (!s->tx_timer) return NULL; qemu_register_reset(serial_reset, s); serial_reset(s); register_savevm("serial", base, 2, serial_save, serial_load, s); if (ioregister) { s_io_memory = cpu_register_io_memory(0, serial_mm_read, serial_mm_write, s); cpu_register_physical_memory(base, 8 << it_shift, s_io_memory); } s->chr = chr; qemu_chr_add_handlers(chr, serial_can_receive1, serial_receive1, serial_event, s); return s; }
1threat
Add And Remove Character in a String : <p><strong>Problem:</strong> I would like add characters to a phone.</p> <p>So instead of displaying ###-###-####, I would like to display (###) ###-####.</p> <p>I tried the following:</p> <pre><code>string x = "Phone_Number"; string y = x.Remove(0,2);//removes the "1-" string z = y.Insert(0,"("); z = z.Insert(4,")"); </code></pre> <p>From here, I am not sure how I would remove the first "-" so it displays the following:(###) ###-####</p> <p>Any help would be appreciated.</p>
0debug
static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){ int i, ret= -1; int av_unused mm_flags = av_get_cpu_flags(); int need_emms= 0; if (c->compensation_distance) dst_size = FFMIN(dst_size, c->compensation_distance); for(i=0; i<dst->ch_count; i++){ #if HAVE_MMXEXT_INLINE #if HAVE_SSE2_INLINE if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_SSE2)) ret= swri_resample_int16_sse2 (c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); else #endif if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_MMX2 )){ ret= swri_resample_int16_mmx2 (c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); need_emms= 1; } else #endif if(c->format == AV_SAMPLE_FMT_S16P) ret= swri_resample_int16(c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); else if(c->format == AV_SAMPLE_FMT_S32P) ret= swri_resample_int32(c, (int32_t*)dst->ch[i], (const int32_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #if HAVE_AVX_INLINE else if(c->format == AV_SAMPLE_FMT_FLTP && (mm_flags&AV_CPU_FLAG_AVX)) ret= swri_resample_float_avx (c, (float*)dst->ch[i], (const float*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif #if HAVE_SSE_INLINE else if(c->format == AV_SAMPLE_FMT_FLTP && (mm_flags&AV_CPU_FLAG_SSE)) ret= swri_resample_float_sse (c, (float*)dst->ch[i], (const float*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif else if(c->format == AV_SAMPLE_FMT_FLTP) ret= swri_resample_float(c, (float *)dst->ch[i], (const float *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #if HAVE_SSE2_INLINE else if(c->format == AV_SAMPLE_FMT_DBLP && (mm_flags&AV_CPU_FLAG_SSE2)) ret= swri_resample_double_sse2(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif else if(c->format == AV_SAMPLE_FMT_DBLP) ret= swri_resample_double(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); if(need_emms) emms_c(); return ret;
1threat
Firebase Analytics for web apps (after Firebase expansion) : <p>I am building a web application with Firebase and yesterday they released their expansion with all great new features. However, the Analytics section is now only available for Android and IOS apps, but I need to check the general performances and data usage of my web app as before. Is there a way to see those statistics, to prevent my app of being turned off if I exceed my limits? </p>
0debug
void ff_put_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_16w_msa(src + stride - 2, src - (stride * 2), stride, dst, stride, 16); }
1threat
Is there a way I can stick this into a for loop? [JAVA] : is there anyway that I can stick this in a for loop??? This is part of the logic for a ticTacToe game, I am checking the button clicked via ActionListener, then I am checking for a boolean value, and thats how I determine wether to place an X or O. if(src == b1){ if(firstPlayer){ b1.setIcon(playerO); firstPlayer = false; } else { b1.setIcon(playerX); firstPlayer = true; } } I want to change the b1 to b2, b3, b4, and so on until I get to b9. I have nine buttons that i need to check. 3X3 grid. Right now, I have copied and pasted this 9 times, then I changed the button to the one I need, but thats bad practice, and the code is repetitive. Thanks in advanced!
0debug
function is deprecated in php 7.2.2, how to fix it? : <pre><code>function selectLecturer($lecturer_id) { $sql=mysqli_query($con,"SELECT * FROM lecturer WHERE id='$lecturer_id'"); $row=mysqli_fetch_array($sql); echo $row['name']." ".$row['surname']; } selectLecturer(1); </code></pre> <p>This was working in old PHP version, I upgrade my server to php 7.2.2, this function code is not working, How can i fix it?</p>
0debug