Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
38,221,181
No module named tensorflow in jupyter
<p>I have some imports in my jupyter notebook and among them is tensorflow:</p> <pre><code>ImportError Traceback (most recent call last) &lt;ipython-input-2-482704985f85&gt; in &lt;module&gt;() 4 import numpy as np 5 import six.moves.copyreg as copyreg ----&gt; 6 import tensorflow as tf 7 from six.moves import cPickle as pickle 8 from six.moves import range ImportError: No module named tensorflow </code></pre> <p>I have it on my computer, in a special enviroment and all connected stuff also:</p> <pre><code>Requirement already satisfied (use --upgrade to upgrade): tensorflow in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): six&gt;=1.10.0 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): protobuf==3.0.0b2 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): numpy&gt;=1.10.1 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): wheel in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): setuptools in ./setuptools-23.0.0-py2.7.egg (from protobuf==3.0.0b2-&gt;tensorflow) </code></pre> <p>I can import tensorflow on my computer:</p> <pre><code>&gt;&gt;&gt; import tensorflow as tf &gt;&gt;&gt; </code></pre> <p>So I'm confused why this is another situation in notebook?</p>
<python><tensorflow><jupyter-notebook>
2016-07-06 09:56:05
HQ
38,221,612
AngularJS. Adding $watch to the partiular model
I am new to angularJS and i dont know how to add `$watch` to the particular model. When going through the angularjs tutorial i facing some issue. i mentioned my doubt in comments part. please go through this. (function(angular) { angular.module('controllerAsExample', []) .controller('SettingsController1', SettingsController1); function SettingsController1() { this.name = "John Smith"; this.contacts = [ {type: 'phone', value: '408 555 1212'}, {type: 'email', value: 'john.smith@example.org'} ]; } //how to add $watch to ng-model 'settings.name' /*$scope.$watch("settings.name", function(oldval, newval){ console.log(oldval + " + " + newval); });*/ SettingsController1.prototype.greet = function() { console.log(this.name); }; })(window.angular); HTML code.. <body ng-app="controllerAsExample"> <div id="ctrl-as-exmpl" ng-controller="SettingsController1 as settings"> <label>Name: <input type="text" ng-model="settings.name"/></label> <button ng-click="settings.greet()">greet</button><br/> </div> </body> Here check my [link][1] [1]: http://plnkr.co/edit/3YJCsuOcLpoFAgipmus8?p=preview
<javascript><angularjs>
2016-07-06 10:18:31
LQ_EDIT
38,221,673
CompletableFuture in the Android Support Library?
<p>So I was migrating an Android Studio project to Java 8, Android API level 24 and the Jack toolchain today to check out the new features, especially lambdas and <code>CompletableFuture</code>. </p> <p>Unfortunately, <code>CompletableFuture</code> seems to be available only from API level 24 on (my minimum API level for that project being 16). </p> <p>Do you know of any plans on bringing <code>CompletableFuture</code> to the Android support library? It looks like a nice solution for the Promises pattern.</p>
<android><java-8>
2016-07-06 10:21:16
HQ
38,221,986
Android vector drawable app:srcCompat not showing images
<p>I'm using support library to show vector images on android kitkat. When I test my app on emulater I don't see any of these images. I made a separate layout for android lollipop and above and it workd perfectly (I think because I'm using <code>src</code> attribute instead of <code>srcCompat</code>Here's the code where I'm usign support library</p> <pre><code>&lt;LinearLayout android:layout_alignParentBottom="true" android:id="@+id/lake_detail" android:background="@drawable/my_fishing_plan_footer_line" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="90dp" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"&gt; &lt;RelativeLayout android:layout_marginRight="3dp" android:id="@+id/fire_logo" android:layout_width="20sp" android:layout_height="20sp"&gt; &lt;ImageView android:tint="#d74313" app:srcCompat="@drawable/circle_icon" android:layout_width="30sp" android:layout_height="30sp" /&gt; &lt;ImageView android:layout_centerVertical="true" android:layout_centerHorizontal="true" app:srcCompat="@drawable/lauzaviete" android:layout_width="25dp" android:layout_height="25dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p> and it's strange because I see the images on android studio preview window.</p>
<android><android-support-library>
2016-07-06 10:38:04
HQ
38,222,302
I have a csv file with two different formats of date value, how to bring it to a single format
My CSV file looks like this id date 1602 11/23/2015 14:10 1602 11/23/2015 22:45 1602 18/10/2011 09:19:46 AM 1702 18/10/2011 09:07:33 AM 1863 18/10/2011 09:07:35 AM 1436 18/10/2011 09:07:36 AM
<java><python><shell>
2016-07-06 10:54:50
LQ_EDIT
38,222,802
How to generate JaxB-Classes with java.util.Optional?
<p>I use the jaxb2-maven-plugin to generate JaxB-Classes from a given XSD. It works fine. But now I want to use java.util.Optional in the generated Classes. But JaxB generated the Classes without the Optionals. So I'm forced to make a Null-Check of every Variable.</p> <p>Did anybody know how the jaxb2-maven-plugin has to be configured to use the java.util.Optional?</p> <p>Thanks for you help!</p>
<java><xsd><jaxb><maven-jaxb2-plugin>
2016-07-06 11:22:09
HQ
38,222,957
jOOQ can I fetch a join of two tables into the respective POJOs
<p>In jOOQ if I want to fetch a row of a table into a jOOQ autogenerated POJOs I do, for instance:</p> <pre><code>dsl.selectFrom(USER) .where(USER.U_EMAIL.equal(email)) .fetchOptionalInto(User.class); </code></pre> <p>Now, suppose that I want to do a join between two tables, e.g. <code>USER</code> and <code>ROLE</code>, how can I fetch the result into the POJOs for these two tables?</p>
<java><jooq>
2016-07-06 11:30:50
HQ
38,223,158
Laravel Migration - Adding Check Constraints In Table
<p>I want to create a table in Laravel Migration like this-</p> <pre><code>CREATE TABLE Payroll ( ID int PRIMARY KEY, PositionID INT, Salary decimal(9,2) CHECK (Salary &lt; 150000.00) ); </code></pre> <p>What I have done is-</p> <pre><code>Schema::create('Payroll', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;integer('PositionID '); $table-&gt;decimal('Salary',9,2); //$table-&gt;timestamps(); }); </code></pre> <p>But I can't create this-</p> <pre><code> CHECK (Salary &lt; 150000.00) </code></pre> <p>Can anyone please tell, how to implement this <code>CHECK</code> constraints in <a href="https://laravel.com/docs/5.1/migrations" rel="noreferrer">Laravel Migration</a> ?</p>
<php><mysql><laravel><migration><database-migration>
2016-07-06 11:41:49
HQ
38,223,631
How to call python function in java
this is my python code: class myPythonClass: def table(nb): i = 0 while i < 10: print(i + 1, "*", nb, "=", (i + 1) * nb) i += 1 i need how to call using : PythonInterpreter
<java><python><spring>
2016-07-06 12:08:26
LQ_EDIT
38,224,044
Copying the location of file names
I have a root folder called "Project" below that I have hundreds of sub folders and I want to export the location of those folder which ever consists a excel file to a separate text file.how can i achieve that in python..? **Example** D:\Project\Folder1 D:\Project\Folder2\Folder3
<excel><vba>
2016-07-06 12:30:05
LQ_EDIT
38,224,075
can't we return list in python?
<p>I'm just started learning python.. How to return list? Is here any error in code.?</p> <pre><code>def fibonocci(x,i): if len(lst)&gt;=x: return lst v=lst[i-1]+lst[i-2] lst.append(v) fibonocci(x,i+1) n=int(input("Enter a number: ")) lst=[0,1] print(fibonocci(n,2)) </code></pre>
<python><list>
2016-07-06 12:31:27
LQ_CLOSE
38,224,081
What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element
<p>When I used inspect elements in Google Chrome there is always <code>== $0</code> at the end of the selected element. This is something new and I hadn't see it in the older versions of the Google Chrome:</p> <p><a href="https://i.stack.imgur.com/lMYiw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lMYiw.png" alt="enter image description here"></a></p>
<javascript><html><css><google-chrome>
2016-07-06 12:31:36
HQ
38,224,800
Search for byte pattern in node.js Buffer
<p>I have this node.js Buffer.</p> <pre><code>var test_buf = "5E4D802158D002001022201022AB778899A1B2C3"; var buffer_hex = new Buffer(test_buf, "hex"); </code></pre> <p>I want to search for the existence of byte pattern <code>77 88 99</code> in <code>buffer_hex</code>. From the tutorial <a href="http://www.tutorialspoint.com/nodejs/nodejs_buffers.htm" rel="noreferrer">http://www.tutorialspoint.com/nodejs/nodejs_buffers.htm</a>, I cannot find a suitable Buffer function to use. Any suggestions? </p>
<node.js>
2016-07-06 13:06:01
HQ
38,225,406
How to get data from Ecto in a custom mix task
<p>I want to display data from my DB through Ecto in a custom mix task. How can I get the Ecto repo in my task (or start it)?</p> <p>I tried something like this but it didn't work:</p> <pre><code>defmodule Mix.Tasks.Users.List do use Mix.Task use Mix.Config use Ecto.Repo, otp_app: :app @shortdoc "List active users" @moduledoc """ List active users """ def run(_) do import Ecto.Query, only: [from: 1] Mix.shell.info "=== Active users ===" query = from u in "users" sync = all(query) Enum.each(users, fn(s) -&gt; IO.puts(u.name) end) end end </code></pre> <p>This will give me the following output when I launch mix users.list: </p> <pre><code>** (ArgumentError) repo Mix.Tasks.Users.List is not started, please ensure it is part of your supervision tree lib/ecto/query/planner.ex:64: Ecto.Query.Planner.query_lookup/5 lib/ecto/query/planner.ex:48: Ecto.Query.Planner.query_with_cache/6 lib/ecto/repo/queryable.ex:119: Ecto.Repo.Queryable.execute/5 </code></pre> <p>Any idea or other way to solve this problem?</p>
<elixir><phoenix-framework><mix>
2016-07-06 13:36:13
HQ
38,225,484
hello guys i need help in this fragment..i need to move to another activity instead of when i click button i get a toast...here is my code..thanks you
public class HomeFragment extends Fragment implements View.OnClickListener { Button btn,btn2; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_home, container, false); btn = (Button) view.findViewById(R.id.btn); btn2 = (Button) view.findViewById(R.id.btn2); btn.setOnClickListener(this); btn2.setOnClickListener(this); return view; } @Override public void onClick(View v) { switch (v.getId()){ case R.id.btn: Toast.makeText(this.getActivity(),"Button 1!", Toast.LENGTH_LONG).show(); break; case R.id.btn2: Toast.makeText(this.getActivity(),"Button 2 !", Toast.LENGTH_LONG).show(); break; } } }
<android>
2016-07-06 13:39:50
LQ_EDIT
38,225,500
char pointer value reassignment
<pre><code>#include&lt;stdio.h&gt; #include&lt;string.h&gt; int main() { int i=0; char *b,*a="a(a+b))"; b=a; printf("%s",b); printf("%d",a); while(a[i]!='\0') { a++; i++; } *a="(a+b)"; printf("%s",a); } </code></pre> <p>initialy i am assigning a value to that char pointer after moving it to the end using null comparision can i again assign a value to that char pointer? Can i do like this? what is wrong here? can anyone please explain??</p>
<c><pointers><char>
2016-07-06 13:40:22
LQ_CLOSE
38,226,215
How to include the end date in a DatePeriod?
<p>I am trying to get a Date range for all workdays this week. I have written the following code to do so.</p> <h3>Code</h3> <pre><code>$begin = new DateTime('monday this week'); 2016-07-04 $end = clone $begin; $end-&gt;modify('next friday'); // 2016-07-08 $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval, $end); foreach($daterange as $date) { echo $date-&gt;format('Y-m-d')."&lt;br /&gt;"; } </code></pre> <h3>Output</h3> <ul> <li>2016-07-04</li> <li>2016-07-05</li> <li>2016-07-06</li> <li>2016-07-07</li> </ul> <p>In the output friday is missing. I can fix this by doing <code>$end-&gt;modify('next saturday')</code> but I was wondering why the last day of a <code>DatePeriod</code> is not included in the range.</p>
<php><datetime>
2016-07-06 14:12:56
HQ
38,226,445
creating index on table
What index would be created for this syntax ''CREATE **INDEX** IDX_NAME ON TABLE(Column name)''
<sql><sql-server><sql-server-2012>
2016-07-06 14:23:01
LQ_EDIT
38,226,720
Could you please help me how to show the comments elements in the dish with using ng-repeat?
I want to show all the comments elements like a list by using the "ng-repeat" and "ng-controller" , but I don't know how to show the comments elements inside the dish ! like this :<br> 5 stars<br> Imagine all the eatables, living in conFusion!<br> John Lemon,oct. 17,2012 <script> var app = angular.module('confusionApp',[]); app.controller('dishDetailController', function() { this.filtText= ''; var dish=[ { name:'Uthapizza', image: 'images/uthapizza.png', category: 'mains', lable:'Hot', price:'4.99', description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', comments: [ { rating:5, comment:"Imagine all the eatables, living in conFusion!", author:"John Lemon", date:"2012-10-16T17:57:28.556094Z" }, { rating:4, comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", author:"Paul McVites", date:"2014-09-05T17:57:28.556094Z" }, { rating:3, comment:"Eat it, just eat it!", author:"Michael Jaikishan", date:"2015-02-13T17:57:28.556094Z" }, { rating:4, comment:"Ultimate, Reaching for the stars!", author:"Ringo Starry", date:"2013-12-02T17:57:28.556094Z" }, { rating:2, comment:"It's your birthday, we're gonna party!", author:"25 Cent", date:"2011-12-02T17:57:28.556094Z" } ] }]; this.dish = dish; }); </script>
<javascript><angularjs><ng-repeat><ng-controller>
2016-07-06 14:34:40
LQ_EDIT
38,226,875
Laravel $request->file() returns null
<p>having trouble trying to upload files using Laravel on the back-end.</p> <h3>Issue</h3> <p>Laravel <code>$request-&gt;file()</code> method returns null.</p> <h3>Setup</h3> <p>I build up an AJAX request using <a href="https://github.com/visionmedia/superagent" rel="noreferrer">superagent</a>, debugged the request and everything seems fine. The <code>Content-Length</code> changes depending on the image I add, indicating an image has been added to the request. The <code>Content-Type</code> is also set to <code>multipart/form-data</code>.</p> <pre><code>// request headers Content-Length:978599 Content-Type:multipart/form-data; // request payload Content-Disposition: form-data; name="files"; filename="item-keymoment.png" Content-Type: image/png </code></pre> <p>But I'm unable to get the file in Laravel. Using <code>$request-&gt;file('files')</code> returns <code>NULL</code>, but if I debug the <code>$_FILES</code> array, I noticed that a my file has been uploaded.</p> <pre><code>dd($request-&gt;file('files')) // NULL dd($_FILES); // array:1 [ // "files" =&gt; array:5 [ // "name" =&gt; "item-keymoment.png" // "type" =&gt; "image/png" // "tmp_name" =&gt; "/tmp/phpipbeeM" // "error" =&gt; 0 // "size" =&gt; 978274 // ] // ] dd($request-&gt;files-&gt;all()) // [] </code></pre> <p>What might be causing Laravel to ignore the file?<br/> <code>Content-Type</code> of the input file not being <code>application/octet-stream</code>?</p> <p><strong>Below have answered the question.</strong></p>
<php><laravel><file-upload>
2016-07-06 14:42:14
HQ
38,227,203
Field with @CreationTimestamp annotation is null while save on repository
<p>(1) Why is the "@CreationTimestamp" field updated to null for a "save" called on the repository with a null value for that field? I expect that a field annotated with "@CreationTimestamp" is never updated and maintained only once at the time of creation. But it does not work that way in my current project.</p> <p>(2) I had to include @Column(updatable =false) (in addition to @CreationTimestamp annotation). Why is this necessary?</p>
<hibernate><jpa><jersey>
2016-07-06 14:57:03
HQ
38,227,783
How to "Delete derived data" in Xcode8?
<p>In Xcode7 you click Window -> Projects and select the projects that you want the derived data to be deleted.</p> <p>But with <strong>Xcode8 beta 2</strong> the project menu no longer exists under the Windows menu. Are there any quick methods to delete the derived data through Xcode8 interface?</p>
<xcode><xcode8>
2016-07-06 15:25:50
HQ
38,227,861
C# out parameter and dictionary
<p>I've a dictionary object in my C# code:dictEmployees;---></p> <p>It has a list of all Employees.Employee class has two properties...Id and Salary.Lets say, Initially, this collection has a salary of 50K for employee Id 1.</p> <pre><code>Employee employee = new Employee(); dictEmployees.TryGetValue(1, out employee); </code></pre> <p>Now,if I modify employee' salary in other some method, I see that the salary is also being reflected in the employee object in the dictionary. Is this expected please?</p> <p>Thanks.</p>
<c#>
2016-07-06 15:30:08
LQ_CLOSE
38,228,255
need to implement virtual wallet in an iOS app (For Austria region), where the user can pay via credits to the seller and i take my cut in real time
<p>I need to implement virtual wallet in an iOS app (For Austria region), where the user can pay via credits to the seller and I take my cut in real time. For example, if user has to pay $ 10 to the seller, then I'd get $ 2 in my account and 8 to seller's. Is there any service that I can leverage for this workflow? or if apple in-App is the answer?</p> <p>I'd be fine even if transaction happens in real currency (can do away virtual credits etc), the priority is I get my cut to be credited in real time as well before seller gets the fee; please suggest.</p>
<ios><payment-gateway><payment-processing><wallet>
2016-07-06 15:49:10
LQ_CLOSE
38,229,325
.NET Standard Library vs. .NET Standard
<p>Reading some blogs and the official <a href="https://docs.microsoft.com/en-us/dotnet/articles/standard/library">documentation for .NET Core 1.0</a>, I'm still quite confused (like many others).<br> Don't get me wrong, I've literally read dozens of posts on the web trying to understand the architecture and terms for this new platform.</p> <p>Reading the docs and blogs, this is what they say about <strong>.NET Standard Library</strong>:</p> <blockquote> <p>The .NET Standard Library is a formal specification of .NET APIs that are intended to be available on all .NET runtimes.</p> </blockquote> <p>But they also use this term: <strong>.NET Standard</strong> and <strong>netstandard</strong> as you can see on the <a href="https://docs.microsoft.com/en-us/dotnet/articles/standard/library#net-platforms-support">Platform Support table</a>.</p> <p>Question: <strong>.NET Standard Library</strong> <code>==</code> <strong>.NET Standard</strong>? If not, what's difference?</p>
<.net><.net-core>
2016-07-06 16:44:10
HQ
38,229,747
What view/layout would work best for this Android fragment?
<p>I am trying to create a view like this in an Android fragment, and after doing a good amount of research, I am still unsure what the best way to go about doing this <strong><em>in a fragment</em></strong>.</p> <p>It appears to possibly need 2 different layouts, but I could also be very incorrect. I am new to Android and appreciate any help I can get. </p> <p><a href="https://i.stack.imgur.com/DH4pK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DH4pK.png" alt="Attempted fragment layout"></a></p> <p>Thank you!</p>
<android><mobile><layout><view><fragment>
2016-07-06 17:08:13
LQ_CLOSE
38,229,906
Store in the database from twig Symfony 2
<p>I would like to now if there is a way to store in my database somes values displayed on twig ? the values was calculated with javascript/jason, and i dont want to do the same script on symfony or php ...</p> <p>Thank you ! </p>
<php><symfony><twig>
2016-07-06 17:16:17
LQ_CLOSE
38,230,152
Error handling with Angular2 async pipe
<p>I am using the Angular2 async pipe to stream values into the DOM. Here's a real simple example:</p> <pre><code>const stream = Observable.interval(1000) .take(5) .map(n =&gt; { if (n === 3) throw "ERROR"; return n; }); &lt;div *ngFor="for num of stream | async"&gt; {{num}} &lt;/div&gt; &lt;div id="error"&gt;&lt;/div&gt; </code></pre> <p>What I would like to do is to have the sequence of 1-5 displayed, but on the error item (3), somehow populate the <code>#error</code> div with the error message.</p> <p>This seems to require two things: first is the ability of the Angular async pipe to do something intelligent with errors, which I see no sign of. Looking at the source code, apparently it throws a JS exception, which doesn't seem too friendly.</p> <p>Second is the ability to restart or continue the sequence after the error. I have read about <code>catch</code> and <code>onErrorResumeNext</code> and so on, but they all involve another sequence which will be switched to on an error. This greatly complicates the logic of generating the stream, on which I would just like to put a series of numbers (in this simple example). I have the sinking feeling that once an error occurs the game is over and the observable is completed and can only be "restarted" with a different observable. I'm still learning observables; is this in fact the case?</p> <p>So my question is twofold:</p> <ol> <li>Can Angular2's async pipe do something intelligent with errors?</li> <li>Do observables have some simple way to continue after an error?</li> </ol>
<error-handling><angular><rxjs>
2016-07-06 17:30:03
HQ
38,230,452
What is command to find detailed information about Kubernetes master(s) using kubectl?
<p>Let say I want to find the kubelet and apiserver version of my k8s master(s), what's the best way to do it?</p> <p>I am aware of the following commands:</p> <pre><code>kubectl cluster-info </code></pre> <p>which only shows the endpoints.</p> <pre><code>kubectl get nodes; kubectl describe node &lt;node&gt;; </code></pre> <p>which shows very detail information but only the nodes and not master.</p> <p>There's also</p> <pre><code>kubectl version </code></pre> <p>but that only shows the kubectl version and not the kubelet or apiserver version.</p> <p>What other commands can I use to identify the properties of my cluster?</p>
<kubernetes><kubectl>
2016-07-06 17:45:32
HQ
38,230,656
Make website span to user?
<p>How would I make a website adopt the dimensions of a user's device who is browsing it, in order to avoid problems that would deter from aesthetics like scrolling the width of the page in order to see full content.</p> <p>If that is not possible what are the best dimensions?</p>
<html><css><web>
2016-07-06 17:57:07
LQ_CLOSE
38,230,696
javascript - parse string and store it in differents variables
my problem is the next one : I have a string with a special character that 'separates' the string in different parts. var str = "this could be part 1 -- this is part 2 -- here is part3"; Here i chose '--' as special group of characters to delimit the parts. And i would like from this string to be able to be able to separate these parts and put one of each in an array and get this result : this could be part 1 , this is part 2 , here is part3 What is the better way to do this ? Thank you in advance for your answer
<javascript><arrays>
2016-07-06 17:58:55
LQ_EDIT
38,230,831
Why does parLapplyLB not actually balance load?
<p>I'm testing out the <code>parLapplyLB()</code> function to understand what it does to balance a load. But I'm not seeing any balancing happening. For example,</p> <pre><code>cl &lt;- parallel::makeCluster(2) system.time( parallel::parLapplyLB(cl, 1:4, function(y) { if (y == 1) { Sys.sleep(3) } else { Sys.sleep(0.5) }})) ## user system elapsed ## 0.004 0.009 3.511 parallel::stopCluster(cl) </code></pre> <p>If it was truly balancing the load, the first job (job 1) that sleeps for 3 seconds would be on the first node and the other three jobs (jobs 2:4) would sleep for a total of 1.5 seconds on the other node. In total, the system time should only be 3 seconds.</p> <p>Instead, I think that jobs 1 and 2 are given to node 1 and jobs 3 and 4 are given to node 2. This results in the total time being 3 + 0.5 = 3.5 seconds. If we run the same code above with <code>parLapply()</code> instead of <code>parLapplyLB()</code>, we get the same system time of about 3.5 seconds.</p> <p>What am I not understanding or doing wrong?</p>
<r><rparallel>
2016-07-06 18:06:00
HQ
38,231,271
Div style according to the place of CSS
<p>I have the following HTML file:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #aDiv{ width:300px; height:100px; background-color:blue; } &lt;/style&gt; &lt;!--link rel="stylesheet" href="style.css"--&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="aDiv"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p></p> <p>If I launch the html in the above form, the blue rectangle is displayed. If I saved the style in a css file (respectively <strong><em>style.css</em></strong>) the rectangle is not displayed. This behaviour is valid for all the browsers I tried (Firefox, IE, Chrome). How to solve this problem ?</p>
<javascript><html><css>
2016-07-06 18:31:09
LQ_CLOSE
38,231,321
Error trying to generate token using .NET JWT library
<p>I'm trying to use package System.IdentityModel.Tokens.Jwt to generate a token. I found some code samples online, was pretty straightforward, but then I'm running into an error that I can't figure out. Here's the code I'm using (has been modified slightly for brevity):</p> <pre><code>&lt;%@ Application Language="C#" %&gt; &lt;%@ Import Namespace="System" %&gt; &lt;%@ Import Namespace="System.Text" %&gt; &lt;%@ Import Namespace="System.Reflection" %&gt; &lt;%@ Import Namespace="System.Collections" %&gt; &lt;%@ Import Namespace="System.IdentityModel.Tokens" %&gt; &lt;%@ Import Namespace="System.IdentityModel.Tokens.Jwt" %&gt; &lt;%@ Import Namespace="System.Security.Claims" %&gt; &lt;%@ Import Namespace="System.IdentityModel.Protocols.WSTrust" %&gt; &lt;script runat="server"&gt; public class TestClass { public static string GetJwtToken() { var tokenHandler = new JwtSecurityTokenHandler(); var input = "anyoldrandomtext"; var securityKey = new byte[input.Length * sizeof(char)]; Buffer.BlockCopy(input.ToCharArray(), 0, securityKey, 0, securityKey.Length); var now = DateTime.UtcNow; var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new[] { new Claim( ClaimTypes.UserData, "IsValid", ClaimValueTypes.String, "(local)" ) }), TokenIssuerName = "self", AppliesToAddress = "https://www.mywebsite.com", Lifetime = new Lifetime(now, now.AddMinutes(60)), SigningCredentials = new SigningCredentials(new InMemorySymmetricSecurityKey(securityKey), "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256", "http://www.w3.org/2001/04/xmlenc#sha256"), }; var token = tokenHandler.CreateToken(tokenDescriptor); var tokenString = tokenHandler.WriteToken(token); return tokenString; } } &lt;/script&gt; </code></pre> <p>I keep getting the following error at line 113 (var token = tokenHandler.CreateToken(tokenDescriptor);):</p> <p><em>Argument 1: cannot convert from 'System.IdentityModel.Tokens.SecurityTokenDescriptor' to 'Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor'</em></p> <p>But I've seen many examples online doing things exactly as I've done them. I also ran into this article (<a href="https://msdn.microsoft.com/en-us/library/jj157089(v=vs.110).aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/jj157089(v=vs.110).aspx</a>) that states the following:</p> <blockquote> <p>In WIF 3.5, all of the WIF classes were contained in the Microsoft.IdentityModel assembly (microsoft.identitymicrosoft.identitymodel.dll). In WIF 4.5, the WIF classes have been split across the following assemblies: mscorlib (mscorlib.dll), System.IdentityModel (System.IdentityModel.dll), System.IdentityModel.Services (System.IdentityModel.Services.dll), and System.ServiceModel (System.ServiceModel.dll).</p> <p>The WIF 3.5 classes were all contained in one of the Microsoft.IdentityModel namespaces; for example, Microsoft.IdentityModel, Microsoft.IdentityModel.Tokens, Microsoft.IdentityModel.Web, and so on. In WIF 4.5, the WIF classes are now spread across the System.IdentityModel namespaces, the System.Security.Claims namespace, and the System.ServiceModel.Security namespace. In addition to this reorganization, some WIF 3.5 classes have been dropped in WIF 4.5.</p> </blockquote> <p>I tried for debugging sake to switch to use the Microsoft.* namespace for the SecurityTokenDescriptor, and then I get another series of errors saying TokenIssuerName, AppliesToAddress, and Lifetime aren't valid properties for that class. Yet when I look at the docs online, seems like those properties do exist on Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor. Yet in my Visual Studio, when I do Go to Definition for that class, they're not there, leading me to believe that there's some kind of configuration issue in my Visual Studio. In my package manager, it shows I have Microsoft.IdentityModel.Tokens v5.0.0 installed. I also changed the project to .NET framework 4.5.1 since the JWT library requires it. Beyond that, I don't know where else to look.</p>
<c#><asp.net><jwt>
2016-07-06 18:34:00
HQ
38,231,504
C# Make form invisible
i know this question seems very simple but its not working for me, i think i changed a property by accident so the form wont go invisible. on load, i have : this.Visible = false; this.ShowInTaskbar = false; this.ShowIcon = false; it doesnt show in taskbar or the icon but for some reason its still visible like in the image below [![enter image description here][1]][1] i know thats the form because i changed the color to red and it turned red [1]: http://i.stack.imgur.com/y1Nv5.png
<c#><winforms>
2016-07-06 18:43:26
LQ_EDIT
38,231,776
C# for loop and encryption
<p>I'm Kind of new to C# but since i have learned other programming languages before, learning it is going pretty well, However I am stuck on this one part, I am trying to "port" my old python application that takes a string or the users input and encrypts it. the python code is below, My problem is doing everything after and including the for loop. How might i go about searching for each letter in the Character string.</p> <pre><code>CHARACTER= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=+_)(*&amp;^%$#@!?&gt;&lt;|:;}{][" translated = '' for uniqueKey in message: if uniqueKey in CHARACTER: num = CHARACTER.find(uniqueKey) if mode == "encrypt": num += key elif mode == "decrypt": num -= key if num &gt;= len(CHARACTER): num -= len(CHARACTER) elif num &lt; 0: num += len(CHARACTER) translated = translated + CHARACTER[num] else: translated = translated + uniqueKey </code></pre>
<c#><for-loop><encryption>
2016-07-06 18:58:26
LQ_CLOSE
38,232,708
Unused 'is' at end of if expression
<pre><code>{% if loop.index is even %} &lt;tr class="row1"&gt; &lt;td&gt;&lt;a href="/webpage_tracking/report_page?url={{report.url}}&amp;validation={{report.validation}}" target="_blank"&gt;{{report.url}}&lt;/a&gt;&lt;/td&gt; &lt;td&gt;{{username}}&lt;/td&gt; &lt;td&gt;{{report.validation}}&lt;/td&gt; &lt;td&gt;{{report.date}}&lt;/td&gt; &lt;/tr&gt; {% else %} &lt;tr class="row2"&gt; &lt;th class="field-object_id"&gt;&lt;a href="/ceeb-admin/ceeb_program/program/{{report.url}}/change/"&gt;{{report.url}}&lt;/a&gt;&lt;/th&gt; &lt;td&gt;{{username}}&lt;/td&gt; &lt;td&gt;{{report.validation}}&lt;/td&gt; &lt;td&gt;{{report.date}}&lt;/td&gt; &lt;/tr&gt; {% endif %} </code></pre> <p>The above is my code and I did what tutorial said but it raised the error at first line and I don't know why.</p>
<html><django>
2016-07-06 19:57:45
LQ_CLOSE
38,233,003
d3.js v4: How to access parent group's datum index?
<p>The description of the <code>selection.data</code> function includes an example with multiple groups (<a href="https://github.com/d3/d3-selection/blob/master/README.md#selection_data">link</a>) where a two-dimensional array is turned into an HTML table.</p> <p>In d3.js v3, for lower dimensions, the accessor functions included a third argument which was the index of the parent group's datum:</p> <pre><code>td.text(function(d,i,j) { return "Row: " + j; }); </code></pre> <p>In v4, this <code>j</code> argument has been replaced by the selection's NodeList. How do I access the parent group's datum index now?</p>
<d3.js>
2016-07-06 20:16:56
HQ
38,233,335
Find the specific number from Array.collect
<p>I want to find out what's the first, the second, and the third result, so that I can do <code>if firstnumber==secondnumber &amp;&amp; secondnumber==thirdnumber</code>. How could I find those numbers on the results?</p> <pre><code>numbers = 3.times.map { Random.new.rand(0..10000) } prizes = numbers.map do |x| case x when 1..3000 [ '7', 10000 ] when 3001..6000 [ "Cherries", 500 ] when 6001..10000 [ "Diamond", 400 ] end end puts "Your results are: #{prizes.collect { |p| p[0] }.join(", ")}! </code></pre> <p>I tried to use p[0][0], but it gives the first letter instead.</p>
<ruby>
2016-07-06 20:36:42
LQ_CLOSE
38,233,649
Angular CLI - How to resolve url in CSS or SCSS?
<p>I have a component whose SCSS references an image in the same component folder, using <code>background-image: url('./logo.jpg')</code>.</p> <p>Removing the leading ./ does not help either. In any case, the image does not show in the browser.</p> <p>I am running <code>ng serve</code> and looking at the <code>dist</code> folder, logo.jpg is indeed copied and placed in the same component folder as expected.</p> <p>I would also like to be able to reference images from other locations outside the folder that my .css or .scss file lives in, using relative paths like I do with my component .html and .css from the .ts file.</p> <p>I think I need some sort of url resolver that would generate the full URL on the outputted .css file. How would I obtain such a resolver and how do I configure it in Angular CLI?</p>
<url><angular-cli>
2016-07-06 20:57:16
HQ
38,233,687
How to use the Firebase refreshToken to reauthenticate?
<p>I use the JS library call <code>firebase.auth().signInWithEmailAndPassword(email, password)</code> and get back a <code>User</code> object. The <code>User</code> object contains a <a href="https://firebase.google.com/docs/reference/js/firebase.User#refreshToken" rel="noreferrer"><code>refreshToken</code></a>.</p> <p>I use <code>curl 'https://docs-examples.firebaseio.com/rest/saving-data/auth-example.json?auth=TOKEN'</code> to make calls to Firebase. </p> <p>The token will eventually expire. In order to make it look like the application (<code>iOS</code> and <code>macOS</code>) has persistent login, I want to refresh the token, how do I do that with using either the <code>REST</code> or <code>JS</code> library? I can't find any calls in the documentation that allow me to use the <code>refreshToken</code> to get a new <code>token</code>.</p>
<firebase><firebase-authentication>
2016-07-06 20:59:30
HQ
38,233,815
Where may I find an IQueryable implementation of Contains for T-SQL?
<p>Everytime I do a:</p> <pre><code>journals = _context.Journals .Where(j =&gt; j.Name.Contains("foo")); </code></pre> <p>I feel the need to stop and write an extension on <code>IQueryable</code> that will make the <code>Contains</code> work. Is there one available already?</p>
<c#><.net><entity-framework><linq>
2016-07-06 21:10:18
LQ_CLOSE
38,234,152
How can I make this rxjava zip to run in parallel?
<p>I have a sleep method for simulating a long running process.</p> <pre><code>private void sleep() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } </code></pre> <p>Then I have a method returns an Observable containing a list of 2 strings that is given in the parameters. It calls the sleep before return the strings back.</p> <pre><code>private Observable&lt;List&lt;String&gt;&gt; getStrings(final String str1, final String str2) { return Observable.fromCallable(new Callable&lt;List&lt;String&gt;&gt;() { @Override public List&lt;String&gt; call() { sleep(); List&lt;String&gt; strings = new ArrayList&lt;&gt;(); strings.add(str1); strings.add(str2); return strings; } }); } </code></pre> <p>Then I am calling the getStrings three times in Observalb.zip, I expect those three calls to run in parallel, so the total time of execution should be within <strong>2 seconds</strong> or maybe 3 seconds the most because the sleep was only 2 seconds. However, it's taking a total of <strong>six</strong> seconds. <strong>How can I make this to run in parallel so it will finish within 2 seconds?</strong></p> <pre><code>Observable .zip(getStrings("One", "Two"), getStrings("Three", "Four"), getStrings("Five", "Six"), mergeStringLists()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer&lt;List&lt;String&gt;&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(List&lt;String&gt; strings) { //Display the strings } }); </code></pre> <p>The mergeStringLists method</p> <pre><code>private Func3&lt;List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;&gt; mergeStringLists() { return new Func3&lt;List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;&gt;() { @Override public List&lt;String&gt; call(List&lt;String&gt; strings, List&lt;String&gt; strings2, List&lt;String&gt; strings3) { Log.d(TAG, "..."); for (String s : strings2) { strings.add(s); } for (String s : strings3) { strings.add(s); } return strings; } }; } </code></pre>
<java><android><rx-java><reactive-programming><rx-android>
2016-07-06 21:33:58
HQ
38,235,183
python dictionary data manipulation
i have the following dataset in pytyhon: > data=[{'id': '431876400186007/insights/page_fans_country/lifetime', 'name': > 'page_fans_country', 'description': 'Lifetime: Aggregated Facebook > location data, sorted by country, about the people who like your Page. > (Unique Users)', 'title': 'Lifetime Likes by Country', 'period': > 'lifetime', 'values': [{'end_time': '2016-07-02T07:00:00+0000', > 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID': > 91, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230, > 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 550, 'GE': > 178, 'GR': 273321, 'CO': 98, 'DZ': 86, 'US': 2447, 'BG': 732, 'MA': > 95, 'MK': 831, 'PT': 160, 'CH': 187, 'CA': 317, 'DE': 4463, 'AL': > 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 609, 'SE': > 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97, > 'DK': 77, 'RS': 444}}, {'end_time': '2016-07-03T07:00:00+0000', > 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID': > 91, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230, > 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 548, 'GE': > 178, 'GR': 273275, 'CO': 98, 'DZ': 86, 'US': 2447, 'BG': 732, 'MA': > 95, 'MK': 831, 'PT': 159, 'CH': 187, 'CA': 317, 'DE': 4462, 'AL': > 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 607, 'SE': > 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97, > 'DK': 77, 'RS': 445}}, {'end_time': '2016-07-04T07:00:00+0000', > 'value': {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID': > 90, 'MX': 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230, > 'RU': 99, 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 547, 'GE': > 178, 'GR': 273249, 'CO': 98, 'DZ': 86, 'US': 2445, 'BG': 732, 'MA': > 95, 'MK': 831, 'PT': 159, 'CH': 187, 'CA': 317, 'DE': 4460, 'AL': > 1588, 'FR': 388, 'PE': 204, 'AE': 142, 'TR': 547, 'BR': 608, 'SE': > 495, 'HU': 120, 'IT': 845, 'PL': 186, 'IN': 114, 'EG': 217, 'NO': 97, > 'DK': 77, 'RS': 444}}]}] i want to make a dictionary with country data like this: > {'PK': 100, 'AT': 151, 'SK': 81, 'RO': 488, 'BE': 367, 'ID': 91, 'MX': > 82, 'GB': 2063, 'CY': 1820, 'TN': 92, 'NL': 418, 'ES': 230, 'RU': 99, > 'CZ': 188, 'AR': 105, 'BD': 80, 'PH': 144, 'AU': 550, 'GE': 178, 'GR': > 273321, 'CO': 98} what should i do? i cannot use the following code data['value'] as i could in an ordinary dictionary
<python><list><dictionary>
2016-07-06 23:02:50
LQ_EDIT
38,235,447
error: ‘Board::Board’ names the constructor, not the type Board::Board; C++
<p>All right so here is the code where the error is,</p> <p>Board::Board {</p> <p>}</p> <p>so, what makes this not compile? </p>
<c++>
2016-07-06 23:31:20
LQ_CLOSE
38,235,613
ECMAScript 6 alternatives to collapse and responsible Bootstrap menus?
<p>I'm trying to create some responsible hamburger menus in Bootstrap 4 without jQuery, relying only on ECMAScript 6 and it's features. I wasn't able to find alternatives to Bootstrap's collapse.js and animation.js, so i decided to tackle this myself.</p> <p>What is the preferred way of manipulating the DOM and animating the changes in ES6? </p>
<javascript><twitter-bootstrap><ecmascript-6>
2016-07-06 23:50:15
LQ_CLOSE
38,237,439
Route object validation as props in React
<p>What is the correct way to validate route props in React class?</p> <p>I tried:</p> <ul> <li><code>route: React.PropTypes.object</code> - my eslint complains: <em>Prop type <code>object</code> is forbidden react/forbid-prop-types</em> </li> <li><code>route: React.PropTypes.instanceOf(React.propTypes)</code> - this results in a warning at runtime: <em>Right-hand side of 'instanceof' is not callable Check the render method of bla</em></li> </ul> <p>We have the policy to validate props enforced by eslint rules, how can I validate route object?</p> <p>My code: </p> <pre><code>var bla = React.createClass({ displayName: 'bla', propTypes: { route: React.PropTypes.object, }) class RootRoute extends React.Component { render() { return ( &lt;Router history={hashHistory}&gt; &lt;Route path="/" component={bla}/&gt; &lt;/Router&gt; ); } } </code></pre>
<reactjs><react-router>
2016-07-07 04:13:27
HQ
38,237,663
Mongo Atlas: Connection authentication failed with custom databases
<p>I am trying the Mongo Atlas Cloud. I create a cluster and i am trying a connection with the mongo shell: (same problem with mongo drivers)</p> <pre><code>mongo mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=****-Cluster-shard-0 --ssl --username ***** --password ***** </code></pre> <p>this is the connection string in the documentation. And this is the error:</p> <pre><code>MongoDB shell version: 3.2.7 connecting to: mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=***-Cluster-shard-0 2016-07-07T01:31:17.535-0300 I NETWORK [thread1] Starting new replica set monitor for ***-Cluster-shard-0/***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017 2016-07-07T01:31:17.535-0300 I NETWORK [ReplicaSetMonitorWatcher] starting 2016-07-07T01:31:20.084-0300 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20 @(auth):6:1 @(auth):1:2 exception: login failed </code></pre> <p>I can connect to the database only when i use admin database "/admin?" in the connection string. </p> <p>THE PROBLEM:</p> <p>I need to connect to a custom database with the console or mongo drivers.</p> <p>PD: i protect my data with "***"</p>
<node.js><mongodb><mongoose>
2016-07-07 04:43:59
HQ
38,237,673
How to Hide an API Key in Client-Side Javascript
<p>Right now I am writing a client-side javascript app that makes a request to the USPS Price Calculator API. In order to make this request, I need to provide my API User ID in the xml of the request. The tag looks like this: <code>&lt;RateV4Request USERID="ThisIsWhereMyUserIdGoes"&gt;</code>. My question is this: is there any way I can provide my user ID to the javascript, while still hiding it from users who look at the client-side files. Right now, the only solution I have is to create a PHP file in my server that has the User ID, then using an AJAX request in the client-side javascript to store it in a global variable. It looks like this:</p> <pre><code>var userID; $.get("/secrets.php", function( data ) { userID = data; }); </code></pre> <p>Is this an adequate way of keeping my API User ID from being seen by the users of my app? What else could I do?</p>
<javascript><php><jquery><api>
2016-07-07 04:44:51
HQ
38,237,919
implementing Runnable acts different compared to extending Thread
I'm trying to learn how multithreading works. This is the example code I have: public class Processor extends Thread { private boolean running = true; public void run() { while (running) { System.out.println("Hello there!"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } public void shutDown() { running = false; } } public class ProcessorDemo { public static void main(String[] args) { Processor proc1 = new Processor(); proc1.start(); System.out.println("Press return to stop"); Scanner sc = new Scanner(System.in); sc.nextLine(); proc1.shutDown(); } } The problem occurs, when I implement Runnable instead of extending Thread - the code difference public class Processor implements Runnable // in ProcessorDemo Thread proc1 = new Thread(new Processor()); What happens is, the code gives an error, saying: "The method shutDown() is undefined for the type Thread" Why is this happening, when both ways of creating Threads should give the same result? Thanks everyone :)
<java><multithreading><runnable>
2016-07-07 05:12:06
LQ_EDIT
38,237,942
cron expression in AWS CloudWatch: How to run once a week
<p>In Amazon AWS CloudWatch it is possible to run a rule according to a schedule that is defined in a cron expression.</p> <p>The rules for this are outlined <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/ScheduledEvents.html" rel="noreferrer">here</a>.</p> <p>After some trying around, I wasn't able to compose an expression that will run <strong>once a week</strong> (e.g. at 4 pm on Sunday). The following attempts were rejected by CloudWatch with the message <code>Parameter ScheduleExpression is not valid..</code>.</p> <pre><code>0 16 * * SUN * 0 16 * * 6 * 0 16 * * SUN-SUN * 0 16 * * 6-6 * </code></pre>
<amazon-web-services><cron><cloudwatch>
2016-07-07 05:14:39
HQ
38,238,107
expected a component class, got [object Object]
<p>I get an error with this code. However, changing to react-native's removes the error. Can you use div with react-native? If not, why is this error so obscure...?</p> <pre><code>var React = require('react'); var ReactNative = require('react-native'); var { StyleSheet, Text, View, } = ReactNative; let Auto = React.createClass({ getInitialState: function() { return { value: 'Ma' } }, render: function() { return ( &lt;div className="fuck-react"&gt; Blah blah blah &lt;/div&gt; ) } </code></pre> <p>});</p>
<react-native>
2016-07-07 05:30:23
HQ
38,238,144
how to use python-numpy-brodcasting
I have a trouble with python broadcasting there is two numpy list x = np.array([1,2,3],[4,5,6]) y = np.array([0,1,1]) I'd like to calculate x : [[1,2,3], [4,5,6]] to x : [[1 - y[0],2-y[1],3-y[2]],[4 - y[0],5-y[1],6-y[2]]] that is, x : [[0,-3,-3], [3,0,0]] at one time. Please, let me know how to do that.
<python><numpy><array-broadcasting>
2016-07-07 05:34:26
LQ_EDIT
38,238,503
Which Java Version required for Junit 4.1
<p>Working with Cucumber FrameWork, Need to know Which Java Version required for Junit 4.1 version</p>
<java><junit><version><cucumber-junit>
2016-07-07 06:05:17
LQ_CLOSE
38,239,852
Ealuate jQuery code nested in the object when object is used
I have a JS object like: { 'element1':{'redirectURI' : 'abc.php?toDate='+encodeURIComponent(jQuery('.dateField1').val())}, 'element2':{'redirectURI' : 'pqr.php?&toDate='+encodeURIComponent(jQuery('.dateField2').val())} }; I need the **redirectURI** index to be evaluated when the object is used i.e. when `obj['element1']['redirectURI']` or `obj['element2']['redirectURI']`. How to achieve this? Right now `jQuery('.dateField2').val()` takes the value available when this object is parsed,the date field is a datepicker whose value can vary. Thanks.
<javascript><jquery>
2016-07-07 07:31:58
LQ_EDIT
38,239,980
Measure full page size in Chrome DevTools
<p>I've been googling for some time but haven't found any clear solution for this.</p> <p>I want to measure full webpage weight / size (all doucment + scripts + fonts + styles etc.). I know the network tab in the devtools has size/content - but I want to have it summed (and not sum it every time).</p> <p>I've been looking for chrome.devtools.* API but haven't found anything straight-forward. </p> <p>Do you have some ideas how to achieve that?</p>
<google-chrome><web><google-chrome-devtools><performance-testing>
2016-07-07 07:39:44
HQ
38,240,452
I want to compare the rows in table and find mismatches in SQL server 2008
[enter image description here][1] [1]: http://i.stack.imgur.com/SnhyU.png I want the query which can pull last three rows with all columns and with another column which specifies type of mismatch i.e. accounting, currency..etc. can any one help me with this?
<sql><sql-server><sql-server-2008>
2016-07-07 08:06:37
LQ_EDIT
38,240,844
HADOOP INSTAllATION ERROR ON RUNNING COMMAND FORMATING NAMENODE
I'm installing hadoop on remote server(centos) I've installed hadoop successfully in local mode and trying to install it in pseudo-distributed mode but after all the configuration changes in core-site.xml and mapred-site.xml when i run hdfd namenode -format i get following errors: [][1] [1]: http://i.stack.imgur.com/9bzWg.png
<java><hadoop><hadoop2>
2016-07-07 08:31:32
LQ_EDIT
38,240,859
How to get a versionName in react-native app on Android?
<p>I've made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get versionName in code?</p>
<android><react-native>
2016-07-07 08:32:13
HQ
38,240,943
How to trigger a jenkins build on specific node using pipeline plugin?
<p>I have a Jenkins pipeline job called "TestPipeline". I want to trigger a build on 2 different slaves which labeled "tester1' and "tester2". And the pipeline script is quite simple here:</p> <pre><code>node('tester1') { build 'test_job' } node('tester2') { build 'test_job' } </code></pre> <p>However when I run the TestPipeline job, the "test_job" won't run on the nodes which I assigned. But run on random node instead. </p> <p>I'm wondering if I should set "Restrict where this project can be run" on my "test_job". So I set it to "tester" (The "tester" label contains both node "tester1" and "tester2"). But when I run the pipeline job again, the "test_job" runs on "tester2" twice. I should expect the job to run on "tester1" first and then run on "tester2". Why is that? Is it because the "node" step doesn't matter when it comes to which node the build step should be built on?</p>
<jenkins><jenkins-pipeline>
2016-07-07 08:37:23
HQ
38,241,850
when i manually execute the garbage collector, how can I tell when it's completed?
<p>I'm writing a web server application using NodeJS 6.3.0. the application is executed with <code>--expose-gc</code> parameter, so I have the <code>global.gc()</code> function available. the question is how can I know when the manual execution of the garbage collector completed.</p> <p>is global.gc() a synchronous function and that means that the next line of code will be executed when the function completed it task?</p> <p>can I somehow monitor when my specific execution of garbage collector completed?</p> <p>thanks!</p>
<node.js><garbage-collection>
2016-07-07 09:23:58
HQ
38,242,584
Clear all queryParams with new Router v3 Angular2
<p>I'm trying to figure out how to use the Angular2 router navigation (router 3.0.0-alpha.7) with query parameters.</p> <p>I can easily navigate to a route with a queryParam with this line:</p> <pre><code>this._router.navigate(['/login'], {queryParams: {redirect: 'route1'}}); </code></pre> <p>In the '/login' component, I do some login which will redirect to the <code>redirect</code> route, namely route1 here. However, after the redirection, the <code>redirect</code> query parameters stays in the URL, i.e. I'm now at page <code>/route1?redirect=route1</code>. I want to remove the redirect parameter here.</p> <p>Moreover, if I then navigate to another page with the same <code>redirect</code> queryParam, it doesn't overwrite the previous one, but adds another <code>?redirect=...</code> in the url. Namely:</p> <pre><code>this._router.navigate(['/another-route'], {queryParams: {redirect:'route2'}}); </code></pre> <p>leads me to <code>/another-route?redirect=route2?redirect=route1</code></p> <p>Is it possible to clear the queryParams when navigating between routes? I tried <code>this._router.navigate(['/route1'], {queryParams: {redirect: null}});</code>, or <code>{queryParams: null}</code> etc but no success.</p>
<angular><angular2-routing>
2016-07-07 09:58:08
HQ
38,243,085
Private getter and public setter for a Kotlin property
<p>How to make a property in Kotlin that has a private getter (or just do not have it) but has a public setter?</p> <pre><code>var status private get </code></pre> <p>doesn't work with an error: <code>Getter visibility must be the same as property visibility</code></p> <p>In my case, the reason is for Java interop: I want my Java code to be able to call <code>setStatus</code> but not <code>getStatus</code>.</p>
<java><kotlin><kotlin-interop>
2016-07-07 10:23:41
HQ
38,243,162
why javaScript behave like synchronous without web api call
I know javaScript is asynchronous by nature. So that when I call a function with web API It performs asynchronous. setTimeout(function(){ console.log('1'); }, 2000); console.log('2'); it will print '2' then '1' but when I run a loop like for loop and increase the iteration It executes synchrounous var first = function(){ for(var i=0;i<=100000000;i++){ if(i==100000000){ console.log('first') }; }; }; var second = function() { console.log('second') }; var a = function() { first(); second(); } a(); It will print the first second respectively. > So, is javaScript perform synchronously with native code
<javascript><asynchronous><dom-events>
2016-07-07 10:28:12
LQ_EDIT
38,243,381
How to set up filter chain in spring boot?
<p>I have come across spring-boot and intend to add a filter chain for incoming request.</p> <p>Here is the Application:</p> <pre><code>package example.hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @SpringBootApplication public class Application { public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(Application.class, args); } } </code></pre> <p>Here is the Controller:</p> <pre><code>package example.hello; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.concurrent.atomic.AtomicLong; @RestController public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); @RequestMapping("/greeting") public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) { return new Greeting(counter.incrementAndGet(), String.format(template, name)); } } </code></pre> <p>Here is the Filter Config:</p> <pre><code>package example.hello; import org.springframework.boot.context.embedded.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class WebConfig { @Bean public FilterRegistrationBean greetingFilterRegistrationBean() { FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setName("greeting"); GreetingFilter greetingFilter = new GreetingFilter(); registrationBean.setFilter(greetingFilter); registrationBean.setOrder(1); return registrationBean; } @Bean public FilterRegistrationBean helloFilterRegistrationBean() { FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setName("hello"); HelloFilter helloFilter = new HelloFilter(); registrationBean.setFilter(helloFilter); registrationBean.setOrder(2); return registrationBean; } } </code></pre> <p>Here is the HelloFilter and Greeting Filter:</p> <pre><code>package example.hello; import javax.servlet.*; import java.io.IOException; public class HelloFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println("HelloFilter!"); } @Override public void destroy() { } } package example.hello; import javax.servlet.*; import java.io.IOException; public class GreetingFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println("Greetings from filter!"); } @Override public void destroy() { } } </code></pre> <p>When I start the application and run <code>curl localhost:8080/greeting</code>, Only "Greetings from filter" is received and the <code>HelloFilter</code> is not invoked.</p> <p>Besides there is no response from <code>Greeting Controller</code>. It seems that the <code>GreetingFilter</code> blocks the procedure.</p> <p>So how to set the filter chain in Spring boot. Are there any bugs in the code above?</p>
<java><spring><spring-boot><servlet-filters>
2016-07-07 10:40:12
HQ
38,243,926
How to build Neural Network in Spark?
<p>The flow should be:</p> <p>Input -> Word2Vectors -> Output -> NeuralNetwork</p> <p>I have tried word2vec function of spark but I am confused with the format "MultilayerPerceptronClassifier" need as a input?</p>
<scala><apache-spark><neural-network><word2vec>
2016-07-07 11:07:14
LQ_CLOSE
38,244,414
php: data from mysql changing from no data into zero
i have this table of "score" in my database <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> ! id ! A ! ----------------- ! 01 ! 10 ! ! 02 ! ! ! 03 ! ! ! 04 ! 5 ! <!-- end snippet --> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> $mySql = "SELECT score.id, score.A FROM score ORDER BY score.id ASC"; $myQry = mysql_query($mySql, $koneksidb) or die ("Query salah : ".mysql_error()); while ($myData = mysql_fetch_array($myQry)) { $id=$myData['id']; $A=$myData['A'];} <!-- end snippet --> when i call with <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <?php echo $A; ?> <!-- end snippet --> it came out with zero instead of no data, <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> ! id ! A ! ----------------- ! 01 ! 10 ! ! 02 ! 0 ! ! 03 ! 0 ! ! 04 ! 5 ! <!-- end snippet --> what should i change?
<php><mysql>
2016-07-07 11:34:37
LQ_EDIT
38,244,585
How Do choose to have an element removed from a list in R?
Say I have a list consisting of a range of integers from 1-10 with repetition and I want to remove all the 0s from that list, is there an easy way to go abouts doing that? Something like na.omit but for my choice of elements? Thank you
<r><subset>
2016-07-07 11:42:30
LQ_EDIT
38,245,414
Django Rest framework, how to include '__all__' fields and a related field in ModelSerializer ?
<p>I have two models, one with M2M relation and a related name. I want to include <strong>all</strong> fields in the serializer and the related field.</p> <p>models.py:</p> <pre><code>class Pizza(models.Model): name = models.CharField(max_length=50, unique=True) toppings = models.ManyToManyField(Topping, null=True, blank=True, related_name='pizzas') class Topping(models.Model): name = models.CharField(max_length=50, unique=True) price = models.IntegerField(default=0) </code></pre> <p>serializer.py:</p> <pre><code>class ToppingSerializer(serializers.ModelSerializer): class Meta: model = Topping fields = '__all__' </code></pre> <p>This works but it doesn't include the related field.</p> <pre><code> fields = ['name', 'price', 'pizzas'] </code></pre> <p>This works exactly as I want, but what happens when Toppings model has a lot of fields. I want to do something like :</p> <pre><code>fields = ['__all__', 'pizzas'] </code></pre> <p>This syntax results in an error saying:</p> <blockquote> <p>Field name <code>__all__</code> is not valid for model</p> </blockquote> <p>Is there a way to achieve the wanted behavior? Or the fields must be typed manually when using a related name ?</p>
<django><django-models><django-rest-framework>
2016-07-07 12:24:49
HQ
38,246,183
Group multiple views into one view in Android
For example, if I have: EditText A; TextView B; ImageView C; And I want to set all their visibilities to `View.GONE`, how can I do it in a way that instead of this: A.setVisibility(View.GONE); B.setVisibility(View.GONE); C.setVisibility(View.GONE); I do this: groupD.setVisibility(View.GONE); without having to put all of them in one `RelativeLayout` and then setting the `RL` to `View.GONE`?
<java><android><android-view>
2016-07-07 13:01:38
LQ_EDIT
38,246,360
How can I take integer regex in Python?
I'm trying to use regex in Python for taking some parts of a text. From a text I need to take this kind of substring '2012-048984'. So what's the equivalent regex? Thank you very much.
<python><regex><integer>
2016-07-07 13:08:54
LQ_EDIT
38,246,476
Lower-bounded wild card causes trouble in javac, but not Eclipse
<p>This piece of code compiles in Eclipse but not in javac:</p> <pre class="lang-java prettyprint-override"><code>import java.util.function.Consumer; public class Test { public static final void m1(Consumer&lt;?&gt; c) { m2(c); } private static final &lt;T&gt; void m2(Consumer&lt;? super T&gt; c) { } } </code></pre> <p>javac output:</p> <pre class="lang-none prettyprint-override"><code>C:\Users\lukas\workspace&gt;javac -version javac 1.8.0_92 C:\Users\lukas\workspace&gt;javac Test.java Test.java:5: error: method m2 in class Test cannot be applied to given types; m2(c); ^ required: Consumer&lt;? super T&gt; found: Consumer&lt;CAP#1&gt; reason: cannot infer type-variable(s) T (argument mismatch; Consumer&lt;CAP#1&gt; cannot be converted to Consumer&lt;? super T&gt;) where T is a type-variable: T extends Object declared in method &lt;T&gt;m2(Consumer&lt;? super T&gt;) where CAP#1 is a fresh type-variable: CAP#1 extends Object from capture of ? 1 error ---------------------------------------------------------------- </code></pre> <p>Which compiler is wrong and why? (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=497380">Eclipse bug report and parts of discussion here</a>)</p>
<java><eclipse><generics><java-8><javac>
2016-07-07 13:15:06
HQ
38,246,624
Show Specific Value
<p>This is the code i try but when i select an item it show some array ouput i just want the specific value that i selected. like white-house</p> <pre><code> &lt;select id="item"&gt; &lt;option value=""&gt;Please select&lt;/option&gt; &lt;option value="white-house"&gt;The White House&lt;/option&gt; &lt;/select&gt; &lt;div id="results"&gt;&lt;/div&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; function makeAjaxRequest(opts){ $.ajax({ type: "POST", data: { opts: opts }, url: "tryonly.php", success: function(res) { $("#results").html("&lt;p&gt; " + res + "&lt;/p&gt;"); } }); } $("#item").on("change", function(){ var selected = $(this).val(); makeAjaxRequest(selected); }); &lt;/script&gt; </code></pre> <p>In php code</p> <pre><code>&lt;?php echo '&lt;pre&gt;'; print_r($_POST); echo '&lt;/pre&gt;'; ?&gt; </code></pre> <p>the output when i select item </p> <pre><code>Array ( [opts] =&gt; white-house ) </code></pre>
<php><ajax>
2016-07-07 13:21:29
LQ_CLOSE
38,247,163
Variable/Path in VB script
VB script syntax pains me greatly compared to Powershell, but I have to use it for this. How to insert my Script Path Variable into powershell script path path. Also anyone know any Visual Studio Like tool I can write those? I think visual studio uses different .net vbs. Here is the Code SCRIPT_PATH = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - (Len(WScript.ScriptName))) msgbox SCRIPT_PATH Set objShell = CreateObject("WScript.Shell") objShell.Run "RUNAS /user:Domain\User ""powershell SCRIPT_PATH & Delete_App_Script.ps1""" Set objShell = Nothing How do I do SCRIPT_PATH = SCRIPT_PATH + Delete_App_Script.ps1 ? It gives no errors, so I am not sure what is the problem. Am I missing some "" or some ,, ? I seen some .Run ,,, syntax for Admin running and This one. Doesn't explain what goes into "". Not looking forward creating interface for this. Thank for your help
<vbscript>
2016-07-07 13:46:17
LQ_EDIT
38,247,362
How I can use docker-registry with login/password?
<p>I have my docker-registry in localhost and I can pull/push with command: <code>docker push localhost:5000/someimage</code> How I can push it with command like <code>docker push username@password:localhost:5000/someimage</code>?</p>
<docker><docker-registry>
2016-07-07 13:55:15
HQ
38,247,440
when to go for new string instead of string literal in java
<p>I know when we use <code>String s = new String("abc");</code> JVM will create the object in heap and when we use <code>String s = "abc";</code> the object gets created in String constant pool.</p> <p>IMO, using <code>String s = "abc";</code> serves our purpose. In which case we have to go for <code>new String("abc");</code></p>
<java>
2016-07-07 13:58:52
LQ_CLOSE
38,248,629
Java Swing Error with format (I think)
I can't solve this, Note that I'm new to swing, thanks. http://prntscr.com/bpz2ve http://hastebin.com/oyucefasah.java
<java><swing><compiler-errors>
2016-07-07 14:50:36
LQ_EDIT
38,248,903
notifyicon in visual studio 2015 missing
<p>I have a WPF application and I'm trying to send it to notification tray following the instructions in this page <a href="http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm" rel="nofollow">http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm</a></p> <p>But I cannot find the NotifyIcon control in Toolbox. Is there a new control for doing this task?</p>
<c#><wpf>
2016-07-07 15:02:26
LQ_CLOSE
38,249,019
Web API optional parameters
<p>I have a controller with the following signature:</p> <pre><code>[Route("products/filter/{apc=apc}/{xpc=xpc}/{sku=sku}")] public IHttpActionResult Get(string apc, string xpc, int? sku) { ... } </code></pre> <p>I call this method with following URIs:</p> <ul> <li>~/api/products/filter?apc=AA&amp;xpc=BB</li> <li>~/api/products/filter?sku=7199123</li> </ul> <p>The first URI works without issue. The second one has a strange side effect. Even though the default values for apc and xpc should be null when not provided, the parameters are actually their names. I can overcome this by adding the additional logic:</p> <pre><code>apc = (apc == "apc") ? null : apc; xpc = (xpc == "xpc") ? null : xpc; </code></pre> <p>This seems like a hack, and would be problematic if value passed was ever equal to the parameter name. </p> <p>Is there a way to define the Route without this side effect? </p>
<c#><asp.net-web-api><asp.net-web-api2>
2016-07-07 15:06:55
HQ
38,249,970
How to import android.support.v7.app.NotificationCompat.Builder class in Android Studio
<p>I am trying to implement simple notifications in my android app. I am reffering this <a href="https://developer.android.com/guide/topics/ui/notifiers/notifications.html" rel="noreferrer">developer guide</a> </p> <p><strong>But getting this error message :</strong> </p> <pre><code>Incompatible types. Required: android.support.v7app.NotificationCompat.Builder Found: android.support.v4.app.Notification.Compat.Builder </code></pre> <p><a href="http://i.stack.imgur.com/fBG5r.png" rel="noreferrer">Error Message screenshot</a></p> <p><strong>For the following code snippet :</strong></p> <pre><code>NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("My notification") .setContentText("Hello World!"); </code></pre> <p><strong>Here are my imports :</strong></p> <pre><code>import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.app.NotificationCompat; import android.view.View; import android.widget.Button; </code></pre> <p>I think the correct <code>NotificationCompat</code> class is imported. I am using <code>Android Studio v2.1.2</code> for development. Please help me with this error message. I am new to android programming and java.</p>
<java><android><android-studio>
2016-07-07 15:50:42
HQ
38,250,336
How can I add a style tag in the header with jade/pug?
<p>I want something like this:</p> <pre><code>html head style(type="text/css") table { width: 100% } body table </code></pre> <p>But can't find the right incantation. This results in an "unexpected text" error. I tried escaping the css with a |, to no avail; and the best I've achieved so far is getting a table tag rendered in the header :(</p> <p>Is it possible to do this with jade/pug?</p>
<pug>
2016-07-07 16:07:41
HQ
38,250,963
Dictionary Contain NSNULL Swift
Is there any way to detect that Dictionary contain NSNull Value. Is there any way to detect that Dictionary contain NSNull Value.
<ios><swift><nsdictionary>
2016-07-07 16:41:29
LQ_EDIT
38,251,031
React Why Unmount Component Slow
<p>I have a component that wraps a bunch of ReactList components. ReactList component is a component that does infinite scrolling ie only load what's on viewport. It has couple of modes: simple and uniform. I'm using simple which just loads and loads as you scroll down (making the scrollable page longer). Uniform loads and removes the above section that is now out of viewport. I tried using uniform mode, and if it worked I wouldn't even need to ask what I'm about to, but it's super buggy and defeats the purpose. Simple on the other hand is super fast scrolling and loading is equally fast.</p> <p>I broken down my list into few groups where user can click and it will load that ReactList component. If the scrollable page is short, ie, user hasn't scrolled all the way down, changing between the group of lists is fast enough. ~2s. However, if the page is scrolled all the way down, and trying to change list takes ~6s.</p> <p>I noticed that the page is fully loaded too, ie nothing more to load. So okay, I think maybe if I change the key for the wrapper parent component and just remount the component, it should be fast right? Nope. The component that reloads is short, only one viewport length, but it takes around ~5s.</p> <p>I noticed changing out of the fully loaded list component page to just regular single line text "Hello world" component still took around the same amount! ~5s. What's up with that?</p> <p><strong>QUESTION: Why is unmounting a long page with many small components in a list take so long to just unmount?</strong></p> <p>Sorry I realize this is long and full of text but I thought I should explain my situation.</p>
<javascript><reactjs>
2016-07-07 16:45:29
HQ
38,251,205
Check if user has scrolled to the bottom in Angular 2
<p>What is the best practice to check if user has scrolled to the bottom of the page in Angular2 without jQuery? Do I have access to the window in my app component? If not should i check for scrolling to the bottom of the footer component, and how would I do that? A directive on the footer component? Has anyone accomplished this?</p>
<angular><angular2-template><angular2-directives>
2016-07-07 16:55:45
HQ
38,251,409
How can I suppress Thread Sanitizer warnings in Xcode from an external library?
<p>Xcode 8 incorporates the Thread Sanitizer, a tool for detecting race conditions and other threading-related issues. </p> <p>I'm trying to run this against a project of mine, and am detecting many issues with a third-party binary library. These issues are overwhelming any ones in my own code, and I can't replace the binary library until the vendor fixes it.</p> <p>How can I suppress these Thread Sanitizer warnings in Xcode for a third-party library?</p>
<xcode><thread-sanitizer>
2016-07-07 17:07:00
HQ
38,252,453
Serving mp3 files using the webpack file loader
<p>I have a problem with getting my mp3 files to work using the webpack file loader.</p> <p>This is the issue:</p> <p>I have a mp3 file on my harddisk, that if I open using chrome by for example "c:\somefolder\somemp3file.mp3" opens up in a tab in the browser and plays just fine.</p> <p>However, when I serve the exact same file using webpack it does not work. I have configured the loader in webpack like this:</p> <pre><code>{ test: /\.(gif|jpg|png|mp3|aac|ogg)$/, loader: 'file' } </code></pre> <p>Then, when I'm trying to link to the file I require it inside my javascript, like this:</p> <pre><code>require('file!./../content/somemp3file.mp3'); </code></pre> <p>this correctly returns me the url for the mp3 file.</p> <p>If I try to manually go to <code>localhost:8080</code> followed by the url returned by require, the mp3 player in Chrome pops up like I expect it to, but the file cannot be played, and it's not possible to click on the play button like the file is corrupted or something. </p> <p>Anyone knows what I'm doing wrong here?</p>
<webpack><mp3><webpack-file-loader>
2016-07-07 18:09:07
HQ
38,252,735
Timer for sending request at some time period
<p>I have specific trouble: I'm using Yandex.Disk cloud storage and working with this by Yandex.Disk REST API. I have some functionality for syncing data and saving to db. Specially it's file name, file md5, file download url. But trouble is that download url is temporary. And I'm looking for solution, to have ability for apdating download url for all saved in db files, each 24 hours. First solution I found is another project that will be launching by windows task scheduler, but my hosting provider not giving this ability. Help me please to find good solution for this. </p>
<c#><asp.net-mvc><razor>
2016-07-07 18:23:32
LQ_CLOSE
38,252,967
Privacy policy link Google Play
<p>I am having trouble here, this is my first app and there is so much involved, I did not think it was this hard, currenctly I am stuck on adding a link to my app's <code>PRIVACY POLICY</code> my app is very simple, it does not share any data but I do use google's analytics, one more thing is that I do not have a website so supposedly I had the privacy policy link where would I put it apart from a site I own? </p>
<android><google-play><privacy-policy>
2016-07-07 18:37:59
HQ
38,253,000
Is it necessary to create couple program OpenGL?
<p>I'm learning OpenGL and want to create simple program. I want to render different meshes with different shaders. Should I recreate program or I must reuse created program? (program - shader program, created by calling glCreateProgram)</p>
<c++><c><opengl><opengl-es-2.0>
2016-07-07 18:40:15
LQ_CLOSE
38,253,018
python 3.5 : quit a if loop (or other loops)
<p>When running the program, the user is asked to input a number. If the number is 1, quit the program. If the number is not 1, print the number. </p> <p>I wonder how to realize this. </p> <p>I am using python 3.5.</p> <p>My code is like this. I always get an error: <code>'break' outside loop</code></p> <p>How can I fix this?</p> <pre><code>x = input('Please input a number: ') if x == '1': print('quit') break else: continue print(x) </code></pre>
<python><python-3.x>
2016-07-07 18:40:55
LQ_CLOSE
38,253,385
Building a row from a dict in pySpark
<p>I'm trying to dynamically build a row in pySpark 1.6.1, then build it into a dataframe. The general idea is to extend the results of <code>describe</code> to include, for example, skew and kurtosis. Here's what I thought should work:</p> <pre><code>from pyspark.sql import Row row_dict = {'C0': -1.1990072635132698, 'C3': 0.12605772684660232, 'C4': 0.5760856026559944, 'C5': 0.1951877800894315, 'C6': 24.72378589441825, 'summary': 'kurtosis'} new_row = Row(row_dict) </code></pre> <p>But this returns <code>TypeError: sequence item 0: expected string, dict found</code> which is a fairly clear error. Then I found that if I defined the Row fields first, I <em>could</em> use a dict:</p> <pre><code>r = Row('summary', 'C0', 'C3', 'C4', 'C5', 'C6') r(row_dict) &gt; Row(summary={'summary': 'kurtosis', 'C3': 0.12605772684660232, 'C0': -1.1990072635132698, 'C6': 24.72378589441825, 'C5': 0.1951877800894315, 'C4': 0.5760856026559944}) </code></pre> <p>Which would be a fine step, except it doesn't seem like I can dynamically specify the fields in <code>Row</code>. I need this to work for an unknown number of rows with unknown names. According to the documentation you can actually go the other way:</p> <pre><code>&gt;&gt;&gt; Row(name="Alice", age=11).asDict() == {'name': 'Alice', 'age': 11} True </code></pre> <p>So it seems like I should be able to do this. It also appears there may be some deprecated features from older versions that allowed this, for example <a href="https://spark.apache.org/docs/1.0.2/api/python/pyspark.sql.Row-class.html" rel="noreferrer">here</a>. Is there a more current equivalent I'm missing?</p>
<python><apache-spark><pyspark>
2016-07-07 19:02:33
HQ
38,253,607
Creating a UserManager outside of built in dependency injection system
<p>This is using asp.net core with identity and entity framework core. I working on a saas application where I have a separate admin web app where you can add new tenants to the system. After a tenant is creates the app creates a default database (database per tenant set up) for the new tenant. I want to add a default user to this new database but I'm struggling with creating user manager outside of the dependency injection system.</p> <p>The admin web app uses the usermanager that is created in the startup.cs (via the built in DI system) as the manager for the admin app. When I go to add the user to the new tenants database I am not using the DI system I just want to create a UserManager with the IdentityDbContext associated with the connection string for the new tenants database.</p> <p>I'm am using this after a new tenant is created in the admin app:</p> <pre><code>public class TenantDbInitializer { private Tenant tenant; private ApplicationDbContext context; private UserManager&lt;ApplicationUser&gt; userManager; public TenantDbInitializer(Tenant tenant) { this.tenant = tenant; } public void Init() { // tenant contains connection string context = new ApplicationDbContext(tenant); var userStore = new UserStore&lt;ApplicationUser&gt;(context); userManager = new UserManager&lt;ApplicationUser&gt;(......... } } </code></pre> <p>The UserManager construction parameters contain items that I can't find examples on what instances I should use. Some of the interfaces appear to have default implementations but I'm not sure if this is the way to proceed (or to pass null). The constructor is:</p> <pre><code> public UserManager(IUserStore&lt;TUser&gt; store, IOptions&lt;IdentityOptions&gt; optionsAccessor, IPasswordHasher&lt;TUser&gt; passwordHasher, IEnumerable&lt;IUserValidator&lt;TUser&gt;&gt; userValidators, IEnumerable&lt;IPasswordValidator&lt;TUser&gt;&gt; passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger&lt;UserManager&lt;TUser&gt;&gt; logger) </code></pre> <p>Looking at the identity source it appears that I can pass null in for some of these parameters but I want to make sure I understand what is going on here so I don't do anything incorrectly.</p> <p>The source for user manager is here: <a href="https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/UserManager.cs" rel="noreferrer">https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/UserManager.cs</a></p> <p>Thanks, Brian</p>
<asp.net-core><identity>
2016-07-07 19:16:03
HQ
38,253,758
Superclass/Subclass methods
<p>I have a situation</p> <pre><code>public class Animal { String noise; public String makeNoise() { return noise; } } </code></pre> <p>Then there will be a subclass with the concrete definition of the noise.</p> <pre><code>public class Dog extends Animal{ String noise = "woof"; } </code></pre> <p>also</p> <pre><code>public class Cat extends Animal{ String noise = "meow"; } </code></pre> <p>What I want to do is</p> <pre><code> Animal cat = new Cat(); cat.makeNoise(); // This will be 'meow' </code></pre> <p>and </p> <pre><code>Animal dog = new Dog(); dog.makeNoise(); // This will be 'woof' </code></pre> <p>Basically, I don't want to repeat the makeNoise() method when I create an animal. However, this will not work. (Noise is an empty string)</p> <p>I could use a static object like </p> <pre><code>static String NoiseDog = "woof" static String NoiseCat = "meow" </code></pre> <p>but then again I have to write the makeNoise() method for each animal. Is there a better way to architect this?</p>
<java><oop><inheritance>
2016-07-07 19:26:24
LQ_CLOSE
38,254,516
AWS SNS workaround for 100,000 topics limit
<p>I am developing an architecture for push notifications using AWS SNS with APNS and GCM. The model that I am following is</p> <ul> <li>Each user (not device) will have an SNS topic corresponding to it</li> <li>Each user can have multiple devices</li> <li>Create an platform application endpoint for each device</li> <li>Subscribe the platform application endpoint to the topic belonging to the device's user</li> </ul> <p>This way, when we have to send a notification to all the devices of a user, we need to call the <code>publish</code> method using the user's <code>topicArn</code> and all its devices should get the message.</p> <p>However, by default AWS has a limit of 100,000 topics. If we are anticipating higher number of users like 1 million or say 10 million to be optimistic, is there any workaround for this approach?</p> <p>Should I ask AWS to raise the limit beforehand? Do they raise limit to a number like 100 million easily? Is there any cost implication of most of them are not used in the beginning few months? </p>
<amazon-web-services><amazon-sns>
2016-07-07 20:17:34
HQ
38,255,291
Retrofit 2.0 - How to get response body for 400 Bad Request error?
<p>So when I make a POST API call to my server, I get a 400 Bad Request error with JSON response.</p> <pre><code>{  "userMessage": "Blah", "internalMessage": "Bad Request blah blah", "errorCode": 1 } </code></pre> <p>I call it by </p> <pre><code>Call.enqueue(new Callback&lt;ResponseBody&gt;() { @Override public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) { //AA } @Override public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) { //BB } } </code></pre> <p>However the problem is that once I get the response, onFailure() is invoke so that //BB is called. Here, I have no way to access the JSON response. When I log the api request and response, it doesn't show JSON response at all. And Throwable t is IOException. However, strangely, when I make the same call on Postman, it does return the expected JSON response with 400 error code. </p> <p>So my question is how can I get the json response when I get 400 Bad Request error? Should I add something to okhttpclient?</p> <p>Thanks</p>
<android><retrofit>
2016-07-07 21:08:25
HQ
38,255,379
onCreateView dialogfragment
So i created an fragment and there's a button inside it when clicked it pop an dialogfragment, so my problem is it crashed when i run it public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_one, container, false); Button off = (Button) getActivity().findViewById(R.id.btnOff); off.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { OneFragment.this.onOff(View v);//error here } }); return view; } public void onOff(View v){ new OffButton().show(getFragmentManager(),"off"); }
<android><android-fragments>
2016-07-07 21:13:57
LQ_EDIT
38,255,655
Trying to pull files from my Github repository: "refusing to merge unrelated histories"
<p>I'm learning git, and I'm following the Git community book. </p> <p>Previously (long time ago) I made a public repository on Github, with some files. Now I set up a local Git repository on my current computer, and committed some files. Then I added a remote pointing to my Github page:</p> <pre><code>[root@osboxes c]# git remote add learnc https://github.com/michaelklachko/Learning-C </code></pre> <p>That seemed to be successful: </p> <pre><code>[root@osboxes c]# git remote show learnc * remote learnc Fetch URL: https://github.com/michaelklachko/Learning-C Push URL: https://github.com/michaelklachko/Learning-C HEAD branch: master Remote branch: master tracked Local ref configured for 'git push': master pushes to master (local out of date) </code></pre> <p>Now I want to download the files from my Github repo to my computer. I did this:</p> <pre><code>[root@osboxes c]# git fetch learnc [root@osboxes c]# git merge learnc/master warning: refname 'learnc/master' is ambiguous. Already up-to-date. </code></pre> <p>However, I don't see any new files in my local directory. How can I get them? </p> <p>I also tried to do this:</p> <pre><code>[root@osboxes c]# git pull learnc master From https://github.com/michaelklachko/Learning-C * branch master -&gt; FETCH_HEAD fatal: refusing to merge unrelated histories </code></pre> <p>BTW, locally I'm on master branch (there are no other branches):</p> <pre><code>[root@osboxes c]# git status On branch master nothing to commit, working directory clean </code></pre>
<git><github><git-pull><git-fetch>
2016-07-07 21:33:49
HQ
38,255,732
If statement not evaluating all the conditions and executing anyway
<p>Ok so I am new to python and trying to learn how to code. I ran into an issue today that I don't understand. So this code executes as expected and prints the largest of the three numbers no matter what position the largest number is.</p> <pre><code> if num1 &gt;= num2 and num3: print(num1, 'Is the greatest number!') elif num2 &gt;= num3 and num1: print(num2, 'Is the greatest number!') else: print(num3, 'Is the greatest number') </code></pre> <p>But if i change the elif statement to this:</p> <pre><code> elif num2 &gt;= num1 and num3: print(num2, 'Is the greatest number!') </code></pre> <p>Even if num3 is the largest the else statement will not execute and it will display the larger number of num1 or num2. </p>
<python>
2016-07-07 21:40:06
LQ_CLOSE
38,256,135
Why won't this python game work with point and damage counters?
def match_duel(): print "do you want to swing right or left" print "and for how many points?" choice = raw_input("> ") points = 0 damage = 0 if "right" in choice: print "you take a swing right. 20 points." points = points + 20 print "You have %d points" % points match_duel() elif "left" in choice: print "you take a swing left. 50 points." points = points + 50 print "You have %d points" % points match_duel() elif "hard right" in choice: print "you take a hard swing right for 100 points." print "cthulhu strikes back with 100 points." print "you take half the damage." points = points + 100 damage = damage - 50 print "You have %d points" % points print "You have %d damage" % damage match_duel() elif "hard left" in choice: print "you take a hard swing left for 200 points." print "cthulhu strikes back with 50 points, taken by surprise." print "you take half the damage" points = points + 200 damage = damage - 25 print "You have %d points" % points print "You have %d damage" % damage match_duel() else: print "take an extended hit." points = points + 300 print "You have %d points" % points The two latter elif statements won't work; it simply redirects me to either of the previous two. And for the else statement, it won't print the number of points.
<python><conditional>
2016-07-07 22:15:53
LQ_EDIT
38,256,972
How to customize look/feel of React Native ListView's RefreshControl
<p>React Native's ListView has a built-in pull-to-refresh control called <a href="https://facebook.github.io/react-native/docs/refreshcontrol.html" rel="noreferrer">RefreshControl</a>. It's super easy to use.</p> <p>I'd like to customize the look and feel of the control to use a different visual design, such as using a material design progress indicator.</p> <p>How can I customize the look of the RefreshControl in React Native?</p>
<react-native>
2016-07-07 23:48:25
HQ