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 |
|---|---|---|---|---|---|
35,137,732 | How to detect dns server and ip-adresses in PHP | <p>I want to program a DNS-leaktester in PHP. Is it possible? or do I have to use other languages like python etc. to get the information.</p>
| <php><dns> | 2016-02-01 18:29:30 | LQ_CLOSE |
35,138,017 | How to specify which domain using ngrok | <p>I use mamp and I have virtual hosts all on port 8888. For example:</p>
<ul>
<li>site1.dev:8888</li>
<li>site2.dev:8888</li>
</ul>
<p>would point to <code>localhost/site1/</code>, <code>localhost/site2/</code> etc.</p>
<p>Before using virtual hosts, I would just change my docroot to whatever project I was currently working on and would start ngrok like so</p>
<p><code>./ngrok http 8888</code> and it would launch and give me a random generated *.ngrok.io url.</p>
<p>My question is how do I specify the domain now since I am using virtual hosts?</p>
<p>I've tried <code>./ngrok http site1.dev:8888</code> and it starts but just serves up mamps webroot.</p>
<p>I am using a free account.</p>
| <ngrok> | 2016-02-01 18:48:44 | HQ |
35,138,710 | Parse public keys from .txt file by php | <p>I have .txt file with list of public keys and its ids and status. Exists some "best practice" method how can I extract one of this public key based on KEY_ID in php from .txt file?</p>
<p>keys.txt</p>
<pre><code>KEY_ID: 1
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaq6djyzkpHdX7kt8DsSt6IuSoXjp
WVlLfnZPoLaGKc/2BSfYQuFIO2hfgueQINJN3ZdujYXfUJ7Who+XkcJqHQ==
-----END PUBLIC KEY-----
KEY_ID: 2
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE+Y5mYZL/EEY9zGji+hrgGkeoyccK
D0/oBoSDALHc9+LXHKsxXiEV7/h6d6+fKRDb6Wtx5cMzXT9HyY+TjPeuTg==
-----END PUBLIC KEY-----
KEY_ID: 3
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEkvgJ6sc2MM0AAFUJbVOD/i34YJJ8
ineqTN+DMjpI5q7fQNPEv9y2z/ecPl8qPus8flS4iLOOxdwGoF1mU9lwfA==
-----END PUBLIC KEY-----
</code></pre>
| <php> | 2016-02-01 19:30:48 | LQ_CLOSE |
35,139,127 | Can someone please thoroughly explain what a URI is? | <p>I understand it has something to do with databases but I am not exactly sure what it does.. I looked on the android developer page and they don't explain it very well. </p>
| <uri> | 2016-02-01 19:53:46 | LQ_CLOSE |
35,139,317 | how to clear history in safari while button clicked in objective c | Could you please let me know how to clear safari history while button clicked in our app using ios sdk?
Thanks,
| <ios><objective-c> | 2016-02-01 20:04:04 | LQ_EDIT |
35,139,711 | Running Python script via ansible | <p>I'm trying to run a python script from an ansible script. I would think this would be an easy thing to do, but I can't figure it out. I've got a project structure like this:</p>
<pre><code>playbook-folder
roles
stagecode
files
mypythonscript.py
tasks
main.yml
release.yml
</code></pre>
<p>I'm trying to run mypythonscript.py within a task in main.yml (which is a role used in release.yml). Here's the task:</p>
<pre><code>- name: run my script!
command: ./roles/stagecode/files/mypythonscript.py
args:
chdir: /dir/to/be/run/in
delegate_to: 127.0.0.1
run_once: true
</code></pre>
<p>I've also tried ../files/mypythonscript.py. I thought the path for ansible would be relative to the playbook, but I guess not?</p>
<p>I also tried debugging to figure out where I am in the middle of the script, but no luck there either.</p>
<pre><code>- name: figure out where we are
stat: path=.
delegate_to: 127.0.0.1
run_once: true
register: righthere
- name: print where we are
debug: msg="{{righthere.stat.path}}"
delegate_to: 127.0.0.1
run_once: true
</code></pre>
<p>That just prints out ".". So helpful ...</p>
| <ansible><ansible-2.x> | 2016-02-01 20:28:55 | HQ |
35,139,790 | I want to print a value in debugger in jsp <script> var url = std.setUrl(); alert(url); </script> | The above code gives an alert instead of printing it to a debugger. | <javascript><jsp> | 2016-02-01 20:34:14 | LQ_EDIT |
35,140,116 | Accessing navigator in Actions with React-Native and Redux | <p>Using React-Native (0.19) and Redux, I'm able to navigate from scene to scene in React Components like so:</p>
<pre><code>this.props.navigator.push({
title: "Registrations",
component: RegistrationContainer
});
</code></pre>
<p>Additionally I'd like to be able push components to the navigator from anywhere in the app (reducers and/or actions).</p>
<p>Example Flow:</p>
<ol>
<li>User fills out form and presses Submit</li>
<li>We dispatch the form data to an action</li>
<li>The action sets state that it has started to send data across the wire</li>
<li>The action fetches the data</li>
<li>When complete, action dispatches that the submission has ended</li>
<li>Action navigates to the new data recently created</li>
</ol>
<p>Problems I'm seeing with my approach:</p>
<ul>
<li>The navigator is in the props, not the state. In the reducer, I do not have access to the props</li>
<li>I need to pass <code>navigator</code> into any action that needs it. </li>
</ul>
<p>I feel like I'm missing something slightly simple on how to access Navigator from actions without sending in as a parameter. </p>
| <react-native><redux> | 2016-02-01 20:53:15 | HQ |
35,140,117 | How to interpret LDA components (using sklearn)? | <p>I used <strong>Latent Dirichlet Allocation</strong> (<strong>sklearn</strong> implementation) to analyse about 500 scientific article-abstracts and I got topics containing most important words (in german language). My problem is to interpret these values associated with the most important words. I assumed to get probabilities for all words per topic which add up to 1, which is not the case. </p>
<p>How can I interpret these values? For example I would like to be able to tell why topic #20 has words with much higher values than other topics. Has their absolute height to do with Bayesian probability? Is the topic more common in the corpus? Im not yet able to bring together theses values with the math behind the LDA.</p>
<pre class="lang-py prettyprint-override"><code>from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation
tf_vectorizer = CountVectorizer(max_df=0.95, min_df=1, top_words=stop_ger,
analyzer='word',
tokenizer = stemmer_sklearn.stem_ger())
tf = tf_vectorizer.fit_transform(texts)
n_topics = 10
lda = LatentDirichletAllocation(n_topics=n_topics, max_iter=5,
learning_method='online',
learning_offset=50., random_state=0)
lda.fit(tf)
def print_top_words(model, feature_names, n_top_words):
for topic_id, topic in enumerate(model.components_):
print('\nTopic Nr.%d:' % int(topic_id + 1))
print(''.join([feature_names[i] + ' ' + str(round(topic[i], 2))
+' | ' for i in topic.argsort()[:-n_top_words - 1:-1]]))
n_top_words = 4
tf_feature_names = tf_vectorizer.get_feature_names()
print_top_words(lda, tf_feature_names, n_top_words)
Topic Nr.1: demenzforsch 1.31 | fotus 1.21 | umwelteinfluss 1.16 | forschungsergebnis 1.04 |
Topic Nr.2: fur 1.47 | zwisch 0.94 | uber 0.81 | kontext 0.8 |
...
Topic Nr.20: werd 405.12 | fur 399.62 | sozial 212.31 | beitrag 177.95 |
</code></pre>
| <python-3.x><scikit-learn><lda><topic-modeling> | 2016-02-01 20:53:20 | HQ |
35,140,341 | EF7: The term 'add-migration' is not recognized as the name of a cmdlet | <p>I have framework version set to: dnx46 in project.json.
Also have the following packages:</p>
<pre><code> "dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
}
</code></pre>
<p>However when I got into running enable-migrations command I get the following:</p>
<p>The term 'enable-migrations' is not recognized as the name of a cmdlet</p>
<p>Does anyone know how I get EF migrations running in latest .NET?</p>
| <entity-framework><entity-framework-core> | 2016-02-01 21:06:36 | HQ |
35,140,358 | React Native - Fetch POST request is sending as GET request | <p>I'm having issues when using FETCH.</p>
<p>I am trying to make a POST request using FETCH in react-native.</p>
<pre><code> fetch("http://www.example.co.uk/login", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'test',
password: 'test123',
})
})
.then((response) => response.json())
.then((responseData) => {
console.log(
"POST Response",
"Response Body -> " + JSON.stringify(responseData)
)
})
.done();
}
</code></pre>
<p>When I inspect this call using Charles it is recorded as a GET request and the username and password that should be in the body are not there.</p>
<p><a href="https://i.stack.imgur.com/4bITU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4bITU.png" alt="enter image description here"></a></p>
<p>Can anyone help with this issue?</p>
| <react-native> | 2016-02-01 21:07:57 | HQ |
35,140,408 | How to get value from a Java enum | <p>I have a enum which looks like:</p>
<pre><code>public enum Constants{
YES("y"), NO("N")
private String value;
Constants(String value){
this.value = value;
}
}
</code></pre>
<p>I have a test class which looks like</p>
<pre><code>public class TestConstants{
public static void main(String[] args){
System.out.println(Constants.YES.toString())
System.out.println(Constants.NO.toString())
}
}
</code></pre>
<p>The output is:</p>
<pre><code>YES
NO
</code></pre>
<p>instead of </p>
<pre><code>Y
N
</code></pre>
<p>I am not sure what is wrong here ??</p>
| <java><enums> | 2016-02-01 21:10:56 | HQ |
35,141,256 | How to detect when a React Native app is opened? | <p>My React Native app wants to synchronize its local data with an API when the user opens the app. This should happen whenever the user returns to the app, not just when it first starts. Essentially, what I would like is the equivalent of AppDelegate's <code>applicationDidBecomeActive</code> callback, so that I can run synchronization code there. Obviously, I would like to do this in React Native instead.</p>
<p>As far as I can tell, the <code>componentWillMount</code> / <code>componentDidMount</code> callbacks on the root component only run when the app is initially loaded, not after the user leaves the app and comes back later (without explicitly quitting the app).</p>
<p>I thought that the <code>AppState</code> API would provide this functionality, but its <code>change</code> listeners don't fire in this case, either.</p>
<p>This seems like obvious functionality to have, so I must be missing something glaringly obvious. Help!</p>
| <react-native> | 2016-02-01 22:03:05 | HQ |
35,141,419 | Visual studio code color picker | <p>I love visual studio code but there's one thing that is missing in my opinion.<br />
A color picker. <br />
Does anyone know if there's a color picker for visual studio code just like in visual studio?</p>
| <color-picker><visual-studio-code> | 2016-02-01 22:14:28 | HQ |
35,142,273 | Defined a method in Ruby and am trying to return a string that incorporates what the method is calculating | Here's my code:
tv_price = 200.50
tv_buyers = 3
tv_sales = tv_price * tv_buyers
def two_decimals(number)
puts sprintf('%0.2f', number)
end
puts "The total dollar amount of TVs sold today was #{two_decimals(tv_sales).to_s}."
I want to return the following:
**The total dollar amount of TVs sold today was 601.50.**
However, whether I test the code in IRB or run the rb, the return always looks like this:
=>601.50
=>The total dollar amount of TVs sold today was
In that exact order. How can I get the return to be on one line, and in the proper order? Thanks! | <ruby> | 2016-02-01 23:16:52 | LQ_EDIT |
35,142,532 | how to split long lines for fmt.sprintf | <p>I have a very long line in fmt.Sprintf. How do I split it in the code? I don't want to put everything in a single line so the code looks ugly.</p>
<pre><code>fmt.Sprintf("a:%s, b:%s ...... this goes really long")
</code></pre>
| <go><gofmt> | 2016-02-01 23:41:30 | HQ |
35,142,634 | Unknown override specifier, missing type specifier | <p>First, <code>Parameter.h</code>:</p>
<pre><code>#pragma once
#include <string>
class Parameter {
public:
Parameter();
~Parameter();
private:
string constValue;
string varName;
};
</code></pre>
<p>And <code>Parameter.cpp</code>:</p>
<pre><code>#include "Parameter.h"
using namespace std;
Parameter::Parameter() {};
Parameter::~Parameter() {};
</code></pre>
<p>I've brought these two files down to the barest of bones to get the errors that seem to be popping up. At the two private declarations for <code>string</code>s, I get the two errors:</p>
<pre><code>'constValue': unknown override specifier
missing type specifier - int assumed. Note: C++ does not support default-int
</code></pre>
<p>I've seen several questions with these errors, but each refers to circular or missing references. As I've stripped it down to what's absolutely required, I can see no circular references or references that are missing.</p>
<p>Any ideas?</p>
| <c++> | 2016-02-01 23:51:30 | HQ |
35,142,656 | where did NUnit Gui Runner go? version 3.0.1 | <p>I just upgraded to version 3.0.1 from nunit 2.6.4. It used to have a NUnit Gui Runner, located here:</p>
<p><a href="https://i.stack.imgur.com/PNHqE.png"><img src="https://i.stack.imgur.com/PNHqE.png" alt="enter image description here"></a></p>
<p>After installing 3.0.1 (which I downloaded windows version <a href="http://www.nunit.org/index.php?p=download">from here</a>)</p>
<p>I now no longer see the nunit.exe in the installation folder, for example the directory structure is different and appears to be missing many files that were part of the previous installation:</p>
<p><a href="https://i.stack.imgur.com/zN6c4.png"><img src="https://i.stack.imgur.com/zN6c4.png" alt="enter image description here"></a></p>
| <nunit> | 2016-02-01 23:53:34 | HQ |
35,143,055 | How to mock psycopg2 cursor object? | <p>I have this code segment in Python2:</p>
<pre><code>def super_cool_method():
con = psycopg2.connect(**connection_stuff)
cur = con.cursor(cursor_factory=DictCursor)
cur.execute("Super duper SQL query")
rows = cur.fetchall()
for row in rows:
# do some data manipulation on row
return rows
</code></pre>
<p>that I'd like to write some unittests for. I'm wondering how to use <code>mock.patch</code> in order to patch out the cursor and connection variables so that they return a fake set of data? I've tried the following segment of code for my unittests but to no avail:</p>
<pre><code>@mock.patch("psycopg2.connect")
@mock.patch("psycopg2.extensions.cursor.fetchall")
def test_super_awesome_stuff(self, a, b):
testing = super_cool_method()
</code></pre>
<p>But I seem to get the following error:</p>
<pre><code>TypeError: can't set attributes of built-in/extension type 'psycopg2.extensions.cursor'
</code></pre>
| <python><python-2.7><unit-testing><mocking><psycopg2> | 2016-02-02 00:34:57 | HQ |
35,143,300 | i get a segmentation fault (core dumped) error but only when half my code runs | the goal of this code is to manipulate an ASCII "image" that comes in the form of a really long string that i print out on different lines
.............
.............
.XXX.....X...
.XXX.....X...
.XXX.........
.XXX.........
.XXXXXXX.....
.XXXXXXX.....
.XXXXXXX.....
...........
it looks like this
` #include <iostream>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <vector>
#include <string>
#include <cassert>
int main (int argc, char* argv[]) {
std::fstream img(argv[1]);
std::vector<char> path;
char x;
while (img >> x) {
path.push_back(x);
}
for (char i = 0; i < path.size(); ++i){
if (i%13==0){
std::cout << path[i] << std::endl;
}
else{
std::cout << path[i];
}
}
std::string replace = "replace";
std::string dilation1 = "dilation";
std::string erosion1 = "erosion";
std::string floodfill1 = "floodfill";
char old_char = argv[4][0];
char new_char = argv[5][0];
if (argv[3] == replace) {
for (char n=0; n<path.size(); ++n){
if(path[n]==old_char){
path[n]=new_char;
}
}
for (char i = 0; i < path.size(); ++i){
if (i%13==0){
std::cout << path[i] << std::endl;
}
else{
std::cout << path[i];
}
}
}
if (argv[3] == dilation1) {
std::cout << "this is ok" << std::endl;
}
}`
here is my code
the replace part of the code is meant to take this as the input from the console
./image_processing.out input4.txt output4_replace.txt replace X O
and replace the X's with O's
and it works
but then i move onto the dilation function which takes this as input from the console
./image_processing.out input4.txt output4_dilation.txt dilation X
nevermind wat it does yet i havent even gotten that far because whenever i try to run the code with the second "if" statement i get this
.............
.............
.XXX.....X...
.XXX.....X...
.XXX.........
.XXX.........
.XXXXXXX.....
.XXXXXXX.....
.XXXXXXX.....
Segmentation fault (core dumped)
i dont know why it does this and i dont know why it only gets as far as the last line before it does that, when i comment out the second if statement the code runs fine however it only does replace | <c++> | 2016-02-02 01:02:35 | LQ_EDIT |
35,144,103 | Sometimes pip install is very slow | <p>I am sure it is not network issue. Some of my machine install packages using pip is very fast while some other machine is pretty slow, from the logs, I suspect the slow is due to it will compile the package, I am wondering how can I avoid this compilation to make the pip installation fast. Here's the logs from the slow pip installation.</p>
<pre><code>Collecting numpy==1.10.4 (from -r requirements.txt (line 1))
Downloading numpy-1.10.4.tar.gz (4.1MB)
100% |ββββββββββββββββββββββββββββββββ| 4.1MB 95kB/s
Requirement already satisfied (use --upgrade to upgrade): wheel==0.26.0 in ./lib/python2.7/site-packages (from -r requirements.txt (line 2))
Building wheels for collected packages: numpy
Running setup.py bdist_wheel for numpy ... -
done
Stored in directory: /root/.cache/pip/wheels/66/f5/d7/f6ddd78b61037fcb51a3e32c9cd276e292343cdd62d5384efd
Successfully built numpy
</code></pre>
| <python><pip> | 2016-02-02 02:38:47 | HQ |
35,144,135 | How to upload a json file with secret keys to Heroku | <p>I'm building a rails app that pulls data from Google Analytics using the Google Api Client Library for Ruby.</p>
<p>I'm using OAuth2 and can get everything working in development on a local machine. My issue is that the library uses a downloaded file, <code>client_secrets.json</code>, to store two secret keys.</p>
<p><strong>Problem:I'm using Heroku and need a way to get the file to their production servers.</strong> </p>
<p>I don't want to add this file to my github repo as the project is public. </p>
<p>If there is a way to temporarily add the file to git, push to Heroku, and remove from git that would be fine. My sense is that the keys will be in the commits and very hard to prevent from showing on github. </p>
<p><strong>Tried:</strong>
As far I can tell you cannot SCP a file to Heroku via a Bash console. I believe when doing this you get a new Dyno and anything you add would be only be temporary. I tried this but couldn't get SCP to work properly, so not 100% sure about this.</p>
<p><strong>Tried:</strong>
I looked at storing the JSON file in an Environment or Config Var, but couldn't get it to work. This seems like the best way to go if anyone has a thought. I often run into trouble when ruby converts JSON into a string or hash, so possibly I just need guidance here. </p>
<p><strong>Tried:</strong>
Additionally I've tried to figure out a way to just pull out the keys from the JSON file, put them into Config Vars, and add the JSON file to git. I can't figure out a way to put <code>ENV["KEY"]</code> in a JSON file though. </p>
<hr>
<p><strong>Example Code</strong>
The <a href="https://developers.google.com/api-client-library/ruby/auth/web-app" rel="noreferrer">Google library has a method</a> that loads the JSON file to create an authorization client. The client then fetches a token (or gives a authorization url).</p>
<pre><code>client_secrets = Google::APIClient::ClientSecrets.load('client_secrets.json')
auth_client = client_secrets.to_authorization
</code></pre>
<p>** note that the example on google page doesn't show a filename because it uses a default ENV Var thats been set to a path</p>
<p>I figure this would all be a lot easier if the <code>ClientSecrets.load()</code> method would just take JSON, a string or a hash which could go into a Config Var. </p>
<p>Unfortunately it always seems to want a file path. When I feed it JSON, a string or hash, it blows up. <a href="http://ar.zu.my/how-to-store-private-key-files-in-heroku/" rel="noreferrer">I've seen someone get around the issue with a p12 key here</a>, but I'm not sure how to replicate that in my situation. </p>
<p><strong>Haven't Tried:</strong>
My only other though (aside from moving to AWS) is to put the JSON file on AWS and have rails pull it when needed. I'm not sure if this can be done on the fly or if the file would need to be pulled down when the rails server boots up. Seems like too much work, but at this point I've spend a few hours on it so ready to attempt. </p>
<p>This is the specific controller I am working on:
<a href="https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb" rel="noreferrer">https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb</a></p>
| <ruby-on-rails><ruby><json><git><heroku> | 2016-02-02 02:43:49 | HQ |
35,144,550 | How to install cryptography on ubuntu? | <p>My ubuntu is 14.04 LTS.</p>
<p>When I install cryptography, the error is:</p>
<pre><code>Installing egg-scripts.
uses namespace packages but the distribution does not require setuptools.
Getting distribution for 'cryptography==0.2.1'.
no previously-included directories found matching 'documentation/_build'
zip_safe flag not set; analyzing archive contents...
six: module references __path__
Installed /tmp/easy_install-oUz7ei/cryptography-0.2.1/.eggs/six-1.10.0-py2.7.egg
Searching for cffi>=0.8
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 1.5.0
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.5.0.tar.gz#md5=dec8441e67880494ee881305059af656
Processing cffi-1.5.0.tar.gz
Writing /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/setup.cfg
Running cffi-1.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/egg-dist-tmp-A2kjMD
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
An error occurred when trying to install cryptography 0.2.1. Look above this message for any errors that were output by easy_install.
While:
Installing egg-scripts.
Getting distribution for 'cryptography==0.2.1'.
Error: Couldn't install: cryptography 0.2.1
</code></pre>
<p>I don't know why it was failed. What is the reason. Is there something necessary when install it on ubuntu system?</p>
| <python><ubuntu><cryptography><pip> | 2016-02-02 03:31:15 | HQ |
35,144,670 | Realm Exception 'value' is not a valid managed object | <p>I'm setting a property on a realm object with another realm object which is a different class, however I'm getting the error: 'value' is not avalid managed object.</p>
<pre><code>realmObject.setAnotherRealmObject(classInstance.returnAnotherRealmObjectWithValues())
</code></pre>
<p>The class instance receives anotherRealmObject constructor and returns it through the method with values from widgets:</p>
<pre><code>public ClassInstance(AnotherRealmObject anotherRealmObject){
mAnotherRealmObject = anotherRealmObject;
}
public AnotherRealmObject returnAnotherRealmObjectWithValues(){
mAnotherRealmObject.setId(RandomUtil.randomNumbersAndLetters(5));
mAnotherRealmObject.setName(etName.getText().toString());
return mAnotherRealmObject;
}
</code></pre>
<p>I'm creating the new Another Realm Object the right way (I think):</p>
<pre><code>mAnotherRealmObject = mRealmInstance.createObject(AnotherRealmObject.class);
</code></pre>
<p>Is it because I'm returning anotherRealmObject wherein it is already modified because of the passing reference?</p>
| <android><realm> | 2016-02-02 03:45:02 | HQ |
35,144,784 | How to use migration programmatically in EntityFramework Codefirst? | <p>I'm working in a project that uses EF Code First. I'm trying to use migration features. I don't want to use Package Console Manager. How can I execute the "Add-Migration" and "Update-Database" programmatically? </p>
<pre><code>add-migration TestMigration01 -force
update-database
</code></pre>
| <c#><entity-framework><ef-code-first><entity-framework-6><entity-framework-migrations> | 2016-02-02 03:58:32 | HQ |
35,144,835 | Fluentd vs Kafka | <p>The use case is this:
I've several java applications running which all have to interact with different (each one has a specific target) elasticsearch indices. For instance an application A uses the indices A,B,C of ElasticSearch to query and update. Application B uses indices A,C,D(say). </p>
<p>Some common interface is required which can manage all these data streams. Currently I'm evaluating Kafka and fluentd for this purpose.
Can someone explain which will be better suited for this situation. I've looked at features of both Kafka and Fluentd and I don't really understand the difference it would make here.
Thanks a lot.</p>
| <elasticsearch><apache-kafka><fluentd> | 2016-02-02 04:04:13 | HQ |
35,145,159 | Simplest way to validate string (Java) | <p>I want to check that a string meets the following criteria:</p>
<ul>
<li>Consists of exactly two words</li>
<li>Each word contains only letters (A-Z and a-z), and is at least two letters long</li>
<li>The two words are separated by exactly one space</li>
</ul>
<p>For example, "Jon Snow" should validate, and any other name consisting of only one given name and one family name, and no special characters.</p>
<p>What is the simplest way to ensure this validation?</p>
<p>Thanks!</p>
| <java><regex><string><validation> | 2016-02-02 04:38:39 | LQ_CLOSE |
35,145,203 | Which ad network do these guys use? | I've been watching these guys and their ad on the lock screen, i'd like to know which ad network they're using, is there a way to find this out?
please let me know as this would really help me make an informed decision.
[enter image description here][1]
[1]: http://i.stack.imgur.com/J849H.png | <ads> | 2016-02-02 04:42:42 | LQ_EDIT |
35,145,400 | git checkout my_branch vs. git checkout origin/my_branch | <p>I was on <code>branch1</code> when I checkout <code>branch2</code> like this (both branches are existing).</p>
<p><code>git checkout origin/branch2</code></p>
<p>then I got a detached head error:</p>
<pre><code>You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
</code></pre>
<p>But then I just checkout <code>branch2</code> (without <code>origin</code>) then it works ok:</p>
<p><code>git checkout branch2</code></p>
<p>So what's the difference between <code>git checkout</code> with and without <code>origin/</code>; and why there was the <code>detached HEAD</code> error when using <code>origin/</code>?</p>
| <git> | 2016-02-02 05:00:39 | HQ |
35,145,702 | I want to read text from motor plate image | <p>I have develop OCR Demo app using tessaract library its giving 100% result from image which keep simple text.but i want to read text from motor plate image.
if any one knows please help me.
<a href="https://i.stack.imgur.com/q2buH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q2buH.png" alt="i want to read text from this image"></a></p>
| <android> | 2016-02-02 05:27:20 | LQ_CLOSE |
35,146,662 | how to return opposite of true or false | I was interview in company and i was asked a question , question was bti strange so wanted to ask with expert guys.
The question suppose i have function which returns bool type, Lets say this :
public bool func(int param)
{
bool retVal;
//here is some algorithm which as a result either set the retVal to false or true, It doesnt matter what is algo, the only thing important is it either do retVal=false or retVal=true
// The question is i have to write the algo here which in case if the previous algo gives us retVal=fale then it should return true and if retVal=true then return flase
}
**What should be that algo ?* | <c><algorithm><data-structures> | 2016-02-02 06:37:09 | LQ_EDIT |
35,147,009 | How does setting the height of elemets html and body to 100% help me in setting the height of an element to the device's screen height? | [I tumbled upon this question here][1]
[1]: http://stackoverflow.com/questions/12172177/set-div-height-equal-to-screen-size
Look at the answer,
He put the height of the body and html to 100%
which helped him solve his answer,
Can I get correct explanation for this?
why that happens? what if I don't use the overflows?
or don't put 100% height to the html or body element? | <html><css> | 2016-02-02 06:59:56 | LQ_EDIT |
35,147,366 | Check if a value exits in array (Laravel or Php) | <p>I have this array:</p>
<pre><code>$list_desings_ids = array('hc1wXBL7zCsdfMu','dhdsfHddfD','otheridshere');
</code></pre>
<p>With a die() + var_dumo() this array return me:</p>
<pre><code>array:2 [βΌ
0 => "hc1wXBL7zCsdfMu"
1 => "dhdsfHddfD"
2 => "otheridshere"
]
</code></pre>
<p>I want check if a design_id exits in $list_desings_ids array.</p>
<p>For example:</p>
<pre><code>foreach($general_list_designs as $key_design=>$design) {
#$desing->desing_id return me for example: hc1wXBL7zCsdfMu
if(array_key_exists($design->design_id, $list_desings_ids))
$final_designs[] = $design;
}
</code></pre>
<p>But this not works to me, what is the correct way?</p>
| <php><arrays><laravel> | 2016-02-02 07:23:28 | HQ |
35,147,995 | unexpected else statement in php | <p>My code retrieve videos based on user connection speed.</p>
<p>I am getting syntax error unexpected else on my code. i am troubleshooting this for the past few days and had run out of idea on how to solve it..</p>
<p>ajax code</p>
<pre><code> $.ajax({
method: "POST",
url: "viewvideo.php",
data: {speedMbps: speedMbps,
video_id: $('[name="video_id"').val()},
cache: false
}).done(function( html ) {
$( "#speed" ).val( html );
});
</code></pre>
<p>viewvideo.php</p>
<pre><code> if(isset($_POST['video_id']) && isset($_POST['speedMbps'] )){
$id = trim($_POST['video_id']);
$speed = $_POST['speedMbps'];
echo $id;
$result = mysqli_query($dbc , "SELECT `video_id`, `video_link` FROM `video480p` WHERE `video_id`='".$id."'");
$count = mysqli_num_rows($result);
if (($speed < 100) && ($count>0)) { //if user speed is less than 100 retrieve 480p quailtiy video
//does it exist?
//if($count>0){
//exists, so fetch it in an associative array
$video_480p = mysqli_fetch_assoc($result);
//this way you can use the column names to call out its values.
//If you want the link to the video to embed it;
echo $video_480p['video_link'];
}
else{
//does not exist
}
?>
<video id="video" width="640" height="480" controls autoplay>
<source src="<?php echo $video_480p['video_link']; ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<br />
<?php
$result2 = mysqli_query($dbc , "SELECT `video_id`, `video_link` FROM `viewvideo` WHERE `video_id`='".$video_id."'");
$count2 = mysqli_num_rows($result2);
// retrieve original video
else (($speed >= 100) && ($count2 >0)) {
//does it exist?
//if($count2>0){
//exists, so fetch it in an associative array
$video_arr = mysqli_fetch_assoc($result2);
//this way you can use the column names to call out its values.
//If you want the link to the video to embed it;
echo $video_arr['video_link'];
}
else{
//does not exist
}
}
?>
<video id="video" width="640" height="480" controls autoplay>
<source src="<?php echo $video_arr['video_link']; ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<br />
<?php
}
mysqli_close($dbc);
?>
</code></pre>
| <javascript><php><ajax> | 2016-02-02 08:05:11 | LQ_CLOSE |
35,148,100 | why using stack data structure for storing primitive values instead of linked lists or arrays ? | <p>Since Stacks internally uses either Linked Lists / Arrays, why don't java directly store primitive values in Linked Lists / Arrays instead of Stacks ? </p>
| <java><memory><memory-management><data-structures><stack> | 2016-02-02 08:11:54 | LQ_CLOSE |
35,148,468 | Safari View Controller uses wrong status bar color | <p>My app uses a dark navigation bar color. Therefore I set the status bar color to white (so it has a nice contrast).</p>
<p><a href="https://i.stack.imgur.com/nDItJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nDItJ.png" alt="red navigation bar with white status bar"></a></p>
<p>I did this by setting the <strong>barStyle</strong> to black (to make the status bar white) and also setting the <strong>barTint</strong> to my dark red color. Works perfectly.</p>
<p>I present a <code>SafariViewController</code> like this:</p>
<pre><code>func openWebsite(urlString: String) {
if let url = NSURL(string: urlString) {
let svc = SFSafariViewController(URL: url)
svc.delegate = self
self.presentViewController(svc, animated: true, completion: nil)
}
}
</code></pre>
<p>However the status bar of the presented <code>SafariViewController</code> still is white. This is a problem because the <code>SVC</code> navigation bar has the default white transparent iOS default style. So the status bar is basically invisible.</p>
<p><a href="https://i.stack.imgur.com/o9HoA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/o9HoA.png" alt="safari view controller with white status bar color"></a></p>
<p>How can I fix that?</p>
| <ios><colors><uinavigationbar><statusbar><sfsafariviewcontroller> | 2016-02-02 08:34:28 | HQ |
35,148,530 | Why is this memory referencing segfault? | <pre><code>double fun(int i)
{
volatile double d[1] = {3.14};
volatile long int a[2];
a[i] = 1073741824;
return d[0];
}
</code></pre>
<p>fun(0) β 3.14</p>
<p>fun(1) β 3.14</p>
<p>fun(2) β 3.1399998664856</p>
<p>fun(3) β 2.00000061035156</p>
<p>fun(4) β 3.14, then segmentation fault</p>
<p>can someone explain to me whats going on in this example and why segfault dont show up when calling func(2)?
and why return value not always 3.14?</p>
| <c><memory-management> | 2016-02-02 08:37:56 | LQ_CLOSE |
35,149,275 | Indent/format code in Visual Studio code on MAC | <p>i'm trying to indent my code in visual studio code. I searched and i found that ctrl + F + K should be work, but it doesn't. I tried cmd + k + f too, but it still not working. I hope you can help me!</p>
| <macos><indentation><auto-indent><visual-studio-code> | 2016-02-02 09:18:37 | HQ |
35,149,422 | How to fix the maven check style error | <p>Currently I just tried to download and build to make the Netty source code work. But when I tried to run the command <code>mvn eclipse:eclipse</code> in the source folder. I got an error said </p>
<pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.10:check (check-style) on project netty-common: Failed during checkstyle execu
tion: There are 304 checkstyle errors. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.10:check (check-style) on proj
ect netty-common: Failed during checkstyle execution
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed during checkstyle execution
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:374)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 24 more
Caused by: org.apache.maven.plugin.checkstyle.CheckstyleExecutorException: There are 304 checkstyle errors.
at org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:218)
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:365)
</code></pre>
<p>It is error of the checkstyle plugin when validating the code <code>netty-common</code> project. </p>
<p>I am not familiar with this plugin . I want to know if I can just ignore it by removing the configuration from the pom.xml(in the ). like below.</p>
<pre><code><plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>check-style</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
<configuration>
<consoleOutput>true</consoleOutput>
<logViolationsToConsole>true</logViolationsToConsole>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<configLocation>io/netty/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-build</artifactId>
<version>21</version>
</dependency>
</dependencies>
</plugin>
</code></pre>
<p>Any idea ? Thanks.</p>
| <java><maven><netty> | 2016-02-02 09:25:37 | HQ |
35,149,563 | how to optimize this mysql query - %a% or | SELECT DISTINCT u.id AS userId,u.type AS userType FROM User AS u,Personal AS p,Company AS c WHERE (p.realName LIKE
'%adf%' AND u.type=1 AND u.id=p.userId) OR (c.name LIKE
'%grge%' AND u.id=c.userId) LIMIT 0 , 10000 | <mysql> | 2016-02-02 09:31:40 | LQ_EDIT |
35,149,690 | Configure sublime text 3 folder node_modules for node.js | <p>I need node_modules in the sidebar but not when searching files, "go to files".</p>
<p>If I use</p>
<pre><code>{
"folder_exclude_patterns": [ "node_modules"]
}
</code></pre>
<p>It works ok except for the sidebar. </p>
| <node.js><sublimetext3> | 2016-02-02 09:37:51 | HQ |
35,149,777 | Provider cannot be found. It may not be properly installed : ADODB | <p>I am using ADO to connect to EXCEL from 64bit machine by VBScript. The MS Office(2013) is 32bit.
The connection string is </p>
<pre><code>Set objExcel = CreateObject( "ADODB.Connection" )
objExcel.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & myXlsFile & ";Extended Properties=""Excel 12.0;IMEX=1;" & strHeader & """"
</code></pre>
<p>And it shows an error: <strong>Provider cannot be found. It may not be properly installed</strong>
error code:<strong>800A0E7A</strong> </p>
<p>Please help me
Thanks in advance.</p>
| <vbscript> | 2016-02-02 09:42:03 | LQ_CLOSE |
35,149,861 | Equivalent urllib.parse.quote() in python 2.7 | <p>What is the equivalent of <code>urllib.parse.quote</code></p>
<p>It's <code>urllib.urlencode()</code>?</p>
<p>Thanks</p>
| <python><python-2.7><python-3.x> | 2016-02-02 09:45:46 | HQ |
35,150,186 | Getting git-revision hash with webpack | <p>I'm trying to create archive with webpack with suffix by git-revision. Could you tell me please what is good way to do it?</p>
| <webpack><git-revision> | 2016-02-02 09:59:10 | HQ |
35,150,409 | Fixed navbar separates from top of browser on Chrome for iPhone | <p>I have a website with a bootstrap fixed-to-top navigation bar (<a href="https://getbootstrap.com/examples/navbar-fixed-top/" rel="noreferrer">example here</a>), and noticed that, using Chrome on an iPhone, the navbar separates from the top of the screen by just a few pixels when scrolling quickly. This is shown in the following screenshot, from the bootstrap navbar example page:</p>
<p><a href="https://i.stack.imgur.com/zwExk.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zwExk.jpg" alt="Fixed navbar separation"></a></p>
<p>This only happens on Chrome on an iPhone, and not on an iPad or any Mac/PC I've tested. It also happens on every website with a fixed navbar that I could find. The only thing I can think of is to extend the background color of the navbar up above the top of the browser so that, when the navbar is eventually pulled down, it doesn't fully separate from the screen. However, that still leaves the content of the navbar pulled down, and certainly seems like a dirty fix.</p>
<p>Has anyone else run into this issue, and is there any sort of known fix available?</p>
| <html><css><iphone><google-chrome> | 2016-02-02 10:08:25 | HQ |
35,150,709 | Authorise Pinterest App | <p>I have added a collaborator for my Pinterest app, however, when accessing the colaberators account and clicking on the application there is no 'authorise' button or anything similar. The "You still need at least 1 collaborator to authorize your app before you can submit" warning still shows on the collaberators account.
Ant help would be appreciated, thanks!</p>
| <api><pinterest> | 2016-02-02 10:20:55 | HQ |
35,150,847 | Why is sub class' static code getting executed? | <p>I have written the following code and created object for the super class.</p>
<pre><code>class SuperClass{
static int a=2;
static int b(){
return 2;
}
int c(){
return 2;
}
SuperClass(){
System.out.println("Super");
}
static {
System.out.println("super");
}
}
public class Sub extends SuperClass{
Sub(){
System.out.println("Sub");
}
static {
System.out.println("sub");
}
static int b(){
return 3;
}
int c(){
return 3;
}
public static void main(String ax[]){
SuperClass f =new SuperClass();
System.out.println(f.c());
System.out.print(SuperClass.b());
}
}
</code></pre>
<p>When I checked the output, it is as follows:</p>
<pre><code>super
sub
Super
2
2
</code></pre>
<p>I know that static block is executed only when object of the class is initialized or any static reference is made. But here, i did not make any of these to Sub class. then why do i see "sub" i.e. sub class' static block output?</p>
| <java><constructor><static><static-methods> | 2016-02-02 10:26:57 | HQ |
35,151,985 | Activity crash while launching third party application | I am trying to start new application on certain Action click and suppose for any reason that application get crashed and doesn't launch,why is it crashing my current activity which started that application.
launchmode for current activity is singleTask and same for other app as well and care has been taken to addFlag of NEW_TASK while launching the other application.
I want behavior in such a way that even launching application get crashed then it should redirect the user to current activity(launcher activity) rather than crashing the current activity. | <android><android-activity> | 2016-02-02 11:18:11 | LQ_EDIT |
35,152,310 | Mongoose text-search with partial string | <p>Hi i'm using <strong>mongoose</strong> to search for persons in my collection.</p>
<pre><code>/*Person model*/
{
name: {
first: String,
last: String
}
}
</code></pre>
<p>Now i want to search for persons with a query:</p>
<pre><code>let regex = new RegExp(QUERY,'i');
Person.find({
$or: [
{'name.first': regex},
{'name.last': regex}
]
}).exec(function(err,persons){
console.log(persons);
});
</code></pre>
<p>If i search for <strong>John</strong> i get results (event if i search for <strong>Jo</strong>).
But if i search for <strong>John Doe</strong> i am not getting any results obviously.</p>
<p>If i change <strong>QUERY</strong> to <strong>John|Doe</strong> i get results, but it returns all persons who either have <strong>John</strong> or <strong>Doe</strong> in their last-/firstname.</p>
<p>The next thing was to try with mongoose textsearch:</p>
<p>First add fields to index:</p>
<pre><code>PersonSchema.index({
name: {
first: 'text',
last: 'text'
}
},{
name: 'Personsearch index',
weights: {
name: {
first : 10,
last: 10
}
}
});
</code></pre>
<p>Then modify the Person query:</p>
<pre><code>Person.find({
$text : {
$search : QUERY
}
},
{ score:{$meta:'textScore'} })
.sort({ score : { $meta : 'textScore' } })
.exec(function(err,persons){
console.log(persons);
});
</code></pre>
<p>This works just fine! <strong>But</strong> now it is only returning persons that match with the whole first-/lastname: </p>
<p>-> <strong>John</strong> returns value</p>
<p>-> <strong>Jo</strong> returns no value</p>
<p>Is there a way to solve this? </p>
<p>Answers <strong>without external plugins</strong> are preferred but others are wished too.</p>
| <node.js><mongodb><mongoose><text-search> | 2016-02-02 11:33:46 | HQ |
35,152,462 | How to avoid memory leak | Question on memory leak. Probably a basic one.
C++ Pseudo code:
map map_a;
for ( 1 to 10 ) {
element = 5;
vector<int> *ptr = map_a[element];
if (!ptr) {
ptr = new vector<int>;
map[element] = ptr;
}
ptr->push_back(i);
}
How to free up the memory we are allocation using new? | <c++> | 2016-02-02 11:40:55 | LQ_EDIT |
35,152,522 | React Transferring Props except one | <p>React suggests to <a href="https://facebook.github.io/react/docs/reusable-components.html#transferring-props-a-shortcut" rel="noreferrer">Transfer Props</a>. Neat!</p>
<p>How can I transfert all but one?</p>
<pre><code>render: function(){
return (<Cpnt {...this.propsButOne}><Subcpnt one={this.props.one} /></Cpnt>);
}
</code></pre>
| <javascript><reactjs> | 2016-02-02 11:43:29 | HQ |
35,152,605 | SSH connections keep dropping out due to inactivity | <p>My SSH connections keep dropping out due to inactivity in the EC2 hosts. I have tried to put these options [1] in <code>/etc/ssh/ssh_config</code> in the server and in the client, but the connections keep dropping out.</p>
<pre><code>ServerAliveInterval 15
ServerAliveCountMax 3
</code></pre>
<p>How I make connections keep alive?</p>
| <linux><amazon-web-services><ssh><amazon-ec2> | 2016-02-02 11:46:42 | LQ_CLOSE |
35,152,667 | Why do I hot nan? | Simple python code
def m(x,y):
x=2
y=[3,5]
a=1
b=[0,26]
print m(a,b)
I want to change the arguments,if it is possible without return.When I run my code
python d1.py
None
Why?
| <python><python-2.7> | 2016-02-02 11:49:25 | LQ_EDIT |
35,152,818 | std::conditional vs std::enable_if | <p>I have a hashing function that can take any object type and hash it, it uses <code>std::hash</code> internally. Because <code>std::hash</code> does not support enum types I've created overloads of the function, 1 for enumerations using <code>std::underlying_type</code> and 1 for other types:</p>
<pre><code>template <typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
static std::size_t Hash(T const & t)
{
return std::hash<typename std::underlying_type<T>::type>()(t);
}
template <typename T, typename std::enable_if<!std::is_enum<T>::value>::type* = nullptr>
static std::size_t Hash(T const & t)
{
return std::hash<T>()(t);
}
</code></pre>
<p>This is working fine.
I then tried to put it all into a single function with <code>std::conditional</code>:</p>
<pre><code>template <typename T>
static std::size_t Hash(T const & t)
{
typedef typename std::conditional<std::is_enum<T>::value, std::hash<typename std::underlying_type<T>::type>, std::hash<T>>::type Hasher;
return Hasher()(t);
}
</code></pre>
<p>Main:</p>
<pre><code>enum test
{
TEST = 2
};
int main() {
Hash<test>(TEST);
Hash<int>(5);
std::cin.get();
return 0;
}
</code></pre>
<p>This however, gave me an <a href="http://ideone.com/CKckZD" rel="noreferrer">error</a> :</p>
<blockquote>
<p>/usr/include/c++/5/type_traits:2190:38: error: 'int' is not an enumeration type
typedef __underlying_type(_Tp) type;</p>
</blockquote>
<p>I do understand the error but I don't understand why, I thought <code>std::conditional</code> would prevent these compile-time errors because <code><int></code> uses <code>std::hash<T></code> instead of <code>std::hash<typename std::underlying_type<T>::type></code> at compile-time.</p>
<p>What am I doing wrong here, is there a way I can merge the 2 functions?</p>
| <c++><c++14> | 2016-02-02 11:55:35 | HQ |
35,152,945 | getting top 2 rows in each group without row number in sql | i am looking a simple code to get result of 2 rows with latest invoice date in each group . Although this task can be accomplished by a ror_number that you can see in below code , but i need alternative of this with minimum complexity.
Code :-
create table #tt
(
id int,
invoiceDT datetime
)
insert into #tt
values(1,'01-01-2016 00:12'),(1,'01-02-2016 06:16'),(1,'01-01-2016 00:16')
,(2,'01-01-2016 01:12'),(2,'04-02-2016 06:16'),(2,'01-06-2016 00:16')
select *
from (
SELECT id,invoiceDT,row_number() over(partition by id order by invoiceDT desc) as rownum
FROM #tt
)tmp
where rownum <=2
I need same result that is returned by above query
Please suggest alternative. | <sql><sql-server> | 2016-02-02 12:01:07 | LQ_EDIT |
35,153,108 | why is logged_out.html not overriding in django registration? | <p>I am using built-in django login and logout. In my Project/urls.py i have added url's for both login and logout.</p>
<pre><code>from django.conf.urls import include, url
from account import views
from django.contrib.auth import views as auth_views
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^$',views.index,name='Index'),
url(r'^accounts/login/$',auth_views.login,name='login'),
url(r'^accounts/logout/$',auth_views.logout,name='logout'),
url(r'^accounts/register/$',views.register,name='register'),
url(r'^accounts/profile/$',views.profile,name='profile'),
]
</code></pre>
<p>and i've templates folder inside my account app folder. i have directory structure like this</p>
<pre><code>account
-templates
-registration
-login.html
-logged_out.html
-register.html
-rest_html_files
-rest files
</code></pre>
<p>i've read django docs which say that for login() default template is registration/login.html which is working fine in my project and logout() default template is registration/logged_out.html if no arguments is supplied but whenever it Logout button ( which has a href={% url 'logout' %} ) is clicked it redirects to the admin logout page rather than my custom logout page.
what could possibly be wrong??</p>
| <python><django><django-templates> | 2016-02-02 12:08:51 | HQ |
35,153,112 | Gradle version 2.10 is required. Current version is 2.8 Error | <p>Following things are using in the project-</p>
<blockquote>
<p>The android studio version - 2.0 Preview 4.<br>
ANDROID_BUILD_MIN_SDK_VERSION=9<br>
ANDROID_BUILD_TARGET_SDK_VERSION=22<br>
ANDROID_BUILD_TOOLS_VERSION=22.0.1<br>
ANDROID_BUILD_SDK_VERSION=22<br></p>
</blockquote>
<pre><code>classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
</code></pre>
<p>As per the error I changed the distribution url <br></p>
<pre><code>https\://services.gradle.org/distributions/gradle-2.8-all.zip
</code></pre>
<p>to</p>
<pre><code>https\://services.gradle.org/distributions/gradle-2.10-all.zip
</code></pre>
<p>but still getting the following error<br><br></p>
<blockquote>
<p>Error:(1, 1) A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/manishpathak/Project/live/code/ICCCricketWorldCup2015Schedule/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip</p>
</blockquote>
| <android><android-studio><build.gradle><android-studio-2.0> | 2016-02-02 12:08:54 | HQ |
35,153,377 | receiving array of data using UART arduino | <p>i am trying to send data through UART in arduino to fingerprint scanner
i am using an array to send the commands and it works fine </p>
<pre><code>for(i =0 ; i<= 24 ; i++)
{
Serial.write(SendArray[i]);
SendArray[i] =0;
}
</code></pre>
<p>the problem is when i'm trying to receive response from the fingerprint
the fingerprint response is 24 bytes so i tried to receive the bytes and store them in an array of 24 elements </p>
<pre><code> for(k=0 ; k<=24 ; k++)
{
RecieveArray[k] = Serial.read();
}
</code></pre>
<p>but when i try to print an element from the received array i get strange symbols </p>
| <c><arrays><arduino> | 2016-02-02 12:20:43 | LQ_CLOSE |
35,153,774 | mongoimport json file syntax | <p>I'm trying to import json document using mongoimport command and have tried all possible ways but it's giving be below error. Plz tell me what m I doing wrong here. I've given full path of json doc. I want to import big document having 800+ records but because it failing so currently my students.json contains simple one line {name : "Archana"} but even this is failing.</p>
<pre><code>C:\data\db>mongo
2016-02-02T17:48:44.788+0530 I CONTROL [main] Hotfix KB2731284 or later update is installed, no need to zero-out data
MongoDB shell version: 3.2.1
connecting to: test
> show collections
names
students
> mondoimport -d test -c students students.json
2016-02-02T17:50:21.001+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < students.json
2016-02-02T17:50:25.840+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < file students.json
2016-02-02T17:50:31.233+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f students.json
2016-02-02T17:50:35.417+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f C:\data\db\students.json
2016-02-02T17:50:51.658+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f "C:\data\db\students.json"
2016-02-02T17:50:56.897+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students C:\data\db\students.json
2016-02-02T17:51:06.849+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -db test -c students C:\data\db\students.json
2016-02-02T17:54:33.545+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:16
> mondoimport --db test --collection students C:\data\db\students.json
2016-02-02T17:56:24.253+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students --file C:\data\db\students.json
2016-02-02T17:56:33.589+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students --file C:\data\db\students.json --jsonArray
2016-02-02T17:58:21.131+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students C:\data\db\students.json --jsonArray
2016-02-02T17:58:32.650+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
</code></pre>
| <json><mongodb><mongoimport> | 2016-02-02 12:39:43 | HQ |
35,153,902 | Find the list of Google Container Registry public images | <p>Where can I find the list of GCR public images?
In case of docker images, we can list it in hub.docker.com.
But I couldn't find anything like that for GCR.</p>
| <image><list><public><google-container-registry> | 2016-02-02 12:45:14 | HQ |
35,154,441 | Docker-compose links vs external_links | <p>I believe it is simple question but I still do not get it from Docker-compose documentations. What is the difference between links and external_links?</p>
<p>I like external_links as I want to have core docker-compose and I want to extend it without overriding the core links. </p>
<p>What exactly I have, I am trying to setup logstash which depends on the elasticsearch. Elasticsearch is in the core docker-compose and the logstash is in the depending one. So I had to define the elastic search in the depended docker-compose as a reference as logstash need it as a link. BUT Elasticsearch has already its own links which I do not want to repeat them in the dependent one.</p>
<p>Can I do that with external_link instead of link?</p>
<p>I know that links will make sure that the link is up first before linking, does the external_link will do the same?</p>
<p>Any help is appreciated. Thanks.</p>
| <elasticsearch><docker><logstash><docker-compose> | 2016-02-02 13:09:32 | HQ |
35,154,603 | R Data-Frame: Get Maximum of Variable B condititional on Variable A | <p>I am searching for an efficient and fast way to do the following:
I have a data frame with, say, 2 variables, A and B, where the values for A can occur several times:</p>
<pre><code>mat<-data.frame('VarA'=rep(seq(1,10),2),'VarB'=rnorm(20))
VarA VarB
1 0.95848233
2 -0.07477916
3 2.08189370
4 0.46523827
5 0.53500190
6 0.52605101
7 -0.69587974
8 -0.21772252
9 0.29429577
10 3.30514605
1 0.84938361
2 1.13650996
3 1.25143046
</code></pre>
<p>Now I want to get a vector giving me for every unique value of VarA</p>
<pre><code>unique(mat$VarA)
</code></pre>
<p>the maximum of VarB conditional on VarA.
In the example here that would be</p>
<pre><code>1 0.95848233
2 1.13650996
3 2.08189370
etc...
</code></pre>
<p>My data-frame is very big so I want to avoid the use of loops. </p>
| <r><dataframe> | 2016-02-02 13:17:53 | LQ_CLOSE |
35,154,652 | Getting webpage source code with java | <p>I'm trying to get a webpage source code with JAVA but i fail all the time! I want to get the source code from the link below.</p>
<p><a href="http://widget.websta.me/rss/n/wikirap_official" rel="nofollow">http://widget.websta.me/rss/n/wikirap_official</a></p>
<p>I searched on the net and tried many codes but all returned nothing, this page return my INSTAGRAM user posts as feed.</p>
<p><strong>please test codes on this link and if you succeeded in get source, share the code with me.</strong></p>
| <java><android><instagram><feed> | 2016-02-02 13:19:45 | LQ_CLOSE |
35,155,824 | Can Spring Data REST's QueryDSL integration be used to perform more complex queries? | <p>I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using <a href="http://querydsl.com/" rel="noreferrer">QueryDSL</a> in combination with <a href="http://projects.spring.io/spring-data-rest/" rel="noreferrer">Spring Data REST</a> (<a href="https://gist.github.com/olivergierke/decf03d4948cd58a51bc" rel="noreferrer">an example by Oliver Gierke</a>) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. <code>/users?firstName=Dennis&lastName=Laumen</code>).</p>
<p>I can even customize the mapping between the query parameters and an entity's properties by implementing the <code>QuerydslBinderCustomizer</code> interface (e.g. for case insensitive searches or partial string matches). This is all great, however I also want the clients to be able to filter some types using ranges. For example with regards to a property like date of birth I'd like to do something like the following, <code>/users?dateOfBirthFrom=1981-1-1&dateOfBirthTo=1981-12-31</code>. The same goes for number based properties, <code>/users?idFrom=100&idTo=200</code>. I have the feeling this should be possible using the <code>QuerydslBinderCustomizer</code> interface but the integration between these two libraries isn't documented very extensively.</p>
<p><strong><em>Concluding, is this possible using Spring Data REST and QueryDSL? If so, how?</em></strong></p>
| <spring><spring-data><spring-data-jpa><spring-data-rest><querydsl> | 2016-02-02 14:15:21 | HQ |
35,156,134 | How to properly setup custom handler404 in django? | <p>According to the <a href="https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views" rel="noreferrer">documentation</a> this should be fairly simple: I just need to define <code>handler404</code>. Currently I am doing, in my top <code>urls.py</code>:</p>
<pre><code>urlpatterns = [
...
]
handler404 = 'myapp.views.handle_page_not_found'
</code></pre>
<p>The application is installed. The corresponding view is just (for the time being I just want to redirect to the homepage in case of 404):</p>
<pre><code>def handle_page_not_found(request):
return redirect('homepage')
</code></pre>
<p>But this has no effect: the standard (debug) <code>404</code> page is shown.</p>
<p>The documentation is a bit ambiguous:</p>
<ul>
<li>where should <code>handler404</code> be defined? The documentation says in the <code>URLconf</code> but, where exactly? I have several applications, each with a different <code>urls.py</code>. Can I put it in any of them? In the top <code>URLconf</code>? Why? Where is this documented?</li>
<li>what will be catched by this handler? Will it catch <code>django.http.Http404</code>, <code>django.http.HttpResponseNotFound</code>, <code>django.http.HttpResponse</code> (with <code>status=404</code>)?</li>
</ul>
| <django><http-status-code-404> | 2016-02-02 14:29:34 | HQ |
35,157,642 | NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor conflits on Elastic Search jar | <p>While creating Elasticsearch Client, I'm getting the exception java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
After some lookup, seams like the Guava-18 is being overwrite by an older version at runtime, and Guava-18 only works during compile task. </p>
<p>My Maven configuration is the follow: </p>
<pre><code> <build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</code></pre>
<p>How can i force the Guava-18 version at execution time?</p>
| <java><maven><elasticsearch><jar><guava> | 2016-02-02 15:38:10 | HQ |
35,157,742 | How to convert singleton array to a scalar value in Python? | <p>Suppose I have 1x1x1x1x... array and wish to convert it to scalar?</p>
<p>How do I do it?</p>
<p><code>squeeze</code> does not help.</p>
<pre><code>import numpy as np
matrix = np.array([[1]])
s = np.squeeze(matrix)
print type(s)
print s
matrix = [[1]]
print type(s)
print s
s = 1
print type(s)
print s
</code></pre>
| <python><numpy><multidimensional-array> | 2016-02-02 15:43:00 | HQ |
35,157,786 | VSCode: Open file from file explorer with Enter key on Mac OSX | <p>When using VSCode on Windows, I can navigate the file explorer and hit <kbd>Enter</kbd> on the focused file and the file will open in the editor. On my Mac, however, when I do this, VSCode will open the rename input as follows:</p>
<p><a href="https://i.stack.imgur.com/up03Q.jpg"><img src="https://i.stack.imgur.com/up03Q.jpg" alt="enter image description here"></a></p>
<p>I'm not sure why it does this. Even in other text editors (e.g. Atom), the default behavior is to open the file on <kbd>Enter</kbd>. Is there any way to change this behavior so that the file opens on <kbd>Enter</kbd>? The only workaround I've found so far is <kbd>CTRL</kbd>+<kbd>Enter</kbd>, which opens the file in a new pane, but with a 3 pane limit in VSCode, this is quite limiting.</p>
| <visual-studio-code> | 2016-02-02 15:44:37 | HQ |
35,158,261 | ImageView in ListView briefly shows previous image on scroll with RecycleElement enabled | <p>I have a list of the following class:</p>
<pre><code>public class Set {
public string IconUrl { get; set; }
}
</code></pre>
<p>This list is bound to a ListView:</p>
<pre><code><ListView ItemsSource="{Binding Sets}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Image Source="{Binding IconUrl}" />
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</code></pre>
<p>When the view loads and the user starts scrolling, the cells are reused and the Image briefly shows the previous image before the new image is downloaded and rendered.</p>
<p>Is there a way to prevent this kind of behavior without disabling RecycleElement?</p>
| <ios><xamarin><xamarin.forms> | 2016-02-02 16:07:21 | HQ |
35,158,573 | Java ArrayList of Strings Throwing ArrayIndexOutOfBoundException | <p>Here is my problem:</p>
<ol>
<li><p>I have a Java String returned from my Web service in the below form:</p>
<p>21,6.417,0.3055714,27,0.7778,0.04761905</p></li>
<li><p>Now I have splitted this string into separate Strings by using split function by comma delimiter.</p>
<p>dataList = Arrays.asList(data.split(","));</p></li>
<li><p>I need to loop through this list and assign these Values into separate Strings like below:</p>
<pre><code>int playsCount = Integer.parseInt(dataList.get(0));
float sumTimeViewed = Float.valueOf(dataList.get(1));
float avgTimeViewed = Float.valueOf(dataList.get(2));
int loadsCount = Integer.parseInt(dataList.get(3));
float loadPlayRatio = Float.valueOf(dataList.get(4));
float avgViewDropOff = Float.valueOf(dataList.get(5));
</code></pre></li>
<li><p>Now While getting the values and assigning to the Individual int and floats, getting ArrayIndexOutofBoundsException. This is because some times the list is returning the size as 4 than 6. Here is the code:</p>
<pre><code>reportDataList = getReportData(entry.id);
//System.out.println("reportDataList.size()"+reportDataList.size());
if(reportDataList.size() >= 1) {
for(int i=0;i<reportDataList.size();i++) {
if(!reportDataList.get(0).equals("")) {
playsCount = Integer.parseInt(reportDataList.get(0));
}
if(!reportDataList.get(1).equals("")) {
sumTimeViewed = Float.valueOf(reportDataList.get(1));
}
if(!reportDataList.get(2).equals("")) {
avgTimeViewed = Float.valueOf(reportDataList.get(2));
}
if(!reportDataList.get(3).equals("")) {
loadsCount = Integer.parseInt(reportDataList.get(3));
}
if(!reportDataList.get(4).equals("")) {
loadPlayRatio =Float.valueOf(reportDataList.get(4));
}
if(!reportDataList.get(5).equals("")) {
avgViewDropOff = Float.valueOf(reportDataList.get(5));
}
}
}
</code></pre></li>
</ol>
<p>And here is the getReportData method:</p>
<pre><code>private List<String> getReportData(String id) throws KalturaApiException {
List<String> headerList = null;
List<String> dataList = new ArrayList<String>();
ReportService reportService = client.getReportService();
ReportType reportType = ReportType.TOP_CONTENT;
ReportInputFilter reportInputFilter = new ReportInputFilter();
reportInputFilter.fromDate = 1390156200;
reportInputFilter.toDate = 1453660200;
ReportTotal reportTotal = reportService.getTotal(reportType, reportInputFilter, id);
String data = reportTotal.data;
if(data != null) {
dataList = Arrays.asList(data.split(","));
}
if(dataList.size() >= 1) {
System.out.println("dataList.size() ------->"+dataList.size());
}
return dataList;
}
</code></pre>
<p>How to resolve this problem for any List size acceptable?</p>
<p>Thanks in Advance
Raji</p>
| <java><string><arraylist> | 2016-02-02 16:21:54 | LQ_CLOSE |
35,158,956 | How to do math pow with decimals | <pre><code>double variable1= 1.125;
double variable2= 1/7;
Math.Pow(variable1,variable2);
</code></pre>
<p>the problem is when using doubles variable2 returns 0 so the Math.Pow result is not acurate, i should use decimals but it is not suported with Math.Pow , what should i do ?</p>
| <c#><math><decimal> | 2016-02-02 16:38:18 | LQ_CLOSE |
35,159,244 | Xcode - There are no dSYMs available for download | <p>I want to extract the dSYM file from but when I click on <em>"Download dSYMs..."</em> in the <em>Organizer</em> I get the follow message: "There are no dSYMs available for download.". </p>
<p>I'm using Xcode 7.2 with a workspace generated by Cocoapods 0.39. </p>
<p>How can I get them?</p>
<p><a href="https://i.stack.imgur.com/bSdOQ.png"><img src="https://i.stack.imgur.com/bSdOQ.png" alt="enter image description here"></a></p>
| <ios><xcode><xcode7><dsym> | 2016-02-02 16:51:37 | HQ |
35,159,530 | Does Rust have Collection traits? | <p>I'd like to write a library that's a thin wrapper around some of the functionality in <a href="https://doc.rust-lang.org/std/collections/btree_map/struct.BTreeMap.html">BTreeMap</a>. I'd prefer not to tightly couple it to that particular data structure though. Strictly speaking, I only need a subset of its functionality, something along the lines of the <a href="https://docs.oracle.com/javase/7/docs/api/java/util/NavigableMap.html">NavigableMap</a> interface in Java. I was hoping to find an analogous trait I could use. I seem to recall that at some point there were traits like <code>Map</code> and <code>MutableMap</code> in the standard library, but they seem to be absent now.</p>
<p>Is there a crate that defines these? Or will they eventually be re-added to std?</p>
| <collections><rust><traits><standard-library> | 2016-02-02 17:04:41 | HQ |
35,159,967 | Setting GOOGLE_APPLICATION_CREDENTIALS for BigQuery Python CLI | <p>I'm trying to connect to Google BigQuery through the BigQuery API, using Python. </p>
<p>I'm following this page here:
<a href="https://cloud.google.com/bigquery/bigquery-api-quickstart" rel="noreferrer">https://cloud.google.com/bigquery/bigquery-api-quickstart</a></p>
<p>My code is as follows:</p>
<pre><code>import os
import argparse
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.client import GoogleCredentials
GOOGLE_APPLICATION_CREDENTIALS = './Peepl-cb1dac99bdc0.json'
def main(project_id):
# Grab the application's default credentials from the environment.
credentials = GoogleCredentials.get_application_default()
print(credentials)
# Construct the service object for interacting with the BigQuery API.
bigquery_service = build('bigquery', 'v2', credentials=credentials)
try:
query_request = bigquery_service.jobs()
query_data = {
'query': (
'SELECT TOP(corpus, 10) as title, '
'COUNT(*) as unique_words '
'FROM [publicdata:samples.shakespeare];')
}
query_response = query_request.query(
projectId=project_id,
body=query_data).execute()
print('Query Results:')
for row in query_response['rows']:
print('\t'.join(field['v'] for field in row['f']))
except HttpError as err:
print('Error: {}'.format(err.content))
raise err
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('project_id', help='Your Google Cloud Project ID.')
args = parser.parse_args()
main(args.project_id)
</code></pre>
<p>However, when I run this code through the terminal, I get the following error: </p>
<pre><code>oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
</code></pre>
<p>As you can see in the code, I've tried to set the <code>GOOGLE_APPLICATION_CREDENTIALS</code> as per the link in the error. However, the error persists. Does anyone know what the issue is? </p>
<p>Thank you in advance. </p>
| <python><google-bigquery> | 2016-02-02 17:26:59 | HQ |
35,160,256 | How do I output lists as a table in Jupyter notebook? | <p>I know that I've seen some example somewhere before but for the life of me I cannot find it when googling around.</p>
<p>I have some rows of data:</p>
<pre><code>data = [[1,2,3],
[4,5,6],
[7,8,9],
]
</code></pre>
<p>And I want to output this data in a table, e.g.</p>
<pre><code>+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 7 | 8 | 9 |
+---+---+---+
</code></pre>
<p>Obviously I could use a library like prettytable or download pandas or something but I'm very disinterested in doing that.</p>
<p>I just want to output my rows as tables in my Jupyter notebook cell. How do I do this?</p>
| <python><jupyter-notebook> | 2016-02-02 17:40:45 | HQ |
35,160,329 | Custom Facebook Login button iOS | <p>I've just integrated the Facebook iOS SDK with my app, and the login works great. That said, the SDK doesnt seem to give me the option to customize my login button (it provides me with that ugly default button in the middle of the screen). I'm using Storyboards with my app - how can I go about hooking up my own button to their provided code? I've seen some older answers posted to Stack, but the FB documentation has since changed :/</p>
<p><strong>Viewcontroller.m</strong></p>
<pre><code> FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
[self.view addSubview:loginButton];
</code></pre>
| <ios><objective-c><facebook> | 2016-02-02 17:44:34 | HQ |
35,161,401 | C++ dereferencing for std::priority_queue::top | <p>Documentation states <code>std::priority_queue::top</code> returns a constant reference to the top element in the priority_queue, but when printing the top element, the unary dereference operator is not used. </p>
<pre><code>// priority_queue::top
#include <iostream> // std::cout
#include <queue> // std::priority_queue
int main ()
{
std::priority_queue<int> mypq;
mypq.push(10);
mypq.push(20);
mypq.push(15);
std::cout << "mypq.top() is now " << mypq.top() << '\n';
return 0;
}
</code></pre>
<p>Is <code>top()</code> being implicitly dereferenced or is the returned value a copy?</p>
| <c++><reference><priority-queue> | 2016-02-02 18:43:21 | LQ_CLOSE |
35,162,533 | Convert String date YYYY-MM to date in Javascript | <p>I have a date as a String like : <code>2015-12</code> for december 2015.</p>
<p>I would like to convert this date to get this date in milliseconds in javascript. (From the first day of the month)</p>
<p>How can i do it ?</p>
| <javascript><jquery><date> | 2016-02-02 19:46:55 | LQ_CLOSE |
35,162,628 | Please help me. i trying create simple game in cocos2d-x. but when i compile my project i get error like this | Please help me. i trying create simple game in cocos2d-x. but when i compile my project i get error like this
BUILD FAILED
D:\Android\sdk\tools\ant\build.xml:597: The following error occurred while executing this line:
D:\Android\sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
D:\Android\sdk\tools\ant\build.xml:730: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "D:\JAVA"
Total time: 2 seconds
Error running command, return code: 1.
D:\cocos2d-x\GAME>
i am sorry for my bad english :(
| <java><android><cocos2d-android> | 2016-02-02 19:52:28 | LQ_EDIT |
35,162,658 | Pro/contra of using "else" if the then-clause exits the method anyways | <p>Which of these two is the "better" method and why?</p>
<pre><code>if(list.isEmpty()) {
return;
} else {
[...]
}
</code></pre>
<p>vs.</p>
<pre><code>if(list.isEmpty()) {
return;
}
[...]
</code></pre>
| <java><if-statement><return> | 2016-02-02 19:54:19 | LQ_CLOSE |
35,162,886 | I am testing a site that is currently live. I am getting an error code when I test it using XAMPP. | <p>When I load my website using my localhost server in XAMPP I get this error:
Undefined index: hideHeader in /Applications/XAMPP/xamppfiles/htdocs/test_new/header.php on line 5</p>
<p>I'm trying to understand it. It works and is live right now on godaddy. I'm updating the site and want to test my changes. Here is the index.php</p>
<pre><code><?php
$title = "Welcome To Morabito Motors";
include "header.php";
?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<img src="images/pic.jpg" width="140" height="300" border="0" alt="" align="left">Great Prices! Great Vehicles! Great Service!<br><br>
<div class="fb-like-box" data-href="https://www.facebook.com/pages/Morabito-Motors/160508257302724" data-width="292" data-show-faces="false" data-stream="false" data-header="false"></div><div id="yelp-biz-badge-plain-1jNKR4Puw_qNR0XKLf8_Lg"><a href="http://yelp.com/biz/morabito-motors-lower-burrell" target="_blank">Check out Morabito Motors on Yelp</a></div><script>(function(d, t) {var g = d.createElement(t);var s = d.getElementsByTagName(t)[0];g.id = "yelp-biz-badge-script-plain-1jNKR4Puw_qNR0XKLf8_Lg";g.src = "//yelp.com/biz_badge_js/en_US/plain/1jNKR4Puw_qNR0XKLf8_Lg.js";s.parentNode.insertBefore(g, s);}(document, 'script'));</script><p />
<p>Jamie Morabito, owner of Morabito Motors in Lower Burrell has been in the Auto Industry since 1991. His hard work and dedication awarded him the honor of being chosen as Businessman of the year for 2003 and 2004 by the National Congressional business advisory council.<br><br>
Jamie is a member of the Strongland Chamber of Commerce as well as all the local and national car dealer associations, PIADA Pennsylvania Independent Auto Dealers Association, PADA Pennsylvania Auto Dealer Association, NIADA National Independent Auto Dealers Association, and is honored to have been elected to the BAA Dealer Advisory Board for the 2006 and 2007 terms.
<br><br>
Jamie has been recognized by our local communtities for his many contributions, involvement and sponsorships of local police departments, football, baseball, soccer, basketball and wrestling programs to name a few. Jamie Morabito believes in giving back to the communities that have always supported him and patronized his business.<br><br>
As an avid Trophy Hunter, Jamie has been recognized by many local publications for his success. Many of his trophies are on display in our indoor showroom.<br><br>
<b>Morabito Motors in Lower Burrell, PA specializes in great vehicles at great prices with outstanding customer service.</b></p>
<p>We offer automotive financing, automotive service, PA state inspections and emissions, warranties, auto detailing, tire sales and installation, on or off road accessories, vehicle locator services, remote starters, automotive electrical repairs, suspension and brake, air conditioning recharging, transmission repair, keyless entry, alarm systems, bedliners, exhaust systems. We are a complete auto dealer, Lower Burrell's exclusive automotive superstore!<br>
</p>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3030.027828089492!2d-79.71296848442876!3d40.58514115330337!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x8834bddbe1105c8f%3A0x3f644fad0f7ec35a!2s3170+Leechburg+Rd%2C+New+Kensington%2C+PA+15068!5e0!3m2!1sen!2sus!4v1452909498843" width="400" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>
<?php include "footer.php"; ?>
</code></pre>
<p>I am new to php and I'm sorry if this is a stupid question.</p>
<p>Here is the Header.php</p>
<pre><code><?php
include_once "sql.php";
if ($_GET['hideHeader']) {
?>
<body bgcolor=#ffffff>
<link rel="StyleSheet" type="text/css" href="/style.css">
<?php
}else {
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<Title><?=$title?> - Morabito Motors, Lower Burrell, PA - Used Car Sales, Auto Repair Shop, Car Wash</Title>
<META Name="Description" Content="Morabito Motors in Lower Burrell, PA, specializing in sport, foreign, and domestic car sales with an on-site auto repair shop, car wash, truck, jeep, and performance accessory shop." />
<META Name="Keywords" Content="used cars, auto repair, lower burrell, TRUCK CAPS, TRAILER HITCHES, OIL CHANGES, TONNEAU COVERS, BIKE RACKS, TRUCK ACCESSORIES, JEEP ACCESSORIES, CAR WASH, WHEELS, MUDFLAPS, CARMAT, TRUCK FLOOR MAT, CARGO CARRIERS, WINDOW TINT, CAR BRAKE SERVICE, BATTERY, CAR BATTERY, RADIATOR, ALTERNATOR, TUNE-UP, REMOTE START, ALARMS, BUSHWACKER, LUND, K&N, BUG SHIELD, GRILL GUARD, NERF BAR, RUNNING BOARDS, FENDER FLARE, EXTENDED AUTO WARRANTY, USED CARS, CAR ACCESSORY, NASCAR DECALS, WINDOW DECALS, HARLEY DECALS, CAR STEREO, EXHAUST, EXHAUST TIPS, STEERING WHEEL, STEERING WHEEL COVER, CAR SEAT COVER, STEP BAR, LIFT KIT, TIRE, TIRES, GROUND EFFECTS, SUSPENSION, TOOL BOX, TRUCK RACK, KEYLESS ENTRY, BED LINERS" />
<script language="javascript" src="/crossfade.js"></script>
<link rel="StyleSheet" type="text/css" href="/style.css">
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-15655212-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</head>
<body onload="runSlideShow()" bgcolor="#094863">
<!-- Begin Table -->
<table border="0" cellpadding="0" cellspacing="0" width="780" align="center">
<tr>
<td rowspan="1" colspan="6" width="378" height="82">
<img name="morabitoA3ea0" src="/images/morabitoA3ea_1x1.jpg" width="378" height="82" border="0" alt="" /></td>
<td rowspan="1" colspan="5" width="151" height="82">
<img name="morabitoA3ea1" src="/images/morabitoA3ea_1x2.jpg" width="151" height="82" border="0" alt="" /></td>
<td rowspan="1" colspan="4" width="251" height="82">
<img name="morabitoA3ea2" src="/images/morabitoA3ea_1x3.jpg" width="251" height="82" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="1" colspan="15" width="780" height="194">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="VU" height=194 width=780>
<img src="/1.jpg" name='SlideShow' style="cursor: pointer;" width=780 height=194 onClick="javascript:linkGo(this.src);"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="15">
<div class="navbar">
<a class="navlink" href="/">Home</a>
&nbsp;&nbsp;
<a class="navlink" href="/showroom.php">Showroom</a>
&nbsp;&nbsp;
<a class="navlink" href="/accessories.php">Accessories</a>
&nbsp;&nbsp;
<a class="navlink" href="/service.php">Service Center</a>
&nbsp;&nbsp;
<a class="navlink" href="/detailing.php">Detailing</a>
&nbsp;&nbsp;
<a class="navlink" href="/finance.php">Finance Department</a>
&nbsp;&nbsp;
<a class="navlink" href="/contact.php">Contact Us</a>
</div>
</td>
</tr>
<tr>
<td rowspan="1" colspan="15">
<div style="height: 54px; background-image: url(/images/graytitlebar.png); width: <?=isset($showSide) && !$showSize ? 780 : 500?>px; float: left;" class="title"><?=$title?></div>
<?php if (isset($showSide) && !$showSize) { } else { ?>
<div class="title" style="height: 54px; background-image: url(/images/graytitlebar2.png); float: left; width: 280px; color: #FF6; font-weight: bold;">SPECIALS!</div>
<?php } ?>
</td>
</tr>
<tr>
<td VALIGN="top" bgcolor="#FFFFFF" rowspan="1" colspan="15">
<table border=0 cellpadding=0 cellspacing=0><tr valign="top"><td width=480>
<DIV style="padding: 10px; padding-top: 0px; width: <?=isset($showSide) && !$showSize ? 760 : 480?>px;" class="bsmall">
<?php } ?>
</code></pre>
<p>My question is what am I missing on line 5 of the header.php?</p>
| <php><indexing><undefined> | 2016-02-02 20:09:52 | LQ_CLOSE |
35,163,198 | Associativity of fold-expressions | <p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4191.html" rel="noreferrer"><strong>N4191</strong></a> proposed fold-expressions to C++. The definition there was that</p>
<pre><code>(args + ...)
</code></pre>
<p>is a left-fold (i.e. <code>(((a0 + a1) + a2) + ...)</code>, and that </p>
<pre><code>(... + args)
</code></pre>
<p>is a right-fold (i.e. <code>(... + (a8 + (a9 + a10)))</code>. However, the revised paper <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4295.html" rel="noreferrer"><strong>N4295</strong></a> reversed the definitions of left and right unary folds.</p>
<p><strong>Question</strong>: what is the rationale? It seems more intuitive (at least when you are used to left-to-right alphabets) to evaluate <code>(args + ...)</code> from left-to-right.</p>
| <c++><language-lawyer><c++17><associativity><fold-expression> | 2016-02-02 20:28:53 | HQ |
35,164,431 | Stack Initialization | I'm still fairly new to C programming so sorry for this really basic question, but can anyone tell me what this particular code does part by part? What does "->" after the stack do?
int StackInit(struct Stack *stack) {
stack->currentItemIndex = -1;
stack->initialized = true;
return SUCCESS;
} | <c> | 2016-02-02 21:49:16 | LQ_EDIT |
35,164,560 | No resource found that matches the given name: attr 'android:windowElevation | i instal new windows and then instal eclipse but when i create a new project its get error and i dont know what is it
workspace\appcompat_v7\res\values-v21\themes_base.xml:129: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
workspace\appcompat_v7\res\values-v21\themes_base.xml:130: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
\workspace\appcompat_v7\res\values-v21\themes_base.xml:81: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
and all of theme in them_base .xml.
i several times change windows or instal eclipse into new labtop and it(eclipse) work fine. im not instal graphic driver is it important for this error? | <android><eclipse> | 2016-02-02 21:56:36 | LQ_EDIT |
35,165,688 | How to Publish Visual Studio Database Project in VS 2015 | <p>I was unable to google this.</p>
<p>We have an existing database project (sql server).</p>
<p>Some new files (scripts) were added.</p>
<p>We have an existing server / database where some new scripts need to be run into that context.</p>
<p>In Visual Studio 2015, how can I accomplish this?</p>
<p>I was told to stay inside Visual Studio 2015. Ideally, I'd like to issue one command vs one for each individual script.</p>
| <visual-studio-2015><publish><database-project> | 2016-02-02 23:18:54 | HQ |
35,165,788 | Quick keyword search | Simple code here, I'm trying to write a code that can pick up on specific keywords, but I'm not having a lot of luck. Here's the code:
#include <iostream>
int main(){
std::string input;
bool isUnique = true;
std::cout<<"Please type a word: ";
std::cin>>input;
if(input == "the" || "me" || "it"){
isUnique = false;
}
if(isUnique){
std::cout<<"UNIQUE!!"<<std::endl;
}
else
std::cout<<"COMMON"<<std::endl;
}
If you type in any of those three words (in the if statement), you'll get the proper output from the program ("COMMON"). However, if you type anything else, you'll get that same exact output. If I limit the program to only search for one word (ie: "the") and then test it, everything works as it should, but as soon as there are two or more keywords, the program just lists everything as "COMMON". I've also tried replacing the or statements with commas but that also didn't do anything. The code I'm trying to implement this into is going to have 50+ keywords so I'm trying to find the most efficient way to search for these words. | <c++><iostream> | 2016-02-02 23:26:36 | LQ_EDIT |
35,166,013 | How do you update a django template context variable after an AJAX call? | <p>I have a table Product that shows information of a group of products.</p>
<pre><code> <table id="item_table" class="table table-sm table-hover table-bordered">
<thead class="thead-inverse">
<tr>
<th colspan="2">Date</th>
<th colspan="6">Product name</th>
<th colspan="2">Category</th>
<th colspan="2">Amount</th>
</tr>
</thead>
<tbody>
{% for item in product_list %}
<tr>
<td colspan="2">{{ item.date }}</td>
<td id="item_name_format" colspan="6">{{ item.name }}</td>
{% if item.category_id %}
<td id="item_name_format" colspan="2">{{ item.category_id.level1_desc }}</td>
{% endif %}
<td id="item_amt_format" colspan="2">${{ item.amount|intcomma }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</code></pre>
<p>I am using the below Ajax call you update the table.</p>
<pre><code>$(document).ready(function(){
// Submit post on submit
$('.item_num').on('click', function(event){
event.preventDefault();
var item_num = $(this).attr('id');
update_item(item_num);
});
function update_item(item_num) {
console.log(item_num) // sanity check
$.ajax({
type: 'GET',
url:'update_items',
data: { 'item_num': item_num },
success: function(result){
console.log(result);
???$('item_table').product_list = result;???
},
... more code
</code></pre>
<p>How do I update the variable product_list with 'result' from my Ajax call?</p>
<p>This should update the table right?</p>
<p>Thanks</p>
| <jquery><ajax><django><django-templates> | 2016-02-02 23:47:52 | HQ |
35,166,596 | Will a NULL string get malloced? | I have a function that accepts a char pointer. In the function the pointer gets malloced. I sent in NULL as the argument in one instance and it didnt create any compiler warnings. I am confused as to why this is? I expected it to do so. I also did not free anything. | <c><malloc> | 2016-02-03 00:49:46 | LQ_EDIT |
35,166,685 | UNKNOWN - Segmentation Fault | I keep getting a Segmentation fault. I figured out that it happens between these two lines:
printf("%s - File exists!\n", file_name);
printf("inforloop");
But I'm unsure why the segmentation fault keeps occuring.
This is the entire code:
#include<stdio.h>
#include<unistd.h>
#include<string.h>
FILE *fp;
char err_message[128], file_name[128];
int main(int argc, char *argv[])
{
if(argc <= 2)
{
printf("ERROR : Usage %s <file name>\n", argv[0]);
return 1;
}
int i = 1;
for(i; i< argc; i++)
{
strcpy(file_name, argv[i]);
if ((access(file_name, F_OK)) != -1)
{
printf("begining of for loop\n");
printf("%s - File exists!\n", file_name);
printf("inforloop");
fclose(fp);
}
else
{
sprintf(err_message, "open %s", file_name);
perror(err_message);
}
}
return 0;
}
Outcome:
1
begining of for loop
date.txt - File exists!
Segmentation fault (core dumped) | <c> | 2016-02-03 01:00:17 | LQ_EDIT |
35,166,758 | React Javascript displaying/decoding unicode characters | <p>I have a string in unicode that i need to convert. I need to render the string with \u00f3 to Γ³. This is an example, it should happen with all other types of characters, Γ‘, Γ, ΓΊ...</p>
<p>I have the following basic code:
<a href="https://jsfiddle.net/dddf7o70/" rel="noreferrer">https://jsfiddle.net/dddf7o70/</a></p>
<p>I need to convert </p>
<pre><code><Hello name="Informaci\u00f3n" />
</code></pre>
<p>into </p>
<pre><code>InformaciΓ³n
</code></pre>
| <javascript><reactjs> | 2016-02-03 01:08:01 | HQ |
35,166,821 | ValueError: attempted relative import beyond top-level package | <p>I was playing the the Python's import system in order to understand better how it works, and I encountered another problem. I have the following structure </p>
<pre><code>pkg/
__init__.py
c.py
d.py
subpkg/
__init__.py
a.py
b.py
</code></pre>
<p>Inside <code>a.py</code> I have the following code:</p>
<pre><code>from . import b
from .. import d
</code></pre>
<p>And inside <code>c.py</code> I have the following:</p>
<pre><code>import subpkg.a
</code></pre>
<p>Now I receive the following error:</p>
<blockquote>
<p>ValueError: attempted relative import beyond top-level package</p>
</blockquote>
<p>But <strong>why</strong>? How can I solve it? I am running <code>c.py</code> from the IDLE, and <code>pkg</code> should be considered a package, since it has the <code>__init__.py</code> file.</p>
<p>The first import works fine, but it's the following that doesn't work:</p>
<pre><code>from .. import d
</code></pre>
<p>Because I am attempting to import something from a parent package, but apparently I cannot, for some weird reason.</p>
| <python-3.x><python-import> | 2016-02-03 01:16:39 | HQ |
35,167,097 | Use Perl to only print if value of column A is present for each value in Column B | So in Perl how can I go through a sample file like so:
1 D Z
1 E F
1 G L
2 D I
2 E L
3 D P
3 G L
So here I want to be able to print out only the values that have the same first value across all values in the second column. Thus output would look like this:
1 D Z
1 E F
1 G L
| <arrays><perl><hash> | 2016-02-03 01:48:23 | LQ_EDIT |
35,167,770 | Can't Draw Filled Rectangle in OpenGL | <p>I am trying to draw a simple filled rectangle in OpenGL. All Google searching tells me that glRectf() should do this, by specifying the color beforehand with glColor4f(), however the rectangle is always drawn unfilled (borders only).</p>
<p>Is there anything I am missing, or need to specify in the code beforehand? Thanks!</p>
| <opengl> | 2016-02-03 03:04:16 | LQ_CLOSE |
35,167,824 | Difference between a server with http.createServer and a server using express in node js | <p>What's the difference between creating a server using http module and creating a server using express framework in node js?
Thanks.</p>
| <node.js><express><npm><server> | 2016-02-03 03:09:47 | HQ |
35,167,861 | sort array data without duplicate | i make twitter bot using codebird
I want to sort the data status in php array without duplicates , line by line (urls media /remote file links)
this my code
require_once ('codebird.php');
`\Codebird\Codebird::setConsumerKey("pubTRI3ik5hJqxxxxxxxxxx",` `"xxxxxS6Uj1t5GJPi6AUxxxxx");`
$cb = \Codebird\Codebird::getInstance();
`$cb->setToken("xxxxxxx-aVixxxxxxxxxX5MsEHEK",` `"Dol6RMhOYgxxxxxxFnDtJ6IzXMOLyt");`
$statusimgs = array (
"/images.com/hfskehfskea33/jshdfjsh.jpeg",
"/pic.images.com/SDjhs33/sZddszf.jpeg",
"/pic.images.com/dfggfd/dgfgfgdg.jpeg",
"//pic.images.com/xgxg/xdgxg6.jpeg",
);
$params = array(
'status' => 'halo my ststus',
'media[]' => $statusimgs[array_rand($statusimgs)]
);
$reply = $cb->statuses_updateWithMedia($params);
initially i use random array , but this can make duplicate photo,,,
i want to sort link remote files from first line to last, i have 1-100 link images to upload on twitter from remote file methot , one by one when script execute manual or with cron .i want set cron every 60s , 60s 1 photo tweet.
please help
| <php><arrays><twitter> | 2016-02-03 03:13:53 | LQ_EDIT |
35,167,904 | What is the scoop of percompile variable in c++? | Is the scoop of the precompile variable the file where it defined?
for example:
three files test1.hpp/test1.cpp test2.hpp/test2.cpp test3.hpp/test3.cpp
#ifndef test1_hpp
#define test1_hpp
// dosomething
#endif
// In test2.hpp and test.hpp both #include test1.hpp. If the scoop of test1_hpp is the whole application,in my opinion, there can only one include test1.hpp success. Because once included, test1.hpp defined.
| <c++><precompile> | 2016-02-03 03:19:55 | LQ_EDIT |
35,168,226 | textbox value cannot be change using javascript | <pre><code> document.getElementById("name").value = data;
</code></pre>
<p>it shows Uncaught TypeError: Cannot set property 'value' of null. why is this happen?</p>
<p>the data have the value.</p>
| <javascript><html> | 2016-02-03 03:55:50 | LQ_CLOSE |
35,168,615 | what is the difference between --force-rm and --rm when running docker build command | <p>When we build docker images using <code>docker build</code> command we have two options <code>--force-rm=true</code> and <code>--rm=true</code> to remove intermediate containers. what is the difference between these two options and in what scenarios should each be used.</p>
| <docker> | 2016-02-03 04:37:17 | HQ |
35,169,491 | How to implement a deep bidirectional LSTM with Keras? | <p>I am trying to implement a LSTM based speech recognizer. So far I could set up bidirectional LSTM (i think it is working as a bidirectional LSTM) by following the example in Merge layer. Now I want to try it with another bidirectional LSTM layer, which make it a deep bidirectional LSTM. But I am unable to figure out how to connect the output of the previously merged two layers into a second set of LSTM layers. I don't know whether it is possible with Keras. Hope someone can help me with this.</p>
<p>Code for my single layer bidirectional LSTM is as follows</p>
<pre><code>left = Sequential()
left.add(LSTM(output_dim=hidden_units, init='uniform', inner_init='uniform',
forget_bias_init='one', return_sequences=True, activation='tanh',
inner_activation='sigmoid', input_shape=(99, 13)))
right = Sequential()
right.add(LSTM(output_dim=hidden_units, init='uniform', inner_init='uniform',
forget_bias_init='one', return_sequences=True, activation='tanh',
inner_activation='sigmoid', input_shape=(99, 13), go_backwards=True))
model = Sequential()
model.add(Merge([left, right], mode='sum'))
model.add(TimeDistributedDense(nb_classes))
model.add(Activation('softmax'))
sgd = SGD(lr=0.1, decay=1e-5, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd)
print("Train...")
model.fit([X_train, X_train], Y_train, batch_size=1, nb_epoch=nb_epoches, validation_data=([X_test, X_test], Y_test), verbose=1, show_accuracy=True)
</code></pre>
<p>Dimensions of my x and y values are as follows.</p>
<pre><code>(100, 'train sequences')
(20, 'test sequences')
('X_train shape:', (100, 99, 13))
('X_test shape:', (20, 99, 13))
('y_train shape:', (100, 99, 11))
('y_test shape:', (20, 99, 11))
</code></pre>
| <deep-learning><keras><lstm> | 2016-02-03 05:54:02 | HQ |
35,169,608 | In which case pip install building wheel? | <p>I found that in different folders, sometimes "pip install" will build wheel which take a lot of time, while sometimes it won't. I'm not sure why's that and how to control that. Anyone can help on this.</p>
<p>The command I use: "bin/python -m pip install -r ../requirements.txt" (due to shebang line length limitation, so don't use pip directly)</p>
<p>The output without building wheel (just take a few seconds)</p>
<pre><code>Collecting numpy==1.10.4 (from -r ../requirements.txt (line 1))
Installing collected packages: numpy
Successfully installed numpy-1.10.4
</code></pre>
<p>The output with building wheel (take at least 2 minutes)</p>
<pre><code>Collecting numpy==1.10.4 (from -r ../requirements.txt (line 1))
Downloading numpy-1.10.4.tar.gz (4.1MB)
100% |ββββββββββββββββββββββββββββββββ| 4.1MB 92kB/s
Building wheels for collected packages: numpy
Running setup.py bdist_wheel for numpy ... done
Stored in directory: /root/.cache/pip/wheels/66/f5/d7/f6ddd78b61037fcb51a3e32c9cd276e292343cdd62d5384efd
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-1.10.4
</code></pre>
<p>The contents of requirements.tt</p>
<pre><code>numpy==1.10.4
</code></pre>
| <python><pip> | 2016-02-03 06:03:02 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.