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 |
|---|---|---|---|---|---|
37,483,566 | Is there something like a jasmine `toNotContain` acceptance criteria for tests? | <p><em>Jasmin comes with many functions for checking the expected values for validating specifications and tests.</em></p>
<p>Is there besides </p>
<pre><code>getJasmineRequireObj().toContain = function() { ... };
</code></pre>
<p>somthing like a </p>
<pre><code>getJasmineRequireObj().toNotContain = function() { ... };
</code></pre>
<p>?</p>
<blockquote>
<p>If not, how to add an extension or plugin to deliver this feature also
to our community of developers?</p>
</blockquote>
| <javascript><unit-testing><testing><jasmine><karma-runner> | 2016-05-27 12:26:13 | HQ |
37,484,937 | angular-cli how to add global styles? | <p>I created a global style sheet using sass and put it in the <code>public/style/styles.scss</code>. I only specify a background color.</p>
<p>In the index, I added a link to it: <code><link rel="stylesheet" href="style/styles.css"></code></p>
<p>The background color does not work on the body tag. Upon inspecting the body tag I can see that the background-color was applied but overruled by <code>scaffolding.less:31</code></p>
<p>What I am doing wrong?</p>
<p>Thanks in advance </p>
| <angular-cli> | 2016-05-27 13:37:08 | HQ |
37,485,953 | Why do i get permision denied? | from ipaddress import *
from socket import *
x = str(IPv4Address('125.67.8.0'))
s = socket()
s.bind((x,456))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 99] Cannot assign requested address
even after calling the ipaddress constructor to construct a new ip address, why can't i not bind, i ran the program on superuser mode, what is wrong with my method? | <python><sockets><networking> | 2016-05-27 14:25:03 | LQ_EDIT |
37,486,143 | How to add/remove properties to object in runtime in javascript | <p>I would like to know how to add/ remove properties to object at run time in javascript? How to achieve this in javascript ?</p>
| <javascript><arrays> | 2016-05-27 14:33:31 | LQ_CLOSE |
37,486,251 | Making REST calls from a react component | <p>I am trying to make REST call from a react component and render the returned JSON data into the DOM</p>
<p>Here is my component</p>
<pre><code>import React from 'react';
export default class ItemLister extends React.Component {
constructor() {
super();
this.state = { items: [] };
}
componentDidMount() {
fetch(`http://api/call`)
.then(result=> {
this.setState({items:result.json()});
});
}
render() {
return(
WHAT SHOULD THIS RETURN?
);
}
</code></pre>
<p>In order to bind the returned json in a DOM?</p>
| <json><rest><dom><reactjs><fetch> | 2016-05-27 14:38:38 | HQ |
37,486,516 | How do I delete/remove an app from a Firebase project? | <p>Where is the delete/remove button???</p>
<p>Attached is a screenshot of what I want to do.</p>
<p><a href="https://i.stack.imgur.com/43ioI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/43ioI.png" alt="firebase app delete"></a></p>
| <firebase> | 2016-05-27 14:51:33 | HQ |
37,486,922 | Method witch iterates object's property | I have a question about method witch iterates object's property (JS).
I have two objects. First Object is main. Second Object is clone. And how can I replace value of each property of clone to main Object. There are a lot of nesting. I don't have time to write for, for in , forEach cycles, because there are a lot of nesting.
Such method exists? | <javascript> | 2016-05-27 15:12:22 | LQ_EDIT |
37,487,266 | Dynamic links in Facebook mobile app is not deep linked to app | <p><strong>Problem</strong> — when opening a Firebase Dynamic Link on Facebook Mobile, the Facebook Browser consumes the deep link and does not open the intended mobile app</p>
<p><strong>Question</strong> — is there a good work around in <strong>Firebase</strong> to help Facebook deliver on the promise of presenting my Dynamic Link as intended? </p>
<p>We are aware of <a href="http://applinks.org">http://applinks.org</a>, and that Facebook is a contributor. Does <strong>Firebase</strong> have a way to configure their server using the AppLinks spec, so that Facebook will pass through the Deep Link to our app instead of consuming it.</p>
<p><strong>Background</strong> — I have created a <a href="https://firebase.google.com/docs/dynamic-links/">Firebase Dynamic Link</a> for an iOS and Android app. </p>
<p>The Dynamic link delivers everything I expect, and is a fantastic experience.</p>
<ol>
<li>When opened on iOS, it navigates to the App. If not installed, goes
App Store </li>
<li>When opened on Android, it navigates to the App. If not installed, goes to Play Store</li>
<li>When opened on non-mobile, it navigates to our Website</li>
<li>On Facebook mobile, neither 1 nor 2 happens. Result is that it goes straight to the mobile web experience, thereby eliminating the promise of the Firebase Dynamic Link</li>
</ol>
| <firebase><firebase-dynamic-links> | 2016-05-27 15:28:24 | HQ |
37,488,090 | Create keystore file with one command | <p>I have a script which creates and signs a keystore file for an android app.</p>
<p>It is working perfectly fine but i would rather have it run without human intervention</p>
<p>what i have to create the keystore: </p>
<pre><code>keytool -genkey -v -keystore my-release-key.keystore
-alias alias_name -keyalg RSA -keysize 2048 -validity 10000
</code></pre>
<p>This then prompts me to enter the following values manually using the terminal: keystore password, full name , organisation unit, organisation name, city , state, county code, key password.</p>
<p>what i have to sign the app:</p>
<pre><code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1
-keystore my-release-key.keystore my_application.apk alias_name
</code></pre>
<p>This then prompts me to enter passphrase for keystore.</p>
<p>Is there anyway i can pass these values in as parameters so the full script runs without anyother interaction needed? </p>
<p>PS: i'm using ubuntu 14.04 LTS.</p>
<p>Thanks For your time :)</p>
| <java><android><linux><command-line-interface><keystore> | 2016-05-27 16:12:22 | HQ |
37,488,178 | Jenkinsfile get current tag | <p>Is there a way to get the current tag ( or null if there is none ) for a job in a Jenkinsfile? The background is that I only want to build some artifacts ( android APKs ) when this commit has a tag.
I tried:</p>
<pre><code>env.TAG_NAME
</code></pre>
<p>and</p>
<pre><code>binding.variables.get("TAG_NAME")
</code></pre>
<p>both are always null - even though this ( <a href="https://issues.jenkins-ci.org/browse/JENKINS-34520" rel="noreferrer">https://issues.jenkins-ci.org/browse/JENKINS-34520</a> ) indicates otherwise </p>
| <git><jenkins><jenkins-2> | 2016-05-27 16:18:10 | HQ |
37,488,412 | C++ badly initialized std::set | <p>I have a public variable inside a class, declared as</p>
<pre><code>std::set<int> test;
</code></pre>
<p>and never explicitly initialized. When I try to access it from a shared pointer <code>c</code> of an instance of the object:</p>
<pre><code>std::set<int>& myset = c->test;
</code></pre>
<p>I see in the debugger that <code>myset</code> is badly initialized: it has both fields <code>_Myhead</code> and <code>_Mysize</code> null. Could you please explain why that happens?</p>
| <c++><std> | 2016-05-27 16:33:31 | LQ_CLOSE |
37,488,660 | Android jobScheduler won't stop with jobFinished(params, false) | <p>I'm tring to create a jobService. Here is what onStartJob() looks like.</p>
<pre><code>@Override
public boolean onStartJob(JobParameters params) {
Log.d(TAG, "onStartJob");
Log.d(TAG, "Params= " + params.getJobId());
param = params;
jobFinished(params, false);
//startAsync();
return true;
}
@Override
public boolean onStopJob(JobParameters params) {
Log.d(TAG, "onStopJob");
return false;
}
</code></pre>
<p>Here is the code that is supposed to start the job.</p>
<pre><code>public void startJobScheduler(){
Log.d(TAG, "inside startJobScheduler");
Activity activity = this.cordova.getActivity();
Context context = activity.getApplicationContext();
mJobScheduler = (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE );
JobInfo.Builder job = new JobInfo.Builder(111, new ComponentName(context, JobSchedulerService.class));
job.setPeriodic(60000);
Log.d(TAG, "before mJobScheduler.schedule(job.build())");
if( mJobScheduler.schedule( job.build() ) <= 0 ) {
Log.d(TAG, "job schedule failed");
}
Log.d(TAG, "333");
}
</code></pre>
<p>I can not get it to stop. It just keeps firing every 1-5 mins. I put jobFinished(params, false) in onStartJob() and commented out the task to try to kill it off right after it starts, but it just keeps firing. It seems jobFinished() fires something, as onDestroy() is called and my service gets destroyed, but then another job comes in with the same ID and starts it all back up.</p>
<p>I have BIND_JOB_SERVICE in the manifest like every example shows. </p>
<p>Any ideas on why jobFinished(params, false) doesn't seem to kill the setPeriodic(60000)?</p>
| <java><android><service><android-jobscheduler> | 2016-05-27 16:48:01 | HQ |
37,488,776 | Virtual Memory,Page size,Maximum Virtual address | In a paging system a virtual address consists of 24 bits in which 16 bits are displacement and 8 bits for page number.
Calculate (a) Page size (b) Maximum number of pages (c) Maximum virtual address space | <operating-system> | 2016-05-27 16:56:21 | LQ_EDIT |
37,488,803 | How to Identify an annular region of a specific color in an white background image? | [What procedure should be followed to identify the **annular region**(pinkish orange color) having a white background. Also how to **amplify the intensity** values in the annular region to further work on them. ***Click on the link below***][1]
http://i.stack.imgur.com/2wJpd.jpg | <matlab><image-processing> | 2016-05-27 16:57:49 | LQ_EDIT |
37,489,270 | How to change the flex order when wrapping | <p>I would like to achieve something that renders like this depending on the screen size:</p>
<pre><code>+---------------------------+
| A | B | C |
+---------------------------+
+---------------+
| A | C |
| B |
+---------------+
</code></pre>
<p>if all size are fixed, i can manage using the flex <code>order</code> property
but the size of my C container is not fixed and so I can't use a static media query.</p>
<p>Is there a way to achieve this?</p>
<p>Edit:
I managed a good enough approximation: In a media query selecting all screens that <em>might</em> need wrapping, I change the <code>order</code> of the B container to something big, and at the same time, I set its <code>min-width</code> to 100% which forces the wrap.</p>
| <html><css><flexbox><responsive> | 2016-05-27 17:29:37 | HQ |
37,489,768 | How to tell DocumentDB SDK to use camelCase during linq query? | <p>Considering the document <code>{ "userName": "user1" }</code> stored in the User collection, and the following <code>User</code> class: </p>
<pre><code>public class User
{
public string Id { get; set; }
public string UserName { get; set; }
}
</code></pre>
<p>With the following JSON.net settings:</p>
<pre><code>JsonConvert.DefaultSettings = () =>
{
return new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
};
};
</code></pre>
<p>When I query with Linq as such:</p>
<pre><code>var t = _client.CreateDocumentQuery<User>(_collection.SelfLink)
.Where(u => u.UserName == "user1").AsDocumentQuery().ExecuteNextAsync();
t.Wait();
var users = t.Result;
var user = users.FirstOrDefault();
</code></pre>
<p><code>user</code> is null. Changing the Document to have a pascal casing or the POCO to use a camel casing solves the issue. Of course I do not want any of those as I want my JSON objects and C# objects to be "standarized". </p>
<p>How can I tell the DocumentDB SDK to map my object's property names using camel casing, similar as JSON.net?</p>
| <azure-cosmosdb> | 2016-05-27 18:02:19 | HQ |
37,490,040 | Why does my ES6 (using Babel) class say `this` is undefined in an instance method? | <p>I am building an application in Node using Hapi.JS.</p>
<p>I have a class for an authentication plugin that is giving me all sorts of problems. When I attempt to reference <code>this</code> from within a method on the class, I get an error saying that <code>this</code> is undefined. Why is this happening?</p>
<p>An excerpt:</p>
<pre><code>class OAuth {
constructor () {}
register (server, err, next) {
this.server = server;
this.registerRoutes();
}
registerRoutes () {
console.log(this.server.route);
this.server.route([
{
method: 'POST',
path: '/oauth/token',
config: {
auth: false,
handler: function(request,reply){
console.log("test");
reply("test");
}
}
},
{
method: 'GET',
path: '/test',
config: {
auth: false,
handler: function(request,reply){
console.log("test");
reply("test");
}
}
}
]);
}
}
module.exports = new OAuth();
</code></pre>
<p>Elsewhere this is being called like:</p>
<pre><code>const oauth = require('./oauth');
oauth.register(server);
</code></pre>
<p>Every time the register function is called, I receive this error:</p>
<pre><code>TypeError: Cannot set property 'server' of undefined
</code></pre>
<p>Why on earth is my instance not working?</p>
| <javascript><node.js><ecmascript-6><babeljs><hapijs> | 2016-05-27 18:21:14 | HQ |
37,490,230 | Angular2: Show activity indicator for every HTTP request and hide views until completed | <p>Im new to Angular2 and I was wondering if there is any way to show an activity indicator for every HTTP request and hide views until completed?</p>
| <http><angular> | 2016-05-27 18:34:12 | HQ |
37,491,822 | I can't Connect on my CSGO Site ;c | MySQL ERROR: Access denied for user 'www-data'@'localhost' (using password: NO)
And this is my set.php
<?php
$sitename = "http://www.URL.COM";
$link = mysql_connect("(ip site)", "root", "password");
$db_selected = mysql_select_db('database', $link);
mysql_query("SET NAMES utf8");
function fetchinfo($rowname,$tablename,$finder,$findervalue) {
if($finder == "1") $result = mysql_query("SELECT $rowname FROM $tablename");
else $result = mysql_query("SELECT $rowname FROM $tablename WHERE `$finder`='$findervalue'");
$row = mysql_fetch_assoc($result);
return $row[$rowname];
}
?>
I search All time answer but with not success ;/ (sorry for my english) | <php><mysql> | 2016-05-27 20:33:22 | LQ_EDIT |
37,492,897 | Swift dispatch to overridden methods in subclass extensions | <p>overriding method signatures in extensions seems to produce unpredictable results in certain cases. The following example demonstrates two different results with a similar pattern.</p>
<pre><code>class A: UIViewController {
func doThing() {
print("dothing super class")
}
override func viewDidLoad() {
print("viewdidload superclass")
super.viewDidLoad()
}
}
class B: A { }
extension B {
override func doThing() {
print("dothing sub class")
super.doThing()
}
override func viewDidLoad() {
print("viewdidload subclass")
super.viewDidLoad()
}
}
let a: A = B()
a.doThing()
let vc: UIViewController = B()
vc.viewDidLoad()
</code></pre>
<p>This prints :</p>
<pre><code>dothing super class
viewdidload subclass
viewdidload superclass
</code></pre>
<p>You can see this skips the <code>B</code>'s implementation of <code>doThing</code> when it is cast as <code>A</code>, however includes both implementations of <code>viewDidLoad</code> when cast as <code>UIViewController</code>. Is this the expected behavior? If so, what is the reason for this?</p>
<p>ENV: Xcode 7.3, Playground</p>
| <ios><swift> | 2016-05-27 22:03:57 | HQ |
37,493,013 | convert dict in list to one dict | <pre><code>result = [{u'timestamp': 1464246000, u'value': 36.9},
{u'timestamp': 1464246900, u'value': 34.61},
{u'timestamp': 1464247200, u'value': 34.84}]
zzz = {}
for x in result:
zzz[x['timestamp']] = x['value']
print zzz
</code></pre>
<p>{1464246000: 36.9, 1464247200: 34.84, 1464246900: 34.61}</p>
<p>But, I need some like this(dict comprehension):</p>
<pre><code>lst = [{'1': 'A'},{'2': 'B'},{'3': 'C'}]
print {k:v for x in lst for k,v in x.items()}
{'2': 'B', '3': 'C', '1': 'A'}
</code></pre>
<p>How to do this ?</p>
| <python><list><dictionary> | 2016-05-27 22:15:10 | LQ_CLOSE |
37,493,319 | Multiply all numbers in a list - Haskell | <p>I'm really new to haskell and would like to multiply all numbers in an array. For example.:</p>
<p>Array:</p>
<pre><code>[3,2,4] //3*2*4
</code></pre>
<p>Output</p>
<pre><code>24
</code></pre>
<p>Thanks, any help is greatly appreciated. </p>
| <list><haskell> | 2016-05-27 22:47:28 | LQ_CLOSE |
37,493,551 | Phonebook in C++ won't work | I need to do a phonebook, and so far I've done this:
#include<stdio.h>
#include<malloc.h>
typedef struct
{
char Name[10];
char Address[10];
long Phone_number;
}Phonebook;
void main()
{
int Counter, Number = 0;
long Number_of_residents;
Phonebook *Information = (Phonebook*)malloc(sizeof(Phonebook));
scanf("%ld", &Number_of_residents);
for (Counter = 0; Counter < Number_of_residents; Counter++)
{
Information = (Phonebook*)realloc(Information, sizeof(Phonebook)*(Counter + 1));
gets(Information[Number].Name);
Number++;
gets(Information[Number].Address);
Number++;
scanf("%ld", &Information[Number].Phone_number);
Number++;
}
}
Problem is, when I type in "Address" it stops working.
What did I do wrong here?
Thank you.
| <c> | 2016-05-27 23:14:15 | LQ_EDIT |
37,493,576 | using regex to make a number of checks | <p>I am very confused by regex expression checks. I am trying to make several checks on two different strings in php. The first string must be 3-8 characters long, begin with a lowercase letter, and consist entirely of lowercase and the second must be 6-12 characters long, begin with a number, and end with any character that is not a letter or number. So if I had $first = "ttyl45" and $second = "6ttyl56*" These would pass the checks. I just don't know how to go about doing this because regex is very confusing to me I looked all over the internet but I'm still stuck</p>
| <php><regex><string> | 2016-05-27 23:17:33 | LQ_CLOSE |
37,493,723 | How do I create a "not" filter in python for pandas | <p>I have this large dataframe I've imported into pandas and I want to chop it down via a filter. Here is my basic sample code:</p>
<pre><code>import pandas as pd
import numpy as np
from pandas import Series, DataFrame
df = DataFrame({'A':[12345,0,3005,0,0,16455,16454,10694,3005],'B':[0,0,0,1,2,4,3,5,6]})
df2= df[df["A"].map(lambda x: x > 0) & (df["B"] > 0)]
</code></pre>
<p>Basically this displays bottom 4 results which is semi-correct. But I need to display everything BUT these results. So essentially, I'm looking for a way to use this filter but in a "not" version if that's possible. So if column A is greater than 0 AND column B is greater than 0 then we want to disqualify these values from the dataframe. Thanks</p>
| <python><python-2.7><pandas> | 2016-05-27 23:37:05 | HQ |
37,493,869 | Java Spring do scheduled task at a specific time of specific timezone | <p>I'm developing a website with Spring and Hibernate (the website is about stock trading). </p>
<p>At about 12 AM everyday, I need to cancel all orders. Currently my solution is using a scheduled task that runs every hour:</p>
<pre><code> <task:scheduled ref="ordersController" method="timeoutCancelAllOrders" fixed-delay="60*60*1000" />
</code></pre>
<p>Then in the method timeoutCancelAllOrders, I get the current time and check, if it's between 11PM and 12AM then do the task</p>
<p>The way I see it, task schedule starts when I start the Server ( I'm using Tomcat in Eclipse), but when I deploy it on an online hosting ( I'm using Openshift), I have no idea when is the starting time of task schedule.</p>
<h2>My question is:</h2>
<p>1: How to do it more automatic ? Is there anything like myTask.startAt(12AM) ?</p>
<p>2: I'm living in Vietnam but the server (Openshift) is located in US, so here's how I do the check :</p>
<pre><code> Date currentTime = new Date();
DateFormat vnTime = new SimpleDateFormat("hh:mm:ss MM/dd/yyyy ");
vnTime.setTimeZone(TimeZone.getTimeZone("Asia/Ho_Chi_Minh"));
String vietnamCurrentTime = vnTime.format(currentTime);
String currentHourInVietnam = vietnamCurrentTime.substring(0, 2);
System.out.println(currentHourInVietnam);
if(currentHourInVietnam.equals("00")){
// DO MY TASK HERE
}
</code></pre>
<p>That looks stupid. How can I improve my code ?</p>
| <java><spring><task><schedule> | 2016-05-27 23:57:15 | HQ |
37,494,799 | PLEASE HELP!! Page refreshes when I click Register! (I'm new to HTML) | My friends are counting on me to make a good rpg game, I'm almost done, but this problem occurs ----> For some reason when I click 'Register' page refreshes..? I copied this register code by the way.. so that could be the problem? please help ! :(
input type='hidden' name='referer' value=''>
input type="submit" name="submit" value="Register" class="button"/>
this is the code, please..anyone
| <javascript><html><refresh> | 2016-05-28 03:09:26 | LQ_EDIT |
37,494,880 | How do I have a sprite fade in onto the scene Swift? | <p>I would like my sprite to fade onto the scene rather than just plainly appear. How can I do this?</p>
| <ios><swift> | 2016-05-28 03:25:25 | LQ_CLOSE |
37,495,039 | Difference between Spark RDD's take(1) and first() | <p>I used to think that <code>rdd.take(1)</code> and <code>rdd.first()</code> are exactly the same. However I began to wonder if this is really true after my colleague pointed me to <a href="http://spark.apache.org/docs/latest/api/python/pyspark.html#pyspark.RDD" rel="noreferrer">Spark's officiation documentation on RDD</a>:</p>
<blockquote>
<p><strong>first()</strong>: Return the first element in this RDD.</p>
<p><strong>take(num)</strong>: Take the first num elements of the RDD.
It works by first scanning one partition, and use the results from that partition to estimate the number of additional partitions needed to satisfy the limit.</p>
</blockquote>
<p>My questions are:</p>
<ol>
<li>Is the underlying implementation of <code>first()</code> the same as <code>take(1)</code>?</li>
<li>Suppose <code>rdd1</code> and <code>rdd2</code> are constructed from the same csv, can I safely assume that <code>rdd1.take(1)</code> and <code>rdd2.first()</code> will <strong>always</strong> return the same result, i.e., the first row of the csv? What if <code>rdd1</code> and <code>rdd2</code> are partitioned differently? </li>
</ol>
| <apache-spark><pyspark><rdd> | 2016-05-28 04:00:08 | HQ |
37,495,249 | React-native unable to run-android | <p>Following this: <a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noreferrer">https://facebook.github.io/react-native/docs/getting-started.html</a> ,
I've created an empty project and am trying to run it by doing:
sudo react-native run-android
This is what is produced:</p>
<pre><code>Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
</code></pre>
<p>(I can post the rest of the error if that would be useful). Does anyone have any advice?</p>
| <android><react-native> | 2016-05-28 04:42:40 | HQ |
37,496,074 | Two way binding in RxSwift | <p>I read the two way binding operator in sample code of RxSwift.</p>
<pre><code>func <-> <T>(property: ControlProperty<T>, variable: Variable<T>) -> Disposable {
let bindToUIDisposable = variable.asObservable()
.bindTo(property)
let bindToVariable = property
.subscribe(onNext: { n in
variable.value = n
}, onCompleted: {
bindToUIDisposable.dispose()
})
return StableCompositeDisposable.create(bindToUIDisposable, bindToVariable)
}
</code></pre>
<p>When <code>property</code> changed, it will notify variable, and set the variable's value, while the variable's value is set, it will notify the property. I think it will lead to endless loop...</p>
| <ios><swift><functional-programming><reactive-cocoa><rx-swift> | 2016-05-28 06:45:38 | HQ |
37,496,299 | python - invalid value encountered in log | <p>I have the following expression:
<code>log = np.sum(np.nan_to_num(-y*np.log(a+ 1e-7)-(1-y)*np.log(1-a+ 1e-7)))</code></p>
<p>it is giving me the following warning:</p>
<pre><code>RuntimeWarning: invalid value encountered in log
log = np.sum(np.nan_to_num(-y*np.log(a+ 1e-7)-(1-y)*np.log(1-a+ 1e-7)))
</code></pre>
<p>I don't understand what might be the invalid value or why am I getting it. Any and every help is appreciated.</p>
<p><strong>NOTE</strong>: This is a cross-entropy cost function where I added <code>1e-7</code> to avoid having zeros inside log. <code>y</code> & <code>a</code> are numpy arrays and <code>numpy</code> is imported as <code>np</code>.</p>
| <python><numpy><math><cross-entropy> | 2016-05-28 07:14:59 | HQ |
37,496,659 | Multiplication and then sum in Android? (GET EDITTEXT) (JAVA) | I need to get one number from the edit text and multiplicate for a standard number and then sum with a number of another edit text this also multiplicate for a standard number. Then i have to show the value when i click a button. All in Java with android studio
the calculation is:
(editextnumber*standardnumber)+(editextnumber*standardnumber) | <java><android><android-studio> | 2016-05-28 07:57:16 | LQ_EDIT |
37,497,056 | Requests and redirections, waste of time? | <p>Let's say that I perform a GET request on a URL (this one for example: <a href="http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398" rel="nofollow">http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398</a>), and that I trace the request:</p>
<pre><code>response = requests.get(url, timeout=10)
if response.history:
print("Request was redirected")
for resp in response.history:
print("Status code, URL: {}, {}".format(resp.status_code, resp.url))
print("Final destination:")
print("Status code, URL: {}, {}".format(resp.status_code, response.url))
else:
print("Request was not redirected")
</code></pre>
<p>The output is:</p>
<pre><code>Request was redirected
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398?cookieSet=1
Final destination:
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398
</code></pre>
<p>I would like to know a few things:</p>
<ul>
<li>why does the server redirects me to the url + cookieSet=1 ? To give me a cookie ?</li>
<li>Does this redirection take time ?</li>
<li>If so, could I request the cookie page in the first place ?</li>
<li>If I have to perform several requests on the same server, should I use a session, if the server gives me a cookie ?</li>
</ul>
| <python><python-requests><url-redirection> | 2016-05-28 08:52:19 | LQ_CLOSE |
37,497,178 | C2084 error when calling function in same file in a diffrent function | <p>So, I'm trying to make a combinatorics library in a .h file. I have a function that calculates the factorial of a number n, followed by a function (in the same file) that uses the factorial function to calculate the combination of n choose k for a given n and k. But when I try to compile the code it throws this error at me: C2048 function 'long factorial(int)' already has a body. (I'm using VS 2015)</p>
<p>Here's the code:</p>
<pre><code>long int factorial(int n) // factorial of n
{
int summation = n;
for (int i = 1; i < n; i++)
{
summation *= i;
}
return summation;
}
double combination(int n, int k) // n choose k
{
return (factorial(n) / (factorial(k) * factorial(n - k)));
}
double permutation(int n, int k) // n permutation k
{
if (k != n)
return (factorial(n) / factorial(n - k));
else
return factorial(n);
}
double repetitiveCombination(int n, int k) // repetitive combination of n choose k
{
return combination(n - 1 + k, k);
}
double orderEquals(int n, int p) // order n objects of wich p are equal
{
return (factorial(n) / factorial(p));
}
</code></pre>
| <c++><combinatorics> | 2016-05-28 09:07:13 | LQ_CLOSE |
37,497,334 | SimpleDateFormat and Date object | <p>In my android app I retrieve from an api the current day as.</p>
<pre><code> long dateTime = innerJSON.getLong("dt");
Date weekDay = new Date(dateTime * 1000L);
SimpleDateFormat outFormat = new
SimpleDateFormat("EEEE");
String day = outFormat.format(weekDay);
</code></pre>
<p>And I get the current day ie Monday. </p>
<p>For the date I use the same Date object but with a different SimpleDateFormat object. </p>
<pre><code> SimpleDateFormat outFormat1 = new SimpleDateFormat("dd-M-yyyy");
String date = outFormat1.format(weekDay);
</code></pre>
<p>And that gives me,</p>
<pre><code> 28-5-2016
</code></pre>
<p>which is fine. However, I want the date to have a format of</p>
<pre><code> 28 May
</code></pre>
<p>Any ideas on that? I checked the official orarcle's <a href="https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" rel="nofollow">site</a>,but I can't find a solution.</p>
<p>Thanks,</p>
<p>Theo.</p>
| <java><android><date> | 2016-05-28 09:25:18 | LQ_CLOSE |
37,497,354 | Compile cgo lib on Cygwin64: "ld: cannot find -lmingw32" | <p>I'm trying to use a cgo library on Windows, namely <code>github.com/mattn/go-sqlite3</code></p>
<p>I use Cygwin64 and installed with all "Development" packages, so gcc is availabe.</p>
<p>But running <code>go get github.com/mattn/go-sqlite3</code> results in:</p>
<pre><code>/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32
</code></pre>
<p>If I search for "mingwex" and "mingw32" in the Cygwin installer, I get no results. Am I looking for the wrong names or are they not available on 64 bit systems?</p>
<p>Or is there a better way to use the library on Windows?</p>
<hr>
<p>Note that the README states that</p>
<blockquote>
<p>However, if you install go-sqlite3 with go install
github.com/mattn/go-sqlite3, you don't need gcc to build your app
anymore</p>
</blockquote>
<p>but I get the same error message if I use <code>go install</code>.</p>
<pre><code>$ go version
go version go1.6.2 windows/amd64
</code></pre>
| <gcc><go><sqlite><cygwin><cgo> | 2016-05-28 09:28:18 | HQ |
37,497,442 | Run a link 100 times using Perl | The problem I met is that I need to run one link (I cannot be specific that link exactly, this link is doing request and looks like http://link.com/?name=name&password=password& and etc)
And I need to run this link 100 times in a row. I can not do this manually using browser - this tooks much time.
Is there any option to run (just run, like you put link in browser and press enter) this link 100 times in a row using Perl scripting?
I have not met before with the Perl and therefore asking the help directly. As I google before some information and make a little script, but seems like I missing something in my knowledge:
#!/usr/bin/perl -w
use LWP::Simple;
my $uri = 'http://my link here';
my $content = get $uri;
Could you please advice to me how I can finish this script? | <perl><loops><lwp> | 2016-05-28 09:38:48 | LQ_EDIT |
37,497,842 | The result of php code is wrong? | When i tried to code a simple php code, i had a problem that the result had showed some things which weren't expected such as "***' . "\n"; echo'*** ". Where is my code wrong?
Here is my code:
<html>
<head>
<title>Putting Data in the DB</title>
</head>
<body>
<?php
/*insert students into DB*/
if(isset($_POST["submit"])) {
$db = mysql_connect("mysql", "martin");
mysql_select_db("martin");
$date=date("Y-m-d"); /* Get the current date in the right SQL format */
$sql="INSERT INTO students VALUES(NULL,'" . $_POST["f_name"] . "','" .
$_POST["l_name"] . "'," . $_POST["student_id"] . ",'" . $_POST["email"] .
"','" . $date . "'," . $_POST["gr"] . ")"; /* construct the query */
mysql_query($sql); /* execute the query */
mysql_close();
echo"<h3>Thank you. The data has been entered.</h3> \n";
echo'<p><a href="data_in.php">Back to registration</a></p>' . "\n";
echo'<p><a href="data_out.php">View the student lists</a></p>' ."\n";
}
<html>
<head>
<title>Putting Data in the DB</title>
</head>
<body>
<?php
/*insert students into DB*/
if(isset($_POST["submit"])) {
$db = mysql_connect("mysql", "martin");
mysql_select_db("martin");
$date=date("Y-m-d"); /* Get the current date in the right SQL format */
$sql="INSERT INTO students VALUES(NULL,'" . $_POST["f_name"] . "','" .
$_POST["l_name"] . "'," . $_POST["student_id"] . ",'" . $_POST["email"] .
"','" . $date . "'," . $_POST["gr"] . ")"; /* construct the query */
mysql_query($sql); /* execute the query */
mysql_close();
echo"<h3>Thank you. The data has been entered.</h3> \n";
echo'<p><a href="data_in.php">Back to registration</a></p>' . "\n";
echo'<p><a href="data_out.php">View the student lists</a></p>' ."\n";
}
Result is here:
> Thank you. The data has been entered. \n"; echo' Back to registration
>
> ' . "\n"; echo' View the student lists
>
> ' ."\n"; } Thank you. The data has been entered. \n"; echo' Back to
> registration
>
> ' . "\n"; echo' View the student lists
>
> ' ."\n"; } | <php> | 2016-05-28 10:23:32 | LQ_EDIT |
37,497,867 | Overloading Operator [][] c++ | <p>Let there be a class :</p>
<pre><code>template <class A_Type,int sizeA,int sizeB>
class Matrix {
A_Type myMatrix[sizeA][sizeB];
int sizeA_Val;
int sizeB_Val;
public:
Matrix();
Matrix(A_Type val);
int getSizeA()const{return sizeA_Val;} ;
int getSizeB()const{return sizeB_Val;};
A_Type mini() const;
double avg() const;
Matrix operator+(const Matrix& b)
{
Matrix<A_Type,sizeA,sizeB> tmpNew;
for (int i=0;i<sizeA;i++){
for (intj=0;j<sizeB;j++){
tmpNew[i][j]=myMatrix[i][j]+b[i][j];
}
}
return box;
}
};
</code></pre>
<p>it is working exept to the <code>Matrix operator+(const Matrix& b)</code> function</p>
<p>i want it to work co i want to create operator [][], is it possible?</p>
<p>i want for example if i see mat[i][j] it will return the value in the mat->myMatrix[i][j]</p>
<p>is it possible?</p>
| <c++><operator-overloading> | 2016-05-28 10:26:47 | LQ_CLOSE |
37,498,124 | AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction | <p>I'm trying to invoke a lambda function from node.</p>
<pre><code>var aws = require('aws-sdk');
var lambda = new aws.Lambda({
accessKeyId: 'id',
secretAccessKey: 'key',
region: 'us-west-2'
});
lambda.invoke({
FunctionName: 'test1',
Payload: JSON.stringify({
key1: 'Arjun',
key2: 'kom',
key3: 'ath'
})
}, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
</code></pre>
<p>The keys are for an IAM user. The user has <code>AWSLambdaExecute</code> and <code>AWSLambdaBasicExecutionRole</code> policies attached.</p>
<p>I get a permission error:
<code>AccessDeniedException: User: arn:aws:iam::1221321312:user/cli is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:us-west-2:1221321312:function:test1</code></p>
<p>I read the docs and several blogs, but I'm unable to authorise this user to invoke the lambda function. How do get this user to invoke lambda?</p>
<p>Thanks.</p>
| <amazon-web-services><aws-lambda><amazon-iam> | 2016-05-28 10:53:35 | HQ |
37,499,242 | Distingusih between numbers and alphabet in a string | I am trying to build a TCPIP communication between a server and a client in visual studio , the client will accept a string from the keyboard, and he will send the string to the server only if it is numbers not alphabet I tried the below code but it seems there is something wrong
while (rc == SOCKET_ERROR); //try as long till there is connection (no Socket Error)
printf("conected with %s..\n\n", address);
do
{
printf("Please insert the Blood pressure values for further Diagnostic\n ");
gets(data);
char i;
for (i = data[0]; i <= MAX; i++)
{
char n = data[i];
if ((strlen(data) > MAX) || (strlen(data) == 0))
{
printf("argument not allowed!\n\n");
memset(data, '\0', strlen(data));
continue;
}
if ((n >= 'a' && n <= 'z') ||( n >= 'A' && n <= 'Z'))
{
printf("you have to enter a number !\n\n");
memset(data, '\0', strlen(data));
continue;
//next iteration
}
} | <c> | 2016-05-28 12:53:57 | LQ_EDIT |
37,499,473 | PHP - Escaping doesn't work for me? | <p>I've been trying to do JSON in string, but I have to escape double quotes.. Here's the line <code>{\"assetid":".$assetid.", "floatvalue\":".$floatvalue.\"},</code></p>
| <php><json> | 2016-05-28 13:16:09 | LQ_CLOSE |
37,500,118 | Laravel 5.2 method to check is view exists? | <p>Is there any method to check if view exists? </p>
<p>Like PHP file_exists, but using internal laravel method for convenience</p>
<p>i want to code like this:</p>
<pre><code>if(__ifViewExist__($view)){
return view($view)->render();
}
return "Page tidak ditemukan";
</code></pre>
| <laravel><view> | 2016-05-28 14:22:15 | HQ |
37,500,511 | Inserting data in a singly link list by specifying the nth node position. | So the logic goes like this:
Suppose the link list consists of (6,7,8) as data and I pass insert(1,5),so the list will be as (5,6,7,8).
Similarly on insert(3,2) link list is (6,7,2,8).
I tried compiling the below code but it gives me an error stating-Undefined reference to main by '-start'.I tried debugging,even searching for answers but found no help.Kindly suggest a solution.Any further suggestions and bug fixes shall be welcomed.
(I have used codepad for compiling)
#include<iostream>
using namespace std;
class Link_no
{
struct node
{
int data;
node *next;
};
void insert(int n,int d,node *head)
{
node *temp=new node();
temp->data=d;
temp->next=NULL;
node *temp1;
if(n==1)
{
temp->next=head;
head=temp;
return;
}
else
temp1=head;
{
for(int i=0;i<n-1;i++)
{
temp1=temp1->next;
}
temp->next=temp1;
temp1=temp;
}
}
void print(node *start)
{
node *temp=start;
while(temp!=NULL)
{
cout<<temp->data<<endl;
temp=temp->next;
}
}
int main()
{
node *head=NULL;
Link_no o1;
o1.insert(1,5,head);
o1.insert(2,7,head);
o1.insert(1,9,head);
o1.print(head);
return 0;
}
}
| <c++><data-structures> | 2016-05-28 15:00:26 | LQ_EDIT |
37,500,825 | c++ program for address and variables | the output for this code is :
>9
and i'm not sure what does it change in the function add1
and also what does this &n mean and what it do when we assign the **i** to **&n**
#include <iostream>
using namespace std;
int add1(int &n){
n++;
return n;
}
int main(){
int m = 0;
for (int i = 0; i < 5; i++){
m += add1(i);
}
cout << m ;
cout << "\n\n";
return 0;
}
| <c++><function><pointers> | 2016-05-28 15:28:53 | LQ_EDIT |
37,501,869 | JavaScript === vs == for type checking | <p>Which of the following lines is correct?...</p>
<pre><code>if (typeof value == 'boolean') { return value; }
</code></pre>
<p>... or ...</p>
<pre><code>if (typeof value === 'boolean') { return value; }
</code></pre>
<p>I thought the double equal sign was a type of "soft compare" so the <code>value</code> variable could either be a <code>string</code> or formal type. Is this not so? I wonder because JSHint complained about the first version. I've changed it but now I'm worried that <code>typeof</code> won't return a string.</p>
| <javascript> | 2016-05-28 17:23:52 | LQ_CLOSE |
37,502,165 | Sql sever wirdest error ever | The C# code:
SqlConnection c;
string str = "Data Source =(LocalDB)\\MSSQLLocalDB;";
str += "AttachDbFilename=|DataDirectory|\\DinoData.mdf;";
str += "Integrated Security= True";
c = new SqlConnection(str);
if (Session["Conect"] != null)
{
if ((bool)Session["Conect"])
{
logdiv.Visible = false;
Usernamec.InnerHtml = (string)Session["CurentUserid"];
Connected.Visible = true;
SqlCommand exp = new SqlCommand("SELECT xp FROM[User] Where Username = @username", c);
exp.Parameters.AddWithValue("@username", (string)Session["CurentUserid"]);
c.Open();
Session["exp"] = exp.ExecuteReader();
c.Close();
int b = (int)Session["exp"] / 2;
string a = b + "px";
xp.Style.Add("width", ((string)Session["exp"])+"%");
}
else
{
Connected.Visible = false;
logdiv.Visible = true;
}
}
The Error:
> An exception of type 'System.InvalidCastException' occurred in
> App_Web_ump4h2pq.dll but was not handled in user code
>
> Additional information: Specified cast is not valid. | <c#><sql-server> | 2016-05-28 17:53:21 | LQ_EDIT |
37,502,413 | How To Separate Mysqli Query After Coma | I am bit confused at one situation. I have a table called slam-book in which I have a column named favorite games. Now User enters their data like
"cricket, foot ball, hockey, basket ball"
Now I want to separate this result and want to give link to it like,
<a href="/game.php=cricket">Cricket</a>, <a href="/game.php=foot-ball">Foot Ball</a>, <a href="/game.php=hockey">Hockey</a>, <a href="/basket-ball.php=hockey">Basket Ball</a>
So, I can list all users with specific interest, Please help me to get such result. I want that code which can give me results like #2 code. | <php> | 2016-05-28 18:20:30 | LQ_EDIT |
37,505,148 | only assignment, call, increment, decrement, await, and new object, expressions can be used as a statement | <p>Error</p>
<blockquote>
<p>only assignment, call, increment, decrement, await, and new object,
expressions can be used as a statement</p>
</blockquote>
<pre><code>**Code Line*
bool IsShiny() { get; set; }
</code></pre>
| <c#> | 2016-05-29 00:56:36 | LQ_CLOSE |
37,505,186 | Finding out who sent data to my website | <p>So, I wanted to write myself a Java program, which will send a bunch of data (probably formatted as JSON) to my website, which will then write that data to MySQL, but I also want my website to get the IP, from which this data was sent.</p>
<p>But is this even possible? I don't have too much experience with PHP :/</p>
| <java><php> | 2016-05-29 01:03:28 | LQ_CLOSE |
37,505,529 | how to get output from a loop which is inside a function in php? | guys i'm scraching my head for hours over this problem. As, i'm basically trying to fetch values from a loop inside a function to pass it to another foreach loop to get the desired results.And it is not working as i intend to. pl,point me in the right direction.
here is the code:
function ff($s) {
$project="";
foreach ($s as $i=> $r ){
$r["friend_one"] == $_SESSION['uname'] ? $friends[]= $r["friend_two"] : $friends[] = $r["friend_one"];
$friend=$friends[$i];
$totalids=$project->totalids($_SESSION['uname'],$friend);
}
return $totalids;
}
$totalid= ff($f);
print_r($totalid);
foreach ($totalid as $v){
$id=$v['user_id'];
//other logic to get desired results
} | <php><function> | 2016-05-29 02:14:17 | LQ_EDIT |
37,505,961 | Coded UI Test cases code Generation | <p>I Have a desktop Application in which I have 200 Test cases with different input parameters</p>
<p>Now the issue is Every time I am recording the Each and every test case with different input parameters</p>
<p>Is there is any way so that I can copy the code and change the parameters so that my code remains same for all the test cases only input parameters change </p>
| <c#><wpf><coded-ui-tests><mahapps.metro> | 2016-05-29 03:47:23 | LQ_CLOSE |
37,507,576 | I am trying to extract data from mongodb using bottle in python and use d3.js to visualize it!Mongodb-->Python-->d3.js | import bottle, pymongo
from pymongo import MongoClient
client = pymongo.MongoClient(some URI)
db = client['database']
dbcoll = db['collection']
@bottle.route('/hello')
def grab_record(name):
bottle.response.headers['Access-Control-Allow-Origin'] = '*'
return dbcoll.find_one({'_id':False})
bottle.run(host='localhost', port=8080, debug=True)
On opening http://localhost:8080/hello, this is the error I get
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/QbyC0.png
Both bottle.py and this file are on my Desktop! What should I do? This is urgent! | <javascript><python><mongodb><d3.js><bottle> | 2016-05-29 08:02:43 | LQ_EDIT |
37,507,852 | Changing span text of a class | <p>I am having troubles changing text of a span class on a website.
I've tried many things but nothing is happening.
What i want to do is to change from value 0 to 245.</p>
<pre><code><td>Coins: <span class="myCoins">0</span></td>
</code></pre>
<p>This is link to the compiler <a href="http://jsfiddle.net/dVBRm/6/" rel="nofollow">Fiddle</a></p>
| <javascript> | 2016-05-29 08:37:30 | LQ_CLOSE |
37,508,382 | Regex - how to match this pattern? (With emojis) | I have a text file of a few thousand entries built like that:
"11111111111: text text text text text :: word11111111: text text text text :: word111111111:"
Where "11111111" is a big number, and "text text text text" can be anything including emojis, and "word" is one of 8 words, and the second 111111111 is another number, but different.
I tried, but just couldn't match it.
I don't know how to treat the emojis, and another problem is the spaces are not consistent, sometimes is a white space, somtime tab, and so on.
Thanks! | <regex><text><emoji> | 2016-05-29 09:41:54 | LQ_EDIT |
37,508,885 | How can I locate people with a gyroscope and accelerometer? | <p>I want to build an app that locate and track people by iPhone using Gyro+Accelerometer. No need for GPS here.</p>
<p>How should I approach this problem?</p>
| <ios><iphone><location><tracking> | 2016-05-29 10:39:01 | LQ_CLOSE |
37,509,310 | Add a Where Clause In a Complex SQL Query | I want to pass a ShowRoomId Value in The Query Below.
The Employees Table Contain ShowRoomId Field
How I can Do It.
My SQL Query
SELECT * FROM Employees A
OUTER APPLY (SELECT TOP 1 *
FROM EmployeeBasics B
WHERE (A.EmployeeID = B.EmployeeID)
ORDER BY B.BasicUpdateDate DESC) AS B
OUTER APPLY (
SELECT C.EmployeeId , count(*) AS TotalAbsent
FROM EmployeeAbsents C
WHERE C.AbsentDate BETWEEN '2016-05-01' AND '2016-05-30' AND A.EmployeeID = C.EmployeeID
GROUP BY C.EmployeeId
) AS C
OUTER APPLY (
SELECT EmployeeId,
SUM(CASE WHEN TransctionTypeId = 1 THEN Amount ELSE 0 END) AS Payment,
SUM(CASE WHEN TransctionTypeId = 2 THEN Amount ELSE 0 END) AS RecoverSalary,
SUM(CASE WHEN TransctionTypeId = 3 THEN Amount ELSE 0 END) AS RecoverCash
FROM dbo.EmployeeAdvances D
WHERE A.EmployeeID = D.EmployeeID
GROUP BY EmployeeId
) AS D | <sql-server><where> | 2016-05-29 11:24:48 | LQ_EDIT |
37,509,577 | When I install twisted, it miss some mudule | I install twisted with pip, but it miss the _win32stdio.py and _pollingfile.py.
So I copy it into my dir. But I don't why? | <python><pip><twisted> | 2016-05-29 11:52:16 | LQ_EDIT |
37,509,700 | Deleting similar elements from a list in python | <p>I want to delete similar elements from a list in Python and print uniques element in that list without using set(). However my code is not doing the same . please help me out </p>
<p><strong>My code</strong> </p>
<pre><code>T = int(raw_input())
a=[]
for i in range(0,T):
a.append(raw_input())
for i in range(len(a)):
for j in range(i+1, len(a)):
if a[i]==a[j]:
del a[j]
print a
</code></pre>
| <python> | 2016-05-29 12:05:50 | LQ_CLOSE |
37,510,167 | I need to get information from json | Here is the result of: var_dump($response):
"is_claimed": false, "rating": 4.5, "mobile_url": "http://m.yelp.com/biz/filbert-steps-san-francisco?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=NUQkLT4j4VnC6ZR7LI-VWA", "rating_img_url": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png", "review_count": 208 | <php><json><yelp> | 2016-05-29 12:55:42 | LQ_EDIT |
37,510,469 | replace the value in one table conditional on the value in another table | I have the following data frames:
df_1 <- data.frame(f1= c(1,3,4,5,7,8), f2 = c(2,3,4,1,4,5))
df_2 <- data.frame(f1= c(0.1,0.3,0.04,0.015,0.7,0.8), f2 = c(0.02,0.13,0.4,1.4,0.04,0.5))
so they look like
> df_1
f1 f2
1 1 2
2 3 3
3 4 4
4 5 1
5 7 4
6 8 5
> df_2
f1 f2
1 0.100 0.02
2 0.300 0.13
3 0.040 0.40
4 0.015 1.40
5 0.700 0.04
6 0.800 0.50
The replacement I wish to perform is:
If one figure in df2 is higher than 0.05, I wish to replace the figure in df1 at the corresponding position with NA. The resulting data frame df1 should look like
f1 f2
1 NA 2
2 NA NA
3 4 NA
4 5 NA
5 NA 4
6 NA NA
I have tried to solve it using a for loop but it will take a long time when applied to my actual large table. I know there could be a quicker way using data.table but I don't actually know how. Can someone help me with this?
Many thanks!
Bill | <r> | 2016-05-29 13:29:26 | LQ_EDIT |
37,510,637 | How can I create a java program that reads from the user a number and searches for that number in an array? | <p>This is the code which I've tried so far: </p>
<pre><code>int num;
int[] a={2, 3, 4,7, 9};
System.out.println("enter a no");
for(int i=0; i<a.length; i++){
num= in.nextInt();
if(num==a[i])
</code></pre>
| <java><arrays> | 2016-05-29 13:44:51 | LQ_CLOSE |
37,510,969 | Example Bruteforce Algorithm | <p>I am currently getting into Pentesting and Ethical Hacking to test website security.
<br> I would appreciate an example Bruteforce algorithm that is stored in a string. Not a dictionary algorithm, but a bruteforce algorithm. <br> For example, it tries the letter a. Then it tries the letter b, then it tries c and so on. Thank you in advance :)</p>
| <c#> | 2016-05-29 14:18:43 | LQ_CLOSE |
37,510,973 | Python syntax error after using multiple print functions | <p>I have just begun teaching myself Python for a project I am working on.
This may be a fairly rookie question, but is there a limit to the number of times you can use the Print function? My code is using Print to request input from the user, however a syntax error (invalid syntax) appears at the 6th instance. As far as I can tell there are no mistakes in/around the line.
I am using Python 3.4.4.</p>
<p>The problem line is;</p>
<pre><code>print('What is the isentropic efficiency of the intake?')
</code></pre>
<p>The whole exert from the code is;</p>
<pre><code># Define cycle
print('What is the cruise altitude (m)?')
altitude = float(input())
print('What is the cruise Mach number?')
print('What is the mass flow?')
W = float(input())
mach0 = float(input())
print('What is the OPR?')
OPR = float(input())
print('What is the TET?')
TET = float(input())
gamma = 1.4
Cp = 1000
# Calculate the freestream properties based on ISA
if altitude < 11000:
t0 = 288.15 - (6.5*(altitude/1000))
p0 = 101325*((1-(0.0065*(altitude/288.15)))**5.2561)
else:
t0 = 288.15 - (6.5*11)
p0 = (101325*((1-(0.0065*(11000/288.15)))**5.2561))*math.exp((-9.80665*(altitude-11000))/(287.04*t0))
# Calculate Intake Performance
T0 = t0*(1+(((gamma-1)/2)*(mach0**2)))
P0 = p0*((T0/t0)**(gamma/(gamma-1))
print('What is the isentropic efficiency of the intake?')
eta_intake = float(input())
T2 = T0*(1+(((gamma-1)/2)*eta_intake*(mach0**2)))
P2 = P0*((T2/T0)**(gamma/(gamma-1))
</code></pre>
| <python><printing><syntax-error> | 2016-05-29 14:18:57 | LQ_CLOSE |
37,511,233 | push item to div from list of item div | <p>I have a question. I have for example list of div, i just want all these dives should be clickable. And after click on div, value from div should be pushed to on an other div. How I can do it in a best way?</p>
<pre><code> <?php
define('HOST','xxxx');
define('USER','xxx');
define('PASS','xxxx');
define('DB','xxxxx');
$con = mysqli_connect(HOST,USER,PASS,DB);
$sql = "select * from users";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,
array(
'email'=>$row[3],
));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>
<html>
<head>
<style>
#usersOnLine {
font-family:tahoma;
font-size:12px;
color:black;
border: 3px teal solid;
height: 525px;
width: 250px;
float: right;
overflow-y:scroll;
}
.container{
width:970px;
height:auto;
margin:0 auto;
}
</style>
</head>
<body>
<div class="container">
<div id="reciver"><h3>reciver</h3></div>
<div id="sender"><h3>sender</h3></div>
<h2 align="right"> all contacts </h2>
<div id="usersOnLine">
<?php
foreach($result as $key => $val)
{
echo $val['email'];
echo "<br>";
}
?>
</div>
</div>
</body>
</html>
</code></pre>
<p>here is useronline div in which many name are i want when i click on any name name push to reciver div how to made it i am new in php</p>
| <php> | 2016-05-29 14:43:38 | LQ_CLOSE |
37,512,340 | Javascript/java is changing my leading spaces to questiom marks | I am using this inside of a minecraft mod to read and write file and all the leading space are being converted to ? in the file.
**file input sample:**
{
"ReturnToStart": "1b",
**file out put sample:**
{
???"ReturnToStart": "1b",
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-js -->
//xxxxxxxxxxxxxxxxxxxxxxx
var ips = new java.io.FileInputStream("ABC.json");
var fileReader = new java.io.InputStreamReader(ips,"UTF-8");
var data1 = fileReader.read();
var data;
var start1 = "";
while(data1 != -1) {
data = String.fromCharCode(data1);
start1 = start1+data;
data1 = fileReader.read();
}
fileReader.close();
var fileWriter = new java.io.FileWriter("J_out2.txt");
fileWriter.write(start1);
fileWriter.close();
<!-- end snippet -->
| <java><minecraft> | 2016-05-29 16:34:58 | LQ_EDIT |
37,514,273 | What do those statements mean to do? | <p>I was going through a Python script, and I couldn't understand very well this portion of the code. The first part of the code portion are the following declarations:</p>
<pre><code>image_paths = []
image_classes = []
class_id = 0
</code></pre>
<p>Those declarations are clear so far.</p>
<p>Then it enters a for-loop, in which I couldn't understand this part:</p>
<pre><code>image_classes+=[class_id]*len(class_path)
class_id+=1
</code></pre>
<p>What could be the meaning of this code portion?</p>
<p>Thanks.</p>
| <python> | 2016-05-29 19:52:04 | LQ_CLOSE |
37,514,621 | Printing part of a .txt file | <p>Hello again and sorry in advance if this a duplicate but I'm a desperate point and I just have to ask!</p>
<p>I'm writing a program in c for a school project, I'm almost done but I got stuck.
I have a txt file shown in this image:
<a href="http://i.stack.imgur.com/RDafL.jpg" rel="nofollow">cars.txt</a></p>
<p>What I need to do with it at this point is print the listed colors but every different color must be printed only once.
Same with the car manufacturers but that's for later.</p>
<p>I'm completely out of ideas... Any help will be greatly appreciated...</p>
| <c><string><file> | 2016-05-29 20:26:04 | LQ_CLOSE |
37,514,931 | css how to place an image specifically | I'm having trouble with placing an image in the correct spot in my css.
I have links in the left side of the page and would like an image to the top right of the nav bar.
Unsure on how that's done. | <css><image> | 2016-05-29 20:58:54 | LQ_EDIT |
37,516,033 | I want to draw a flow chart using HTML, what are the best packages out there | <p>I want to draw a flow chart in my app using HTML. I was wondering if there are libraries or examples out there.</p>
| <javascript><java><html><css> | 2016-05-29 23:52:58 | LQ_CLOSE |
37,517,356 | what do && and || mean in the following code | <p>Reading highstock source codes, but confused the following codes:</p>
<pre><code>textLineHeight = textStyles && textStyles.lineHeight,
wrapper.height = (height || bBox.height || 0) + 2 * padding;
cHeight = (old && chart.oldChartHeight) || chart.chartHeight;
</code></pre>
<p>Thanks</p>
| <javascript><highcharts><highstock> | 2016-05-30 03:51:44 | LQ_CLOSE |
37,517,614 | Functions return NaN in JavaScript | <p>I'm trying to write a game in JavaScript, and it has some simple car physics that determines that RPM, torque, speed of the car, etc. I have some functions that convert RPM/hp values into different units, and when the RPM gets past a certain point the gear is incremented. However, for some reason, when the car passes the RPM at which it's supposed to shift up on the final gear, the functions start returning NaN and the object disappears from the canvas. What could be the problem? Here is the code: </p>
<pre><code>function gameObject(width, height, color, x, y) {
this.width = width;
this.height = height;
this.speedX = 0;
this.speedY = 0;
this.x = x;
this.y = y;
this.weight = 2500;
this.health = 100;
this.hp = 276;
this.accelTime = 1;
this.gearRatios = [1.98, 1.64, 1.4, 1.23, 1.04];
this.gear = 1;
this.RPM = 0;
this.shiftUpRPM = 7000;
this.shiftDownRPM = 1100;
ctx = game.canvas.getContext('2d');
ctx.fillStyle = color;
ctx.fillRect(this.x, this.y, this.width, this.height);
this.update = function() {
if (this.RPM >= this.shiftUpRPM && this.gear < 5) {
this.RPM = 1400;
this.gear += 1;
} else if (this.RPM <= this.shiftDownRPM && this.gear > 1) {
this.RPM = 5200;
this.gear -= 1;
}
ctx = game.context;
ctx.fillStyle = color;
ctx.fillRect(this.x, this.y, this.width, this.height);
}
this.newPos = function() {
this.x += this.speedX;
this.y += this.speedY;
};
}
var torqueToNewton = function(torque) {
return torque * 1.36;
}
var calculateTorqueOutput = function(hp, RPM) {
console.log("cTO:" + (hp * 5252) / RPM)
return (hp * 5252) / RPM;
}
var velocity = function(kn_energy, mass) {
var v = Math.sqrt(2*kn_energy/mass);
return v;
}
var detectCollision = function(object1, object2) {
object1.left = object1.x;
object1.right = object1.x + object1.width;
object1.bottom = object1.y
object1.top = object1.y + object1.height;
object2.left = object2.x;
object2.right = object2.x + object2.width;
object2.bottom = object2.y
object2.top = object2.y + object2.height;
}
var updateGame = function() {
game.clear();
if (window.key && window.key == 83) {
yourObject.speedX = -1;
}
if (window.key && window.key == 87) {
yourObject.RPM += 1;
nm_s = torqueToNewton(calculateTorqueOutput(yourObject.hp, yourObject.RPM));
yourObject.speedX += velocity(nm_s, yourObject.weight)/10;
yourObject.RPM /= (1/yourObject.gearRatios[yourObject.gear]);
console.log(yourObject.speedX + ":" + yourObject.RPM + ":" + yourObject.gear);
}
else {
if (yourObject.RPM > 0 && yourObject.speedX > 0) {
yourObject.RPM -= yourObject.speedX * (.25 / yourObject.speedX);
yourObject.speedX -= .25;
console.log(yourObject.speedX + ":" + yourObject.RPM + ":" + yourObject.gear);
} else {
yourObject.RPM = 0;
yourObject.speedX = 0;
}
}
if (window.key && window.key == 38) {yourObject.speedY = -1; }
if (window.key && window.key == 39) {yourObject.speedY = 1; }
yourObject.newPos();
yourObject.update();
</code></pre>
| <javascript> | 2016-05-30 04:26:50 | LQ_CLOSE |
37,519,250 | How can I send a SOAP massage using PHP? | I want to send a SOAP massage using SOAP client. I have a WSDL file for an example. I can use the WSDL file using SOAP UI.
But my requirement is: whenever I am sending a SOAP massage to a particular device or somewhere else a massage ID should be generated to me for each and every massage.
How can I write that SOAP Request using PHP.
Any example/links much appreciated as I am very new to this. | <php><xml><http><soap><wsdl> | 2016-05-30 06:47:20 | LQ_EDIT |
37,519,503 | How to use cubic spline interpolation to get a curve in java? | <p>I am working in image processing to get intermediate points using cubic spline interpolation as done <a href="http://in.mathworks.com/help/matlab/ref/spline.html" rel="nofollow noreferrer">here</a>. How can I achieve this in Java-language. Such as I have some main points :</p>
<ul>
<li>x = 24, 35, 67, 78,79.</li>
<li>y = 13, 45, 8, 45, 23.
I want to get intermediate points for x=1 to 100.</li>
</ul>
<p><a href="https://i.stack.imgur.com/FSYkB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FSYkB.png" alt="enter image description here"></a></p>
<p>Is there any library or function available in java. Please tell.</p>
| <java><interpolation><curve><cubic-spline> | 2016-05-30 07:02:41 | LQ_CLOSE |
37,520,393 | How to Send Loop value to another page? | <p>I try to send loop variable to another page with url and GET. but $_GET just only print the last value.</p>
<p>This My code now</p>
<pre><code> ...
//example
$codereg[0] = 6;
$codereg[1] = 2;
$codereg[2] = 67;
if ($option =='sent')
{
foreach($codereg as $ids)
{
header("location:checkout.php?id=$userId&productIds[]=$ids");
}
}
</code></pre>
<p>and this my checkout.php</p>
<pre><code> <?php
$userId= $_GET['id'];
$code= $_GET['productIds'];
foreach($code as $test)
{
echo $test;
}
?>
</code></pre>
<p>some one help me fix my code or give better solution...</p>
| <php><foreach><get> | 2016-05-30 07:53:50 | LQ_CLOSE |
37,522,686 | How do i query mysql database using where like or like in array? | <p>How do i query mysql database using where like (array) or like (array)? </p>
| <mysql><sql><database> | 2016-05-30 09:54:24 | LQ_CLOSE |
37,523,073 | How To Extract Data Inside This Single Quoted String in C? I Need This in 2 Hours Please | Simple question and lets be straightforward.
I have this string.
('string1', 'string2', 'string3');
I want to extract data ONLY the string1, string2, string3 using C. Anyone have an idea?
Have tried something like this
`scanf("%s", &data1);
printf("%s", data1);
if(d=='`'){
scanf("%s", &sampah);
printf("%s", sampah);
if(d=='`'){
scanf("%s", &data2);
printf("%s", data2);
if(d=='`'){
scanf("%s", &sampah);
printf("%s", sampah);
if(d=='`'){
scanf("%s", &data3);
printf("%s", data3);
if(d=='`'){
scanf("%s", &sampah);
printf("%s", sampah);
if(d=='`'){
scanf("%s", &data4);
printf("%s", data4);
}
}
}
}
}
}`
yes its stupid but this is just because I don't know what to do.
Please help :( | <c><string><extract> | 2016-05-30 10:12:50 | LQ_EDIT |
37,523,750 | Is it possible to use AWS SES with HEROKU? | If yes, then how?
It is urgent.
Although I am able to send mail from localhost,but not able to send mails from my application deployed on HEROKU..
| <ruby><amazon-web-services> | 2016-05-30 10:45:09 | LQ_EDIT |
37,525,103 | How to sort data in between two date using Angular.js | I need one help.I need to sort table data selecting two date using Angular.js.I am explaining my code below.
<div class="col-md-3">
<div class="input-group datepicker" date-format="yyyy-MM-dd" button-prev='<i class="fa fa-arrow-circle-left"></i>' button-next='<i class="fa fa-arrow-circle-right"></i>'>
<input type="text" name="birthdate" class="form-control" id="date" ng-model="date" placeholder="From date" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-md-3">
<div class=" input-group datepicker" date-format="yyyy-MM-dd" button-prev='<i class="fa fa-arrow-circle-left"></i>' button-next='<i class="fa fa-arrow-circle-right"></i>'>
<input type="text" name="birthdate" class="form-control" id="date" ng-model="date1" placeholder="To date" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<tbody id="detailsstockid">
<tr ng-repeat="d in clickDetail">
<td>{{$index+1}}</td>
<td>{{d.rest_name}}</td>
<td>{{d.Android}}</td>
<td>{{d.IOS}}</td>
<td>{{d.resultant_counter}}</td>
<td>{{d.date}}</td>
</tr>
</tbody>
Here i have two datepicker field .When user will select `From date` and `To date` the record will fetch in between these two date including these dates also.Here i have also `d.date` which contains value like this `2016-05-21 15:15:44` from DB.as per this value i need to sort the table data.Please help me. | <javascript><angularjs><datepicker> | 2016-05-30 11:56:47 | LQ_EDIT |
37,525,107 | override ToString() behave with Binding | see below `XAML`:
<Window x:Class="TabControl.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TabControl"
Title="MainWindow" Height="300" Width="300"
xmlns:Interact="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
>
<Window.Resources>
<Style TargetType="{x:Type DataGridRow}" x:Key="myStyle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsTrend.Value}" Value="True" >
<Setter Property="Background" Value="Gold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<ScrollViewer>
<DataGrid ItemsSource="{Binding list}" x:Name="myGrid" RowStyle="{StaticResource myStyle}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name.Value,Mode=TwoWay}" />
</DataGrid.Columns>
</DataGrid>
</ScrollViewer>
</Window>
***Source of `DataGrid`***
private ObservableCollection<dynamic> GetDynamicOrders2()
{
var retVal = new ObservableCollection<dynamic>();
for (int i = 0; i < 50; i++)
{
dynamic eo = new ExpandoObject();
eo.Name = new CellContent("Order" + i);
eo.IsTrend = new CellContent(i % 2 == 0);
retVal.Add(eo);
}
return retVal;
}
***Class***
public sealed class CellContent : INotifyPropertyChanged
{
private object _value;
public object Value
{
get { return _value; }
set
{
_value = value;
OnPropertyChanged("Value");
}
}
public CellContent(object value)
{
Value = value;
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
To remove `.Value` from every binding I `override` `ToString()` method.
public override string ToString()
{
return Value.ToString();
}
and Binding is changed as:
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name,Mode=TwoWay}" />
***But It's behaving differently for `DataTrigger` and `Column` Binding. Can someone explain why and How? Why is `DataTrigger` not working after the change?*** | <c#><wpf><xaml><data-binding><datatrigger> | 2016-05-30 11:57:10 | LQ_EDIT |
37,526,280 | Connecting client-server Java | <p>How do I connect 2 java classes client-server shown in the link below:</p>
<p><a href="https://systembash.com/a-simple-java-tcp-server-and-tcp-client/" rel="nofollow">https://systembash.com/a-simple-java-tcp-server-and-tcp-client/</a></p>
<p>It says i need to compile using TCPserver, I have tried finding the compiling option in my IDE, which is Netbeans, but I cant seem to locate it anywhere. Could I ask for some tips of how to connect those 2 files so that server file responds to client app ?</p>
| <java><compilation><server> | 2016-05-30 12:57:58 | LQ_CLOSE |
37,526,358 | Firebase login failed | <p>I'm having troubles trying to migrate to new firebase console.
I'm doing exactly what is on this link: <a href="https://firebase.google.com/support/guides/firebase-web#import_your_project_to_the_firebase_console_numbered" rel="noreferrer">https://firebase.google.com/support/guides/firebase-web#import_your_project_to_the_firebase_console_numbered</a></p>
<p>And this is what happened in the step 2:
<strong><em>Firebase login failed
The Firebase CLI login request was rejected or an error occurred. Please run firebase login again or contact support if you continue to have difficulty logging in.</em></strong></p>
<p>Any ideas? Thanks since now.</p>
| <firebase><firebase-realtime-database><firebase-security> | 2016-05-30 13:01:20 | HQ |
37,526,846 | How do I correctly use libsodium so that it is compatible between versions? | <p>I'm planning on storing a bunch of records in a file, where each record is then signed with <a href="https://libsodium.org/">libsodium</a>. However, I would like future versions of my program to be able to check signatures the current version has made, and ideally vice-versa.</p>
<p>For the current version of Sodium, signatures are made using the Ed25519 algorithm. I imagine that the default primitive can change in new versions of Sodium (otherwise libsodium wouldn't expose a way to choose a particular one, I think).</p>
<p>Should I...</p>
<ol>
<li>Always use the default primitive (i.e. <code>crypto_sign</code>)</li>
<li>Use a specific primitive (i.e. <code>crypto_sign_ed25519</code>)</li>
<li>Do (1), but store the value of <code>sodium_library_version_major()</code> in the file (either in a dedicated 'sodium version' field or a general 'file format revision' field) and quit if the currently running version is lower</li>
<li>Do (3), but also store <code>crypto_sign_primitive()</code></li>
<li>Do (4), but also store <code>crypto_sign_bytes()</code> and friends</li>
</ol>
<p>...or should I do something else entirely?</p>
<p>My program will be written in C.</p>
| <c><cryptography><compatibility><libsodium> | 2016-05-30 13:24:48 | HQ |
37,527,247 | firebase.initializeApp callback/promise? | <p>This is my web page</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Calcolo Diliuzioni</title>
</head>
<body>
<h1>My app</h1>
<!-- Libreria per gestire l'autenticazione con google -->
<script src="https://apis.google.com/js/platform.js" async defer></script>
<!-- Firebae config -->
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
};
firebase.initializeApp(config);
</script>
<script type="text/javascript">
var user = firebase.auth().currentUser;
if (user) {
console.log(user);
} else {
console.log(user);
}
</script>
</body>
</html>
</code></pre>
<p>Let's assume I have an already logged user. When I load the page in the console I got <code>null</code>. While I'm expecting to have the current user's object.</p>
<p>If I run the same code in the browser console</p>
<pre><code>var user = firebase.auth().currentUser;
if (user) {
console.log(user);
} else {
console.log(user);
}
</code></pre>
<p>I'm able to get the current user's object. </p>
<p>I think that the <code>firebase.initializeApp(config);</code> has some async behavior. What's the right way to work around it? Should I use a promise or something on the <code>firebase.initializeApp(config);</code> function? A sort of callback..</p>
| <javascript><web><firebase><firebase-authentication> | 2016-05-30 13:44:01 | HQ |
37,528,011 | iOS safari input caret color | <p>I have a small CSS issue with Safari on iPhone device. My search input is blue and when user focuses on it, caret is almost invisible:</p>
<p><a href="https://i.stack.imgur.com/7cBaT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7cBaT.png" alt="Caret"></a></p>
<p>In all desktop browsers, it has right color (white), even on desktop Safari. Any idea how to fix this and change caret color on iOS device?</p>
<p>Input styles:</p>
<pre><code>input {
background-color: $stateBlue;
height: $navbarItemHeight;
padding: 0 10px;
vertical-align: bottom;
color: $white;
border-radius: $borderRadius;
font-size: 1.1666666667em; // 16px
-moz-appearance:none;
-webkit-appearance:none;
&::-webkit-input-placeholder {
text-shadow: none;
-webkit-text-fill-color: initial;
}
}
</code></pre>
| <ios><css><safari> | 2016-05-30 14:22:58 | HQ |
37,528,286 | How to make migrations for a reusable Django app? | <p>I am making a reusable Django app without a project. This is the directory structure:</p>
<pre><code>/
/myapp/
/myapp/models.py
/myapp/migrations/
/myapp/migrations/__init__.py
</code></pre>
<p>When I run <code>django-admin makemigrations</code> I get the following error:</p>
<pre><code>django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
</code></pre>
<p>Obviously, this is because I don't have a settings module configured, because this is a reusable app. However, I would still like to ship migrations with my app. How can I make them?</p>
| <python><django><migration> | 2016-05-30 14:37:48 | HQ |
37,528,405 | Entity Framework: The context is being used in Code First mode with code that was generated from an EDMX file | <p>I am developing an WPF application with EF 6 database first approach, I am have 1 project in my solutions, if i run my project this error always appear.</p>
<p><em>The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: <a href="http://go.microsoft.com/fwlink/?LinkId=394715" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=394715</a></em></p>
| <c#><.net><wpf><entity-framework><visual-studio> | 2016-05-30 14:43:22 | HQ |
37,528,677 | For Fitting in All Screen | <p>I Had Made a Website it is Complete But it does not fits all displays Like on Mobile Phones So is there any code for html or css that it should automatically fits all types of screen.</p>
| <html><css> | 2016-05-30 14:58:15 | LQ_CLOSE |
37,529,235 | Which is faster inline function or MACRO | <p>I believe that preprocessor expands the Macro as a copy text in the code before compilation wherever is it called, while the compiler writes a copy of compiled function definition in each function call. So in both cases we avoided the overhead of regular function call, but in this case which is faster and has less overhead, inline function or MACRO? </p>
| <c++><c><performance><function><macros> | 2016-05-30 15:27:51 | LQ_CLOSE |
37,529,513 | Why does webpack need an empty extension | <p>I'm trying to figure out why webpack requires this empty extension.</p>
<p>Inside <code>resolve.extensions</code> there's always this kind of configuration:</p>
<pre><code>extensions: ['', '.js', '.jsx']
</code></pre>
<p>Why can't it be just this:</p>
<pre><code>extensions: ['.js', '.jsx']
</code></pre>
| <javascript><webpack> | 2016-05-30 15:44:27 | HQ |
37,529,838 | How to disable spell checking in Sublime Text 3? | <p>I tried the following settings, but all it did was make things progressively worse.</p>
<pre><code>"spell_check": false,
"dictionary": "",
"spelling_selector": "",
</code></pre>
<p>I don't understand the default value of <code>spelling_selector</code>, but maybe that's the key?</p>
| <sublimetext3><sublimetext> | 2016-05-30 16:04:59 | HQ |
37,530,368 | Difference between OpenCV type CV_32F and CV_32FC1 | <p>I would like to know if there is any difference between OpenCV types CV_32F and CV_32FC1?
I already know that 32F stands for a "32bits floating point" and C1 for "single channel", but further explanations would be appreciated.</p>
<p>If yes, how are they different / which one should I use in which specific cases? As you might know that openCV types can get very tricky...</p>
<p>Thank you all in advance for your help!</p>
| <c++><opencv><computer-vision> | 2016-05-30 16:41:46 | HQ |
37,530,641 | pipe both, stdout and stderr in the fish shell | <p>I know this has been an issue for a while and I found a lot of discussion about it, however I didn't get which would be finally a way to get it done: pipe both, stdout and stderr. In bash, this would be simply:</p>
<pre><code>cmd 2>&1 | cmd2
</code></pre>
| <fish> | 2016-05-30 17:01:59 | HQ |
37,530,931 | Fatal error: Call to a member function execute() on boolean on line 33 | <p>I've been getting one warning and one fatal error when trying to run the execute() command. I can't seem to find the error at my stm->execute();</p>
<p>Here are my errors:</p>
<blockquote>
<p>Warning: mysqli_stmt::bind_param(): Invalid type or no types specified in C:\xampp\htdocs\library\admin-reg.php on line 20</p>
<p>Fatal error: Call to a member function execute() on boolean in
C:\xampp\htdocs\library\admin-reg.php on line 33</p>
</blockquote>
<p>Then this is a snippet of my code.</p>
<pre><code> <?php
#CONNECTION
require 'dbcon.php';
#INPUT CONTAINERS
$ACTIVATION_CODE=$USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE='';
#ERROR CONTAINERS
$USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE=$USER_TYPE='';
#CONNECTION/QUERY#
$connection = mysqli_connect('localhost','root','','library_system') or die(mysqli_error());
$stm = $mysli_link->prepare("INSERT INTO users (username,password,first_name,middle_name,last_name,address,contact_no,email,activation_code) values(?,?,?,?,?,?,?,?,?)");
$stm = $stm->bind_param($USERNAME,$PASSWORD,$FIRST_NAME,$MIDDLE_NAME,$LAST_NAME,$ADDRESS,$CONTACT_NO,$EMAIL,$ACTIVATION_CODE);
#VERIFICATION SCRIPT
IF(isset($_POST['register'])){
$USERNAME = trim(mysqli_real_escape_string($connection,$_POST['username']));
$PASSWORD = trim(mysqli_real_escape_string($connection,password_hash($_POST['password'],PASSWORD_DEFAULT)));
$EMAIL = trim(mysqli_real_escape_string($connection,$_POST['email']));
$FIRST_NAME = mysqli_real_escape_string($connection,$_POST['first_name']);
$MIDDLE_NAME = mysqli_real_escape_string($connection,$_POST['middle_name']);
$LAST_NAME = mysqli_real_escape_string($connection,$_POST['last_name']);
$CONTACT_NO = trim(mysqli_real_escape_string($connection,$_POST['contact_no']));
$ADDRESS = mysqli_real_escape_string($connection,$_POST['address']);
$ACTIVATION_CODE = md5($USERNAME.(rand(0,1000)));
$USER_TYPE = "ADMIN";
$stm->execute();
}
?>
</code></pre>
<p>Hope you can help me.</p>
| <php><mysqli> | 2016-05-30 17:23:44 | LQ_CLOSE |
37,531,450 | move an image to a top of a cell (urgent) | I put an image on a cell and all margins were separated from the image, the thing is that I united the borders again with display: block; but the top margin is , and I want to move the photo up to touch with the title and this with the top margin but as a limit and not allowed to rise me more , I need urgent help the project must be delivered in a few days in class . There is the photo [image][1]
[1]: http://i.stack.imgur.com/U3XK9.png | <html><css><web> | 2016-05-30 18:04:22 | LQ_EDIT |
37,532,114 | SQL Granting already existing rights to users / revoking them | <p>I have to answer some questions based on the statements below. Initially, user A is the owner of relation R, and no other user holds privileges on R. The following are executed:</p>
<pre><code>By A: GRANT INSERT ON R TO B WITH GRANT OPTION;
By B: GRANT INSERT ON R TO C WITH GRANT OPTION;
By C: GRANT INSERT ON R TO D WITH GRANT OPTION;
By D: GRANT INSERT ON R TO B WITH GRANT OPTION;
By B: REVOKE INSERT ON R FROM C CASCADE;
</code></pre>
<p>The questions are: What happens when D grants privileges to B, but they already exist? And what users still have the privileges after the last line is executed?</p>
| <sql><sql-server> | 2016-05-30 18:54:31 | LQ_CLOSE |
37,532,335 | What do i have to learn/use to achieve the folding animation on this site? | <p>I am currently trying to make a website for my art director father, and <a href="http://www.creaktif.com/" rel="nofollow">this</a> animation(scroll down to see) on the site is close to what i'm trying to create. I know html and css but my research led me to believe that i need to use javascript and/or animation apis. It would be amazing if someone directs me to the right direction. Thanks on advance to everyone.</p>
| <html> | 2016-05-30 19:13:34 | LQ_CLOSE |
37,532,956 | Debug assertion failed C | I'm writing a program that allows users to add a question that has 4 answers, right answer, date, author and level of complexity, also the program has functions for reading all the questions and deleting a question. When I choose the option add a question and i insert all of the characteristics the message box for the error appears it also doesn't allow me to delete or see the `.
questions. i need help
void edit()
{
char filename[2];
int y;
int q,ft,s,t, fr,d,a,l,tr,n,da;
FILE *f, *f1;
f=fopen("pff.txt","r");
if (f==NULL)
{
perror ("Error!");
}
fscanf(f,"%d",&y);
printf(" " );
gets(question.name);
n=sizeof(question.name);
printf("Name : ");
gets(question.name);
q=sizeof(question.name);
printf("Answer 1: ");
gets(question.first);
ft=sizeof(question.first);
printf("Answer 2: ");
gets(question.second);
s=sizeof(question.second);
printf("Answer 3: ");
gets(question.third);
t=sizeof(question.third);
printf("Answer 4: ");
gets(question.fourth);
fr=sizeof(question.fourth);
printf("Right answer (1-4): ");
scanf("%d",&question.tr);
printf(" ");
gets(question.date);
da=sizeof(question.date);
printf("Date: ");
gets(question.date);
d=sizeof(question.date);
printf(" Author: ");
gets(question.author);
t=sizeof(question.author);
printf("Level (0-2): ");
scanf("%d",&question.level);
fclose (f);
sprintf(filename, "%d.bin", y+1);
puts (filename); f=fopen(filename,"wb");
fwrite(&q,sizeof(int),1,f);
fwrite(question.name,sizeof(question.name),1,f);
fwrite(&ft,sizeof(int),1,f);
fwrite(question.first,sizeof(question.first),1,f);
fwrite(&s,sizeof(int),1,f);
fwrite(question.second,sizeof(question.second),1,f);
fwrite(&t,sizeof(int),1,f);
fwrite(question.third,sizeof(question.third),1,f);
fwrite(&fr,sizeof(int),1,f);
fwrite(question.fourth,sizeof(question.fourth),1,f);
fwrite (&question.tr, sizeof (int),1,f);
fwrite(&d,sizeof(int),1,f);
fwrite(question.date, sizeof(question.date),1,f);
fwrite(&a,sizeof(int),1,f);
fwrite(question.author,sizeof(question.author),1,f);
fwrite(question.level,sizeof(int),1,f);
fclose(f);
f=fopen("pff.txt","w");
fprintf(f,"%d",y+1);
fclose(f);
}
| <c> | 2016-05-30 20:03:27 | LQ_EDIT |
37,533,162 | Sanitize JSON with php | <p>I always use filter_var($var, FILTER, FLAG); when I get data from $_GET, $_POST and so on, but now this data is a JSON string but I didn't find any filter to sanitize JSON. Anyone know how to implement this filter?</p>
<p>PHP filter_var(): <a href="http://php.net/manual/en/function.filter-var.php" rel="noreferrer">http://php.net/manual/en/function.filter-var.php</a></p>
<p>PHP FILTER CONST: <a href="http://php.net/manual/en/filter.filters.sanitize.php" rel="noreferrer">http://php.net/manual/en/filter.filters.sanitize.php</a></p>
| <php><json><filter-var> | 2016-05-30 20:21:02 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.