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
36,648,625
Measure time of query in Mongo
<p>How can I measure execution time of query in MongoDB ? I found Mongo-hacker plugin but it looks like it measure time of query including time of displaying all results. In PostgreSQL I use Explain Analyze SELECT ... , but i didn't found any information about time in mongo's db.collection.find({smth}).explain()</p>
<mongodb><time><sql-execution-plan>
2016-04-15 13:32:59
HQ
36,649,653
What is the use of "or" operator with integers
<p>I am not getting what <code>or</code> operator does with inters. I have following code</p> <pre><code>-1||4 // output -1 4||-1 //output 4 </code></pre> <p>Does it converts integers in bytes and performs or operation. </p>
<javascript><or-operator>
2016-04-15 14:18:01
LQ_CLOSE
36,649,795
Is it possible to import an HTML file as a string with TypeScript?
<p>I wonder if it is possible to do as the title said.</p> <p>For example let's say we are working on a Angular2 project and we want to avoid set the template as an external url in order to have less http requests. Still we don't want to write all the HTML within the component because maybe it's big enough or we want designers to work in different files than devs.</p> <p>So here is a first solution:</p> <p>File <strong><em>template.html.ts</em></strong> Transform a file to .ts to something like this:</p> <pre><code>export const htmlTemplate = ` &lt;h1&gt;My Html&lt;/h1&gt; `; </code></pre> <p>Then in my component I can import it like this:</p> <pre><code>import { Component } from 'angular2/core'; import {RouteParams, RouterLink} from 'angular2/router'; import {htmlTemplate} from './template.html'; @Component({ selector: 'home', directives: [RouterLink], template: htmlTemplate, }) </code></pre> <p>Actually this works perfectly but you are loosing the IDE HTML intelligence so this is bad for the designer/dev that creates the HTML templates.</p> <p>What I'm trying to achieve is to find a way to import <strong><em>.html</em></strong> files and not .ts.</p> <p><strong>So is it possible to import an .html file as a string in TypeScript?</strong></p>
<javascript><html><import><typescript><angular>
2016-04-15 14:24:06
HQ
36,650,052
Golang equivalent of npm install -g
<p>If I had a compiled Golang program that I wanted to install such that I could run it with a bash command from anywhere on my computer, how would I do that? For example, in nodejs</p> <pre><code>npm install -g express </code></pre> <p>Installs express such that I can run the command</p> <pre><code>express myapp </code></pre> <p>and express will generate a file directory for a node application called "myapp" in whatever my current directory is. Is there an equivalent command for go? I believe now with the "go install" command you have to be in the directory that contains the executable in order to run it</p> <p>Thanks in advance!</p>
<go><npm><bin><npm-install><goinstall>
2016-04-15 14:35:19
HQ
36,650,287
How to remove # from URL in Aurelia
<p>Can anybody please explain in step by step manner, how can we remove # from URL in Aurelia</p>
<aurelia>
2016-04-15 14:45:28
HQ
36,650,312
How to Grab stdClass Object Result
<p>can i ask ? . I have class cURL POST into a website ( API Integration ) , and if i post with class. The result is (i use print_r) :</p> <pre><code>stdClass Object ( [order] =&gt; 200029 ) 1 </code></pre> <p>How to grab [order] value?</p>
<php>
2016-04-15 14:46:31
LQ_CLOSE
36,650,522
Custom Cordova Plugin: Add framework to "Embedded Binaries"
<p>In a custom Cordova plugin, how can I config a specific .framework file in plugin.xml such that it will be added to the "Embedded Binaries" section in Xcode? If that's not currently possible directly in plugin.xml, I'm open to alternative suggestions.</p>
<ios><xcode><cordova><cordova-plugins>
2016-04-15 14:56:42
HQ
36,650,570
How to update object in React state
<p>I have an indexed list of <code>users</code> in the JS object (not array). It's part of the React state.</p> <pre><code>{ 1: { id: 1, name: "John" } 2: { id: 2, name: "Jim" } 3: { id: 3, name: "James" } } </code></pre> <p>What's the best practice to:</p> <ol> <li>add a new user { id: 4, name: "Jane" } with id (4) as key</li> <li>remove a user with id 2</li> <li>change the name of user #2 to "Peter"</li> </ol> <p>Without any immutable helpers. I'm using Coffeescript and Underscore (so _.extend is ok...).</p> <p>Thanks.</p>
<javascript><reactjs><coffeescript>
2016-04-15 14:58:58
HQ
36,650,642
did you specify the right host or port? error on Kubernetes
<p>I have followed the helloword tutorial on <a href="http://kubernetes.io/docs/hellonode/" rel="noreferrer">http://kubernetes.io/docs/hellonode/</a>. </p> <p>When I run:</p> <pre><code>kubectl run hello-node --image=gcr.io/PROJECT_ID/hello-node:v1 --port=8080 </code></pre> <p>I get: The connection to the server localhost:8080 was refused - did you specify the right host or port?</p> <p>Why do the command line tries to connect to localhost? </p>
<kubernetes>
2016-04-15 15:02:11
HQ
36,651,091
How to install packages in Linux (CentOS) without root user with automatic dependency handling?
<p>Is it possible to use RPM or YUM or any other package manager in Linux, specifically CentOS, to install a package either already downloaded or from repo to a custom location without admin/root access?</p> <p>I tried building from sources, using cmake, configure, make, make install etc, but, it ended up having so many dependencies one after other.</p> <p>Or are there any better alternatives?</p>
<linux><centos><rpm><yum><package-managers>
2016-04-15 15:23:27
HQ
36,651,240
How to use Fragment in an activity - giving lots of errors
<p>This is the <code>ImageActivity.java</code> </p> <pre><code>package com.example.app6; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.widget.FrameLayout; public abstract class ImageActivity extends FragmentActivity { private ExampleFragment mFragment; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout frame = new FrameLayout(this); if (savedInstanceState == null) { mFragment = new ExampleFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(frame.getId(), mFragment).commit(); } setContentView(frame); } } </code></pre> <p>and this is <code>ExampleFragment.java</code></p> <pre><code>package com.example.app6; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; public class ExampleFragment extends Activity { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Button button = new Button(getActivity()); button.setText("Hello There"); return button; } } </code></pre> <p>Now both the files are giving me errors. In ExampleFragment, </p> <blockquote> <p>cannot resolve methos 'getActivity()'</p> </blockquote> <p>and in ImageActivity, </p> <blockquote> <p>cannot resolve method 'add(int, com.example.app6.ExampleFragment)'</p> </blockquote> <p>I am new to Android, thats why I don't have much knowledge about it. Please help me out. Thanks in Advance :)</p>
<java><android><android-activity><android-fragmentactivity>
2016-04-15 15:29:37
LQ_CLOSE
36,651,989
How to create a bot in my website that checks if the user is really online or offline and update his status in the database
<p>U want the bot ro check every 30 seconds to every single user if they are really online and offline by sending a request and if the bot dont get any respond after 20 sexonds they will update the status on the satabase ro offline. Like $con->query("UPDATE users SET status='offline' WHERE username='$username'); I want the bot to check on all users online. Offline users dont need to be checked. It doesnt need to ne a super modded bot. I just need the simplest form of a bot that can perform the following actions. </p>
<php><jquery>
2016-04-15 16:07:50
LQ_CLOSE
36,652,364
I need to create a batch file which will copy a file on multiple servers
<p>Basically this batch file will keep track of changes made by users and it will update the changes on multiple server. Is this feasible to update file on multiple servers</p>
<batch-file>
2016-04-15 16:27:16
LQ_CLOSE
36,652,691
How to get the names of songs in a directory using Javascript
<p>There is a directory in my server where there are lots of mp3 and ogg files. And there is a player in my site that gets an array of those songs in that directory and play them. The array should be defined like this:</p> <pre><code>[ 'song1', 'song2', 'song3', 'songx' ] </code></pre> <p>How can I get the name of those songs like this array using javascript in my template?</p> <p>Thanks in advance</p>
<javascript><arrays>
2016-04-15 16:46:53
LQ_CLOSE
36,652,746
Where are Run configurations stored?
<p>Run Liclipse 2.5.3 on Mac OS. I renamed my project. I lost all my run configurations. When i recreate one, it says the file exists. However there are no run configurations present. </p> <p>Where are the run configs stored</p>
<eclipse><macos><pydev><liclipse>
2016-04-15 16:50:24
HQ
36,653,126
Send request over WiFi (without connection) even if Mobile data is ON (with connection) on Android M
<p>I have to send UDP packets to a WiFi module (provided with own AP) with no internet connection but when I connect the mobile with the AP, Android redirects my packets on the mobile data interface because it has got internet connection.</p> <p>I've used the code below to do my job but it seems not working on Android M.</p> <pre><code>@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setWifiInterfaceAsDefault() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkRequest.Builder builder = new NetworkRequest.Builder(); NetworkRequest networkRequest= builder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .build(); connectivityManager.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback()); } </code></pre> <p>I've also added</p> <pre><code>&lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.WRITE_SETTINGS" /&gt; </code></pre> <p>on my AndroidManifest.xml and I ensured myself that <code>Settings.System.canWrite(this)</code> returns <code>true</code> but still nothing.</p> <p>Thanks in advance.</p>
<android><networking><android-wifi><android-6.0-marshmallow><iot>
2016-04-15 17:12:40
HQ
36,653,519
How do I get the size (width x height) of my pygame window
<p>I have created a window using</p> <pre><code>pygame.display.set_mode((width, height), pygame.OPENGL | pygame.DOUBLEBUF | pygame.RESIZABLE) </code></pre> <p>Later on in the app I want to be able to ask that window its width and height so I can decide how to process the mouse position.</p> <p>How do I access the dimensions of that pygame window elsewhere in the program? (event processing loop)</p>
<python><pygame>
2016-04-15 17:35:23
HQ
36,654,990
Error building xwalk with cordova android
<p>Building a cordova app with xwalk and it's no longer working.</p> <p>ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk JAVA_HOME=C:\Program Files\Java\jdk1.8.0_77 Reading build config file: f:\source\Cutter\Canvasser\build.json null embedded org.xwalk:xwalk_core_library:15+</p> <p>FAILURE: Build failed with an exception.</p> <ul> <li>What went wrong: A problem occurred configuring root project 'android'. <blockquote> <p>Could not resolve all dependencies for configuration ':_armv7DebugCompile'. Could not resolve org.xwalk:xwalk_core_library:15+. Required by: :android:unspecified Failed to list versions for org.xwalk:xwalk_core_library. Unable to load Maven meta-data from <a href="https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml">https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml</a>. Could not GET '<a href="https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml">https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml</a>'. Connection to <a href="http://127.0.0.1:8888">http://127.0.0.1:8888</a> refused Failed to list versions for org.xwalk:xwalk_core_library. Unable to load Maven meta-data from <a href="https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml">https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml</a>. Could not GET '<a href="https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml">https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml</a>'.</p> </blockquote></li> </ul> <p>BUILD FAILED</p> <p>Total time: 4.251 secs</p> <blockquote> <p>Connection to <a href="http://127.0.0.1:8888">http://127.0.0.1:8888</a> refused</p> </blockquote> <p>Can anyone help? I don't understand why it's a maven repository which can't be found.</p>
<cordova><cordova-plugins><crosswalk>
2016-04-15 19:02:20
HQ
36,655,104
Spring Boot Localization issue - Accept-Language header
<p>We are using Spring Boot for the application. In ApplicationConfig.java I have the below code</p> <pre><code> @Bean public LocaleResolver localeResolver() { return new SmartLocaleResolver(); } </code></pre> <p>and the SmartLocaleResolver.java is below</p> <pre><code>public class SmartLocaleResolver extends SessionLocaleResolver { @Override public Locale resolveLocale(HttpServletRequest request) { final String acceptLanguage = request.getHeader("Accept-Language"); if (acceptLanguage.contains(",")) { String[] aheader = acceptLanguage.split(",[ ]*"); for (String locale : aheader) { if (ApplicationConstants.LOCALE.contains(locale)) { locale.trim(); return Locale.forLanguageTag(locale); } } } else if (!acceptLanguage.contains(",") &amp;&amp; !acceptLanguage.isEmpty()) { if (ApplicationConstants.LOCALE.contains(acceptLanguage)) { return Locale.forLanguageTag(acceptLanguage); } } return request.getLocale(); } } </code></pre> <p>and I have in my constants class the below to compare the value from header Accept-Language.</p> <p>public static final List LOCALE = Collections .unmodifiableList(Arrays.asList("en", "es"));</p> <p>I know in actual scenario the header will be like Accept-Language : fr,es;q=0.8,en-us;q=0.6 but for testing purpose i'm passing it as below.</p> <p>Accept-language : fr,es,en</p> <p>The code is not complete yet, but i'm just testing from postman to see if the code picks up "es" as the locale and gives me the localized result.</p> <p>I don't have messages_fr.properties file but I have messages_es.properties so I expect if the application sets the locale from the below code, it would pick Locale as 'es' and give the values I want in Spanish. What changes I need to make here for the code to work? </p>
<java><spring><rest><localization><spring-boot>
2016-04-15 19:09:17
HQ
36,655,732
pre-increment and post-increment in C
<p>First of all, I would like to apologize, if this question has been asked before in this forum. I searched, but could't find any similar problem.</p> <p>I am a beginner in C. I was going through a tutorial and came across a code, the solution of which I can't understand. </p> <p>Here is the code - </p> <pre><code>#include &lt;stdio.h&gt; #define PRODUCT(x) (x*x) int main() { int i=3, j, k; j = PRODUCT(i++); k = PRODUCT(++i); return 1; } </code></pre> <p>I tried running the code through compiler and got the solution as "j = 12" and "k = 49". </p> <p>I know how #define works. It replace every occurrence of PRODUCT(x) by (x*x), but what I can't grasp is how j and k got the values 12 and 49, respectively. </p> <p>Any help would be appreciated. </p> <p>Thank you for your time.</p>
<c>
2016-04-15 19:51:09
LQ_CLOSE
36,656,867
How to .gitignore app/app.iml in Android Studio project?
<p>No matter how I structure my .gitignore I can't seem to ignore app/app.iml via Android Studio 2.0.0.</p> <p>So far, I've tried ignoring all *.iml files per the github's standard Android Studio .gitignore template, as well as targeting the file directly..</p> <pre><code>app/app.iml *.iml </code></pre> <p>Anybody run into a similar issue with this specific file or other *.iml files? How did you resolve it?</p>
<android><android-studio><gitignore>
2016-04-15 21:09:44
HQ
36,656,895
Remove navigation bar on Xamarin Forms app with Caliburn.Micro
<p>When using the <code>FormsApplication</code> base class with a brand new Xamarin.Forms app using Caliburn.Micro, I end up with an empty navigation bar at the top of my screen. I assume it's being created by Caliburn.Micro somehow, because an out-of-the-box Xamarin.Forms app doesn't have that.</p> <p>Is there any way I can use Caliburn.Micro with Xamarin.Forms without this navigation bar?</p>
<xamarin.forms><caliburn.micro>
2016-04-15 21:11:39
HQ
36,657,458
How to version and separate Service Fabric applications?
<p>All of the service fabric <a href="https://github.com/Azure-Samples/service-fabric-dotnet-getting-started">examples</a> depict single-solution service fabric examples. This seems to go <em>counter</em> to the philosophy of microservices, where you want complete dependency isolation between your services. While you can manually follow this pattern, the more common practice is to enforce it by making each service it's own repository and solution/project.</p> <p>How do you manage and deploy service fabric services, and enforce service contracts (ServiceInferfaces) using multiple solutions (in multiple Git repositories)?</p> <p>E.g.</p> <pre><code>Service Fabric Solution App1 - Customers - Service1 [Carts] From Other Solution - Service2 [LocationInfo]From Other Solution - Service3 [REST WebAPI for Admin] From Other Solution App2 - Products - Service4 [Status]From Other Solution - Service5 [Firmware]From Other Solution - Service6 [Event Stream] From Other Solution External Solution - Service1 External Solution - Service2 External Solution - Service3 External Solution - Service4 External Solution - Service5 External Solution - Service6 </code></pre> <p>1) As a developer, I want to check out and build all the current versions of apps/services. I want to fire up my Service Fabric project that manages all the manifests, and deploy it to my local dev cluster. I want to enforce the same service interfaces between solutions. I don't understand how you'd do this, because the application is external to the services. </p> <p>2) As a DevOps team, I want to automate pulling down the apps, building them and deploying to Azure. </p> <p>How do we "enforce" isolation via separate solutions, but make it easy to pull them together and deploy into the cluster, while also making it easy to make pipelines to deploy each cluster configured uniquely for DEV, QA, and PROD environments. </p> <p>What is the workflow/process/project structure to enable this? Is it even possible?</p>
<c#><.net><visual-studio><azure><azure-service-fabric>
2016-04-15 21:53:51
HQ
36,657,644
How do i save the values from a huffman codification
im doing a huffman compression in c++ using opencv, i already have the codes for the tones of grey, but im confused about what to do with it, is there a way to replace the values in the image? do I have to create other mat? ps. My huffman codes are strings, do i need to change them?
<c++><opencv><huffman-code>
2016-04-15 22:09:34
LQ_EDIT
36,657,944
creating a matching card game (javascript)
I want to create a matching card game and I have an issue in showing the images that suppose to be hidden. When I click on a card, the path of the image will show instead of the actual image. here is all the codes I have wrote: <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <style type="text/css"> div#card_board { background: #ccc; border: #999 1px solid; width: 710px; height: 600px; padding: 24px; margin: 0px auto; } div#card_board > div { background: url(cardQtion.jpg) no-repeat; background-size: 100%; border: #000 1px solid; width: 114px; height: 132px; float: left; margin: 10px; padding: 20px; font-size: 64px; cursor: pointer; text-align: center; } </style> <script> var cardArray = new Array(); cardArray[0] = new Image(); cardArray[0].src = 'cardA.jpg'; cardArray[1] = new Image(); cardArray[1].src = 'cardA.jpg'; cardArray[2] = new Image(); cardArray[2].src = 'cardB.jpg'; cardArray[3] = new Image(); cardArray[3].src = 'cardB.jpg'; cardArray[4] = new Image(); cardArray[4].src = 'cardC.jpg'; cardArray[5] = new Image(); cardArray[5].src = 'cardC.jpg'; cardArray[6] = new Image(); cardArray[6].src = 'cardD.jpg'; cardArray[7] = new Image(); cardArray[7].src = 'cardD.jpg'; cardArray[8] = new Image(); cardArray[8].src = 'cardE.jpg'; cardArray[9] = new Image(); cardArray[9].src = 'cardE.jpg'; cardArray[10] = new Image(); cardArray[10].src = 'cardF.jpg'; cardArray[11] = new Image(); cardArray[11].src = 'cardF.jpg'; var cardVal = []; var cardIDs = []; var cardBackFace = 0; Array.prototype.cardMix = function () { var i = this.length, j, temp; while (--i > 0) { j = Math.floor(Math.random() * (i + 1)); temp = this[j]; this[j] = this[i]; this[i] = temp; } } function newBoard() { cardBackFace = 0; var output = ""; cardArray.cardMix(); for (var i = 0; i < cardArray.length; i++) { output += '<div id="card_' + i + '" onclick="cardBackcard(this,\'' + cardArray[i].src + '\')"></div>'; } document.getElementById('card_board').innerHTML = output; } function cardBackcard(tile, val) { if (tile.innerHTML == "" && cardVal.length < 2) { tile.style.background = '#FFF'; tile.innerHTML = val; if (cardVal.length == 0) { cardVal.push(val); cardIDs.push(tile.id); } else if (cardVal.length == 1) { cardVal.push(val); cardIDs.push(tile.id); if (cardVal[0] == cardVal[1]) { cardBackFace += 2; cardVal = []; cardIDs = []; if (cardBackFace == cardArray.length) { alert("Board cleared... generating new board"); document.getElementById('card_board').innerHTML = ""; newBoard(); } } else { function card2Back() { var card_1 = document.getElementById(cardIDs[0]); var card_2 = document.getElementById(cardIDs[1]); card_1.style.background = 'url(cardQtion.jpg) no-repeat'; card_1.innerHTML = ""; card_2.style.background = 'url(cardQtion.jpg) no-repeat'; card_2.innerHTML = ""; cardVal = []; cardIDs = []; } setTimeout(card2Back, 700); } } } } </script> </head> <body> <div id="card_board"></div> <script>newBoard();</script> </body> </html>
<javascript>
2016-04-15 22:39:05
LQ_EDIT
36,657,973
how to insert a colon in between string as like date formats in c++
I have string 20150410 121416 in c++ output- 20150410 12:14:16 how can i insert a colon to the string.Can anyone please help me out.
<c++><string>
2016-04-15 22:41:13
LQ_EDIT
36,658,250
Convert list of tuples w/ lenght 5 to dictionary in Python
<p>what if I have a tuple list like this:</p> <pre><code>list = [('Ana', 'Lisbon', 42195, '10-18', 2224), ('Eva', 'New York', 42195, '06-13', 2319), ('Ana', 'Tokyo', 42195, '02-22', 2403), ('Eva', 'Sao Paulo', 21098, '04-12', 1182), ('Ana', 'Sao Paulo', 21098, '04-12', 1096), ('Dulce', 'Tokyo', 42195, '02-22', 2449), ('Ana', 'Boston', 42195, '04-20', 2187)] </code></pre> <p>How can I convert this to a dictionary like this one?</p> <pre><code>dict = {'Ana': [('Ana', 'Lisboa', 42195, '10-18', 2224),('Ana', 'Toquio',42195, '02-22', 2403), ('Ana', 'Sao Paulo', 21098, '04-12', 1096),('Ana', 'Boston', 42195, '04-20', 2187)], 'Dulce': [('Dulce', 'Toquio', 42195, '02-22', 2449)], 'Eva': [('Eva', 'Nova Iorque', 42195, '06-13', 2319), ('Eva', 'Sao Paulo', 21098, '04-12', 1182)]} </code></pre>
<python><dictionary><tuples>
2016-04-15 23:11:46
LQ_CLOSE
36,658,280
Play local Video in webview
<p>I want to play local videos in crosswalk webview. I'm getting the video path from an intent opening my activity, so it could be stored internally or on sd card. </p> <p>Using this url <code>file:///storage/emulated/0/Download/movies/movie.mp4</code> i get <code>Failed to load resource: net::ERR_ACCESS_DENIED</code>.</p> <p>Using input file dialog with <code>URL.createObjectURL(file);</code> it works. But because i know the path, i dont want to select it again manually. Setting the value of input file is forbidden.</p> <p>Creating a url using the path is also not possible, because it needs file or blob.</p> <p>Because of possible big filesize its not possible to temporarily copy it to sd card.</p> <p>This gives me file not found error:</p> <pre><code>@Override public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) { if(url.contains("file:///storage")){ try { return new WebResourceResponse("video/*", "UTF-8", new FileInputStream(url)); } catch (FileNotFoundException e) { e.printStackTrace(); } } return super.shouldInterceptLoadRequest(view, url); } </code></pre> <p>also i have defined <code>&lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;</code></p> <p>other questions on stackoverflow asking for accessing assets, so i created this new question</p>
<android><video><webview>
2016-04-15 23:15:32
HQ
36,658,508
Nested For Loop in C# to print below mentioned pattern
I wanting to print 1 23 456 78910 in C# Console application, Can any one help in doing it for me
<c#>
2016-04-15 23:46:20
LQ_EDIT
36,658,991
Enumerate Dictionary.Values vs Dictionary itself
<p>I was exploring the sources of ASP.NET core on GitHub to see what kind of tricks the ASP.NET team used to speed up the framework. I saw something that intrigued me. In the source code of the <a href="https://github.com/aspnet/DependencyInjection/blob/dev/src/Microsoft.Extensions.DependencyInjection/ServiceProvider.cs" rel="noreferrer">ServiceProvider</a>, in the Dispose implementation, they enumerate a dictionary, and they put a comment to indicate a performance trick :</p> <pre><code>private readonly Dictionary&lt;IService, object&gt; _resolvedServices = new Dictionary&lt;IService, object&gt;(); // Code removed for brevity public void Dispose() { // Code removed for brevity // PERF: We've enumerating the dictionary so that we don't allocate to enumerate. // .Values allocates a KeyCollection on the heap, enumerating the dictionary allocates // a struct enumerator foreach (var entry in _resolvedServices) { (entry.Value as IDisposable)?.Dispose(); } _resolvedServices.Clear(); } </code></pre> <p>What is the difference if the dictionary is enumerated like that ?</p> <p></p> <pre><code>foreach (var entry in _resolvedServices.Values) { (entry as IDisposable)?.Dispose(); } </code></pre> <p>It has a performance impact ? Or it's because allocate a <a href="https://msdn.microsoft.com/en-us/library/x8bctb9c(v=vs.110).aspx" rel="noreferrer">ValueCollection</a> will consume more memory ?</p>
<c#><.net><dictionary><asp.net-core><.net-core>
2016-04-16 00:53:05
HQ
36,659,224
How to append a list to an existing list of lists?
<p>If I have a list of lists <code>[[1,1,1,1],[2,2,2,2]]</code> how do I add a 3rd list <code>[3,3,3,3]</code> to it to make it <code>[[1,1,1,1],[2,2,2,2],[3,3,3,3]]</code></p>
<python>
2016-04-16 01:33:34
LQ_CLOSE
36,659,457
Python print syntax error couldnt find error
<p>I'm writing a python program to find the chi-square value of a set of data I'm running into a syntax error in the following chunk of code:<br></p> <pre><code>obs1 = int(input("") print("Observed Number 2: (OR SIMPLY PRESS ENTER TO CONTINUE) ") obs2 = int(input("") if obs2 == "": </code></pre> <p>The IDE is giving me a syntax error for <code>print</code>, and when i deleted print to see if that it ran well w/o it, i ran into another syntax error with <code>obs2</code> Could someone look over the code and tell me what they think? <br> Thank you</p>
<python><python-3.x><math><syntax-error>
2016-04-16 02:18:02
LQ_CLOSE
36,659,471
Modify style of 'Pay with Card' Stripe button
<p>Is it possible to modify style of "Pay with Card" Stripe button? I've tried modifying by,</p> <ul> <li>adding a new class defined in external style sheet</li> <li>modifying its own class of <code>stripe-button</code> in external style sheet</li> <li>and editing it inline with <code>style=""</code></li> </ul> <p>But I cannot get the button to change its style.</p> <p>It looks like it might be possible with the <code>custom integration</code> instead of the <code>simple integration</code> (source: <a href="https://stripe.com/docs/checkout#integration-simple" rel="noreferrer">https://stripe.com/docs/checkout#integration-simple</a>), but I was hoping there was something simpler.</p> <p><strong>Button with default style:</strong></p> <p><a href="https://i.stack.imgur.com/pAyUB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pAyUB.png" alt="enter image description here"></a></p> <p>Does anyone have experience with this?</p> <p>(I'm integrating into Ruby on Rails if that makes any difference.)</p>
<css><stripe-payments>
2016-04-16 02:20:54
HQ
36,659,694
I'm new to Programming , Learning java from new boston but while practicing stuck here
Was trying to make a sorting program of integers entered by user and wanted it to take as many integer user wants, without first asking how many int he wanna sort , but while taking input it just crashes , **basically the problem is it is not storing values in array** import java.util.Scanner; class apple { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int j = 0; int[] arr; arr = new int[j]; while (true) { arr[j] = scan.nextInt(); if (arr[j]=='\n'){break;} j++; arr = new int[j]; } for(j = 0 ;j < arr.length ;j++){ System.out.print(arr[j] + " "); } } }
<java>
2016-04-16 03:09:33
LQ_EDIT
36,659,741
why is my CountRecur method not working, ive tried to comb through it but no dice.
why is my CountRecur method not working, ive tried to comb through it but no dice. I know its not all that well optimized, but ive tried everything and i thought i might give this a shot. //* assume that StrArr1 is already in alphabetical order, and that all the strings in it are words that may occur more than once, they're also all in low caps. the remove recur works fine, i tested it//* public void CountRecur() { ArrayList <String> StrArr2 = new ArrayList <String> (); StrArr2 = StrArr1; this.RemoveRecur(StrArr2); int count = 0; int j = 0; for (int i = 0; i <= StrArr2.size(); i++) { if (count != 0) { IntArr.add(count); } count = 0; if (i < StrArr2.size()) { while (j < StrArr1.size() && StrArr2.get(i).equals(StrArr1.get(j))) { count++; j++; } } } } public void RemoveRecur(ArrayList <String> StrArr3) { int i = 1; while (i < StrArr3.size()) { if (StrArr3.get(i).equals(StrArr3.get(i - 1))) { StrArr3.remove(i - 1); i = 0; } i++; } }
<java><for-loop><arraylist><count><recurrence>
2016-04-16 03:18:54
LQ_EDIT
36,660,024
Write a program in java to print the sum of all numbers from 50 to 250(inclusive of 50 and 250) that are multiples of 3 and not divisible by 9.
/* when I run this code there is no error in fact output generated is also correct but I want to know what is the logical error in this code? please can any one explain what is the logical error. */ class abc { public static void main(String arg[]){ int sum=0; //for-loop for numbers 50-250 for(int i=50;i<251;i++){ // condition to check if number should be divided by 3 and not divided by 9 if(i%3==0 & i%9!=0){ //individual number which are selected in loop System.out.println(i); //adding values of array so that total sum can be calculated sum=sum+i; } } //final display output for the code System.out.println("the sum of intergers from 50 to 250 that are multiples of 3 and not divisible by 9 \n"+sum); } }
<java><arrays>
2016-04-16 04:11:52
LQ_EDIT
36,660,866
Javascript encryption that match with PHP decryption
<p>I have the php code as below, and I want to create a Javascript functions that work the same as the php code below. Also, the data that encrypted in Javascript can also decrypt in php. `</p> <pre><code>&lt;?php class Security { public static function encrypt($input, $key) { $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $input = Security::pkcs5_pad($input, $size); $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $key, $iv); $data = mcrypt_generic($td, $input); mcrypt_generic_deinit($td); mcrypt_module_close($td); $data = base64_encode($data); return $data; } private static function pkcs5_pad ($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); return $text . str_repeat(chr($pad), $pad); } public static function decrypt($sStr, $sKey) { $decrypted= mcrypt_decrypt( MCRYPT_RIJNDAEL_128, $sKey, base64_decode($sStr), MCRYPT_MODE_ECB ); $dec_s = strlen($decrypted); $padding = ord($decrypted[$dec_s-1]); $decrypted = substr($decrypted, 0, -$padding); return $decrypted; } } ?&gt; </code></pre> <p>`</p>
<javascript><php><encryption>
2016-04-16 06:20:50
LQ_CLOSE
36,661,331
How to put a simple passsword on SQLIte database like other database?
I am asking about just put password not encryption using [SQLClipher][1] or SEE or AES but when I want to access file I need come password like 'VISHAL' or Nothing else [1]: https://www.zetetic.net/sqlcipher/
<android><sqlite>
2016-04-16 07:19:29
LQ_EDIT
36,661,830
Request.Files in ASP.NET CORE
<p>I am trying to upload files using aspnet core using ajax request . In previous versions of .net i used to handle this using </p> <pre><code> foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[fileName]; //Save file content goes here fName = file.FileName; (...) </code></pre> <p>but now its showing error at request.files how can i get it to work ? i searched and found that httppostedfile has been changed to iformfile but how to handle request.files?</p>
<asp.net><ajax><file><upload><asp.net-core>
2016-04-16 08:15:47
HQ
36,661,927
how to find application builder in apex 5 to build first application
I got started with oracle apex 5 and lately finished apex installation, I want to start building first application.. I found in apex documentation that I should start with application builder but I didn't find it in my environment. when I login to apex the environment appears as in this image.[enter image description here][1] [1]: http://i.stack.imgur.com/kHFto.jpg
<oracle><oracle-apex>
2016-04-16 08:27:22
LQ_EDIT
36,662,065
webpack-dev-server proxy dosen't work
<p>I want to proxy /v1/* to <a href="http://myserver.com" rel="noreferrer">http://myserver.com</a>, and here is my script</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> devServer: { historyApiFallBack: true, // progress: true, hot: true, inline: true, // https: true, port: 8081, contentBase: path.resolve(__dirname, 'public'), proxy: { '/v1/*': { target: 'http://api.in.uprintf.com', secure: false // changeOrigin: true } } },</code></pre> </div> </div> </p> <p>but it doesn't work, <a href="https://i.stack.imgur.com/BanoH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BanoH.png" alt="enter image description here"></a></p>
<webpack><http-proxy><webpack-dev-server>
2016-04-16 08:45:06
HQ
36,662,305
Help to using Switch case in c++?
How do I use switch case in this code ?? I have tried several times , But I really do not know how to make it without error . I don't know anywhere i put it ?? #include<iostream.h> int x,y; int sum(int a,int b) { int c; c = a+b; return (c); } int sub (int a ,int b) { int c; c = a-b ; return (c); } int multi ( int a, int b ) { int c ; c = a*b; return (c); } float div ( int a , int b) { float c; c = a/b ; return (c); } main() { cout<<"enter the value of x = "; cin>>x; cout<<"enter the value of y = "; cin>>y; cout<<"x + y = "<< sum(x,y); cout<<"\n x - y = "<< sub(x,y); cout<<"\n x * y = "<< multi(x,y); cout<<"\n x /y = "<< div (x,y); cin>>"\n"; }
<c++><switch-statement>
2016-04-16 09:14:04
LQ_EDIT
36,662,738
How do I find the square root of the negative integer -16 or the numbers that it is a multiple of with a while loop
<p>I am more interested in finding out why this doesn't work</p> <pre><code>x = -16 ans = -1 ans2 = 1 while (ans*ans2 &gt; x): ans = ans - 1 ans2 = ans + 1 print ans, ans2 </code></pre>
<python>
2016-04-16 10:07:51
LQ_CLOSE
36,662,871
i want to parse this json in php plz help me
//i want to parse this json in php ,,plz help //i don't know how to parse it.. stdClass Object ( [coord] => stdClass Object ( [lon] => 138.93 [lat] => 34.97 ) [weather] => Array ( [0] => stdClass Object ( [id] => 803 [main] => Clouds [description] => broken clouds [icon] => 04n ) ) [base] => stations [main] => stdClass Object ( [temp] => 290.738 [pressure] => 1026.59 [humidity] => 94 [temp_min] => 290.738 [temp_max] => 290.738 [sea_level] => 1035.92 [grnd_level] => 1026.59 ) [wind] => stdClass Object ( [speed] => 6.81 [deg] => 225.502 ) [clouds] => stdClass Object ( [all] => 56 ) [dt] => 1460799951 [sys] => stdClass Object ( [message] => 0.0131 [country] => JP [sunrise] => 1460751040 [sunset] => 1460798268 ) [id] => 1851632 [name] => Shuzenji [cod] => 200 )
<php><json>
2016-04-16 10:22:14
LQ_EDIT
36,663,645
Finding the minimum and maximum value within a Metal texture
<p>I have a <code>MTLTexture</code> containing 16bit unsigned integers (<code>MTLPixelFormatR16Uint</code>). The values range from about 7000 to 20000, with 0 being used as a 'nodata' value, which is why it is skipped in the code below. I'd like to find the minimum and maximum values so I can rescale these values between 0-255. Ultimately I'll be looking to base the minimum and maximum values on a histogram of the data (it has some outliers), but for now I'm stuck on simply extracting the min/max.</p> <p><em>I can read the data from the GPU to CPU and pull the min/max values out but would prefer to perform this task on the GPU.</em></p> <p><strong>First attempt</strong></p> <p>The command encoder is dispatched with 16x16 threads per thread group, the number of thread groups is based on the texture size (eg; width = textureWidth / 16, height = textureHeight / 16).</p> <pre><code>typedef struct { atomic_uint min; atomic_uint max; } BandMinMax; kernel void minMax(texture2d&lt;ushort, access::read&gt; band1 [[texture(0)]], device BandMinMax &amp;out [[buffer(0)]], uint2 gid [[thread_position_in_grid]]) { ushort value = band1.read(gid).r; if (value != 0) { uint currentMin = atomic_load_explicit(&amp;out.min, memory_order_relaxed); uint currentMax = atomic_load_explicit(&amp;out.max, memory_order_relaxed); if (value &gt; currentMax) { atomic_store_explicit(&amp;out.max, value, memory_order_relaxed); } if (value &lt; currentMin) { atomic_store_explicit(&amp;out.min, value, memory_order_relaxed); } } } </code></pre> <p>From this I get a minimum and maximum value, but for the same dataset the min and max will often return different values. Fairly certain this is the min and max from a single thread when there are multiple threads running.</p> <p><strong>Second attempt</strong></p> <p>Building on the previous attempt, this time I'm storing the individual min/max values from each thread, all 256 (16x16).</p> <pre><code>kernel void minMax(texture2d&lt;ushort, access::read&gt; band1 [[texture(0)]], device BandMinMax *out [[buffer(0)]], uint2 gid [[thread_position_in_grid]], uint tid [[ thread_index_in_threadgroup ]]) { ushort value = band1.read(gid).r; if (value != 0) { uint currentMin = atomic_load_explicit(&amp;out[tid].min, memory_order_relaxed); uint currentMax = atomic_load_explicit(&amp;out[tid].max, memory_order_relaxed); if (value &gt; currentMax) { atomic_store_explicit(&amp;out[tid].max, value, memory_order_relaxed); } if (value &lt; currentMin) { atomic_store_explicit(&amp;out[tid].min, value, memory_order_relaxed); } } } </code></pre> <p>This returns an array containing 256 sets of min/max values. From these I guess I could find the lowest of the minimum values, but this seems like a poor approach. Would appreciate a pointer in the right direction, thanks!</p>
<ios><multithreading><metal>
2016-04-16 11:37:16
HQ
36,663,683
Part of Fragment items hides under Action bar
<p>I am learning android dev and my question might be very simple. I am stuck at the below part and requesting your help</p> <p><strong>Description</strong></p> <p>I am using the android's default "Navigation Drawer" activity to implement a small project. I have created a fragment and when user selects an option from Navigation drawer, the fragment opens. </p> <p><strong>Problem faced</strong></p> <p>When the fragment opens, part of the fragment &amp; action bar is clipped. Image below<a href="https://i.stack.imgur.com/1jTnA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1jTnA.png" alt="enter image description here"></a></p> <p><strong>Code</strong></p> <p><strong>fragment layout</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:clipToPadding="false" android:orientation="vertical" android:background="#ffffff" android:layout_weight="120" tools:context="test.navigationdrawcheck.RateCalculator"&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:ems="12" android:gravity="center" android:layout_weight="10" android:hint="text 1" android:textColorHint="@color/colorDivider" android:id="@+id/editText" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 2" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText1" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 3" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText3" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 4" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText4" android:layout_gravity="center_horizontal" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="15dp" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Total " android:textColor="@color/colorDivider" android:layout_weight="10" android:textStyle="bold" android:gravity="center_vertical" android:id="@+id/textView" android:layout_gravity="center_horizontal" /&gt; &lt;Button android:layout_width="match_parent" android:layout_height="10dp" android:inputType="number" android:ems="15" android:gravity="center" android:layout_weight="5" android:id="@+id/editText6" android:text="Submit" android:textSize="20sp" android:textColor="@color/colorWhite" android:background="@color/colorPrimary" android:layout_gravity="center_horizontal" /&gt; </code></pre> <p></p> <p><strong>App Bar Code</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="test.navigationdrawcheck.MainActivity"&gt; &lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/AppTheme.AppBarOverlay"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:elevation="4dp" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:fitsSystemWindows="true" app:popupTheme="@style/AppTheme.PopupOverlay"/&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;FrameLayout android:id="@+id/framecheck" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;/FrameLayout&gt; &lt;android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" /&gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; </code></pre> <p><strong>Actual output i am looking for</strong> </p> <p>Below is my actual fragment layout xml. <strong>When i merge it with Navigation drawer it should not be clipped</strong> and fragment items should be displayed correctly</p> <p><a href="https://i.stack.imgur.com/88DQw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/88DQw.png" alt="enter image description here"></a></p> <p><strong>What I have tried so far</strong></p> <p>I tried adding this <code>android:windowActionBarOverlay=false</code> in my styles.xml but no luck</p> <p>Requesting your suggestions</p>
<android><android-fragments>
2016-04-16 11:40:46
HQ
36,663,742
docker unauthorized: authentication required - upon push with successful login
<p>While pushing the docker image (after successful login) from my host I am getting "unauthorized: authentication required". </p> <p>Details below.</p> <pre><code>-bash-4.2# docker login --username=asamba --email=anand.sambamoorthy@gmail.com WARNING: login credentials saved in /root/.docker/config.json *Login Succeeded* -bash-4.2# -bash-4.2# docker push asamba/docker-whale Do you really want to push to public registry? [y/n]: y The push refers to a repository [docker.io/asamba/docker-whale] (len: 0) faa2fa357a0e: Preparing unauthorized: authentication required </code></pre> <ul> <li>Docker version: 1.9.1 (both client and server)</li> <li><a href="http://hub.docker.com">http://hub.docker.com</a> has the repo created as well (asamba/docker-whale). </li> </ul> <p>The /var/log/messages shows 403, I dont know if this docker. See below.</p> <pre><code>Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884872524Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}" Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884988574Z" level=error msg="Handler for POST /v1.21/images/asamba/docker-whale/push returned error: Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced" Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.885013241Z" level=error msg="HTTP Error" err="Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced" statusCode=403 Apr 16 11:39:05 localhost journal: time="2016-04-16T11:39:05.420188969Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}" Apr 16 11:39:06 localhost kernel: XFS (dm-4): Mounting V4 Filesystem Apr 16 11:39:06 localhost kernel: XFS (dm-4): Ending clean mount Apr 16 11:39:07 localhost kernel: XFS (dm-4): Unmounting Filesystem </code></pre> <p>Any help is appreciated, please let me know if you need further info. I did the push with -f as well. No luck!</p>
<docker>
2016-04-16 11:45:54
HQ
36,663,765
GitLab CI Start job manually (deployment)
<p>Is it possible to mark gitlab ci jobs to start manually?</p> <p>I need it for deploying application but I want to decide if it's going to be deployed</p>
<gitlab><continuous-deployment><gitlab-ci><continuous-delivery><gitlab-ci-runner>
2016-04-16 11:47:38
HQ
36,663,809
How to remove all docker volumes?
<p>If I do a <code>docker volume ls</code>, my list of volumes is like this:</p> <pre><code>DRIVER VOLUME NAME local 305eda2bfd9618266093921031e6e341cf3811f2ad2b75dd7af5376d037a566a local 226197f60c92df08a7a5643f5e94b37947c56bdd4b532d4ee10d4cf21b27b319 ... ... local 209efa69f1679224ab6b2e7dc0d9ec204e3628a1635fa3410c44a4af3056c301 </code></pre> <p>and I want to remove all of my volumes at once. How can I do it?</p>
<docker>
2016-04-16 11:51:16
HQ
36,664,423
How to find that particular array Item is present or not Using JQuery + Backbone.js
<p>Each ArrayItem contains no. of Property like Id, Name, Description etc But we want to Fetch ArrayItem with Help of Name Property .</p> <p>So Please give me code suggestion in Jquery or backbonejs without using for loop.</p>
<javascript><jquery><backbone.js>
2016-04-16 12:52:12
LQ_CLOSE
36,664,426
Tkinter or ttk GUI programming?
<p>I'm a beginner in python programming and have to make a project that has to be submitted in school. I discovered tkinter and ttk a month ago and am wondering which one would be better to code.</p> <p>The purpose of my program is for it to be user-interactive and look as modern as possible. I would appreciate it if you could tell me the advantages of tkinter over ttk and vice versa and which one you recommend I should use.</p> <p>The program purpose is to interact with the resident of a place and allow him to access different features of the place and stuff like that.</p>
<python><python-2.7><tkinter><ttk>
2016-04-16 12:52:29
LQ_CLOSE
36,664,537
Python-File to Dictionary?
I have two columns in this text file like this: William 2 David 3 Victor 5 Jack 1 Gavin 4 And I want it to be like this in a dict: d = {'William': 2,'David': 3,'Victor': 5,'Jack': 1,'Gavin': 4} Is anyone knows how to do this in python? Please help me! Thank You!
<python-3.x>
2016-04-16 13:04:24
LQ_EDIT
36,664,824
Typescript getter and setter error
<p>Ok it's my first day doing some Angular 2 using typescript and I am try to make a simple getter and setter service.</p> <pre><code>import {Injectable} from "angular2/core"; @Injectable() export class TodoService { private _todos:Array = []; get todos():Array { return this._todos; } set todos(value:Array) { this._todos = value; } } </code></pre> <p>Can anyone explain why the Typescript compiler is throwing the following error as I think it should be ok.</p> <pre><code>ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:6:17 Generic type 'Array&lt;T&gt;' requires 1 type argument(s). ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:8:14 Generic type 'Array&lt;T&gt;' requires 1 type argument(s). ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:12:18 Generic type 'Array&lt;T&gt;' requires 1 type argument(s). </code></pre>
<typescript><angular><angular2-services>
2016-04-16 13:30:30
HQ
36,665,234
Retrieve hash fragment from url with Angular2
<p>Given this url structure (over which I have no control), how can I retrieve the hash fragment using Angular2? </p> <p><code>http://your-redirect-uri#access_token=ACCESS-TOKEN</code></p> <p>My router does route to the correct component, but everything after <code>oauth</code> get scrapped and I can't find the hash fragment in request.params or location.path. Doomed??</p> <p>Router config:</p> <pre><code>@RouteConfig([ {path: '/welcome', name: 'Welcome', component: WelcomeComponent, useAsDefault: true}, {path: '/landing/oauth', name: 'Landing', component: LandingComponent} // this one </code></pre> <p>])</p>
<typescript><angular2-routing>
2016-04-16 14:11:46
HQ
36,665,320
A cookie header was received that contained an invalid cookie.
<p>I am <strong>migrating</strong> my Server from <strong>Tomcat-6</strong> to <strong>Tomcat-9</strong>. My website is designed for the protocol of HTTP/1.1 . The server.xml file contains the Connector Protocol of <strong>org.apache.coyote.http11.Http11NioProtocol</strong> . The server starts up normally without generating any errors. However, when I try to access my website using localhost, I get the following error :-</p> <p>INFO [https-nio-8445-exec-3] <strong>org.apache.tomcat.util.http.parser.Cookie.logInvalidHeader</strong> A cookie header was received [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23]; userId=53136] that contained an invalid cookie. That cookie will be ignored.Note: further occurrences of this error will be logged at DEBUG level. </p> <p>Can anyone please tell me the reason for this error? What causes an invalid cookie? Can this error be avoided if I use a different connector?</p>
<java><tomcat><networking><cookies><web>
2016-04-16 14:20:18
HQ
36,666,149
How do i solve this segmentation fault?
<p>i have been trying to figure out what is wrong with my piece of code. So taking in and out of my code everywhere, i think i have found the culprit. it is this chunk of code here that is causing it</p> <pre><code> if (strcmp(input, "load 1") != 0 || strcmp(input, "load 2") != 0 || strcmp(input, "quit") != 0) { Player player; Position position; Direction direction; char* tok; char* firstInput=0; char* secondInput=0; char* thirdInput=0; char* fourthInput=0; int x; int y; char str[10]; char str2[10]; tok = strtok(input, " "); strcpy(firstInput, tok); tok = strtok(NULL, ", "); strcpy(secondInput, tok); tok = strtok(NULL, ", "); strcpy(thirdInput, tok); tok = strtok(NULL, ""); strcpy(fourthInput, tok); strcpy(str, secondInput); x = atoi(str); strcpy(str2, thirdInput); y = atoi(str2); if(strcmp(firstInput, "init") == 0 ) { if(x &gt;= 0 &amp;&amp; x &lt;= 9) { if(y &gt;= 0 &amp;&amp; y &lt;= 9) { if (strcmp(fourthInput,"north") == 0 || (strcmp(fourthInput,"south")) || (strcmp(fourthInput,"west") == 0) || (strcmp(fourthInput,"east") == 0)) { position.x = x; position.y = y; if(strcmp(fourthInput,"north") == 0) { direction = NORTH; } if(strcmp(fourthInput,"south") == 0) { direction = SOUTH; } if(strcmp(fourthInput,"west") == 0) { direction = WEST; } if(strcmp(fourthInput,"east") == 0) { direction = EAST; } initialisePlayer(&amp;player, &amp;position, direction); placePlayer(board, position); displayDirection(direction); } } } } } </code></pre> <p>from what i know segmentation fault means a memory problem. I have made sure there is enough space for everything. what is actually going on?</p>
<c><segmentation-fault>
2016-04-16 15:36:18
LQ_CLOSE
36,666,246
Docker look at the log of an exited container
<p>Is there any way I can see the log of a container that has exited?</p> <p>I can get the container id of the exited container using <code>docker ps -a</code> but I want to know what happened when it was running.</p>
<docker>
2016-04-16 15:43:42
HQ
36,666,433
Node 5.10 spread operator not working
<p><a href="https://nodejs.org/en/docs/es6/#which-features-ship-with-node-js-by-default-no-runtime-flag-required">According to the docs</a>, the latest node (Node 5+) should support the spread operator by default, like so:</p> <pre><code>const newObj = { ...oldObj, newProperty: 1 } </code></pre> <p>And I have node 5.10.1 installed (e.g. that's what 'node -v' tells me). But I am still getting this error:</p> <pre><code>c:\[myprojectfolder]&gt;node index.js c:\[myprojectfolder]\index.js:21 ...oldObj, ^^^ SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10) at startup (node.js:146:18) at node.js:404:3 </code></pre> <p>What am I missing?</p>
<node.js><ecmascript-6>
2016-04-16 16:01:51
HQ
36,667,037
how to print incorrect questions?
<p>I am making a quiz in python and i want to know how i can display the incorrect questions at the end of the quiz. For example i have a 10 question quiz and i get 3 wrong, so i want to those questions to be displayed in the program and give me the option to re take them.</p> <p>Here is my code:</p> <pre><code>correct=0 incorrect=0 def tryagain(): while True: answer = input('Do you want to continue?: Press Y for yes and N for no ') if answer.lower().startswith("y"): print() elif answer.lower().startswith("n"): exit() print('****** Welceome to the Online Maths Test ********') print() print() print() print() print() print() print() import os os.system("PAUSE") import os os.system('cls') print('Question 1: 123 - 39 = ? \n 1. 64 \n 2. 44 \n 3. 74 \n 4. 84') print() answer=int(input()) if answer == 4: print () print () global correct correct=correct+1 elif answer != 4: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 2: 123+39 = ? \n \n 1. 162 \n 2. 166 \n 3. 62 \n 4. 66') print() answer=int(input()) if answer == 1: print () print () global correct correct=correct+1 elif answer != 1: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 3: 123*9 = ? \n 1. 1007 \n 2. 1107 \n 3. 1106 \n 4. 1116') print() answer=int(input()) if answer == 2: print () print () global correct correct=correct+1 elif answer != 2: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 4: 135 / 15 = ? \n 1. 8 \n 2. 8.5 \n 3. 9 \n 4. 9.5') print() answer=int(input()) if answer == 3: print () print () global correct correct=correct+1 elif answer != 3: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 5: 12 * (12 / 2) = ? \n 1. 144 \n 2. 6 \n 3. 72 \n 4. 36') print() answer=int(input()) if answer == 3: print () print () global correct correct=correct+1 elif answer != 3: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 6: 130 / 2 + 8 = ? \n 1. 13 \n 2. 14 \n 3. 61 \n 4. 84') print() answer=int(input()) if answer == 4: print () print () correct=correct+1 elif answer != 4: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 7: 10 + 12 + 13 * 6 / 2 = ? \n 1. 105 \n 2. 44 \n 3. 61 \n 4. 84') print() answer=int(input()) if answer == 3: print () print () global correct correct=correct+1 elif answer != 3: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 8: (10 + 12 + 13 * 6) / 2 = ? \n 1. 50 \n 2. 44 \n 3. 61 \n 4. 84') print() answer=int(input()) if answer == 1: print () print () global correct correct=correct+1 elif answer != 1: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 9: 8 (12 + 6 / 3 * 2) - 1 = ? \n 1. 127 \n 2. 109 \n 3. 95 \n 4. 135') print() answer=int(input()) if answer == 1: print () print () global correct correct=correct+1 elif answer != 1: print () global incorrect incorrect=incorrect+1 import os os.system('cls') print('Question 10: 1 / 1 * 1 - 1 + 1 = ? \n 1. 1 \n 2. -1 \n 3. 0 \n 4. -2') print() answer=int(input()) if answer == 1: print () print () global correct correct=correct+1 elif answer != 1: global incorrect incorrect=incorrect+1 print() print() print() print() import os os.system('cls') print('Your total score is: ',correct,' / 10') print('Your presentage is: ',correct*100/10,'%') print() print() print() print() tryagain() tryagain() </code></pre>
<python>
2016-04-16 16:58:12
LQ_CLOSE
36,667,286
How the user would like to be able to find the employees with the lowest yearly salary?
<p>I have to create an appropriate GUI to enter information for at least 10 employee. for each employee i have to enter the following information. employee ID, employee first name, employee last name and yearly salary. besides i have to check for the correctness of the input data. in addition i need to create a separate class EMPLOYEE, containing employee information: employee ID, first name , last name and yearly salary. the class should have constructors properties and methods. all the employee information has to be stored in a array of type employee. after reading form GUI the information about particular employee , also create an object of class employee(element of the array) with the relevant constructor. the user would like to be able to find the employee with lowest yearly salary despite of having more than one employee with lowest yearly salary. and display information about them. user should be provided with appropriate GUI to display the required information. i need to assure including in my program appropriate code for handling exceptions and also methods where appropriate.</p> <p>here is the class employee:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project_employee { class Employee { private int employeeID; private string fullName; private string lastName; private double salary; public Employee() { employeeID = 0; fullName = ""; lastName = ""; salary = 0.0; } public Employee(int empIDValue, string fullNameVal, string lastNameVal) { employeeID = empIDValue; fullName = fullNameVal; lastName = lastNameVal; salary = 0.0; } public Employee(int empIDValue, string fullNameVal, string lastNameVal, double salaryValue) { employeeID = empIDValue; fullName = fullNameVal; lastName = lastNameVal; salary = salaryValue; } public int EmployeeIDNum { get { return employeeID; } set { employeeID = value; } } public string FullName { get { return fullName; } set { fullName = value; } } public int Getinfo { get { return employeeID; } set { employeeID = value; } } public string employeeInformationToString() { // employeeID = Convert.ToInt32(this.textBox1.Text); return (Convert.ToString(employeeID) + " " + fullName + " " + lastName + " " + Convert.ToString(salary)); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Project_employee { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void richTextBox1_TextChanged(object sender, EventArgs e) { } private void Searchbtn_Click(object sender, EventArgs e) { employee[0] = new Employee(); employee[1] = new Employee(17433, "Adrian", "Smith", 8000.00); employee[2] = new Employee(17434, "Stephen", "Rad", 9000.00); employee[3] = new Employee(17435, "Jesse", "Harris", 800.00); employee[4] = new Employee(17436, "jonatan", "Morris", 9500.00); employee[5] = new Employee(17437, "Morgen", "Freeman", 12000.00); employee[6] = new Employee(17438, "Leory", "Gomez", 10200.00); employee[7] = new Employee(17439, "Michael", "Brown", 9000.00); employee[8] = new Employee(17440, "Andrew", "White", 3500.00); employee[9] = new Employee(17441, "Maria", "Carson", 12000.00); //employee[10] = new Employee(17442, "Mark", "Jonson", 17000.00); for(int i = 0; i &lt; 10; i++) { string employeeString = employee[i].employeeInformationToString() + "\r\n"; richTextBox1.AppendText(employeeString); } } Employee[] employee = new Employee[10]; private void getinfibtn_Click(object sender, EventArgs e) { Find(); } private void Find() { } } } </code></pre> <p>My question is:</p> <p>How the user can find the employee with the lowest yearly salary. i have to make sure that there can be more than one employee with lowest yearly salary and display the information about them. providing the user with an appropriate GUI (e.g a message box) to display the required information with including appropriate code for handling exceptions and also use methods where appropriate?</p>
<c#><arrays><methods><constructor>
2016-04-16 17:21:46
LQ_CLOSE
36,667,870
Why is my program printing out only the last object value of the array?
<p>Candidate class: </p> <pre><code>public class Candidate { private static String name; private static int numVotes; Candidate(String name, int numVotes) { Candidate.name = name; Candidate.numVotes = numVotes; } public String toString() { return name + " recieved " + numVotes + " votes."; } public static int getVotes() { return numVotes; } public static void setVotes(int inputVotes) { numVotes = inputVotes; } public static String getName() { return name; } public static void setName(String inputName) { name = inputName; } } </code></pre> <p>TestCandidate class:</p> <pre><code>public class TestCandidate { public static Candidate[] election = new Candidate[5]; public static void addCandidates(Candidate[] election) { election[0] = new Candidate("John Smith", 5000); election[1] = new Candidate("Mary Miller", 4000); election[2] = new Candidate("Michael Duffy", 6000); election[3] = new Candidate("Tim Robinson", 2500); election[4] = new Candidate("Joe Ashton", 1800); } public static int getTotal(Candidate[] election) { int total = 0; for (Candidate i : election) { total += Candidate.getVotes(); } return total; } public static void printResults(Candidate[] election) { System.out.printf("%s%12s%25s", "Candidate", "Votes", "Percentage of Votes\n"); for (Candidate i: election) { System.out.printf("\n%s%10s%10s", Candidate.getName(), Candidate.getVotes(), ((double)Candidate.getVotes()/getTotal(election) * 100)); } System.out.println("\n\nTotal Number of Votes: " + getTotal(election)); } public static void main (String args[]) { addCandidates(election); printResults(election); } } </code></pre> <p>Whenever I run the TestCandidate class, it outputs this: </p> <pre><code>Candidate Votes Percentage of Votes Joe Ashton 1800 20.0 Joe Ashton 1800 20.0 Joe Ashton 1800 20.0 Joe Ashton 1800 20.0 Joe Ashton 1800 20.0 Total Number of Votes: 9000 </code></pre> <p>The point of the program is to output all of the candidates and calculate averages based on everyone. I believe it's an issue within my for-each loops. Any help with this would be appreciated.</p>
<java><arrays><traversal>
2016-04-16 18:13:46
LQ_CLOSE
36,668,515
Can you write if ( (x && y) || y || z) { do this;}?
<p>Newbie question: In C#, how do I put a set of conditions, and one of them must be two values or conditions that are true together, not just one of them. For example, is the following valid syntax:</p> <pre><code>if ( (x &amp;&amp; y) || y || z) { do this;} </code></pre>
<c#>
2016-04-16 19:10:38
LQ_CLOSE
36,668,542
Flatten batch in tensorflow
<p>I have an input to tensorflow of shape <code>[None, 9, 2]</code> (where the <code>None</code> is batch).</p> <p>To perform further actions (e.g. matmul) on it I need to transform it to <code>[None, 18]</code> shape. How to do it? </p>
<tensorflow>
2016-04-16 19:13:09
HQ
36,668,550
unqualified-id error before ')' token
<p>I am new to stack overflow and I would appreciate feedback. I am creating a template graph class and have split it into two files graph.h and graph.hpp, but everytime I compile I get this error:</p> <pre><code> In file included from graph.h:97:0, from main.cpp:2: graph.hpp:4:26: error: expected unqualified-id before ‘)’ token typename graph&lt;T&gt;::graph(){ ^ makefile:2: recipe for target 'executable.x' failed </code></pre> <p>Here is my graph.hpp file so far:</p> <pre><code>#include "graph.h" //template &lt;typename T&gt; typename graph&lt;T&gt;::graph(){ numVertices = 0; graphWeight = 0; } </code></pre> <p>And my graph.h file looks something like:</p> <pre><code>template &lt;typename T&gt; class graph{ public: graph(); . . . private: }; </code></pre> <p>Also, my main.cpp is just simply:</p> <pre><code>#include "graph.h" int main(){ graph&lt;int&gt; g; } </code></pre> <p>What could possibly be wrong? I know it's probably something simple that has to do with the template.</p> <p>Thanks</p>
<c++><class><graph>
2016-04-16 19:13:57
LQ_CLOSE
36,668,973
React Native: 2 scroll views with 2 sticky headers
<p>I am trying to create a day-view with times on the left side, and a top header of people. Currently I can get the left OR the top header to stick, but not both.</p> <p><strong>How do you get 2 sticky headers?</strong></p> <p><a href="https://i.stack.imgur.com/07CUw.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/07CUw.gif" alt="Two Scroll Views each with a header"></a></p> <p>My render looks like this:</p> <pre><code> &lt;ScrollView style={{height: 600}}&gt; &lt;ScrollView horizontal={true}&gt; &lt;View style={styles.column}&gt; &lt;View style={{ flex: 1, flexDirection: 'row', width}}&gt; {header} &lt;/View&gt; &lt;View style={styles.row}&gt; &lt;View style={[styles.container, { width, marginLeft: 40 }]}&gt; {this.generateRows()} &lt;/View&gt; &lt;/View&gt; &lt;/View&gt; &lt;/ScrollView&gt; &lt;View style={{backgroundColor: 'white', position: 'absolute', top: 0, bottom: 0, left: 0, }}&gt; &lt;View style={{ flex: 1, flexDirection: 'row'}}&gt; &lt;View style={styles.row}&gt; &lt;Text&gt;&lt;/Text&gt; &lt;/View&gt; &lt;/View&gt; &lt;View style={{height: 1000, width: 40 }}&gt; {this.generateRowLabels()} &lt;/View&gt; &lt;/View&gt; &lt;/ScrollView&gt; </code></pre>
<scrollview><react-native>
2016-04-16 19:53:34
HQ
36,669,325
Launch Screen storyboard not displaying image
<p>I'm trying to get an image to display as the launch screen from my Launch Screen.storyboard file, however the image never displays. I have labels that show up fine, but the image doesn't appear.</p> <p>This is how the launch screen looks in the Launch Screen.storyboard file: <a href="https://i.stack.imgur.com/Vjy5B.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Vjy5B.png" alt="enter image description here"></a></p> <p>However when I run the app on the simulator (as well as on the physical device) this is what shows up:</p> <p><a href="https://i.stack.imgur.com/kjUeh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kjUeh.png" alt="enter image description here"></a></p> <p>As you can see, the label "Test" shows up fine, however the image does not display. I'm really not sure why this is happening and nothing I try seems to work. If anyone has any ideas of how to fix this it would be greatly appreciated. </p>
<ios><iphone><xcode>
2016-04-16 20:24:44
HQ
36,669,579
Is the thread in C++ a time slice or the execution of a function?
Is the thread in C++ a time slice or the execution of a function or both? A thread is executing a function which is a block of code inside an outer loop. If you send a signal (via a global variable) to break from the outer loop. The function returns, but what happens to the running thread assuming it is a time slice of execution?
<windows><multithreading>
2016-04-16 20:49:40
LQ_EDIT
36,669,710
Iterating through keys of Immutable Map in React
<p>What is a good practice for handling iteration through an Immutable.js Map object? This works: </p> <pre><code>{stocks.map((stock,key)=&gt;{ return ( &lt;h3&gt;{key}&lt;/h3&gt; ) })} </code></pre> <p>but gives the warning in the console "warning.js:45 Warning: Using Maps as children is not yet fully supported. It is an experimental feature that might be removed. Convert it to a sequence / iterable of keyed ReactElements instead."</p> <p>This has been discussed before, and this link suggests some strategies <a href="https://github.com/facebook/immutable-js/issues/667">https://github.com/facebook/immutable-js/issues/667</a> but they seem clunky to me. Like:</p> <pre><code>posts.entrySeq().map(o =&gt; &lt;Post value={o[1]} key={o[0]} /&gt; ) </code></pre> <p>works but is clunky feeling. Is there a more natural way of doing this?</p>
<dictionary><reactjs><immutability>
2016-04-16 21:02:14
HQ
36,669,911
$_POST not retrieving data from Javascript's Fetch()
<p>I'm posting data using javascript's <code>fetch()</code> .</p> <pre><code> fetch('/string.php', { method: 'post', body: JSON.stringify({ name: 'helloe world', }) }) .then(function(response) { if (response.status &gt;= 200 &amp;&amp; response.status &lt; 300) { return response.text() } throw new Error(response.statusText) }) .then(function(response) { console.log(response); }) </code></pre> <p>string.php file contains:</p> <pre><code>print_r($_POST); </code></pre> <p>Now my problem is the <code>$_POST</code> returns an empty array. I can fix this by appending the file with:</p> <pre><code>$_POST = json_decode(file_get_contents('php://input'), true); </code></pre> <p>But that feels very hackish and isn't ideal. Is this the intended behaviour for PHP when retrieving post data from a JS <code>fetch()</code>?</p> <p>Is there anyway I may automatically put the contents within the <code>$_POST</code>?</p>
<javascript><php><post>
2016-04-16 21:20:49
HQ
36,670,330
If this contains that change CSS of another element
I have a percent bar that need to change your width when a element appears. I tried use .has but :contains is more correct I think. But does't work. Some idea how to do this work? var animals = [ 'Lion', 'Cat', 'Tiger', 'Dog' ] var box_animals = animals.valueOf; if ("box_animals:contains(Cat)"){ $("#ruler_bar").css("width", 2% ); } if ("box_animals:contains(Lion)"){ $("#ruler_bar").css("width", 50% ); }
<javascript><contains>
2016-04-16 22:05:53
LQ_EDIT
36,670,501
How do I select hardware OpenGL rendering for MATLAB on Linux
<p>When I start matlab on my linux machine, I get the notice, "MATLAB is selecting SOFTWARE OPENGL rendering." Once it starts up, if I try <code>opengl hardware</code> I get the message that I can't switch at runtime. How do I enable hardware rendering as simply as possible?</p>
<matlab>
2016-04-16 22:27:03
HQ
36,670,600
Advice on html/javascript coding
<!DOCTYPE HTML> <html> <head><meta charset="utf-8"> <title>TaxDay</title> <script type="text/javascript"> <!-- Hide from old browsers function scrollColor() { styleObject=document.getElementsByTagName('html')[0].style styleObject.scrollbarFaceColor="#857040" styleObject.scrollbarTrackColor="#f4efe9" } function countDown() { var today = new Date() var day of week = today.toLocaleString() dayLocate = dayofweek.indexOf(" ") weekDay = dayofweek.substring(0, dayLocate) newDay = dayofweek.substring(dayLocate) dateLocate = newday.indexOf(",") monthDate = newDay.substring(0, dateLocate+1)} yearLocate = dayofweek.indexOf("2016") year = dayofweek.substr(yearLocate, 4) var taxDate = new Date ("April 16, 2017") var daysToGo = taxDate.getTime()-today.getTime() var daysToTaxDate = Math.ceil(daysToGo/(1000*60*60*24)) function taxmessage() { var lastModDate = document.lastModified var lastModDate = lastModDate.substring(0,10) taxDay.innerHTML = "<p style='font-size:12pt; font- family:helvetica;'>Today is "+weekDay+" "+monthDate+" "+year+". You have "+daysToTaxDate+" days to file your taxes.</p>" } } //--> </script> the <div> id is taxDay if its relevant. the body onLoad event handler are "scrollColor(); countDown(); and taxmessage()" The website suppose to display a message counting down to the tax day. I can't seem to get anything to display on the page. the scrollbar doesn't even show up with the color even though i put in the write code. Some advice please. Thank you.
<javascript><html><countdown>
2016-04-16 22:37:58
LQ_EDIT
36,670,642
how to compare the elemnts of an array
<p>Given a non-empty array, return true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side. </p>
<php><arrays>
2016-04-16 22:43:34
LQ_CLOSE
36,670,825
global name 'distance' is not defined
<p>I'm new to python and ros, and I'm having a little issue at the moment. I'm sure it's a simple error on my part, but I can't figure it out.</p> <p>I've searched and found similar situations, but I'm not sure how to implement the solutions given to other answers on my code.</p> <p>Please ignore any 'crappiness' in my code that does not directly contribute to the issue. I just need this project to run as quickly as possible.</p> <pre><code>#!/usr/bin/env python import rospy from geometry_msgs.msg import Twist, Vector3Stamped from math import radians from sensor_msgs.msg import NavSatFix import geometry_msgs.msg import time import numpy global distance global pub global dest_lat global dest_long global move_cmd global turn_cmd global bearing global heading global initial_bearing global cur_lat global prev_lat global cur_long global prev_long bearing = 0 ################################################################################ lat_dest = 30.210406 # DESTINATION COORDINATES long_dest = -92.022914 ################################################################################ move_cmd = Twist() turn_cmd = Twist() def nav_dist(navsat): R = 6373000 # Radius of the earth in m cur_lat = navsat.latitude cur_long = navsat.longitude dLat = cur_lat - lat_dest dLon = cur_long - long_dest x = dLon * numpy.cos((lat_dest+cur_lat)/2) distance = numpy.sqrt(x**2 + dLat**2) * R return distance def bearing(): if (bearing == 0): bearing = initial_bearing return bearing else: bearing = calculate_bearing(cur_lat, prev_lat, cur_long, prev_long) return bearing def calculate_bearing(lat1, lat2, long1, long2): dLon = long2 - long1 y = np.sin(dLon) * np.cos(lat2) x = np.cos(lat1)*np.sin(lat2) - np.sin(lat1)*np.cos(lat2)*np.cos(dLon) bearing = (np.rad2deg(np.arctan2(y, x)) + 360) % 360 return bearing def calculate_nav_angle(lat1, lat_dest, long1, long_dest): dLon = long_dest - long1 y = np.sin(dLon) * np.cos(lat_dest) x = np.cos(lat1)*np.sin(lat_dest) - np.sin(lat1)*np.cos(lat_dest)*np.cos(dLon) heading = (np.rad2deg(np.arctan2(y, x)) + 360) % 360 return heading def navigate(distance, nav_angle): turn_cmd.angular.z = radians(bearing - heading) move_cmd.linear.x = distance pub.publish(turn_cmd) time.sleep(.01) pub.publish(move_cmd) time.sleep(.001) prev_long = cur_long prev_lat = cur_lat ############################################################################################### ################################# callbacks and run ################################# ############################################################################################### def call_nav(navsat): rospy.loginfo("Latitude: %s", navsat.latitude) #Print GPS co-or to terminal rospy.loginfo("Longitude: %s", navsat.longitude) nav_dist(navsat) time.sleep(.001) def call_bear(bearing): rospy.loginfo("Bearing: %s", bearing.vector) #Print mag reading for bearing x = -bearing.vector.y y = bearing.vector.z initial_bearing = numpy.arctan2(y, x) return initial_bearing def run(): pub = rospy.Publisher('/husky_velocity_controller/cmd_vel', Twist) rospy.Subscriber("/imu_um6/mag", Vector3Stamped, call_bear) rospy.Subscriber("/gps/fix", NavSatFix, call_nav) rospy.init_node('navigate_that_husky') rospy.spin() if __name__ == '__main__': run() navigate(distance, nav_angle) </code></pre> <p>and here is the error</p> <pre><code>Traceback (most recent call last): File "NewTest.py", line 111, in &lt;module&gt; navigate(distance, nav_angle) NameError: global name 'distance' is not defined </code></pre> <p>how might I fix this? I appreciate any help.</p>
<python><ros>
2016-04-16 23:06:48
LQ_CLOSE
36,670,910
webstorm: what does "Element is not exported" warning mean?
<p>if i write such code in webstorm </p> <pre><code>export class someOne { constructor(param) { this.test = param; } useTest(){ return this.test; } } console.log(new someOne(123).useTest()); </code></pre> <p>and mouseover on "this.test" i see the warning: "Element is not exported"</p> <p><a href="https://i.stack.imgur.com/UPh9s.png"><img src="https://i.stack.imgur.com/UPh9s.png" alt="element is not exported wtf"></a></p> <p>what does it mean? if i change the <code>.test</code> to <code>.test1</code> the warning disappears</p>
<javascript><ecmascript-6><warnings><webstorm>
2016-04-16 23:18:44
HQ
36,671,441
Ruby on Rail, Haml::SyntaxError at /
I am a newbee for ruby on rails. When I compile, on the browser, it just keeps me same error on index.haml Haml::SyntaxError at / Illegal nesting: nesting within plain text is illegal. [![enter image description here][1]][1] This is the code, %h1.text-center All images .row %ul.list-unstyled @images.each do |image| %li %h2=image.title %p %a.thumbnail{href: image.file, data:{ lightbox: "gallery", title: image.title } } %img{src: image.file.url(:small), width: "100%"} %p %span(class='st_facebook_hcount' displayText='Facebook' st_url="#{request.base_url}/images/#{image.id}") %span(class='st_twitter_hcount' displayText='Tweet' st_url="#{request.base_url}/images/#{image.id}") [1]: http://i.stack.imgur.com/UeH0n.png Thank you in advance.
<ruby-on-rails><ruby><haml>
2016-04-17 00:44:11
LQ_EDIT
36,671,507
how to use coordinates outside of didUpdateLocation function in swift
Im trying to use the coordinates outside of did update locations function but i can not get it to work i try to declare the coordinates as a degree outside of the function but that does not work how can i get some guidance on this. var currentUserLatitude:CLLocationDegrees? var currentUserLongitude:CLLocationDegrees? func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ //location info about the user let location = locations.last let center = CLLocationCoordinate2D(latitude: (location?.coordinate.latitude)!, longitude: (location?.coordinate.longitude)!) let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) let region = MKCoordinateRegion(center: center, span:span) self.mapView.setRegion(region, animated: true) // i want to use these variables outside the function var currentUserLatitude = location!.coordinate.latitude var currentUserLongitude = location!.coordinate.longitude }
<ios><swift><core-location>
2016-04-17 00:55:46
LQ_EDIT
36,672,002
font size depending on number of words
<p>I have vertically aligned <em>div</em> with <em>fixed height</em> (800px). The problem is that my div is dynamic and <em>font size</em> depends on number of words, for example <a href="https://i.stack.imgur.com/RpgbT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RpgbT.png" alt=""></a></p> <p>how can I achieve that?</p> <p><a href="https://fiddle.jshell.net/elene/640kLut2/1/" rel="nofollow noreferrer">link</a></p>
<javascript><css><twitter-bootstrap>
2016-04-17 02:18:33
LQ_CLOSE
36,672,158
send POST to nodes save file.txt
webrequest.mq4 > //+------------------------------------------------------------------+ > //| webrequest.mq4 //| Copyright 2013, apla //| - > //+------------------------------------------------------------------+ > #property copyright "Copyright 2013, apla" > #property link "-" > > int start() { //---- > > //WebRequest string cookie = NULL; string headers = > "Content-Type: application/x-www-form-urlencoded"; int res; //url > = localhost:8080 string url = "localhost"; char post[], result[]; string signal = > "account="+AccountNumber()+"&balance="+AccountBalance()+"&equity="+AccountEquity(); > StringToCharArray(signal, post); Print(signal); int timeout = 50000; > // 5 sec res = WebRequest("POST", url, cookie, NULL, timeout, post, > ArraySize(post), result, headers); > > Print("Status code: " , res, ", error: ", GetLastError()); > > //---- return(0); } > //+------------------------------------------------------------------+ --------------- I want to send the file from mt4 webrequest.mq4 to the node js this Site section that can be given up, however. MT4 >> Nodejs ??? POST[] ??? (javascript nodes) account, balance, equity Which I do not know how to get the POST. write file.js > var http = require('http'); var fs = require('fs'); > > fs.writeFile("file.txt",??? POST[] ???, function(err,data) { > if (err) throw err; > console.log('The file was saved!'); > > http.createServer(function(req, res) { > res.writeHead(200, {'Content-Type': 'text/plain'}); > res.end('OK'); // Send the file data to the browser. }).listen(3000); console.log('Server running at > http://localhost:8080/'); });
<javascript><php><node.js><mql4>
2016-04-17 02:47:53
LQ_EDIT
36,672,514
Efficiently merge two objects in python
<p>I have a two objects that I want to merge in such a way that all references to the two merged objects now point to the one merged object.</p> <pre><code>#What I want listOfObjects=[obj1, obj1, obj2, obj2, obj3] mergeObjects(obj1, obj2) #now listofObjects==[merged, merged, merged, merged, obj3] </code></pre> <p>One way to accomplish it is this:</p> <pre><code>def mergeObjects(obj1, obj2): obj1.property1+=obj2.property1 obj1.property2+=obj2.property2 obj2=obj1 </code></pre> <p>However, this has the downside that rather than having one merged object, I have a merged object and an identical copy of it. My program will merge dozens of objects with each other, so this will consume far too much memory.</p> <p>Another way is:</p> <pre><code>listOfObjects=[obj1, obj1, obj2, obj2, obj3] mergeObjects(obj1, obj2) for i in range(len(listOfObjects)): if (listOfObjects[i]==obj2): listOfObjects[i]==obj1 #now listofObjects==[merged, merged, merged, merged, obj3] #and obj2 is now free to be garbage collected </code></pre> <p>However, there are multiple references to these objects and iterating over every one of them each time I merge an object is also not optimal.</p> <p>One thing I thought of is if I could use pointers. I could instead store a list of pointers to objects and then write:</p> <pre><code>def mergeObjects(obj1_pointer, obj2_pointer): obj1=&amp;obj1_pointer obj2=&amp;obj2_pointer obj1.property1+=obj2.property1 obj1.property2+=obj2.property2 obj2_pointer=obj1_pointer #let's say the pointers are themselves objects so now we have: listOfPointers==[obj1_pointer, obj1_pointer, obj1_pointer, obj1_pointer, obj3_pointer] #obj1_pointer is now pointing to the merged object #obj2 now has no references so is free to be deleted </code></pre> <p>Where I'm using &amp; as the dereference operator.</p> <p>So would writing my own pseudopointer object with a dereference method that returned an object be an efficient solution?</p> <p>If not is there a cleaner way to do this (change object 1 to merged object, then have all references to object 2 instead be a reference to object 1)?</p>
<python><pointers><object><merge>
2016-04-17 03:57:59
LQ_CLOSE
36,674,079
How to do Facebook Messenger Bot development locally?
<p>When setting webhooks, it's saying a <code>Secure URL</code> is required.</p>
<facebook><facebook-messenger>
2016-04-17 08:02:06
HQ
36,674,641
android.database.sqlite.SQLiteException: near "s": syntax error (code 1): ,
<p>android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , while compiling: INSERT OR REPLACE INTO movies(backdrop_path,id,original_language,orginal_title,overview,poster_path,title,popularity,adult,video,vote_avg,vote_count,release_date,favourite) VALUES ('/tbhdm8UJAb4ViCTsulYFL3lxMCd.jpg','76341','en','null','An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order. There's Max, a man of action and a man of few words, who seeks peace of mind following the loss of his wife and child in the aftermath of the chaos. And Furiosa, a woman of action and a woman who believes her path to survival may be achieved if she can make it across the desert back to her childhood homeland.','/kqjL17yufvn9OVLyXYpvtyrFfak.jpg','Mad Max: Fury Road','19.132107','false','false','7','4359','-546474976','false' ); at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)</p>
<android><android-sqlite>
2016-04-17 09:09:53
LQ_CLOSE
36,675,251
How to properly implement linkedIn login ?
<p>I have an andorid app and i am trying to implement linkedIn login in it. LinkedIn SDK has been successfully integrated and i am getting user information as well along with the email address. </p> <p><strong>Here is how my application works for google login :</strong> </p> <p>1) get access token on mobile </p> <p>2) send email address with access token to server </p> <p>3) fetch details of users with access token i received via webapi of google. </p> <p>4) if the response email matches with the email received from mobile device then check for account exists or not of that email address . If not create account and login other wise login. </p> <hr> <p><strong>Problem with linkedIn :</strong> </p> <p>The access token i have received belongs to mobile sdk and i cannot use the same token to make REST API request. (<a href="https://developer.linkedin.com/docs/android-sdk-auth" rel="noreferrer">as per documentation</a>)</p> <blockquote> <p>Mobile vs. server-side access tokens</p> <p>It is important to note that access tokens that are acquired via the Mobile SDK are only useable with the Mobile SDK, and cannot be used to make server-side REST API calls.</p> <p>Similarly, access tokens that you already have stored from your users that authenticated using a server-side REST API call will not work with the Mobile SDK.</p> </blockquote> <p>So how to verify details in step 3) i mentioned above on my webserver ?</p> <hr> <p><strong>Is It a disaster ?</strong> I am sure there has to be a way to do what i am trying to do, as there are many applications which let their users login through linkedin on their mobile apps. </p> <p><em>Because if its not possible then anyone can easily change the email address the mobile app is sending to webserver after receiving from linkedin and i can login with any email address i want by doing that.</em> </p>
<android><oauth><oauth-2.0><linkedin><linkedin-api>
2016-04-17 10:16:29
HQ
36,675,758
Fix width of element in UIStackView
<p>I create <code>UIStackView</code>s programmatically and add them to parent <code>UIStackView</code>, which is created in Storyboard. Child stack views are horizontal with 2 labels. I need to fix width of second <code>UILabel</code> and make the first <code>UILabel</code> fill the rest space.</p> <p>Now I have this:</p> <p><a href="https://i.stack.imgur.com/ckD9X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ckD9X.png" alt="Before"></a></p> <p>And I want this:</p> <p><a href="https://i.stack.imgur.com/sYgYO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sYgYO.png" alt="After"></a></p> <p>My code for generating children stack views:</p> <pre><code>@IBOutlet weak var parentStackView: UIStackView! func addStackViewsToParentStackView(params: [String: Float]) { for (name, value) in params { let parameterNameLabel = UILabel() // first label parameterNameLabel.text = name let parameterValueLabel = UILabel() // second label parameterValueLabel.text = value.description parameterValueLabel.frame.size.width = 80.0 // I've tried to fix width, but it does't help let childStackView = UIStackView(arrangedSubviews: [parameterNameLabel, parameterValueLabel]) childStackView.axis = .Horizontal childStackView.distribution = .FillProportionally childStackView.alignment = .Fill childStackView.spacing = 5 childStackView.translatesAutoresizingMaskIntoConstraints = true parentStackView.addArrangedSubview(childStackView) } } </code></pre> <p>Thanks for any help!</p>
<ios><swift><uistackview>
2016-04-17 11:14:31
HQ
36,675,995
Whay do I get a gap betwwen border and backgound image -HTML CSS3
[enter image description here][1] [Why do i get the gap between the border and backgroound ][2] [1]: http://i.stack.imgur.com/kZ0Z7.jpg [2]: http://i.stack.imgur.com/iknj8.jpg
<html><css>
2016-04-17 11:38:34
LQ_EDIT
36,676,017
JAX-RS 2 print JSON request
<p>I'd like to be able to print JAX-RS 2 JSON payload from request, regardless of actual implementation on my application server.</p> <p>I've tried suggested solutions on SO but all include binaries from actual implementation (like Jersey and similar), and I'm allowed only to use javaee-api v 7.0 in my application.</p> <p>I've tried implementing ClientRequestFilter and ClientResponseFilter on my Client but they don't contain serialized entities.</p> <p>Here's an example of client:</p> <pre><code>WebTarget target = ClientBuilder.newClient().register(MyLoggingFilter.class).target("http://localhost:8080/loggingtest/resources/accounts"); Account acc = target.request().accept(MediaType.APPLICATION_JSON).get(account.Account.class); </code></pre> <p>And here's the implementation of MyLoggingFilter:</p> <pre><code>@Provider public class MyLoggingFilter implements ClientRequestFilter, ClientResponseFilter { private static final Logger LOGGER = Logger.getLogger(MyLoggingFilter.class.getName()); @Override public void filter(ClientRequestContext requestContext) throws IOException { LOGGER.log(Level.SEVERE, "Request method: {0}", requestContext.getMethod()); } @Override public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { LOGGER.log(Level.SEVERE, "Response status: {0}", responseContext.getStatus()); } } </code></pre>
<java><json><jakarta-ee><logging><jax-rs>
2016-04-17 11:40:53
HQ
36,676,395
How to resolve external packages with spark-shell when behind a corporate proxy?
<p>I would like to run spark-shell with a external package behind a corporate proxy. Unfortunately external packages passed via <code>--packages</code> option are not resolved.</p> <p>E.g., when running</p> <pre><code>bin/spark-shell --packages datastax:spark-cassandra-connector:1.5.0-s_2.10 </code></pre> <p>the cassandra connector package is not resolved (stuck at last line):</p> <pre><code>Ivy Default Cache set to: /root/.ivy2/cache The jars for the packages stored in: /root/.ivy2/jars :: loading settings :: url = jar:file:/opt/spark/lib/spark-assembly-1.6.1-hadoop2.6.0.jar!/org/apache/ivy/core/settings/ivysettings.xml datastax#spark-cassandra-connector added as a dependency :: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0 confs: [default] </code></pre> <p>After some time the connection times out containing error messages like this:</p> <pre><code>:::: ERRORS Server access error at url https://repo1.maven.org/maven2/datastax/spark-cassandra-connector/1.5.0-s_2.10/spark-cassandra-connector-1.5.0-s_2.10.pom (java.net.ConnectException: Connection timed out) </code></pre> <p>When i deactivate the VPN with the corporate proxy the package gets resolved and downloaded immediately.</p> <p>What i tried so far:</p> <p>Exposing proxies as environment variables:</p> <pre><code>export http_proxy=&lt;proxyHost&gt;:&lt;proxyPort&gt; export https_proxy=&lt;proxyHost&gt;:&lt;proxyPort&gt; export JAVA_OPTS="-Dhttp.proxyHost=&lt;proxyHost&gt; -Dhttp.proxyPort=&lt;proxyPort&gt;" export ANT_OPTS="-Dhttp.proxyHost=&lt;proxyHost&gt; -Dhttp.proxyPort=&lt;proxyPort&gt;" </code></pre> <p>Running spark-shell with extra java options:</p> <pre><code>bin/spark-shell --conf "spark.driver.extraJavaOptions=-Dhttp.proxyHost=&lt;proxyHost&gt; -Dhttp.proxyPort=&lt;proxyPort&gt;" --conf "spark.executor.extraJavaOptions=-Dhttp.proxyHost=&lt;proxyHost&gt; -Dhttp.proxyPort=&lt;proxyPort&gt;" --packages datastax:spark-cassandra-connector:1.6.0-M1-s_2.10 </code></pre> <p>Is there some other configuration possibility i am missing?</p>
<apache-spark><proxy><dependencies><ivy>
2016-04-17 12:20:01
HQ
36,676,665
What are the disadvantages if I don't use mysqli_real_escape_string()?
<p>As per my knowledge If I don't use mysqli_real_escape_string() I may get a wrong entry in database. Correct me if I am wrong.</p> <p>Are there any disadvantages?</p>
<php>
2016-04-17 12:44:36
LQ_CLOSE
36,676,828
Servlet Not Found Error
<p>Im getting a servlet not found error. Im using WIldFly. My directory structure looks like this:</p> <p>root --> app, converter.html, src</p> <p>app --> WEB-INF</p> <p>WEB-INF--> classes, lib, web.xml</p> <p>src --> servlet.java</p> <p>I have been looking over it for awhile and can't pin point the problem. I think I have the mapping down correctly in the web.xml and the form action seems to be sent to the right place as well in the .html file.</p> <p>Servlet Class:</p> <pre><code>import java.io.IOException; import java.util.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class servlet extends HttpServlet{ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String username = request.getParameter("username"); String email = request.getParameter("email"); response.getWriter().println("&lt;html&gt;"); response.getWriter().println("&lt;head&gt;"); response.getWriter().println("&lt;title&gt;Title&lt;/title&gt;"); response.getWriter().println("&lt;/head&gt;"); response.getWriter().println("&lt;body&gt;"); response.getWriter().println("Convert. "); response.getWriter().println("&lt;/body&gt;"); response.getWriter().println("&lt;/html&gt;"); } } </code></pre> <p>web.xml</p> <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"&gt; &lt;servlet&gt; &lt;servlet-name&gt;servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;servlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/servlet&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>converter.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; Test form &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="http://localhost:8080/root/src/servlet" method="get"&gt; Name: &lt;input type="text" name="username"&gt;&lt;br&gt; Email: &lt;input type="text" name="email"&gt;&lt;br&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<java><xml><servlets>
2016-04-17 12:59:17
LQ_CLOSE
36,677,331
Detect that an application is locked
<p>I have an application developed in C # that sometimes is blocked, when it is blocked I have to restart it. I know if there is any way to detect if the application is frozen, close it and then restart.</p> <p>Thank for all!</p>
<c#>
2016-04-17 13:42:36
LQ_CLOSE
36,677,422
Need help importing specific data (variable values) from a text file and ignoring non useful text and metadata
<p><a href="http://i.stack.imgur.com/xOgp4.jpg" rel="nofollow">here is my attempted code though it may be rubbish and to the right is the data, i just want the two columns of data from line 15 onwards</a></p> <p>my code reads: </p> <pre><code>import numpy as np import matplotlib as mplt data = np.genfromtxt('practice_data.txt', dtype='float', delimiter=' ') time = data[:,0] channel=data[:,1] </code></pre> <p>if anyone can help me to extract the two columns as two variables that would be amazing</p>
<python><numpy><data-extraction><genfromtxt>
2016-04-17 13:52:06
LQ_CLOSE
36,677,604
How can I change the project in BigQuery
<p>When configuring the Big-Query command line tool I was asked to set up a default project. However, now I have many projects and I can't happen to find how do I switch from one project to the other. Does someone know how to navigate the projects using the command line? Thanks in advance!</p> <p>G</p>
<google-bigquery>
2016-04-17 14:10:20
HQ
36,677,787
Add property to all objects in array
<p>I have the following array of objects:</p> <pre><code>var array = [ {'a': '12', 'b':'10'}, {'a': '20', 'b':'22'} ]; </code></pre> <p>How can I add a new property <code>c = b - a</code> to all objects of the array?</p>
<javascript>
2016-04-17 14:27:07
HQ
36,677,971
Implementing hierarchical clustering in Python using Levenshtein distance
<p>Following up on my previous question, I have implemented a clustering algorithm for a huge number of strings using Python &amp; Levenshtein distance..But it is taking a very long time to complete clustering. Any suggestions please?</p> <p>&lt;> iterate thro the list in a for loop for each item in list run through the list again, to find similarity percentage if similarity > threshold, move to cluster end for loop</p>
<python><cluster-analysis><levenshtein-distance><hierarchical>
2016-04-17 14:43:00
LQ_CLOSE
36,678,064
What Dose this exception meen
What dose this exception mean this exception keeps pophing when i try to execute query throw JDBC java.lang.ArrayIndexOutOfBoundsException: 252 at com.orientechnologies.common.serialization.types.OLongSerializer.deserializeLiteral(OLongSerializer.java:69) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.readLong(ORecordSerializerBinaryV0.java:788) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.readSingleValue(ORecordSerializerBinaryV0.java:307) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryV0.deserialize(ORecordSerializerBinaryV0.java:195) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary.fromStream(ORecordSerializerBinary.java:74) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.record.impl.ODocument.deserializeFields(ODocument.java:1817) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.record.impl.ODocument.checkForFields(ODocument.java:2416) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.core.record.impl.ODocument.fieldNames(ODocument.java:736) ~[orientdb-core-2.1.11.jar:2.1.11] at com.orientechnologies.orient.jdbc.OrientJdbcResultSet.<init>(OrientJdbcResultSet.java:59) ~[orientdb-jdbc-2.1.11.jar:2.1.11] at com.orientechnologies.orient.jdbc.OrientJdbcPreparedStatement.executeQuery(OrientJdbcPreparedStatement.java:70) ~[orientdb-jdbc-2.1.11.jar:2.1.11] at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:688) ~[spring-jdbc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
<exception><orientdb>
2016-04-17 14:50:34
LQ_EDIT
36,678,196
Derivate class from a derivate class
Hello i have 3 class (City, Neighborhood and Block) Here is class definiton of City class class City: def __init__(self, id_city, name_city): self.__id = id_city self.__name = name_city Definition of the Neighborhood class Neighborhood(City):' def __init__(self, id_neighborhood, name_neighborhood, number_block, *city_args, **kwargs): City.__init__(self, *city_args, **kwargs) self.__id = id_neighborhood self.__name = name_neighborhood self.__number = number_block Definition of the Block class Block(Neighborhood): def __init__(self, id_block, number_block, number_flats, *neighborhood_args, **kwargs): Neighborhood.__init__(*neighborhood_args, **kwargs) self.__id = id_block self.__number_b = number_block self.__number_f = number_flats Now i declare a entities: city = City(5, "New York") neighborhood = Neighborhood(1, "Brooklyn", 500, 5, "New York") block = Block(11, 2, 20 1, "Brooklyn", 500, 5, "New York") And the error is this: AttributeError: 'int' object has no attribute '_City__id'
<python><class><python-3.x>
2016-04-17 15:02:40
LQ_EDIT
36,678,302
Stubbing window.location.href with Sinon
<p>I am trying to test some client-side code and for that I need to stub the value of <code>window.location.href</code> property using Mocha/Sinon.</p> <p>What I have tried so far (<a href="https://gist.github.com/jouni-kantola/8761980" rel="noreferrer">using this example</a>):</p> <pre><code>describe('Logger', () =&gt; { it('should compose a Log', () =&gt; { var stub = sinon.stub(window.location, 'href', 'http://www.foo.com'); }); }); </code></pre> <p>The runner displays the following error:</p> <blockquote> <p>TypeError: Custom stub should be a function or a property descriptor</p> </blockquote> <p>Changing the test code to: </p> <pre><code>describe('Logger', () =&gt; { it('should compose a Log', () =&gt; { var stub = sinon.stub(window.location, 'href', { value: 'foo' }); }); }); </code></pre> <p>Which yields this error:</p> <blockquote> <p>TypeError: Attempted to wrap string property href as function</p> </blockquote> <p>Passing a function as third argument to <code>sinon.stub</code> doesn't work either.</p> <p>Is there a way to provide a fake <code>window.location.href</code> string, also avoiding redirection (since I'm testing in the browser)?</p>
<javascript><mocha><sinon><stubbing>
2016-04-17 15:12:26
HQ
36,678,868
Find Highest Value in a dictionary
<p>I have a dictionary like so:</p> <pre><code>class1 = { max: 10, 3, 5 Michael: 4. 4, 8 jack: 0, 0, 3 } </code></pre> <p>This is the relevant code</p> <pre><code>class1 = {} with open("1.txt", "r+") as f: for line in f: columns = line.split(":") if len(columns) == 2: names = columns[0] scores = columns[1].strip() else: pass if class1.get(names): class1[names].append(scores) else: class1[names] = list(scores) </code></pre> <p>The numbers represent the scores and I would like for the highest score for each name to be printed out, this is my desired output:</p> <pre><code>max: 10 Micheal: 8 jack: 3 </code></pre> <p>I have already tried this:</p> <pre><code>max_value = max(class1.values()) print(sorted(max_value)) </code></pre> <p>But it makes no difference to my output.</p> <p>Thank you in advanced</p>
<python><dictionary>
2016-04-17 16:05:29
LQ_CLOSE
36,679,379
Elixir - Call method on module by String-name
<p>I'm pretty new to Elixir and functional programming-languages in general.</p> <p>In Elixir, I want to call one specific function on Modules, given the Module name as String.</p> <p>I've got the following (very bad) code working, which pretty much does what I want to:</p> <pre><code>module_name = elem(elem(Code.eval_file("module.ex", __DIR__), 0), 1) apply(module_name, :helloWorld, []) </code></pre> <p>This (at least as I understand it) compiles the (already compiled) module of <code>module.ex</code> in the current directory. I'm extracting the modules name (not as a String, don't know what data-type it actually is) out of the two tuples and run the method <code>helloWorld</code> on it.</p> <p>There are two problems with this code:</p> <ol> <li><p>It prints a warning like <code>redefining module Balance</code>. I certainly don't want that to happen in production.</p></li> <li><p>AFAIK this code compiles <code>module.ex</code>. But as module.ex is already compiled and loaded, it don't want that to happen.</p></li> </ol> <p>I don't need to call methods on these modules by filename, the module-name would be ok too. But it does have to by dynamic, eg. entering "Book" at the command line should, after a check whether the module exists, call the function <code>Book.helloWorld</code>.</p> <p>Thanks.</p>
<dynamic><module><load><elixir>
2016-04-17 16:50:55
HQ
36,679,934
how would i return a instance of interface Infocard?
i am currently doing an assignment for my computer science course, however i have ran into a road block preventing me advancing any further. i am trying to return the InfoCard interface and i am unsure as to how. public interface IInfoCardFactory { IInfoCard CreateNewInfoCard(string category); IInfoCard CreateInfoCard(string initialDetails); string[] CategoriesSupported { get; } string GetDescription(string category); } public IInfoCard CreateNewInfoCard(string category) { ...... }
<c#><interface>
2016-04-17 17:40:56
LQ_EDIT