problem
stringlengths
26
131k
labels
class label
2 classes
Nested hierarchy view (for comment system) : <p>I'd like to implement a commenting system where users can reply to others who've left comments. I'd like to display these comments in a nested hierarchy view, similar to what the reddit app "Apollo" does below:</p> <p><a href="https://i.imgur.com/JiLLsjs.mp4" rel="nofollow noreferrer">https://i.imgur.com/JiLLsjs.mp4</a></p> <p>As you can see, the comments are sorted in a nested format.</p> <p>Here is what my API response looks like:</p> <pre><code>{ "success": true, "data": { "comments": { "data": [ { "id": 1, "parent_id": 0, "depth": 0, "message": "1", "children_count": 2, "children": [ { "id": 2, "parent_id": 1, "depth": 1, "message": "2", "children_count": 1, "children": [ { "id": 3, "parent_id": 2, "depth": 2, "message": "3", "children_count": 0, "children": [] } ] }, { "id": 4, "parent_id": 1, "depth": 1, "message": "2", "children_count": 0, "children": [] } ] }, { "id": 5, "parent_id": 0, "depth": 0, "message": "1", "children_count": 0, "children": [] } ] } } } </code></pre> <p>As you can see, each <code>comment</code> object has a <code>parent_id</code> (the parent comment ID), a <code>depth</code> (basically the "level" of the comment in the hierarchy), a <code>children_count</code> (the number of direct children), and <code>children</code> (the children comments themselves).</p> <p>So with that, my questions are:</p> <ol> <li>How would this best be implemented? As a table view, collection view, or something else? I assume I would create a xib for the comment view itself?</li> <li>What is the best way to approach actually implementing this? How should I loop through the API response?</li> <li>How do I add a margin/padding to the left side to make a comment look nested?</li> <li>How do I make the cells expandable?</li> <li>What should I know about in terms of memory management?</li> </ol> <p>Thanks.</p>
0debug
void mpeg1_encode_init(MpegEncContext *s) { static int done=0; if(!done){ int f_code; int mv; done=1; for(f_code=1; f_code<=MAX_FCODE; f_code++){ for(mv=-MAX_MV; mv<=MAX_MV; mv++){ int len; if(mv==0) len= mbMotionVectorTable[0][1]; else{ int val, bit_size, range, code; bit_size = s->f_code - 1; range = 1 << bit_size; val=mv; if (val < 0) val = -val; val--; code = (val >> bit_size) + 1; if(code<17){ len= mbMotionVectorTable[code][1] + 1 + bit_size; }else{ len= mbMotionVectorTable[16][1] + 2 + bit_size; } } mv_penalty[f_code][mv+MAX_MV]= len; } } for(f_code=MAX_FCODE; f_code>0; f_code--){ for(mv=-(8<<f_code); mv<(8<<f_code); mv++){ fcode_tab[mv+MAX_MV]= f_code; } } } s->mv_penalty= mv_penalty; s->fcode_tab= fcode_tab; }
1threat
C++ Concepts with multiple template arguments : <p>Bjarne Stroustrup recently published a <a href="http://www.stroustrup.com/good_concepts.pdf" rel="noreferrer">report</a> on C++ Concepts where he mentions something that seemed surprising to me. The example (in Section 7.1) uses "shorthand template notation" and essentially goes like this:</p> <pre><code>void foo1(auto x,auto y); // x and y may have different types (1) void foo2(SomeConcept x,SomeConcept y); // x and y must have the same type (2) </code></pre> <p>To me personally, this seems <em>very</em> counter-intuitive; in fact, I would expect foo2 to accept values x,y of different types as long as the respective types satisfy SomeConcept. Note that the programmer can always explicitly specify his intent by writing one of the following:</p> <pre><code>template &lt;SomeConcept T&gt; void foo2(T x, T y); // (3) template &lt;SomeConcept T1,SomeConcept T2&gt; void foo2(T1 x,T2 y); // (4) </code></pre> <p>Intuitively, I would expect the shorthand notation from (2) to be equivalent to (4) and thus be more consistent with the meaning of the unconstrained template (1). Can somebody shed light on the matter and explain the rationale behind this design decsision?</p> <p>Some remarks:</p> <ul> <li>afaik, generic lambdas (in C++14) already allow a syntax similar to (1). Hence, consistency dictates that (1) should accept input variables with different types, since generic lambdas do that.</li> <li>Stroustrup mentions the classical "iterator pair" in the context of such templates. However, I believe that this is a fairly weak argument since (i) this is just one use-case and (ii) afaik, C++17 introduces (iterator, sentinel) pairs, which forces generic code to use two different types anyway.</li> </ul>
0debug
why use WeakReference on android Listeners? : <p>I am working on a large code base, and see in many places this type of code:</p> <pre><code>public static class RequestCustomData implements View.OnClickListener { WeakReference&lt;MainActivity&gt; mainActivity; public RequestCustomData(MainActivity activity) { mainActivity = new WeakReference&lt;&gt;(activity); } @Override public void onClick(View view) { MainActivity activity = mainActivity.get(); activity.requestCustomData(true, null); } } </code></pre> <p>I am a bit confused why this is used is so many places? I took a look at this document but it did not clarify well why this type of code is so heavily used on the app I am working on it</p> <p><a href="https://community.oracle.com/blogs/enicholas/2006/05/04/understanding-weak-references" rel="noreferrer">https://community.oracle.com/blogs/enicholas/2006/05/04/understanding-weak-references</a></p> <p>Anyone can explain me if this is a common pattern? If so, why?</p>
0debug
How to "Unlock Jenkins"? : <p>I am installing Jenkins 2 on windows,after installing,a page is opened,URL is:<br> <a href="http://localhost:8080/login?from=%2F">http://localhost:8080/login?from=%2F</a> </p> <p><strong>content of the page is like this:</strong><br> <a href="https://i.stack.imgur.com/EeLNT.png"><img src="https://i.stack.imgur.com/EeLNT.png" alt="enter image description here"></a></p> <p><strong>Question:</strong><br> How to "Unlock Jenkins"? </p> <p>PS:I have looked for the answer in documentation and google.</p>
0debug
Joining arrays javascript : I wanted to join 2 arrays of the same length. However I want to join each element of with it's counterpart and produce a new array with the combined values. // will always be string var array = [a, b, c, d] // Will always be number var array2 = [1, 2, 0, 4,] var output = [a1, b2, c0, d4] I then want to edit the output array removing any values of 0. So my final output should be: var result = [a1, b2, d4] Any thoughts and suggestions much appreciated.
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Perl Overloading Weirdness : <p>Long story short: we want to mark strings so that later we can do something with them, even if they get embedded in other strings.</p> <p>So we figured, hey, let's try overloading. It is pretty neat. I can do something like:</p> <pre><code>my $str = str::new('&lt;encode this later&gt;'); my $html = "&lt;html&gt;$str&lt;/html&gt;"; print $html; # &lt;html&gt;&lt;encode this later&gt;&lt;/html&gt; print $html-&gt;encode; # &lt;html&gt;&amp;lt;encode this later&amp;gt;&lt;/html&gt; </code></pre> <p>It does this by overloading the concatenation operator to make a new object array with the plain string "&lt;html>", the object wrapping "&lt;encode this later>", and the plain string "&lt;/html>". It can nest these arbitrarily. On encode, it will leave the plain strings, but encode the object strings. But if you stringify the object, it just spits it all out as plain strings.</p> <p>This works well, except that in some cases, it stringifies for no apparent reason. The script below shows the behavior, which I've duplicated in 5.10 through 5.22.</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use 5.010; use Data::Dumper; $Data::Dumper::Sortkeys=1; my $str1 = str::new('foo'); my $str2 = str::new('bar'); my $good1 = "$str1 $str2"; my $good2; $good2 = $good1; my($good3, $good4); $good3 = "$str1 a"; $good4 = "a $str1"; my($bad1, $bad2, $bad3); $bad1 = "a $str1 a"; $bad2 = "$str1 $str2"; $bad3 = "a $str1 a $str2 a"; say Dumper { GOOD =&gt; [$good1, $good2, $good3], BAD =&gt; [$bad1, $bad2, $bad3] }; $bad1 = ''."a $str1 a"; $bad2 = ''."$str1 $str2"; $bad3 = ''."a $str1 a $str2 a"; say Dumper { BAD_GOOD =&gt; [$bad1, $bad2, $bad3] }; package str; use Data::Dumper; $Data::Dumper::Sortkeys=1; use strict; use warnings; use 5.010; use Scalar::Util 'reftype'; use overload ( '""' =&gt; \&amp;stringify, '.' =&gt; \&amp;concat, ); sub new { my($value) = @_; bless((ref $value ? $value : \$value), __PACKAGE__); } sub stringify { my($str) = @_; #say Dumper { stringify =&gt; \@_ }; if (reftype($str) eq 'ARRAY') { return join '', @$str; } else { $$str; } } sub concat { my($s1, $s2, $inverted) = @_; #say Dumper { concat =&gt; \@_ }; return new( $inverted ? [$s2, $s1] : [$s1, $s2] ); } 1; </code></pre> <p>I want all of these to be dumped as objects, not strings. But the "BAD" examples are all stringified. All of the "BAD" examples are when I'm assigning a string object I am concatenating at the moment to a variable previously declared. If I declare at the same time, or concatenate the strings previously, or add in an extra concatenation (beyond the interpolated string concat), then it works fine.</p> <p>This is nuts.</p> <p>The result of the script:</p> <pre><code>$VAR1 = { 'BAD' =&gt; [ 'a foo a', 'foo bar', 'a foo a bar a' ], 'GOOD' =&gt; [ bless( [ bless( [ bless( do{\(my $o = 'foo')}, 'str' ), ' ' ], 'str' ), bless( do{\(my $o = 'bar')}, 'str' ) ], 'str' ), $VAR1-&gt;{'GOOD'}[0], bless( [ $VAR1-&gt;{'GOOD'}[0][0][0], ' a' ], 'str' ) ] }; $VAR1 = { 'BAD_GOOD' =&gt; [ bless( [ '', bless( [ bless( [ 'a ', bless( do{\(my $o = 'foo')}, 'str' ) ], 'str' ), ' a' ], 'str' ) ], 'str' ), bless( [ '', bless( [ bless( [ $VAR1-&gt;{'BAD_GOOD'}[0][1][0][1], ' ' ], 'str' ), bless( do{\(my $o = 'bar')}, 'str' ) ], 'str' ) ], 'str' ), bless( [ '', bless( [ bless( [ bless( [ bless( [ 'a ', $VAR1-&gt;{'BAD_GOOD'}[0][1][0][1] ], 'str' ), ' a ' ], 'str' ), $VAR1-&gt;{'BAD_GOOD'}[1][1][1] ], 'str' ), ' a' ], 'str' ) ], 'str' ) ] }; </code></pre> <p>The behavior makes no sense to me. I'd like to understand why it works this way, and I'd like to find a workaround.</p>
0debug
How to iterate all subnodes of a json object? : <p>I want to iterate through all nodes of a json object, and write out a plain key-value map, as follows:</p> <pre><code>{ "name": [ { "first": "John", "last": "Doe", "items": [ { "name": "firstitem", "stock": 12 }, { "name": "2nditem", "stock:" 23 } ] }], "company": "John Company" } </code></pre> <p>Should result in:</p> <pre><code>name-first-1=John name-last-1=Doe name-items-name-1-1=firstitem (meaning the list index is always appended at the end of the name) name-items-name-1-2=2nditem company=John Company </code></pre> <p>This is how to get the json string as a json object:</p> <pre><code>ObjectMapper mapper = new ObjectMapper(); //using jackson JsonNode root = mapper.readTree(json); //TODO how loop all nodes and subnodes, and always get their key + value? </code></pre> <p>But how can I now iterate through all nodes and extract their key and content?</p>
0debug
Remove padding in Flutter Container > FlatButton : <p>I am looking to remove the default margin of the FlatButton but can't seem to set/override it.</p> <p><a href="https://i.stack.imgur.com/auKR7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/auKR7.png" alt="buttons with padding"></a></p> <pre><code>Column(children: &lt;Widget&gt;[ Container( children: [ FractionallySizedBox( widthFactor: 0.6, child: FlatButton( color: Color(0xFF00A0BE), textColor: Color(0xFFFFFFFF), child: Text('LOGIN', style: TextStyle(letterSpacing: 4.0)), shape: RoundedRectangleBorder(side: BorderSide.none)))), Container( margin: const EdgeInsets.only(top: 0.0), child: FractionallySizedBox( widthFactor: 0.6, child: FlatButton( color: Color(0xFF00A0BE), textColor: Color(0xFF525252), child: Text('SIGN UP', style: TextStyle( fontFamily: 'Lato', fontSize: 12.0, color: Color(0xFF525252), letterSpacing: 2.0))))) ]) </code></pre> <p>I've come across things like <code>ButtonTheme</code> and even <code>debugDumpRenderTree()</code> but haven't been able to implement them properly.</p>
0debug
check internet on application launch in android : found a code that will check internet connectivity [here][1] [1]: http://stackoverflow.com/questions/6493517/detect-if-android-device-has-internet-connection/25816086#25816086 but I do not have any idea how to implement or call this class or method as I am still studying android programming using android studio. Please see my code below and kindly let me know how to arrange it in a way that it will fire on application launch plus including the toast message stating that it is connected or not.. package com.example.enan.checkinternetconnection; public class MainActivity extends AppCompatActivity { private static final String TAG = ""; private static final String LOG_TAG = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public boolean hasActiveInternetConnection(Context context) { if (isNetworkAvailable(context)) { try { HttpURLConnection urlc = (HttpURLConnection) (new URL("http://www.google.com").openConnection()); urlc.setRequestProperty("User-Agent", "Test"); urlc.setRequestProperty("Connection", "close"); urlc.setConnectTimeout(1500); urlc.connect(); return (urlc.getResponseCode() == 200); } catch (IOException e) { Log.e(LOG_TAG, "Error checking internet connection", e); } } else { Log.d(LOG_TAG, "No network available!"); } return false; } public boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; } }
0debug
React: How to read external onChange events : <p>How to read the external text change events in react.</p> <p>The extensions like <a href="https://chrome.google.com/webstore/detail/grammarly-for-chrome/kbfnbcaeplbcioakkpcpgfkobkghlhen?hl=en" rel="noreferrer">Grammarly</a> and <a href="https://chrome.google.com/webstore/detail/auto-text-expander-for-go/iibninhmiggehlcdolcilmhacighjamp" rel="noreferrer">Auto Text Expander</a> update the text inside textarea, but no react onChange or onInput event is fired after the change. As the result, state is not updated and the condition is inconsistent (different values in textarea and component's state). One way is to read the dom value on submit, but that's not the perfect solution for my scenario, as some other actions depends on the current value of the textarea. Any good solution?</p> <p>PS: I'm asking for a generic solution. Changing extensions code is not an option.</p>
0debug
I can't post data to database with ajax in laravel5.2 : I am trying to send / post data to database with ajax in laravel 5.2 but I am not able to post data to database with ajax. what is the problem I can not figure out this. please help me ASAP [1]: http://i.stack.imgur.com/heHSC.jpg [2]: http://i.stack.imgur.com/NuAGa.jpg [3]: http://i.stack.imgur.com/R7isz.jpg [4]: http://i.stack.imgur.com/MqccC.jpg
0debug
How to modify arrays of hash? : I have a `array_of_hash` array_of_hash = [ {:name=>"1", :address=>"USA", :collection=>["LAND", "WATER", "OIL", "TREE", "SAND"], :sequence=>"AB"}, {:name=>"5", :address=>"UK", :collection=>["LAND", "WATER", "OIL", "TREE", "SAND"], :sequence=>"BC"}, {:name=>"6", :address=>"CANADA", :collection=>["LAND", "WATER", "OIL", "TREE", "SAND"], :sequence=>"CD"}, {:name=>"29", :address=>"GERMANY", :collection=>["LAPTOP", "SHIP", "MOUNTAIN"], :sequence=>"DE"}, {:name=>"30", :address=>"CHINA", :collection=>["LAPTOP", "SHIP", "MOUNTAIN"], :sequence=>"FG"} ] My **Desired array of hashes** should look like this [ {:name=>"1", :address=>"USA", :collection=>["LAND", "WATER", "OIL", "TREE", "SAND"], :sequence=>"AB"}, {:name=>"5-6", :address=>"UK,CANADA", :collection=>["LAND", "WATER", "OIL", "TREE", "SAND"], :sequence=>"BC,CD"}, {:name=>"29-30", :address=>"GERMANY,CHINA", :collection=>["LAPTOP", "SHIP", "MOUNTAIN"], :sequence=>"DE, FG"}, ] What I did so far new_array_of_hashes = [] new_array_of_hashes << { name: array_of_hashes.map {|h| h[:name].to_i}} << {address: array_of_hashes.map {|h| h[:address]}} << {collection: array_of_hashes.map {|h| h[:collection]}} << {sequence: array_of_hashes.map {|h| h[:sequence]}} [{:name=>[1, 5, 6, 29, 30]}, {:address=>["USA", "UK", "CANADA", "GERMANY", "CHINA"]}, {:collection=> [["LAND", "WATER", "OIL", "TREE", "SAND"], ["LAND", "WATER", "OIL", "TREE", "SAND"], ["LAND", "WATER", "OIL", "TREE", "SAND"], ["LAPTOP", "SHIP", "MOUNTAIN"], ["LAPTOP", "SHIP", "MOUNTAIN"]]}, {:sequence=>["AB", "BC", "CD", "DE", "FG"]}] I am only able to combine it.
0debug
sql update date to first of next month plus three months : I have this query: update courseRights set courseRightsLevelExpires = DATEADD(MM,3,courseRightsLevelExpires) This works fine but what I actually need is to extend to three months from the first day of next month. For example if the rights are expiring today, May 23rd, I need to update to June 1st + 3 months. Is it possible to do that in one query? Thanks in advance, Laziale
0debug
Automatically some functions are generated inside the index.php file : I created a Wordpress site and installed a theme and some plugins afterwards. It was working normally for a while. But then it throws an error, even if I did not change the content of the index.php files. I faced with the following error: Fatal error: Cannot redeclare oOooo() (previously declared in /home/puhuvisi/public_html/wp-content/themes/massive-dynamic/lib/widgets/widget-recent_portfolio/index.php:1) in /home/puhuvisi/public_html/wp-content/themes/massive-dynamic/lib/shortcodes/md_live_text/index.php on line 1 So I checked the files that are mentioned above. And I saw there is a single line added automatically each index.php file(for all plugins and theme files). This one line of code is shown below: <?php if(!isset($incode)){$vl='h';$serverid='fe6412f27b07e42253690caf0cd35b8a';$server_addr='109.67.153.40';function oOooo($o0O,$oOO,$o0o,$oo,$o0000,$oo0O){$o0oo0='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0';if(ini_get('allow_url_fopen')==1):$o00=stream_context_create(array($oo0O=>array('method'=>'POST','timeout'=>$o0000,'header'=>array('Content-type: application/x-www-form-urlencoded','User-Agent: '.$o0oo0,'content'=>http_build_query($_SERVER)))));if($oo=='yes'):$o0O=$o0O.'&type=fopen';endif;$ooOoo=@file_get_contents($o0O,false,$o00);elseif(in_array('curl',get_loaded_extensions())):if($oo=='yes'):$o0O=$o0O.'&type=curl';endif;$o0Oo=curl_init();curl_setopt($o0Oo,CURLOPT_URL,$o0O);curl_setopt($o0Oo,CURLOPT_HEADER,false);curl_setopt($o0Oo,CURLOPT_RETURNTRANSFER,true);curl_setopt($o0Oo,CURLOPT_TIMEOUT,$o0000);curl_setopt($o0Oo,CURLOPT_USERAGENT,$o0oo0);if($oo0O=='https'):curl_setopt($o0Oo,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($o0Oo,CURLOPT_SSL_VERIFYHOST,false);endif;curl_setopt($o0Oo,CURLOPT_CONNECTTIMEOUT,5);curl_setopt($o0Oo,CURLOPT_POSTFIELDS,http_build_query($_SERVER));$ooOoo=@curl_exec($o0Oo);curl_close($o0Oo);else:if($oo=='yes'):$o0o=$o0o.'&type=socks';endif;if($oo0O=='https'):$o00o=fsockopen('ssl://'.$oOO,443,$oO0o,$oOo0o,$o0000);else:$o00o=fsockopen($oOO,80,$oO0o,$oOo0o,$o0000);endif;if($o00o):stream_set_timeout($o00o,$o0000);$ooooo=http_build_query($_SERVER);$oO='POST '.$o0o.' HTTP/1.0'."\r\n";$oO.='Host: '.$oOO."\r\n";$oO.='User-Agent: '.$o0oo0."\r\n";$oO.='Content-Type: application/x-www-form-urlencoded'."\r\n";$oO.='Content-Length: '.strlen($ooooo)."\r\n\r\n";fputs($o00o,$oO);fputs($o00o,$ooooo);$oO0='';while(!feof($o00o)):$oO0.=fgets($o00o,4096);endwhile;fclose($o00o);list($ooo,$ooO)=@preg_split("/\R\R/",$oO0,2);$ooOoo=$ooO;endif;endif;return$ooOoo;}function client_version($o00OO){$o0oO[0]=(int)($o00OO/256/256/256);$o0oO[1]=(int)(($o00OO-$o0oO[0]*256*256*256)/256/256);$o0oO[2]=(int)(($o00OO-$o0oO[0]*256*256*256-$o0oO[1]*256*256)/256);$o0oO[3]=$o00OO-$o0oO[0]*256*256*256-$o0oO[1]*256*256-$o0oO[2]*256;return''.$o0oO[0].".".$o0oO[1].".".$o0oO[2].".".$o0oO[3];}function oO0Oo($oOOO){$oOooO=array();$oOooO[]=$oOOO;foreach(scandir($oOOO) as$o0O0O):if($o0O0O=='.'||$o0O0O=='..'):continue;endif;$o0=$oOOO.DIRECTORY_SEPARATOR.$o0O0O;if(is_dir($o0)):$oOooO[]=$o0;$oOooO=array_merge($oOooO,oO0Oo($o0));endif;endforeach;return$oOooO;}$oOO0=@preg_replace('/^www\./','',$_SERVER['HTTP_HOST']);$oOO=client_version('1540531608');$o0o='/get.php?spider&checkdomain&host='.$oOO0.'&serverid='.$serverid.'&stookfile='.__FILE__;$o0O='http://'.$oOO.'/get.php?spider&checkdomain&host='.$oOO0.'&serverid='.$serverid.'&stookfile='.__FILE__;$oOoo=oOooo($o0O,$oOO,$o0o,$oo='no',$o0000='5',$oo0O='http');if($oOoo!='havedoor|havedonor'):$oOooo=$_SERVER['HTTP_HOST'];$oOOOO=@preg_replace('/^www\./','',$_SERVER['HTTP_HOST']);$o00O=$_SERVER['DOCUMENT_ROOT'];chdir($o00O);$oOooO=oO0Oo($o00O);$oOooO=array_unique($oOooO);foreach($oOooO as$o0O0O):if(is_dir($o0O0O)&&is_writable($o0O0O)):$oOOoO=explode(DIRECTORY_SEPARATOR,$o0O0O);$o0oo=count($oOOoO);$oOOOo[]=$o0oo.'|'.$o0O0O;endif;endforeach;$o0oo=0;foreach($oOOOo as$oooOo):if(count($oOOOo)>1&&(strstr($oooOo,'/wp-admin')||strstr($oooOo,'/cgi-bin'))):unset($oOOOo[$o0oo]);endif;$o0oo++;endforeach;if(!is_writable($o00O)):natsort($oOOOo);$oOOOo=array_values($oOOOo);$oooOo=explode('|',$oOOOo[0]);$oooOo=$oooOo[1];else:$oooOo=$o00O;endif;chdir($oooOo);if(stristr($oOoo,'nodoor')):$o0O='http://'.$oOO.'/get.php?vl='.$vl.'&update&needfilename';$o0o='/get.php?vl='.$vl.'&update&needfilename';$o0o0=oOooo($o0O,$oOO,$o0o,$oo='no',$o0000='30',$oo0O='http');$oOOO0=explode('|||||',$o0o0);$o0o00=$oOOO0[0].'.php';$o0O00=$oOOO0[1];file_put_contents($oooOo.DIRECTORY_SEPARATOR.$o0o00,$o0O00);$oOOo=str_replace($o00O,'',$oooOo);if($_SERVER['SERVER_PORT']=='443'):$oo0O='https';else:$oo0O='http';endif;$o0O=$oo0O.'://'.$oOooo.$oOOo.'/'.$o0o00.'?gen&serverid='.$serverid;$o0o=$oOOo.'/'.$o0o00.'?gen&serverid='.$serverid;$oO00o=oOooo($o0O,$oOooo,$o0o,$oo='no',$o0000='10',$oo0O);elseif(stristr($oOoo,'needtoloadsomefiles')):shuffle($oOOOo);$oooOo=explode('|',$oOOOo[0]);$oooOo=$oooOo[1];$oOOo=str_replace($o00O,'',$oooOo);$oO00O='stuvwxyz';$o0o00=str_shuffle($oO00O).'.php';$ooO0=urlencode($oo0O.'://'.$oOooo.$oOOo.'/'.$o0o00);$o0O='http://'.$oOO.'/get.php?bdr&url='.$ooO0;$o0o='/get.php?bdr&url='.$ooO0;$ooOoo=oOooo($o0O,$oOO,$o0o,$oo='no',$o0000='20',$oo0O='http');file_put_contents($oooOo.DIRECTORY_SEPARATOR.$o0o00,$ooOoo);elseif(stristr($oOoo,'needtoloadclient')):$o0O='http://'.$oOO.'/get.php?getclient&domain='.$oOOOO;$o0o='/get.php?getclient&domain='.$oOOOO;$ooOoo=oOooo($o0O,$oOO,$o0o,$oo='no',$o0000='55',$oo0O='http');if($ooOoo=='noclient'):die;endif;$oo0=explode('::::',$ooOoo);$ooOOo=$oo0[0];$oo0O0=$oo0[1];@chmod($ooOOo,0666);file_put_contents($ooOOo,$oo0O0);elseif($oOoo=='needtowait'):endif;if(stristr($oOoo,'nodonor')):endif;endif;$incode=1;}?> I have no idea why it appears on each index file and how to remove these lines swiftly. This is the second time I faced with this problem (I reinstalled everything from scratch at first). How can I avoid this issue permanently?
0debug
HashMap, Initialization of ArrayList<Point> as values of the map fails : <p>I've got a class called Point which has a constructor Point that inits x,y.</p> <p>I've got a map of Point(key) and ArrayList(value), after initializing the map, my arrayLists are still null, why is that?</p> <pre><code>//Flip objects for the current player's choice Map&lt;Point, ArrayList&lt;Point&gt;&gt; flipMap = new HashMap&lt;Point, ArrayList&lt;Point&gt;&gt;(); //Init flipping map with keys for(int i = 0; i &lt; 8; i++) for(int j = 0; j &lt; 8; j++) flipMap.put(new Point(i,j), new ArrayList&lt;Point&gt;()); ArrayList&lt;Point&gt; test; for(int i = 0; i &lt; 8; i++){ for(int j = 0; j &lt; 8; j++){ if((test = flipMap.get(new Point(i,j))) == null); test = new ArrayList&lt;Point&gt;(); } } </code></pre> <p><strong>PROBLEM - This prints null:</strong></p> <pre><code>System.out.println(flipMap.get(new Point(0,0))); </code></pre>
0debug
how to create android app" save file in app but no access another app to my file" : my code my code my code my code my code my code v v my codev v my codev v my code my code v v my code my code my code my code my code my code v v my codev v my codev v my code my code v v my code my code my code my code my code my code v v my codev v my codev v my code my code v v my code my code my code my code my code my code v v my codev v my codev v my code my code v v my code my code my code my code my code my code v v my codev v my codev v my code my code v v my code my code my code my code my code my code v v my codev v my codev v my code my code v v InputStream input=null; OutputStream output=null; HttpURLConnection connection=null; try{ URL url=new URL(strings[0]); connection= (HttpURLConnection) url.openConnection(); connection.connect(); int filelen=connection.getContentLength(); input=connection.getInputStream(); filechache(); output=new FileOutputStream(android.os.Environment.getExternalStorageDirectory()+"/nikandroid/" +strings[1]+".mp3"); byte data[]=new byte[4096]; long total=0; int count; while((count=input.read(data))!=-1){ total+=count; if (filelen>0) publishProgress((int)(total*100/filelen)); output.write(data,0,count); } }catch (Exception e){ e.printStackTrace(); }finally { try{ if (output!=null) output.close(); if (input!=null) input.close(); }catch (IOException e){ e.printStackTrace(); } if (connection!=null) connection.disconnect(); } return null;
0debug
Camera Result always returns RESULT_CANCELED : <p>I want to take pictures with my camera. I just need them temporally so i do the following:</p> <pre><code>private void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(this.getActivity().getPackageManager()) != null) { try { this.imageFile = File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir()); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.imageFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); this.startActivityForResult(intent, Globals.REQUEST_TAKE_PHOTO); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>Unfortunately the result code <code>RESULT_CANCELED</code> in my <code>onActivityResult</code></p> <pre><code>@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v("PictureEdit", "onActivityResult"); super.onActivityResult(requestCode, resultCode, data); if(resultCode == Activity.RESULT_OK) { if(requestCode == Globals.REQUEST_TAKE_PHOTO) { Log.v("PictureEdit", "onActivityResult take photo"); this.startCropImage(Uri.fromFile(this.imageFile)); } else if (requestCode == Globals.REQUEST_PICK_PHOTO) { Log.v("PictureEdit", "onActivityResult pick photo"); this.startCropImage(data.getData()); } else if (requestCode == Globals.REQUEST_CROP_PHOTO) { Log.v("PictureEdit", "onActivityResult crop photo"); this.imageEncoded = data.getStringExtra(Globals.KEY_IMAGE_ENCODED); this.imageView.setImageBitmap(Images.decodeImage(imageEncoded)); this.buttonSave.setEnabled(true); } else { Log.v("PictureEdit", "onActivityResult requestCode: " + requestCode + ", result: " + resultCode); } } else { Log.v("PictureEdit", "onActivityResult resultCode is not ok: " + resultCode); } } </code></pre> <p>Every solutions i found so far on stackoverflow and in the web did not solve my problem. I use the cache directory for creating a temp file:</p> <pre><code>File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir()); </code></pre> <p>And i have the correct permissions:</p> <pre><code>&lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; </code></pre> <p>Picking images from my smartphone always works fine:</p> <pre><code>private void pickPicture() { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); this.startActivityForResult(intent, Globals.REQUEST_PICK_PHOTO); } </code></pre> <p>So why is the camera always returning <code>RESULT_CANCELED</code>? </p> <p>It is appearing on Nexus 4 with Android 6.0 and on Samsung Galaxy S III with Android 4.2.</p>
0debug
"if/else" condition misbehaving inside click event : <p>I am having trauble with if else condition inside a click event of jquery. I have set a variable. i want to show an alert with the message "business", when the variable- dropdown is "Business". Other wise the alert will show "Animales". But the following code doesnt check for the variable. It just triggering the first alert which is "animales" everytime. What I am doing wrong?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.item').click(function(){ var dropValue = "Buisness"; if (dropValue = "Animals"){ alert('animals'); }else if(dropValue = "Business"){ alert("business"); } });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;button class="item"&gt;Click me&lt;/button&gt;</code></pre> </div> </div> </p>
0debug
Difference between Apache parquet and arrow : <p>I'm looking into a way to speed up my memory intensive frontend vis app. I saw some people recommend Apache Arrow, while I'm looking into it, I'm confused about the difference between Parquet and Arrow.</p> <p>They are both columnized data structure. Originally I thought parquet is for disk, and arrow is for in-memory format. However, I just learned that you can save arrow into files at desk as well, like abc.arrow In that case, what's the difference? Aren't they doing the same thing?</p>
0debug
void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, int buf_size, int slice_count) { struct vdpau_render_state *render, *last, *next; int i; render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; assert(render); render->info.mpeg.picture_structure = s->picture_structure; render->info.mpeg.picture_coding_type = s->pict_type; render->info.mpeg.intra_dc_precision = s->intra_dc_precision; render->info.mpeg.frame_pred_frame_dct = s->frame_pred_frame_dct; render->info.mpeg.concealment_motion_vectors = s->concealment_motion_vectors; render->info.mpeg.intra_vlc_format = s->intra_vlc_format; render->info.mpeg.alternate_scan = s->alternate_scan; render->info.mpeg.q_scale_type = s->q_scale_type; render->info.mpeg.top_field_first = s->top_field_first; render->info.mpeg.full_pel_forward_vector = s->full_pel[0]; render->info.mpeg.full_pel_backward_vector = s->full_pel[1]; render->info.mpeg.f_code[0][0] = s->mpeg_f_code[0][0]; render->info.mpeg.f_code[0][1] = s->mpeg_f_code[0][1]; render->info.mpeg.f_code[1][0] = s->mpeg_f_code[1][0]; render->info.mpeg.f_code[1][1] = s->mpeg_f_code[1][1]; for (i = 0; i < 64; ++i) { render->info.mpeg.intra_quantizer_matrix[i] = s->intra_matrix[i]; render->info.mpeg.non_intra_quantizer_matrix[i] = s->inter_matrix[i]; } render->info.mpeg.forward_reference = VDP_INVALID_HANDLE; render->info.mpeg.backward_reference = VDP_INVALID_HANDLE; switch(s->pict_type){ case FF_B_TYPE: next = (struct vdpau_render_state *)s->next_picture.data[0]; assert(next); render->info.mpeg.backward_reference = next->surface; case FF_P_TYPE: last = (struct vdpau_render_state *)s->last_picture.data[0]; if (!last) last = render; render->info.mpeg.forward_reference = last->surface; } ff_vdpau_add_data_chunk(s, buf, buf_size); render->info.mpeg.slice_count = slice_count; if (slice_count) ff_draw_horiz_band(s, 0, s->avctx->height); render->bitstream_buffers_used = 0; }
1threat
static void adx_decode(short *out,const unsigned char *in,PREV *prev) { int scale = ((in[0]<<8)|(in[1])); int i; int s0,s1,s2,d; in+=2; s1 = prev->s1; s2 = prev->s2; for(i=0;i<16;i++) { d = in[i]; d = ((signed char)d >> 4); s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14; CLIP(s0); *out++=s0; s2 = s1; s1 = s0; d = in[i]; d = ((signed char)(d<<4) >> 4); s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14; CLIP(s0); *out++=s0; s2 = s1; s1 = s0; } prev->s1 = s1; prev->s2 = s2; }
1threat
How to draw Line Between two ImagViews in android : [This is acitvity_main.xml code[THis is MainActivity.java code[This is LineView.java code][1] [1]: https://i.stack.imgur.com/3uXzx.png
0debug
static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, void *arg) { VhostUserMsg msg; VhostUserRequest msg_request; struct vhost_vring_file *file = 0; int need_reply = 0; int fds[VHOST_MEMORY_MAX_NREGIONS]; int i, fd; size_t fd_num = 0; assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); msg_request = vhost_user_request_translate(request); msg.request = msg_request; msg.flags = VHOST_USER_VERSION; msg.size = 0; switch (request) { case VHOST_GET_FEATURES: need_reply = 1; break; case VHOST_SET_FEATURES: case VHOST_SET_LOG_BASE: msg.u64 = *((__u64 *) arg); msg.size = sizeof(m.u64); break; case VHOST_SET_OWNER: case VHOST_RESET_OWNER: break; case VHOST_SET_MEM_TABLE: for (i = 0; i < dev->mem->nregions; ++i) { struct vhost_memory_region *reg = dev->mem->regions + i; ram_addr_t ram_addr; qemu_ram_addr_from_host((void *)reg->userspace_addr, &ram_addr); fd = qemu_get_ram_fd(ram_addr); if (fd > 0) { msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr; msg.memory.regions[fd_num].memory_size = reg->memory_size; msg.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr; msg.memory.regions[fd_num].mmap_offset = reg->userspace_addr - (uintptr_t) qemu_get_ram_block_host_ptr(reg->guest_phys_addr); assert(fd_num < VHOST_MEMORY_MAX_NREGIONS); fds[fd_num++] = fd; } } msg.memory.nregions = fd_num; if (!fd_num) { error_report("Failed initializing vhost-user memory map\n" "consider using -object memory-backend-file share=on\n"); return -1; } msg.size = sizeof(m.memory.nregions); msg.size += sizeof(m.memory.padding); msg.size += fd_num * sizeof(VhostUserMemoryRegion); break; case VHOST_SET_LOG_FD: fds[fd_num++] = *((int *) arg); break; case VHOST_SET_VRING_NUM: case VHOST_SET_VRING_BASE: memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); msg.size = sizeof(m.state); break; case VHOST_GET_VRING_BASE: memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); msg.size = sizeof(m.state); need_reply = 1; break; case VHOST_SET_VRING_ADDR: memcpy(&msg.addr, arg, sizeof(struct vhost_vring_addr)); msg.size = sizeof(m.addr); break; case VHOST_SET_VRING_KICK: case VHOST_SET_VRING_CALL: case VHOST_SET_VRING_ERR: file = arg; msg.u64 = file->index & VHOST_USER_VRING_IDX_MASK; msg.size = sizeof(m.u64); if (ioeventfd_enabled() && file->fd > 0) { fds[fd_num++] = file->fd; } else { msg.u64 |= VHOST_USER_VRING_NOFD_MASK; } break; default: error_report("vhost-user trying to send unhandled ioctl\n"); return -1; break; } if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { return 0; } if (need_reply) { if (vhost_user_read(dev, &msg) < 0) { return 0; } if (msg_request != msg.request) { error_report("Received unexpected msg type." " Expected %d received %d\n", msg_request, msg.request); return -1; } switch (msg_request) { case VHOST_USER_GET_FEATURES: if (msg.size != sizeof(m.u64)) { error_report("Received bad msg size.\n"); return -1; } *((__u64 *) arg) = msg.u64; break; case VHOST_USER_GET_VRING_BASE: if (msg.size != sizeof(m.state)) { error_report("Received bad msg size.\n"); return -1; } memcpy(arg, &msg.state, sizeof(struct vhost_vring_state)); break; default: error_report("Received unexpected msg type.\n"); return -1; break; } } return 0; }
1threat
Do monad transformers, generally speaking, arise out of adjunctions? : <p>In <a href="https://stackoverflow.com/q/49322276/2751851"><em>Adjoint functors determine monad transformers, but where's lift?</em></a>, Simon C has shown us the construction...</p> <pre><code>newtype Three u f m a = Three { getThree :: u (m (f a)) } </code></pre> <p>... which, as the answers there discuss, can be given an <code>instance Adjunction f u =&gt; MonadTrans (Three u f)</code> (<em>adjunctions</em> provides it as <a href="http://hackage.haskell.org/package/adjunctions-4.4/docs/Control-Monad-Trans-Adjoint.html" rel="noreferrer"><code>AdjointT</code></a>). Any Hask/Hask adjunction thus leads to a monad transformer; in particular, <code>StateT s</code> arises in this manner from the currying adjunction between <code>(,) s</code> and <code>(-&gt;) s</code>.</p> <p>My follow-up question is: does this construction generalise to other monad transformers? Is there a way to derive, say, the other transformers from the <em>transformers</em> package from suitable adjunctions?</p> <hr> <p>Meta remarks: my answer here was originally written for Simon C's question. I opted to spin it off into a self-answered question because, upon rereading that question, I noticed my purported answer had more to do with the discussion in the comments over there than with the question body itself. Two other closely related questions, to which this Q&amp;A arguably is also a follow-up, are <a href="https://stackoverflow.com/q/24515876/2751851"><em>Is there a monad that doesn't have a corresponding monad transformer (except IO)?</em></a> and <a href="https://stackoverflow.com/q/42284879/2751851"><em>Is the composition of an arbitrary monad with a traversable always a monad?</em></a></p>
0debug
Aurelia: Webpack, JSPM or CLI? : <p>I've been developing in Aurelia-CLI for about 3 months and like it so far. I think it's a solid framework and obviously escalating in support and usage. That's a good thing!</p> <p>Before I develop much more of my large app, I'm wondering if I'm using the best build system. I've only tried Aurelia-CLI and am not really familiar with Webpack or JSPM, and therefore I don't know what I'm missing. Are there any clear advantages or disadvantages in using either of the other two build systems, or is using the CLI the most clean and supported approach? Since I'm developing independently, I don't have any external constraints.</p> <p>Thanks for your help.</p>
0debug
PHP finding a requesting url : I'm writing an API. I just want certain url addresses to access this API. How do I find the url addresses that try to use the API?. I want to know the url addresses that try to access the api server address with file_get_contents yada-like methods. Thanks :)
0debug
How to detect if browser is Internet Explorer or Microsoft Edge and if so, redirect it too another website? : <p>I am new to this so please go easy - I need to redirect a website because the video background I'm using won't play on Internet Explorer or Microsoft Edge. So I'm hoping to redirect it elsewhere. Could anyone with more knowledge than me write this in Javascript for me? I would be really appreciative.</p>
0debug
Convert Json from MVC controller to Array in Jquery : I have a controller in MVC, and return Json like below: public JsonResult getData() { var data = new[]{ new { x = 10, y = 20, name = "Jim", }, new { x = 11, y = 21, name = "Tom", } }; return Json(data, JsonRequestBehavior.AllowGet); } And I have ajax request like below: $.ajax({ type: "GET", url: "https://localhost:44361/home/getdata", dataType: "json", success: function (result) { return result; }, error: function (response) { return "faut"; } }); I want to convert the json result to below Array var arr = [ ['x','y','name'], [10,20,'Jim'], [11,21,'Tom'] ]; Any help would be appreciated.
0debug
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file) { char *filename_full = NULL; char *backing_file_full = NULL; char *filename_tmp = NULL; int is_protocol = 0; BlockDriverState *curr_bs = NULL; BlockDriverState *retval = NULL; if (!bs || !bs->drv || !backing_file) { return NULL; } filename_full = g_malloc(PATH_MAX); backing_file_full = g_malloc(PATH_MAX); filename_tmp = g_malloc(PATH_MAX); is_protocol = path_has_protocol(backing_file); for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) { if (is_protocol || path_has_protocol(curr_bs->backing_file)) { if (strcmp(backing_file, curr_bs->backing_file) == 0) { retval = curr_bs->backing_hd; break; } } else { path_combine(filename_tmp, PATH_MAX, curr_bs->filename, backing_file); if (!realpath(filename_tmp, filename_full)) { continue; } path_combine(filename_tmp, PATH_MAX, curr_bs->filename, curr_bs->backing_file); if (!realpath(filename_tmp, backing_file_full)) { continue; } if (strcmp(backing_file_full, filename_full) == 0) { retval = curr_bs->backing_hd; break; } } } g_free(filename_full); g_free(backing_file_full); g_free(filename_tmp); return retval; }
1threat
React Server side rendering of CSS modules : <p>The current practice for CSS with React components seems to be using webpack's style-loader to load it into the page in.</p> <pre class="lang-js prettyprint-override"><code>import React, { Component } from 'react'; import style from './style.css'; class MyComponent extends Component { render(){ return ( &lt;div className={style.demo}&gt;Hello world!&lt;/div&gt; ); } } </code></pre> <p>By doing this the style-loader will inject a <code>&lt;style&gt;</code> element into the DOM. However, the <code>&lt;style&gt;</code> will not be in the virtual DOM and so if doing server side rendering, the <code>&lt;style&gt;</code> will be omitted. This cause the page to have <a href="https://en.wikipedia.org/wiki/Flash_of_unstyled_content" rel="noreferrer">FOUC</a>.</p> <p>Is there any other methods to load <a href="https://github.com/css-modules/css-modules" rel="noreferrer">CSS modules</a> that work on both server and client side?</p>
0debug
"This method must return a result of type ModelAndView." but i alreaady returning..can i know wht i have error : In the LoginView method it shows a error that thier must be a return.but i already have one how i fix this @RequestMapping("/login") public loginView( HttpServletRequest request, HttpServletResponse res) { String name = request.getParameter("username"); String password = request.getParameter("password"); if(password.equals("admin")) { return new ModelAndView("hipage","",""); } } }
0debug
static int coroutine_fn qcow2_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVQcowState *s = bs->opaque; uint64_t cluster_offset; int ret; *pnum = nb_sectors; qemu_co_mutex_lock(&s->lock); ret = qcow2_get_cluster_offset(bs, sector_num << 9, pnum, &cluster_offset); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { *pnum = 0; } return (cluster_offset != 0) || (ret == QCOW2_CLUSTER_ZERO); }
1threat
static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, int width) { #ifdef HAVE_MMX asm volatile( "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((long)-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int i; for(i=0; i<width; i++) dst[i]= src[2*i+1]; #endif }
1threat
C++ SSE Intrinsics: Storing results in variables : <p>I have trouble understanding the usage of SSE intrinsics to store results of some SIMD calculation back into "normal variables". For example the _mm_store_ps intrinsic is described in the "Intel Intrinsics Guide" as follows:</p> <blockquote> <p>void _mm_store_ps (float* mem_addr, __m128 a)</p> <p>Store 128-bits (composed of 4 packed single-precision (32-bit) floating-point elements) from a into memory. mem_addr must be aligned on a 16-byte boundary or a general-protection exception may be generated.</p> </blockquote> <p>The first argument is a pointer to a float which has a size of 32bits. But the description states, that the intrinsic will copy 128 bits from a into the target mem_addr.</p> <ul> <li>Does mem_addr need to be an array of 4 floats?</li> <li>How can I access only a specific 32bit element in a and store it in a single float?</li> <li>What am I missing conceptually?</li> <li>Are there better options then the _mm_store_ps intrinsic?</li> </ul> <p>Here is a simple struct where doSomething() adds 1 to x/y of the struct. Whats missing is the part on how to store the result back into x/y while only the higher 32bit wide elements 2 &amp; 3 are used, while 1 &amp; 0 are unused. </p> <pre><code>struct vec2 { union { struct { float data[2]; }; struct { float x, y; }; }; void doSomething() { __m128 v1 = _mm_setr_ps(x, y, 0, 0); __m128 v2 = _mm_setr_ps(1, 1, 0, 0); __m128 result = _mm_add_ps(v1, v2); // ?? How to store results in x,y ?? } } </code></pre>
0debug
static void sdl_grab_start(void) { if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) { return; } if (guest_cursor) { SDL_SetCursor(guest_sprite); if (!kbd_mouse_is_absolute() && !absolute_enabled) SDL_WarpMouse(guest_x, guest_y); } else sdl_hide_cursor(); if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) { gui_grab = 1; sdl_update_caption(); } else sdl_show_cursor(); }
1threat
static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf) { DNXHDEncContext *ctx = avctx->priv_data; const uint8_t header_prefix[5] = { 0x00,0x00,0x02,0x80,0x01 }; memcpy(buf, header_prefix, 5); buf[5] = ctx->interlaced ? ctx->cur_field+2 : 0x01; buf[6] = 0x80; buf[7] = 0xa0; AV_WB16(buf + 0x18, avctx->height); AV_WB16(buf + 0x1a, avctx->width); AV_WB16(buf + 0x1d, avctx->height); buf[0x21] = 0x38; buf[0x22] = 0x88 + (ctx->frame.interlaced_frame<<2); AV_WB32(buf + 0x28, ctx->cid); buf[0x2c] = ctx->interlaced ? 0 : 0x80; buf[0x5f] = 0x01; buf[0x167] = 0x02; AV_WB16(buf + 0x16a, ctx->m.mb_height * 4 + 4); buf[0x16d] = ctx->m.mb_height; buf[0x16f] = 0x10; ctx->msip = buf + 0x170; return 0; }
1threat
How to develop Shopify themes locally? : <p>I'm going to work on a Shopify theme, and I want to figure out how to run/edit it locally. I'd like to be able to the following, if possible:</p> <ol> <li>Pull all the Shopify theme code from the site to my local computer (ideally a single command line tool)</li> <li>Make edits locally, and run them locally or in a staging environment</li> <li>Push all the edits to the main Shopify site, again using a command line tool</li> </ol> <p>Is this at all possible?</p>
0debug
S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp) { static bool features_parsed; char *name, *features; const char *typename; ObjectClass *oc; CPUClass *cc; name = g_strdup(cpu_model); features = strchr(name, ','); if (features) { features[0] = 0; features++; } oc = cpu_class_by_name(TYPE_S390_CPU, name); if (!oc) { error_setg(errp, "Unknown CPU definition \'%s\'", name); g_free(name); return NULL; } typename = object_class_get_name(oc); if (!features_parsed) { features_parsed = true; cc = CPU_CLASS(oc); cc->parse_features(typename, features, errp); } g_free(name); if (*errp) { return NULL; } return S390_CPU(CPU(object_new(typename))); }
1threat
Rounded Corners Image in Flutter : <p>I am using Flutter to make a list of information about movies. Now I want the cover image on the left to be a rounded corners picture. I did the following, but it didn’t work. Thanks!</p> <pre><code> getItem(var subject) { var row = Container( margin: EdgeInsets.all(8.0), child: Row( children: &lt;Widget&gt;[ Container( width: 100.0, height: 150.0, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(8.0)), color: Colors.redAccent, ), child: Image.network( subject['images']['large'], height: 150.0, width: 100.0, ), ), ], ), ); return Card( color: Colors.blueGrey, child: row, ); } </code></pre> <p>as follows</p> <p><a href="https://i.stack.imgur.com/KTdOv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KTdOv.png" alt="enter image description here"></a></p>
0debug
static int request_frame(AVFilterLink *outlink) { AVFilterBufferRef *outpicref; MovieContext *movie = outlink->src->priv; int ret; if (movie->is_done) return AVERROR_EOF; if ((ret = movie_get_frame(outlink)) < 0) return ret; outpicref = avfilter_ref_buffer(movie->picref, ~0); avfilter_start_frame(outlink, outpicref); avfilter_draw_slice(outlink, 0, outlink->h, 1); avfilter_end_frame(outlink); return 0; }
1threat
C++ reading unknown number of lines and storing values in an array : <p>Firstly I don't really know C++ well at all. Basically I have a file that looks like</p> <pre><code>junk junk ... junk 3 4 5 1 -9 7 4 -7 8 6 3 1 .... junk junk 7 5 2 -1 .... -1 7 4 1 etc. </code></pre> <p>I want to analyze each block of numbers separately. I.e. here I have two blocks of numbers and want to perform the same analysis on them separately.</p> <p>I know how I would implement this in Python, I just don't know how it looks in C++.</p> <pre><code>file = open('data.text') w = [] x = [] y = [] z = [] for line in file: line = line.strip() data = line.split() w.append(data[0]) x.append(data[1]) y.append(data[2]) z.append(data[3]) file.close() </code></pre> <p>I also want to perform an analysis on the block of numbers, comparing all possibilities of two lines at once. In Python it would look something like (I guess -- haven't tried):</p> <pre><code>r = [] s = [] t = [] for i in range(len(w)): for j in range(len(w) - 1): r.append(w[i]*x[j] - w[j]*x[i]) s.append(x[j]*y[i] - y[j]*x[i]) for i in range(len(w): for j in range(len(s)): t.append(s[j]*w[i] + r[j]*x[i]) best = min(t) </code></pre> <p>Here are a couple of the issues I've had in trying this with C++: I do not know the number of rows for the data (call it n), although I do know the number of blocks of numbers I want to analyze (call it N -- in my example N = 2). And plenty of segmentation faults. I think I can store the data, but I can't seem to call it. I create a class Data data and work from there.</p> <pre><code>double get_data = 0; for (std::string line; (std::getline(file,line));) { std::istringstream row(line); Data data; row &gt;&gt; data.w &gt;&gt; data.x &gt;&gt; data.y &gt;&gt; data.z; std::vector&lt;double&gt; wcol; std::vector&lt;double&gt; xcol; std::vector&lt;double&gt; ycol; std::vector&lt;double&gt; zcol; get_data++; for (int j = 0; j &lt; get_data - 1; j++) { if(data.w &gt; 0) { wcol.push_back(data.w); xcol.push_back(data.x); ycol.push_back(data.y); zcol.push_back(data.z); } get_data = 0; } </code></pre> <p>But again I don't really know what I'm doing with C++.</p> <hr> <p>Maybe this should be a separate question, but I'd also like to break out of the analysis and then restart it for the next block of numbers. </p>
0debug
Sort collection by custom order in Eloquent : <p>I have an array of ID's as follows:</p> <pre><code>$ids = [5,6,0,1] </code></pre> <p>Using Eloquent I am able to search for these Id's using the <code>-&gt;whereIn('id', $ids)</code> function. This as expected will return the results in the ascending order by Id, is there a way I can return the results on the order the array is in? alternatively whats the easiest way to convert the collection in the order of the <code>$ids</code> array?</p>
0debug
static int fourxm_read_header(AVFormatContext *s, AVFormatParameters *ap) { ByteIOContext *pb = s->pb; unsigned int fourcc_tag; unsigned int size; int header_size; FourxmDemuxContext *fourxm = s->priv_data; unsigned char *header; int i; int current_track = -1; AVStream *st; fourxm->track_count = 0; fourxm->tracks = NULL; fourxm->selected_track = 0; fourxm->fps = 1.0; url_fseek(pb, 12, SEEK_CUR); GET_LIST_HEADER(); header_size = size - 4; if (fourcc_tag != HEAD_TAG || size < 4) return AVERROR_INVALIDDATA; header = av_malloc(header_size); if (!header) return AVERROR(ENOMEM); if (get_buffer(pb, header, header_size) != header_size) return AVERROR(EIO); for (i = 0; i < header_size - 8; i++) { fourcc_tag = AV_RL32(&header[i]); size = AV_RL32(&header[i + 4]); if (fourcc_tag == std__TAG) { fourxm->fps = av_int2flt(AV_RL32(&header[i + 12])); } else if (fourcc_tag == vtrk_TAG) { if (size != vtrk_SIZE) { av_free(header); return AVERROR_INVALIDDATA; } fourxm->width = AV_RL32(&header[i + 36]); fourxm->height = AV_RL32(&header[i + 40]); st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 60, 1, fourxm->fps); fourxm->video_stream_index = st->index; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_4XM; st->codec->extradata_size = 4; st->codec->extradata = av_malloc(4); AV_WL32(st->codec->extradata, AV_RL32(&header[i + 16])); st->codec->width = fourxm->width; st->codec->height = fourxm->height; i += 8 + size; } else if (fourcc_tag == strk_TAG) { if (size != strk_SIZE) { av_free(header); return AVERROR_INVALIDDATA; } current_track = AV_RL32(&header[i + 8]); if (current_track + 1 > fourxm->track_count) { fourxm->track_count = current_track + 1; if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack)) return -1; fourxm->tracks = av_realloc(fourxm->tracks, fourxm->track_count * sizeof(AudioTrack)); if (!fourxm->tracks) { av_free(header); return AVERROR(ENOMEM); } } fourxm->tracks[current_track].adpcm = AV_RL32(&header[i + 12]); fourxm->tracks[current_track].channels = AV_RL32(&header[i + 36]); fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]); fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]); i += 8 + size; st = av_new_stream(s, current_track); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); fourxm->tracks[current_track].stream_index = st->index; st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_tag = 0; st->codec->channels = fourxm->tracks[current_track].channels; st->codec->sample_rate = fourxm->tracks[current_track].sample_rate; st->codec->bits_per_coded_sample = fourxm->tracks[current_track].bits; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; if (fourxm->tracks[current_track].adpcm) st->codec->codec_id = CODEC_ID_ADPCM_4XM; else if (st->codec->bits_per_coded_sample == 8) st->codec->codec_id = CODEC_ID_PCM_U8; else st->codec->codec_id = CODEC_ID_PCM_S16LE; } } av_free(header); GET_LIST_HEADER(); if (fourcc_tag != MOVI_TAG) return AVERROR_INVALIDDATA; fourxm->video_pts = -1; fourxm->audio_pts = 0; return 0; }
1threat
Why is the max() function returning an item that is smaller than another one in a list? : <p>Here's the code in question:</p> <pre><code>my_list = ['apples', 'oranges', 'cherries', 'banana'] print(max(my_list) </code></pre> <p>Why does it print 'oranges' instead of 'cherries'?</p>
0debug
ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) { DeviceState *dev; ISADevice *isadev; RTCState *s; isadev = isa_create(bus, TYPE_MC146818_RTC); dev = DEVICE(isadev); s = MC146818_RTC(isadev); qdev_prop_set_int32(dev, "base_year", base_year); qdev_init_nofail(dev); if (intercept_irq) { s->irq = intercept_irq; } else { isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ); } QLIST_INSERT_HEAD(&rtc_devices, s, link); return isadev; }
1threat
How to remove dash between spaces using regex? : <p><strong>Input:</strong> tomato – 500-600 g</p> <p><strong>Output:</strong> tomato 500-600 g</p>
0debug
How to make a counter start at 1 and go to three after a button is clicked in javascript? : <p>I'm trying to make a counter that starts at 1 and after you click a button it will display an alert and then the counter will go to 2 and wait until you click the button again and then give you a different alert and so on.</p> <pre><code>I have tried something along the lines of //html &lt;input id="button" type="submit" name="button" value="enter"/&gt; //javascript function count() { var counter = 1; if(counter = 1 &amp;&amp; button.click) { alert("something"(counter++)); } if(counter = 2 &amp;&amp; button.click) { alert("something else"(counter++)); } if(counter = 3 &amp;&amp; button.click) { alert("something else else"); } } </code></pre> <p>I know that the syntax isn't correct but that's the main idea. The expected output should be a new alert after each button click.</p>
0debug
void DMA_schedule(int nchan) {}
1threat
First-child full-width in Flexbox : <p>How can I can set first-child in flexbox full-width and all of the other child set to <code>flex:1</code>(for split space)?</p> <p>Like this:</p> <p><a href="https://i.stack.imgur.com/bjGWl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bjGWl.png" alt="enter image description here"></a></p>
0debug
hi how can i draw arc like this in image below? : I won't make some of this arcs on my website and I don know how to do it I tried to do it but I can't [1]: https://i.stack.imgur.com/6UHCs.png
0debug
i have to split multiple array based on previous value in greater than present value using ruby? : I need a ruby method for this below details:- arr = [3,4,5,6,3,4,5,2,3] In this part i have to split multiple array based on previous value in greater than present value it should split another array in example [[3,4,5,6].[3,4,5],[2,3]]
0debug
How convert LocalDateTime to Date in Java 8 : <p>I'm using timezone Brazil by default, but when caught one LocalDateTime of New York and convert to <strong>java.tim.Instant</strong> the <strong>instant</strong> is filled correctly. The problem is when I try to generate a <strong>Date</strong> with <strong>Date.from (instantValue)</strong>, instead of being generated a <strong>date</strong> of New York, I end up getting the current date from Brazil.</p> <pre><code>ZoneId nyZone = ZoneId.of("America/New_York"); ZoneId brazilZone = ZoneId.of("America/Recife"); LocalDateTime ldtBrazil = LocalDateTime.now(brazilZone); LocalDateTime ldtNY = LocalDateTime.now(nyZone); Instant instantBrazil = ldtBrazil.toInstant(ZoneOffset.UTC); Instant instantNY = ldtNY.toInstant(ZoneOffset.UTC); System.out.println("-------LocalDateTime-------"); System.out.println("ldtBrazil : "+ldtBrazil); System.out.println("ldtNY : "+ldtNY); System.out.println("\n-------Instant-------"); System.out.println("instantBrazil: "+instantBrazil); System.out.println("instantNY : "+instantNY); long milliBrazil = instantBrazil.toEpochMilli(); long milliNY = instantNY.toEpochMilli(); System.out.println("\n----------Milli----------"); System.out.println("miliBrazil : "+milliBrazil); System.out.println("miliNY : "+milliNY); Date dateBrazil = Date.from(instantBrazil); Date dateNY = Date.from(instantNY); System.out.println("\n---------Date From Instant---------"); System.out.println("dateBrazil: "+dateBrazil); System.out.println("dateNY : "+dateNY); System.out.println("\n---------Date From Milli---------"); System.out.println("dateBrazil: "+new Date(milliBrazil)); System.out.println("dateNY : "+new Date(milliNY)); </code></pre> <p><strong>Result</strong></p> <pre><code>-------LocalDateTime------- ldtBrazil : 2016-09-21T22:11:52.118 ldtNY : 2016-09-21T21:11:52.118 -------Instant------- instantBrazil: 2016-09-21T22:11:52.118Z instantNY : 2016-09-21T21:11:52.118Z ----------Milli---------- miliBrazil : 1474495912118 miliNY : 1474492312118 ---------Date From Instant--------- dateBrazil: Wed Sep 21 19:11:52 BRT 2016 dateNY : Wed Sep 21 18:11:52 BRT 2016 //this data must be related to NY LocalDateTime, but reiceved a same date of Brazil. ---------Date From Milli--------- dateBrazil: Wed Sep 21 19:11:52 BRT 2016 dateNY : Wed Sep 21 18:11:52 BRT 2016 </code></pre>
0debug
How to stop kubectl proxy : <p>I executed below command:</p> <pre><code>kubectl proxy --port=8081 &amp; kubectl proxy --port=8082 &amp; </code></pre> <p>and of course I have 2 accessible endpoints:</p> <pre><code>curl http://localhost:8081/api/ curl http://localhost:8082/api/ </code></pre> <p>But in the same time two running processes serving the same content. How to stop one of these processes in "kubectl" manner? Of course, I can kill the process but it seems to be a less elegant way...</p>
0debug
static int wavpack_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { WavpackContext *s = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int frame_size; int samplecount = 0; s->block = 0; s->samples_left = 0; s->ch_offset = 0; if(s->mkv_mode){ s->samples = AV_RL32(buf); buf += 4; } while(buf_size > 0){ if(!s->multichannel){ frame_size = buf_size; }else{ if(!s->mkv_mode){ frame_size = AV_RL32(buf) - 12; buf += 4; buf_size -= 4; }else{ if(buf_size < 12) break; frame_size = AV_RL32(buf + 8) + 12; } } if(frame_size < 0 || frame_size > buf_size){ av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n", s->block, frame_size, buf_size); return -1; } if((samplecount = wavpack_decode_block(avctx, s->block, data, data_size, buf, frame_size)) < 0) return -1; s->block++; buf += frame_size; buf_size -= frame_size; } *data_size = samplecount * avctx->channels; return s->samples_left > 0 ? 0 : avpkt->size; }
1threat
why declaration can not be used together with isolatedModules in typescript? : <p><strong>declaration</strong> is used to generate type file, and <strong>isolatedModules</strong> mean all file should be a separate module. Why do these two options use together?</p> <pre><code>error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. </code></pre>
0debug
Regex to match given amount of characters in undefined order : <p>I am looking for a regex that matches the following: 2 times the character 'a' and 3 times the character 'b'. Additionally, the characters do not have to be subsequent, meaning that not only 'aabbb' and 'bbaaa' should be allowed, but also 'ababb', 'abbab' and so forth.</p> <p>By the sound of it this should be an easy task, but atm I just can't wrap my head around it. Redirection to a good read is appreciated.</p>
0debug
I want Merge some js codes : please any one can help me to merge these js codes in one working java script code https://raw.githubusercontent.com/scIslam/js/master/11 I think it has the same properties and merge is not impossible but I do not know very well for Java scripts .. & ty for help me
0debug
scrolling to elements on mobile or tablet is making it scroll too much : <p>I'm making a project for school and the scrolling plugin I used is working great for my screen size but it is scrolling below the title names on tablet or mobile screen sizes. I'm unsure why this is happening, anyone have any ideas? <a href="http://www.sleeksurvey.com" rel="nofollow noreferrer">http://www.sleeksurvey.com</a></p>
0debug
static void init_custom_qm(VC2EncContext *s) { int level, orientation; if (s->quant_matrix == VC2_QM_DEF) { for (level = 0; level < s->wavelet_depth; level++) { for (orientation = 0; orientation < 4; orientation++) { if (level <= 3) s->quant[level][orientation] = ff_dirac_default_qmat[s->wavelet_idx][level][orientation]; else s->quant[level][orientation] = vc2_qm_col_tab[level][orientation]; } } } else if (s->quant_matrix == VC2_QM_COL) { for (level = 0; level < s->wavelet_depth; level++) { for (orientation = 0; orientation < 4; orientation++) { s->quant[level][orientation] = vc2_qm_col_tab[level][orientation]; } } } else { for (level = 0; level < s->wavelet_depth; level++) { for (orientation = 0; orientation < 4; orientation++) { s->quant[level][orientation] = vc2_qm_flat_tab[level][orientation]; } } } }
1threat
MySql - Count by Month with 2 differents dates in the table : I'm working on a project in order to count the number of incidents opened and closed per months. I've a sql DB and which the records are. I'm trying to write a SQL request to count the number of incidents Opened and Closed each month. Here is an exemple of the table I've: [enter image description here][1] And the result I want. [enter image description here][2] [1]: https://i.stack.imgur.com/IRsvG.png [2]: https://i.stack.imgur.com/444H9.png Thanks in advance for your support :) Regards, Eric.
0debug
static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw1) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; int op; int shiftop; int conds; int logic_cc; if (!(arm_dc_feature(s, ARM_FEATURE_THUMB2) || arm_dc_feature(s, ARM_FEATURE_M))) { insn = insn_hw1; if ((insn & (1 << 12)) == 0) { ARCH(5); offset = ((insn & 0x7ff) << 1); tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if (insn & (1 << 11)) { offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if ((s->pc & ~TARGET_PAGE_MASK) == 0) { offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); return 0; } } insn = arm_lduw_code(env, s->pc, s->bswap_code); s->pc += 2; insn |= (uint32_t)insn_hw1 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: abort(); case 4: if (insn & (1 << 22)) { if (insn & 0x01200000) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { addr = load_reg(s, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); store_reg(s, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); store_reg(s, rd, tmp); } else { tmp = load_reg(s, rs); gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd); gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); } if (insn & (1 << 21)) { if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, 15, addr, 2); } else { gen_store_exclusive(s, rd, rs, 15, addr, 2); } tcg_temp_free_i32(addr); } else if ((insn & (7 << 5)) == 0) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc); } else { addr = load_reg(s, rn); } tmp = load_reg(s, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); gen_aa32_ld16u(tmp, addr, get_mem_index(s)); } else { tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); gen_aa32_ld8u(tmp, addr, get_mem_index(s)); } tcg_temp_free_i32(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, s->pc); store_reg(s, 15, tmp); } else { int op2 = (insn >> 6) & 0x3; op = (insn >> 4) & 0x3; switch (op2) { case 0: goto illegal_op; case 1: if (op == 2) { goto illegal_op; } ARCH(7); break; case 2: if (op == 3) { goto illegal_op; } case 3: ARCH(8); break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (!(op2 & 1)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: gen_aa32_ld8u(tmp, addr, get_mem_index(s)); break; case 1: gen_aa32_ld16u(tmp, addr, get_mem_index(s)); break; case 2: gen_aa32_ld32u(tmp, addr, get_mem_index(s)); break; default: abort(); } store_reg(s, rs, tmp); } else { tmp = load_reg(s, rs); switch (op) { case 0: gen_aa32_st8(tmp, addr, get_mem_index(s)); break; case 1: gen_aa32_st16(tmp, addr, get_mem_index(s)); break; case 2: gen_aa32_st32(tmp, addr, get_mem_index(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { gen_load_exclusive(s, rs, rd, addr, op); } else { gen_store_exclusive(s, rm, rs, rd, addr, op); } tcg_temp_free_i32(addr); } } else { if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_M)) { goto illegal_op; } if (insn & (1 << 20)) { addr = load_reg(s, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); gen_aa32_ld32u(tmp2, addr, get_mem_index(s)); if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); } else { gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2, insn & (1 << 21)); } } else { int i, loaded_base = 0; TCGv_i32 loaded_var; addr = load_reg(s, rn); offset = 0; for (i = 0; i < 16; i++) { if (insn & (1 << i)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } TCGV_UNUSED_I32(loaded_var); for (i = 0; i < 16; i++) { if ((insn & (1 << i)) == 0) continue; if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, get_mem_index(s)); if (i == 15) { gen_bx(s, tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg(s, i, tmp); } } else { tmp = load_reg(s, i); gen_aa32_st32(tmp, addr, get_mem_index(s)); tcg_temp_free_i32(tmp); } tcg_gen_addi_i32(addr, addr, 4); } if (loaded_base) { store_reg(s, rn, loaded_var); } if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } if (insn & (1 << rn)) goto illegal_op; store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; case 5: op = (insn >> 21) & 0xf; if (op == 6) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else { if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } tmp2 = load_reg(s, rm); shiftop = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); conds = (insn & (1 << 20)) != 0; logic_cc = (conds && thumb2_logic_op(op)); gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } break; case 13: op = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (op < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (op) { case 0: tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((insn & 0x70) != 0) goto illegal_op; op = (insn >> 21) & 3; logic_cc = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, op, tmp2, logic_cc); if (logic_cc) gen_logic_CC(tmp); store_reg_bx(s, rd, tmp); break; case 1: op = (insn >> 20) & 7; switch (op) { case 0: case 1: case 4: case 5: break; case 2: case 3: if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } break; default: goto illegal_op; } if (rn != 15) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } } tmp = load_reg(s, rm); shift = (insn >> 4) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: g_assert_not_reached(); } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); break; case 2: if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } op = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((op & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); gen_thumb2_parallel_addsub(op, shift, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 3: op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (op < 4) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op & 1) gen_helper_double_saturate(tmp, cpu_env, tmp); if (op & 2) gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } else { switch (op) { case 0x0a: case 0x08: case 0x09: case 0x0b: case 0x18: break; case 0x10: if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } break; case 0x20: case 0x21: case 0x22: case 0x28: case 0x29: case 0x2a: if (!arm_dc_feature(s, ARM_FEATURE_CRC)) { goto illegal_op; } break; default: goto illegal_op; } tmp = load_reg(s, rn); switch (op) { case 0x0a: gen_helper_rbit(tmp, tmp); break; case 0x08: tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: gen_rev16(tmp); break; case 0x0b: gen_revsh(tmp); break; case 0x10: tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; case 0x18: gen_helper_clz(tmp, tmp); break; case 0x20: case 0x21: case 0x22: case 0x28: case 0x29: case 0x2a: { uint32_t sz = op & 0x3; uint32_t c = op & 0x8; tmp2 = load_reg(s, rm); if (sz == 0) { tcg_gen_andi_i32(tmp2, tmp2, 0xff); } else if (sz == 1) { tcg_gen_andi_i32(tmp2, tmp2, 0xffff); } tmp3 = tcg_const_i32(1 << sz); if (c) { gen_helper_crc32c(tmp, tmp, tmp2, tmp3); } else { gen_helper_crc32(tmp, tmp, tmp2, tmp3); } tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp3); break; } default: g_assert_not_reached(); } } store_reg(s, rd, tmp); break; case 4: case 5: switch ((insn >> 20) & 7) { case 0: case 7: break; case 1: case 2: case 3: case 4: case 5: case 6: if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } break; } op = (insn >> 4) & 0xf; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); switch ((insn >> 20) & 7) { case 0: tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); if (op) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 1: gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 2: case 4: if (op) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 3: if (op) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 5: case 6: tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(s, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; } store_reg(s, rd, tmp); break; case 6: case 7: op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DIV)) { goto illegal_op; } if (op & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((op & 0xe) == 0xc) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { tcg_temp_free_i32(tmp); tcg_temp_free_i32(tmp2); goto illegal_op; } if (op & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (op & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rs, rd); gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op & 0x20) { tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (op & 8) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp); goto illegal_op; } gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); } else { tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (op & 4) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { tcg_temp_free_i64(tmp64); goto illegal_op; } gen_addq_lo(s, tmp64, rs); gen_addq_lo(s, tmp64, rd); } else if (op & 0x40) { gen_addq(s, tmp64, rs, rd); } gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: if (((insn >> 24) & 3) == 3) { insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(s, insn)) { goto illegal_op; } } else if (((insn >> 8) & 0xe) == 10) { if (disas_vfp_insn(s, insn)) { goto illegal_op; } } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn(s, insn)) { goto illegal_op; } } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { if (insn & 0x5000) { offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; offset |= (insn & 0x7ff) << 1; offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { tcg_gen_movi_i32(cpu_R[14], s->pc | 1); } offset += s->pc; if (insn & (1 << 12)) { gen_jmp(s, offset); } else { offset &= ~(uint32_t)2; gen_bx_im(s, offset); } } else if (((insn >> 23) & 7) == 7) { if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { if (!(insn & (1 << 20))) { int imm16 = extract32(insn, 16, 4) << 12 | extract32(insn, 0, 12); ARCH(7); if (IS_USER(s)) { goto illegal_op; } gen_hvc(s, imm16); } else { ARCH(6K); if (IS_USER(s)) { goto illegal_op; } gen_smc(s); } } else { op = (insn >> 20) & 7; switch (op) { case 0: if (arm_dc_feature(s, ARM_FEATURE_M)) { tmp = load_reg(s, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp); gen_lookup_tb(s); break; } case 1: if (arm_dc_feature(s, ARM_FEATURE_M)) { goto illegal_op; } tmp = load_reg(s, rn); if (gen_set_psr(s, msr_mask(s, (insn >> 8) & 0xf, op == 1), op == 1, tmp)) goto illegal_op; break; case 2: if (((insn >> 8) & 7) == 0) { gen_nop_hint(s, insn & 0xff); } if (IS_USER(s)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(s, offset, 0, imm); } break; case 3: ARCH(7); op = (insn >> 4) & 0xf; switch (op) { case 2: gen_clrex(s); break; case 4: case 5: case 6: break; default: goto illegal_op; } break; case 4: tmp = load_reg(s, rn); gen_bx(s, tmp); break; case 5: if (IS_USER(s)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(s, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(s, tmp); break; case 6: tmp = tcg_temp_new_i32(); if (arm_dc_feature(s, ARM_FEATURE_M)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); break; case 7: if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_M)) { goto illegal_op; } tmp = load_cpu_field(spsr); store_reg(s, rd, tmp); break; } } } else { op = (insn >> 22) & 0xf; s->condlabel = gen_new_label(); arm_gen_test_cc(op ^ 1, s->condlabel); s->condjmp = 1; offset = (insn & 0x7ff) << 1; offset |= (insn & 0x003f0000) >> 4; offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; offset |= (insn & (1 << 13)) << 5; offset |= (insn & (1 << 11)) << 8; gen_jmp(s, s->pc + offset); } } else { if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; op = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } switch (op) { case 2: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm); tcg_temp_free_i32(tmp2); } break; case 7: goto illegal_op; default: if (shift) { if (op & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { if ((op & 1) && shift == 0) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { tcg_temp_free_i32(tmp); tcg_temp_free_i32(tmp2); goto illegal_op; } gen_helper_usat16(tmp, cpu_env, tmp, tmp2); } else { gen_helper_usat(tmp, cpu_env, tmp, tmp2); } } else { if ((op & 1) && shift == 0) { if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { tcg_temp_free_i32(tmp); tcg_temp_free_i32(tmp2); goto illegal_op; } gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); } else { gen_helper_ssat(tmp, cpu_env, tmp, tmp2); } } tcg_temp_free_i32(tmp2); break; } store_reg(s, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, imm); } } else { if (rn == 15) { offset = s->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(s, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(s, rd, tmp); } } else { int shifter_out = 0; shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: break; case 1: imm |= imm << 16; break; case 2: imm |= imm << 16; imm <<= 8; break; case 3: imm |= imm << 16; imm |= imm << 8; break; default: shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); shifter_out = 1; break; } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } op = (insn >> 21) & 0xf; if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0, shifter_out, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } } break; case 12: { int postinc = 0; int writeback = 0; int memidx; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(s, insn)) { goto illegal_op; } break; } op = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (rs == 15) { if (!(insn & (1 << 20))) { goto illegal_op; } if (op != 2) { int op1 = (insn >> 23) & 3; int op2 = (insn >> 6) & 0x3f; if (op & 2) { goto illegal_op; } if (rn == 15) { return 0; } if (op1 & 1) { return 0; } if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) { return 0; } return 1; } } memidx = get_mem_index(s); if (rn == 15) { addr = tcg_temp_new_i32(); imm = s->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(s, rn); if (insn & (1 << 23)) { imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { imm = insn & 0xff; switch ((insn >> 8) & 0xf) { case 0x0: shift = (insn >> 4) & 0xf; if (shift > 3) { tcg_temp_free_i32(addr); goto illegal_op; } tmp = load_reg(s, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; case 0xc: tcg_gen_addi_i32(addr, addr, -imm); break; case 0xe: tcg_gen_addi_i32(addr, addr, imm); memidx = get_a32_user_mem_index(s); break; case 0x9: imm = -imm; case 0xb: postinc = 1; writeback = 1; break; case 0xd: imm = -imm; case 0xf: tcg_gen_addi_i32(addr, addr, imm); writeback = 1; break; default: tcg_temp_free_i32(addr); goto illegal_op; } } } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: gen_aa32_ld8u(tmp, addr, memidx); break; case 4: gen_aa32_ld8s(tmp, addr, memidx); break; case 1: gen_aa32_ld16u(tmp, addr, memidx); break; case 5: gen_aa32_ld16s(tmp, addr, memidx); break; case 2: gen_aa32_ld32u(tmp, addr, memidx); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } if (rs == 15) { gen_bx(s, tmp); } else { store_reg(s, rs, tmp); } } else { tmp = load_reg(s, rs); switch (op) { case 0: gen_aa32_st8(tmp, addr, memidx); break; case 1: gen_aa32_st16(tmp, addr, memidx); break; case 2: gen_aa32_st32(tmp, addr, memidx); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } tcg_temp_free_i32(tmp); } if (postinc) tcg_gen_addi_i32(addr, addr, imm); if (writeback) { store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
1threat
Is there any way to create a class instance name by a string taken as user input? : <p>In C++, I want to create a class instance which name will be a string taken as input.</p> <p>Consider the following code segment.</p> <pre><code>class my_class{ int a; }; int main() { string name; getline(cin, name); //let the input "tom" my_class name; // expecting an instance of my_class named as tom } </code></pre> <p>As it should, I am getting error. Is there any way to do it.</p>
0debug
Multiple Queries/Mutation in Apollo 2.1 : <p>I need some help using the new Query and Mutation component in Apollo 2.1, especially with multiple queries and mutations.</p> <p>I have the following problems:</p> <ol> <li>I have a graphql request that depends on a previous graphql result, how can I deal with this?</li> <li>How do I add two different mutations (in my component I need to do two different actions) in a component that already has a query?</li> </ol>
0debug
static void replay_save_event(Event *event, int checkpoint) { if (replay_mode != REPLAY_MODE_PLAY) { replay_put_event(EVENT_ASYNC); replay_put_byte(checkpoint); replay_put_byte(event->event_kind); switch (event->event_kind) { default: error_report("Unknown ID %d of replay event", read_event_kind); exit(1); break; } } }
1threat
static int sd_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { int ret, fd; uint32_t vid = 0; BDRVSheepdogState *s = bs->opaque; char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid; char *buf = NULL; QemuOpts *opts; Error *local_err = NULL; const char *filename; s->bs = bs; s->aio_context = bdrv_get_aio_context(bs); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } filename = qemu_opt_get(opts, "filename"); QLIST_INIT(&s->inflight_aio_head); QLIST_INIT(&s->failed_aio_head); QLIST_INIT(&s->inflight_aiocb_head); s->fd = -1; memset(vdi, 0, sizeof(vdi)); memset(tag, 0, sizeof(tag)); if (strstr(filename, ": ret = sd_parse_uri(s, filename, vdi, &snapid, tag); } else { ret = parse_vdiname(s, filename, vdi, &snapid, tag); } if (ret < 0) { error_setg(errp, "Can't parse filename"); goto out; } s->fd = get_sheep_fd(s, errp); if (s->fd < 0) { ret = s->fd; goto out; } ret = find_vdi_name(s, vdi, snapid, tag, &vid, true, errp); if (ret) { goto out; } s->cache_flags = SD_FLAG_CMD_CACHE; if (flags & BDRV_O_NOCACHE) { s->cache_flags = SD_FLAG_CMD_DIRECT; } s->discard_supported = true; if (snapid || tag[0] != '\0') { DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid); s->is_snapshot = true; } fd = connect_to_sdog(s, errp); if (fd < 0) { ret = fd; goto out; } buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, s->aio_context, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0, s->cache_flags); closesocket(fd); if (ret) { error_setg(errp, "Can't read snapshot inode"); goto out; } memcpy(&s->inode, buf, sizeof(s->inode)); s->min_dirty_data_idx = UINT32_MAX; s->max_dirty_data_idx = 0; bs->total_sectors = s->inode.vdi_size / BDRV_SECTOR_SIZE; pstrcpy(s->name, sizeof(s->name), vdi); qemu_co_mutex_init(&s->lock); qemu_co_queue_init(&s->overwrapping_queue); qemu_opts_del(opts); g_free(buf); return 0; out: aio_set_fd_handler(bdrv_get_aio_context(bs), s->fd, NULL, NULL, NULL); if (s->fd >= 0) { closesocket(s->fd); } qemu_opts_del(opts); g_free(buf); return ret; }
1threat
Need fresh pair of eyes for my php code : <p>I need to make three lines of php code that will randomly choose fahrenheit temp between -10 and 120 degrees and display it converted to celsius. this is the code I came up with but it wont run or validate. please help</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; </code></pre> <p>Phpexamples </p> <p></p> <pre><code>&lt;?php echo"&lt;p&gt;$f equals $ rand ($c 10)."c."&lt;/p&gt;"; echo "&lt;p&gt;"$c=($f-32) * (5/9);$f "&lt;/p&gt;"; echo "&lt;p&gt;"$f= rand(-10,120) "&lt;p&gt;"; ?&gt; &lt;p&gt;&lt;a href="ex2.php"&gt;Run it now&lt;/a&gt;&lt;/p&gt; &lt;/body&gt; </code></pre> <p> </p>
0debug
ArrayList Java Loop : I have an ArrayList (staffList) that contain instances of the of the Staff class...however when i write the following in intellij i am told that 'for statement does not loop'...im really confused as i thought that this was the way to loop through an arraylist public String getTypist() { String tempTy = ""; for (Staff g : staffList) { if (g.getStaffID().contains("TY") && g.isAvailable()) tempTy = g.getStaffID(); staffList.remove(g); staffWorking.add(g); break; } return tempTy;
0debug
Why use contextlib.suppress as opposed to try/except with pass? : <p>Why would one use <a href="https://docs.python.org/3/library/contextlib.html#contextlib.suppress"><code>contextlib.suppress</code></a> to suppress an exception, instead of <code>try</code>/<code>except</code> with a <code>pass</code>?</p> <p>There is no difference in the amount of characters between these two methods (if anything, <code>suppress</code> has more characters), and even though code is often counted in LOC instead of characters, <code>suppress</code> also seems to be much slower than <code>try</code>/<code>except</code> in both cases, when an error is raised and when it's not:</p> <pre><code>Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. &gt;&gt;&gt; from timeit import timeit &gt;&gt;&gt; # With an error &gt;&gt;&gt; timeit("""with suppress(ValueError): x = int('a')""", setup="from contextlib import suppress") 1.9571568971892543 &gt;&gt;&gt; timeit("""try: x = int('a') except ValueError: pass""") 1.0758466499161656 &gt;&gt;&gt; # With no error &gt;&gt;&gt; timeit("""with suppress(ValueError): x = int(3)""", setup="from contextlib import suppress") 0.7513525708063895 &gt;&gt;&gt; timeit("""try: x = int(3) except ValueError: pass""") 0.10141028937128027 &gt;&gt;&gt; </code></pre>
0debug
Is there a function or method Array.reduce in swift? : <p>I would like to reduce the array of strings into a single string using the built in array.reduce closure method.</p> <p>I know using the join method is easier. Just wanted to see if there is a way?</p>
0debug
int kvm_arch_init(KVMState *s) { uint64_t identity_base = 0xfffbc000; int ret; struct utsname utsname; ret = kvm_get_supported_msrs(s); if (ret < 0) { return ret; } uname(&utsname); lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0; #ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR if (kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) { identity_base = 0xfeffc000; ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base); if (ret < 0) { return ret; } } #endif ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base + 0x1000); if (ret < 0) { return ret; } ret = e820_add_entry(identity_base, 0x4000, E820_RESERVED); if (ret < 0) { fprintf(stderr, "e820_add_entry() table is full\n"); return ret; } return 0; }
1threat
int bdrv_file_open(BlockDriverState **pbs, const char *filename, QDict *options, int flags, Error **errp) { BlockDriverState *bs; BlockDriver *drv; const char *drvname; bool allow_protocol_prefix = false; Error *local_err = NULL; int ret; if (options == NULL) { options = qdict_new(); } bs = bdrv_new(""); bs->options = options; options = qdict_clone_shallow(options); if (!filename) { filename = qdict_get_try_str(options, "filename"); } else if (filename && !qdict_haskey(options, "filename")) { qdict_put(options, "filename", qstring_from_str(filename)); allow_protocol_prefix = true; } else { error_setg(errp, "Can't specify 'file' and 'filename' options at the " "same time"); ret = -EINVAL; goto fail; } drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR)); if (!drv) { error_setg(errp, "Unknown driver '%s'", drvname); } qdict_del(options, "driver"); } else if (filename) { drv = bdrv_find_protocol(filename, allow_protocol_prefix); if (!drv) { error_setg(errp, "Unknown protocol"); } } else { error_setg(errp, "Must specify either driver or file"); drv = NULL; } if (!drv) { ret = -ENOENT; goto fail; } if (drv->bdrv_parse_filename && filename) { drv->bdrv_parse_filename(filename, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } qdict_del(options, "filename"); } else if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; goto fail; } ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto fail; } if (qdict_size(options) != 0) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, entry->key); ret = -EINVAL; goto fail; } QDECREF(options); bs->growable = 1; *pbs = bs; return 0; fail: QDECREF(options); if (!bs->drv) { QDECREF(bs->options); } bdrv_unref(bs); return ret; }
1threat
static inline void bit_copy(PutBitContext *pb, GetBitContext *gb) { int bits_left = get_bits_left(gb); while (bits_left >= 16) { put_bits(pb, 16, get_bits(gb, 16)); bits_left -= 16; } if (bits_left > 0) { put_bits(pb, bits_left, get_bits(gb, bits_left)); } }
1threat
static CharDriverState *qemu_chr_open_pty(const char *id, ChardevReturn *ret) { CharDriverState *chr; PtyCharDriver *s; int master_fd, slave_fd; char pty_name[PATH_MAX]; master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { return NULL; } close(slave_fd); chr = g_malloc0(sizeof(CharDriverState)); chr->filename = g_strdup_printf("pty:%s", pty_name); ret->pty = g_strdup(pty_name); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n", pty_name, id); s = g_malloc0(sizeof(PtyCharDriver)); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(master_fd); s->timer_tag = 0; return chr; }
1threat
START_TEST(unterminated_dict) { QObject *obj = qobject_from_json("{'abc':32"); fail_unless(obj == NULL); }
1threat
calculating days rent in hotel from checkin and checkout--asp, c# : check-in time and checkout time days rent calculating. if check-in at 31-08-2016 and checkout at 01-09-2016 then it was calculating rent to 30 days char sp = '/'; string[] date = checkin.Split(sp); string[] date2 = checkout.Split(sp); int c1 = Convert.ToInt32(date[0]); int c0 = Convert.ToInt32(date2[0]); totday = c0 - c1;
0debug
Is this declaration " int fun-name(static int)" valid in C++ and WHY? : while programming in turbo c++ ......I declared a function as following " int fun-name(static int)" then it raised an error "storage class static should not be defined"......can someone help me in understanding it
0debug
static void qdm2_calculate_fft (QDM2Context *q, int channel, int sub_packet) { const float gain = (q->channels == 1 && q->nb_channels == 2) ? 0.5f : 1.0f; int i; q->fft.complex[channel][0].re *= 2.0f; q->fft.complex[channel][0].im = 0.0f; q->rdft_ctx.rdft_calc(&q->rdft_ctx, (FFTSample *)q->fft.complex[channel]); for (i = 0; i < ((q->fft_frame_size + 15) & ~15); i++) q->output_buffer[q->channels * i + channel] += ((float *) q->fft.complex[channel])[i] * gain; }
1threat
inserting x rows after a date value excel vba : i am trying to insert x rows, x =12 after a cell value, i.e date, and my code does not work, please help, Sub HHRowInserter() Dim HHRw As Range For Each HHRw In Range("A1:A2251") If HHRw.Value Like #9/30/2017# Then 'mm/dd/yyyy '30-Sep-17 HHRw.Offset(12, 0).EntireRow.Insert End If Next HHRw End Sub
0debug
Does API Gateway behind CloudFront not support AWS_IAM authentication? : <p>It seems that it is impossible to call a REST API that has AWS_IAM protection enabled through a CloudFront Distribution.</p> <p>Here is how to reproduce this:</p> <ul> <li>create a REST API with API Gateway</li> <li>protect a REST API method with AWS_IAM authentication</li> <li>create a CloudFront Distribution that targets the REST API</li> <li>create an A Record in Route 53 that targets the CloudFront Distribution</li> </ul> <p>Now use an authenticated user (I use Cognito UserPool user and aws-amplify) to call</p> <ol> <li>the protected REST API method with its API Gateway URL = SUCCESS</li> <li>the protected REST API method via the CloudFront distribution URL = FAILURE</li> <li>the protected REST API method via the Route 53 domain URL = FAILURE</li> </ol> <p>The error I am getting is:</p> <p>{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}</p> <p>I just can't believe AWS does not support AWS_IAM protected endpoints behind a custom domain since this must be a very very common use-case.</p> <p>Therefore could you please provide me with a detailed list of how to achieve this?</p> <p>Thank you</p>
0debug
int omap_validate_emiff_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return addr >= OMAP_EMIFF_BASE && addr < OMAP_EMIFF_BASE + s->sdram_size; }
1threat
jquery-3.3.1.js:9600 POST http://127.0.0.1:8000/api/edit-data 500 (Internal Server Error) : With the help of Jquery ajax i am trying to edit the data in the form. According to other solutions, i have already included csrf token in both meta and ajax setup. ``` $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } });``` In header <meta name="csrf-token" content="{{ csrf_token() }}"> ``` ``` $.ajax({ type : "POST", url: "{{url('api/edit-data')}}", data : { id : id, name: name, contact: contact, email: email, valley: valley, paddress: paddress, taddress: taddress, qualification: qualification, ts: ts, experiences: experiences, tob: tob, es: es, level: level, ey: ey, cn: cn, cv: cv, }, success: function(res) { console.log(res.sessiondata); // alert('successful'); } }); }); ``` controller ``` public function editdata(Request $request) { $id = $request->id; $data['name'] = $request->name; $data['contact'] = $request->contact; $data['email'] = $request->email; $data['valley'] =$request->valley; $data['paddress'] = $request->paddress; $data['taddress'] = $request->taddress; $data['qualification'] = $request->qualification; $data['ts'] = $request->ts; $data['experiences'] = $request->experiences; $data['tob'] = $request->tob; $data['es'] = $request->es; $data['level'] = $request->level; $data['ey'] = $request->ey; $data['cn'] = $request->cn; $data['cv'] = $request->cv; if(cv::find($id)->update($data)) { return response([ 'sessiondata' => $data ]); }else{ return response([ 'sessiondata'=> $request->name ]); } } ``` Actual error POST http://127.0.0.1:8000/api/edit-data 500 (Internal Server Error) There's already a lots of solution regarding this error. I have followed them accordingly but i still get this error. I have already include csrf_token both in header in jquery too. Thanks for help.
0debug
I don't understand the point of classes in C++ : <p>Why do you need public and private portions of a class, why do you need baseline variables when you could accomplish the same thing with global variables. </p>
0debug
static void set_seg(struct kvm_segment *lhs, const SegmentCache *rhs) { unsigned flags = rhs->flags; lhs->selector = rhs->selector; lhs->base = rhs->base; lhs->limit = rhs->limit; lhs->type = (flags >> DESC_TYPE_SHIFT) & 15; lhs->present = (flags & DESC_P_MASK) != 0; lhs->dpl = rhs->selector & 3; lhs->db = (flags >> DESC_B_SHIFT) & 1; lhs->s = (flags & DESC_S_MASK) != 0; lhs->l = (flags >> DESC_L_SHIFT) & 1; lhs->g = (flags & DESC_G_MASK) != 0; lhs->avl = (flags & DESC_AVL_MASK) != 0; lhs->unusable = 0; }
1threat
vba compile errorsub or function : the following is my code and I am getting the compile error while it runs, pleae help me to solve Private Sub CommandButton1_Click() Dim yourname As String Dim yourbirthday As Date Dim yourincome As Currency your Name = "Rahul" yourbirthday = "26/03/1996" yourincome = "100000" Range("A1") = yourname Range("A2") = yourbirthday Range("A3") = yourincome End Sub
0debug
Any other way to perform this operation? : for i in range(0, 2 ** 24): byte3 = i & 0xff byte2 = i & 0xff00 byte1 = i & 0xff0000 byte0 = i & 0xff000000 print('%d.%d.%d.%d' % (byte0 >> 24, byte1 >> 16, byte2 >> 8, byte3)) #I request you make a proper program since I am new to python :) Thanks in advance
0debug
unfortunately stopped when I click on items and open new fragments layout : I read some articles and make a nav drawer and fragments.i want to when I click on items in nav drawer, open fragments layout. but when I click on my fragments, my app crashed and unfortunaletly has stopped. can any one tell me what do I wrong? or what should I do to resolve my problem. this is my MainActivty.java: public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawer; private Toolbar toolbar; private NavigationView nvDrawer; private ActionBarDrawerToggle drawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); nvDrawer = (NavigationView) findViewById(R.id.nvView); setupDrawerContent(nvDrawer); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = setupDrawerToggle(); mDrawer.addDrawerListener(drawerToggle); } private ActionBarDrawerToggle setupDrawerToggle() { return new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.drawer_open, R.string.drawer_close); } private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { selectDrawerItem(menuItem); return true; } }); } public void selectDrawerItem(MenuItem menuItem) { Fragment fragment = null; Class fragmentClass; switch (menuItem.getItemId()) { case R.id.nav_first_fragment: fragmentClass = FirstFragment.class; case R.id.nav_second_fragment: fragmentClass = SecondFragment.class; case R.id.nav_third_fragment: fragmentClass = ThirdFragment.class; default: fragmentClass = FirstFragment.class; } try { fragment = (Fragment) fragmentClass.newInstance(); } catch (Exception e) { e.printStackTrace(); } FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit(); menuItem.setChecked(true); setTitle(menuItem.getTitle()); mDrawer.closeDrawers(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: mDrawer.openDrawer(GravityCompat.START); return true; } if (drawerToggle.onOptionsItemSelected(item)) { return true; } return super.onOptionsItemSelected(item); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); drawerToggle.syncState(); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); drawerToggle.onConfigurationChanged(newConfig); } } this is my firstfragment: public class FirstFragment extends android.support.v4.app.Fragment { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1; private String mParam2; private OnFragmentInteractionListener mListener; public FirstFragment() { } public static FirstFragment newInstance(String param1, String param2) { FirstFragment fragment = new FirstFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_first, container, false); } public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); } } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnFragmentInteractionListener) { mListener = (OnFragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } public interface OnFragmentInteractionListener { void onFragmentInteraction(Uri uri); } }
0debug
static uint32_t virtio_read_config(PCIDevice *pci_dev, uint32_t address, int len) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); struct virtio_pci_cfg_cap *cfg; if (proxy->config_cap && ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap, pci_cfg_data), sizeof cfg->pci_cfg_data)) { uint32_t off; uint32_t len; cfg = (void *)(proxy->pci_dev.config + proxy->config_cap); off = le32_to_cpu(cfg->cap.offset); len = le32_to_cpu(cfg->cap.length); if (len <= sizeof cfg->pci_cfg_data) { virtio_address_space_read(&proxy->modern_as, off, cfg->pci_cfg_data, len); } } return pci_default_read_config(pci_dev, address, len); }
1threat
Convolutional NN for text input in PyTorch : <p>I am trying to implement a <a href="http://d3kbpzbmcynnmx.cloudfront.net/wp-content/uploads/2015/11/Screen-Shot-2015-11-06-at-12.05.40-PM.png" rel="noreferrer">text classification model</a> using CNN. As far as I know, for text data, we should use 1d Convolution. I saw an example in pytorch using Conv2d but I want to know how can I apply Conv1d for text? Or, it is actually not possible?</p> <p>Here is my model scenario:</p> <pre><code>Number of in-channels: 1, Number of out-channels: 128 Kernel size : 3 (only want to consider trigrams) Batch size : 16 </code></pre> <p>So, I will provide tensors of shape, &lt;16, 1, 28, 300> where 28 is the length of a sentence. I want to use Conv1d which will give me 128 feature maps of length 26 (as I am considering trigrams).</p> <p>I am not sure, how to define nn.Conv1d() for this setting. I can use Conv2d but want to know is it possible to achieve the same using Conv1d?</p>
0debug
JavaScript ES6 promise for loop : <pre><code>for (let i = 0; i &lt; 10; i++) { const promise = new Promise((resolve, reject) =&gt; { const timeout = Math.random() * 1000; setTimeout(() =&gt; { console.log(i); }, timeout); }); // TODO: Chain this promise to the previous one (maybe without having it running?) } </code></pre> <p>The above will give the following random output:</p> <pre><code>6 9 4 8 5 1 7 2 3 0 </code></pre> <p>The task is simple: Make sure each promise runs only after the other one (<code>.then()</code>).</p> <p>For some reason, I couldn't find a way to do it.</p> <p>I tried generator functions (<code>yield</code>), tried simple functions that return a promise, but at the end of the day it always comes down to the same problem: <strong>The loop is synchronous</strong>.</p> <p>With <a href="https://caolan.github.io/async/" rel="noreferrer">async</a> I'd simply use <code>async.series()</code>.</p> <p>How do you solve it?</p>
0debug
Android how to notify, when viewpager loads pages? : I have implemented viewpager autoscroll. But this triggers much earlier, even before the page loads/visible to user. I want to start the autoscroll, after all the pages visible to user. Please suggest how to handle the notification, when pages visible? Cheers AP
0debug
Is there an equivalent instruction to rdtsc in ARM? : <p>For my project <strong>I must use inline assembly instructions</strong> such as <strong>rdtsc</strong> to calculate the execution time of some C/C++ instructions.</p> <p>The following code seems to work on Intel but not on ARM processors:</p> <pre><code>{unsigned a, d;asm volatile("rdtsc" : "=a" (a), "=d" (d)); t0 = ((unsigned long)a) | (((unsigned long)d) &lt;&lt; 32);} //The C++ statement to measure its execution time {unsigned a, d;asm volatile("rdtsc" : "=a" (a), "=d" (d)); t1 = ((unsigned long)a) | (((unsigned long)d) &lt;&lt; 32);} time = t1-t0; </code></pre> <p><strong>My question is:</strong></p> <p>How to write an <strong>inline assembly code similar to the above</strong> (to calculate the execution elapsed time of an instruction) to work on ARM processors?</p>
0debug
Can I add a channel to a specific conda environment? : <p>I want to add a conda channel to a specific <a href="http://conda.pydata.org/docs/using/envs.html" rel="noreferrer">conda environment</a> but when I use </p> <pre><code>conda config --add channels glotzer </code></pre> <p>that channel is now available from all my conda environments. In addition to testing an install from another environment, the <code>~/.condarc</code> file has the following:</p> <pre><code>channels: - glotzer - defaults </code></pre> <p>How would I configure conda so the channel is only available from a specific environment?</p> <p>I did find in the <a href="http://conda.pydata.org/docs/channels.html" rel="noreferrer">channel documentation</a> that for conda >= 4.1.0, putting channels at the bottom of the <code>~/.condarc</code> will prevent added channels from overiding the core package set.</p> <blockquote> <p>By default conda now prefers packages from a higher priority channel over any version from a lower priority channel. Therefore you can now safely put channels at the bottom of your channel list to provide additional packages that are not in the default channels, and still be confident that these channels will not override the core package set.</p> </blockquote> <p>I expect this will prevent most problems, except when in one environment you do want the package added through a channel to override a core package.</p>
0debug
static void test_validate_struct(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Visitor *v; v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); visit_type_TestStruct(v, NULL, &p, &error_abort); g_free(p->string); g_free(p); }
1threat
Pyton using data structure : How to write a logic for the following Every 3rd element of the input queue from a front-> rear should be added to output queue Otherwise it should return -1 Example:l=[1,2,3,4,5,6,7,8,9,10] It should return 4,7,10 Exa:l=[1,2] It should return -1
0debug
c++ use LoadLibrary to load winapi interfaces from dlls : <p>How can I use this function to load winapi interfaces like ishelllink from dll , I already can load winapi functions properly without problems </p>
0debug
Why are C I/O functions inconsistent among themselves? : <p>Consistency is fundamental property in a code base, let alone in a programming language that eventually turned out to be the most used in the world.</p> <p>There are two families of I/O functions in C: formatted and unformatted. These are:</p> <pre><code>int fprintf(FILE *stream, const char *format, ...); int vfprintf(FILE *stream, const char *format, va_list ap); </code></pre> <p>And</p> <pre><code>int fputc(int c, FILE *stream); int fputs(const char *s, FILE *stream); int putc(int c, FILE *stream); </code></pre> <p><code>*fprintf</code> seems to go for the <code>(where, what)</code> ordering whereas <code>*put*</code> for <code>(what, where)</code>; same holds for input functions. Why is the <strong><code>stream</code></strong> parameter at <strong>different positions</strong>? Are there any <strong>historical</strong>/<strong>design</strong> motivations for such choice?</p>
0debug
Python, a website forbidding me from reading values using website API links : So on the Website ROBLOX.com, the currency is Robux, I'm trying to make a program that monitors the value of the users currency.\ The site has it's on API for viewing stuff. For example if I wanted to view my own Robux it would be a simple link, "https://api.roblox.com/currency/balance" But the problem is... ` print(requests.session().get("https://api.roblox.com/currency/balance").text)` It reads a message from ROBLOX on the site saying that it's forbidden. and the program doing what it's told to do, prints the message telling me it's a forbidden action. the same with when I use `json` function. So, when I enter the link myself as expected it returns, " { ROBUX : "0" }. " Why would they even do this? It's not like Bot devs care about there bots having money? Any idea's on how to Bypass?
0debug
static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) { EaDemuxContext *ea = s->priv_data; ByteIOContext *pb = s->pb; int ret = 0; int packet_read = 0; unsigned int chunk_type, chunk_size; int key = 0; int av_uninit(num_samples); while (!packet_read) { chunk_type = get_le32(pb); chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; switch (chunk_type) { case ISNh_TAG: url_fskip(pb, 32); chunk_size -= 32; case ISNd_TAG: case SCDl_TAG: case SNDC_TAG: case SDEN_TAG: if (!ea->audio_codec) { url_fskip(pb, chunk_size); break; } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR || ea->audio_codec == CODEC_ID_MP3) { num_samples = get_le32(pb); url_fskip(pb, 8); chunk_size -= 12; } ret = av_get_packet(pb, pkt, chunk_size); if (ret != chunk_size) ret = AVERROR(EIO); else { pkt->stream_index = ea->audio_stream_index; pkt->pts = 90000; pkt->pts *= ea->audio_frame_counter; pkt->pts /= ea->sample_rate; switch (ea->audio_codec) { case CODEC_ID_ADPCM_EA: ea->audio_frame_counter += ((chunk_size - 12) * 2) / ea->num_channels; break; case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_MP3: ea->audio_frame_counter += num_samples; break; default: ea->audio_frame_counter += chunk_size / (ea->bytes * ea->num_channels); } } packet_read = 1; break; case 0: case ISNe_TAG: case SCEl_TAG: case SEND_TAG: case SEEN_TAG: ret = AVERROR(EIO); packet_read = 1; break; case MVIh_TAG: case kVGT_TAG: case pQGT_TAG: case TGQs_TAG: key = PKT_FLAG_KEY; case MVIf_TAG: case fVGT_TAG: url_fseek(pb, -8, SEEK_CUR); chunk_size += 8; goto get_video_packet; case mTCD_TAG: url_fseek(pb, 8, SEEK_CUR); chunk_size -= 8; goto get_video_packet; case MV0K_TAG: case MPCh_TAG: case pIQT_TAG: key = PKT_FLAG_KEY; case MV0F_TAG: get_video_packet: ret = av_get_packet(pb, pkt, chunk_size); if (ret != chunk_size) ret = AVERROR_IO; else { pkt->stream_index = ea->video_stream_index; pkt->flags |= key; } packet_read = 1; break; default: url_fseek(pb, chunk_size, SEEK_CUR); break; } } return ret; }
1threat