Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
38,293,572 | Python regular expression matching liquid code | I'm building a website using Jekyll and for reasons too tedious to specify here I would like to automatically remove liquid code (and **only** liquid code) from a given .html file. I'm doing it in python using regular expressions, and so far I have this one:
\{.*?\}|\{\{.*?\}\}
As I am not too familiar with liquid (and .html), could someone confirm that this will suffice for my goal? | <python><html><regex><liquid> | 2016-07-10 15:37:54 | LQ_EDIT |
38,293,573 | tsql similar Id in same column | I have a table like that and I need result just UserId 11, because UserId 12 is no lessonId 103 but still getting result.
<code>
SELECT * from LessonList
where
(LessonId = 102 and LessonValue = 1002)
or
(LessonId = 103 and LessonValue = 1003)
or
(LessonId = 102 and LessonValue = 1008)
</code>
<code>
Id UserId LessonId LessonValue
1 11 102 1002
2 11 103 1003
3 12 102 1008
</code>
I need result like that?
<code>
Id UserId LessonId LessonValue
1 11 102 1002
2 11 103 1003
</code>
thanks
| <sql-server><tsql> | 2016-07-10 15:37:56 | LQ_EDIT |
38,294,271 | Python random matrix | How to solve the problem to create a matrix with random numbers (user input)?
I also how a problem with this: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128)
Thank you in advance!
array = list()
i = int(input("How many row: "))
j = int(input("How many column: "))
for x in range(i):
if i <= 0 or i>10:
print("Failure!")
break
elif j <= 0 or j>10:
print("Failure!")
break
else:
for y in range(j):
num = raw_input("Value: ")
array.append(int(num))
a = np.reshape((i,j))
print a
| <python><matrix><input> | 2016-07-10 16:52:42 | LQ_EDIT |
38,294,781 | How to merge duplicates in an array of objects and sum a specific property? | <p>I have this array of objects:</p>
<pre><code>var arr = [
{
name: 'John',
contributions: 2
},
{
name: 'Mary',
contributions: 4
},
{
name: 'John',
contributions: 1
},
{
name: 'Mary',
contributions: 1
}
];
</code></pre>
<p>... and I want to merge duplicates but sum their contributions. The result would be like the following:</p>
<pre><code>var arr = [
{
name: 'John',
contributions: 3
},
{
name: 'Mary',
contributions: 5
}
];
</code></pre>
<p>How could I achieve that with JavaScript?</p>
| <javascript><arrays><object> | 2016-07-10 17:46:23 | HQ |
38,295,332 | Pug/ Jade - input is a self closing element: <input/> but contains nested content? | <p>I want to create the html like this:</p>
<pre><code><label class="radio-inline">
<input type="radio" name="hidden" checked="" value="Visible"> Visible
</label>
</code></pre>
<p>Pug/ Jade:</p>
<pre><code>label.radio-inline
input(type="radio", name="hidden", value="0", checked="") Visible
</code></pre>
<p>But I get an error:</p>
<blockquote>
<p>input is a self closing element: but contains nested content.</p>
</blockquote>
<p>What does it mean? How I can fix this?</p>
| <javascript><node.js><express><pug> | 2016-07-10 18:47:02 | HQ |
38,295,463 | node http-server not serving updated html files | <p>I am building out a front-end web app with angular (mostly ui-router) and doing local development by serving the html files through node <a href="https://github.com/indexzero/http-server" rel="noreferrer">http-server</a>. I have noticed that http-server isn't serving my static html files when I make updates, which is challenging to my local development.</p>
<p>I have http-server installed globally with <code>npm install http-server -g</code> and start it up by going to the root project folder and running <code>http-server</code>. It defaults to localhost:8080- the two ways that seem to work is changing the port number after each update or going through chrome incognito mode.</p>
<p>Is there a way to use http-server normally without having to change the port or using incognito mode?</p>
<p>If it is relevant, I am using MBP v. 10.11.3</p>
<p>Thank you!</p>
| <angularjs><node.js><httpserver> | 2016-07-10 18:58:25 | HQ |
38,295,517 | scope of do-catch in swift - cannot assign value to outside variable | <p>I have made some code to make POST request to my php script which is placed on my servers. I have tested and that part is working fine. I got the problem with the returning result from the server - I get it in JSON format, and print in inside do-catch statement - its OK. I assign the returning variable to variable which is declared outside of the do-catch and its not "visible". Let me show my code, it will be more simplier to explain when you see the code:</p>
<pre><code>//sending inputs to server and receiving info from server
let json:[String:AnyObject] = [ "username" : username!, "password" : password!, "iphone" : "1" ]
var link = "http://www.pnc.hr/rfid/login.php"
var novi:String = ""
do {
let jsonData = try NSJSONSerialization.dataWithJSONObject(json, options: .PrettyPrinted)
// create post request
let url = NSURL(string: link)!
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
// insert json data to the request
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.HTTPBody = jsonData
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){ data, response, error in
if error != nil{
print("Error 55 -> \(error)")
return
}
do {
let result = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? [String:AnyObject]
print("FIRST PRINT -> \(result!["password"])")
novi = String(result!["password"])
//return result
} catch {
print("Error 43-> \(error)")
}
}
task.resume()
}
catch {
//handle error. Probably return or mark function as throws
print(error)
}
print("SECOND PRINT -> \(novi)")
</code></pre>
<p>If you see <code>print("FIRST PRINT -> \(result!["password"])")</code> - it executes normally and output all the variables. Then if you see <code>print("SECOND PRINT -> \(novi)")</code> at the end of the code it outputs empty sting - like I haven't assigned variable to it. </p>
| <swift><scope><swift2><nsjsonserialization><do-catch> | 2016-07-10 19:04:42 | LQ_CLOSE |
38,295,615 | Complete tmux reset | <p>I was wondering if it is possible to completely reset tmux (the UI mainly) ?
I have tried deleting my <code>~/.tmux.conf</code> and reinstalling tmux it but I always ended up with the same status bar I had defined. </p>
| <macos><tmux> | 2016-07-10 19:15:30 | HQ |
38,296,548 | How to check if integer comes null/empty | I need to check if an input comes null/empty.
If input <= 100 And input > 0 And Not input = "" Then
subjectsInt.Add(subjects(i), input)
check = True
End If
I know in that code I am checking it as String but I already did `Not input = Nothing` and `Not input = 0` and I am getting an error:
>Run-time exception (line -1): Conversion from string "" to type 'Integer' is not valid.
>Stack Trace:
>[System.FormatException: Input string was not in a correct format.]
>[System.InvalidCastException: Conversion from string "" to type 'Integer' is not valid.]
Any suggestions? | <vb.net> | 2016-07-10 21:16:07 | LQ_EDIT |
38,296,761 | How to support ES7 in ESLint | <p>I have a project setup with WebPack to use ESLint and I'm wanting to use ES7 for the inline bind operator <code>::</code>. Currently I'm getting the parse errors shown below</p>
<pre><code>/Users/ryanvice/Documents/Code/pluralsight-redux-starter/src/components/project/ProjectsPage.js (1/0)
✖ 7:27 Parsing error: Unexpected token :
/Users/ryanvice/Documents/Code/pluralsight-redux-starter/src/routes.js (2/2)
✖ 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/namespace
✖ 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/default
! 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/no-named-as-default
! 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/no-named-as-default-member
✖ 3 errors ! 2 warnings (4:45:40 PM)
</code></pre>
<p>using the following <code>.eslintrc</code> configuration which include <code>"ecmaVersion": 7</code></p>
<pre><code>{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"jquery": true,
"mocha": true
},
"rules": {
"quotes": 0,
"no-console": 1,
"no-debugger": 1,
"no-var": 1,
"semi": [1, "always"],
"no-trailing-spaces": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-underscore-dangle": 0,
"no-alert": 0,
"no-lone-blocks": 0,
"jsx-quotes": 1,
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 0,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 0,
"react/jsx-key": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/jsx-pascal-case": 1,
"react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-extension": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/wrap-multilines": 1
}
}
</code></pre>
| <webpack><eslint><ecmascript-7> | 2016-07-10 21:51:26 | HQ |
38,296,947 | Continue the loop elsewhere in the site | <p>this code causes the images to be displayed on a rotating basis on the site.</p>
<pre><code><?php
$myImagesList = array (
'image1.png' ,
'image2.png' ,
'image3.png' ,
'image4.png' ,
'image5.png' ,
'image6.png' ,
'image7.png' ,
'image8.png' ,
'image9.png' ,
'image10.png'
);
shuffle ($myImagesList);
echo '<div style = "background: #0600ff" class = "div02">';
for ($i=0; $i<10; $i++) {
if ($i < 5) {
echo '' . $myImagesList[$i] . '';
}
if ($i == 5) {
echo '</div>';
echo '<div style = "background: #0600ff" class = "div02">';
}
if ($i > 5) {
echo '' . $myImagesList[$i] . '';
}
}
echo '</div>';
?>
</code></pre>
CONTENT
<p><strong>It is that way in html page</strong>
<a href="https://i.stack.imgur.com/3pQXf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3pQXf.png" alt="enter image description here"></a></p>
<p>But how to break this code so that the loop with rotating images continues elsewhere on the site?</p>
<p><strong>something like this</strong></p>
<pre><code><?php
RANDOM IMAGES
?>
XXX HTML CODE XXX
<?php
CONTINUOUS RANDOM IMAGE
?>
</code></pre>
<p><strong>imagem:</strong>
<a href="https://i.stack.imgur.com/Ix31A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ix31A.png" alt="enter image description here"></a></p>
| <php> | 2016-07-10 22:22:24 | LQ_CLOSE |
38,298,322 | Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_WKWebView", referenced from: | <p>Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_WKWebView", referenced from:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)</p>
<p><a href="https://i.stack.imgur.com/8zDF9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8zDF9.png" alt="enter image description here"></a></p>
<p>Any help is appreciated!</p>
| <ios><objective-c><xcode7.3> | 2016-07-11 02:27:08 | HQ |
38,298,652 | PermissionError: [Errno 13] Permission denied Flask.run() | <p>I am running MacOS X with python 3. The folder and files have 755 but I have also tested it in 777 with no luck. My question is if I have the right permissions why does it not let me run without sudo. Or are my settings incorrect?</p>
<pre><code>cris-mbp:ProjectFolder cris$ python3 zbo.py
Traceback (most recent call last):
File "zbo.py", line 9, in <module>
app.run(host="127.0.0.1",port=81,debug=True)
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 843, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python3.5/site-packages/werkzeug/serving.py", line 677, in run_simple
s.bind((hostname, port))
PermissionError: [Errno 13] Permission denied
cris-mbp:ProjectFolder cris$ sudo python3 zbo.py
* Running on http://127.0.0.1:81/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 106-133-233
</code></pre>
| <python><python-3.x><flask> | 2016-07-11 03:16:49 | HQ |
38,299,182 | What is the meaning of the mentioned query? | <p>If I had the table "CustomerDetails" than what is the below query explains??</p>
<pre><code>var details = (from data in entity.CustomerDetails where (data.CustomerId == CustId && data.CustomerProjectID == CustProjId) select data).FirstOrDefault();
</code></pre>
<p>Share the exact meaning. Thanks in advance.</p>
| <c#><sql> | 2016-07-11 04:28:53 | LQ_CLOSE |
38,299,305 | LED board in python using tkinter,matrix and pixels | As a part of a python project I am trying to make an LED board using tkinter library.This board should receive an input (a sentence) and show it on the board.I have started by making 0 and 1 (6*7) matrix es for each letter but I really don't know what to do next and how should these letters be shown on the board
For example:
A=[[0,1,1,1,0,0],[1,0,0,0,1,0],[1,0,0,0,1,0],[1,0,0,0,1,0],[1,1,1,1,1,0],[1,0,0,0,1,0],[1,0,0,0,1,0]]
Letters should be shown as below
[enter image description here][1]
[1]: http://i.stack.imgur.com/gwyHZ.png | <python><tkinter> | 2016-07-11 04:44:12 | LQ_EDIT |
38,299,558 | How can I make this code better? (C++ temperature converter) | <p>I wrote this temperature conversion program while practicing classes and functions in C++. While the code works, I am not entirely satisfied with it.
Is there any way to make this code more efficient? Are there any
persistent mistakes in my code?
I would love it if you would critique my code. Thanks.</p>
<pre><code> #include<iostream>
#include<string>
class convert{
public:
int c_con(float y){
float f;
std::cout << "Converting to Fahrenheit: ";
f=y*9/5+32;
std::cout << f << std::endl;
return 0;
}
int f_con(float x){
float c;
std::cout << "Converting to Celsius:";
c=(x-32)*5/9;
std::cout << c << std::endl;
return 0;
}
};
int main(){
char a;
int b;
convert temp;
std::cout << "__________Temp Converter-----------" << std::endl;
std::cout << "What would like to convert? (c/f): ";
std::cin >> a;
switch(a)
{
case 'c' : std::cout << "Input Celsius: ";
std::cin >> b;
temp.c_con(b);
break;
case 'f' :std::cout << "Input Fahrenheit: ";
std::cin >> b;
temp.f_con(b);
break;
default: std::cout << "Wrong input.";
}
return 0;
}
</code></pre>
| <c++> | 2016-07-11 05:14:02 | LQ_CLOSE |
38,299,744 | Why does it not make a new list each time? | <pre><code>>>> def foo(bar=[]):
... bar.append("apple")
... return bar
>>> foo()
["apple"]
>>> foo()
["apple", "apple"]
>>> foo()
["apple", "apple", "apple"]
</code></pre>
<p>Why did it add in "apple" instead of making a new list?</p>
| <python> | 2016-07-11 05:32:34 | LQ_CLOSE |
38,300,948 | Invalid CSRF token. Send the form again. Adminer | <p>I am getting this error on export of my database in adminer.
Error: <strong>Invalid CSRF token. Send the form again. If you did not send this request from Adminer then close this page.</strong> Need Help </p>
| <adminer> | 2016-07-11 07:03:42 | HQ |
38,301,261 | EXCEL MACRO VBA COPY WORDS WHICH START WITH "Acc" FROM COLUMN A TO B | [Excel sheet][1]
[1]: http://i.stack.imgur.com/xi1Ol.jpg
I would like a an automation developed.
Starting from A2 move contents of A2 into B3 and B4 then move contents A5 into B6 to B8, then A9 into B10 and so forth to the end
of the records
The logic is if cell AX has string starting with "Acc" move contents into cell BX+1 If next cell AX+2 is not starting with "Acc"
then copy cell BX above and so forth till end of the data.
Stop when cell AX is blank.
Here is my code i tried but its not working http://pastebin.com/WSp375CE
| <vba><excel> | 2016-07-11 07:21:59 | LQ_EDIT |
38,301,308 | Multiple VPC and Subnet with same CIDR blocks | <p>I realized that I can create multiple AWS VPCs and Subnets with Same CIDR blocks, I am not sure what is the philosophy behind that and how it is possible.</p>
| <amazon-web-services><amazon-ec2><amazon-vpc><vpc> | 2016-07-11 07:24:56 | HQ |
38,301,599 | aws s3 ls The read operation timed out | <p>I try to get a huge list of files from AWS S3 bucket with this command:</p>
<pre><code>aws s3 ls --human-readable --recursive my-directory
</code></pre>
<p>This directory contains tens of thousands of files, so <em>sometimes</em>, after long pause, I get this error:</p>
<pre><code>('The read operation timed out',)
</code></pre>
<p>I've tried parameter <code>--page-size</code> with different values, but it didn't help. How can I fix this error?</p>
| <amazon-s3> | 2016-07-11 07:42:58 | HQ |
38,301,838 | I want to match whole word django | Here is my code that i want to search the input that user fill in the web, I called input as aranan, but it dose not work proper. I search 'urla' but it return me 'memurlarin' . the urla is inside the word memurlarin. but I want to get me back just sentences thet urla is on it.I
please help me. thenk you
if form.is_valid():
cd = form.cleaned_data
aranan = cd['aranan']
sen1 = pd.read_csv('.../Corpus.csv',encoding="utf-8")
sen1 = sen1.sentence1_stop
sen2 = pd.read_csv(.../Corpus.csv',encoding="utf-8")
sen2 = sen2.sentence2_stop
for i in range(len(sen1)):
if (aranan in sen1[i] and aranan in sen2[i]):
... | <python><django> | 2016-07-11 07:57:07 | LQ_EDIT |
38,301,957 | Difference between as_json and to_json method in Ruby | <p>What's the difference between the two methods <code>as_json</code> and <code>to_json</code>. Are they same? If not what's the difference between them?</p>
| <ruby-on-rails><ruby> | 2016-07-11 08:05:14 | HQ |
38,302,287 | User interface design with Bootstrap | <p>I would like to make UI like in link that i have provided below. How is it possible with Bootstrap or with basic html table?</p>
<p><a href="https://imgur.com/COVjhAL" rel="nofollow">https://imgur.com/COVjhAL</a></p>
| <html><css><twitter-bootstrap><user-interface> | 2016-07-11 08:23:27 | LQ_CLOSE |
38,302,304 | how do i write login form in android studio | <p>I am trying to login with this code after
entering credentials is gives an error in MainActivity.java at<br>
"setContentView(R.layout.main_activity)"<br>
so whole application get crashed.<br>
please give me a solution to do this.</p>
<p>Login.java</p>
<pre><code>package com.example.user.mangoair11;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by User on 6/29/2016.
*/
public class Login extends Activity {
private EditText editTextEmail;
private EditText editTextPassword;
public static final String EMAIL_NAME = "EMAIL";
String email;
String password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_activity);
editTextEmail = (EditText) findViewById(R.id.editTextEmail);
editTextPassword = (EditText) findViewById(R.id.editTextPassword);
}
public void invokeLogin(View view){
email = editTextEmail.getText().toString();
password = editTextPassword.getText().toString();
login(email,password);
}
private void login(final String username, String password) {
class LoginAsync extends AsyncTask<String, Void, String> {
private Dialog loadingDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
loadingDialog = ProgressDialog.show(Login.this, "Please wait", "Loading...");
}
@Override
protected String doInBackground(String... params) {
String email = params[0];
String pass = params[1];
InputStream is = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("email", email));
nameValuePairs.add(new BasicNameValuePair("password", pass));
String result = null;
try{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://hostogen.com/mangoair10/login.php");
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
result = sb.toString();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
@Override
protected void onPostExecute(String result) {
String s = result.trim();
loadingDialog.dismiss();
if (s.equalsIgnoreCase("success")) {
Intent intent = new Intent(Login.this, UserProfile.class);
intent.putExtra(EMAIL_NAME, email);
finish();
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Invalid User Name or Password", Toast.LENGTH_LONG).show();
}
}
}
LoginAsync la = new LoginAsync();
la.execute(username, password);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
MainActivity.java
package com.example.user.mangoair11;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button register,login;
TextView privacy, contact, about;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
register=(Button)findViewById(R.id.button_register);
login=(Button)findViewById(R.id.button_login);
privacy=(TextView)findViewById(R.id.textView2_privacy);
contact=(TextView)findViewById(R.id.textView3_contact);
about=(TextView)findViewById(R.id.textView_about);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this, Register.class);
startActivity(i);
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new Intent(MainActivity.this,Login.class);
startActivity(i);
}
});
privacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Privacy.class);
startActivity(i);
}
});
contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Contact.class);
startActivity(i);
}
});
about.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,About.class);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}[it give error at page shown in image][1]
return super.onOptionsItemSelected(item);
}
}
</code></pre>
| <android> | 2016-07-11 08:24:19 | LQ_CLOSE |
38,302,492 | How to get systemd to restart Rails App with Puma | <p>I've been struggling with this a week now and really can't seem to find an answer. I've deployed my Rails App with Capistrano. I use Puma as a server.</p>
<p>When I deploy, everything works ok. The problem is to get Puma to start at reboot and/or when it crashes.</p>
<p>To get the deployment setup, I've used this <a href="https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma" rel="noreferrer">tutorial</a>. I'm also using RVM. The problem I seem to get is to get the service to start Puma. Here's what I've used (service file):</p>
<pre><code>[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=simple
#User=my-user
WorkingDirectory=/home/my-user/apps/MyApp/current
ExecStart=/home/my-user/apps/MyApp/current/sbin/puma -C /home/my-user/apps/MyApp/shared/puma.rb
Restart=always
[Install]
WantedBy=multi-user.target
</code></pre>
<p>That doesn't work. I was starting to think the problem was Ruby not being installed for all users, so I've installed RVM for all users and still get the same problem. My server has only root and my-user. </p>
<p>Looking at how Capistrano deploys, the command it runs is: <code>cd /home/my-user/apps/MyApp/current && ( RACK_ENV=production /home/my-user/.rvm/bin/rvm default do bundle exec puma -C /home/my-user/apps/MyApp/shared/puma.rb --daemon )</code>. If I use the aforementioned command, I get an error from Systmd complaining about missing parameters. So I've written a script with it and got the service file to call this script to start the app. </p>
<p>That doesn't work either. Note that if I call the script from anywhere on the server the script does start the App, so its an issue on configuring Systemd, but I can't figure out what's wrong and I'm not sure how to debug it. I've seen the debug page on System's website, but it didn't help me. If I run <code>systemctl status puma.service</code> all it tells me is that the service is in failed state, but it doesn't tell me how or why.</p>
<p>Also worth noting: If I run <code>bundle exec puma -C /home/my-user/apps/MyApp/shared/puma.rb</code> from my App folder it works ok, so how I could duplicate this command with Systemd service?</p>
| <ruby-on-rails><linux><nginx><puma><systemd> | 2016-07-11 08:36:08 | HQ |
38,302,685 | How to call a class from a winform? | <p>Sorry I use this title on purpose. I m quite new on c# and i don't manage to call my class on the usual way.</p>
<p>I have a winform and I want to insert a class (copy and paste from an API), and call it from my winform. </p>
<p>This class is a program which open the console, ask me parameters and then lunch an EMG acquisition.</p>
<p>the class is like that:</p>
<pre><code> class Program1
{
static void Main(string[] args)
{
// some code here, with a lot of "Console.Writeline"
}
}
</code></pre>
<p>It works fine.</p>
<p>I change it to:</p>
<pre><code> public class Program1
{
public void method1(string[] args)
{
//some code here, , with a lot of "Console.Writeline"
}
}
</code></pre>
<p>And i tried to call it on my form </p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
Program1 program = new Program1();
program.method1();
}
</code></pre>
<p>it says "No overload for method 'method1' takes 0 arguments" .
The thing i don"t understand is when i run the program of the API alone it doesn't ask me anything it just runs. </p>
<p>I'm pretty sure the error is from the <code>Console.WriteLine</code> and <code>Console.Readline</code> but i don't know how to resolve my problem.
I want a button on my winform which run my class, open the console and ask me on the console which paramaters i want.</p>
<p>Thank you !</p>
| <c#><winforms><console> | 2016-07-11 08:47:18 | LQ_CLOSE |
38,302,834 | how to parse below Json android | <p>i have below Json to Parse. I am doing it by means of multiple if else loop . is there is any standard way to parse such json format.?
Please provide any help..</p>
<pre><code>JSON:
{
"Info": {
"DeviceInfo": {
"Version": "NA",
"IMEI" : "NA",
"IMSI" : "NA",
"Manufacture" : "NA",
"Network" : "NA",
"Root" : "NA",
"Storage" : "NA"
},
"SettingInfo": {
"Brightness": "NA",
"FlightMode": "NA"
},
"AdvanceInfo": {
"PictureCount": "NA",
"VideoCount": "NA",
"CallIn": "NA",
"CallOut":"NA"
},
"MemoryInfo": {
"RAM": "NA",
"ReadSpeedInternal": "NA",
"WriteSpeedInternal": "NA"
}
}
}
</code></pre>
| <android><json> | 2016-07-11 08:56:12 | LQ_CLOSE |
38,302,858 | Google static maps with directions | <p>I have in my project list of generated places with mini maps. There should be 2 points on the map and colored road direction between this two points.</p>
<p>it should looks somehow like this:</p>
<p><a href="https://i.stack.imgur.com/rdi7Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rdi7Y.png" alt="expected map picture"></a></p>
<p>This should be static image, because there will be many such pictures with different directions on the page. But as I see, Google Static map didn't allow to draw such image. There can be only direct line between two points, like this:</p>
<p><a href="https://i.stack.imgur.com/Cx4EF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Cx4EF.png" alt="enter image description here"></a></p>
<p>But I need direction on it...</p>
<p>I decided to use static map, because in my web application I receive coordinates of those 2 points, and it's easy to put it as variables in my PHP template if I use static maps.
But is it possible to receive direction as static image in same way?</p>
<p>I have found few solution with JavaScript API, but didn't find how to draw static image as I need...</p>
| <google-maps><google-maps-api-3><google-static-maps> | 2016-07-11 08:57:24 | HQ |
38,303,179 | Shareable Key Value Pair in Android | <p>Good day mates! I am wondering if there are ways to create a shareable key-value pair in Android? What I meant by shareable is that a file that can be viewed in file manager. Any help will be much appreciated. Thank you very much!</p>
| <android> | 2016-07-11 09:13:06 | LQ_CLOSE |
38,303,415 | Error:Data Binding does not support Jack builds yet | <p>I am implementing <code>DataBinding</code>, it is working perfect, but it is not allowing me to use <code>jackOptions</code>. It throws error <code>Data Binding does not support Jack builds yet</code> while build.</p>
<p>Here is my <code>build.gradle</code></p>
<pre><code>android {
defaultConfig {
...
dataBinding {
enabled true
}
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
</code></pre>
| <android><data-binding><android-databinding><android-jack-and-jill> | 2016-07-11 09:25:17 | HQ |
38,305,216 | I want to build a minimap for my HTML5 game, how do I start? | <p>Assume I have a big map which uses a background image as pattern. I want to place a minimap at the corner when I am moving the player around. All I need the minimap to do is to display where my player is in the big map and where are other sprites in the map, using a very coarse representation and keeping their relative location but shows everything in a much smaller map. So I think this is a very basic and simple minimap. My player will be in the middle of the screen (I have already done that) and the minimap will stay at the corner of the screen. If I want to build such a feature for my game, how do I start?</p>
| <javascript><html> | 2016-07-11 10:58:51 | LQ_CLOSE |
38,305,264 | Is there a way to return an abstraction from a function without using new (for performance reasons) | <p>For example I have some function <code>pet_maker()</code> that creates and returns a <code>Cat</code> or a <code>Dog</code> as a base <code>Pet</code>. I want to call this function many many times, and do something with the <code>Pet</code> returned.</p>
<p>Traditionally I would <code>new</code> the <code>Cat</code> or <code>Dog</code> in <code>pet_maker()</code> and return a pointer to it, however the <code>new</code> call is much slower than doing everything on the stack.</p>
<p>Is there a neat way anyone can think of to return as an abstraction without having to do the new every time the function is called, or is there some other way that I can quickly create and return abstractions?</p>
| <c++><oop> | 2016-07-11 11:01:34 | HQ |
38,306,528 | How to call python function from java code without use of jpython | I am trying to call my python code from java code , without use of jpython, as my code contains numpy, scipy and other module which is not available on jpython, more over i want to create a api of my python code for java. | <java><python><numpy> | 2016-07-11 12:06:26 | LQ_EDIT |
38,306,927 | How Will I get the Present date is 1st of the Month in C# | <p>Could you please help me, </p>
<p>How Will I get to know "Present date is 1st of the Month" in C#.
I am writing Batch Job (Which runs on every day mid night 12 AM) in C#, here I am doing some logic , If the present date is 1st Of the Month.
Kindly help me.</p>
| <c#> | 2016-07-11 12:28:19 | LQ_CLOSE |
38,307,060 | How to set focus on element with binding? | <p>In Angular2 how can I set binding on element focus.
I don't want to set it with elementRef.
I think in AngularJS there is ngFocus directive
In Angular2 there is no such directive</p>
| <angular> | 2016-07-11 12:34:20 | HQ |
38,307,489 | set list as value in a column of a pandas dataframe | <p>Let's say I have a dataframe <code>df</code> and I would like to create a new column filled with 0, I use:</p>
<pre><code>df['new_col'] = 0
</code></pre>
<p>This far, no problem. But if the value I want to use is a list, it doesn't work:</p>
<pre><code>df['new_col'] = my_list
ValueError: Length of values does not match length of index
</code></pre>
<p>I understand why this doesn't work (pandas is trying to assign one value of the list per cell of the column), but how can we avoid this behavior? (if it isn't clear I would like every cell of my new column to contain the same predefined list)</p>
<p>Note: I also tried: <code>df.assign(new_col = my_list)</code>, same problem</p>
| <python><list><pandas> | 2016-07-11 12:53:27 | HQ |
38,307,739 | A simple drawing program | <p>I need to draw circle and rectangular on a picture on webpage,</p>
<p>For this, I found out some programs and open source projects, like <a href="http://zwibbler.com" rel="nofollow">Zwibbler</a>, <a href="http://literallycanvas.com" rel="nofollow">Literally Canvas</a></p>
<p>However, they are lack of some features</p>
<p>I need to take the coordinates of the drawn circles and rectangulars</p>
<p>I couldn't find any application for this operation.</p>
<p>If you know some and comment I would be glad</p>
<p>Thanks in Advance</p>
| <javascript><drawing> | 2016-07-11 13:05:15 | LQ_CLOSE |
38,308,214 | React Enzyme - Test `componentDidMount` Async Call | <p>everyone.</p>
<p>I'm having weird issues with testing a state update after an async call happening in <code>componentDidMount</code>.</p>
<p>Here's my component code:</p>
<pre><code>'use strict';
import React from 'react';
import UserComponent from './userComponent';
const request = require('request');
class UsersListComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
usersList: []
};
}
componentDidMount() {
request('https://api.github.com/users', (err, res) => {
if (!err && res.statusCode === 200) {
this.setState({
usersList: res.slice(0)
});
}
else {
console.log(err);
}
});
}
render() {
if (!this.state.usersList.length) {
return null;
}
return (
<div className="users-list">
{ this._constructUsersList() }
</div>
);
}
_constructUsersList() {
return this.state.usersList.map((user, index) => {
return (
<UserComponent
key={ index }
name={ user.name }
age={ user.age } />
);
});
}
};
export default UsersListComponent;
</code></pre>
<p>Now, what I'm doing in my test files (I have a setup comprised of Mocha + Chai + Sinon, all working):</p>
<pre><code>import React from 'react';
import { expect } from 'chai';
import { shallow, mount, render } from 'enzyme';
import sinon from 'sinon';
import UsersListComponent from '../src/usersListComponent';
describe('Test suite for UsersListComponent', () => {
it('Correctly updates the state after AJAX call in `componentDidMount` was made', () => {
const server = sinon.fakeServer.create();
server.respondWith('GET', 'https://api.github.com/users', [
200,
{
'Content-Type': 'application/json',
'Content-Length': 2
},
'[{ "name": "Reign", "age": 26 }]'
]);
let wrapper = mount(<UsersListComponent />);
server.respond();
server.restore();
expect(wrapper.update().state().usersList).to.be.instanceof(Array);
console.log(wrapper.update().state().usersList.length);
});
});
</code></pre>
<p>State does not get updated, even though I call <code>update()</code> on wrapper. Length is still 0. Am I missing something here? Do I need to mock the server response in another way?</p>
<p>Thnx for the help!</p>
| <javascript><reactjs><enzyme> | 2016-07-11 13:27:14 | HQ |
38,308,350 | How to get week number from date input in javascript? | <p>I am trying to get the week number of current date / specific date falls in. Any suggestions for logic building will be helpful.</p>
| <javascript><date><week-number> | 2016-07-11 13:33:51 | LQ_CLOSE |
38,308,794 | Where is the mistake in this code? | <p>I'm a noobie in php, so I got this code from my teacher and I can't get the answer. Can somebody explain me where is the mistake is this code?</p>
<pre><code><?php
function XXX($array, $val) {
foreach ($array as $key => $value) {
if ($value == $val) {
unset($value);
return $key;
break;
}
}
return FALSE;
}
</code></pre>
| <php> | 2016-07-11 13:55:44 | LQ_CLOSE |
38,308,871 | How to disable gathering facts for subplays not included within given tag | <p>Several of my playbooks have sub-plays structure like this:</p>
<pre><code>- hosts: sites
user: root
tags:
- configuration
tasks:
(...)
- hosts: sites
user: root
tags:
- db
tasks:
(...)
- hosts: sites
user: "{{ site_vars.user }}"
tags:
- app
tasks:
(...)
</code></pre>
<p>In Ansible 1.x both admins and developers were able to use such playbook. Admins could run it with all the tags (root and user access), while developers had access only to the last tag with tasks at user access level. When developers run this playbook with the <em>app</em> tag, gathering facts was skipped for the first two tags. Now however, in Ansible 2.1, it is not being skipped, which causes failure for users without root access. </p>
<p>Is there a mechanism or an easy modification to fix this behaviour? Is there a new approach which should be applied for such cases now?</p>
| <ansible><ansible-playbook><ansible-2.x> | 2016-07-11 13:58:50 | HQ |
38,308,998 | Car travel time between two points swift | <p>I am looking for something in swift that can give me the travel time (by car) of two coordinates. On some other threads, I have only seen suggestions to use external sources, but my question is, does apple have a built in feature to do this? Similarily, if there is not can someone please link a few external sources, as I have not found it (probably because I don't know exactly what I am looking for?</p>
<p>Thanks a lot.</p>
| <ios><swift> | 2016-07-11 14:04:56 | LQ_CLOSE |
38,309,430 | sed search for line and remove the first character of the following ten lines | <p>I have a file with links in it. the links are commented out. I would like to use sed or awk to search for a specific string and then remove the first character of the following ten lines. </p>
<p>As far as I know, I can search with sed in the following way</p>
<pre><code>sed -n '/StringToSearchFor/p' file
</code></pre>
<p>With awk I would write the following</p>
<pre><code>awk '/pattern/ {print $1}'
</code></pre>
<p>But how could I delete the first character of the following ten lines?</p>
<p>The manual page of sed and awk are a huge. So please do not point to them beside you have a search string for me.</p>
<p>Thanks in advance.</p>
| <bash><awk><sed> | 2016-07-11 14:25:11 | LQ_CLOSE |
38,309,481 | Angular 2: Inject service into class | <p>I have angular class that represents shape. I want to be able to instantiate multiple instances of that class using constructor.</p>
<p>The constructor takes multiple arguments representing properties of that shape.</p>
<pre><code>constructor(public center: Point, public radius: number, fillColor: string,
fillOpacity: number, strokeColor: string, strokeOpacity: number, zIndex: number)
</code></pre>
<p>Inside my class I want to use service that provides capability to draw shapes on the map. Is it possible to inject that service into my class and still use constructor the standard way.</p>
<p>So I want to do something like below and have Angular automatically resolve injected dependency.</p>
<pre><code>constructor(public center: GeoPoint, public radius: number,
fillColor: string, fillOpacity: number, strokeColor: string, strokeOpacity: number,
zIndex: number, @Inject(DrawingService) drawingService: DrawingService)
</code></pre>
| <typescript><dependency-injection><angular> | 2016-07-11 14:27:35 | HQ |
38,309,685 | Calculate cumulative sum based on other columns in R | I have a data frame like this:
wpt ID Fuel Dist Express Local
1 S36 12 1 1 0
2 S36 14 4 1 0
inter S36 15 7 0 1
3 S36 18 10 0 1
inter S36 20 12 1 0
4 S36 23 17 1 0
5 S36 30 20 1 0
6 W09 45 9 0 1
7 W09 48 14 0 1
8 W09 50 15 0 1
I want to get **cumulative sum of Fuel and Dist** under each **Express and Local type**. The ideal output would be:
ID sum.fuel sum.dist Express Local
S36 12 11 1 0
S36 3 3 0 1
W09 5 6 0 1
**Note:** There are **multiple blocks grouped by Express and Local**;
To be clear, for **"S36"** under **Express** the cumulative fuel is defined by (14-12)+(23-20).
Thanks in advance!!!
| <r><dataframe><dplyr><plyr> | 2016-07-11 14:36:29 | LQ_EDIT |
38,310,523 | sql db2 how to string match between two columns | Hi if I have two columns such as:
col1 col2
---- ----
5qt exception for 5qt ammended
5qt exception for 5076 ammended
6d3 6d3 registered
I want to string match so that if the value of `col1` exists in `col2`, return col2.
So I get:
exception for 5qt ammended
6d3 registered
I have tried using `locate()` but not with much luck:
select col2 from mytable
where locate(col1,col2) = 1
I have previously had this working where `col2` began with the value of `col1` i.e.
col1 col2
---- ----
5qt 5qt ammended
5qt 5076 ammended
6d3 6d3 registered
but it seems the fact the value of `col1` can appear in any position of `col2` is throwing `locate()` off the trail.
any advice would be grateful. | <sql><string><db2> | 2016-07-11 15:16:41 | LQ_EDIT |
38,311,393 | PHP install instructions? | <p>I need to learn php, but i'm struggling with the install process to run the code in a web browser.</p>
<p>usually when I try to run a php code the screen stays white</p>
<p>I tried to follow the php configuration process from some sites but usually I end up getting lost.</p>
<p>So if anyone knows the steps to install and configure php in windows 7 please help.</p>
| <php><installation> | 2016-07-11 16:01:36 | LQ_CLOSE |
38,312,247 | what's the difference between the two function? | def PartitionDemo(a,p,r):
x=a[p]
start=p
end=r
while start<end :
while start<end and a[end]>=x :
end-=1
while start<end and a[start]<x :
a[start]=a[end]
start+=1
a[end]=a[start]
a[start]=x
return start
def Partition2(a,low,high):
key = a[low]
while low < high:
while low < high and a[high] >= key:
high -= 1
while low < high and a[high] < key:
a[low] = a[high]
low += 1
a[high] = a[low]
a[low] = key
return low
PartitionDemo i write it myself,Partition2 i copy it from the net.but PartitionDemo can't run normally.it can not jump out the loop.they are the same logic i think.Partition2 works well.i try the quicksort in C++,Java,python.i don't understand what's going wrong in python. | <python><quicksort> | 2016-07-11 16:53:05 | LQ_EDIT |
38,313,432 | how can I have this in formula in excel please? | Cell > 0: Overdue
Cell between 0 to -2: A
Cell between -3 to -5: B
Cell between -6 to -10: C
Cell between -11 to 30: D | <excel><excel-formula> | 2016-07-11 18:06:50 | LQ_EDIT |
38,314,717 | Use Moment to get month of Date object | <p>I'm sure this is a simple thing but I haven't been able to find the specific syntax in any of the documentation or in any related posts. </p>
<p>In order to get a month-picker to work i need to instantiate a new <code>Date</code> object when my controller initializes. </p>
<p><strong>Controller</strong></p>
<pre><code>scope.date = new Date();
</code></pre>
<p>This creates a date object with the following format: </p>
<blockquote>
<p>Mon Feb 01 2016 15:21:43 GMT-0500 (Eastern Standard Time)</p>
</blockquote>
<p>However when I attempt to pull the month from the date object, using moment, I get the error: </p>
<blockquote>
<p>enter code here</p>
</blockquote>
<p><strong>getMonth method</strong></p>
<pre><code>var month = moment().month(scope.date, "ddd MMM DD YYYY");
</code></pre>
<p>Any idea how to pull the month from the above date object without using substring?</p>
| <javascript><date><momentjs> | 2016-07-11 19:28:40 | HQ |
38,315,235 | Podio Integratioon | <p>I'm developing an app which uses the data from podio website. Here my need is that Integrate the Podio api into my app and Authenticate the app with user credentials.</p>
<p>How this could be done??
please put some example codes. <<<<strong>THANKS IN ADVANCE>>>>></strong></p>
| <authentication><integration><podio> | 2016-07-11 20:01:19 | LQ_CLOSE |
38,315,539 | Duplicating a git repository and its GIT-LFS settings | <p>I've duplicated a repo into a newer repo but when doing a git clone on the new repo it's unable to download the files using the LFS pointers and I get an error when smudge is used...
e.g... "Error downloading object. Object not found on server"</p>
<p>Steps:</p>
<pre><code>git clone --bare https://github.com/myuser/old-repo.git
cd old-repository.git
git push --mirror https://github.com/myuser/new-repo.git
git clone https://github.com/myuser/new-repo.git
[error.....git-lfs.exe smudge --- somefile.....Error downloading object]
</code></pre>
<p>The branches and commit histories look fine but LFS fails to download the required files. Is there another method when using git-lfs?</p>
| <git><github><github-for-windows><git-lfs> | 2016-07-11 20:19:44 | HQ |
38,316,321 | Change a field in a Django REST Framework ModelSerializer based on the request type? | <p>Consider this case where I have a <code>Book</code> and <code>Author</code> model. </p>
<p>serializers.py</p>
<pre><code>class AuthorSerializer(serializers.ModelSerializer):
class Meta:
model = models.Author
fields = ('id', 'name')
class BookSerializer(serializers.ModelSerializer):
author = AuthorSerializer(read_only=True)
class Meta:
model = models.Book
fields = ('id', 'title', 'author')
</code></pre>
<p>viewsets.py</p>
<pre><code>class BookViewSet(viewsets.ModelViewSet):
queryset = Book.objects.all()
serializer_class = BookSerializer
</code></pre>
<p>This works great if I send a <code>GET</code> request for a book. I get an output with a nested serializer containing the book details and the nested author details, which is what I want.</p>
<p>However, when I want to create/update a book, I have to send a <code>POST</code>/<code>PUT</code>/<code>PATCH</code> with the nested details of the author instead of just their id. I want to be able to create/update a book object by specifying a author id and not the entire author object. </p>
<p>So, something where my serializer looks like this for a <code>GET</code> request</p>
<pre><code>class BookSerializer(serializers.ModelSerializer):
author = AuthorSerializer(read_only=True)
class Meta:
model = models.Book
fields = ('id', 'title', 'author')
</code></pre>
<p>and my serializer looks like this for a <code>POST</code>, <code>PUT</code>, <code>PATCH</code> request</p>
<pre><code>class BookSerializer(serializers.ModelSerializer):
author = PrimaryKeyRelatedField(queryset=Author.objects.all())
class Meta:
model = models.Book
fields = ('id', 'title', 'author')
</code></pre>
<p>I also do not want to create two entirely separate serializers for each type of request. I'd like to just modify the <code>author</code> field in the <code>BookSerializer</code>. </p>
<p>Lastly, is there a better way of doing this entire thing?</p>
| <django><django-rest-framework><django-serializer> | 2016-07-11 21:13:32 | HQ |
38,317,379 | Plot with darker color for denser areas and transparent color for less dense areas | <p>How can I make a plot in R with ggplot2 that is darker where there are more points and more transparent where there are less points? I tried making a geom_hex plot with a gradient but it is ignoring alpha values.</p>
| <r><ggplot2> | 2016-07-11 22:47:16 | LQ_CLOSE |
38,318,536 | Differences between vue instance and vue component? | <p>I'm new to vue js and have some questions when learning it.</p>
<p>I'm now a little confused about the relationship between its instance and component. As far as I learned, every app build by vue should only have one instance and one instance only, it can have as many components as you like if needed. But recently I've seen a demo, and in that demo it has more than one instance.</p>
<p>So my question is, is that ok to have multiple intances in one app( the demo code works fine, but is that the correct way)? What's the best practice to use instance and component in vue app?</p>
| <vue.js> | 2016-07-12 01:15:15 | HQ |
38,318,717 | Null pointer Exception on TabLayout | <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.TabLayout.addOnTabSelectedListener(android.support.design.widget.TabLayout$OnTabSelectedListener)' on a null object reference
</code></pre>
<p>Declared this before onCreate():</p>
<pre><code>TabLayout.OnTabSelectedListener listener;
</code></pre>
<p>and this in onCreate():</p>
<pre><code>TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
listener = new TabLayout.OnTabSelectedListener(){
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
};
tabLayout.addOnTabSelectedListener(listener);
</code></pre>
<p>I'm having trouble seeing how listener is null. I have other NullPointerExceptions that even claim null object on primitives including ints defined by drawable pngs?</p>
| <android><android-support-library> | 2016-07-12 01:37:51 | LQ_CLOSE |
38,319,050 | Where is Illuminate? | <p>Every time when I try to do some modifications in certain area, <em>Authentication for example</em>, I end up finding everything is declared in <code>Illuminate\Foundation\...</code>.</p>
<p>Okay, now all I need to do is get to that location and look into some codes.</p>
<p>But hey, where is this <code>Illuminate</code> and all stuff???</p>
<p>I don't see any folders named Illuminate anywhere in my Laravel package.</p>
<p>Tried to search for the solution but I guess I'm the only silly person who lacks ability in understanding some basics.</p>
| <php><laravel> | 2016-07-12 02:23:55 | HQ |
38,319,898 | tensorflow neural net with continuous / floating point output? | <p>I'm trying to create a simple neural net in tensorflow that learns some simple relationship between inputs and outputs (for example, y=-x) where the inputs and outputs are floating point values (meaning, no softmax used on the output).</p>
<p>I feel like this should be pretty easy to do, but I must be messing up somewhere. Wondering if there are any tutorials or examples out there that do something similar. I looked through the existing tensorflow tutorials and didn't see anything like this and looked through several other sources of tensorflow examples I found by googling, but didn't see what I was looking for.</p>
<p>Here's a trimmed down version of what I've been trying. In this particular version, I've noticed that my weights and biases always seem to be stuck at zero. Perhaps this is due to my single input and single output?</p>
<p>I've had good luck altering the mist example for various nefarious purposes, but everything I've gotten to work successfully used softmax on the output for categorization. If I can figure out how to generate a raw floating point output from my neural net, there are several fun projects I'd like to do with it.</p>
<p>Anyone see what I'm missing? Thanks in advance!
- J.</p>
<pre><code> # Trying to define the simplest possible neural net where the output layer of the neural net is a single
# neuron with a "continuous" (a.k.a floating point) output. I want the neural net to output a continuous
# value based off one or more continuous inputs. My real problem is more complex, but this is the simplest
# representation of it for explaining my issue. Even though I've oversimplified this to look like a simple
# linear regression problem (y=m*x), I want to apply this to more complex neural nets. But if I can't get
# it working with this simple problem, then I won't get it working for anything more complex.
import tensorflow as tf
import random
import numpy as np
INPUT_DIMENSION = 1
OUTPUT_DIMENSION = 1
TRAINING_RUNS = 100
BATCH_SIZE = 10000
VERF_SIZE = 1
# Generate two arrays, the first array being the inputs that need trained on, and the second array containing outputs.
def generate_test_point():
x = random.uniform(-8, 8)
# To keep it simple, output is just -x.
out = -x
return ( np.array([ x ]), np.array([ out ]) )
# Generate a bunch of data points and then package them up in the array format needed by
# tensorflow
def generate_batch_data( num ):
xs = []
ys = []
for i in range(num):
x, y = generate_test_point()
xs.append( x )
ys.append( y )
return (np.array(xs), np.array(ys) )
# Define a single-layer neural net. Originally based off the tensorflow mnist for beginners tutorial
# Create a placeholder for our input variable
x = tf.placeholder(tf.float32, [None, INPUT_DIMENSION])
# Create variables for our neural net weights and bias
W = tf.Variable(tf.zeros([INPUT_DIMENSION, OUTPUT_DIMENSION]))
b = tf.Variable(tf.zeros([OUTPUT_DIMENSION]))
# Define the neural net. Note that since I'm not trying to classify digits as in the tensorflow mnist
# tutorial, I have removed the softmax op. My expectation is that 'net' will return a floating point
# value.
net = tf.matmul(x, W) + b
# Create a placeholder for the expected result during training
expected = tf.placeholder(tf.float32, [None, OUTPUT_DIMENSION])
# Same training as used in mnist example
cross_entropy = -tf.reduce_sum(expected*tf.log(tf.clip_by_value(net,1e-10,1.0)))
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
sess = tf.Session()
init = tf.initialize_all_variables()
sess.run(init)
# Perform our training runs
for i in range( TRAINING_RUNS ):
print "trainin run: ", i,
batch_inputs, batch_outputs = generate_batch_data( BATCH_SIZE )
# I've found that my weights and bias values are always zero after training, and I'm not sure why.
sess.run( train_step, feed_dict={x: batch_inputs, expected: batch_outputs})
# Test our accuracy as we train... I am defining my accuracy as the error between what I
# expected and the actual output of the neural net.
#accuracy = tf.reduce_mean(tf.sub( expected, net))
accuracy = tf.sub( expected, net) # using just subtract since I made my verification size 1 for debug
# Uncomment this to debug
#import pdb; pdb.set_trace()
batch_inputs, batch_outputs = generate_batch_data( VERF_SIZE )
result = sess.run(accuracy, feed_dict={x: batch_inputs, expected: batch_outputs})
print " progress: "
print " inputs: ", batch_inputs
print " outputs:", batch_outputs
print " actual: ", result
</code></pre>
| <tensorflow> | 2016-07-12 04:11:14 | HQ |
38,320,008 | How to cache Django Rest Framework API calls? | <p>I'm using Memcached as backend to my django app. This code works fine in normal django query:</p>
<pre><code>def get_myobj():
cache_key = 'mykey'
result = cache.get(cache_key, None)
if not result:
result = Product.objects.all().filter(draft=False)
cache.set(cache_key, result)
return result
</code></pre>
<p>But it doesn't work when used with django-rest-framework api calls:</p>
<pre><code>class ProductListAPIView(generics.ListAPIView):
def get_queryset(self):
product_list = Product.objects.all()
return product_list
serializer_class = ProductSerializer
</code></pre>
<p>I'm about to try DRF-extensions which provide caching functionality:</p>
<p><a href="https://github.com/chibisov/drf-extensions" rel="noreferrer">https://github.com/chibisov/drf-extensions</a></p>
<p>but the build status on github is currently saying "build failing".</p>
<p>My app is very read-heavy on api calls. Is there a way to cache these calls?</p>
<p>Thank you.</p>
| <python><django><caching><django-rest-framework><memcached> | 2016-07-12 04:25:35 | HQ |
38,320,363 | Subclassing a UITableViewCell subclass and still use the existing Xib file | What is the proper way to *subclass* an existing *sublass of UITableViewCell* that has an attached Xib file. How do I subclass the UITableViewCell subclass and still use the Xib in the new class? | <ios><objective-c><uitableview><ios8> | 2016-07-12 05:02:30 | LQ_EDIT |
38,320,543 | As i am Got the XML data and how i can save the XML Data in Objective C | As an New to the iOS Developement in Xcode 7.
Below i have some questions please clarify my doubt
1. I need to Store the XML Data from an URL
2. And Split the XML data each line and store it in the Objective C
3. Below i mention my XML data
<EstablishmentName>La Parrilla Colombian Steakhouse & Bar</EstablishmentName>
<BusinessName>La Parrilla Colombian Steakhouse & Bar</BusinessName>
<OpenTime>PT8H31M</OpenTime>
<ClosingTime>PT18H50M</ClosingTime>
<Floor>12 th floor</Floor>
<Building>EST Buliding</Building> | <objective-c><xml> | 2016-07-12 05:17:30 | LQ_EDIT |
38,320,771 | Getting more hardware profiles in to Android Studio | <p>I have been looking for some time now for where to obtain and how to import new hardware profiles in to Android Studio, or manually build new ones, but have been unsuccessful. Can someone point me to a resource that would allow me to do this? Specifically, I am talking about this area within Android Studio.</p>
<p><a href="https://i.stack.imgur.com/g1R3Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g1R3Y.png" alt="enter image description here"></a></p>
| <android><android-studio> | 2016-07-12 05:38:17 | HQ |
38,320,837 | How can I execute the code line by line in jupyter-notebook? | <p>I'm reading the book, <code>Python Machine Learning</code>, and tried to analyze the code. But it offers only <code>*.ipynb</code> file and it makes me very bothersome.</p>
<p>For example, </p>
<p><a href="https://i.stack.imgur.com/VVzTb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VVzTb.png" alt="enter image description here"></a></p>
<p>In this code, I don't want to run whole <code>In[9]</code> but want to run line by line so that I can check each value of variable and know what each library function do. </p>
<p>Do I have to comment everytime I want to execute part of codes? I just want something like <code>Execute the block part</code> like in <code>MATLAB</code></p>
<p>And also, let say I comment some part of code and execute line by line. How can I check each variable's value without using <code>print()</code> or <code>display()</code>? As you know, I don't have to use <code>print()</code> to check the value in <code>python interactive shell</code> in terminal. Is there a similar way in <code>Jupyter</code>?</p>
| <python><ipython><ipython-notebook><jupyter><jupyter-notebook> | 2016-07-12 05:43:41 | HQ |
38,320,886 | App Insights: Disable SQL Dependency telemetry | <p>I'm using Azure Application Insights for a website (Azure App Service).
On that I'm using a clustered Umbraco setup and hangfire. These two alone keep hitting the database every minute and are flooding my 'App Insights'.</p>
<p>So my question is, how do I disable the Sql Dependency Tracker?
I've had a look at the ApplicationInsights.config and couldn't find anything obvious.
I can see <code>Microsoft.ApplicationInsights.DependencyCollector</code> which is probably responsible, but I don't want to remove all types of dependency telemetry, <strong>only</strong> sql.</p>
<p>Thanks</p>
| <azure><azure-sql-database><azure-application-insights> | 2016-07-12 05:47:08 | HQ |
38,321,275 | Toggle button in WPF | <p>I am new to wpf . I want to create toggle button like </p>
<p><a href="https://i.stack.imgur.com/pIhyh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pIhyh.png" alt="Toggle button"></a></p>
<p>how can I achieve this. should I need to use two buttons and on click of each I need to disable other one. or there is anything else like toggle button in wpf. what is best way to achieve this.. any suggestion appreciated.Thanks</p>
| <wpf><button><toggle> | 2016-07-12 06:17:07 | HQ |
38,321,880 | How to go about adding a link/reference to another method in documentation Xcode? | <p>I am adding some description to my method in class. This is how I achieved this:</p>
<p><a href="https://i.stack.imgur.com/1przA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1przA.png" alt="enter image description here"></a></p>
<p>And it looks like this upon clicking...</p>
<p><a href="https://i.stack.imgur.com/WqCwW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WqCwW.png" alt="enter image description here"></a></p>
<p>How can I make the underlined method clickable? I want it to be referenced so that when a user clicks on it, they are directed to a particular web page for documentation. </p>
<p>Is it even possible?
Thanks in advance, any help will be appreciated</p>
| <ios><swift><xcode><documentation> | 2016-07-12 06:52:44 | HQ |
38,321,910 | Sorting data in Angular | <pre><code><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<style>
table{
border:2px solid black;
border-collapse:collapse;
font-family:Arial;
}
td{
border:2px solid black;
padding:5px;
}
th{
border:2px solid black;
padding:10px;
}
</style>
</head>
<script type="text/javascript">
var app=angular.module("myApp",[]);
app.controller("likeDislikeCount",function($scope)
{
var technology=[
{name:"C",like:0,Dislike:0},
{name:"Python",like:0,Dislike:0},
{name:"Java",like:0,Dislike:0},
{name:"Angular",like:0,Dislike:0}
];
$scope.technology=technology;
$scope.rowLimit=1;
$scope.selectCol=name;
$scope.increeseLike=function(technology1){
technology1.like++;
};
$scope.increseDisLike=function(technology1){
technology1.Dislike++;
};
}
);
</script>
<body ng-app="myApp">
<div ng-controller="likeDislikeCount">
No. of rows to display :: <input type="number" ng-model="rowLimit" min=0 max=4 /> <br><br>
order by <select ng-model="selectCol">
<option value="name">Name ASC</option>
<option value="like">LIke ASC</option>
<option value="-Dislike">Dislike DSC</option>
</select>
<br><br>
<table>
<thead>
<th>Name</th>
<th>LikeCount</th>
<th>DislikeCount</th>
<th>Click</th>
</thead>
<tbody>
<tr ng-repeat = "x in technology | orderBy:'selectCol'">
<td>{{x.name}}</td>
<td>{{x.like}}</td>
<td>{{x.Dislike}}</td>
<td><button ng-click="increeseLike(x)">LIKE</button><button ng-click="increseDisLike(x)">DISLIKE</button></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
</code></pre>
<p>this code I am trying to show the table depending on order of any of name,like and dislike.When I will select any of one from dropdown It should the data according to that field.But its not working appropriately.
Please correct it completly and help me
Thanks</p>
| <angularjs> | 2016-07-12 06:54:22 | LQ_CLOSE |
38,323,132 | How to set image received from JSON in UIImageView in objective c | i Received following response from JSON:
{
age = 42;
city = Berlin;
country = Deutschland;
distance = "4.58";
"full_name" = Klaus;
gender = Male;
id = 654;
online = 0;
profile = "Klaus.png";
})
NSString *imageURL = [[_responsedic valueForKey:@"profile"]objectAtIndex:0];
_TopList_ImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]];
i want to set profile value in UIImageView.
but this will do nothing. Any help .Thanx in advance.
| <ios><objective-c><iphone><uiimageview> | 2016-07-12 08:01:30 | LQ_EDIT |
38,323,286 | Change CSS code when div elemet ist clicked | I'm currently trying to make a little photo album for a website.
There are some small photo thumbnails on the left side. If you click one of them it should appear on the right side in full resulution. I thought you could solve this by overlapping all pictures and put them in `display: none`. Every time you click on a thumbnail image a little javascript function triggers which changes the css of the specific picture to `display: block` to make it visible. Here's my existing code incl. JSfiddle:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.images{
float: left;
margin-right: 10px;
border: 1px solid silver;
width: 100px;
height: 100px;
overflow: hidden;
margin-bottom: 50px;
border: 4px solid transparent;}
.images img{
height: 100px;
width: auto;}
.images:hover, .images:visited, .images:active {
border: 4px solid #009EE0;}
.table {
width: 60%;
height: 100%;
border-right: 1px solid silver;
float: left;}
<!-- language: lang-html -->
<div class="table">
<div class="images">
<img src="http://mgt.sjp.ac.lk/ent/wp-content/uploads/2015/03/coming-soon-bigger-600x600.jpg" alt="DK_2014_MFK_Radtour_0168.jpg, 241kB" title="DK 2014 MFK Radtour 0168" height="auto" width="300">
</div>
<div class="images">
<img src="https://www.drphillipscenter.org/resources/images/default.jpg" alt="DK_2014_MFK_Radtour_0168.jpg, 241kB" title="DK 2014 MFK Radtour 0168" height="auto" width="300">
</div>
</div>
<p>When clicked, I want the Picture to appear right here but sized bigger.</p>
<!-- end snippet -->
https://jsfiddle.net/zar2u0v1/1/
Better suggestions as hiding all the images would be nice because the lack of performance would be a problem.
Thanks in advance and I hope you can help me!
| <javascript><jquery><html><css> | 2016-07-12 08:10:28 | LQ_EDIT |
38,323,303 | Identifying use case diagram elements | <p>To map the User Stories, Epics, and Roles to Use Case diagram elements what are the possible methods of we can follow?</p>
| <use-case><user-stories> | 2016-07-12 08:11:15 | LQ_CLOSE |
38,323,596 | Depend on git repository in setup.py | <p>I'm trying to make a project depend on a git dependency. However, I can't seem to get it to work. What I basically want to achieve is the following, but it doesn't work:</p>
<pre><code>#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'git+https://github.com/remcohaszing/pywakeonlan.git'
])
</code></pre>
<p>I tried several variations on the above, such as adding <code>@master</code> or <code>#egg=wakeonlan-0.2.2</code>, but this doesn't make a difference.</p>
<p>The following works, but only when using the deprecated <code>pip</code> flag, <code>--process-dependency-links</code>:</p>
<pre><code>#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'wakeonlan'
],
dependency_links=[
'git+https://github.com/remcohaszing/pywakeonlan.git#egg=wakeonlan-0.2.2'
])
</code></pre>
<p>This outputs:</p>
<pre><code>$ pip install --no-index -e . --process-dependency-links
Obtaining file:///home/remco/Downloads/spam
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting wakeonlan (from spam==0.0.0)
Cloning https://github.com/remcohaszing/pywakeonlan.git to /tmp/pip-build-mkhpjcjf/wakeonlan
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Installing collected packages: wakeonlan, spam
Running setup.py install for wakeonlan ... done
Running setup.py develop for spam
Successfully installed spam wakeonlan-0.2.2
</code></pre>
<p>The following does work:</p>
<pre><code>pip install 'git+https://github.com/remcohaszing/pywakeonlan.git'
</code></pre>
<p>Also adding the git url in a requirements file just works.</p>
<p>Is there any <strong>non deprecated</strong> way to depend on a git url using a <code>setup.py</code> file?</p>
| <python><git><pip><setuptools> | 2016-07-12 08:27:29 | HQ |
38,323,895 | How to add claims in a mock ClaimsPrincipal | <p>I am trying to unit test my controller code which gets the information from the ClaimsPrincipal.Current.
In the controller code I</p>
<pre><code>public class HomeController {
public ActionResult GetName() {
return Content(ClaimsPrincipal.Current.FindFirst("name").Value);
}
}
</code></pre>
<p>And I am trying to mock my ClaimsPrincipal with claims but I still don't have any mock value from the claim.</p>
<pre><code>// Arrange
IList<Claim> claimCollection = new List<Claim>
{
new Claim("name", "John Doe")
};
var identityMock = new Mock<ClaimsIdentity>();
identityMock.Setup(x => x.Claims).Returns(claimCollection);
var cp = new Mock<ClaimsPrincipal>();
cp.Setup(m => m.HasClaim(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
cp.Setup(m => m.Identity).Returns(identityMock.Object);
var sut = new HomeController();
var contextMock = new Mock<HttpContextBase>();
contextMock.Setup(ctx => ctx.User).Returns(cp.Object);
var controllerContextMock = new Mock<ControllerContext>();
controllerContextMock.Setup(con => con.HttpContext).Returns(contextMock.Object);
controllerContextMock.Setup(con => con.HttpContext.User).Returns(cp.Object);
sut.ControllerContext = controllerContextMock.Object;
// Act
var viewresult = sut.GetName() as ContentResult;
// Assert
Assert.That(viewresult.Content, Is.EqualTo("John Doe"));
</code></pre>
<p>The viewresult.Content is empty as I run the unit test. Any help if I can add the mock claim. Thanks.</p>
| <c#><.net><unit-testing><asp.net-mvc-5><moq> | 2016-07-12 08:41:54 | HQ |
38,324,326 | SASS Multiplication with units | <p>If I try to multiply two value with units I get an unexpected error.</p>
<pre><code>$test: 10px;
.testing{
width: $test * $test;
}
result: 100px*px isn't a valid CSS value.
</code></pre>
| <sass> | 2016-07-12 09:01:47 | HQ |
38,324,439 | thumb rule for using auto&& and const auto & | I have studied auto and I know it deduces types from initialized values. So if I try to write certain thumb rule for usage of auto, can I put below statements as rule-
1) Use auto && for all values (r-values and l-value, as It is universal ref)those are modifiable.
2)const auto & - for read only values.
3) Use auto wherever possible (individual preference for coding style)
| <c++><c++11><constants><auto><forwarding-reference> | 2016-07-12 09:07:02 | LQ_EDIT |
38,324,448 | Telegram Bot Event When Users Join To Channel | <p>After create telegram bot, access and admin this bot to channel. how to get channel members list or event when users join to this channel?</p>
| <bots><telegram> | 2016-07-12 09:07:33 | HQ |
38,324,949 | error TS2339: Property 'x' does not exist on type 'Y' | <p>I don't understand why this code generates TypeScript error.
(It's not the original code and is a bit derived, so please ignore the non-sense in the example):</p>
<pre class="lang-js prettyprint-override"><code>interface Images {
[key:string]: string;
}
function getMainImageUrl(images: Images): string {
return images.main;
}
</code></pre>
<p>I'm getting error (using TypeScript 1.7.5):</p>
<blockquote>
<p>error TS2339: Property 'main' does not exist on type 'Images'.</p>
</blockquote>
<p>Of course I could get rid of the error when writing:</p>
<pre><code>return images["main"];
</code></pre>
<p>I'd prefer not using string to access the property. What can I do?</p>
| <typescript> | 2016-07-12 09:29:31 | HQ |
38,325,162 | Why click tree throws 'System.Windows.Documents.Run' is not a Visual or Visual3D' InvalidOperationException? | <p>Sometimes right-clicking treeviewitem results unhandled InvalidOperationException. In code behind I select the right clicked row:</p>
<pre><code> static TreeViewItem VisualUpwardSearch(DependencyObject source)
{
while (source != null && !(source is TreeViewItem))
source = VisualTreeHelper.GetParent(source);
return source as TreeViewItem;
}
private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
if (treeViewItem != null)
{
treeViewItem.Focus();
e.Handled = true;
}
}
</code></pre>
<p>According to stacktrace above is the source of the problem. </p>
<p>xaml:</p>
<pre><code><UserControl.Resources>
<HierarchicalDataTemplate ItemsSource="{Binding ClassesItemsSource}" DataType="{x:Type pnls:FavoriteObjectTableViewModel}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="{Binding Bitmap}" />
<Label Content="{Binding TableName}"/>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type pnls:FavoriteObjectClassViewModel}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Bitmap, Converter={StaticResource UriToCachedImageConverter}}"/>
<Label Content="{Binding ClassName}"/>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<TreeView Name="Insert_ObjectTreeIE" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding TablesItemsSource}">
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<EventSetter Event="PreviewMouseRightButtonDown" Handler="OnPreviewMouseRightButtonDown"></EventSetter>
<EventSetter Event="MouseDoubleClick" Handler="OnMouseDoubleClick" />
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</code></pre>
<p>Stacktrace:</p>
<pre><code>e.StackTrace " at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)\r\n
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)\r\n
at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)\r\n
at Tekla.Nis.Application.Shared.UI.Panels.FavoriteObjectsView.VisualUpwardSearch(DependencyObject source) in c:\\XXX\\161wpf\\src\\SharedAppFeature\\Panels\\FavoriteObjectsView.xaml.cs:line 45\r\n
at Application.Shared.UI.Panels.FavoriteObjectsView.OnPreviewMouseRightButtonDown(Object sender, MouseButtonEventArgs e) in c:\\XXX\\161wpf\\src\\NisSharedAppFeature\\Panels\\FavoriteObjectsView.xaml.cs:line 52\r\n
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)\r\n
at System.Windows.UIElement.OnPreviewMouseDownThunk(Object sender, MouseButtonEventArgs e)\r\n
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args)\r\n
at System.Windows.Input.InputManager.ProcessStagingArea()\r\n
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)\r\n
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)\r\n
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)\r\n
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)\r\n
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n
at System.Windows.Application.RunDispatcher(Object ignore)\r\n
at System.Windows.Application.RunInternal(Window window)\r\n
at System.Windows.Application.Run(Window window)\r\n
at System.Windows.Application.Run()\r\n at "my application start location"
</code></pre>
<p>I can reproduce this only sometimes. My colleague said left click item 1 and right click item 2 produces this every time in certain tree.</p>
| <c#><wpf><visual-tree><visualtreehelper> | 2016-07-12 09:39:55 | HQ |
38,325,210 | Proper way to stop Akka Streams on condition | <p>I have been successfully using <a href="http://doc.akka.io/api/akka/2.4/?_ga=1.140568374.588201913.1464855311#akka.stream.scaladsl.FileIO$" rel="noreferrer">FileIO</a> to stream the contents of a file, compute some transformations for each line and aggregate/reduce the results. </p>
<p>Now I have a pretty specific use case, where I would like to stop the stream when a condition is reached, so that it is not necessary to read the whole file but the process finishes as soon as possible. What is the recommended way to achieve this?</p>
| <scala><akka-stream> | 2016-07-12 09:42:20 | HQ |
38,325,533 | Disable frozen string literal comment checking | <p>I'm newbie in Rails. I am using 'Rubocop' for checking standards, however I'm bothered with the way it checks the 'frozen string literal'. It keeps on saying on my files: </p>
<pre><code>Missing frozen string literal comment.
</code></pre>
<p>Is there a way to disable the checking of this on rubocop? Or is it a bad idea to disable it?</p>
<p>I tried this on rubocop.yml but didn't work</p>
<pre><code>frozen_string_literal: false
</code></pre>
| <ruby-on-rails><ruby><rubocop> | 2016-07-12 09:55:33 | HQ |
38,325,756 | create email address validation in this formet in javascript |
**An acceptable email address should meet following criteria to be called a valid email address**
> Contains exactly one '@'
> Minimum 2 characters before '@'
> Any characters including numbers and special characters before '@' are allowed.
> Contains at least one '.' after '@'
> Any number of '.' are allowed after '@'
> Only alphabets and '.' are allowed after '@'
> Minimum 2 characters required between '@' and '.' after '@'
> Minimum 2 characters required between two '.' if more than one '.' is present after '@'
> Minimum 2 characters required after last '.' | <javascript> | 2016-07-12 10:06:12 | LQ_EDIT |
38,326,354 | Multiple apps in one project or one project per app in Firebase? | <p>I have, at the moment 2 android apps in which I want to add notifications and maybe ads and analytics, using Firebase, since it's free and easy to implement.</p>
<p>I see that I have 2 options:</p>
<ol>
<li>Create a new project with my company's name and add the 2 apps in there</li>
<li>Create 2 projects, each with app's name and on each of them add the related apps.</li>
</ol>
<p>Which one would be the correct approach and why?
Thank you.</p>
| <firebase> | 2016-07-12 10:32:18 | HQ |
38,326,987 | error class interface or enum expected - Adding 2 numbers from android | This code is to add 2 numbers from android. Please help me.
public void onButtonclick(View v) {
EditText e1 = (EditText) findViewById(R.id.editText);
EditText e2 = (EditText) findViewById(R.id.editText2);
TextView t1 = (TextView) findViewById(R.id.textView);
int num1 = Integer.parseInt(e1.getText().toString());
int num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 + num2;
t1.setText(Integer.toString(sum));
} | <android><android-edittext><textview> | 2016-07-12 11:01:01 | LQ_EDIT |
38,327,188 | Android, setting background color of button loses ripple effect | <p>After adding color to an android button, it loses its ripple effect that makes the user feel like there is a responsive click. How do I fix this? I've searched through many solutions but I couldn't find a definite one that wasn't ambiguous. </p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ClockInOutFragment">
<AnalogClock
android:id="@+id/clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/date_and_time"/>
<RelativeLayout
android:id="@+id/date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:id="@+id/time_digits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12:10"
android:textSize="45sp"/>
<TextView
android:id="@+id/am_pm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/time_digits"
android:layout_toRightOf="@+id/time_digits"
android:paddingLeft="3dp"
android:text="PM"
android:textSize="20sp"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/time_digits"
android:text="Mon, July 11"
android:textSize="22sp"/>
</RelativeLayout>
<!--Clock in and out buttons-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<Button
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:background="#4CAF50"
android:gravity="center"
android:text="Clock In"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"/>
<!--Divider between the clock in and out button-->
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#B6B6B6"/>
<Button
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:background="#FF5252"
android:gravity="center"
android:text="Clock Out"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"/>
</LinearLayout>
</RelativeLayout>
</code></pre>
| <android><button><click><effect><ripple> | 2016-07-12 11:10:15 | HQ |
38,327,391 | jQuery if Statement with Multiple conditions | I need to check 3 conditions, sheet_exists = 1, recalc = 1 and qty_total and new_qty_total are not equal.
The if statement works well if only the first 2 arguments are used:
if(sheet_exists === 1 && recalc === 'yes'){
//do something
}
But when I try to add he 3rd argument it fails, the actions in the if statement are ignored
I've tried..
if((sheet_exists === 1) && (recalc === 'yes') && (qty_total !== new_qty_total)){
//do something
}
And...
if(sheet_exists === 1 && recalc === 'yes' && (qty_total !== new_qty_total)){
//do something
}
And...
if(sheet_exists === 1 && recalc === 'yes' && qty_total !== new_qty_total){
//do something
}
Where am I going wrong? | <javascript> | 2016-07-12 11:19:05 | LQ_EDIT |
38,327,593 | Java script custom function how to call | I have written some custom function for image slider but it not get called
following is my code.
carousel: {
init: function() {
// main function to run
}
previous: function() {
// function to run when they want to go back
},
next: function() {
// function to run when they want to go forward
}
}
and i am calling it like `onclick=javascript:previous()`
but it display error in console function not defined
can somebody help me
| <javascript> | 2016-07-12 11:27:31 | LQ_EDIT |
38,328,144 | Setup ASP.NET MVC 4 or 5 project with Angular 2 | <p>I am learning angular 2 with Typescript.</p>
<p>I am using following resource.
<a href="https://angular.io/docs/ts/latest/quickstart.html" rel="noreferrer">QuickStart with Angular 2</a></p>
<p>Now from there and other examples i found that they telling to create package.json file that lists all dependencies for project.</p>
<p><strong>I think creating this package.json file and listing all dependency packages this kind of structure is followed in .NetCore Project.</strong></p>
<p><strong>In MVC 4 or 5 we have packages.config file which lists although packages that we are going to use.</strong></p>
<p>I am not saying we can not use package.json file when we have package.config file.</p>
<p><strong>But is there any simple way to integrate Angular 2 with typescript in MVC Webapplication project using NUGet Packages and get started?</strong></p>
<p><strong>If not available please let me know how can i setup Angular 2 with type script in ASP.Net MVC 4 or 5?</strong></p>
| <asp.net-mvc><asp.net-mvc-4><angular> | 2016-07-12 11:52:08 | HQ |
38,328,511 | Javascript Dont Change The Background | <p>I want to change my list background but it wont work</p>
<p>my code :</p>
<pre><code>change(num, element){
var text
if (num == 1){ ... }
else if (num == 2) { ... }
else { ... }
document.getElementById('text').innerHTML = text;
document.getElementByClass("left").style.backgroundColor = "black"; //<------
element.style.backgroundColor = "white"; //<------
}
</code></pre>
<p>and my html :</p>
<pre><code><ul>
<li><a class="left" href="#" onclick="change(1,this)>First</a></li>
<li><a class="left" href="#" onclick="change(2,this)>Second</a></li>
<li><a class="left" href="#" onclick="change(3,this)>Third</a></li>
</ul>
</code></pre>
<p>When i click on one of my list element , the text changes but background color won't ...</p>
<p>How i can fix this ?</p>
<p>Thanks,</p>
| <javascript><html><background-color> | 2016-07-12 12:08:47 | LQ_CLOSE |
38,328,677 | Failed to make the following project runnable (Object reference not set to an instance of an object.) | <p>When I create default web project in Visual Studio 2015 (Update 3) with installed .NET Core 1.0 SDK and Tooling (preview 2) and restart the Visual Studio after reverting local source control changes I am getting the following <strong>compilation error</strong>:</p>
<blockquote>
<p>Failed to make the following project runnable: MyDefaultWebProject (.NETCoreApp,Version=v1.0) reason: Object reference not set to an instance of an object.</p>
</blockquote>
<p>According to Visual Studio the error is located in <code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets</code> on line 262</p>
<p>On this line there is the following code:</p>
<pre><code><Dnx
RuntimeExe="$(SDKToolingExe)"
Condition="'$(_DesignTimeHostBuild)' != 'true'"
ProjectFolder="$(MSBuildProjectDirectory)"
Arguments="$(_BuildArguments)"
/>
</code></pre>
<p>How can I fix such a problem?</p>
| <visual-studio-2015><asp.net-core><asp.net-core-mvc><asp.net-core-1.0> | 2016-07-12 12:16:44 | HQ |
38,329,193 | Where is redux store saved? | <p>I was looking into how secure a redux application can be, I am storing certain values in redux store i.e. user token etc.. and tried to see if someone else could gain access to them via an xss attack for example, I checked sessionStorage, localStorage, cookies and it is not there, as well as it is not inside my app.js file (my bundle file), hence my question.</p>
| <javascript><redux> | 2016-07-12 12:40:21 | HQ |
38,330,176 | Difference between Xms and Xmx and XX:MaxPermSize | <p>What the difference between</p>
<pre><code>-Xms4096m
-Xmx2048M
-XX:MaxPermSize=712M
</code></pre>
<p>I am getting confused of this two <code>-Xmx2048M</code> and <code>-XX:MaxPermSize=712M</code> </p>
<p>and will happen if I use -Xmx2048<code>M</code> or -Xmx2048<code>m</code></p>
| <tomcat><garbage-collection> | 2016-07-12 13:23:00 | HQ |
38,331,073 | sheets / excel look up value by "submission number" return "name" | I have one sheet, with values such as this:
**Sheet A**
[![enter image description here][1]][1]
another sheet with values like so:
**Sheet B**
[![enter image description here][2]][2]
What I would like to do is search in the **Sheet A** by "Submission Number", i.e. the values in cell `A`, I want to search there using the values in cell `B` of **Sheet B** and return the *Name* of the company, the value in **Sheet A**, cell `B`.
I was trying something like this but it didn't work:
=LOOKUP(B2, eligible.submissions!B2:B160,1,1)
So in the example above, for row `1` in **Sheet B** I want to use the value `724`, i.e. (**Sheet B**, column `B`, row 1), to look in the Column `A` of **Sheet A**, there I would find that `724` corresponds to "*Advice Business Development*", and accordingly I want my function to return me that value, the name.
Is this possible with Google sheets or excel?
Which function to use?
I was also trying something like this:
=LOOKUP(B2, SheetA!B2:B160,SheetA!B2)
[1]: http://i.stack.imgur.com/hghYX.png
[2]: http://i.stack.imgur.com/Ghi5H.png | <google-sheets><google-sheets-formula><gs-vlookup> | 2016-07-12 14:00:13 | LQ_EDIT |
38,331,995 | Dependency Property mechanism | <p>Dependency property are static in nature, so if i create a bool type custom dependency property called as "IsGrayProperty", and implement it on two buttons.
Then if I set the value in btn1 , why it should not be reflected in btn2, as the dependencyproperty is static and their is a .net wrapper property "IsGray"</p>
| <c#><wpf><data-binding><wpf-controls> | 2016-07-12 14:40:07 | LQ_CLOSE |
38,332,094 | How can I mock Webpack's require.context in Jest? | <p>Suppose I have the following module:</p>
<pre><code>var modulesReq = require.context('.', false, /\.js$/);
modulesReq.keys().forEach(function(module) {
modulesReq(module);
});
</code></pre>
<p>Jest complains because it doesn't know about <code>require.context</code>:</p>
<pre><code> FAIL /foo/bar.spec.js (0s)
● Runtime Error
- TypeError: require.context is not a function
</code></pre>
<p>How can I mock it? I tried using <a href="http://facebook.github.io/jest/docs/api.html#setuptestframeworkscriptfile-string"><code>setupTestFrameworkScriptFile</code></a> Jest configuration but the tests can't see any changes that I've made in <code>require</code>.</p>
| <webpack><jestjs> | 2016-07-12 14:44:30 | HQ |
38,332,201 | Mssql to server synchronization | I want to synchronize my local MSSQL database to the shared hosting mssql database from Mochahost.com what i will be required to do this ? or is there any easy way to synchronize this mssql database with mysql database please give me suggestions. | <sql-server> | 2016-07-12 14:49:04 | LQ_EDIT |
38,332,492 | Add custom headers to 'request' | <p>I am proxying my api via following setup in my express config</p>
<pre><code> // Proxy api calls
app.use('/api', function (req, res) {
let url = config.API_HOST + req.url
req.pipe(request(url)).pipe(res)
})
</code></pre>
<p><code>config.API_HOST</code> in here resolves to my api url and <code>req.url</code> is some endpoint i.e. <code>/users</code> I tried following documentation on npm for <a href="https://www.npmjs.com/package/request#custom-http-headers" rel="noreferrer">request</a> and set up my headers like so</p>
<pre><code> // Proxy api calls
app.use('/api', function (req, res) {
let options = {
url: config.API_HOST + req.url,
options: { 'mycustomheader': 'test' }
}
req.pipe(request(options)).pipe(res)
})
</code></pre>
<p>But I am not able to see my custom headers in chrome dev tools under Network.</p>
| <node.js><api><express><header><request> | 2016-07-12 14:59:27 | HQ |
38,333,190 | Create XML with XmlDocument C# | <p>I need to create an XML with this structure :</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/">
<soapenv:Header/>
<soapenv:Body>
<res:buscaEventos>
<usuario>ECT</usuario>
<senha>SRO</senha>
<tipo>L</tipo>
<resultado>T</resultado>
<lingua>101</lingua>
<objetos>JS331400752BR</objetos>
</res:buscaEventos>
</soapenv:Body>
</soapenv:Envelope>
</code></pre>
<p>However it is wrong out this way:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/">
<soapenv:Header />
<soapenv:Body>
<res:buscaEventos xmlns:res="http://schemas.xmlsoap.org/soap/envelope/">
<usuario>ETC</usuario>
<senha>SRO</senha>
<tipo>L</tipo>
<resultado>T</resultado>
<lingua>101</lingua>
<objetos>JS331400752BR</objetos>
</res:buscaEventos>
</soapenv:Body>
</soapenv:Envelope>
</code></pre>
<p><strong>The difference is in buscaEventos</strong></p>
<p>I created in the following way
<code>XmlNode eventosNode = xmlDoc.CreateElement
( "res " , " buscaEventos " " http://schemas.xmlsoap.org/soap/envelope/ " ) ;</code> How do I remove the xmlns : res only that node ?</p>
| <c#><xml><xmldocument> | 2016-07-12 15:30:26 | LQ_CLOSE |
38,334,010 | Angular 2 change image src attribute | <p>Assuming I have the following code:</p>
<pre><code><img [src]="JwtService.characterImage(enemy)"
class="{{enemy.status}}"
(click)="sidenav.toggle();" style="cursor:pointer">
</code></pre>
<p>How I can change this img <code>src</code> asttribute from my components <code>.ts</code> file?</p>
| <angular> | 2016-07-12 16:07:15 | HQ |
38,334,539 | Force not working in non-interactive mode | <pre><code>Deleting folder 'C:\agent\_work\2\a\Foo\_PublishedWebsites\Foo\sourcejs'
Remove-Item : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
At C:\agent\_work\2\s\Build\Deployment\PrepareWebsites.ps1:29 char:2
+ Remove-Item -Path $source -Force -Confirm:$false | Where { $_.PSIsContainer }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Remove-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RemoveItemCommand
Process completed with exit code 1 and had 1 error(s) written to the error stream.
</code></pre>
<p>I have tried adding -Force and -Confirm:$false but I still get this error. Using TFS 2015 builds. Anyone got any ideas?</p>
| <powershell> | 2016-07-12 16:34:19 | HQ |
38,334,652 | Sum all the digits of a number Javascript | <p>I am newbie.</p>
<p>I want to make small app which will calculate the sum of all the digits of a number.</p>
<p>For example, if I have the number 2568, the app will calculate 2+5+6+8 which is equal with 21. Finally, it will calculate the sum of 21's digits and the final result will be 3 .</p>
<p>Please help me</p>
| <javascript><numbers><sum><digits> | 2016-07-12 16:40:37 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.