problem
stringlengths
26
131k
labels
class label
2 classes
What should i do when offset fetch not working in SQL 2017 : Please help me I think it is in correct syntax. But why it alerts me incorrect in SQL2017 [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/YXFPR.png
0debug
static void evolve(AVFilterContext *ctx) { LifeContext *life = ctx->priv; int i, j; uint8_t *oldbuf = life->buf[ life->buf_idx]; uint8_t *newbuf = life->buf[!life->buf_idx]; enum { NW, N, NE, W, E, SW, S, SE }; for (i = 0; i < life->h; i++) { for (j = 0; j < life->w; j++) { int pos[8][2], n, alive, cell; if (life->stitch) { pos[NW][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NW][1] = (j-1) < 0 ? life->w-1 : j-1; pos[N ][0] = (i-1) < 0 ? life->h-1 : i-1; pos[N ][1] = j ; pos[NE][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NE][1] = (j+1) == life->w ? 0 : j+1; pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? life->w-1 : j-1; pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? 0 : j+1; pos[SW][0] = (i+1) == life->h ? 0 : i+1; pos[SW][1] = (j-1) < 0 ? life->w-1 : j-1; pos[S ][0] = (i+1) == life->h ? 0 : i+1; pos[S ][1] = j ; pos[SE][0] = (i+1) == life->h ? 0 : i+1; pos[SE][1] = (j+1) == life->w ? 0 : j+1; } else { pos[NW][0] = (i-1) < 0 ? -1 : i-1; pos[NW][1] = (j-1) < 0 ? -1 : j-1; pos[N ][0] = (i-1) < 0 ? -1 : i-1; pos[N ][1] = j ; pos[NE][0] = (i-1) < 0 ? -1 : i-1; pos[NE][1] = (j+1) == life->w ? -1 : j+1; pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? -1 : j-1; pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? -1 : j+1; pos[SW][0] = (i+1) == life->h ? -1 : i+1; pos[SW][1] = (j-1) < 0 ? -1 : j-1; pos[S ][0] = (i+1) == life->h ? -1 : i+1; pos[S ][1] = j ; pos[SE][0] = (i+1) == life->h ? -1 : i+1; pos[SE][1] = (j+1) == life->w ? -1 : j+1; } n = (pos[NW][0] == -1 || pos[NW][1] == -1 ? 0 : oldbuf[pos[NW][0]*life->w + pos[NW][1]] == ALIVE_CELL) + (pos[N ][0] == -1 || pos[N ][1] == -1 ? 0 : oldbuf[pos[N ][0]*life->w + pos[N ][1]] == ALIVE_CELL) + (pos[NE][0] == -1 || pos[NE][1] == -1 ? 0 : oldbuf[pos[NE][0]*life->w + pos[NE][1]] == ALIVE_CELL) + (pos[W ][0] == -1 || pos[W ][1] == -1 ? 0 : oldbuf[pos[W ][0]*life->w + pos[W ][1]] == ALIVE_CELL) + (pos[E ][0] == -1 || pos[E ][1] == -1 ? 0 : oldbuf[pos[E ][0]*life->w + pos[E ][1]] == ALIVE_CELL) + (pos[SW][0] == -1 || pos[SW][1] == -1 ? 0 : oldbuf[pos[SW][0]*life->w + pos[SW][1]] == ALIVE_CELL) + (pos[S ][0] == -1 || pos[S ][1] == -1 ? 0 : oldbuf[pos[S ][0]*life->w + pos[S ][1]] == ALIVE_CELL) + (pos[SE][0] == -1 || pos[SE][1] == -1 ? 0 : oldbuf[pos[SE][0]*life->w + pos[SE][1]] == ALIVE_CELL); cell = oldbuf[i*life->w + j]; alive = 1<<n & (cell == ALIVE_CELL ? life->stay_rule : life->born_rule); if (alive) *newbuf = ALIVE_CELL; else if (cell) *newbuf = cell - 1; else *newbuf = 0; av_dlog(ctx, "i:%d j:%d live_neighbors:%d cell:%d -> cell:%d\n", i, j, n, cell, *newbuf); newbuf++; } } life->buf_idx = !life->buf_idx; }
1threat
Detecting matching bits in C++ : <p>I'm trying to take two <code>bitset</code> objects, for example </p> <pre><code>a = 10010111 b = 01110010 </code></pre> <p>and remove bits from both variables if they match in the same position/index. So we'd be left with</p> <pre><code>a = 100xx1x1 = 10011 b = 011xx0x0 = 01100 </code></pre> <p>Is there any way to achieve this?</p>
0debug
Encrypt data before sending to SQL by VB.NET : <p>I need to create an application where most of the data written to DB is encrypted. For that sake it shouldn't be visible/obtainable by any of the super users who can access that DB Server. Which is ok because the data is to be encrypted. The problem is that I should not have a way to see it or way to obtain it neither, however the manager user should be able to see it.</p> <p>The application will be authenticating users using LDAP however I could grab the password when it's inputed to the form by the user and use that password as an encryption key so all data gets saved to DB encrypted and can be decrypted with that same password.</p> <p>I have few concerns with this idea:</p> <ol> <li>What if the user forgets password and gets a new one by doing password reset on LDAP?</li> <li>How can I give access to this data to manager user?</li> </ol> <p>I am thinking I could store the first password inputed by the user in DB encrypted with some built in function and use the encrypted string without decrypting. I could then give the manager users a way to decrypt this data using those keys but again that means I know how it works so I can take those keys from DB and decrypt if I wanted to.</p> <p>What is the best approach here?</p> <p>Regards Matt</p>
0debug
Generating heatmap layer for milions of points : <p>I'm using heatmap layer from Google Maps to display a heatmap, however, I now have too many points and it stopped working, because browser cannot handle it anymore. I've found that they provide Fusion Tables, but they're also limited: to 100k rows, which is way too low. I need to render heatmap of milions or maybe even more points. I'd be perfect if my server can have some PHP script to render a heatmap, for example, once a day. And then a client from js will just download a preloaded heatmap (on the map like google maps, but may be different map too). Is this possible with some existing technology (can be commercial)?</p>
0debug
static void qcow2_close(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; qemu_vfree(s->l1_table); s->l1_table = NULL; if (!(s->flags & BDRV_O_INACTIVE)) { qcow2_inactivate(bs); } cache_clean_timer_del(bs); qcow2_cache_destroy(bs, s->l2_table_cache); qcow2_cache_destroy(bs, s->refcount_block_cache); qcrypto_cipher_free(s->cipher); s->cipher = NULL; g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); g_free(s->image_backing_file); g_free(s->image_backing_format); g_free(s->cluster_cache); qemu_vfree(s->cluster_data); qcow2_refcount_close(bs); qcow2_free_snapshots(bs); }
1threat
Serving static javascript in nodejs : I'm trying to serve my bootstrap.min.js to the page. But for some reason it isn't working. But the bootstrap.min.css works perfectly fine. What did I do wrong? [![Image of the code in Atom][1]][1] [1]: https://i.stack.imgur.com/L9pGs.png In the picture you can see my structure and part of my code. There isn't much going on really. I'm trying to serve the javascript like this: <script type="text/javascript" src="../js/bootstrap.min.js"></script> <script type="text/javascript" src="../js/jquery.min.js"></script> I do the same for the css and it works.
0debug
Array pointer data being cleared in between function calls without an explicit command? : <p>I have the following issue:</p> <p>In a C++ program I have a global data structure declared as <code>Renderer Rendering_Handler</code>, which contains a member field defined as <code>vector&lt;Render_Info&gt; visble objects</code>.</p> <p>What the data structures themselves are doing is not important, they are wrappers needed to abstract data to parallelize my program.</p> <p>To be clear, Rendering_Handler is completely global, and it's in fact a singleton (I can 100% confirm that the constructor has been called once and only once for this class).</p> <p>I have declared the following class method:</p> <pre><code>Render_Info* Renderer::add_Render_Info() { visible_objects.push_back(Render_Info()); return &amp;(visible_objects.back()); } </code></pre> <p>Simple enough, it creates a new <code>Render_Info</code> structure, appends it to the <code>visible_objects</code> array and returns a pointer to the object.</p> <p>A different data structure called <code>Chunk</code> has a constructor defined as</p> <pre><code>Chunk::Chunk(vec3 offset, World* w) { /*initialize some values*/ draw_info = Rendering_Handler-&gt;add_Render_Info(); draw_info-&gt;VBOs = vector&lt;GLuint&gt;(5); /*initialize OpenGL VAOs, VBOs and other buffer objects*/ cout &lt;&lt; draw_info-&gt;VBOs.size() &lt;&lt; endl; cout &lt;&lt; draw_info &lt;&lt; endl; } </code></pre> <p>It also has a method defined as:</p> <pre><code>void Chunk::update_render_info() { cout &lt;&lt; draw_info-&gt;VBOs.size() &lt;&lt; endl; cout &lt;&lt; draw_info &lt;&lt; endl; /*OpenGL stuff*/ } </code></pre> <p>And finally</p> <p>We have the method that initializes everything:</p> <pre><code>World::World() { /*Initialize chunks in a circular 3D array*/ loaded_chunks = new Chunk_Holder(h_radius, h_radius, v_radius, this); for(int i=0; i&lt;h_radius; i++) { for(int j=0; j&lt;h_radius; j++) { for(int k=0; k&lt;v_radius; k++) { (*loaded_chunks)(i,j,k)-&gt;update(); } } } } </code></pre> <p>The output of the rpgram is:</p> <p><a href="https://i.stack.imgur.com/NUqLm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NUqLm.png" alt="enter image description here"></a></p> <p>...</p> <p><a href="https://i.stack.imgur.com/6xbPY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6xbPY.png" alt="enter image description here"></a></p> <p>Let's focus on the frist 2 and last 2 lines of the output, which correspond to the print statements I have added for debugging.</p> <p>The first 2 lines indicate that 5 elements have been added to the buffer at location 0x556edb7ae200</p> <p>The last 2 lines tell me that the same buffer (same since the memory location is the same) now contains 0 elements.</p> <p>As you can see from the snaps of the code, no function is called in between creating the Chunks and updating them. Does anybody have an idea of what could be causing the dissapearance of these elements? </p> <p>Have I not correctly reserved the memory? Are these objects being cleared without my knowledge due to wrong allocation?</p>
0debug
"network not manually attachable" when running one-off command against docker swarm network : <p>I'm trying to run a one-off command to initialise a database schema in a new docker swarm which is deployed with 1.13's new support for docker-compose files.</p> <p>The swarm has the following network:</p> <pre><code>$ docker network ls NETWORK ID NAME DRIVER SCOPE ... b7dptlu8zyqa vme_internal overlay swarm ... </code></pre> <p>defined in the <code>docker-compose.yml</code> file as:</p> <pre><code>networks: internal: </code></pre> <p>The command I run is</p> <pre><code>docker run --rm --network vme_internal app:0.1 db upgrade </code></pre> <p>with the extra <code>vme_</code> prefix coming from the name that I gave the stack when deploying. Now when I run the above command, I get:</p> <pre><code>docker: Error response from daemon: Could not attach to network vme_internal: rpc error: code = 7 desc = network vme_internal not manually attachable. </code></pre> <p>How do I make the network attachable?</p> <p>I couldn't find any specific info about attachable in <a href="https://docs.docker.com/compose/networking/%22Docker%20networking%22" rel="noreferrer">Docker networking</a> and tried adding an attribute <code>attachable</code> to the network definition without success.</p>
0debug
String's hascode value can be changed? : <p>I need one help to understand String class, I wrote a program where i have created one string with new keyword and other one with literal, below is program. here my confusion is why string s (literal one) got changed , as string is immutable so only value have to change why hashcode got changed. is it because of intern() method, Please help me to understand this.</p> <pre><code> String s = "xyz"; String s1 = new String("abc"); System.out.println(s.hashCode()+"--&gt; hashcode before literal string"); System.out.println(s1.hashCode()+"--&gt; hashcode before new keyword string"); System.out.println(s+"--&gt; before case S value "); s = s1; System.out.println(s+ "--&gt; after case S value"); System.out.println(s.hashCode()+"--&gt; hashcode after literal string"); System.out.println(s1.hashCode()+"--&gt; hashcode after new keyword string"); </code></pre> <hr> <p>the output of this is </p> <p>119193--> hashcode, before literal string</p> <p>96354--> hashcode, before new keyword string</p> <p>xyz--> before case S value </p> <p>abc--> after case S value</p> <p>96354--> hashcode, after literal string</p> <p>96354--> hashcode, after new keyword string </p>
0debug
Google Play Store Security Alert Says that your app contains Vulnerable JavaScript libraries how to remove the security warning? : <p>In Google Play Store am getting warning below like this,</p> <p>Your app contains one or more libraries with known security issues. Please see this <a href="https://support.google.com/faqs/answer/9464300" rel="noreferrer">Google Help Center article</a> for details.</p> <p>Vulnerable JavaScript libraries:</p> <ul> <li>Name --> jquery</li> <li>Version --> 3.3.1</li> <li>Known issues --> SNYK-JS-JQUERY-174006</li> <li>Identified files --> res/raw/jquery_min.js</li> </ul> <p>Note: when loading webview in my app i will InterceptRequest in webview url and load the local jquery_min.js file from raw folder resource which helps us to load the webpage faster due this function and i save 5 gb download from server per month.</p> <p><a href="https://i.stack.imgur.com/Gl0pA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Gl0pA.png" alt="enter image description here"></a></p> <p>Sample WebView Program</p> <pre><code> LoadLocalScripts localScripts=new LoadLocalScripts(this); webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { return true; } //Show loader on url load public void onLoadResource(WebView view, String url) { } public void onPageFinished(WebView view, String url) { } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { } @Override public WebResourceResponse shouldInterceptRequest (final WebView view, String url) { WebResourceResponse response= localScripts.getLocalSCripts(url); if(response==null) { return super.shouldInterceptRequest(view, url); }else{ return response; } } }); webView.loadUrl(url); </code></pre> <p>Class for Loading local scripts</p> <pre><code> public class LoadLocalScripts { private Context ctx; public LoadLocalScripts(Context context) { ctx=context; } public WebResourceResponse getLocalSCripts(String url) { //Log.e("url_raw",url); if (url.contains(".css")) { if(url.contains("bootstrap.min.css")) { return getCssWebResourceResponseFromRawResource("bootstrap_min.css"); }else { return null; } }else if (url.contains(".js")){ if(url.contains("bootstrap.min.js")) { return getScriptWebResourceResponseFromRawResource("bootstrap_min.js"); } else if(url.contains("jquery.lazyload.min.js")) { return getScriptWebResourceResponseFromRawResource("lazyload_min.js"); } else{ return null; } } else { return null; } } /** * Return WebResourceResponse with CSS markup from a raw resource (e.g. "raw/style.css"). */ private WebResourceResponse getCssWebResourceResponseFromRawResource(String url) { //Log.e("url_raw",url); if(url.equalsIgnoreCase("bootstrap_min.css")) { return getUtf8EncodedCssWebResourceResponse(ctx.getResources().openRawResource(R.raw.bootstrap_min)); }else { return null; } } private WebResourceResponse getScriptWebResourceResponseFromRawResource(String url) { //Log.e("url_raw",url); if(url.equalsIgnoreCase("bootstrap_min.js")) { return getUtf8EncodedScriptWebResourceResponse(ctx.getResources().openRawResource(R.raw.bootstrap_min_js)); }else if(url.equalsIgnoreCase("lazyload_min.js")) { return getUtf8EncodedScriptWebResourceResponse(ctx.getResources().openRawResource(R.raw.lazyload_min)); }else { return null; } } private WebResourceResponse getUtf8EncodedCssWebResourceResponse(InputStream data) { return new WebResourceResponse("text/css", "UTF-8", data); } private WebResourceResponse getUtf8EncodedScriptWebResourceResponse(InputStream data) { return new WebResourceResponse("text/javascript", "UTF-8", data); } } </code></pre> <ol> <li>If i update new to Jquery script will google play remove Security Alert (Vulnerable JavaScript libraries)?</li> <li>If i place Jquery script somewhere else in my app will google play remove Security Alert?</li> <li>Let me know what is the efficient way of loading the script in webview without loading everytime from the server.</li> </ol>
0debug
plot mulitple lines in ggplot : I need to plot hourly data for different days using ggplot, and here is my dataset: [enter image description here][1] [1]: https://i.stack.imgur.com/lN7PN.png. The data consists of hourly observations, and I want to plot each day's observation into one separate line. Please advice on this.
0debug
session does not start when user first logs in on on the second attempt : <p>Please can you help, i am new to php but starting to get a bit of grip but sessions are causing me a problem, i have been stuck on this for a while now. </p> <p>I have a basic html / php log in form, the form should put the username from the form into a session and then the rest of the php scripts use this session data for various sql queries.</p> <p>My problem is that the login username will only go into the session on the second attempt, the first attempt results in nothing going into the session and a blank return? but if i go back and repeat the log the data goes into the session fine?</p> <p>I have been looking in the answers already posted and the most relevant told me to add the full web address in the redirect url but this had no effect.</p> <p>Please can someone help me as this is driving me mad!! </p> <p>Here is the html form:</p> <pre><code>&lt;table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"&gt; &lt;tr&gt; &lt;form name="form1" method="post" action="checkLogIn.php"&gt; &lt;td&gt; &lt;table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"&gt; &lt;tr&gt; &lt;td colspan="3"&gt;&lt;div align="center"&gt;&lt;strong&gt;Employee Log In&lt;/strong&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="27%"&gt;Username&lt;/td&gt; &lt;td width="4%"&gt;:&lt;/td&gt; &lt;td width="69%"&gt;&lt;input name="myusername" type="text" id="myusername2"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Password&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;input name="mypassword" type="password" id="mypassword2"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/form&gt; &lt;/tr&gt; &lt;/table&gt; &lt;?php // Start the session session_start(); echo "Welcome ".$_SESSION['user']."!"; ?&gt; </code></pre> <p>The PHP script:</p> <pre><code>&lt;?php session_start(); $host="db659279157.db.1and1.com"; // Host name $username="dbo659279157"; // Mysql username $password="password1"; // Mysql password $db_name="db659279157"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $_SESSION['user'] = $myusername; echo "Welcome ".$_SESSION['user']."!"; echo "&lt;meta http-equiv=\"refresh\" content=\"0;URL=http://www.morgan- data.co.uk/logInHome.php\"&gt;"; } else { echo "&lt;p&gt;Wrong Username Or Password, Please Press Back To Try Again&lt;/p&gt;"; } ?&gt; </code></pre> <p>The page the user is directed to with successful log in:</p> <pre><code>&lt;body&gt; &lt;div align="center"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;a href="../php/insert2.php"&gt;&lt;img src="../graphics/timesheet.jpg" width="225" height="225" border="0"&gt;&lt;/a&gt; &lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;a href="view.php"&gt;&lt;img src="../graphics/planner.jpg" width="240" height="175" border="0"&gt;&lt;/a&gt;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;a href="storeFinder.htm"&gt;&lt;img src="../graphics/location.gif" width="240" height="175" border="0"&gt;&lt;/a&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;div align="center"&gt;Submitt Timesheet&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;View Planner&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;Find Store Address&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;?php echo "Welcome ".$_SESSION['user']."!"; ?&gt; </code></pre> <p></p>
0debug
Incorrect syntaxis near AND clause : I have this JOIN LEFT MERGE JOIN (SELECT VOUCHER,TAXITEMGROUP,TAXCODE,TAXAMOUNT,TAXAMOUNTCUR,SOURCERECID, GENERALJOURNALACCOUNTENTRY FROM ##TGJAE TT WHERE (TT.TAXCODE LIKE 'RISR%')) TTRISR AND TT.POSTINGTYPE IN( 14,236,71) AND TT.TRANSDATE between @FECHA_INI AND @FECHA AND TT.TAXORIGIN = 11 AND ON C1.TT_VOUCHER = TTRISR.VOUCHER AND C1.TT_SOURCERECID = TTRISR.SOURCERECID AND C1.TT_TAXITEMGROUP = TTRISR.TAXITEMGROUP AND TTRISR.GENERALJOURNALACCOUNTENTRY = PRO.TTGJAEF_GENERALJOURNALACCOUNTENTRY But when I execute with SQL Managment Studio I get > Incorrect syntax near the keyword 'AND'. I don´t found problems with my AND clause, can anyone explain me what is wrong with my join? Regards
0debug
static void dead_tmp(TCGv tmp) { int i; num_temps--; i = num_temps; if (GET_TCGV(temps[i]) == GET_TCGV(tmp)) return; while (GET_TCGV(temps[i]) != GET_TCGV(tmp)) i--; while (i < num_temps) { temps[i] = temps[i + 1]; i++; } temps[i] = tmp; }
1threat
why am i getting this java.lang.NumberFormatException? : Hi i have written the folwing code where i am declaring a string then extracting the numbers and then assigning it into a variable 'result' where i am trying to convert the numbers which is in a form of string into Integer.However i am getting an exception called java.lang.NumberFormatException how do i avoid this exception. My code is as follows.Can anyone explain.:)..Cheers package trialprogram; public class Interviewaskedq { public static void main(String[] args) { // TODO Auto-generated method stub String S1="12SERT34"; String alpha=" "; String num=" "; for(int i=0;i<=S1.length()-1;i++) { char ch=S1.charAt(i); if(Character.isAlphabetic(ch)) { alpha=alpha+ch; } else if(Character.isDigit(ch)) { num=num+ch; } } int result = Integer.parseInt(num); } }
0debug
My script works the first time and does anymore not after reload on this online IDE : <p>I have a slight problem with this online code editor. When I launch my snippet, it only works one time. If I try to bring any modification to the code, it crashes for unknown reasons.</p> <p><a href="https://playcode.io/313059?tabs=console&amp;script.js&amp;output" rel="nofollow noreferrer">https://playcode.io/313059?tabs=console&amp;script.js&amp;output</a></p> <p>Any clue of what is going on here?</p>
0debug
Determine user's "Temperature Unit" setting on iOS 10 (Celsius / Fahrenheit) : <p>iOS 10 adds the ability for the user to set their "Temperature Unit" choice under Settings > General > Language &amp; Region > Temperature Unit.</p> <p>How can my app programmatically determine this setting so it can display the right temperature unit? I poured through NSLocale.h and didn't see anything relevant.</p> <p>(Before iOS 10, it was sufficient to test if the locale used metric and assume that metric users want to use Celsius. This is no longer the case.)</p>
0debug
void helper_sysenter(void) { if (env->sysenter_cs == 0) { raise_exception_err(EXCP0D_GPF, 0); } env->eflags &= ~(VM_MASK | IF_MASK | RF_MASK); cpu_x86_set_cpl(env, 0); cpu_x86_load_seg_cache(env, R_CS, env->sysenter_cs & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK); cpu_x86_load_seg_cache(env, R_SS, (env->sysenter_cs + 8) & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_W_MASK | DESC_A_MASK); ESP = env->sysenter_esp; EIP = env->sysenter_eip; }
1threat
SwsVector *sws_cloneVec(SwsVector *a) { int i; SwsVector *vec = sws_allocVec(a->length); if (!vec) return NULL; for (i = 0; i < a->length; i++) vec->coeff[i] = a->coeff[i]; return vec; }
1threat
void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, VirtIOBlockDataPlane **dataplane, Error **errp) { VirtIOBlockDataPlane *s; Error *local_err = NULL; BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); *dataplane = NULL; if (!conf->data_plane && !conf->iothread) { return; } if (!k->set_guest_notifiers || !k->set_host_notifier) { error_setg(errp, "device is incompatible with x-data-plane " "(transport does not support notifiers)"); return; } if (blk_op_is_blocked(conf->conf.blk, BLOCK_OP_TYPE_DATAPLANE, &local_err)) { error_setg(errp, "cannot start dataplane thread: %s", error_get_pretty(local_err)); error_free(local_err); return; } s = g_new0(VirtIOBlockDataPlane, 1); s->vdev = vdev; s->conf = conf; if (conf->iothread) { s->iothread = conf->iothread; object_ref(OBJECT(s->iothread)); } else { object_initialize(&s->internal_iothread_obj, sizeof(s->internal_iothread_obj), TYPE_IOTHREAD); user_creatable_complete(OBJECT(&s->internal_iothread_obj), &error_abort); s->iothread = &s->internal_iothread_obj; } s->ctx = iothread_get_aio_context(s->iothread); s->bh = aio_bh_new(s->ctx, notify_guest_bh, s); error_setg(&s->blocker, "block device is in use by data plane"); blk_op_block_all(conf->conf.blk, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_RESIZE, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_DRIVE_DEL, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_BACKUP_SOURCE, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_COMMIT, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_MIRROR, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_STREAM, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_REPLACE, s->blocker); *dataplane = s; }
1threat
Get first two digits of a long long number : <p>Hello I have a <code>long long</code> number which varies from 13,15, and 16 digits in length. I want to get the first two digits(from the left) of these numbers. For example:</p> <pre><code>Enter Number = 1234567890123; First 2 digits = 12 Enter Number = 453456789012345; First 2 digits = 45 Enter Number = 3534567890123456; First 2 digits = 35 </code></pre>
0debug
CharDriverState *qemu_chr_open(const char *filename) { const char *p; if (!strcmp(filename, "vc")) { return text_console_init(&display_state); } else if (!strcmp(filename, "null")) { return qemu_chr_open_null(); } else if (strstart(filename, "tcp:", &p)) { return qemu_chr_open_tcp(p, 0, 0); } else if (strstart(filename, "telnet:", &p)) { return qemu_chr_open_tcp(p, 1, 0); } else if (strstart(filename, "udp:", &p)) { return qemu_chr_open_udp(p); } else if (strstart(filename, "mon:", &p)) { CharDriverState *drv = qemu_chr_open(p); if (drv) { drv = qemu_chr_open_mux(drv); monitor_init(drv, !nographic); return drv; } printf("Unable to open driver: %s\n", p); return 0; } else #ifndef _WIN32 if (strstart(filename, "unix:", &p)) { return qemu_chr_open_tcp(p, 0, 1); } else if (strstart(filename, "file:", &p)) { return qemu_chr_open_file_out(p); } else if (strstart(filename, "pipe:", &p)) { return qemu_chr_open_pipe(p); } else if (!strcmp(filename, "pty")) { return qemu_chr_open_pty(); } else if (!strcmp(filename, "stdio")) { return qemu_chr_open_stdio(); } else #if defined(__linux__) if (strstart(filename, "/dev/parport", NULL)) { return qemu_chr_open_pp(filename); } else #endif if (strstart(filename, "/dev/", NULL)) { return qemu_chr_open_tty(filename); } else #else if (strstart(filename, "COM", NULL)) { return qemu_chr_open_win(filename); } else if (strstart(filename, "pipe:", &p)) { return qemu_chr_open_win_pipe(p); } else if (strstart(filename, "con:", NULL)) { return qemu_chr_open_win_con(filename); } else if (strstart(filename, "file:", &p)) { return qemu_chr_open_win_file_out(p); } #endif { return NULL; } }
1threat
regex find all utf8 text, started with # and end by space or enter : <p>I want render Utf8 text and link all tag that started with <code>#</code> and ended with <code>space</code> or <code>enter</code> or any separator such as <code>\r</code> <code>\t</code> <code>\n</code>.</p> <p>text example:</p> <pre><code>Текстовые теги #общий #тест Хиджаб в исламе, философии безопасности #женщин english #teg #test </code></pre>
0debug
Type cannot be used as an index type : <p>Go to <a href="https://www.typescriptlang.org/play/index.html" rel="noreferrer">https://www.typescriptlang.org/play/index.html</a> and paste: </p> <pre><code>let userTypes = {}; let keys = Object.keys[userTypes]; </code></pre> <p>receive error:</p> <pre><code>error TS2538: Type '{}' cannot be used as an index type. </code></pre> <p>Why?</p>
0debug
Is there any way to remove VSTS agent without PAT? : <p>I'm trying to remove a VSTS agent from a system, but I no longer possess the Personal Access Token (PAT) originally used during setup. An answer on <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/431f9a06-db69-49d4-8bc0-3bff9911f959/vsts-private-agent-authentication-with-pat-personal-access-tokens?forum=TFService" rel="noreferrer">this thread</a> states that I can just delete the agent from the VSTS web UI, but I don't see that option besides nuking the entire agent pool (which is not a great option for us).</p> <p>When I try to run <code>config.cmd remove</code>, these are my results:</p> <pre><code>PS C:\agent&gt; .\config.cmd remove Removing agent from the server Enter authentication type (press enter for PAT) &gt; Enter personal access token &gt; Enter personal access token &gt; Exiting... </code></pre>
0debug
I'm having some problems when I try localhost:3000 for programming with Google Chrome Browser : <p>I'm having many problems when I try use my localhost:3000 for programming in Ruby On Rails 4. When I put in the Chrome browser in my Mac OS X "El Capitan". This redirect's of this link</p> <pre><code>http://www.free-merchants.com/partner/promokod_aliexpress-by-alibabacom#e4da3b7fbbce2345d7772b0674a318d5-http%3A%2F%2Flocalhost%3A3000%2F </code></pre> <p>and then automaticallyfor the other called: <code>http://localhost/to.php?subid=31</code></p> <p>I think i have a virus. Anyone has this? </p>
0debug
Changing words on my website whilesomeone is logged in : <p>How can I set words on a page, in my case the words: "sign up/login" change to "profile" when someone is logged in on my site?</p> <p>I also want to add words that say, "welcome (profile name)</p> <p>(Website is in html5 and the page has a .php extension, on windows 10 if that helps) </p>
0debug
Python re.search Patterns : <p>I have a bunch of strings that consist of Q, D or T. Below are some examples.</p> <pre><code> aa= "QDDDDQDTDQTD" bb = "QDT" cc = "TDQDQQDTQDQ" </code></pre> <p>i am new to re.search, for each string, is it possible to get all patterns with any length that start with Q, and ends with D or Q, and there is no T in between the first Q and the last D or Q. </p> <p>So for aa, it would find "QDDDDQD"</p> <p>for bb, it would find "QD"</p> <p>for cc, it would find "QDQQD" and "QDQ" </p> <p>I understand the basic forms of using re.search like:</p> <pre><code> re.search(pattern, my_string, flags=0) </code></pre> <p>Just having trouble how to set up the patterns mentioned above, like how to find patterns start with Q, or ends with Q, etc. Any help would be greatly appreciated!</p>
0debug
static int eth_can_rx(NetClientState *nc) { struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; int r; r = !(s->regs[R_RX_CTRL0] & CTRL_S); return r; }
1threat
float on the <p> now working like float only if i aplied to img : in the next code if u use float left or right for the image work fine but if u use for the <p> i dont know why but is not working, i thinked that float was the same for bot if u applied float left and dont do a clear both will change the overflow but here isnt doing it <!DOCTYPE html> <html> <head> <style> p { float: right; } </style> </head> <body> <p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is that the image will float to the right in the paragraph. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </p> <img src="logocss.gif" width="95" height="84" /> </body> </html>
0debug
my jsp page gets error while inserting data into mysql databse : com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'gender' in 'field list' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3250) at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355) at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270) at org.apache.jsp.reg_jsp._jspService(reg_jsp.java:157) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) not insertedcom.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'gender' in 'field list'
0debug
iam beginner in android testing with Mockito : i want to test this method using mockito and unit testing `public class CurrentIP { public static String getIPAddress() { try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { String sAddr = addr.getHostAddress(); boolean isIPv4 = sAddr.indexOf(':') < 0; if (isIPv4) return sAddr; } } } } catch (Exception ignored) { } // for now eat exceptions return ""; } }`
0debug
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) { int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi; int num_blocks = s->coded_fragment_list_index; for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) { i = blocks_decoded = num_blocks_at_qpi = 0; bit = get_bits1(gb); do { run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1; if (run_length == 34) run_length += get_bits(gb, 12); blocks_decoded += run_length; if (!bit) num_blocks_at_qpi += run_length; for (j = 0; j < run_length; i++) { if (i > s->coded_fragment_list_index) return -1; if (s->all_fragments[s->coded_fragment_list[i]].qpi == qpi) { s->all_fragments[s->coded_fragment_list[i]].qpi += bit; j++; } } if (run_length == 4129) bit = get_bits1(gb); else bit ^= 1; } while (blocks_decoded < num_blocks); num_blocks -= num_blocks_at_qpi; } return 0; }
1threat
Removing spaces while printing with python : I'm printing my output in a file with a command like this print >> outfile, columns2[0],"\t",columns2[1],"\t",columns2[2] My problem is that I have a "space" at the end of the content of each column. I know some times it can be solve with "sep", like this print('foo', 'bar', sep='') But I don't know how implement "sep" while writing in a file with my command: print >> outfile Any suggestion? Thank you very much.
0debug
Most efficient Rails query method : <p>I've been looking into a few ways of writing efficient ActiveRecord queries and I thought I might put it out to gather a consensus on who thinks what might be best.</p> <pre><code>@page = @current_shop.pages.where(state: "home").first </code></pre> <p>At the moment, I've surmised that find_by_sql might be the best route?</p>
0debug
PHP: How to constantly add to a database : <p>I'll be constantly adding stock prices into a database, But what "settings/variables" do I put into the database to allow it to accept multiple values for a field? So later I can echo the SQL Database out?</p>
0debug
Add a random prefix to the key names to improve S3 performance? : <p>You expect this bucket to immediately receive over 150 PUT requests per second. What should the company do to ensure optimal performance?</p> <p>A) Amazon S3 will automatically manage performance at this scale.</p> <p>B) Add a random prefix to the key names.</p> <p>The correct answer was B and I'm trying to figure out why that is. Can someone please explain the significance of B and if it's still true?</p>
0debug
Spark UDF for StructType / Row : <p>I have a "StructType" column in spark Dataframe that has an array and a string as sub-fields. I'd like to modify the array and return the new column of the same type. Can I process it with UDF? Or what are the alternatives?</p> <pre><code>import org.apache.spark.sql.types._ import org.apache.spark.sql.Row val sub_schema = StructType(StructField("col1",ArrayType(IntegerType,false),true) :: StructField("col2",StringType,true)::Nil) val schema = StructType(StructField("subtable", sub_schema,true) :: Nil) val data = Seq(Row(Row(Array(1,2),"eb")), Row(Row(Array(3,2,1), "dsf")) ) val rd = sc.parallelize(data) val df = spark.createDataFrame(rd, schema) df.printSchema root |-- subtable: struct (nullable = true) | |-- col1: array (nullable = true) | | |-- element: integer (containsNull = false) | |-- col2: string (nullable = true) </code></pre> <p>It seems that I need a UDF of the type Row, something like </p> <pre><code>val u = udf((x:Row) =&gt; x) &gt;&gt; Schema for type org.apache.spark.sql.Row is not supported </code></pre> <p>This makes sense, since Spark does not know the schema for the return type. Unfortunately, udf.register fails too: </p> <pre><code>spark.udf.register("foo", (x:Row)=&gt; Row, sub_schema) &lt;console&gt;:30: error: overloaded method value register with alternatives: ... </code></pre>
0debug
Flutter: upgrade the version code for play store : <p>i have published an application on the play store with flutter, now i want to upload a new version of the application. I am trying to change the version code with: </p> <blockquote> <p>flutter build apk --build-name=1.0.2 --build-number=3 </p> </blockquote> <p>or changing the local.properties like this</p> <pre><code> flutter.versionName=2.0.0 flutter.versionCode=2 flutter.buildMode=release </code></pre> <p>but everytime i get error on the playstore</p> <blockquote> <p>You must use a different version code for your APK or your Android App Bundle because the code 1 is already assigned to another APK or Android App Bundle.</p> </blockquote>
0debug
How do I convert a list to Uppercase : I am new to coding and I need help with this coding problem . my problem is that I need to convert the "letter_guessed" input to lower case ,if its upper case and if the uppercase letter is already exists inside the list as a lower case it will return false but I cant get to do it . I have tried using isupper(),upper ,islower(), lower() in many ways , I am pretty sure that I am doing something wrong with "if" but cant get it right been stuck on it for two days . Thanks in advance !! def check_valid_input(letter_guessed, old_letters_guessed): while True: """ will work only if you enter one letter and do not contain special letters other then the abc and if its all ready been entered it will show false """ if len(letter_guessed) == 1 and letter_guessed not in old_letters_guessed : """if the letter is one letter and not already inside old_letter_guessed only then continue """ old_letters_guessed.append(letter_guessed) print("True") letter_guessed = input(" : ") else: """ if its wrong input will print False Try again and if the input is correct it will go back to " if " """ #old_letters_guessed.append(letter_guessed) print(False, 'Try again') old_letters_guessed.sort() print('->'.join(old_letters_guessed)) letter_guessed = input(" : ") #if letter_guessed is letter_guessed.isupper() new = input() old = [] check_valid_input(new,old)
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Resize dynamic string array : <p>How can I resize a dynamic multidimensional array <code>std::string**</code> in C++ without using C methods like <code>malloc/free</code>?</p>
0debug
static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb, const AVFrame *frame) { LJpegEncContext *s = avctx->priv_data; const int width = frame->width; const int height = frame->height; const int linesize = frame->linesize[0]; uint16_t (*buffer)[4] = s->scratch; const int predictor = avctx->prediction_method+1; int left[3], top[3], topleft[3]; int x, y, i; for (i = 0; i < 3; i++) buffer[0][i] = 1 << (9 - 1); for (y = 0; y < height; y++) { const int modified_predictor = y ? predictor : 1; uint8_t *ptr = frame->data[0] + (linesize * y); if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 3 * 3) { av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } for (i = 0; i < 3; i++) top[i]= left[i]= topleft[i]= buffer[0][i]; for (x = 0; x < width; x++) { buffer[x][1] = ptr[3 * x + 0] - ptr[3 * x + 1] + 0x100; buffer[x][2] = ptr[3 * x + 2] - ptr[3 * x + 1] + 0x100; buffer[x][0] = (ptr[3 * x + 0] + 2 * ptr[3 * x + 1] + ptr[3 * x + 2]) >> 2; for (i = 0; i < 3; i++) { int pred, diff; PREDICT(pred, topleft[i], top[i], left[i], modified_predictor); topleft[i] = top[i]; top[i] = buffer[x+1][i]; left[i] = buffer[x][i]; diff = ((left[i] - pred + 0x100) & 0x1FF) - 0x100; if (i == 0) ff_mjpeg_encode_dc(pb, diff, s->huff_size_dc_luminance, s->huff_code_dc_luminance); else ff_mjpeg_encode_dc(pb, diff, s->huff_size_dc_chrominance, s->huff_code_dc_chrominance); } } } return 0; }
1threat
Store Data from formatted text file to Linked List c++ : I'm working on a Project @Student Course Registration System, I'm having problems Reading From a Text File and storing it in Singly Linked List, which gets updated every time a new student is added. The Data is stored in an formatted way. The Problem is my Struct has type **"char"** variables, so it gives me as Assignment Error. Following is my code: struct Code: struct Student { char stdID[10]; char stdName[30]; char stdSemester[5]; Student *next; } *Head,*Tail; Saving Code: // For Saving: SFile << std->stdID << '\t' << std->stdName << '\t' << std->stdSemester << '\n'; Display Code (Reading From Text File): // Display: system("cls"); cout << "\n\n\n"; cout << "\t\t\t\t LIST OF COURSES" << endl; cout << "\t\t\t ====================================================\n" << endl; cout << "\t" << "ID" << "\t" << setw(15) << "Course Name" << "\n\n"; // Initialize: char ID[10]; char Name[30]; char Sem[5]; ifstream SFile("StudentRecord.txt"); Student *Temp = NULL; while(!SFile.eof()) { // Get: SFile.getline(ID, 10, '\t'); SFile.getline(Name, 30, '\t'); SFile.getline(Sem, 5, '\t'); Student *Std = new Student; //node*c=new node; // Assign: Std->stdID = *ID; if (Head == NULL) { Head = Std; } else { Temp = Head; { while ( Temp->next !=NULL ) { Temp=Temp->next; } Temp->next = Std; } } } SFile.close(); system("pause"); } P.S: I'm Having Problem at Assign Comment; Will I have to change data type and make the whole project in String? I preferred char because I was able to format the output, and in String i'm sure it reads line by line, so I wont be able stores values from single line. Thank You! :)
0debug
Using php expire cookie after 30th visit : <p>I have cookie with useranme "ABC" . How can I set it,such that it would expire after 30th visit.</p>
0debug
why we have to use index!=1 for alphabets in java : Iam unable to get why we should use idx != -1 in a if statement here is my friend's code public static String encrypt(String input, int key) { String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String shifted =alphabet.substring(key)+alphabet.substring(0,key); StringBuilder encrypted=new StringBuilder(input); for(int i=0; i<encrypted.length();i++) { char current=encrypted.charAt(i); int idx=alphabet.indexOf(current); if(idx !=-1) { char newchar = shifted.charAt(idx); encrypted.setCharAt(i, newchar); } } return encrypted.toString(); } please help me Thanks.
0debug
void helper_retry(CPUSPARCState *env) { trap_state *tsptr = cpu_tsptr(env); env->pc = tsptr->tpc; env->npc = tsptr->tnpc; cpu_put_ccr(env, tsptr->tstate >> 32); env->asi = (tsptr->tstate >> 24) & 0xff; cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f); cpu_put_cwp64(env, tsptr->tstate & 0xff); if (cpu_has_hypervisor(env)) { uint32_t new_gl = (tsptr->tstate >> 40) & 7; env->hpstate = env->htstate[env->tl]; cpu_gl_switch_gregs(env, new_gl); env->gl = new_gl; } env->tl--; trace_win_helper_retry(env->tl); #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { cpu_check_irqs(env); } #endif }
1threat
Run triggered Azure WebJob from Code : <p>I created a console application upload as Azure trigger Webjob. It is working fine when I run it from Azure Portal. I want to run this from my C# code. I don't want to use Queue or service bus. I just want to trigger it when user perform a specific action in my web app. </p> <p>After searching I got a solution to trigger job from a scheduled <a href="http://blog.davidebbo.com/2015/05/scheduled-webjob.html" rel="noreferrer">http://blog.davidebbo.com/2015/05/scheduled-webjob.html</a></p> <p>Any idea how to run from code? </p>
0debug
int vhost_set_vring_enable(NetClientState *nc, int enable) { VHostNetState *net = get_vhost_net(nc); const VhostOps *vhost_ops; nc->vring_enable = enable; if (!net) { return 0; } vhost_ops = net->dev.vhost_ops; if (vhost_ops->vhost_set_vring_enable) { return vhost_ops->vhost_set_vring_enable(&net->dev, enable); } return 0; }
1threat
Signing ElasticSearch AWS calls : <p>I'm attempting to sign all of our AWS calls to ElasticSearch however the response is always;</p> <p><code>User: anonymous is not authorized to perform: es:ESHttpGet on resource:</code></p> <p>I've tried multiple key pairs and IAM users.</p> <p>The calls within our PHP are made using the official <a href="https://github.com/elastic/elasticsearch-php" rel="noreferrer">elasticsearch-php client</a> and all requests are signed using the connector found <a href="https://github.com/wizacha/AwsSignatureMiddleware" rel="noreferrer">here</a>.</p> <p>Shown below is how we build the ElasticSearch client and apply signing middleware;</p> <pre><code>$credentials = new Credentials('&lt;KEY&gt;', '&lt;SECRET&gt;'); $signature = new SignatureV4('es', 'eu-central-1'); $middleware = new AwsSignatureMiddleware($credentials, $signature); $defaultHandler = ESClientBuilder::defaultHandler(); $awsHandler = $middleware($defaultHandler); $clientBuilder = ESClientBuilder::create(); $clientBuilder -&gt;setHandler($awsHandler) -&gt;setHosts(['&lt;URL&gt;']); $this-&gt;_client = $clientBuilder-&gt;build(); </code></pre> <p>For reference the policy attached to the elasticsearch instance we are trying to access is;</p> <pre><code>{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::&lt;IAM_USER&gt;" }, "Action": "es:*", "Resource": "&lt;RESOURCE&gt;/*" } ] } </code></pre> <p>Other info;</p> <ul> <li>We are using the Laravel framework, version 5.4.7</li> <li>Elasticsearch client version 5.3.2</li> </ul>
0debug
send file in c# socket worck in same machine but not in different machine : i don't speak English very well so I'm sorry if my question is not clear. My problem is that I wrote a client/server application to send file. It works if the server and client are on the same machine, but when I put the server on another machine, I get errors when the server reads the socket. This is the code of the server: class conexion { int sizeofonpacket = 9999; string filsc=""; string titre = ""; bool sendfilcomand = false; int conteur1 = 0; int conteur2 = 0; BinaryWriter sf; TcpListener listiner; TcpClient client; NetworkStream netStream; public conexion(IPAddress ip, int port) { listiner = new TcpListener(ip, port); listiner.Start(); client = listiner.AcceptTcpClient(); netStream = client.GetStream(); Console.Write("client is present \r\n "); } public void read() { while (client.Connected) { string returndata; int size = 0; string c = ""; byte[] bs = new byte[4]; byte[] b = new byte[1]; try { ////////////read the comand of client "s" for string or "b" for binary file if it is "s" it read the string that client write //if it is "b" we read the string "dfgjsdgfjdsgfjhdsgfj" it is not important Console.Write("ready \r\n "); netStream.Read(b, 0, 1); c = Encoding.UTF8.GetString(b); Console.WriteLine("\r\n comand :" + c); b = new byte[4]; netStream.Read(b, 0, 4); returndata = Encoding.UTF8.GetString(b); size = Int32.Parse(returndata); Console.WriteLine("\r\n size de packet int =" + size); b = new byte[size]; netStream.Read(b, 0, size); } catch { Console.WriteLine("\r\n conexion echoue"); listiner.Stop(); } switch (c) { case "b": if (sendfilcomand == false)//if sendfilcomand is false we read first the title { sendfilcomand = true; break; } sendfilcomand = false; filsc = titre; Console.WriteLine("\r\nle titr est:" + titre); titre = ""; sf = new BinaryWriter(new FileStream(filsc, FileMode.Create)); conteur2 = 0; conteur1 = size; crebfile(b); Console.WriteLine("\r\n creat file for " + conteur2 + " to " + conteur1); b = new byte[sizeofonpacket]; while (size != 0) { try { netStream.Read(bs, 0, 4); returndata = Encoding.UTF8.GetString(bs); size = Int32.Parse(returndata); conteur1 = size; Console.WriteLine("sizee a get" + size); if (size == 0) { Console.WriteLine("yout est termine"); sf.Close(); conteur1 = 0; conteur2 = 0; break; } else if (size != sizeofonpacket) b = new byte[size]; netStream.Read(b, 0, size); } catch { Console.WriteLine("\r\n imposible to read "); } crebfile(b); b.Initialize(); } sf.Close(); conteur1 = 0; conteur2 = 0; break; case "s": returndata = Encoding.UTF8.GetString(b); Console.WriteLine("\r\n" + returndata); if (sendfilcomand) { titre = returndata; Console.WriteLine("titre a get" + titre); break; } break; default: Console.WriteLine("\r\n rien comand"); break; } } } /// ////function public string quadripl(string s) { while (s.Length < 4) { s = "0" + s; } return s; } public void crebfile(byte[] byts) { try { sf.Write(byts, 0, conteur1); } catch { Console.WriteLine("imposible de crer le fichier"); } } } Here is the client code: class conexion { string filsr; int sizeofonpacket = 9999; bool sendfilcomand = false; bool getfilcomand = false; int bali; int fali; Stream file; TcpListener listiner; TcpClient client; NetworkStream netStream; public conexion(string ip, int port) { listiner = null; Console.Write("star client "); client = new TcpClient(ip, 3568); netStream = client.GetStream(); } public void send() { while (client.Connected) { //enter the comand "s" or "b" string c = ""; Console.WriteLine("\r\n ecrir comand:"); c = Console.ReadLine(); string s = ""; if (c == "s") { Console.WriteLine("\r\n entrer string:"); s = Console.ReadLine(); } string size = ""; Byte[] sendBytes = null; /////////////try { switch (c) { case "b": Console.WriteLine("\r\n comand binary file"); netStream.Write(Encoding.UTF8.GetBytes(c), 0, 1); if (sendfilcomand == false)// we will first send the patsh of file after we will send data of file { sendBytes = Encoding.UTF8.GetBytes("dfgjsdgfjdsgfjhdsgfj");//this is not important size = quadripl(sendBytes.Length.ToString()); netStream.Write(Encoding.UTF8.GetBytes(size), 0, Encoding.UTF8.GetBytes(size).Length); netStream.Write(sendBytes, 0, sendBytes.Length); sendfilcomand = true; s = getitr(); c = "s"; goto case "s"; } sendfilcomand = false; //now we will send data filsr = actitr(); // the title is save in "C:/Users/Ce-Pc/Desktop/titreactuel.txt" file = new FileStream(filsr, FileMode.Open); fali = (int)file.Length; bali = 0; byte[] bs = new byte[4]; Console.WriteLine("\r\n star sending "); do { sendBytes = filebtobyte(filsr); //read part of file to send Console.WriteLine("\r\n terminer " + bali + " " + " " + fali); size = quadripl(sendBytes.Length.ToString());// just for add the zero Console.WriteLine("\r\n le size de fichier binair est " + size); netStream.Write(Encoding.UTF8.GetBytes(size), 0, Encoding.UTF8.GetBytes(size).Length); netStream.Write(sendBytes, 0, sendBytes.Length); } while (bali != -1); //when we come to last part of the file (filebtobyte give -1 to bali) bali = 0; size = quadripl("0"); Console.WriteLine("\r\n terminer fiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiin "); netStream.Write(Encoding.UTF8.GetBytes(size), 0, Encoding.UTF8.GetBytes(size).Length); netStream.Read(bs, 0, 4); break; case "s": Console.WriteLine("\r\n comand string"); netStream.Write(Encoding.UTF8.GetBytes(c), 0, 1); size = quadripl(s.Length.ToString()); sendBytes = Encoding.UTF8.GetBytes(size); Console.WriteLine("\r\n size=" + size); netStream.Write(sendBytes, 0, sendBytes.Length); sendBytes = Encoding.UTF8.GetBytes(s); netStream.Write(sendBytes, 0, sendBytes.Length); if (sendfilcomand) { c = "b"; goto case "b"; } break; default: Console.WriteLine("\r\n rien comand"); break; } } catch { Console.WriteLine("\r\n imposible de transfer"); } } Console.Write("client est deconect \r\n "); } //////////////////the functions////////////////////////////////// public byte[] filebtobyte(string s) { byte[] byts = null; try { if (fali - bali < sizeofonpacket) { byts = new byte[fali - bali]; file.Read(byts, 0, fali - bali); file.Close(); bali = -1; } else { byts = new byte[sizeofonpacket]; file.Read(byts, 0, sizeofonpacket); bali += sizeofonpacket; } } catch { Console.WriteLine("imposible de trouver le fichier"); } return byts; } public string quadripl(string s) { while (s.Length < 4) { s = "0" + s; } return s; } public string getitr() { StreamReader titrfil = new StreamReader("C:/Users/Ce-Pc/Desktop/titre.txt"); string sss = ""; try { sss = titrfil.ReadLine(); Console.WriteLine("\r\n le chemin " + sss); titrfil.Close(); } catch { Console.WriteLine("\r\n imposible"); } return sss; } public string actitr() { StreamReader titrfil = new StreamReader("C:/Users/Ce-Pc/Desktop/titreactuel.txt"); string sss = ""; try { sss = titrfil.ReadLine(); Console.WriteLine("\r\n le chemin " + sss); titrfil.Close(); } catch { Console.WriteLine("\r\n imposible"); } return sss; } } }
0debug
How can I define a optional part in the pattern? : <p>Here is <a href="https://regex101.com/r/D6Qas8/3" rel="nofollow noreferrer">my content</a>:</p> <pre><code>&lt;div&gt;something&lt;/div&gt; &lt;div&gt;something else &lt;p&gt;paragraph&lt;/p&gt;&lt;/div&gt; </code></pre> <p>And this is my pattern:</p> <pre><code>/&lt;div&gt;([^&lt;]+).*?&lt;\/div&gt;/ </code></pre> <p>As you see, it matches just the text content of <code>div</code>. Now I want to add an optional part to the pattern for <code>p</code>. I mean, I want to get <code>p</code>'s value as another capturing group if it exists.</p> <p>How can I do that?</p>
0debug
pvscsi_convert_sglist(PVSCSIRequest *r) { int chunk_size; uint64_t data_length = r->req.dataLen; PVSCSISGState sg = r->sg; while (data_length) { while (!sg.resid) { pvscsi_get_next_sg_elem(&sg); trace_pvscsi_convert_sglist(r->req.context, r->sg.dataAddr, r->sg.resid); } assert(data_length > 0); chunk_size = MIN((unsigned) data_length, sg.resid); if (chunk_size) { qemu_sglist_add(&r->sgl, sg.dataAddr, chunk_size); } sg.dataAddr += chunk_size; data_length -= chunk_size; sg.resid -= chunk_size; } }
1threat
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact, int *header_len, AVDictionary **m, int framing_bit) { const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; int size; uint8_t *p, *p0; ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL); size = offset + ff_vorbiscomment_length(*m, vendor) + framing_bit; p = av_mallocz(size); if (!p) return NULL; p0 = p; p += offset; ff_vorbiscomment_write(&p, m, vendor); if (framing_bit) bytestream_put_byte(&p, 1); *header_len = size; return p0; }
1threat
R: How to ignore case when using str_detect? : <p>stringr package provides good string functions.</p> <p>To search for a string (ignoring case)</p> <p>one could use</p> <pre><code>stringr::str_detect('TOYOTA subaru',ignore.case('toyota')) </code></pre> <p>This works but gives warning </p> <blockquote> <p>Please use (fixed|coll|regex)(x, ignore_case = TRUE) instead of ignore.case(x)</p> </blockquote> <p>What is the right way of rewriting it?</p>
0debug
How to edit legend labels in google spreadsheet plots? : <p>I'm trying to plot some data in Google spreadsheet:</p> <p><a href="https://i.stack.imgur.com/qRAuF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qRAuF.png" alt="enter image description here"></a></p> <p>And as you may see all of the series are in a same column and I can't use the any of the rows as headers. My plot looks like this:</p> <p><a href="https://i.stack.imgur.com/jBdry.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jBdry.png" alt="enter image description here"></a></p> <p>I would appreciate if you could help me know how I can edit/add legend labels.</p>
0debug
PPC_OP(neg) { if (T0 != 0x80000000) { T0 = -Ts0; } RETURN(); }
1threat
def max_of_three(num1,num2,num3): if (num1 >= num2) and (num1 >= num3): lnum = num1 elif (num2 >= num1) and (num2 >= num3): lnum = num2 else: lnum = num3 return lnum
0debug
Can't enable phar writing : <p>I am actually using wamp 2.5 with PHP 5.5.12 and when I try to create a <strong>phar</strong> file it returns me the following message : </p> <blockquote> <p>Uncaught exception 'UnexpectedValueException' with message 'creating archive "..." disabled by the php.ini setting phar.readonly'</p> </blockquote> <p>even if I turn to off the <em>phar.readonly</em> option in <em>php.ini</em>.</p> <p><strong>So how can I enable the creation of phar files ?</strong></p>
0debug
How to skip the first two lines of a file and read those lines that are multiple of 5 : <p>I have a file and I want to skip the first two lines and read those lines that are multiple of 5</p> <p>line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10</p> <p>output: line 3 line 8 .. . .</p>
0debug
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !st->codec->sample_rate && sc->time_scale > 1) st->codec->sample_rate = sc->time_scale; switch (st->codec->codec_id) { #if CONFIG_DV_DEMUXER case AV_CODEC_ID_DVAUDIO: c->dv_fctx = avformat_alloc_context(); if (!c->dv_fctx) { av_log(c->fc, AV_LOG_ERROR, "dv demux context alloc error\n"); return AVERROR(ENOMEM); } c->dv_demux = avpriv_dv_init_demux(c->dv_fctx); if (!c->dv_demux) { av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); return AVERROR(ENOMEM); } sc->dv_audio_container = 1; st->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; #endif case AV_CODEC_ID_QCELP: st->codec->channels = 1; if (st->codec->codec_tag != MKTAG('Q','c','l','p')) st->codec->sample_rate = 8000; break; case AV_CODEC_ID_AMR_NB: st->codec->channels = 1; st->codec->sample_rate = 8000; break; case AV_CODEC_ID_AMR_WB: st->codec->channels = 1; st->codec->sample_rate = 16000; break; case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP3: st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->need_parsing = AVSTREAM_PARSE_FULL; break; case AV_CODEC_ID_GSM: case AV_CODEC_ID_ADPCM_MS: case AV_CODEC_ID_ADPCM_IMA_WAV: case AV_CODEC_ID_ILBC: st->codec->block_align = sc->bytes_per_frame; break; case AV_CODEC_ID_ALAC: if (st->codec->extradata_size == 36) { st->codec->channels = AV_RB8 (st->codec->extradata + 21); st->codec->sample_rate = AV_RB32(st->codec->extradata + 32); } break; case AV_CODEC_ID_VC1: st->need_parsing = AVSTREAM_PARSE_FULL; break; default: break; } return 0; }
1threat
How to automatically toggle Airplane mode on Windows : <p>On my laptop I can toggle Airplane mode manually by pressing <kbd>FN</kbd>+<kbd>F12</kbd>, I want to do the same thing automatically from VB6 project or VBA.</p> <p>I did a lot of search and only found answers about Enable/Disable wireless adapter or using <code>Sendkeys</code> for Windows 8:</p> <pre><code>Dim WSh As Object Set WSh = CreateObject("Wscript.Shell") WSh.Run "C:\WINDOWS\system32\rundll32.exe %SystemRoot%\system32\van.dll,RunVAN", , True Sleep 200 WSh.SendKeys " " Sleep 1000 WSh.SendKeys "{ESC}" </code></pre> <p>But this code is not reliable and I don't think it will work on Windows 7 or Windows 10.</p> <p>So my question is: Is there any reliable way to automatically toggle Airplane mode on Windows.</p>
0debug
In C I trying to do funtion of sum but the answer isn't the expected : I've been trying to do a program which it can sum to numbers, I want to do the one by funtions althought. The funtion is call "sum", but program get " the sum is 0". What i need to debug ? #include <stdio.h> int sum() { int a, b; int answer; answer = a+b; return 0; } int main() { int var_a, var_b; int result; printf (" first number \n"); scanf ("%i",&var_a); printf ("second number \n"); scanf ("%i",&var_b); result = sum(var_a,var_b); printf(" The sum is %i", result); return 0; } Sincerily NIN.
0debug
Make absolute paths relative to the project root in Webpack : <p>I find that I need to type <code>../</code> a lot to <code>require()</code> files. My directory structure includes these:</p> <pre><code>js/ components/ ... actions/ ... </code></pre> <p>From the components folder, I need to do <code>import foo from '../actions/fooAction'</code>. Is it possible to make the root directory the root of the project? I.e. I want to do <code>import foo from '/actions/fooAction'</code> instead. I tried setting Webpack's <code>resolve.root</code> option, but it didn't seem to do anything.</p>
0debug
Making nested lists in python : This was the question " Write a function *find_all(L, i)* that takes a nested list *L* and, an item *i* and, prints the indices of all occurrences of *i* in *L*. I wrote this code from string import * def *find_all(L,i)*: for *sub_list* in *L*: if *i* in *sub_list*: return *(L.index(sub_list), sub_list.index(i))* print *find_all([[1,2,3],[4,5],[6],[5,13]], 5)* It only prints (1,1).
0debug
Define size for /dev/shm on container engine : <p>I'm running Chrome with xvfb on Debian 8. It works until I open a tab and try to load content. The process dies silently...</p> <p>Fortunately, I have gotten it to run smoothly on my local docker using <code>docker run --shm-size=1G</code>.</p> <p>There is <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=522853" rel="noreferrer">a known bug in Chrome</a> that causes it to crash when /dev/shm is too small.</p> <p>I am deploying to Container engine, and inspecting the OS specs. The host OS has a solid 7G mounted to /dev/shm, but the actual container is only allocated 64M. Chrome crashes.</p> <p>How can I set the size of /dev/shm when using kubectl to deploy to container engine?</p>
0debug
Jquery auto width for a counter : Guys this is my site: > codepen.io/anon/pen/KpXBYL I created a Counter. With + and - and in the middle you will see the number but if the number is 10000 you can not see it in the box. Can someone add a Auto width code for the middle box ?
0debug
write one specific formula in python : <p>I have a question, everyone knows how can I write this formula with python? </p> <p><a href="https://i.stack.imgur.com/eg7G5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eg7G5.png" alt="enter image description here"></a></p>
0debug
Stuck with a syntax error with basic php function. : <p>I keep getting the following error for this function.</p> <blockquote> <p>Parse error: syntax error, unexpected '$tempsql' (T_VARIABLE) in /home/vps20119/public_html/outlet/admin/internal/dcOrderFunctions.php on line 6</p> </blockquote> <p>I don't get it. I can't find any syntax errors before I start defining / declaring the $tempsql. What am I over looking? Below is a copy of the entire file.</p> <pre><code>&lt;?php //A function to extract the QC from the Order number function orderGetQC($dropcomOrderID){     //Get the Product ID from the order. $tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'"; //runs the query (above) and puts the resulting data into a variable called $orderInfo. $orderInfo = $conn-&gt;query($tempsql); $temprow = $orderInfo-&gt;fetch_assoc(); $productID = $temprow['product_id']; //Get the QC from the product ID. $tempsql2 = "SELECT * FROM `multi_quantity_received` WHERE `product_id` = '". $productID ."'"; //runs the query (above) and puts the resulting data into a variable called $productInfo. $productInfo = $conn-&gt;query($tempsql2); $temprow2 = $productInfo-&gt;fetch_assoc(); if( $productInfo-&gt;num_rows &gt; 1){ $QC = "multipleQCs"; } else { $QC = $temprow2['qc']; } return $QC; } ?&gt; </code></pre>
0debug
javascript hoisting and execution context : <pre><code>var employeeId = 'abc123'; function foo() { employeeId = '123bcd'; return; var employeeId = function(){} } foo(); console.log(employeeId); </code></pre> <p>I am new to javascript programming, could someone explain to me why above output is 'abc123' not '123bcd', I thought the employeeId defined inside foo() should be global variable and overwrite the outside one, am I wrong?</p>
0debug
can you please give an idea for our program to ignore spaces and count only alphabets is even small other wise caps : can you please give an idea for our program to ignore spaces and count only alphabets is even small other wise caps public class evennumbersloop { public static void main(String[] args) { String str = "Hello World uuuu iii pppp jjj"; int count = 0; for (int i = 0; i <= str.length() - 1; i++) { if (str.charAt(i) != ' ') { if (count % 2 == 0) { String str1 = ""; str1 = str1 + str.charAt(count); System.out.print(str1.toUpperCase()); } else { System.out.print(str.charAt(count)); } count++; } } } }
0debug
Equivalent of C++ for loop in python : What will be the python equivalent to this simple C++ code : for (i = 0; i < 10; i++) { for (j = 10; j > i; j--) { a[i]*a[j]; } } Especially I am having problem in the implementation of the second loop with 'j' using the j > i condition
0debug
Angular validation with Required not working : <p>Simplest example ever not working. I generated an Angular 4 application using the Angular CLI v1.0.6, changed the content of app.component.html to:</p> <pre><code>&lt;form #form='ngForm' (ngSubmit)='submitForm(form.value)'&gt; &lt;input type='email' class='form-control' placeholder='E-mail' name='userEmail' ngModel required &gt; &lt;button type='submit'&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p>And the content of app.component.ts to:</p> <pre><code>import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { submitForm(data){ console.log(data); } } </code></pre> <p>I expected the submit function to not be fired in case I didn't supply an email, but it does. What did I miss?</p> <p>P.S.: I have looked around for examples (e.g.: <a href="https://scotch.io/tutorials/angular-2-form-validation" rel="noreferrer">https://scotch.io/tutorials/angular-2-form-validation</a>), but after many hours I am unable to find a solution, that's why I come to you. I know it is in my face, but somehow I can't see it.</p>
0debug
I can't view the database content on a php page : <p>I can't view the database content on php page I want to fetch data using ID thats the code :</p> <pre><code>&lt;?php //connect with database $servername = "localhost"; $userdbname = "root"; $dbpassword = ""; $dbname = "users"; $usid = 0; $docname = ''; $conn = new mysqli($servername, $userdbname, $dbpassword, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } $sql = "SELECT * FROM users WHERE id=".$usid; if ($conn-&gt;query($sql) === TRUE) { $conn-&gt;close(); $URLS = array(); while ($row = $result-&gt;fetch_array()) { $docname= $row['docname']; } header("Location:Editeform.php"); } ?&gt; </code></pre> <p>This is the form I am trying to view the data in :</p> <pre><code>&lt;div class="form-group"&gt; &lt;input type="text" class="form-input" name="docname" id="name" placeholder="Your Name" value="&lt;?php echo $users['docname']; ?&gt;" /&gt; &lt;/div&gt; </code></pre>
0debug
Yahoo Finance API changes (2017) : <p>Requesting data from Yahoo Finance seems to have changed or is now blocked. The request below for commodity data no longer works as of May 2017. Does anyone know if there is a new way to make this request? </p> <pre><code>http://chartapi.finance.yahoo.com/instrument/1.0/GCQ17.CMX/chartdata;type=quote;range=10d/csv/ </code></pre>
0debug
float64 HELPER(ucf64_subd)(float64 a, float64 b, CPUUniCore32State *env) { return float64_sub(a, b, &env->ucf64.fp_status); }
1threat
Time complexity of the following function : <p>Please help me by giving the time complexity analysis of the following function.</p> <pre><code>function (n) { for( i = 1 ; i &lt;= n ; i + + ) { for( j = 1 ; j &lt;= n ; j+ = i ) { print( “*” ) ; } } } </code></pre>
0debug
Can I use AND in a SWITH function in Access? : I have create this function to check holiday prices in MS Access: Holiday Price: Switch([Holiday Type]="Single",£1000,[Holiday Type]="Couple",£2000,[Holiday Type]="Family",£4000) This works but I'd like to add another field (Activity) from the table that checks if an activity has been booked. It this field is not empty I want it to return £1200 for Single, £2200 for Couple and £4200 for Family. Any help would be greatly appreciated. I am fairly new to databases. Thanks
0debug
@angular else angular2 library which one is the latest : I just started learning Angular2 and have a doubt with these two libraries that are present in angular2 Some examples has "@angular" in its import command and some example has "angular2" in its import command which one among these is the latest library Thanks
0debug
How to create website with 100% reliability? : <p>I have PHP aplication with MySQL database. I want to use something to provide 100% access to website. How to do that when one server fall down another will take over whole traffic?</p> <p>I was thinking about cloning serwer, add load balancer and set up master-master replication in MySQL. Is it correct? Is there a simpler solution?</p>
0debug
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) { RMContext *rm = s->priv_data; AVStream *st; ByteIOContext *pb = &s->pb; unsigned int tag, v; int tag_size, size, codec_data_size, i; int64_t codec_pos; unsigned int h263_hack_version, start_time, duration; char buf[128]; int flags = 0; tag = get_le32(pb); if (tag == MKTAG('.', 'r', 'a', 0xfd)) { return rm_read_header_old(s, ap); } else if (tag != MKTAG('.', 'R', 'M', 'F')) { return AVERROR_IO; get_be32(pb); get_be16(pb); get_be32(pb); get_be32(pb); for(;;) { if (url_feof(pb)) goto fail; tag = get_le32(pb); tag_size = get_be32(pb); get_be16(pb); #if 0 printf("tag=%c%c%c%c (%08x) size=%d\n", (tag) & 0xff, (tag >> 8) & 0xff, (tag >> 16) & 0xff, (tag >> 24) & 0xff, tag, tag_size); #endif if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A')) goto fail; switch(tag) { case MKTAG('P', 'R', 'O', 'P'): get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); get_be16(pb); flags = get_be16(pb); break; case MKTAG('C', 'O', 'N', 'T'): get_str(pb, s->title, sizeof(s->title)); get_str(pb, s->author, sizeof(s->author)); get_str(pb, s->copyright, sizeof(s->copyright)); get_str(pb, s->comment, sizeof(s->comment)); break; case MKTAG('M', 'D', 'P', 'R'): st = av_new_stream(s, 0); if (!st) goto fail; st->id = get_be16(pb); get_be32(pb); st->codec->bit_rate = get_be32(pb); get_be32(pb); get_be32(pb); start_time = get_be32(pb); get_be32(pb); duration = get_be32(pb); st->start_time = start_time; st->duration = duration; get_str8(pb, buf, sizeof(buf)); get_str8(pb, buf, sizeof(buf)); codec_data_size = get_be32(pb); codec_pos = url_ftell(pb); st->codec->codec_type = CODEC_TYPE_DATA; av_set_pts_info(st, 64, 1, 1000); v = get_be32(pb); if (v == MKTAG(0xfd, 'a', 'r', '.')) { rm_read_audio_stream_info(s, st, 0); } else { int fps, fps2; if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { fail1: av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); goto skip; st->codec->codec_tag = get_le32(pb); if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) goto fail1; st->codec->width = get_be16(pb); st->codec->height = get_be16(pb); st->codec->time_base.num= 1; fps= get_be16(pb); st->codec->codec_type = CODEC_TYPE_VIDEO; get_be32(pb); fps2= get_be16(pb); get_be16(pb); st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, st->codec->extradata_size); st->codec->time_base.den = fps * st->codec->time_base.num; #ifdef WORDS_BIGENDIAN h263_hack_version = ((uint32_t*)st->codec->extradata)[1]; #else h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]); #endif st->codec->sub_id = h263_hack_version; switch((h263_hack_version>>28)){ case 1: st->codec->codec_id = CODEC_ID_RV10; break; case 2: st->codec->codec_id = CODEC_ID_RV20; break; case 3: st->codec->codec_id = CODEC_ID_RV30; break; case 4: st->codec->codec_id = CODEC_ID_RV40; break; default: goto fail1; skip: size = url_ftell(pb) - codec_pos; url_fskip(pb, codec_data_size - size); break; case MKTAG('D', 'A', 'T', 'A'): goto header_end; default: url_fskip(pb, tag_size - 10); break; header_end: rm->nb_packets = get_be32(pb); if (!rm->nb_packets && (flags & 4)) rm->nb_packets = 3600 * 25; get_be32(pb); return 0; fail: for(i=0;i<s->nb_streams;i++) { av_free(s->streams[i]); return AVERROR_IO;
1threat
static int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, struct image_info * info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; struct exec interp_ex; int interpreter_fd = -1; unsigned long load_addr, load_bias; int load_addr_set = 0; unsigned int interpreter_type = INTERPRETER_NONE; unsigned char ibcs2_interpreter; int i; unsigned long mapped_addr; struct elf_phdr * elf_ppnt; struct elf_phdr *elf_phdata; unsigned long elf_bss, k, elf_brk; int retval; char * elf_interpreter; unsigned long elf_entry, interp_load_addr = 0; int status; unsigned long start_code, end_code, end_data; unsigned long elf_stack; char passed_fileno[6]; ibcs2_interpreter = 0; status = 0; load_addr = 0; load_bias = 0; elf_ex = *((struct elfhdr *) bprm->buf); #ifdef BSWAP_NEEDED bswap_ehdr(&elf_ex); #endif if (elf_ex.e_ident[0] != 0x7f || strncmp(&elf_ex.e_ident[1], "ELF",3) != 0) { return -ENOEXEC; } if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || (! elf_check_arch(elf_ex.e_machine))) { return -ENOEXEC; } elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); if (elf_phdata == NULL) { return -ENOMEM; } retval = lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); if(retval > 0) { retval = read(bprm->fd, (char *) elf_phdata, elf_ex.e_phentsize * elf_ex.e_phnum); } if (retval < 0) { perror("load_elf_binary"); exit(-1); free (elf_phdata); return -errno; } #ifdef BSWAP_NEEDED elf_ppnt = elf_phdata; for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) { bswap_phdr(elf_ppnt); } #endif elf_ppnt = elf_phdata; elf_bss = 0; elf_brk = 0; elf_stack = ~0UL; elf_interpreter = NULL; start_code = ~0UL; end_code = 0; end_data = 0; for(i=0;i < elf_ex.e_phnum; i++) { if (elf_ppnt->p_type == PT_INTERP) { if ( elf_interpreter != NULL ) { free (elf_phdata); free(elf_interpreter); close(bprm->fd); return -EINVAL; } elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); if (elf_interpreter == NULL) { free (elf_phdata); close(bprm->fd); return -ENOMEM; } retval = lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); if(retval >= 0) { retval = read(bprm->fd, elf_interpreter, elf_ppnt->p_filesz); } if(retval < 0) { perror("load_elf_binary2"); exit(-1); } if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 || strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0) { ibcs2_interpreter = 1; } #if 0 printf("Using ELF interpreter %s\n", elf_interpreter); #endif if (retval >= 0) { retval = open(path(elf_interpreter), O_RDONLY); if(retval >= 0) { interpreter_fd = retval; } else { perror(elf_interpreter); exit(-1); } } if (retval >= 0) { retval = lseek(interpreter_fd, 0, SEEK_SET); if(retval >= 0) { retval = read(interpreter_fd,bprm->buf,128); } } if (retval >= 0) { interp_ex = *((struct exec *) bprm->buf); interp_elf_ex=*((struct elfhdr *) bprm->buf); } if (retval < 0) { perror("load_elf_binary3"); exit(-1); free (elf_phdata); free(elf_interpreter); close(bprm->fd); return retval; } } elf_ppnt++; } if (elf_interpreter){ interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) && (N_MAGIC(interp_ex) != QMAGIC)) { interpreter_type = INTERPRETER_ELF; } if (interp_elf_ex.e_ident[0] != 0x7f || strncmp(&interp_elf_ex.e_ident[1], "ELF",3) != 0) { interpreter_type &= ~INTERPRETER_ELF; } if (!interpreter_type) { free(elf_interpreter); free(elf_phdata); close(bprm->fd); return -ELIBBAD; } } if (!bprm->sh_bang) { char * passed_p; if (interpreter_type == INTERPRETER_AOUT) { sprintf(passed_fileno, "%d", bprm->fd); passed_p = passed_fileno; if (elf_interpreter) { bprm->p = copy_strings(1,&passed_p,bprm->page,bprm->p); bprm->argc++; } } if (!bprm->p) { if (elf_interpreter) { free(elf_interpreter); } free (elf_phdata); close(bprm->fd); return -E2BIG; } } info->end_data = 0; info->end_code = 0; info->start_mmap = (unsigned long)ELF_START_MMAP; info->mmap = 0; elf_entry = (unsigned long) elf_ex.e_entry; info->rss = 0; bprm->p = setup_arg_pages(bprm->p, bprm, info); info->start_stack = bprm->p; for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { int elf_prot = 0; int elf_flags = 0; unsigned long error; if (elf_ppnt->p_type != PT_LOAD) continue; if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; elf_flags = MAP_PRIVATE | MAP_DENYWRITE; if (elf_ex.e_type == ET_EXEC || load_addr_set) { elf_flags |= MAP_FIXED; } else if (elf_ex.e_type == ET_DYN) { error = target_mmap(0, ET_DYN_MAP_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); exit(-1); } load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); } error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), (elf_ppnt->p_filesz + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), bprm->fd, (elf_ppnt->p_offset - TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); if (error == -1) { perror("mmap"); exit(-1); } #ifdef LOW_ELF_STACK if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); #endif if (!load_addr_set) { load_addr_set = 1; load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; if (elf_ex.e_type == ET_DYN) { load_bias += error - TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr); load_addr += load_bias; } } k = elf_ppnt->p_vaddr; if (k < start_code) start_code = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; if (k > elf_bss) elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) end_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; if (k > elf_brk) elf_brk = k; } elf_entry += load_bias; elf_bss += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias; end_data += load_bias; if (elf_interpreter) { if (interpreter_type & 1) { elf_entry = load_aout_interp(&interp_ex, interpreter_fd); } else if (interpreter_type & 2) { elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd, &interp_load_addr); } close(interpreter_fd); free(elf_interpreter); if (elf_entry == ~0UL) { printf("Unable to load interpreter\n"); free(elf_phdata); exit(-1); return 0; } } free(elf_phdata); if (loglevel) load_symbols(&elf_ex, bprm->fd); if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd); info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); #ifdef LOW_ELF_STACK info->start_stack = bprm->p = elf_stack - 4; #endif bprm->p = (unsigned long) create_elf_tables((char *)bprm->p, bprm->argc, bprm->envc, &elf_ex, load_addr, load_bias, interp_load_addr, (interpreter_type == INTERPRETER_AOUT ? 0 : 1), info); if (interpreter_type == INTERPRETER_AOUT) info->arg_start += strlen(passed_fileno) + 1; info->start_brk = info->brk = elf_brk; info->end_code = end_code; info->start_code = start_code; info->end_data = end_data; info->start_stack = bprm->p; set_brk(elf_bss, elf_brk); padzero(elf_bss); #if 0 printf("(start_brk) %x\n" , info->start_brk); printf("(end_code) %x\n" , info->end_code); printf("(start_code) %x\n" , info->start_code); printf("(end_data) %x\n" , info->end_data); printf("(start_stack) %x\n" , info->start_stack); printf("(brk) %x\n" , info->brk); #endif if ( info->personality == PER_SVR4 ) { mapped_addr = target_mmap(0, host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, -1, 0); } #ifdef ELF_PLAT_INIT ELF_PLAT_INIT(regs); #endif info->entry = elf_entry; return 0; }
1threat
Is it ok to send to token from frontend to backend? : <p>If I have an application in which a user can connect to facebook from the frontend, it is ok to send the access token to the backend?</p> <p>If there are security risks, what are them?</p>
0debug
static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) { DECLARE_ALIGNED(8, PPContext, c)= *c2; int x,y; #ifdef COMPILE_TIME_MODE const int mode= COMPILE_TIME_MODE; #else const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode; #endif int black=0, white=255; int QPCorrecture= 256*256; int copyAhead; #if HAVE_MMX_INLINE int i; #endif const int qpHShift= isColor ? 4-c.hChromaSubSample : 4; const int qpVShift= isColor ? 4-c.vChromaSubSample : 4; uint64_t * const yHistogram= c.yHistogram; uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride; uint8_t * const tempDst= dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride; #if HAVE_MMX_INLINE for(i=0; i<57; i++){ int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1; int threshold= offset*2 + 1; c.mmxDcOffset[i]= 0x7F - offset; c.mmxDcThreshold[i]= 0x7F - threshold; c.mmxDcOffset[i]*= 0x0101010101010101LL; c.mmxDcThreshold[i]*= 0x0101010101010101LL; } #endif if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16; else if( (mode & LINEAR_BLEND_DEINT_FILTER) || (mode & FFMPEG_DEINT_FILTER) || (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14; else if( (mode & V_DEBLOCK) || (mode & LINEAR_IPOL_DEINT_FILTER) || (mode & MEDIAN_DEINT_FILTER) || (mode & V_A_DEBLOCK)) copyAhead=13; else if(mode & V_X1_FILTER) copyAhead=11; else if(mode & DERING) copyAhead=9; else copyAhead=8; copyAhead-= 8; if(!isColor){ uint64_t sum= 0; int i; uint64_t maxClipped; uint64_t clipped; double scale; c.frameNum++; if(c.frameNum == 1) yHistogram[0]= width*height/64*15/256; for(i=0; i<256; i++){ sum+= yHistogram[i]; } maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold); clipped= sum; for(black=255; black>0; black--){ if(clipped < maxClipped) break; clipped-= yHistogram[black]; } clipped= sum; for(white=0; white<256; white++){ if(clipped < maxClipped) break; clipped-= yHistogram[white]; } scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black); #if HAVE_MMXEXT_INLINE c.packedYScale= (uint16_t)(scale*256.0 + 0.5); c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF; #else c.packedYScale= (uint16_t)(scale*1024.0 + 0.5); c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF; #endif c.packedYOffset|= c.packedYOffset<<32; c.packedYOffset|= c.packedYOffset<<16; c.packedYScale|= c.packedYScale<<32; c.packedYScale|= c.packedYScale<<16; if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5); else QPCorrecture= 256*256; }else{ c.packedYScale= 0x0100010001000100LL; c.packedYOffset= 0; QPCorrecture= 256*256; } y=-BLOCK_SIZE; { const uint8_t *srcBlock= &(src[y*srcStride]); uint8_t *dstBlock= tempDst + dstStride; for(x=0; x<width; x+=BLOCK_SIZE){ #if HAVE_MMXEXT_INLINE __asm__( "mov %4, %%"REG_a" \n\t" "shr $2, %%"REG_a" \n\t" "and $6, %%"REG_a" \n\t" "add %5, %%"REG_a" \n\t" "mov %%"REG_a", %%"REG_d" \n\t" "imul %1, %%"REG_a" \n\t" "imul %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" "add %1, %%"REG_a" \n\t" "add %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride), "g" ((x86_reg)x), "g" ((x86_reg)copyAhead) : "%"REG_a, "%"REG_d ); #elif HAVE_AMD3DNOW_INLINE #endif RENAME(blockCopy)(dstBlock + dstStride*8, dstStride, srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset); RENAME(duplicate)(dstBlock + dstStride*8, dstStride); if(mode & LINEAR_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(mode & LINEAR_BLEND_DEINT_FILTER) RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); else if(mode & MEDIAN_DEINT_FILTER) RENAME(deInterlaceMedian)(dstBlock, dstStride); else if(mode & CUBIC_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(mode & FFMPEG_DEINT_FILTER) RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); else if(mode & LOWPASS5_DEINT_FILTER) RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); dstBlock+=8; srcBlock+=8; } if(width==FFABS(dstStride)) linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride); else{ int i; for(i=0; i<copyAhead; i++){ memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width); } } } for(y=0; y<height; y+=BLOCK_SIZE){ const uint8_t *srcBlock= &(src[y*srcStride]); uint8_t *dstBlock= &(dst[y*dstStride]); #if HAVE_MMX_INLINE uint8_t *tempBlock1= c.tempBlocks; uint8_t *tempBlock2= c.tempBlocks + 8; #endif const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)]; int QP=0; if(y+15 >= height){ int i; linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, FFMAX(height-y-copyAhead, 0), srcStride); for(i=FFMAX(height-y, 8); i<copyAhead+8; i++) memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride)); linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride); for(i=height-y+1; i<=copyAhead; i++) memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride)); dstBlock= tempDst + dstStride; srcBlock= tempSrc; } for(x=0; x<width; x+=BLOCK_SIZE){ const int stride= dstStride; #if HAVE_MMX_INLINE uint8_t *tmpXchg; #endif if(isColor){ QP= QPptr[x>>qpHShift]; c.nonBQP= nonBQPptr[x>>qpHShift]; }else{ QP= QPptr[x>>4]; QP= (QP* QPCorrecture + 256*128)>>16; c.nonBQP= nonBQPptr[x>>4]; c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16; yHistogram[ srcBlock[srcStride*12 + 4] ]++; } c.QP= QP; #if HAVE_MMX_INLINE __asm__ volatile( "movd %1, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "movq %%mm7, %0 \n\t" : "=m" (c.pQPb) : "r" (QP) ); #endif #if HAVE_MMXEXT_INLINE __asm__( "mov %4, %%"REG_a" \n\t" "shr $2, %%"REG_a" \n\t" "and $6, %%"REG_a" \n\t" "add %5, %%"REG_a" \n\t" "mov %%"REG_a", %%"REG_d" \n\t" "imul %1, %%"REG_a" \n\t" "imul %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" "add %1, %%"REG_a" \n\t" "add %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride), "g" ((x86_reg)x), "g" ((x86_reg)copyAhead) : "%"REG_a, "%"REG_d ); #elif HAVE_AMD3DNOW_INLINE #endif RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride, srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset); if(mode & LINEAR_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(mode & LINEAR_BLEND_DEINT_FILTER) RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); else if(mode & MEDIAN_DEINT_FILTER) RENAME(deInterlaceMedian)(dstBlock, dstStride); else if(mode & CUBIC_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(mode & FFMPEG_DEINT_FILTER) RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); else if(mode & LOWPASS5_DEINT_FILTER) RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); if(y + 8 < height){ if(mode & V_X1_FILTER) RENAME(vertX1Filter)(dstBlock, stride, &c); else if(mode & V_DEBLOCK){ const int t= RENAME(vertClassify)(dstBlock, stride, &c); if(t==1) RENAME(doVertLowPass)(dstBlock, stride, &c); else if(t==2) RENAME(doVertDefFilter)(dstBlock, stride, &c); }else if(mode & V_A_DEBLOCK){ RENAME(do_a_deblock)(dstBlock, stride, 1, &c); } } #if HAVE_MMX_INLINE RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride); #endif if(x - 8 >= 0){ #if HAVE_MMX_INLINE if(mode & H_X1_FILTER) RENAME(vertX1Filter)(tempBlock1, 16, &c); else if(mode & H_DEBLOCK){ const int t= RENAME(vertClassify)(tempBlock1, 16, &c); if(t==1) RENAME(doVertLowPass)(tempBlock1, 16, &c); else if(t==2) RENAME(doVertDefFilter)(tempBlock1, 16, &c); }else if(mode & H_A_DEBLOCK){ RENAME(do_a_deblock)(tempBlock1, 16, 1, &c); } RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16); #else if(mode & H_X1_FILTER) horizX1Filter(dstBlock-4, stride, QP); else if(mode & H_DEBLOCK){ #if HAVE_ALTIVEC DECLARE_ALIGNED(16, unsigned char, tempBlock)[272]; int t; transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride); t = vertClassify_altivec(tempBlock-48, 16, &c); if(t==1) { doVertLowPass_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } else if(t==2) { doVertDefFilter_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } #else const int t= RENAME(horizClassify)(dstBlock-4, stride, &c); if(t==1) RENAME(doHorizLowPass)(dstBlock-4, stride, &c); else if(t==2) RENAME(doHorizDefFilter)(dstBlock-4, stride, &c); #endif }else if(mode & H_A_DEBLOCK){ RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c); } #endif if(mode & DERING){ if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c); } if(mode & TEMP_NOISE_FILTER) { RENAME(tempNoiseReducer)(dstBlock-8, stride, c.tempBlurred[isColor] + y*dstStride + x, c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256, c.ppMode.maxTmpNoise); } } dstBlock+=8; srcBlock+=8; #if HAVE_MMX_INLINE tmpXchg= tempBlock1; tempBlock1= tempBlock2; tempBlock2 = tmpXchg; #endif } if(mode & DERING){ if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c); } if((mode & TEMP_NOISE_FILTER)){ RENAME(tempNoiseReducer)(dstBlock-8, dstStride, c.tempBlurred[isColor] + y*dstStride + x, c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256, c.ppMode.maxTmpNoise); } if(y+15 >= height){ uint8_t *dstBlock= &(dst[y*dstStride]); if(width==FFABS(dstStride)) linecpy(dstBlock, tempDst + dstStride, height-y, dstStride); else{ int i; for(i=0; i<height-y; i++){ memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width); } } } } #if HAVE_AMD3DNOW_INLINE __asm__ volatile("femms"); #elif HAVE_MMX_INLINE __asm__ volatile("emms"); #endif #ifdef DEBUG_BRIGHTNESS if(!isColor){ int max=1; int i; for(i=0; i<256; i++) if(yHistogram[i] > max) max=yHistogram[i]; for(i=1; i<256; i++){ int x; int start=yHistogram[i-1]/(max/256+1); int end=yHistogram[i]/(max/256+1); int inc= end > start ? 1 : -1; for(x=start; x!=end+inc; x+=inc) dst[ i*dstStride + x]+=128; } for(i=0; i<100; i+=2){ dst[ (white)*dstStride + i]+=128; dst[ (black)*dstStride + i]+=128; } } #endif *c2= c; }
1threat
Incorporating interactive shiny apps into Rmarkdown document for blogdown Hugo blog : <p>I am attempting to upload my first post to a Hugo blog using RMarkdown. Below you can find my code creating the document:</p> <pre><code>--- title: "Untitled" author: "Jorge" date: "September 9, 2017" output: html_document runtime: shiny --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r echo=FALSE, include=FALSE} data('USArrests') head(USArrests) ``` ```{r echo = TRUE, include = FALSE} library(tidyverse) library(maps) library(mapproj) library(geosphere) library(ggrepel) library(scales) library(RColorBrewer) library(plotly) library(shiny) ``` ## Map ```{r, echo = FALSE, include = TRUE} us_states &lt;- map_data('state') USArrests$region &lt;- tolower(row.names(USArrests)) arrest_map_data &lt;- merge(us_states, USArrests, by = 'region') arrest_map_data &lt;- arrest_map_data[order(arrest_map_data$order),] inputPanel( selectInput("crime", label = "Crime: ", choices = list('Murder' = 'Murder', 'Assault' = 'Assault', 'Rape' = 'Rape'), selected = 'Murder') ) renderPlot( ggplot() + coord_map() + geom_map(data = arrest_map_data, map = arrest_map_data, aes(x = long, y = lat, map_id = region), fill = "grey80", color = "black", size = 0.15) + geom_polygon(data = arrest_map_data, aes_string(x = 'long', y = 'lat', group = 'group', fill = input$crime)) + scale_fill_gradient(low = 'light blue', high = 'dark blue', name = 'Arrests per 100,000\nresidents') + theme(legend.position = 'bottom', panel.grid = element_blank(), panel.background = element_blank(), axis.text = element_blank(), axis.title = element_blank()) ) ``` ## Scatterplot ```{r, echo = FALSE, include = TRUE} inputPanel( checkboxGroupInput("crime2", label = "Crime: ", choices = list('Murder' = 'Murder', 'Assault' = 'Assault', 'Rape' = 'Rape'), selected = c('Murder', 'Assault')) ) renderPlotly( ggplotly(ggplot(data = USArrests, aes_string(x = input$crime2[1], y = input$crime2[2], text = input$region)) + geom_point(fill = "grey80", color = "black", size = (USArrests$UrbanPop) / 10)) ) ``` </code></pre> <p>I save this as an .Rmd file within the Posts section of the R project related to the blogdown directory. When I run:</p> <pre><code>blogdown::serve_site() </code></pre> <p>I get an error saying: Error: path for html_dependency not provided Execution halted Error in render_page(f): The page shown above.</p> <p>I am new to blogdown and cannot find a solution to this error, so if anyone could provide some insight into how to work around this error and include interactive shiny apps into Hugo please let me know. </p> <p>Thank you!</p>
0debug
Adding '' to every character of a tuple sublist : <p>Hello I'm just finishing my Lorenz code but i have struggle with something, I can't add '' to a character of a list.</p> <pre><code>my_sublist:[(0,0,0,0,0,0,0),(0,0,0,0,0,0,1),(0,0,0,0,0,1,0)] </code></pre> <p>and the output that I expect is:</p> <pre><code>my_sublist:[('0','0','0','0','0','0','0'),('0','0','0','0','0','0','1'),('0','0','0','0','0','1','0')] </code></pre>
0debug
void ff_imdct_calc(MDCTContext *s, FFTSample *output, const FFTSample *input, FFTSample *tmp) { int k, n8, n4, n2, n, j; const uint16_t *revtab = s->fft.revtab; const FFTSample *tcos = s->tcos; const FFTSample *tsin = s->tsin; const FFTSample *in1, *in2; FFTComplex *z = (FFTComplex *)tmp; n = 1 << s->nbits; n2 = n >> 1; n4 = n >> 2; n8 = n >> 3; in1 = input; in2 = input + n2 - 1; for(k = 0; k < n4; k++) { j=revtab[k]; CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]); in1 += 2; in2 -= 2; } ff_fft_calc(&s->fft, z); for(k = 0; k < n4; k++) { CMUL(z[k].re, z[k].im, z[k].re, z[k].im, tcos[k], tsin[k]); } for(k = 0; k < n8; k++) { output[2*k] = -z[n8 + k].im; output[n2-1-2*k] = z[n8 + k].im; output[2*k+1] = z[n8-1-k].re; output[n2-1-2*k-1] = -z[n8-1-k].re; output[n2 + 2*k]=-z[k+n8].re; output[n-1- 2*k]=-z[k+n8].re; output[n2 + 2*k+1]=z[n8-k-1].im; output[n-2 - 2 * k] = z[n8-k-1].im; } }
1threat
Swift 2.x to swift 3, XCode complaining error : Non-optional expression of type 'String' used in a check for optionals : Migrating from Swift 2.x to swift 3, I have the warning on my code : let response=NSString(data:data!,encoding: String.Encoding.utf8.rawValue) let responseArray:Array=response!.components(separatedBy: "|VCSPACER|") if let result:String=responseArray[0] { if let action:String=responseArray[1] { if let datas:String=responseArray[2] { ....... } } } The compiler is warning at line : "if let action:String=responseArray[0]" and line "if let action:String=responseArray[1]" and "line if let datas:String=responseArray[2]" with the message "Non-optional expression of type 'String' used in a check for optionals" It was perfectly working on swift 2.X but not on swift 3 . What can change on this code to make it work ? Thanks a lot.
0debug
Is there a way to confirm a package-lock.json actually resolves all dependencies in a package.json? : <p>We want to add an automated check to our CI server that would prevent code from getting committed that updates a dependency in <code>package.json</code> but does not update the resolved dependency in <code>package-lock.json</code>.</p> <p>This could happen if, for example, someone updated a dependency in <code>package.json</code> manually but ran <code>npm install</code> instead of <code>npm update</code> (<code>npm install</code> favors <code>package-lock.json</code>, if present). Or it could happen even if someone runs the correct <code>npm</code> command when updating a dependency but then forgets to commit the resulting changes to <code>package-lock.json</code>. We try to watch for these things in code review, but an automated check would definitely be better. Is there any <code>npm</code> command that does this?</p> <p>Here's an example to illustrate.</p> <p><strong>Before</strong>:</p> <pre><code>// package.json { "lodash": "~3.1.0" } // package-lock.json { "dependencies": { "lodash": { "version": "3.1.3" } } } </code></pre> <p>Someone updates <code>package.json</code> but forgets to commit the change to <code>package-lock.json</code>.</p> <p><strong>After:</strong></p> <pre><code>// package.json { "lodash": "~3.2.0" } // package-lock.json (not changed) { "dependencies": { "lodash": { "version": "3.1.3" } } } </code></pre> <p>Now <code>package-lock.json</code> no longer reflects a valid set of dependency resolutions for the <code>package.json</code> file.</p>
0debug
BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read) { return is_read ? bs->on_read_error : bs->on_write_error; }
1threat
Changing method return from void to int still pass by value? : <p>I have referred to the various explanations around here on SO about pass by value and pass by reference in Java. So far the notion is that incase of primitive datatypes it goes pass by value and incase of reference and user defined datatypes it is pass by reference. I also read that arrays are always pass by reference. However, when I try to execute the following program why the outputs are different in both these methods? The location of the object is called the reference. So if I am passing by value to <code>demoByValue_</code> it should return <code>90</code> or <code>91</code>? What am I missing here? Also, will it help to start fiddling with first pointers from C/C++ in order to get an abstract picture of this idea or what could be a real life analogy to grasp thi concept for a beginner? I did look into the analogy of house addresses and if the person wants to go to a specific house it needs the address etc. But, I want to know here that why I am failing to understand this concept? How to access the reference to the value of a primitve data type to see whats going on?</p> <pre><code>public class Misc { public static void main(String[] args) { int a = 91; System.out.println(a); //prints 91 demoByValue(a); System.out.println(a); //prints 91 a = demoByValue_(a); System.out.println(a); //prints 90 -- Why?? } public static void demoByValue(int a){ a = 90; } public static int demoByValue_(int a){ a = 90; return a; } } </code></pre>
0debug
static void monitor_protocol_event_handler(void *opaque) { MonitorEventState *evstate = opaque; int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); qemu_mutex_lock(&monitor_event_state_lock); trace_monitor_protocol_event_handler(evstate->event, evstate->data, evstate->last, now); if (evstate->data) { monitor_protocol_event_emit(evstate->event, evstate->data); qobject_decref(evstate->data); evstate->data = NULL; } evstate->last = now; qemu_mutex_unlock(&monitor_event_state_lock); }
1threat
Generate Thumbnail of Pdf in Android : <p>I want to generate the image(thumbnail) from pdf file just like done by <strong>WhatsApp</strong> as shown below <a href="https://i.stack.imgur.com/fVTPy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fVTPy.jpg" alt="WhatsApp"></a></p> <p>I have tried</p> <ol> <li><strong>PDFBox</strong> (<a href="https://github.com/TomRoush/PdfBox-Android" rel="noreferrer">https://github.com/TomRoush/PdfBox-Android</a>)</li> <li><strong>Tika</strong> (compile 'org.apache.tika:tika-parsers:1.11')</li> <li><strong>AndroidPdfViewer</strong> (<a href="https://github.com/barteksc/AndroidPdfViewer" rel="noreferrer">https://github.com/barteksc/AndroidPdfViewer</a>)</li> </ol> <p>and still unable to find a way to generate image from pdf.</p> <hr> <p><strong><em>PDFBox:</em></strong></p> <p>There is a github issue that deals with this problem (<a href="https://github.com/TomRoush/PdfBox-Android/issues/3" rel="noreferrer">https://github.com/TomRoush/PdfBox-Android/issues/3</a>) but this is still unresolved.</p> <p><strong>Note:</strong> I am successfully able to extract image from PDF using <strong>PDFBOX</strong></p> <hr> <p><strong><em>AndroidPdfViewer:</em></strong></p> <p>Github issue (<a href="https://github.com/barteksc/AndroidPdfViewer/issues/49" rel="noreferrer">https://github.com/barteksc/AndroidPdfViewer/issues/49</a>)</p>
0debug
Accessing array index greater than the array size : <p>I always thought if I accessed an array index greater than the array size that it would cause a runtime error? But it seems to be happy to run and output zero. Is this compiler specific or OS specific? Will some different environments cause a runtime error when you access an array index greater than the array size?</p> <p>For eg;</p> <pre><code>int foo[5]; cout &lt;&lt; foo[5] &lt;&lt; endl; vector&lt;int&gt; bar(5); cout &lt;&lt; bar[5] &lt;&lt; endl; </code></pre>
0debug
how to show animation only once per applicaton run (Android) : I have 2 activities in my app, Activity 1 (with some elements) and Activity 2 which has Progress Bar (and the user needs to move between those all the time), i want to show this progress bar in ony th first time the user moves to the activity 2, every time the app launches (meaning if the app was closed and reopened and the user switched to activity 2 i want to show this progress bar again, how can i achieve this? Thanks!
0debug
Error:Data Binding does not support Jack builds yet : <p>I am implementing <code>DataBinding</code>, it is working perfect, but it is not allowing me to use <code>jackOptions</code>. It throws error <code>Data Binding does not support Jack builds yet</code> while build.</p> <p>Here is my <code>build.gradle</code></p> <pre><code>android { defaultConfig { ... dataBinding { enabled true } jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } </code></pre>
0debug
static int create_filtergraph(AVFilterContext *ctx, const AVFrame *in, const AVFrame *out) { ColorSpaceContext *s = ctx->priv; const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in->format); const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format); int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0; #define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12) #define supported_subsampling(lcw, lch) \ (((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1)) #define supported_format(d) \ ((d) != NULL && (d)->nb_components == 3 && \ !((d)->flags & AV_PIX_FMT_FLAG_RGB) && \ supported_depth((d)->comp[0].depth) && \ supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h)) if (!supported_format(in_desc)) { av_log(ctx, AV_LOG_ERROR, "Unsupported input format %d (%s) or bitdepth (%d)\n", in->format, av_get_pix_fmt_name(in->format), in_desc ? in_desc->comp[0].depth : -1); return AVERROR(EINVAL); } if (!supported_format(out_desc)) { av_log(ctx, AV_LOG_ERROR, "Unsupported output format %d (%s) or bitdepth (%d)\n", out->format, av_get_pix_fmt_name(out->format), out_desc ? out_desc->comp[0].depth : -1); return AVERROR(EINVAL); } if (in->color_primaries != s->in_prm) s->in_primaries = NULL; if (out->color_primaries != s->out_prm) s->out_primaries = NULL; if (in->color_trc != s->in_trc) s->in_txchr = NULL; if (out->color_trc != s->out_trc) s->out_txchr = NULL; if (in->colorspace != s->in_csp || in->color_range != s->in_rng) s->in_lumacoef = NULL; if (out->colorspace != s->out_csp || out->color_range != s->out_rng) s->out_lumacoef = NULL; if (!s->out_primaries || !s->in_primaries) { s->in_prm = in->color_primaries; s->in_primaries = get_color_primaries(s->in_prm); if (!s->in_primaries) { av_log(ctx, AV_LOG_ERROR, "Unsupported input primaries %d (%s)\n", s->in_prm, av_color_primaries_name(s->in_prm)); return AVERROR(EINVAL); } s->out_prm = out->color_primaries; s->out_primaries = get_color_primaries(s->out_prm); if (!s->out_primaries) { if (s->out_prm == AVCOL_PRI_UNSPECIFIED) { if (s->user_all == CS_UNSPECIFIED) { av_log(ctx, AV_LOG_ERROR, "Please specify output primaries\n"); } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output color property %d\n", s->user_all); } } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output primaries %d (%s)\n", s->out_prm, av_color_primaries_name(s->out_prm)); } return AVERROR(EINVAL); } s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries, sizeof(*s->in_primaries)); if (!s->lrgb2lrgb_passthrough) { double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3]; fill_rgb2xyz_table(s->out_primaries, rgb2xyz); invert_matrix3x3(rgb2xyz, xyz2rgb); fill_rgb2xyz_table(s->in_primaries, rgb2xyz); if (s->out_primaries->wp != s->in_primaries->wp && s->wp_adapt != WP_ADAPT_IDENTITY) { double wpconv[3][3], tmp[3][3]; fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp, s->out_primaries->wp); mul3x3(tmp, rgb2xyz, wpconv); mul3x3(rgb2rgb, tmp, xyz2rgb); } else { mul3x3(rgb2rgb, rgb2xyz, xyz2rgb); } for (m = 0; m < 3; m++) for (n = 0; n < 3; n++) { s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]); for (o = 1; o < 8; o++) s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0]; } emms = 1; } } if (!s->in_txchr) { av_freep(&s->lin_lut); s->in_trc = in->color_trc; s->in_txchr = get_transfer_characteristics(s->in_trc); if (!s->in_txchr) { av_log(ctx, AV_LOG_ERROR, "Unsupported input transfer characteristics %d (%s)\n", s->in_trc, av_color_transfer_name(s->in_trc)); return AVERROR(EINVAL); } } if (!s->out_txchr) { av_freep(&s->lin_lut); s->out_trc = out->color_trc; s->out_txchr = get_transfer_characteristics(s->out_trc); if (!s->out_txchr) { if (s->out_trc == AVCOL_TRC_UNSPECIFIED) { if (s->user_all == CS_UNSPECIFIED) { av_log(ctx, AV_LOG_ERROR, "Please specify output transfer characteristics\n"); } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output color property %d\n", s->user_all); } } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output transfer characteristics %d (%s)\n", s->out_trc, av_color_transfer_name(s->out_trc)); } return AVERROR(EINVAL); } } s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough && !memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr))); if (!s->rgb2rgb_passthrough && !s->lin_lut) { res = fill_gamma_table(s); if (res < 0) return res; emms = 1; } if (!s->in_lumacoef) { s->in_csp = in->colorspace; s->in_rng = in->color_range; s->in_lumacoef = get_luma_coefficients(s->in_csp); if (!s->in_lumacoef) { av_log(ctx, AV_LOG_ERROR, "Unsupported input colorspace %d (%s)\n", s->in_csp, av_color_space_name(s->in_csp)); return AVERROR(EINVAL); } redo_yuv2rgb = 1; } if (!s->out_lumacoef) { s->out_csp = out->colorspace; s->out_rng = out->color_range; s->out_lumacoef = get_luma_coefficients(s->out_csp); if (!s->out_lumacoef) { if (s->out_csp == AVCOL_SPC_UNSPECIFIED) { if (s->user_all == CS_UNSPECIFIED) { av_log(ctx, AV_LOG_ERROR, "Please specify output transfer characteristics\n"); } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output color property %d\n", s->user_all); } } else { av_log(ctx, AV_LOG_ERROR, "Unsupported output transfer characteristics %d (%s)\n", s->out_csp, av_color_space_name(s->out_csp)); } return AVERROR(EINVAL); } redo_rgb2yuv = 1; } fmt_identical = in_desc->log2_chroma_h == out_desc->log2_chroma_h && in_desc->log2_chroma_w == out_desc->log2_chroma_w; s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && fmt_identical; s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->in_rng == s->out_rng && !memcmp(s->in_lumacoef, s->out_lumacoef, sizeof(*s->in_lumacoef)); if (!s->yuv2yuv_passthrough) { if (redo_yuv2rgb) { double rgb2yuv[3][3], (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs; int off, bits, in_rng; res = get_range_off(&off, &s->in_y_rng, &s->in_uv_rng, s->in_rng, in_desc->comp[0].depth); if (res < 0) { av_log(ctx, AV_LOG_ERROR, "Unsupported input color range %d (%s)\n", s->in_rng, av_color_range_name(s->in_rng)); return res; } for (n = 0; n < 8; n++) s->yuv_offset[0][n] = off; fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv); invert_matrix3x3(rgb2yuv, yuv2rgb); bits = 1 << (in_desc->comp[0].depth - 1); for (n = 0; n < 3; n++) { for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) { s->yuv2rgb_coeffs[n][m][0] = lrint(28672 * bits * yuv2rgb[n][m] / in_rng); for (o = 1; o < 8; o++) s->yuv2rgb_coeffs[n][m][o] = s->yuv2rgb_coeffs[n][m][0]; } } av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0); av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0); av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]); av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]); s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1] [in_desc->log2_chroma_h + in_desc->log2_chroma_w]; emms = 1; } if (redo_rgb2yuv) { double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs; int off, out_rng, bits; res = get_range_off(&off, &s->out_y_rng, &s->out_uv_rng, s->out_rng, out_desc->comp[0].depth); if (res < 0) { av_log(ctx, AV_LOG_ERROR, "Unsupported output color range %d (%s)\n", s->out_rng, av_color_range_name(s->out_rng)); return res; } for (n = 0; n < 8; n++) s->yuv_offset[1][n] = off; fill_rgb2yuv_table(s->out_lumacoef, rgb2yuv); bits = 1 << (29 - out_desc->comp[0].depth); for (out_rng = s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) { for (m = 0; m < 3; m++) { s->rgb2yuv_coeffs[n][m][0] = lrint(bits * out_rng * rgb2yuv[n][m] / 28672); for (o = 1; o < 8; o++) s->rgb2yuv_coeffs[n][m][o] = s->rgb2yuv_coeffs[n][m][0]; } } av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]); s->rgb2yuv = s->dsp.rgb2yuv[(out_desc->comp[0].depth - 8) >> 1] [out_desc->log2_chroma_h + out_desc->log2_chroma_w]; s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) >> 1] [out_desc->log2_chroma_h + out_desc->log2_chroma_w]; emms = 1; } if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) { int idepth = in_desc->comp[0].depth, odepth = out_desc->comp[0].depth; double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs; double (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs; double yuv2yuv[3][3]; int in_rng, out_rng; mul3x3(yuv2yuv, yuv2rgb, rgb2yuv); for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) { for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) { s->yuv2yuv_coeffs[m][n][0] = lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) / (in_rng * (1 << odepth))); for (o = 1; o < 8; o++) s->yuv2yuv_coeffs[m][n][o] = s->yuv2yuv_coeffs[m][n][0]; } } av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0); av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0); s->yuv2yuv = s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1] [in_desc->log2_chroma_h + in_desc->log2_chroma_w]; } } if (emms) emms_c(); return 0; }
1threat
def neg_nos(list1): for num in list1: if num < 0: return num
0debug
static int vmdk_open_vmfs_sparse(BlockDriverState *bs, BlockDriverState *file, int flags, Error **errp) { int ret; uint32_t magic; VMDK3Header header; VmdkExtent *extent; ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read header from file '%s'", file->filename); return ret; } ret = vmdk_add_extent(bs, file, false, le32_to_cpu(header.disk_sectors), le32_to_cpu(header.l1dir_offset) << 9, 0, le32_to_cpu(header.l1dir_size), 4096, le32_to_cpu(header.granularity), &extent, errp); if (ret < 0) { return ret; } ret = vmdk_init_tables(bs, extent, errp); if (ret) { vmdk_free_last_extent(bs); } return ret; }
1threat