problem
stringlengths
26
131k
labels
class label
2 classes
How to train a RNN with LSTM cells for time series prediction : <p>I'm currently trying to build a simple model for predicting time series. The goal would be to train the model with a sequence so that the model is able to predict future values.</p> <p>I'm using tensorflow and lstm cells to do so. The model is trained with truncated backpropagation through time. My question is how to structure the data for training.</p> <p>For example let's assume we want to learn the given sequence:</p> <pre><code>[1,2,3,4,5,6,7,8,9,10,11,...] </code></pre> <p>And we unroll the network for <code>num_steps=4</code>.</p> <p><strong>Option 1</strong></p> <pre><code>input data label 1,2,3,4 2,3,4,5 5,6,7,8 6,7,8,9 9,10,11,12 10,11,12,13 ... </code></pre> <p><strong>Option 2</strong></p> <pre><code>input data label 1,2,3,4 2,3,4,5 2,3,4,5 3,4,5,6 3,4,5,6 4,5,6,7 ... </code></pre> <p><strong>Option 3</strong></p> <pre><code>input data label 1,2,3,4 5 2,3,4,5 6 3,4,5,6 7 ... </code></pre> <p><strong>Option 4</strong></p> <pre><code>input data label 1,2,3,4 5 5,6,7,8 9 9,10,11,12 13 ... </code></pre> <p>Any help would be appreciated.</p>
0debug
Python remove some alphabet from a string : <p>Python newb here. I have a string as 'July 27, 2019' I want output as 'Jul. 27, 2019' Please let me know how can I achieve the same.</p>
0debug
def binary_to_integer(test_tup): res = int("".join(str(ele) for ele in test_tup), 2) return (str(res))
0debug
Issue with String Extension in C# : <p>I am trying to make a simple string extension that assigns the changes to the original string (like toUpper).In this case, the method is assigning the contents to a second argument if it is neither white space nor null...otherwise, it leaves the current value in place, or assigns a null value to "". So, I would like to have it go:</p> <pre><code>somerecord.Property1.func(someobj.property); somerecord.Property2.func(someobj.otherproperty); somerecord.Property3.func(someobj.anotherproperty); </code></pre> <p>while my code looks like</p> <pre><code> public static string func(this String str, string replacement) { if (!String.IsNullOrWhiteSpace(replacement)) { str = replacement; return replacement; } else { if(str == null) str = ""; return ""; } } </code></pre> <p>I wanted to set <code>this</code> to <code>ref</code> but I can't. Any ideas on how to implement this cleanly?</p>
0debug
require_tree argument must be a directory in a Rails 5 upgraded app : <p>I just upgraded my app from <code>Rails 4.2.7</code> to <code>Rails 5.0.0.1</code>. I used <a href="http://railsdiff.org/4.2.7/5.0.0.1" rel="noreferrer">RailsDiff</a> to make sure I had everything covered and I believe I did. So far everything has worked well up until the loading of my app. </p> <p>Now I am seeing this error:</p> <pre><code>Sprockets::ArgumentError at / require_tree argument must be a directory </code></pre> <p>This is my <code>application.css</code>:</p> <pre><code>/* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require_tree . *= require_self */ </code></pre> <p>This is my <code>application.js</code></p> <pre><code>// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . </code></pre> <p>This is what the server log looks like:</p> <pre><code>Started GET "/" for ::1 at 2016-09-02 09:08:19 -0500 ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations" User Load (1.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]] Processing by ProfilesController#index as HTML Rendering profiles/index.html.erb within layouts/application Profile Load (1.6ms) SELECT "profiles".* FROM "profiles" Rendered profiles/index.html.erb within layouts/application (45.8ms) Completed 500 Internal Server Error in 367ms (ActiveRecord: 6.3ms) DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1@myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:7) DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:8) Sprockets::ArgumentError - require_tree argument must be a directory: sprockets (3.7.0) lib/sprockets/directive_processor.rb:182:in `rescue in block in process_directives' sprockets (3.7.0) lib/sprockets/directive_processor.rb:179:in `block in process_directives' sprockets (3.7.0) lib/sprockets/directive_processor.rb:178:in `process_directives' </code></pre> <p>I am using no plugins of any kind. It is a fairly simple/vanilla app. The only styling is from the default <code>scaffold.scss</code>.</p> <p>What could be causing this?</p>
0debug
static void qobject_input_optional(Visitor *v, const char *name, bool *present) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, false, NULL); if (!qobj) { *present = false; return; } *present = true; }
1threat
Why don't the two programmes on fibonnaci sequence give similar output yet intuitively they seem similar : http://pastebin.com/raw/s4wahXVK The above snippet contains two programmes ,one from the python docs the other from intuitive me, I thought they would both produce similar results but the former outputs 1 1 2 3 5 8 and the latter 1 2 4 8 ...a good Samaritan kindly explain why?
0debug
Get keys in JSON : <p>I get the following JSON result from an external system:</p> <pre><code>{ "key1": "val1", "key2": "val2", "key3": "val3" } </code></pre> <p>Now I want to display all keys and all values by using JSONPath. So I am looking for something to get key1, key2 and key3 as a result. Additionally I would like to use the index of a property, e. g. <code>$....[2].key</code> to get "key3" etc. Is there a way to do something like this?</p>
0debug
void kvmppc_check_papr_resize_hpt(Error **errp) { if (!kvm_enabled()) { return; } error_setg(errp, "Hash page table resizing not available with this KVM version"); }
1threat
static void subband_scale(int *dst, int *src, int scale, int offset, int len) { int ssign = scale < 0 ? -1 : 1; int s = FFABS(scale); unsigned int round; int i, out, c = exp2tab[s & 3]; s = offset - (s >> 2); if (s > 31) { for (i=0; i<len; i++) { dst[i] = 0; } } else if (s > 0) { round = 1 << (s-1); for (i=0; i<len; i++) { out = (int)(((int64_t)src[i] * c) >> 32); dst[i] = ((int)(out+round) >> s) * ssign; } } else { s = s + 32; round = 1U << (s-1); for (i=0; i<len; i++) { out = (int)((int64_t)((int64_t)src[i] * c + round) >> s); dst[i] = out * ssign; } } }
1threat
Should I use logging in a C++ library : <p>So I am asking about a general advise on the topic. I'm developing a C++ library for numerical computation, however trough development I found it useful for debugging when there is an issue to have a flag which to enables some form of logging done so that I can inspect what is going wrong. My question is what are the acceptable standards on this? Should I define some macro for DEBUG so that if its not define no DEBUGs happen? Should I use a logging library and log stuff.</p>
0debug
How to transform a data frame in structured streaming? : I am testing structured streaming using localhost from which it reads streams of data. Input streaming data from localhost: ID Subject Marks 1 Maths 85 1 Physics 80 2 Maths 70 2 Physics 80 I would like to get the average marks for each unique ID's. I tried this but not able to transform the DF which is a single value. Below is my partial code: from pyspark.sql import SparkSession from pyspark.sql.functions import * from pyspark.sql.types import * spark = SparkSession.builder.appName("SrteamingMarks").getOrCreate() marks = spark.readStream.format("socket").option("host", "localhost").option("port", 9999).load() marks.printSchema() root |-- value: string (nullable = true) My expected output is just 2 columns (ID and Average Marks) ID Average Marks 1 82.5 2 75
0debug
How to fix 'Use of unassigned local variable' in C# : <p>I am new to C#, my last programming language was C</p> <p>I kept getting Use of unassigned local variable 'average' The <code>average</code> it is pertaining was the <code>average /= 10;</code></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int i, average; int[] scores = new int[10]; Console.WriteLine("Enter 10 scores"); for (i = 0; i &lt; 10; i++) { scores[i] = Convert.ToInt32(Console.ReadLine()); } for (i = 0; i &lt; 10; i++) { average = scores[i] + scores[i + 1]; i++; } average /= 10; Console.WriteLine("Average of All the Scores: {0}", average); Console.Read(); } } } </code></pre>
0debug
ArrayList<String> objects point to null. Why? : <p>I have a piece of code that takes in an <code>ArrayList&lt;String&gt;</code> object and eventually takes that object and adds it to a <code>HashMap</code> object as the key. When I print the hashmap, the key's are all null while the values are correct.</p> <p>I already know I can fix the code by passing in a copy of the <code>ArrayList&lt;String&gt;</code> object and that fixes my issue (i.e. <code>buildHash(new ArrayList&lt;String&gt;(key))</code>. But why does it point to null otherwise?</p> <pre class="lang-java prettyprint-override"><code>HashMap&lt;ArrayList&lt;String&gt;, ArrayList&lt;String&gt;&gt; hash = new HashMap&lt;&gt;(); ArrayList&lt;String&gt; key = new ArrayList&lt;String&gt;(); for (int i = 0; i &lt;= 9999999; i++) { key.add(//different strings depending on the iteration); if ( !hash.contains(key) ) { buildHash(key); } key.clear(); } private void buildHash(ArrayList&lt;String&gt; key) { ArrayList&lt;String&gt; follows = new ArrayList&lt;String&gt;(); for (int index = 0; index &lt;= 9999999; index++) { // add stuff to follows... } hash.put(key, follows); } </code></pre> <p>I thought that the value of the key would be added to the hash, and the hash's keys would point to the value it was before it was cleared by <code>key.clear()</code>. That way I could reuse key over and over without creating another object in memory. </p> <p>I'm new to Java (and coding) so I'm probably naive, but I thought I could save memory by utilizing the mutability of <code>ArrayLists</code> as opposed to <code>Lists</code> as the number of operations and key's generated for this project are well into the millions, if not more. Is there no avoiding that? And if not, is there any other optimization I could do?</p>
0debug
dynamically adding a property name to a typescript interface : <p>I have a constant: </p> <pre><code>const name = 'some/property'; </code></pre> <p>I'd like to define an interface that uses name as a key for a property in a similar way to using it in an object declaration like so:</p> <pre><code>{[name]: 'Bob'} </code></pre> <p>I tried the following, but it seems that this is doing something else:</p> <pre><code>interface MyInterface { [name]: string; } </code></pre> <p>is dynamically defining property names supported in typescript?</p>
0debug
linux - created duplicate root user, cant login anymore.. what do i do? : <p>i became over zealous and ran the command here</p> <p><a href="http://www.shellhacks.com/en/HowTo-Create-USER-with-ROOT-Privileges-in-Linux" rel="nofollow">http://www.shellhacks.com/en/HowTo-Create-USER-with-ROOT-Privileges-in-Linux</a></p> <pre><code>useradd -ou 0 -g 0 john passwd john </code></pre> <p>now i try to connect the way i usually do</p> <pre><code>ssh -i yok.pem root@staging.yok.com -vv </code></pre> <p>and I'm getting</p> <pre><code>debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to staging.yok.com [23.23.77.124] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file yok.pem type -1 debug1: key_load_public: No such file or directory debug1: identity file yok.pem-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.9 </code></pre> <p>i luckily still have one connection to the server open.. i checked my ~/.ssh folder and the files all have 600 permissions.</p> <p>what do i need to do here im stuck :(</p>
0debug
static int rtc_load_td(QEMUFile *f, void *opaque, int version_id) { RTCState *s = opaque; if (version_id != 1) return -EINVAL; s->irq_coalesced = qemu_get_be32(f); s->period = qemu_get_be32(f); rtc_coalesced_timer_update(s); return 0; }
1threat
Data Structure ,Pointers : i made a queue in c using pointers ,my code works but i can not understand how the pointer variable rear1 is works ,because every time function called ,rear1 is initialized and same for front ,front store the address of start for first time then after front reinitailize but it still keep start address ,how is it possible. enter code here #include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, ("pause") or input loop */ struct node{ int data; struct node *next; }; enqueue(struct node **start){ struct node *front,*rear; if (*start==NULL){ *start=(struct node *)malloc(sizeof(struct node)); scanf("%d",&(*start)->data); (*start)->next=NULL; printf("%s","hello"); front=(*start); rear=*start; } else { printf("%d",front->data); struct node *temp,*curr; curr=(struct node *)malloc(sizeof(struct node)); rear->next=curr; rear=curr; rear->next=NULL; scanf("%d",&rear->data); } } dequeue(struct node **front){ struct node *temp; temp=(*front); (*front)=(*front)->next; printf("%d",(temp->data)); free(temp); } int main(int argc, char *argv[]) { struct node *start=NULL; enqueue(&start); enqueue(&start); enqueue(&start); enqueue(&start); enqueue(&start); enqueue(&start); dequeue(&start); printf("\n"); dequeue(&start); printf("\n"); dequeue(&start); printf("\n"); dequeue(&start); printf("\n"); dequeue(&start); printf("\n"); dequeue(&start); return 0; }
0debug
CANT ACCESS SESSION VARIABLES OUTSIDE SUBMIT BUTTON CODE : Hello Everyone I am a beginner in php.Ihave a problem in accessing session variables outside the code for submit button.when i am printing the session variable within submit code it is printing but at the time of echoing outside submit code it is not printing the value of date .Actually i want to insert the value of session variable in database but it is not getting inserted .the code is given below: <!Doctype html> <?php session_start(); $_SESSION['date']=''; include 'connect.php'; ?> <form> Date: <input type='date' name='date'> <br> <input type='submit' name='submit'> </form> <?php $date=''; if(isset($_POST['submit'] )) { $date=$_POST['date']; $_SESSION['bdate']=$date; echo $_SESSION['bdate']; } ?> <?php echo $_SESSION['date']; ?> Any help will be greatly appreciated. Thanks , Nilanjana Maiti.
0debug
React JSX file giving error "Cannot read property 'createElement' of undefined" : <p>I have a file test_stuff.js that I am running with <code>npm test</code></p> <p>It pretty much looks like this:</p> <pre><code>import { assert } from 'assert'; import { MyProvider } from '../src/index'; import { React } from 'react'; const myProvider = ( &lt;MyProvider&gt; &lt;/MyProvider&gt; ); describe('Array', function() { describe('#indexOf()', function() { it('should return -1 when the value is not present', function() { assert.equal(-1, [1,2,3].indexOf(4)); }); }); }); </code></pre> <p>Unfortunately, I get the error</p> <pre><code>/Users/me/projects/myproj/test/test_stuff.js:11 var myProvider = _react.React.createElement(_index.MyProvider, null); ^ TypeError: Cannot read property 'createElement' of undefined at Object.&lt;anonymous&gt; (/Users/me/projects/myproj/test/test_stuff.js:7:7) </code></pre> <p>What does that mean? I am importing React from 'react' successfully, so why would React be undefined? It is _react.React, whatever that means...</p>
0debug
When to use promise.all()? : <p>This is more of a conceptual question. I understand the Promise design pattern, but couldn't find a reliable source to answer my question about <code>promise.all()</code>:</p> <h3>What is(are) the correct scenario(s) to use <code>promise.all()</code></h3> <p>OR</p> <h3>Are there any best practices to use <code>promise.all()</code>? Should it be ideally used only if all of the promise objects are of the same or similar types?</h3> <p>The only one I could think of is:</p> <ul> <li>Use <code>promise.all()</code> if you want to resolve the promise <strong>only</strong> if <strong>all</strong> of the promise objects resolve and reject if even one rejects.</li> </ul>
0debug
Method to query data from Oracle database in C# : <p>Currently I'm using the following method to get data from Oracle database and return it to <code>DataTable</code>:</p> <pre><code>private static DataTable OraSelect(string cmdString) { string conString = ConfigurationManager.AppSettings["dbconnection"]; OracleConnection oraCon = new OracleConnection(conString); OracleCommand oraCmd = new OracleCommand(cmdString, oraCon); OracleDataAdapter oraDA = new OracleDataAdapter(oraCmd.CommandText, oraCon); DataTable dt = new DataTable(); oraCon.Open(); oraDA.Fill(dt); oraCon.Close(); return dt; } </code></pre> <p>Visual Studio displays the following warning: "OracleConnection has been deprecated." </p> <p>I think that's not the best way to do this. Could you give me some examples about how to get data from an Oracle database with a better method?</p>
0debug
spring/application.rb:161 undefined method `reject!' for nil:NilClass (NoMethodError) : <p>I am using ruby 2.5 and rails 5.0.1 for my application. when i try to run console or generate controller or migration it gives me this error:</p> <p><code>Running via Spring preloader in process 6473 Loading development environment (Rails 5.0.1) Traceback (most recent call last): /home/abwahed/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.1/lib/spring/application.rb:161:in</code>fork': undefined method <code>reject!' for nil:NilClass (NoMethodError)</code></p>
0debug
Border not showing in CSS even after labeling them !important : <p>Here is the code for this particular <code>div</code>:</p> <pre><code>.generated_text { display: inline-block; width: 50px; font-family:'Gudea' !important; text-align: left; color:#000 !important; background:#fff !important; border: 30px !important; border-color: #4b4b4b !important; position: absolute; top: 54%; left: 38.5%; margin: -150px 0 0 -150px; width:560px; height:170px; } </code></pre> <p>Here is the result: <a href="https://i.stack.imgur.com/qNVen.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qNVen.png" alt="enter image description here"></a></p> <p>Note, I'm very new when it comes to web dev. Any help would be much appreciated and let me know if i'm missing anything in this post. </p>
0debug
Visual Studio mouse click event : <p>I need a quick and simple (I hope) solution for my C# Windows Form application.</p> <p>How can I make a <code>Mouse Down</code> event that occurs every time I click anywhere in my form (not a specific object)?</p>
0debug
def loss_amount(actual_cost,sale_amount): if(sale_amount > actual_cost): amount = sale_amount - actual_cost return amount else: return None
0debug
Do I use Node.js to build a whole website? : <p>The last couple of days I began to teach myself how to create a Website from scratch.</p> <p>I bought a webspace and fooled around with html, css and javascript and when I wanted to build a online chess game I learned about Node.js</p> <p>But I don't understand what Node.js is used for because the <a href="https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_http" rel="nofollow noreferrer">documentation</a> shows how to install and create a fresh server(!) with Node.js and handle requests. </p> <ul> <li><p>Do I don't have to use a apache installation on my server anymore? </p></li> <li><p>Do I create the whole website and all it's pages with Node.js like the index or about page? </p></li> <li><p>If I use Node.js just for a web application, how can I add the web app to an already existing Apache website's page?</p></li> </ul> <p>I think I really got confused and need some help to understand Node.js better since so many are using it.</p>
0debug
int cpu_restore_state(TranslationBlock *tb, CPUState *env, unsigned long searched_pc, void *puc) { TCGContext *s = &tcg_ctx; int j; unsigned long tc_ptr; #ifdef CONFIG_PROFILER int64_t ti; #endif #ifdef CONFIG_PROFILER ti = profile_getclock(); #endif tcg_func_start(s); if (gen_intermediate_code_pc(env, tb) < 0) return -1; tc_ptr = (unsigned long)tb->tc_ptr; if (searched_pc < tc_ptr) return -1; s->tb_next_offset = tb->tb_next_offset; #ifdef USE_DIRECT_JUMP s->tb_jmp_offset = tb->tb_jmp_offset; s->tb_next = NULL; #else s->tb_jmp_offset = NULL; s->tb_next = tb->tb_next; #endif j = dyngen_code_search_pc(s, (uint8_t *)tc_ptr, (void *)searched_pc); if (j < 0) return -1; while (gen_opc_instr_start[j] == 0) j--; #if defined(TARGET_I386) { int cc_op; #ifdef DEBUG_DISAS if (loglevel & CPU_LOG_TB_OP) { int i; fprintf(logfile, "RESTORE:\n"); for(i=0;i<=j; i++) { if (gen_opc_instr_start[i]) { fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]); } } fprintf(logfile, "spc=0x%08lx j=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n", searched_pc, j, gen_opc_pc[j] - tb->cs_base, (uint32_t)tb->cs_base); } #endif env->eip = gen_opc_pc[j] - tb->cs_base; cc_op = gen_opc_cc_op[j]; if (cc_op != CC_OP_DYNAMIC) env->cc_op = cc_op; } #elif defined(TARGET_ARM) env->regs[15] = gen_opc_pc[j]; #elif defined(TARGET_SPARC) { target_ulong npc; env->pc = gen_opc_pc[j]; npc = gen_opc_npc[j]; if (npc == 1) { } else if (npc == 2) { target_ulong t2 = (target_ulong)(unsigned long)puc; if (t2) env->npc = gen_opc_jump_pc[0]; else env->npc = gen_opc_jump_pc[1]; } else { env->npc = npc; } } #elif defined(TARGET_PPC) { int type, c; env->nip = gen_opc_pc[j]; c = gen_opc_buf[j]; switch(c) { #if defined(CONFIG_USER_ONLY) #define CASE3(op)\ case INDEX_op_ ## op ## _raw #else #define CASE3(op)\ case INDEX_op_ ## op ## _user:\ case INDEX_op_ ## op ## _kernel:\ case INDEX_op_ ## op ## _hypv #endif CASE3(stfd): CASE3(stfs): CASE3(lfd): CASE3(lfs): type = ACCESS_FLOAT; break; CASE3(lwarx): type = ACCESS_RES; break; CASE3(stwcx): type = ACCESS_RES; break; CASE3(eciwx): CASE3(ecowx): type = ACCESS_EXT; break; default: type = ACCESS_INT; break; } env->access_type = type; } #elif defined(TARGET_M68K) env->pc = gen_opc_pc[j]; #elif defined(TARGET_MIPS) env->PC[env->current_tc] = gen_opc_pc[j]; env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags |= gen_opc_hflags[j]; #elif defined(TARGET_ALPHA) env->pc = gen_opc_pc[j]; #elif defined(TARGET_SH4) env->pc = gen_opc_pc[j]; env->flags = gen_opc_hflags[j]; #endif #ifdef CONFIG_PROFILER dyngen_restore_time += profile_getclock() - ti; dyngen_restore_count++; #endif return 0; }
1threat
how to create an app tour/walkthrough in cordova? : <blockquote> <p>I want to create an app tour/walkthrough for my cordova project. I have tried bootstrap tour ,but it is not like native android tour/walkthrough .</p> </blockquote>
0debug
static guint io_add_watch_poll(GIOChannel *channel, IOCanReadHandler *fd_can_read, GIOFunc fd_read, gpointer user_data) { IOWatchPoll *iwp; iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll)); iwp->fd_can_read = fd_can_read; iwp->opaque = user_data; iwp->src = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP); g_source_set_callback(iwp->src, (GSourceFunc)fd_read, user_data, NULL); return g_source_attach(&iwp->parent, NULL); }
1threat
find the index i of a sorted array y[:], such that y[i-1] <= x <y[i] : <pre><code>getindex(x,y) </code></pre> <p><strong>Input:</strong> a value <code>x</code>, and a sorted array <code>y[:]</code> (no repeat element)</p> <p><strong>Output:</strong> the index <code>i</code>, such that <code>y[i-1] &lt;= x &lt;y[i]</code></p> <p>The time complexity should be <strong>O(log(N))</strong></p> <p>Is there a Python/Numpy function we can use?</p> <p><strong>For example:</strong></p> <pre><code>y[0]=-0.2 y[1]=1.5 y[2]=1.9 y[3]=3.2 </code></pre> <p>Then</p> <p><code>getindex(-4.0,y)</code> returns 0</p> <p><code>getindex(0.5,y)</code> returns 1</p> <p><code>getindex(6.0,y)</code> returns 4</p>
0debug
int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { ssize_t ret; NBDClientSession *client = nbd_get_client_session(bs); NBDRequest request = { .type = NBD_CMD_WRITE_ZEROES, .from = offset, .len = count, }; NBDReply reply; if (!(client->nbdflags & NBD_FLAG_SEND_WRITE_ZEROES)) { return -ENOTSUP; } if (flags & BDRV_REQ_FUA) { assert(client->nbdflags & NBD_FLAG_SEND_FUA); request.flags |= NBD_CMD_FLAG_FUA; } if (!(flags & BDRV_REQ_MAY_UNMAP)) { request.flags |= NBD_CMD_FLAG_NO_HOLE; } nbd_coroutine_start(client, &request); ret = nbd_co_send_request(bs, &request, NULL); if (ret < 0) { reply.error = -ret; } else { nbd_co_receive_reply(client, &request, &reply, NULL); } nbd_coroutine_end(bs, &request); return -reply.error; }
1threat
Column repeat direction in microsoft report viewer : <p>I am using windows form to generate Identity Card using c# and Microsoft report viewer. Everything is working fine except I could not find column repeat direction in Microsoft report viewer. </p> <p><strong>Current Scenario</strong></p> <p>My report paper size is A4. Each page can display maximum 10 individual cards. There are 2 columns in page. Each column display 5 cards. It is generating card as shown in image. The column repeat direction is vertically. It first list 1st column (1-5) and then list 2nd column (6-10).</p> <p><a href="https://i.stack.imgur.com/dXnog.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dXnog.png" alt="enter image description here"></a></p> <p><strong>My Requirement</strong></p> <p>I want the report column repeat direction to be horizontally like in the image below. First display 1 then 2 and 3 and 4 and so on.</p> <p><a href="https://i.stack.imgur.com/E2lIr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E2lIr.png" alt="enter image description here"></a></p> <p><strong>Why I want to display horizontally rather than vertically?</strong></p> <p>It will save the paper. For example, if the user generate 4 Identity cards only then as per current scenario, it will generate 4 cards in column 1 and the whole page space is wasted because I can not re-use the left space. </p> <p>By repeating the column direction to horizontally, the 4 cards will be displayed as in column 1, card 1 and 3 and in column 2, card 2 and 4 will be displayed. I can then cut the paper and reuse it later.</p> <p>I have searched alot but could not find any solution. Any suggestion, comments or links will be helpful. I can not use any other reports. Thanks in advance.</p>
0debug
static void calc_slice_sizes(VC2EncContext *s) { int slice_x, slice_y; SliceArgs *enc_args = s->slice_args; for (slice_y = 0; slice_y < s->num_y; slice_y++) { for (slice_x = 0; slice_x < s->num_x; slice_x++) { SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x]; args->ctx = s; args->x = slice_x; args->y = slice_y; args->bits_ceil = s->slice_max_bytes << 3; args->bits_floor = s->slice_min_bytes << 3; memset(args->cache, 0, MAX_QUANT_INDEX*sizeof(*args->cache)); } } s->avctx->execute(s->avctx, rate_control, enc_args, NULL, s->num_x*s->num_y, sizeof(SliceArgs)); }
1threat
How to use a primary key as FK in another table for 2 columns with different name for each column? : when I was trying to insert values to table Emps. I was required to insert 3. One For City_Id,departure_City_Id, and arrival_City_Id. I just want to insert to departure_City_Id, and arrival_City_Id. Please not: Values must be related to the PK in City table. Thanks in advance . CREATE TABLE City ( City_Id char(3), state varchar(30), Primary key (City_Id) ); create table Emps ( Emp_number varchar(30) primary key, City_Id char(3),--Foreign Key departure_City_Id char(3), arrival_City_Id char(3), FOREIGN KEY (City_Id) REFERENCES City(City_Id), FOREIGN KEY (City_Id) REFERENCES City(City_Id) );
0debug
static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, Error **errp) { SocketAddress *saddr = NULL; QDict *addr = NULL; QObject *crumpled_addr = NULL; Visitor *iv = NULL; Error *local_err = NULL; qdict_extract_subqdict(options, &addr, "server."); if (!qdict_size(addr)) { error_setg(errp, "NBD server address missing"); goto done; } crumpled_addr = qdict_crumple(addr, errp); if (!crumpled_addr) { goto done; } iv = qobject_input_visitor_new(crumpled_addr); visit_type_SocketAddress(iv, NULL, &saddr, &local_err); if (local_err) { error_propagate(errp, local_err); goto done; } done: QDECREF(addr); qobject_decref(crumpled_addr); visit_free(iv); return saddr; }
1threat
static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, int n, bool assign) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtQueue *vq = virtio_get_queue(vdev, n); bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY); bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); bool fast_mmio = kvm_ioeventfd_any_length_enabled(); bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY; MemoryRegion *modern_mr = &proxy->notify.mr; MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr; MemoryRegion *legacy_mr = &proxy->bar; hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * virtio_get_queue_index(vq); hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY; if (assign) { if (modern) { if (fast_mmio) { memory_region_add_eventfd(modern_mr, modern_addr, 0, false, n, notifier); } else { memory_region_add_eventfd(modern_mr, modern_addr, 2, false, n, notifier); } if (modern_pio) { memory_region_add_eventfd(modern_notify_mr, 0, 2, true, n, notifier); } } if (legacy) { memory_region_add_eventfd(legacy_mr, legacy_addr, 2, true, n, notifier); } } else { if (modern) { if (fast_mmio) { memory_region_del_eventfd(modern_mr, modern_addr, 0, false, n, notifier); } else { memory_region_del_eventfd(modern_mr, modern_addr, 2, false, n, notifier); } if (modern_pio) { memory_region_del_eventfd(modern_notify_mr, 0, 2, true, n, notifier); } } if (legacy) { memory_region_del_eventfd(legacy_mr, legacy_addr, 2, true, n, notifier); } } return 0; }
1threat
React efficiently update object in array with useState hook : <p>I have a React component that renders a moderately large list of inputs (100+ items). It renders okay on my computer, but there's noticeable input lag on my phone. The React DevTools shows that the entire parent object is rerendering on every keypress.</p> <p>Is there a more efficient way to approach this?</p> <p><a href="https://codepen.io/anon/pen/YMvoyy?editors=0011" rel="noreferrer">https://codepen.io/anon/pen/YMvoyy?editors=0011</a></p> <pre><code>function MyInput({obj, onChange}) { return ( &lt;div&gt; &lt;label&gt; {obj.label} &lt;input type="text" value={obj.value} onChange={onChange} /&gt; &lt;/label&gt; &lt;/div&gt; ); } // Passed in from a parent component const startingObjects = new Array(100).fill(null).map((_, i) =&gt; ({label: i, value: 'value'})); function App() { const [objs, setObjects] = React.useState(startingObjects); function handleChange(obj) { return (event) =&gt; setObjects(objs.map((o) =&gt; { if (o === obj) return {...obj, value: event.target.value} return o; })); } return ( &lt;div&gt; {objs.map((obj) =&gt; &lt;MyInput obj={obj} onChange={handleChange(obj)} /&gt;)} &lt;/div&gt; ); } const rootElement = document.getElementById("root"); ReactDOM.render(&lt;App /&gt;, rootElement); </code></pre>
0debug
How can I remove a property from an object? : <p>I have this object:</p> <pre><code> {"wordFormId":"abandon", "wordFormIdentity":1, "ascii":97, "wordId":"abandon", "primary":true, "posId":2} </code></pre> <p>How can I remove the ascii property? I know I could set it to null but I assume it would then still be there. What I would like to do is to completely remove it.</p>
0debug
Kubernetes - sharing secret across namespaces : <p>Is there a way to share secrets across namespaces in Kubernetes?</p> <p>My use case is: I have the same private registry for all my namespaces and I want to avoid creating the same secret for each.</p> <p>Thanks for your help.</p>
0debug
Division with returning quotient and remainder : <p>I try to migrate from Python to Golang. I currently do research some math operations and wonder about how can I get both quotient and remainder value with result of a division. I'm going to share below an equivalent of Python code.</p> <pre><code>hours, remainder = divmod(5566, 3600) minutes, seconds = divmod(remainder, 60) print('%s:%s' % (minutes, seconds)) # 32:46 </code></pre> <p>Above will be my aim. Thanks.</p>
0debug
def coin_change(S, m, n): table = [[0 for x in range(m)] for x in range(n+1)] for i in range(m): table[0][i] = 1 for i in range(1, n+1): for j in range(m): x = table[i - S[j]][j] if i-S[j] >= 0 else 0 y = table[i][j-1] if j >= 1 else 0 table[i][j] = x + y return table[n][m-1]
0debug
C# List implementation : <p>I am not very good at data structures but I wanna try to implement in C# List class with method Add that's the only method that I need and I can't figure it out what to do next I only have this piece of code</p> <pre><code>public class myList&lt;T&gt; : List&lt;T&gt; { public T[] items; public int size; public myList() { items = new T[0]; } public myList(int dim) { items = new T[dim]; } public new void Add(T item) { items[size++] = item; } } </code></pre> <p>I am also use inheritance to List because I don't want to implement other things(interfaces).With this code that I have something is missing when I am trying to see what I add to the list(foreach) I can't see nothing. Can anyone help me please?</p>
0debug
How to access the value of an input disabled? : <p>I'm creating a reactive form in angular 2 and using material angular 2 to inputs;</p> <p>I need to set an input as disabled and when submitting the value that is in the unlocked input the value to be sent. I Already created the input and the disabled is running. My problem is that when I give a submit value it does not come.</p> <p>My code</p> <pre><code>this.formVariacao = this._fb.group({ id:[p &amp;&amp; p['id']], codigoItem: [p &amp;&amp; p['codigoItem'], Validators.required], }); </code></pre> <p>My html</p> <pre><code>&lt;md-input-container&gt; &lt;input mdInput placeholder="Código da Variação" formControlName="codigoItem" name="codigoItem"&gt; &lt;/md-input-container&gt; </code></pre> <p>I block the input as follows</p> <pre><code>this.formVariacao.get('codigoItem').disable(); </code></pre> <p>Only when I send the form the value does not come. Alguém pode me ajudar?</p>
0debug
int main(void) { int x = 0; int i, j; AVLFG state; av_lfg_init(&state, 0xdeadbeef); for (j = 0; j < 10000; j++) { START_TIMER for (i = 0; i < 624; i++) { x += av_lfg_get(&state); } STOP_TIMER("624 calls of av_lfg_get"); } av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x); { double mean = 1000; double stddev = 53; av_lfg_init(&state, 42); for (i = 0; i < 1000; i += 2) { double bmg_out[2]; av_bmg_get(&state, bmg_out); av_log(NULL, AV_LOG_INFO, "%f\n%f\n", bmg_out[0] * stddev + mean, bmg_out[1] * stddev + mean); } } return 0; }
1threat
Why does modulus return these values? : <p>5%5 is 0</p> <p>5%4 is 1</p> <p>5%3 is 2</p> <p>5%2 is 1</p> <p>5%1 is 0</p> <p>Why is that? From my understanding modulus just prints out whether or not it has a remainder but I'm apparently wrong here.</p> <p>also 5%10 prints out 5, and "%10" seems to consistently print out the last number of any value. 123%10 is 3 for some reason.</p> <p>What's the deal here?</p> <pre><code>x = 5%2; y = 123%10; </code></pre>
0debug
blockchain - Student Management System - Custom Data Structure : <p>I'm new to blockchain and trying to learn the same. I'm creating Student Management System, wherein students will enroll themselves in training program, these training program will have batch associated. I'm trying to build a basic data structure for this requirement.</p> <p>Please suggest, if I can have all these information as part of blockchain's block or keep student, training prg and batch information as private storage i.e each entity will have separate storage, and have the blockchain block to store only the ID's of each object i.e. student id, training prog id and batch id for which student has enrolled?</p> <p>Please suggest.</p>
0debug
How to know the text files developed in particular OS like UNIX or Windows using Java : I want to know the which Operating System(EX:UNIX or Windows or MAC) is used to Develop Text File and it's File Format(EX:UTF-8 or ANSI or DOS) by using Java.If I read one text file using Java Application, I want to know which Operating System is used to develop that File and it's File Format.How to do this using Java Application.Please give me some suggestions.
0debug
int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; int32 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0x9E; if ( 0 <= shiftCount ) { if ( a != 0xCF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; } return (sbits32) 0x80000000; } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig = ( aSig | 0x00800000 )<<8; z = aSig>>( - shiftCount ); if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
1threat
Share credentials between native app and web site : <p>An application I'm working on allows users to log into an OAuth-enabled backend. The application is therefore privy only to the authentication tokens and user metadata, not to the user's credentials.</p> <p>Within the application, users can hit links that open up links in a browser. These resources are also protected by OAuth, and the token obtained during login to the native app is also relevant to the web.</p> <p>I would like the user's credentials to flow from the native app to the web browser in the standard OAuth manner (by including it as an <code>Authorization</code> header).</p> <p>It seems that Android facilitates this through its <a href="https://developers.google.com/identity/smartlock-passwords/android/associate-apps-and-sites" rel="noreferrer">shared credentials</a> feature, but I cannot find an equivalent for iOS. I did find the <a href="https://developer.apple.com/reference/security/shared_web_credentials" rel="noreferrer">shared web credentials</a> feature, but that seems to require knowledge of the user's credentials.</p> <p>How can I flow OAuth tokens from my native app through to web browsers that it opens?</p>
0debug
How to copy files from local machine to docker container on windows : <p>I have to import data files from a user local file C:/users/saad/bdd to a docker container (cassandra), I didn't find how to proceed using docker commands. I'm working on windows 7.</p> <p>Many thanks for your help </p>
0debug
Matrix possibilities in javascript : **Hello** As you can see in my gist bellow, i have 03 different properties in a object or array (I could use anyone of this as input), and I have to discover all the possibilites of combination between them. In this case, we just have 03 properties, but we can easily have more than 20 props ... how could i implement this in a smart way? Thinking in a bigger amount of data ... https://gist.github.com/matheus-rossi/c0261d1d8e138475c049f500fb2616fa const configPossibilities = [ [ 1 ], [ 1, 2 ], [ 1, 2, 3, 4 ] ] const configPossibilities2 = { ID_LINHA: [ 1 ], ID_IMPLEMENTO: [ 1 , 2 ], ID_COMPOSICAO: [ 1 , 2 , 3 , 4 ] } const desiredResult = [ [1, 1, 1 ], [1, 1, 2 ], [1, 1, 3 ], [1, 1, 4 ], [1, 2, 1 ], [1, 2, 2 ], [1, 2, 3 ], [1, 1, 4 ], ]
0debug
static av_cold int cinvideo_decode_init(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; unsigned int i; cin->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; for (i = 0; i < 3; ++i) { cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); } return 0; }
1threat
PHP WTF??? (string) comparing : I'm very VERY confused!! var_dump('12345678901234567891' == '12345678901234567890'); shows `bool(true)`! I know about "===" but in this example two strings (types are same)!!! Any suggestions?
0debug
static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, int l1_size, int64_t *visited_l1_entries, int64_t l1_entries, BlockDriverAmendStatusCB *status_cb, void *cb_opaque) { BDRVQcow2State *s = bs->opaque; bool is_active_l1 = (l1_table == s->l1_table); uint64_t *l2_table = NULL; int ret; int i, j; if (!is_active_l1) { l2_table = qemu_try_blockalign(bs->file->bs, s->cluster_size); if (l2_table == NULL) { return -ENOMEM; } } for (i = 0; i < l1_size; i++) { uint64_t l2_offset = l1_table[i] & L1E_OFFSET_MASK; bool l2_dirty = false; uint64_t l2_refcount; if (!l2_offset) { (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries, cb_opaque); } continue; } if (offset_into_cluster(s, l2_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#" PRIx64 " unaligned (L1 index: %#x)", l2_offset, i); ret = -EIO; goto fail; } if (is_active_l1) { ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void **)&l2_table); } else { ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); } if (ret < 0) { goto fail; } ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, &l2_refcount); if (ret < 0) { goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); int64_t offset = l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry); bool preallocated = offset != 0; if (cluster_type != QCOW2_CLUSTER_ZERO) { continue; } if (!preallocated) { if (!bs->backing) { l2_table[j] = 0; l2_dirty = true; continue; } offset = qcow2_alloc_clusters(bs, s->cluster_size); if (offset < 0) { ret = offset; goto fail; } if (l2_refcount > 1) { ret = qcow2_update_cluster_refcount(bs, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); if (ret < 0) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_OTHER); goto fail; } } } if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset " "%#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, j); if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } ret = -EIO; goto fail; } ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } ret = bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, 0); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } if (l2_refcount == 1) { l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED); } else { l2_table[j] = cpu_to_be64(offset); } l2_dirty = true; } if (is_active_l1) { if (l2_dirty) { qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); } else { if (l2_dirty) { ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size); if (ret < 0) { goto fail; } ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); if (ret < 0) { goto fail; } } } (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries, cb_opaque); } } ret = 0; fail: if (l2_table) { if (!is_active_l1) { qemu_vfree(l2_table); } else { qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); } } return ret; }
1threat
The .on('click') jquery event doesn't work on a dinamyc list box : I'd like to know why, and how to solve it, when I click on an option of my multiple list box... `$(document).on("click, id", function () { //some code });` doesn't work Here is my html code <div class="box"> <div class="input-group"> <div class="text-primary"> Select something <select name="boxAgents" class="form-control" id="boxAgents" size="5"> </select> </div> </div> </div> When that list box is filled with some dynamic data obtained from ajax like this $.each(res, function (index, item) { var listAgents = item.agentName; $("#boxAgents").append('<option id="agent' + listAgents + '" value="' + listAgents + '">' + listAgents + '</option>'); }); I'd like that when I click an option in my "boxAgents" list, pass it to another list box. I try to pass the options this way $(document).on("click", "option[id^='agent']", function () { var id = $(this).attr("id").replace("agent", ""); $("#boxSelectedAgen").append('<option id="remove"' + id + ' value="' + id + '">' + id + '</option>'); }); The funny thing is that my code only works if I remove the "`size=5`" from the select tag, it doesn't work if I use "`multiple=multiple`" neither. It only works if my "boxAgents" is a normal dropdown list. What should I do?, thanks!.
0debug
Linear Recursion reverse the array. : //cant figure out why my recursion function doesnt work #include <iostream> using namespace std; int ReverseArray(int* A, int i, int j); int main() { int j = 10; int i = 0; int *b = new int[j]; for (int i = 0; i <= 10; i++) b[i] = i; //just to compare the old and new array for (int i = 0; i <= 10; i++) cout << b[i] << endl; //just to compare the for(int i = 0; i <= j; i++) cout << ReverseArray(b,i,j) << endl; system("pause"); return 0; } int ReverseArray(int* A, int i, int j) { if (i <= j) { swap(A[i], A[j]); ReverseArray(A, i + 1, j - 1); } return A[i]; //this should return 10,9,8.... but it return 10,0,9,1... i dont get why its happening
0debug
How to get the position of another element in ReactJS? : <p>My parent element has 2 child, the 2nd child can be dragged into the first child.</p> <p>if it's dragged correctly (into the first child), a callback will be triggered.</p> <p>how can I know if the drag ended in the correct location?</p> <p>I'm using react-draggable.</p>
0debug
better alternative to C# contains method : <p>Is there a faster alternative to using the Contains method in C#? </p> <p>Here is a sample that looks like what I'm trying to do, but I have read that Contains is an expensive way to do it and I want to find a better alternative as speed is important.</p> <pre><code> public List&lt;Guid&gt; getCumulativeListByUsername(string username) { List&lt;Guid&gt; CombinedList = new List&lt;Guid&gt;(); List&lt;Guid&gt; ListA = new List&lt;Guid&gt;(); List&lt;Guid&gt; ListB = new List&lt;Guid&gt;(); ListA = getListAFromDatabase(username); ListB = getListBFromDatabase(username); CombinedList = ListA; foreach (Guid x in ListB) { if (!CombinedList.Contains(x)) { CombinedList.Add(x); } } return CombinedList; } </code></pre> <p>If you could explain your reasoning as well, it would be appreciated.</p>
0debug
Find and replace regex in Intellij, but keep some of the matched regex? : <p>I changed an array to a list, so I want to change all instances of <code>myObject[index]</code> to <code>myObject.get(index)</code> where index is different integers. I can find these instances by doing</p> <pre><code>`myObject\[.*\]` </code></pre> <p>However, I am not sure what I should put in the replace line - I don't know how to make it keep the <code>index</code> values.</p>
0debug
static void ohci_bus_stop(OHCIState *ohci) { trace_usb_ohci_stop(ohci->name); if (ohci->eof_timer) { timer_del(ohci->eof_timer); timer_free(ohci->eof_timer); } ohci->eof_timer = NULL; }
1threat
how to Sort Grade in Array : <p>I want to sort their grades in descending order. I just don't know how using bubble sort.. </p> <pre><code>void computegrade(string name[], int studentno[], float ave[], int top) { if (top==0){ cout&lt;&lt;"Nothing to display\n"; } cout&lt;&lt;"Students are: " &lt;&lt;"\n" &lt;&lt;"\n"; for (int x=top-1; x&gt;=0; x--) { cout&lt;&lt;"Student Name: " &lt;&lt;name[x] &lt;&lt;endl; cout&lt;&lt;"Student No: " &lt;&lt;studentno[x] &lt;&lt;endl; cout&lt;&lt;"Average: " &lt;&lt;ave[x]; } } </code></pre>
0debug
Matplotlib 3D scatter animations : <p>I am graphing out positions in a star cluster, my data is in a dataframe with x,y,z positions as well as a time index.</p> <p>I am able to produce a 3d scatter plot and was trying to produce a rotating plot--I have been somewhat successful, but struggling through the animation API.</p> <p>If my "update_graph" function just returns a new ax.scatter(), the old one stays plotted unless i rebuild the entire graph. That seems inefficient. As well, I have to set my interval rather high or my animation "skips" every other frame, so it says my performance is rather bad. Finally I am forced to use the "blit=False" as I cannot get an iterator for a 3d scatter plot. Apparently the "graph.set_data()" doesn't work, and I can use the "graph.set_3d_properties" but that allows me new z coordinates only. </p> <p>So i have cobbled together a cluuge-- (data i used is at <a href="https://www.kaggle.com/mariopasquato/star-cluster-simulations" rel="noreferrer">https://www.kaggle.com/mariopasquato/star-cluster-simulations</a> scroll to bottom)</p> <p>Also I am only plotting 100 points (data=data[data.id&lt;100])</p> <p>My (working) code is as follows:</p> <pre><code>def update_graph(num): ax = p3.Axes3D(fig) ax.set_xlim3d([-5.0, 5.0]) ax.set_xlabel('X') ax.set_ylim3d([-5.0, 5.0]) ax.set_ylabel('Y') ax.set_zlim3d([-5.0, 5.0]) ax.set_zlabel('Z') title='3D Test, Time='+str(num*100) ax.set_title(title) sample=data0[data0['time']==num*100] x=sample.x y=sample.y z=sample.z graph=ax.scatter(x,y,z) return(graph) fig = plt.figure() ax = p3.Axes3D(fig) # Setting the axes properties ax.set_xlim3d([-5.0, 5.0]) ax.set_xlabel('X') ax.set_ylim3d([-5.0, 5.0]) ax.set_ylabel('Y') ax.set_zlim3d([-5.0, 5.0]) ax.set_zlabel('Z') ax.set_title('3D Test') data=data0[data0['time']==0] x=data.x y=data.y z=data.z graph=ax.scatter(x,y,z) # Creating the Animation object line_ani = animation.FuncAnimation(fig, update_graph, 19, interval=350, blit=False) plt.show() </code></pre>
0debug
Hello everybody.i am not able to upload my localhost website on live server. This is not showing me the background images. Can anyone help please? : I have uploaded my website many times with the help of plugins and direct also.but this is always showing error with the background images. I need your help. please revert.
0debug
Why does change from Spring boot version 2.1.4 to 2.1.5 gives unknown configuration Maven error? : <p>I had installed Eclipse (actually Spring Tool Suite). It came with Maven. I had created Spring boot starter projects. Maven was downloading all the dependencies and things were working fine.</p> <p>Recently, I created a new project. This time, I noticed an error in pom.xml and the problem window (in STS) showing the following:</p> <pre><code>Description Resource Path Location Type Unknown pom.xml /TestSessionAttribute line 1 Maven Configuration Problem </code></pre> <p>I noticed that the spring boot version was at 2.1.5 (it was 2.1.4 before). </p> <pre><code>&lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.1.5.RELEASE&lt;/version&gt; &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt; &lt;/parent&gt; </code></pre> <p>I went ahead and did an update of the project (Maven > Update project) with the 'Force Update of Snapshots/Releases' checked. This did not resolve the problem. I do see the </p> <pre><code>spring-boot-2.1.5.RELEASE.jar </code></pre> <p>in the m2 repository.</p> <p>I went back and changed the version to 2.1.4 and then a Maven > Update Project and the errors went away.</p> <p>Why am I getting the Maven error when version is 2.1.5?</p>
0debug
Php convert a date to string character : <p>I have searched but I could not find out how to convert a date from a character string. For example string date is 18-08-2016 I want to convert 18 August 2016 How can I do?</p>
0debug
function attached with a button not working after changing its id in ajax success callback : <p>When I click the button its id, name and val attribute change successfully in ajax success. But if If I click it again the old function attached to the previous id is called not the one attached to the new id. I checked other posts but they did not worked for me either.</p> <pre><code>&lt;input type="submit" name="textareaInsert" id="textareaInsert" class="textareaInsert" value="Insert data"&gt; //script $(document).ready(function() { graph_post_data(); graph_update_data(); }); function graph_post_data() { $('#textareaInsert').on("click", function() { var poll_id = $('#poll_id').val(); var graph_data = $('#graphPost').val(); var ownerid = $('#ownerid').val(); var ownername = $('#ownername').val(); var insert = 'insert'; if(ownerid != null || graph_data != '') { $.ajax({ type:"post", url:"reg2.php", data: {insert:insert, poll_id:poll_id, graph_data:graph_data, ownerid:ownerid, ownername:ownername}, success: function() { $('#textareaInsert').attr("id", "textareaUpdate").attr("name","textareaUpdate").val("Update"); } }).error( function() { console.log("Error in inserting graph data") } ).success( function(data) { var Poll_insert_data = jQuery.parseJSON(data); $('#poll_author').text(Poll_insert_data.data.publisherName); $('#owner_input_data').append(Poll_insert_data.data.data); } ); } else { alert('Please write something first.'); } }); } function graph_update_data() { $('#textareaUpdate').on("click", function() { var poll_id = $('#poll_id').val(); var graph_data = $('#graphPost').val(); var ownerid = $('#ownerid').val(); var ownername = $('#ownername').val(); var update = 'update'; if(ownerid != null || graph_data != '') { $.ajax({ type:"post", url:"reg2.php", data: {update:update, poll_id:poll_id, graph_data:graph_data, ownerid:ownerid, ownername:ownername}, }).error( function() { console.log("Error in updating graph page data") } ) .success( function(data) { var Poll_insert_data = jQuery.parseJSON(data); $('#poll_author').text(Poll_insert_data.data.publisherName); $('#owner_input_data').text("").append(Poll_insert_data.data.data); } ); } else { alert('Please write something first.'); } }); } </code></pre> <p>When I click the button first time 'Insert data' successfully changes its attributes to that of "Upload". But when I click "Upload", function graph_post_data() is called instead of graph_update_data(). I'm not getting what's the problem. Please help me figure it out. </p>
0debug
Is it considered copyright if I use a small portion of a song to play as an alarm in my iOS app? Will my app be taken down for copyright infringement? : <p>I just want to know if the following scenario is considered to be copyright infringement...</p> <p>In my app, the user can accumulate points to "buy" different alarm sounds..these alarms are actual 5-10 second snippets of songs from artists...Is it considered to be copyright if I use those snippets in my app?</p> <p>P.S. The app will be free download BTW</p>
0debug
Lombok not working with STS : <p>Although I love lombok, it gives too much problems while configuring sometimes, specially in Linux. When I was trying to install it, I was getting the following error:<a href="https://i.stack.imgur.com/5cWwl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5cWwl.png" alt="enter image description here"></a></p> <p>I tried to set it up manually,as suggested here <a href="https://github.com/rzwitserloot/lombok/issues/95" rel="noreferrer">https://github.com/rzwitserloot/lombok/issues/95</a> but that didn't work out either. Any suggestions?</p>
0debug
How to read in individual characters and output when two-character-sequnce is inputted? using while loop and C++ : I am in the works of trying to write a program that reads in *individual* characters and prompts the user when the two-character-sequence 'cs' that the door has opened. I'm stuck on where or how to store the current value and output the response after the string has completely been read. **Data reading in from notepad:** cs imacsmajor css ab decds **Desired output:** cs open door imacsmajor open door css open door ab closed door decds closed door [code written so far][1] [1]: https://i.stack.imgur.com/fjiJq.png
0debug
reading a file in hdfs from pyspark : <p>I'm trying to read a file in my hdfs. Here's a showing of my hadoop file structure.</p> <pre><code>hduser@GVM:/usr/local/spark/bin$ hadoop fs -ls -R / drwxr-xr-x - hduser supergroup 0 2016-03-06 17:28 /inputFiles drwxr-xr-x - hduser supergroup 0 2016-03-06 17:31 /inputFiles/CountOfMonteCristo -rw-r--r-- 1 hduser supergroup 2685300 2016-03-06 17:31 /inputFiles/CountOfMonteCristo/BookText.txt </code></pre> <p>Here's my pyspark code:</p> <pre><code>from pyspark import SparkContext, SparkConf conf = SparkConf().setAppName("myFirstApp").setMaster("local") sc = SparkContext(conf=conf) textFile = sc.textFile("hdfs://inputFiles/CountOfMonteCristo/BookText.txt") textFile.first() </code></pre> <p>The error I get is: </p> <pre><code>Py4JJavaError: An error occurred while calling o64.partitions. : java.lang.IllegalArgumentException: java.net.UnknownHostException: inputFiles </code></pre> <p>Is this because I'm setting my sparkContext incorrectly? I'm running this in a ubuntu 14.04 virtual machine through virtual box. </p> <p>I'm not sure what I'm doing wrong here....</p>
0debug
Argument of type 'Http' is not assignable to parameter of type 'Http' in Ionic ngx-translate : <p>I'm developing an Ionic 2 mobile app and want to use ngx-translate features. Following the tutorial, I'm importing necessary files in app module like this:</p> <pre><code>import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { HttpModule, Http } from '@angular/http'; ... export function createTranslateLoader(http: Http) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } </code></pre> <p>which gives the error:</p> <pre><code> Argument of type 'Http' is not assignable to parameter of type 'Http'. Property 'handler' is missing in type 'Http' </code></pre> <p>I think there is a mismatch of packages expected by ngx-translate but i cannot figure out what and how. My @angular/http version is 4.3.2 Has anybody an idea what to do?</p>
0debug
static always_inline void gen_excp (DisasContext *ctx, int exception, int error_code) { TCGv tmp1, tmp2; tcg_gen_movi_i64(cpu_pc, ctx->pc); tmp1 = tcg_const_i32(exception); tmp2 = tcg_const_i32(error_code); tcg_gen_helper_0_2(helper_excp, tmp1, tmp2); tcg_temp_free(tmp2); tcg_temp_free(tmp1); }
1threat
No symbols have been loaded for this document. Breakpoint issue : <p>I already had a look at solutions on the internet for this problem but no one really worked.</p> <p>What I already tried:</p> <ul> <li>Cleaning the solution and rebuilding everything</li> <li>Deleteing the bin + obj directory</li> <li>Restarting visual studio</li> <li>Restarting the pc</li> <li>Loading the module manually (but it will not be loaded when starting debugging again so this is a really annoying solution)</li> </ul> <p>I have two startup projects, one is loaded normally but the other one is not.</p> <p>Thanks for your help!</p>
0debug
void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *r, void *opaque) { int crm, opc1, opc2; int crmmin = (r->crm == CP_ANY) ? 0 : r->crm; int crmmax = (r->crm == CP_ANY) ? 15 : r->crm; int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1; int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1; int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2; int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2; assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn))); if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) { if (r->access & PL3_R) { assert(r->fieldoffset || r->readfn); } if (r->access & PL3_W) { assert(r->fieldoffset || r->writefn); } } assert(cptype_valid(r->type)); for (crm = crmmin; crm <= crmmax; crm++) { for (opc1 = opc1min; opc1 <= opc1max; opc1++) { for (opc2 = opc2min; opc2 <= opc2max; opc2++) { uint32_t *key = g_new(uint32_t, 1); ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; *key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2); if (opaque) { r2->opaque = opaque; } r2->crm = crm; r2->opc1 = opc1; r2->opc2 = opc2; if ((r->type & ARM_CP_SPECIAL) || ((r->crm == CP_ANY) && crm != 0) || ((r->opc1 == CP_ANY) && opc1 != 0) || ((r->opc2 == CP_ANY) && opc2 != 0)) { r2->type |= ARM_CP_NO_MIGRATE; } if (!(r->type & ARM_CP_OVERRIDE)) { ARMCPRegInfo *oldreg; oldreg = g_hash_table_lookup(cpu->cp_regs, key); if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { fprintf(stderr, "Register redefined: cp=%d %d bit " "crn=%d crm=%d opc1=%d opc2=%d, " "was %s, now %s\n", r2->cp, 32 + 32 * is64, r2->crn, r2->crm, r2->opc1, r2->opc2, oldreg->name, r2->name); g_assert_not_reached(); } } g_hash_table_insert(cpu->cp_regs, key, r2); } } } }
1threat
Loop help C++ test : <p>i have a test and i get this question : <a href="https://prnt.sc/ip3z7n" rel="nofollow noreferrer">https://prnt.sc/ip3z7n</a> and this is my answer </p> <pre><code>#include &lt;iostream&gt; using namespace std; int main () { int grade,counter=0; for(int counter;counter&lt;10;counter++) { cout&lt;&lt;"Enter the grade: "; cin&gt;&gt;grade; if(grade&gt;=60) cout&lt;&lt;"Passed \n"; else cout&lt;&lt;"Failed \n"; } return 0; } </code></pre>
0debug
static int decode_mips16_opc (CPUState *env, DisasContext *ctx, int *is_branch) { int rx, ry; int sa; int op, cnvt_op, op1, offset; int funct; int n_bytes; op = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 2) & 0x7; sa = sa == 0 ? 8 : sa; rx = xlat((ctx->opcode >> 8) & 0x7); cnvt_op = (ctx->opcode >> 5) & 0x7; ry = xlat((ctx->opcode >> 5) & 0x7); op1 = offset = ctx->opcode & 0x1f; n_bytes = 2; switch (op) { case M16_OPC_ADDIUSP: { int16_t imm = ((uint8_t) ctx->opcode) << 2; gen_arith_imm(env, ctx, OPC_ADDIU, rx, 29, imm); } break; case M16_OPC_ADDIUPC: gen_addiupc(ctx, rx, ((uint8_t) ctx->opcode) << 2, 0, 0); break; case M16_OPC_B: offset = (ctx->opcode & 0x7ff) << 1; offset = (int16_t)(offset << 4) >> 4; gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0, offset); break; case M16_OPC_JAL: offset = lduw_code(ctx->pc + 2); offset = (((ctx->opcode & 0x1f) << 21) | ((ctx->opcode >> 5) & 0x1f) << 16 | offset) << 2; op = ((ctx->opcode >> 10) & 0x1) ? OPC_JALX : OPC_JAL; gen_compute_branch(ctx, op, 4, rx, ry, offset); n_bytes = 4; *is_branch = 1; break; case M16_OPC_BEQZ: gen_compute_branch(ctx, OPC_BEQ, 2, rx, 0, ((int8_t)ctx->opcode) << 1); break; case M16_OPC_BNEQZ: gen_compute_branch(ctx, OPC_BNE, 2, rx, 0, ((int8_t)ctx->opcode) << 1); break; case M16_OPC_SHIFT: switch (ctx->opcode & 0x3) { case 0x0: gen_shift_imm(env, ctx, OPC_SLL, rx, ry, sa); break; case 0x1: #if defined(TARGET_MIPS64) check_mips_64(ctx); gen_shift_imm(env, ctx, OPC_DSLL, rx, ry, sa); #else generate_exception(ctx, EXCP_RI); #endif break; case 0x2: gen_shift_imm(env, ctx, OPC_SRL, rx, ry, sa); break; case 0x3: gen_shift_imm(env, ctx, OPC_SRA, rx, ry, sa); break; } break; #if defined(TARGET_MIPS64) case M16_OPC_LD: check_mips_64(ctx); gen_ldst(ctx, OPC_LD, ry, rx, offset << 3); break; #endif case M16_OPC_RRIA: { int16_t imm = (int8_t)((ctx->opcode & 0xf) << 4) >> 4; if ((ctx->opcode >> 4) & 1) { #if defined(TARGET_MIPS64) check_mips_64(ctx); gen_arith_imm(env, ctx, OPC_DADDIU, ry, rx, imm); #else generate_exception(ctx, EXCP_RI); #endif } else { gen_arith_imm(env, ctx, OPC_ADDIU, ry, rx, imm); } } break; case M16_OPC_ADDIU8: { int16_t imm = (int8_t) ctx->opcode; gen_arith_imm(env, ctx, OPC_ADDIU, rx, rx, imm); } break; case M16_OPC_SLTI: { int16_t imm = (uint8_t) ctx->opcode; gen_slt_imm(env, OPC_SLTI, 24, rx, imm); } break; case M16_OPC_SLTIU: { int16_t imm = (uint8_t) ctx->opcode; gen_slt_imm(env, OPC_SLTIU, 24, rx, imm); } break; case M16_OPC_I8: { int reg32; funct = (ctx->opcode >> 8) & 0x7; switch (funct) { case I8_BTEQZ: gen_compute_branch(ctx, OPC_BEQ, 2, 24, 0, ((int8_t)ctx->opcode) << 1); break; case I8_BTNEZ: gen_compute_branch(ctx, OPC_BNE, 2, 24, 0, ((int8_t)ctx->opcode) << 1); break; case I8_SWRASP: gen_ldst(ctx, OPC_SW, 31, 29, (ctx->opcode & 0xff) << 2); break; case I8_ADJSP: gen_arith_imm(env, ctx, OPC_ADDIU, 29, 29, ((int8_t)ctx->opcode) << 3); break; case I8_SVRS: { int do_ra = ctx->opcode & (1 << 6); int do_s0 = ctx->opcode & (1 << 5); int do_s1 = ctx->opcode & (1 << 4); int framesize = ctx->opcode & 0xf; if (framesize == 0) { framesize = 128; } else { framesize = framesize << 3; } if (ctx->opcode & (1 << 7)) { gen_mips16_save(ctx, 0, 0, do_ra, do_s0, do_s1, framesize); } else { gen_mips16_restore(ctx, 0, 0, do_ra, do_s0, do_s1, framesize); } } break; case I8_MOV32R: { int rz = xlat(ctx->opcode & 0x7); reg32 = (((ctx->opcode >> 3) & 0x3) << 3) | ((ctx->opcode >> 5) & 0x7); gen_arith(env, ctx, OPC_ADDU, reg32, rz, 0); } break; case I8_MOVR32: reg32 = ctx->opcode & 0x1f; gen_arith(env, ctx, OPC_ADDU, ry, reg32, 0); break; default: generate_exception(ctx, EXCP_RI); break; } } break; case M16_OPC_LI: { int16_t imm = (uint8_t) ctx->opcode; gen_arith_imm(env, ctx, OPC_ADDIU, rx, 0, imm); } break; case M16_OPC_CMPI: { int16_t imm = (uint8_t) ctx->opcode; gen_logic_imm(env, OPC_XORI, 24, rx, imm); } break; #if defined(TARGET_MIPS64) case M16_OPC_SD: check_mips_64(ctx); gen_ldst(ctx, OPC_SD, ry, rx, offset << 3); break; #endif case M16_OPC_LB: gen_ldst(ctx, OPC_LB, ry, rx, offset); break; case M16_OPC_LH: gen_ldst(ctx, OPC_LH, ry, rx, offset << 1); break; case M16_OPC_LWSP: gen_ldst(ctx, OPC_LW, rx, 29, ((uint8_t)ctx->opcode) << 2); break; case M16_OPC_LW: gen_ldst(ctx, OPC_LW, ry, rx, offset << 2); break; case M16_OPC_LBU: gen_ldst(ctx, OPC_LBU, ry, rx, offset); break; case M16_OPC_LHU: gen_ldst(ctx, OPC_LHU, ry, rx, offset << 1); break; case M16_OPC_LWPC: gen_ldst(ctx, OPC_LWPC, rx, 0, ((uint8_t)ctx->opcode) << 2); break; #if defined (TARGET_MIPS64) case M16_OPC_LWU: check_mips_64(ctx); gen_ldst(ctx, OPC_LWU, ry, rx, offset << 2); break; #endif case M16_OPC_SB: gen_ldst(ctx, OPC_SB, ry, rx, offset); break; case M16_OPC_SH: gen_ldst(ctx, OPC_SH, ry, rx, offset << 1); break; case M16_OPC_SWSP: gen_ldst(ctx, OPC_SW, rx, 29, ((uint8_t)ctx->opcode) << 2); break; case M16_OPC_SW: gen_ldst(ctx, OPC_SW, ry, rx, offset << 2); break; case M16_OPC_RRR: { int rz = xlat((ctx->opcode >> 2) & 0x7); int mips32_op; switch (ctx->opcode & 0x3) { case RRR_ADDU: mips32_op = OPC_ADDU; break; case RRR_SUBU: mips32_op = OPC_SUBU; break; #if defined(TARGET_MIPS64) case RRR_DADDU: mips32_op = OPC_DADDU; check_mips_64(ctx); break; case RRR_DSUBU: mips32_op = OPC_DSUBU; check_mips_64(ctx); break; #endif default: generate_exception(ctx, EXCP_RI); goto done; } gen_arith(env, ctx, mips32_op, rz, rx, ry); done: ; } break; case M16_OPC_RR: switch (op1) { case RR_JR: { int nd = (ctx->opcode >> 7) & 0x1; int link = (ctx->opcode >> 6) & 0x1; int ra = (ctx->opcode >> 5) & 0x1; if (link) { op = nd ? OPC_JALRC : OPC_JALR; } else { op = OPC_JR; } gen_compute_branch(ctx, op, 2, ra ? 31 : rx, 31, 0); if (!nd) { *is_branch = 1; } } break; case RR_SDBBP: check_insn(env, ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { generate_exception(ctx, EXCP_DBp); } else { generate_exception(ctx, EXCP_DBp); } break; case RR_SLT: gen_slt(env, OPC_SLT, 24, rx, ry); break; case RR_SLTU: gen_slt(env, OPC_SLTU, 24, rx, ry); break; case RR_BREAK: generate_exception(ctx, EXCP_BREAK); break; case RR_SLLV: gen_shift(env, ctx, OPC_SLLV, ry, rx, ry); break; case RR_SRLV: gen_shift(env, ctx, OPC_SRLV, ry, rx, ry); break; case RR_SRAV: gen_shift(env, ctx, OPC_SRAV, ry, rx, ry); break; #if defined (TARGET_MIPS64) case RR_DSRL: check_mips_64(ctx); gen_shift_imm(env, ctx, OPC_DSRL, ry, ry, sa); break; #endif case RR_CMP: gen_logic(env, OPC_XOR, 24, rx, ry); break; case RR_NEG: gen_arith(env, ctx, OPC_SUBU, rx, 0, ry); break; case RR_AND: gen_logic(env, OPC_AND, rx, rx, ry); break; case RR_OR: gen_logic(env, OPC_OR, rx, rx, ry); break; case RR_XOR: gen_logic(env, OPC_XOR, rx, rx, ry); break; case RR_NOT: gen_logic(env, OPC_NOR, rx, ry, 0); break; case RR_MFHI: gen_HILO(ctx, OPC_MFHI, rx); break; case RR_CNVT: switch (cnvt_op) { case RR_RY_CNVT_ZEB: tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]); break; case RR_RY_CNVT_ZEH: tcg_gen_ext16u_tl(cpu_gpr[rx], cpu_gpr[rx]); break; case RR_RY_CNVT_SEB: tcg_gen_ext8s_tl(cpu_gpr[rx], cpu_gpr[rx]); break; case RR_RY_CNVT_SEH: tcg_gen_ext16s_tl(cpu_gpr[rx], cpu_gpr[rx]); break; #if defined (TARGET_MIPS64) case RR_RY_CNVT_ZEW: check_mips_64(ctx); tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]); break; case RR_RY_CNVT_SEW: check_mips_64(ctx); tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]); break; #endif default: generate_exception(ctx, EXCP_RI); break; } break; case RR_MFLO: gen_HILO(ctx, OPC_MFLO, rx); break; #if defined (TARGET_MIPS64) case RR_DSRA: check_mips_64(ctx); gen_shift_imm(env, ctx, OPC_DSRA, ry, ry, sa); break; case RR_DSLLV: check_mips_64(ctx); gen_shift(env, ctx, OPC_DSLLV, ry, rx, ry); break; case RR_DSRLV: check_mips_64(ctx); gen_shift(env, ctx, OPC_DSRLV, ry, rx, ry); break; case RR_DSRAV: check_mips_64(ctx); gen_shift(env, ctx, OPC_DSRAV, ry, rx, ry); break; #endif case RR_MULT: gen_muldiv(ctx, OPC_MULT, rx, ry); break; case RR_MULTU: gen_muldiv(ctx, OPC_MULTU, rx, ry); break; case RR_DIV: gen_muldiv(ctx, OPC_DIV, rx, ry); break; case RR_DIVU: gen_muldiv(ctx, OPC_DIVU, rx, ry); break; #if defined (TARGET_MIPS64) case RR_DMULT: check_mips_64(ctx); gen_muldiv(ctx, OPC_DMULT, rx, ry); break; case RR_DMULTU: check_mips_64(ctx); gen_muldiv(ctx, OPC_DMULTU, rx, ry); break; case RR_DDIV: check_mips_64(ctx); gen_muldiv(ctx, OPC_DDIV, rx, ry); break; case RR_DDIVU: check_mips_64(ctx); gen_muldiv(ctx, OPC_DDIVU, rx, ry); break; #endif default: generate_exception(ctx, EXCP_RI); break; } break; case M16_OPC_EXTEND: decode_extended_mips16_opc(env, ctx, is_branch); n_bytes = 4; break; #if defined(TARGET_MIPS64) case M16_OPC_I64: funct = (ctx->opcode >> 8) & 0x7; decode_i64_mips16(env, ctx, ry, funct, offset, 0); break; #endif default: generate_exception(ctx, EXCP_RI); break; } return n_bytes; }
1threat
Rat in Maze Puzzle : I was recently asked this question in an Interview. http://www.geeksforgeeks.org/backttracking-set-2-rat-in-a-maze/ I gave the interviewer the solution mentioned in the link which happens to be exponential.The interviewer was quite surprised by my response , and was apparently expecting a polynomial time solution.I looked for one but could not find any.Does there exist a polynomial time solution for this problem.
0debug
static void utf8_string(void) { static const struct { const char *json_in; const char *utf8_out; const char *json_out; const char *utf8_in; } test_cases[] = { { "\"Falsches \xC3\x9C" "ben von Xylophonmusik qu\xC3\xA4lt" " jeden gr\xC3\xB6\xC3\x9F" "eren Zwerg.\"", "Falsches \xC3\x9C" "ben von Xylophonmusik qu\xC3\xA4lt" " jeden gr\xC3\xB6\xC3\x9F" "eren Zwerg.", "\"Falsches \\u00DCben von Xylophonmusik qu\\u00E4lt" " jeden gr\\u00F6\\u00DFeren Zwerg.\"", }, { "\"\xCE\xBA\xE1\xBD\xB9\xCF\x83\xCE\xBC\xCE\xB5\"", "\xCE\xBA\xE1\xBD\xB9\xCF\x83\xCE\xBC\xCE\xB5", "\"\\u03BA\\u1F79\\u03C3\\u03BC\\u03B5\"", }, { "\"\\u0000\"", "", "\"\\u0000\"", "\xC0\x80", }, { "\"\xC2\x80\"", "\xC2\x80", "\"\\u0080\"", }, { "\"\xE0\xA0\x80\"", "\xE0\xA0\x80", "\"\\u0800\"", }, { "\"\xF0\x90\x80\x80\"", "\xF0\x90\x80\x80", "\"\\uD800\\uDC00\"", }, { "\"\xF8\x88\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xF8\x88\x80\x80\x80", }, { "\"\xFC\x84\x80\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xFC\x84\x80\x80\x80\x80", }, { "\"\x7F\"", "\x7F", "\"\\u007F\"", }, { "\"\xDF\xBF\"", "\xDF\xBF", "\"\\u07FF\"", }, { "\"\xEF\xBF\xBC\"", "\xEF\xBF\xBC", "\"\\uFFFC\"", }, { "\"\xF7\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xF7\xBF\xBF\xBF", }, { "\"\xFB\xBF\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xFB\xBF\xBF\xBF\xBF", }, { "\"\xFD\xBF\xBF\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xFD\xBF\xBF\xBF\xBF\xBF", }, { "\"\xED\x9F\xBF\"", "\xED\x9F\xBF", "\"\\uD7FF\"", }, { "\"\xEE\x80\x80\"", "\xEE\x80\x80", "\"\\uE000\"", }, { "\"\xEF\xBF\xBD\"", "\xEF\xBF\xBD", "\"\\uFFFD\"", }, { "\"\xF4\x8F\xBF\xBD\"", "\xF4\x8F\xBF\xBD", "\"\\uDBFF\\uDFFD\"" }, { "\"\xF4\x90\x80\x80\"", "\xF4\x90\x80\x80", "\"\\uFFFD\"", }, { "\"\x80\"", "\x80", "\"\\uFFFD\"", }, { "\"\xBF\"", "\xBF", "\"\\uFFFD\"", }, { "\"\x80\xBF\"", "\x80\xBF", "\"\\uFFFD\\uFFFD\"", }, { "\"\x80\xBF\x80\"", "\x80\xBF\x80", "\"\\uFFFD\\uFFFD\\uFFFD\"", }, { "\"\x80\xBF\x80\xBF\"", "\x80\xBF\x80\xBF", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", }, { "\"\x80\xBF\x80\xBF\x80\"", "\x80\xBF\x80\xBF\x80", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", }, { "\"\x80\xBF\x80\xBF\x80\xBF\"", "\x80\xBF\x80\xBF\x80\xBF", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", }, { "\"\x80\xBF\x80\xBF\x80\xBF\x80\"", "\x80\xBF\x80\xBF\x80\xBF\x80", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", }, { "\"\x80\x81\x82\x83\x84\x85\x86\x87" "\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F" "\x90\x91\x92\x93\x94\x95\x96\x97" "\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F" "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7" "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF" "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7" "\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\"", "\x80\x81\x82\x83\x84\x85\x86\x87" "\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F" "\x90\x91\x92\x93\x94\x95\x96\x97" "\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F" "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7" "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF" "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7" "\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"" }, { "\"\xC0 \xC1 \xC2 \xC3 \xC4 \xC5 \xC6 \xC7 " "\xC8 \xC9 \xCA \xCB \xCC \xCD \xCE \xCF " "\xD0 \xD1 \xD2 \xD3 \xD4 \xD5 \xD6 \xD7 " "\xD8 \xD9 \xDA \xDB \xDC \xDD \xDE \xDF \"", NULL, "\"\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD " "\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD " "\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD " "\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \"", "\xC0 \xC1 \xC2 \xC3 \xC4 \xC5 \xC6 \xC7 " "\xC8 \xC9 \xCA \xCB \xCC \xCD \xCE \xCF " "\xD0 \xD1 \xD2 \xD3 \xD4 \xD5 \xD6 \xD7 " "\xD8 \xD9 \xDA \xDB \xDC \xDD \xDE \xDF ", }, { "\"\xE0 \xE1 \xE2 \xE3 \xE4 \xE5 \xE6 \xE7 " "\xE8 \xE9 \xEA \xEB \xEC \xED \xEE \xEF \"", "\xE0 \xE1 \xE2 \xE3 \xE4 \xE5 \xE6 \xE7 " "\xE8 \xE9 \xEA \xEB \xEC \xED \xEE \xEF ", "\"\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD " "\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \"", }, { "\"\xF0 \xF1 \xF2 \xF3 \xF4 \xF5 \xF6 \xF7 \"", NULL, "\"\\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \\uFFFD \"", "\xF0 \xF1 \xF2 \xF3 \xF4 \xF5 \xF6 \xF7 ", }, { "\"\xF8 \xF9 \xFA \xFB \"", NULL, "\"\\uFFFD \\uFFFD \\uFFFD \\uFFFD \"", "\xF8 \xF9 \xFA \xFB ", }, { "\"\xFC \xFD \"", NULL, "\"\\uFFFD \\uFFFD \"", "\xFC \xFD ", }, { "\"\xC0\"", NULL, "\"\\uFFFD\"", "\xC0", }, { "\"\xE0\x80\"", "\xE0\x80", "\"\\uFFFD\"", }, { "\"\xF0\x80\x80\"", "\xF0\x80\x80", "\"\\uFFFD\"", }, { "\"\xF8\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xF8\x80\x80\x80", }, { "\"\xFC\x80\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xFC\x80\x80\x80\x80", }, { "\"\xDF\"", "\xDF", "\"\\uFFFD\"", }, { "\"\xEF\xBF\"", "\xEF\xBF", "\"\\uFFFD\"", }, { "\"\xF7\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xF7\xBF\xBF", }, { "\"\xFB\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xFB\xBF\xBF\xBF", }, { "\"\xFD\xBF\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xFD\xBF\xBF\xBF\xBF", }, { "\"\xC0\xE0\x80\xF0\x80\x80\xF8\x80\x80\x80\xFC\x80\x80\x80\x80" "\xDF\xEF\xBF\xF7\xBF\xBF\xFB\xBF\xBF\xBF\xFD\xBF\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", "\xC0\xE0\x80\xF0\x80\x80\xF8\x80\x80\x80\xFC\x80\x80\x80\x80" "\xDF\xEF\xBF\xF7\xBF\xBF\xFB\xBF\xBF\xBF\xFD\xBF\xBF\xBF\xBF", }, { "\"\xFE\"", NULL, "\"\\uFFFD\"", "\xFE", }, { "\"\xFF\"", NULL, "\"\\uFFFD\"", "\xFF", }, { "\"\xFE\xFE\xFF\xFF\"", NULL, "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", "\xFE\xFE\xFF\xFF", }, { "\"\xC0\xAF\"", NULL, "\"\\uFFFD\"", "\xC0\xAF", }, { "\"\xE0\x80\xAF\"", "\xE0\x80\xAF", "\"\\uFFFD\"", }, { "\"\xF0\x80\x80\xAF\"", "\xF0\x80\x80\xAF", "\"\\uFFFD\"", }, { "\"\xF8\x80\x80\x80\xAF\"", NULL, "\"\\uFFFD\"", "\xF8\x80\x80\x80\xAF", }, { "\"\xFC\x80\x80\x80\x80\xAF\"", NULL, "\"\\uFFFD\"", "\xFC\x80\x80\x80\x80\xAF", }, { "\"\xC1\xBF\"", NULL, "\"\\uFFFD\"", "\xC1\xBF", }, { "\"\xE0\x9F\xBF\"", "\xE0\x9F\xBF", "\"\\uFFFD\"", }, { "\"\xF0\x8F\xBF\xBC\"", "\xF0\x8F\xBF\xBC", "\"\\uFFFD\"", }, { "\"\xF8\x87\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xF8\x87\xBF\xBF\xBF", }, { "\"\xFC\x83\xBF\xBF\xBF\xBF\"", NULL, "\"\\uFFFD\"", "\xFC\x83\xBF\xBF\xBF\xBF", }, { "\"\xC0\x80\"", NULL, "\"\\u0000\"", "\xC0\x80", }, { "\"\xE0\x80\x80\"", "\xE0\x80\x80", "\"\\uFFFD\"", }, { "\"\xF0\x80\x80\x80\"", "\xF0\x80\x80\x80", "\"\\uFFFD\"", }, { "\"\xF8\x80\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xF8\x80\x80\x80\x80", }, { "\"\xFC\x80\x80\x80\x80\x80\"", NULL, "\"\\uFFFD\"", "\xFC\x80\x80\x80\x80\x80", }, { "\"\xED\xA0\x80\"", "\xED\xA0\x80", "\"\\uFFFD\"", }, { "\"\xED\xAD\xBF\"", "\xED\xAD\xBF", "\"\\uFFFD\"", }, { "\"\xED\xAE\x80\"", "\xED\xAE\x80", "\"\\uFFFD\"", }, { "\"\xED\xAF\xBF\"", "\xED\xAF\xBF", "\"\\uFFFD\"", }, { "\"\xED\xB0\x80\"", "\xED\xB0\x80", "\"\\uFFFD\"", }, { "\"\xED\xBE\x80\"", "\xED\xBE\x80", "\"\\uFFFD\"", }, { "\"\xED\xBF\xBF\"", "\xED\xBF\xBF", "\"\\uFFFD\"", }, { "\"\xED\xA0\x80\xED\xB0\x80\"", "\xED\xA0\x80\xED\xB0\x80", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xA0\x80\xED\xBF\xBF\"", "\xED\xA0\x80\xED\xBF\xBF", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAD\xBF\xED\xB0\x80\"", "\xED\xAD\xBF\xED\xB0\x80", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAD\xBF\xED\xBF\xBF\"", "\xED\xAD\xBF\xED\xBF\xBF", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAE\x80\xED\xB0\x80\"", "\xED\xAE\x80\xED\xB0\x80", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAE\x80\xED\xBF\xBF\"", "\xED\xAE\x80\xED\xBF\xBF", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAF\xBF\xED\xB0\x80\"", "\xED\xAF\xBF\xED\xB0\x80", "\"\\uFFFD\\uFFFD\"", }, { "\"\xED\xAF\xBF\xED\xBF\xBF\"", "\xED\xAF\xBF\xED\xBF\xBF", "\"\\uFFFD\\uFFFD\"", }, { "\"\xEF\xBF\xBE\"", "\xEF\xBF\xBE", "\"\\uFFFD\"", }, { "\"\xEF\xBF\xBF\"", "\xEF\xBF\xBF", "\"\\uFFFD\"", }, { "\"\xEF\xB7\x90\"", "\xEF\xB7\x90", "\"\\uFFFD\"", }, { "\"\xEF\xB7\xAF\"", "\xEF\xB7\xAF", "\"\\uFFFD\"", }, { "\"\xF0\x9F\xBF\xBE\xF0\x9F\xBF\xBF" "\xF0\xAF\xBF\xBE\xF0\xAF\xBF\xBF" "\xF0\xBF\xBF\xBE\xF0\xBF\xBF\xBF" "\xF1\x8F\xBF\xBE\xF1\x8F\xBF\xBF" "\xF1\x9F\xBF\xBE\xF1\x9F\xBF\xBF" "\xF1\xAF\xBF\xBE\xF1\xAF\xBF\xBF" "\xF1\xBF\xBF\xBE\xF1\xBF\xBF\xBF" "\xF2\x8F\xBF\xBE\xF2\x8F\xBF\xBF" "\xF2\x9F\xBF\xBE\xF2\x9F\xBF\xBF" "\xF2\xAF\xBF\xBE\xF2\xAF\xBF\xBF" "\xF2\xBF\xBF\xBE\xF2\xBF\xBF\xBF" "\xF3\x8F\xBF\xBE\xF3\x8F\xBF\xBF" "\xF3\x9F\xBF\xBE\xF3\x9F\xBF\xBF" "\xF3\xAF\xBF\xBE\xF3\xAF\xBF\xBF" "\xF3\xBF\xBF\xBE\xF3\xBF\xBF\xBF" "\xF4\x8F\xBF\xBE\xF4\x8F\xBF\xBF\"", "\xF0\x9F\xBF\xBE\xF0\x9F\xBF\xBF" "\xF0\xAF\xBF\xBE\xF0\xAF\xBF\xBF" "\xF0\xBF\xBF\xBE\xF0\xBF\xBF\xBF" "\xF1\x8F\xBF\xBE\xF1\x8F\xBF\xBF" "\xF1\x9F\xBF\xBE\xF1\x9F\xBF\xBF" "\xF1\xAF\xBF\xBE\xF1\xAF\xBF\xBF" "\xF1\xBF\xBF\xBE\xF1\xBF\xBF\xBF" "\xF2\x8F\xBF\xBE\xF2\x8F\xBF\xBF" "\xF2\x9F\xBF\xBE\xF2\x9F\xBF\xBF" "\xF2\xAF\xBF\xBE\xF2\xAF\xBF\xBF" "\xF2\xBF\xBF\xBE\xF2\xBF\xBF\xBF" "\xF3\x8F\xBF\xBE\xF3\x8F\xBF\xBF" "\xF3\x9F\xBF\xBE\xF3\x9F\xBF\xBF" "\xF3\xAF\xBF\xBE\xF3\xAF\xBF\xBF" "\xF3\xBF\xBF\xBE\xF3\xBF\xBF\xBF" "\xF4\x8F\xBF\xBE\xF4\x8F\xBF\xBF", "\"\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD" "\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\\uFFFD\"", }, {} }; int i; QObject *obj; QString *str; const char *json_in, *utf8_out, *utf8_in, *json_out; for (i = 0; test_cases[i].json_in; i++) { json_in = test_cases[i].json_in; utf8_out = test_cases[i].utf8_out; utf8_in = test_cases[i].utf8_in ?: test_cases[i].utf8_out; json_out = test_cases[i].json_out ?: test_cases[i].json_in; obj = qobject_from_json(json_in, NULL); if (utf8_out) { str = qobject_to_qstring(obj); g_assert(str); g_assert_cmpstr(qstring_get_str(str), ==, utf8_out); } else { g_assert(!obj); } qobject_decref(obj); obj = QOBJECT(qstring_from_str(utf8_in)); str = qobject_to_json(obj); if (json_out) { g_assert(str); g_assert_cmpstr(qstring_get_str(str), ==, json_out); } else { g_assert(!str); } QDECREF(str); qobject_decref(obj); if (0 && json_out != json_in) { obj = qobject_from_json(json_out, NULL); str = qobject_to_qstring(obj); g_assert(str); g_assert_cmpstr(qstring_get_str(str), ==, utf8_out); } } }
1threat
static av_cold int png_enc_close(AVCodecContext *avctx) { av_frame_free(&avctx->coded_frame); return 0; }
1threat
what is the difference between 9_9 and 99 as integer in . JS : when I try 9_9 === 99 output is true. but parInt('9_9')'s output is 9 parseInt("9_9") 9_9====99 I expect the output of parseInt('9_9') to be 99, but the actual output is 99.
0debug
conditional formatting excell 2010,, as per attached sheet how i can apply conditional formatting in coloum b : 10 9 20 10 30 25 40 18 50 27 60 50 70 55 80 40 90 30 100 150 I want conditional formatting in b Colosseum less the a column[enter image description here][1] [1]: http://i.stack.imgur.com/rY4Ei.jpg
0debug
Getting all positions of bit 1 in javascript? : <p>I have provided binary for example, <code>01001</code>, and would like to get positions of bit 1, so I expect it will return me <code>[0, 3]</code>.</p> <p>Is there any function provided by javascript to get all positions of bit 1?</p>
0debug
static void sigp_cpu_restart(void *arg) { CPUState *cs = arg; S390CPU *cpu = S390_CPU(cs); struct kvm_s390_irq irq = { .type = KVM_S390_RESTART, }; kvm_s390_vcpu_interrupt(cpu, &irq); s390_cpu_set_state(CPU_STATE_OPERATING, cpu); }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
Promises not working on IE11 : <p>I'm new to Promises on javascript so I hope some can help me with this issue.</p> <p><strong>Problem:</strong> Promise not being execute on IE11, works fine on Chrome and FireFox</p> <p><strong>Frameworks used:</strong> I tried using es6-promise.d.ts and bluebird.d.ts same result.</p> <p>Code:</p> <pre><code>static executeSomething(): Promise&lt;any&gt; { console.log("inside executeSomething"); var test= new Promise((resolve, reject)=&gt; { console.log("inside Promise"); }).catch(function(error){console.log("error")}); console.log("after promise"); return test; } </code></pre> <p><strong>Results:</strong> on chrome and Firefox I can see all the logs but on IE11 I only see "Inside executeSomething" which means the problem is while creating the promise.</p> <p>I thought it was because IE11 didn't support es6 but I get the same result using bluebird, I hope some can bring some light to my issue.</p>
0debug
I want to hide woocommerce products from the shop loop which the user already puchased : <p>I want to hide those products from the shop loop which user already purchased </p>
0debug
How to fix "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory" error : <p>I'm trying to deploy a reactjs application to heroku. While compiling assets, the build fails and produces this error:</p> <pre><code>-----&gt; Ruby app detected -----&gt; Compiling Ruby/Rails -----&gt; Using Ruby version: ruby-2.5.1 -----&gt; Installing dependencies using bundler 1.15.2 Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. Fetching gem metadata from https://rubygems.org/............ Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Using rake 12.3.1 Using concurrent-ruby 1.1.3 Using minitest 5.11.3 Using thread_safe 0.3.6 Using builder 3.2.3 Using erubi 1.7.1 Using mini_portile2 2.3.0 Using crass 1.0.4 Using rack 2.0.6 Using nio4r 2.3.1 Using websocket-extensions 0.1.3 Using mini_mime 1.0.1 Using jsonapi-renderer 0.2.0 Using arel 9.0.0 Using mimemagic 0.3.2 Using public_suffix 3.0.3 Using airbrake-ruby 2.12.0 Using execjs 2.7.0 Using bcrypt 3.1.12 Using popper_js 1.14.5 Using rb-fsevent 0.10.3 Using ffi 1.9.25 Using bundler 1.15.2 Using regexp_parser 1.3.0 Using mime-types-data 3.2018.0812 Using chartkick 3.0.1 Using highline 2.0.0 Using connection_pool 2.2.2 Using orm_adapter 0.5.0 Using method_source 0.9.2 Using thor 0.19.4 Using multipart-post 2.0.0 Using geokit 1.13.1 Using temple 0.8.0 Using tilt 2.0.9 Using hashie 3.5.7 Using json 2.1.0 Using mini_magick 4.9.2 Using multi_json 1.13.1 Using newrelic_rpm 5.5.0.348 Using one_signal 1.2.0 Using xml-simple 1.1.5 Using pg 0.21.0 Using puma 3.12.0 Using rack-timeout 0.5.1 Using redis 4.0.3 Using secure_headers 6.0.0 Using swagger-ui_rails 0.1.7 Using i18n 1.1.1 Using nokogiri 1.8.5 Using tzinfo 1.2.5 Using websocket-driver 0.7.0 Using mail 2.7.1 Using marcel 0.3.3 Using addressable 2.5.2 Using rack-test 1.1.0 Using warden 1.2.8 Using sprockets 3.7.2 Using request_store 1.4.1 Using rack-protection 2.0.4 Using rack-proxy 0.6.5 Using autoprefixer-rails 9.4.2 Using uglifier 4.1.20 Using airbrake 7.4.0 Using rb-inotify 0.9.10 Using mime-types 3.2.2 Using commander 4.4.7 Using net-http-persistent 3.0.0 Using faraday 0.15.4 Using hashie-forbidden_attributes 0.1.1 Using omniauth 1.8.1 Using haml 5.0.4 Using slim 4.0.1 Using paypal-sdk-core 0.3.4 Using faker 1.9.1 from https://github.com/stympy/faker.git (at master@aca03be) Using money 6.13.1 Using loofah 2.2.3 Using xpath 3.2.0 Using activesupport 5.2.0 Using sidekiq 5.2.3 Using sass-listen 4.0.0 Using houston 2.4.0 Using stripe 4.2.0 Using paypal-sdk-adaptivepayments 1.117.1 Using monetize 1.9.0 Using rails-html-sanitizer 1.0.4 Using capybara 3.12.0 Using rails-dom-testing 2.0.3 Using globalid 0.4.1 Using activemodel 5.2.0 Using case_transform 0.2 Using decent_exposure 3.0.0 Using factory_bot 4.11.1 Using fast_jsonapi 1.5 Using groupdate 4.1.0 Using pundit 2.0.0 Using sass 3.7.2 Using actionview 5.2.0 Using activerecord 5.2.0 Using carrierwave 1.2.3 Using activejob 5.2.0 Using actionpack 5.2.0 Using bootstrap 4.1.3 Using actioncable 5.2.0 Using actionmailer 5.2.0 Using active_model_serializers 0.10.8 Using activestorage 5.2.0 Using railties 5.2.0 Using sprockets-rails 3.2.1 Using simple_form 4.1.0 Using responders 2.4.0 Using factory_bot_rails 4.11.1 Using font-awesome-rails 4.7.0.4 Using highcharts-rails 6.0.3 Using jquery-rails 4.3.3 Using lograge 0.10.0 Using money-rails 1.13.0 Using slim-rails 3.2.0 Using webpacker 3.5.5 Using rails 5.2.0 Using sass-rails 5.0.7 Using geokit-rails 2.3.1 Using swagger-docs 0.2.9 Using devise 4.5.0 Using devise_token_auth 1.0.0 Bundle complete! 68 Gemfile dependencies, 125 gems now installed. Gems in the groups development and test were not installed. Bundled gems are installed into ./vendor/bundle. Bundle completed (5.09s) Cleaning up the bundler cache. Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. The latest bundler is 2.0.1, but you are currently running 1.15.2. To update, run `gem install bundler` -----&gt; Installing node-v10.14.1-linux-x64 -----&gt; Installing yarn-v1.12.3 -----&gt; Detecting rake tasks -----&gt; Preparing app for Rails asset pipeline Running: rake assets:precompile yarn install v1.12.3 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... info fsevents@1.2.4: The platform "linux" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation. [4/5] Linking dependencies... warning "@rails/webpacker &gt; postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697". warning " &gt; react-addons-css-transition-group@15.6.2" has incorrect peer dependency "react@^15.4.2". warning " &gt; react-bootstrap-table-next@1.4.0" has unmet peer dependency "classnames@^2.2.5". warning " &gt; react-progressbar@15.4.1" has incorrect peer dependency "react@^15.0.1". warning " &gt; redux-immutable@4.0.0" has unmet peer dependency "immutable@^3.8.1 || ^4.0.0-rc.1". warning "eslint-config-airbnb &gt; eslint-config-airbnb-base@11.3.2" has incorrect peer dependency "eslint-plugin-import@^2.7.0". warning " &gt; webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0". warning "webpack-dev-server &gt; webpack-dev-middleware@1.12.2" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0". [5/5] Building fresh packages... $ cd client &amp;&amp; yarn yarn install v1.12.3 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... info fsevents@1.2.4: The platform "linux" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation. [4/5] Linking dependencies... warning " &gt; babel-loader@7.1.0" has unmet peer dependency "webpack@2 || 3". warning " &gt; react-intl@2.3.0" has incorrect peer dependency "react@^0.14.9 || ^15.0.0". warning " &gt; react-router-dom@4.1.1" has incorrect peer dependency "react@^15". warning " &gt; react-router-redux@5.0.0-alpha.6" has incorrect peer dependency "react@^15". warning " &gt; enzyme@2.8.2" has incorrect peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || 15.x". warning " &gt; eslint-import-resolver-webpack@0.8.3" has unmet peer dependency "webpack@&gt;=1.11.0". warning " &gt; html-webpack-plugin@2.29.0" has unmet peer dependency "webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3". warning "image-webpack-loader &gt; file-loader@1.1.11" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0". warning " &gt; react-test-renderer@15.6.1" has incorrect peer dependency "react@^15.6.1". [5/5] Building fresh packages... Done in 31.85s. Done in 76.09s. Webpacker is installed 🎉 🍰 Using /tmp/build_8f521e11fc612876bcd3c01cd8da6bdd/config/webpacker.yml file for setting up webpack paths Compiling… Compilation failed: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x8dbaa0 node::Abort() [node] 2: 0x8dbaec [node] 3: 0xad83de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 4: 0xad8614 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 5: 0xec5c42 [node] 6: 0xec5d48 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node] 7: 0xed1e22 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 8: 0xed2754 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 9: 0xed53c1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node] 10: 0xe9e844 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node] 11: 0x113dfae v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node] 12: 0x2daefc5be1d &lt;--- Last few GCs ---&gt; [587:0x2713f20] 1469419 ms: Mark-sweep 1362.0 (1417.7) -&gt; 1361.9 (1418.2) MB, 1183.8 / 0.0 ms (average mu = 0.099, current mu = 0.004) allocation failure scavenge might not succeed [587:0x2713f20] 1470575 ms: Mark-sweep 1363.1 (1418.7) -&gt; 1362.9 (1419.7) MB, 1151.7 / 0.0 ms (average mu = 0.053, current mu = 0.004) allocation failure scavenge might not succeed &lt;--- JS stacktrace ---&gt; ==== JS stack trace ========================================= 0: ExitFrame [pc: 0x2daefc5be1d] Security context: 0x395bbaa1e6e1 &lt;JSObject&gt; 1: addMappingWithCode [0x1a4bb3f1a89] [/tmp/build_8f521e11fc612876bcd3c01cd8da6bdd/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:~150] [pc=0x2daf487dfd2](this=0x08663a09ad49 &lt;JSGlobal Object&gt;,mapping=0x2969e26a1e61 &lt;Object map = 0x1067d74ad2e1&gt;,code=0x3e38d99f4479 &lt;String[6]: break &gt;) 2: /* anonymous */ [0x1a4bb3dcc79] [/tmp/... ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app. ! Push failed </code></pre> <p>I've tried various methods in my <code>package.json</code> file:</p> <pre><code>"scripts" : { "start": "cross-env NODE_OPTIONS=--max_old_space_size=5120 webpack" } "scripts" : { "webpacker": "node --max-old-space-size=4096 node_modules/.bin/react-scripts start" } "scripts" : { "start": "node --max-old-space-size=6144 client/app/app.js" } </code></pre> <p>I've researched and found various github and stackoverflow threads but they do not seem to fix my issue.</p> <ul> <li><a href="https://github.com/npm/npm/issues/12238" rel="noreferrer">https://github.com/npm/npm/issues/12238</a></li> <li><a href="https://stackoverflow.com/questions/44046366/increase-javascript-heap-size-in-create-react-app-project">Increase JavaScript Heap size in create-react-app project</a></li> </ul> <p>Here is my <code>package.json</code> file:</p> <pre><code>{ "name": "safe_deliver", "private": true, "engines": { "node": "&gt;=6.0.0", "yarn": "&gt;=0.25.2" }, "scripts": { "postinstall": "cd client &amp;&amp; yarn", "pre-commit": "cd client &amp;&amp; npm run lint:staged", "start": "cross-env NODE_OPTIONS=--max-old-space-size=6144 bin/webpack" }, "dependencies": { "@fortawesome/fontawesome": "^1.1.8", "@fortawesome/fontawesome-free": "^5.3.1", "@fortawesome/fontawesome-free-brands": "^5.0.13", "@fortawesome/fontawesome-free-regular": "^5.0.13", "@fortawesome/fontawesome-free-solid": "^5.0.13", "@fortawesome/fontawesome-svg-core": "^1.2.4", "@fortawesome/free-solid-svg-icons": "^5.3.1", "@fortawesome/react-fontawesome": "^0.1.3", "@rails/webpacker": "^3.3.1", "babel-plugin-emotion": "^9.2.6", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", "bootstrap": "4.0.0", "chart.js": "^2.7.3", "chartkick": "^3.0.1", "emotion": "^9.2.6", "google-maps-react": "^2.0.2", "jquery": "^3.2.1", "jquery-ujs": "^1.2.2", "leaflet": "^1.3.1", "normalize.css": "^8.0.1", "popper.js": "^1.12.9", "prop-types": "^15.6.1", "rc-time-picker": "^3.6.2", "react": "^16.4.1", "react-addons-css-transition-group": "^15.6.2", "react-animate-height": "^2.0.5", "react-bootstrap-table-next": "^1.4.0", "react-calendar": "^2.16.0", "react-datepicker": "^2.3.0", "react-dom": "^16.4.1", "react-emotion": "^9.2.6", "react-fontawesome": "^1.6.1", "react-geocode": "^0.1.2", "react-https-redirect": "^1.0.11", "react-input-mask": "^2.0.4", "react-progressbar": "^15.4.1", "react-star-rating-component": "^1.4.1", "react-stripe-elements": "^2.0.1", "reactjs-popup": "^1.3.2", "redux-immutable": "^4.0.0", "reset-css": "^4.0.1", "seamless-immutable": "^7.1.4", "styled-components": "^3.4.2" }, "devDependencies": { "eslint": "3.19.0", "eslint-config-airbnb": "15.0.1", "eslint-plugin-import": "2.2.0", "eslint-plugin-jsx-a11y": "5.0.3", "eslint-plugin-react": "7.0.1", "pre-commit": "1.2.2", "webpack-dev-server": "^2.7.1" } } </code></pre> <p>I am expecting this error to go away and the application to be deployed. Right now it is throwing javascript heap out of memory error.</p>
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
static void socket_start_outgoing_migration(MigrationState *s, SocketAddress *saddr, Error **errp) { QIOChannelSocket *sioc = qio_channel_socket_new(); qio_channel_socket_connect_async(sioc, saddr, socket_outgoing_migration, s, NULL); qapi_free_SocketAddress(saddr); }
1threat
Fix children container width truble : [Width Bug][1] [1]: http://i.stack.imgur.com/8Y8fM.png My children view may be a different width, but it not be bigger than parent view.How can i fix it?
0debug
How to extract json elements to variables in javascript : <p>I have json string like this:</p> <pre><code>[ {"COMPLIANCE_ID":"1/FIRST/US/191CC2/20160906/pW1WSpD/1","TOLERANCE":null,"WEIGHTED_ARR_LAST_SLP":"0.03801186624130076","SLIPPAGE_INTERVAL_VWAP_BPS":"10.2711","ROOT_ORDER_ID":"735422197553491","ENTERING_TRADER":"duffy_dma2","SECURITY_ID":"EOG.N","ARRIVAL_MID_PX":"93.6100","WEIGHTED_ARR_SLP":"0.12323190317127024","AVG_PX":"93.6586","ORDER_CCY":"USD","LEAVES_QTY":"0","WEIGHT":"0.02372627566400397","INITIATING_TRADER":null,"PARTICIPATION_RATE":"0E-12","LOCAL_REF_END_TIME":"2016-09-06 06:00:27.775","WEIGHTED_IVWAP_SLP":"0.2436949499725512","NOTIONAL_USD":"477940","LIST_ID":null,"SYM":"EOG","LIQ_CONSUMPTION":"15.21","URGENCY":null,"SIDE":"Sell Short","ALGO":"Hydra","EXECUTING_TRADER":"duffy_dma2","EXEC_QTY":"5103","CL_ORD_ID":"7245294057012908344","LOCAL_REF_START_TIME":"2016-09-06 05:59:57.844","SLIPPAGE_END_LAST_ARR_LAST_BPS":"1.6021","ORD_STATUS":"Filled","IVWAP_PX":"93.5625","LIMIT_PX":"93.6100","ORDER_ID":"735422197553491","VOLUME_LIMIT":"0E-12","SLIPPAGE_ARR_MID_BPS":"5.1939","ORDER_QTY":"5103","CLIENT_ACRONYM":"PEAKM","EXECUTION_STYLE":"2"},{"COMPLIANCE_ID":"1/FIRST/US/191CC2/20160906/pW1PUxP/1","TOLERANCE":null,"WEIGHTED_ARR_LAST_SLP":"-0.046488357264395964","SLIPPAGE_INTERVAL_VWAP_BPS":"0.1625","ROOT_ORDER_ID":"73855219760798","ENTERING_TRADER":"duffy_dma2","SECURITY_ID":"MCD.N","ARRIVAL_MID_PX":"118.0950","WEIGHTED_ARR_SLP":"-0.0041198933937856425","AVG_PX":"118.0923","ORDER_CCY":"USD","LEAVES_QTY":"0","WEIGHT":"0.01830250285999841","INITIATING_TRADER":null,"PARTICIPATION_RATE":"0E-12","LOCAL_REF_END_TIME":"2016-09-06 05:32:24.895","WEIGHTED_IVWAP_SLP":"0.002974156714749742","NOTIONAL_USD":"368684","LIST_ID":null,"SYM":"MCD","LIQ_CONSUMPTION":"62.82","URGENCY":null,"SIDE":"Sell","ALGO":"Hydra","EXECUTING_TRADER":"duffy_dma2","EXEC_QTY":"3122","CL_ORD_ID":"7244573979975932119","LOCAL_REF_START_TIME":"2016-09-06 05:32:19.697","SLIPPAGE_END_LAST_ARR_LAST_BPS":"-2.5400","ORD_STATUS":"Filled","IVWAP_PX":"118.0904","LIMIT_PX":"117.9900","ORDER_ID":"73855219760798","VOLUME_LIMIT":"0E-12","SLIPPAGE_ARR_MID_BPS":"-0.2251","ORDER_QTY":"3122","CLIENT_ACRONYM":"PEAKM","EXECUTION_STYLE":"4"}] </code></pre> <p>which I'm getting from another file in a js file:</p> <pre><code>var jsondata = document.getElementById("jsonArray").value; </code></pre> <p>How do I extract json elements from jsondata to variables like this:</p> <pre><code>RefData.COMPLIANCE_ID = [ "1/FIRST/US/191CC2/20160906/pW1WSpD/1", "1/FIRST/US/191CC2/20160906/pW1PUxP/1" ]; </code></pre> <p>etc..</p>
0debug
static int webvtt_event_to_ass(AVBPrint *buf, const char *p) { int i, again, skip = 0; while (*p) { for (i = 0; i < FF_ARRAY_ELEMS(webvtt_tag_replace); i++) { const char *from = webvtt_tag_replace[i].from; const size_t len = strlen(from); if (!strncmp(p, from, len)) { av_bprintf(buf, "%s", webvtt_tag_replace[i].to); p += len; again = 1; break; } } if (!*p) break; if (again) { again = 0; skip = 0; continue; } if (*p == '<') skip = 1; else if (*p == '>') skip = 0; else if (p[0] == '\n' && p[1]) av_bprintf(buf, "\\N"); else if (!skip && *p != '\r') av_bprint_chars(buf, *p, 1); p++; } return 0; }
1threat
How to access parameters of sys.argv Python? : <p>if given a command like:</p> <p>python 1.py ab 2 34</p> <p>How to print the next argument while you are currently sitting on the one before. e.g if x is ab then I want to print 2:</p> <pre><code>import sys for x in sys.argv[1:]: print next element after x </code></pre>
0debug
static int read_header(ShortenContext *s) { int i, ret; int maxnlpc = 0; if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); s->lpcqoffset = 0; s->blocksize = DEFAULT_BLOCK_SIZE; s->nmean = -1; s->version = get_bits(&s->gb, 8); s->internal_ftype = get_uint(s, TYPESIZE); s->channels = get_uint(s, CHANSIZE); if (!s->channels) { av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n"); if (s->channels > MAX_CHANNELS) { av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); s->channels = 0; s->avctx->channels = s->channels; if (s->version > 0) { int skip_bytes; unsigned blocksize; blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); if (!blocksize || blocksize > MAX_BLOCKSIZE) { av_log(s->avctx, AV_LOG_ERROR, "invalid or unsupported block size: %d\n", blocksize); return AVERROR(EINVAL); s->blocksize = blocksize; maxnlpc = get_uint(s, LPCQSIZE); s->nmean = get_uint(s, 0); skip_bytes = get_uint(s, NSKIPSIZE); if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) { av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes); for (i = 0; i < skip_bytes; i++) skip_bits(&s->gb, 8); s->nwrap = FFMAX(NWRAP, maxnlpc); if ((ret = allocate_buffers(s)) < 0) return ret; if ((ret = init_offset(s)) < 0) return ret; if (s->version > 1) s->lpcqoffset = V2LPCQOFFSET; if (s->avctx->extradata_size > 0) goto end; if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); for (i = 0; i < s->header_size; i++) s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); if (AV_RL32(s->header) == MKTAG('R','I','F','F')) { if ((ret = decode_wave_header(s->avctx, s->header, s->header_size)) < 0) return ret; } else if (AV_RL32(s->header) == MKTAG('F','O','R','M')) { if ((ret = decode_aiff_header(s->avctx, s->header, s->header_size)) < 0) return ret; } else { avpriv_report_missing_feature(s->avctx, "unsupported bit packing %" PRIX32, AV_RL32(s->header)); return AVERROR_PATCHWELCOME; end: s->cur_chan = 0; s->bitshift = 0; s->got_header = 1; return 0;
1threat
Print two different dictionary in the same line : i have a problem i don't know how to print two dictionary on the same line. I have: Fantasy = {Gotham:[city, 2000], Smallville:[town, 30]} Real = {London:[city, 1000], Whitby:[town, 40]} i Need to print this two dictionaries inline like this: Fantasy Real Gotham 2000 London 1000 Smalville 30 Whitby 40
0debug
void qemu_coroutine_enter(Coroutine *co) { Coroutine *self = qemu_coroutine_self(); CoroutineAction ret; trace_qemu_coroutine_enter(self, co, co->entry_arg); if (co->caller) { fprintf(stderr, "Co-routine re-entered recursively\n"); abort(); } co->caller = self; co->ctx = qemu_get_current_aio_context(); smp_wmb(); ret = qemu_coroutine_switch(self, co, COROUTINE_ENTER); qemu_co_queue_run_restart(co); switch (ret) { case COROUTINE_YIELD: return; case COROUTINE_TERMINATE: assert(!co->locks_held); trace_qemu_coroutine_terminate(co); coroutine_delete(co); return; default: abort(); } }
1threat
int tcp_socket_outgoing_opts(QemuOpts *opts) { Error *local_err = NULL; int fd = inet_connect_opts(opts, &local_err, NULL, NULL); if (local_err != NULL) { qerror_report_err(local_err); error_free(local_err); } return fd; }
1threat
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size) { const int data_ptr = 2 + AV_RL16(&buf[0]); int d, r, y; d = data_ptr; r = 2; y = 0; while(r < data_ptr) { int i, j; int length = buf[r] & 0x7f; int x = buf[r+1] + ((buf[r] & 0x80) << 1); r += 2; if (length==0) { y += x; continue; } for(i=0; i<length; i++) { for(j=0; j<8; j++) { int replace = (buf[r+i] >> (7-j)) & 1; if (replace) { int color = buf[d]; s->frame.data[0][y*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color; if (half_vert) { s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color; } d++; } x += half_horiz ? 2 : 1; } } r += length; y += half_vert ? 2 : 1; } }
1threat
Can I stop the transition to the next state in an onExit? : <p>I have two states, A and B. </p> <ul> <li>When I exit state A by clicking on a close button I do a transition to screen A using $state.go to state B (screen B) </li> <li>When I exit state A by clicking on the back browser button on screen A I do a transition to state B (screen B) as the browser URL changes</li> </ul> <p>In the onExit of screen A I do a check and if this fails an Error Dialog opens, clicking Close on the error dialog returns a failed promise to the onExit</p> <p>However the onExit still goes ahead and I go to screen B</p> <p>Is it possible to stop the transition from State A (Screen A) to State B (Screen B) if something fails in the onExit?</p>
0debug