Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
37,872,812 | How to print all combinations? | <p>I've just started studying C++. I have to create an array with 1000 names. My idea was to first create an array with 10 names and then to permutate the names in order to produce 1000. However, I don't know how to create the first array (i suppose it is an array of strings, but I do not know if my syntax is correct), and I don't know how to further permutate the names to form a bigger array. Could anyone help me?</p>
| <c++> | 2016-06-17 03:47:14 | LQ_CLOSE |
37,873,254 | How do I read Class paths in Java's API documentation? | I was attempting to use a method I found in Java's documentation and I ran into some trouble. I have some confusion on what class path to use from the documentation.
If I want to use the method getLength(Object name) from the Array class the compiler accepts java.lang.reflect.Array.getLength(nameOfArray) but not java.lang.Object.getLength(nameOfArray). Though the picture of the API documentation linked below seems to imply to me that both class paths are linked to the Array classes method.
Also I feel like I might be using the wrong jargon when wording my question, how might you have reworded my question. I ask because It seems like to me I could find this information online but I did a search on google for "How to read Java Documentation" and coundn't find this piece of information.
My guess was maybe one of these class paths are extended and one is an implementation, but I'm also confused on which is which or why that would make a difference.
[Java API documentation example][1]
[1]: http://i.stack.imgur.com/nqMJs.png
Thank you
| <java><class><methods><javadoc> | 2016-06-17 04:40:37 | LQ_EDIT |
37,873,954 | What are python's equivalents of std::lower_bound and std::upper_bound C++ algorithms? | <p>Does python provide functions for performing binary search on sorted lists, analogous to the <code>std::lower_bound</code> and <code>std::upper_bound</code> algorithms of the C++ Standard Library?</p>
| <python><binary-search> | 2016-06-17 05:43:03 | HQ |
37,874,432 | If ng-content has content or empty Angular2 | <p>I am trying to understand how to create an if to show when a <code>ng-content</code> is empty.</p>
<pre><code><div #contentWrapper [hidden]="isOpen">
<ng-content ></ng-content>
</div>
<span *ngIf="contentWrapper.childNodes.length == 0">
<p>Display this if ng-content is empty!</p>
</span>
</code></pre>
<p>I've tried to use that one to show a display data when the content is empty but even if the information is empty doesn't show the <code><span></code> tag</p>
<p>Thanks, always grateful for your help. </p>
| <angular><angular2-template> | 2016-06-17 06:17:47 | HQ |
37,874,920 | Can multiple android application access same firebase database? | <p>Is it possible for multiple android applications to access a single firebase backend. If no what is the alternative in such situation? </p>
| <android><firebase><firebase-realtime-database> | 2016-06-17 06:49:28 | HQ |
37,874,960 | How to convert Decimal() to a number in Python? | <p>I have a JSON output that is <code>Decimal('142.68500203')</code>.</p>
<p>I can use str() to get a string which is <code>"142.68500203"</code>. But I want to get a number output which is <code>142.68500203</code>.</p>
<p>How to make the conversion in Python?</p>
| <python> | 2016-06-17 06:52:01 | LQ_CLOSE |
37,875,190 | Need a function to reverse an array in C# | <p>I need to create a function that receives an array items and reverses the order of items in the array and returns it. </p>
<p>Basically if I have an array ['cat', 'dog', 'bird', 'worm'] the function should return an array of ['worm','bird','dog','cat']. </p>
<p>So far I get lost in the function language... I have this.</p>
<pre><code> //Split a string into an array of substring
string avengersNames = "Thor;Iron Man;Spider-Man;Hulk;Hawk Eye";
//Creat an array to hold substring
string[] heroArray = avengersNames.Split(';');
foreach (string hero in heroArray)
{
Console.WriteLine(hero);
}
//Parameter is Array of items
//At a loss when trying to incorporate an array into this function.
public static string[] heroList = new string[5];
{
}
</code></pre>
| <c#><arrays><function><return> | 2016-06-17 07:06:28 | LQ_CLOSE |
37,875,614 | How to use syntaxnet output | <p>I started playing with Syntaxnet two days ago and I'm wondering <strong>how to use/export</strong> the output (ascii tree or conll ) in a format that is easy to parse (ie : Json, XML, python graph).</p>
<p>Thanks for your help ! </p>
| <nlp><syntaxnet> | 2016-06-17 07:29:16 | HQ |
37,875,945 | Is there still a way to fetch instagram feed without using access token now (06/2016)? | <p>I have an issue that my Instagram API access token keeps expiring frequently and I red the document and understood that although the token wouldn't expire generally, Instagram may decide to expire a token any time for any security reason or whatever reasons. </p>
<p>I know that when it expires, I need to set up an authentication process and request for a new token and all those of things. But the problem is that my app is just retrieving my own feeds to show on my own website, once the token expires it doesn't make sense to set up such a process, the only thing I can do is to manually retrieve and update the token in my code. </p>
<p>So I was wondering if there is still a way to get feeds without using access token as I am just pulling in my own feeds. Or is there any other way I can solve this issue?</p>
<p>Thanks for your help.</p>
| <api><instagram><access-token><instagram-api> | 2016-06-17 07:47:04 | HQ |
37,876,051 | Opening zip files in browser with FileReader and JSZip.js | <p>I'm trying to open up zip files inside the browser with FileReader and JSZip.js, then handle the files contained inside. I can't figure out how to correctly pass the FileReader object to JSZip.</p>
<p>Here's a stripped version of the page I use to load the javascript:</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script type="text/javascript" src="zipscan.js"></script>
<script type="text/javascript" src="jszip.js"></script>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
</head>
<body>
<div id="openFile"><input type="file" id="inputFile" /></div>
</body>
</html>
</code></pre>
<p>And the javascript in zipscan.js after removing all unnecessary code:</p>
<pre><code>function checkFiles()
{
//Check support for the File API support
if ( window.File && window.FileReader && window.FileList && window.Blob )
{
var fileSelected = document.getElementById( "inputFile" );
fileSelected.addEventListener( "change", handleFile, false );
}
else
{
alert( "Files are not supported" );
}
}
function handleFile( evt )
{
//Set wanted file object
var fileToRead = evt.target.files[0];
//Create fileReader object
var fileReader = new FileReader();
fileReader.onload = function ( e )
{
//Create JSZip instance
var archive = new JSZip().loadAsync( e.target );
//Testing that it is loaded correctly
alert( e.target );
alert( archive.file( "hello.txt" ).name );
}
fileReader.readAsArrayBuffer( fileToRead );
}
window.addEventListener( "load", checkFiles, false );
</code></pre>
<p>The first alert displays [object FileReader], and the second results in a TypeError, archive.file(...) is being null.</p>
<p>I have used FileReader's readAsText method with the same code to open text files successfully, so if there is an error it's either in using readAsArrayBuffer (JSZip documentation suggested it) or in the way I'm using it. Almost all the resources I've found about JSZip use the old method with constructor parameters instead of loadAsync so it could be I'm not using it right. </p>
| <javascript><filereader><jszip> | 2016-06-17 07:52:27 | HQ |
37,876,275 | How do I store a Swift Struct in Core Data on iOS? | <p>At the moment I'm storing one of my classes as NSData in a plist and obviously that isn't a good way to do it.</p>
<p>So I'm trying to set up Core Data, but my class has Structs. This is what I have:</p>
<pre><code>import Foundation
import CoreData
class Favourite: NSManagedObject {
@NSManaged var origin: Stop
struct Stop {
var name: String;
var id: String;
}
}
</code></pre>
<p>But this is no good because it says</p>
<p><em>Property cannot be marked as @NSManaged because its type cannot be represented in Objective-C</em></p>
<p>Furthermore, if this error did not occur, I don't know what I'd set it up as in my xcdatamodeld file.</p>
<p>I guess I could store the values in the struct and assign on initialisation of the object? Is this the most optimal/clean way?</p>
| <ios><swift><core-data><struct> | 2016-06-17 08:05:49 | HQ |
37,876,288 | Is there a one-liner to unpack tuple/pair into references? | <p>I frequently write snippets like</p>
<pre><code>int x,y,z; tie(x,y,z) = g[19];
</code></pre>
<p>where, for instance, <code>g</code> was declared earlier</p>
<pre><code>vector<tuple<int,int,int>> g(100);
</code></pre>
<p>Problem is, maybe later I actually want <code>x</code> and <code>y</code> to point to the internals of <code>g</code> by reference, and the refactoring is ugly, e.g.</p>
<pre><code>int &x = get<0>(g[19]);
int &y = get<1>(g[19]);
int &z = get<2>(g[19]);
</code></pre>
<p>or sometimes even worse, for instance if the access is a more complex expression</p>
<pre><code>tuple<int,int,int> &p = g[19]; // if the rhs was actually more complicated
int &x = get<0>(p);
int &y = get<1>(p);
int &z = get<2>(p);
</code></pre>
<p>Is there a better refactoring, more in the style of the assignment to tie(..)? </p>
<p>The difficulty as I understand it is that references insist on being initialized <a href="http://en.cppreference.com/w/cpp/language/reference_initialization">exactly at their declaration</a>. So, in possibly other words, is there a way to use <code>tie</code>-like syntax for multiple variable <em>initialization</em> in c++ (this would also make the earlier non reference usage cleaner)?</p>
| <c++> | 2016-06-17 08:06:23 | HQ |
37,876,533 | *ngFor running an infinite loop in angular2 | <p>I am trying to render object properties using keys in angular2 using below code:</p>
<pre><code><ul>
<li *ngFor="let element of componentModel | keys;let i=index">
{{element.key}}--{{element.value}} // 1---Bhushan...loaded only once
<span *ngIf="element">{{ loadProperty(i,element) }}</span>
</li>
</ul>
</code></pre>
<p>But I am facing a problem here. The output in the browser in loaded only once.
but the method call i.e. <code>loadProperty(i,element)</code> is running in an infinite loop.</p>
<pre><code>loadProperty(i:number,element:any){
console.log(element.key+'========'+element.value);
console.log(element);
}
</code></pre>
<p>means on browser output </p>
<blockquote>
<p>(1---Bhushan)</p>
</blockquote>
<p>is displayed only once but on the console its running infinitely like below:</p>
<p><a href="https://i.stack.imgur.com/YN902.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YN902.png" alt="Snapshot of the console"></a></p>
<p>I want to call this method only once per iteration.</p>
<p>any inputs?</p>
| <typescript><angular><ngfor> | 2016-06-17 08:20:25 | HQ |
37,876,746 | How can I compile a library with Carthage using the latest beta of Xcode? | <p>I am testing out Swift 3 with Xcode 8 Beta (8S128d), which leads me to a situation where my Carthage-built libraries are not compatible with the source base.</p>
<p><code>Module file was created by an older version of the compiler; rebuild 'SwiftValidator' and try again</code>.</p>
<p>How can I configure Carthage so that <code>carthage update</code> uses the Beta compiler rathe rthan the standard one?</p>
| <xcode><carthage> | 2016-06-17 08:32:16 | HQ |
37,876,842 | Assembly - how to use less variables | I am making the game "Connect Four". I have a square board which is 4x4. For each tile on the board I have to draw a disc (squre shaped) which has an x value and a y value. The problem is that I have to make 32 variables or a lot of procedures which change the two variables all the time but these options seem very unefficient and the code would be very long. If you have any suggestions of how to it more efficient, please tell.
Thanks for the help. | <assembly><x86><dos><tasm><x86-16> | 2016-06-17 08:37:08 | LQ_EDIT |
37,876,872 | how to show select option value in mysql | hello I create database 2 table 1 vn_rent 2 amount_cus
from insert to vn_rent
i user code this select option value
<?php
session_start();
//PUT THIS HEADER ON TOP OF EACH UNIQUE PAGE
if(!isset($_SESSION['id_user'])){
header("location:index.php");
header("Content-type: text/html; charset=utf-8");
}
include_once('config/dbconnect.php');
$id_user = $_SESSION['id_user'];
$rn_first_name = $_POST['rn_first_name'];
$rn_last_name = $_POST['rn_last_name'];
$rn_gostart = $_POST['rn_gostart'];
$rn_endstart = $_POST['rn_endstart'];
$time_gostart = $_POST['time_gostart'];
$time_endstart = $_POST['time_endstart'];
$rn_tel = $_POST['rn_tel'];
$rn_amount = $_POST['rn_amount'];
$rn_svan = $_POST['rn_svan'];
$rn_destination = $_POST['rn_destination'];
$id_invoice = $_POST['id_invoice'];
$Status = $_POST['Status'];
$vn_dtial = $_POST['vn_dtial'];
$rn_place = $_POST['rn_place'];
$id_vn_order = $_POST['id_vn_order'];
$travel_id = $_POST['travel_id'];
$province_id = $_POST['province_id'];
$am_id = $_POST['am_id'];
$date = "$rn_gostart"; //กำหนดค้นวันที่
$result = mysqli_query($con,"select * from vn_rent where rn_gostart = '$date'");
$ckd = mysqli_num_rows($result);
if($ckd >= 3){
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> วันที่จองเต็มแล้ว
</div>";
}else{
$sql = "INSERT INTO vn_rent (id_user,rn_first_name,rn_last_name,rn_gostart,rn_endstart,time_gostart,time_endstart,rn_tel,rn_amount,rn_svan,Status,vn_dtial,rn_place,rn_destination,travel_id,province_id,am_id)
VALUES ('$id_user', '$rn_first_name',' $rn_last_name ','$rn_gostart','$rn_endstart','$time_gostart','$time_endstart','$rn_tel','$rn_amount','$rn_svan','$Status','$vn_dtial','$rn_place','$rn_destination','$travel_id','$province_id','$am_id')";
//คำสั่ง insert 2 ตาราง
if ($con->query($sql) === TRUE) {
$id_van = $con->insert_id;
$con->query("INSERT INTO invoice
(id_user, id_vn_order,id_van)
VALUE($id_user, $id_vn_order, $id_van)");
$id_invoice = $con->insert_id;
$con->query("UPDATE vn_rent
SET id_invoice = '$id_invoice'
WHERE id_van = $id_van");
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> s] จองรถตู้สำเร็จ โปรดรอการตอบรับทาง Email !
</div>";
}
else {
echo "Error: " . $sql . "<br>" . $con->error;
}
}
$con->close();
/*
$sql = "INSERT INTO vn_rent (id_user,rn_first_name,rn_last_name,rn_dstart,rn_estart,rn_tel,rn_amount,rn_svan,Status,vn_dtial,rn_place,rn_destination)
VALUES ('$id_user', '$rn_first_name',' $rn_last_name ','$rn_dstart','$rn_estart','$rn_tel','$rn_amount','$rn_svan','$Status','$vn_dtial','$rn_place','$rn_destination')";
$sql1="INSERT INTO invoice (id_invoice,id_van,id_user,id_vn_order)
VALUES ('$id_invoice', '$id_van',' $id_user ','$id_vn_order')";
if($con->multi_query($sql))
{
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> s] จองรถตู้สำเร็จ โปรดรอการตอบรับทาง Email !
</div>";
}
else
{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> error while registering !
</div>";
}
$con->close();*/
?>
Simple Select table amount_cus insert to vn_rent
<?php
include "config.php";
$query = "SELECT * FROM amount_cus";
$result = mysqli_query($mysqli, $query); ?>
<select class="select-search" name="am_id"> <?php while ($line = mysqli_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['am_id'];?>"> <?php echo $line['am_text'];?> </option>
<?php } ?>
</select>
[IMaGE from vn_rent][1]
[amount_cus][2]
OK I'm sorry i'm not good english
What I will do is. I will make changes, but the problem is, I do it to extract data from tables and lists amount_cus selected first. And along with other data
[1]: http://i.stack.imgur.com/Jfemx.png
[2]: http://i.stack.imgur.com/HJa3r.png | <php><mysql> | 2016-06-17 08:39:21 | LQ_EDIT |
37,877,860 | lodash pick object fields from array | <p>I have array of objects:</p>
<pre><code>var results= [
{
"_type": "MyType",
"_id": "57623535a44b8f1417740a13",
"_source": {
"info": {
"year": 2010,
"number": "string",
},
"type": "stolen",
"date": "2016-06-16T00:00:00",
"createdBy": "57469f3c71c8bf2479d225a6"
}
}
];
</code></pre>
<p>I need to select specific fields from array. In result, I want to get the following:</p>
<pre><code>[
{
"_id": "57623535a44b8f1417740a13",
"info": {
"year": 2010,
"number": "string"
},
"type": "stolen",
"date": "2016-06-16T00:00:00",
"createdBy": "57469f3c71c8bf2479d225a6"
}
]
</code></pre>
<p>As you can see, I want to select <code>_id</code> field and content of <code>_source</code> object. How can I do this with lodash?</p>
<p>I've found <code>.map</code> function, but it doesn't take array of keys:
<code>
var res = _.map(results, "_source");
</code></p>
| <javascript><lodash> | 2016-06-17 09:24:43 | HQ |
37,878,567 | how to resolve InteractiveAuthentication cannot be resolved to a type? | How to make sub_folder in alfresco using Content Management Interoperability Services api,I am able to create folder in alfresco but I want to make sub folder inside this folder but,not geeting any idea how to do that,so please help me..thankyou in advance
| <alfresco> | 2016-06-17 09:56:52 | LQ_EDIT |
37,878,831 | Xamarin.Forms Page BackgroundImage property | <p>How are you supposed to set the background image for a Page, as the BackgroundImage is a string? I would greatly appreciate any suggestions.</p>
<p>So far I've tried:</p>
<pre><code>MainPage = new ContentPage
{
BackgroundImage = "Images/image.png"
}
</code></pre>
<p>which does not work. The image file is located in the PCL project.</p>
| <xamarin><xamarin.forms> | 2016-06-17 10:09:45 | HQ |
37,878,946 | Indexing one array by another in numpy | <p>Suppose I have a matrix <strong>A</strong> with some arbitrary values:</p>
<pre><code>array([[ 2, 4, 5, 3],
[ 1, 6, 8, 9],
[ 8, 7, 0, 2]])
</code></pre>
<p>And a matrix <strong>B</strong> which contains indices of elements in A:</p>
<pre><code>array([[0, 0, 1, 2],
[0, 3, 2, 1],
[3, 2, 1, 0]])
</code></pre>
<p>How do I select values from <strong>A</strong> pointed by <strong>B</strong>, i.e.:</p>
<pre><code>A[B] = [[2, 2, 4, 5],
[1, 9, 8, 6],
[2, 0, 7, 8]]
</code></pre>
| <python><numpy> | 2016-06-17 10:15:22 | HQ |
37,878,951 | How to clear Route Caching on server: Laravel 5.2.37 | <p>This is regarding route cache on localhost</p>
<h1>About Localhost</h1>
<p>I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below.</p>
<p>if I comment any one route in my route.php file and then run below command</p>
<pre><code>php artisan route:cache
</code></pre>
<p>This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it will show 404 because I need to remove cache by using below command</p>
<pre><code>php artisan route:clear
</code></pre>
<p>So far everything is understood in localhost. No problem in that.</p>
<h1>After deploying on shared hosting server on godaddy</h1>
<p>Question : How can I remove the route cache on server?</p>
| <laravel><laravel-5><laravel-5.1><laravel-5.2> | 2016-06-17 10:15:46 | HQ |
37,879,448 | MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded" | <p>My local environment is:</p>
<ul>
<li>fresh Ubuntu 16.04</li>
<li>with PHP 7</li>
<li><p>with installed MySQL 5.7</p>
<pre><code>sudo apt-get install mysql-common mysql-server
</code></pre></li>
</ul>
<hr>
<p>When I tried to login to MySQL (via CLI):</p>
<pre><code>mysql -u root -p
</code></pre>
<p>I came across an cyclic issue with 3 steps.</p>
<h2>1) First was some socket issue</h2>
<pre><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
</code></pre>
<p><strong>Solution: restarting PC.</strong></p>
<p>Which led to another error:</p>
<h2>2) With access denied</h2>
<pre><code>ERROR 1698 (28000): Access denied for user 'root'@'localhost'.
</code></pre>
<p>Possible issue? Wrong password for "root" user!</p>
<p><strong>Solution: <a href="https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/">reset root password with this tutorial</a>.</strong></p>
<p>With correct password and working socket, there comes last error.</p>
<h2>3) Incorrect auth plugin</h2>
<pre><code>mysql "ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded"
</code></pre>
<p>Here I stopped or somehow got to 1) again.</p>
| <mysql><linux><ubuntu><auth-socket> | 2016-06-17 10:36:19 | HQ |
37,879,542 | change the URL path one folder before in javascript string | my url look like below. i need to move one folder before for reference. i can you regex. I have also tried several things. bot nothing works for me.
var str = "../../myfolder";
var str0 = "../myfolder";
var str1 = "../../../myfolder";
i need to change this as
str = "../myfolder";
str0 = "myfolder";
str1 = "../../myfolder";
please help me for this. | <javascript><regex><string> | 2016-06-17 10:41:54 | LQ_EDIT |
37,880,177 | how to get value of cell in table and display it in textbox | <p>I have a table like this:</p>
<pre><code><table id="mytable">
<tr>
<th>Customer Id</th>
<th>Name</th>
</tr>
<tr>
<td>123</td>
<td>A</td>
</tr>
<tr>
<td>456</td>
<td>B</td>
</tr>
<tr>
<td>789</td>
<td>C</td>
</tr>
</table>
<form>
<input type="text" name="txtDsCode" id="txtDsCode"/>
</form>
</code></pre>
<p>When I click on the <code>textbox</code> and then click on the <code>cell</code> in the table , the value of the cell will display in the <code>textbox</code>.
How should i do it with javascript?
Thanks all!</p>
| <javascript><html> | 2016-06-17 11:14:43 | LQ_CLOSE |
37,880,491 | .ansible/tmp/ansible-tmp-* Permission denied | <p>Remote host throws error while running Ansible playbook despite a user being sudo user.</p>
<pre><code>"/usr/bin/python: can't open file '/home/ludd/.ansible/tmp/ansible-tmp-1466162346.37-16304304631529/zypper'
</code></pre>
| <ansible> | 2016-06-17 11:31:27 | HQ |
37,880,961 | AWS dynamodb over AWS S3 | <p>I am new to AWS and need to decide what to choose between AWS dynamo db or AWS S3.</p>
<p>I have a use case in which I need to fetch multiple items from the data source and update the items and put back to the data source. I have searched and found that we can't perform multiple get in S3. </p>
<p>Any Suggestions it will be helpful !!</p>
| <database><amazon-web-services><amazon-s3><amazon-dynamodb> | 2016-06-17 11:55:50 | LQ_CLOSE |
37,881,893 | Get number of comments within a forum | <p>I have 3 tables:</p>
<p>forums, threads, comments</p>
<p>I would like to write a query to get the number of comments within a forum.</p>
<p>Every row in threads has a column "fid" which shows which forum the thread was posted in.</p>
<p>Every row in comments has a column "tid" which shows which thread the comment was posted on.</p>
<p>Do you have any idea?</p>
<p>Thanks.</p>
| <mysql> | 2016-06-17 12:43:57 | LQ_CLOSE |
37,882,052 | Conversion failed when converting date and/or time from character string select app.[Pap_id], reg.[p_id],[p_name],[p_age],[p_gender],[p_mob | Conversion failed when converting date and/or time from character string.
"select app.[Pap_id], reg.[p_id],[p_name],[p_age],[p_gender],[p_mob],[p_specificId],app.[ap_date],app.[reqst_txt] from [dbo].[tblpatientReg] reg
inner join [dbo].[tblAppoinment] app on app.[P_id]=reg.[p_id] where app.[p_status] =1 order by convert(date,app.[ap_date] ,105) asc"
| <sql><sql-server><sql-server-2008> | 2016-06-17 12:51:45 | LQ_EDIT |
37,882,417 | Linux where does zip place the newly created zip file? | <p>Looking to zip up a folder on my linux box ie <code>zip -r9 test /var/www/html/</code> where does that resulting test.zip file end up? in my pwd? I still want to leave the contents of /var/www/html intact.</p>
| <linux><zip> | 2016-06-17 13:09:29 | LQ_CLOSE |
37,883,418 | Does OkHttpClient have a max retry count | <p>I am setting the retry on connection failure option for OkHttpClient. </p>
<pre><code>client = new OkHttpClient();
client.setRetryOnConnectionFailure(true);
</code></pre>
<p>I will like to know how many times it will keep trying. Looking at the <a href="https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/http/HttpEngine.java#L362" rel="noreferrer">source code</a> I did not see any maximum limit. How do I configure the client to stop trying after a few attempts?</p>
| <android><okhttp><okhttp3> | 2016-06-17 13:53:29 | HQ |
37,883,682 | Variable assignment in C Vs scanf | I am new to C got a small problem in understanding below scanf line
printf("Enter a message to add to message queue : ");
`scanf("%[^\n]",sbuf.mtext);`
how do I write this statement if I am getting the value from command line?
I think I would have to declare the variable as string?
Thanks in advance. | <c><scanf> | 2016-06-17 14:06:04 | LQ_EDIT |
37,883,901 | Unable to align background color in html and css | I am a beginner to website design and development and also learning it. As a beginner i creating a site which is old bbc news website from the following archive link http://web.archive.org/web/20140402131524/http://www.bbc.co.uk/news/uk
so i am stcked at watch/listen part the backgroun color orange to link which is below the video is aligning to the right side of it according to my code
following is my code...
***HTML***
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<div class="watch">
<img src="http://s9.tinypic.com/2hd45fp_th.jpg" id="WatchListenlogo"/>
<span class="watchhead">Watch/Listen</span>
<img src="http://s9.tinypic.com/35c03yr_th.jpg" id="rightarrow"/>
<div id="videoa">
<img src="http://s9.tinypic.com/j64ufl_th.jpg"/>
<a href="">Titanic letter could fetch £ 100,000</a>
</div>
</div>
</body>
</html>
***CSS***
<style type="text/css">
body{
margin:0;
line-height:15px;
}
.watch{
position:relative;
top:50px;
right:50px;
color:#505050;
line-height:24px;
background-color:#eeeeee;
float:right;
width:336px;
}
#videoa{
float:left;
background-color:#d1700e;
position:relative;
top:-84px;
left:25px;
}
#videoa a{
float:left;
color:white;
position:relative;
top:2px;
left:5px;
}
.watchhead{
font-size:24px;
font-weight:bolder;
position:relative;
top:10px;
left:8px;
}
#WatchListenlogo{
float:right;
position:relative;
top:22px;
right:10px;
}
#rightarrow{
float:left;
border-right:solid white 1px;
position:relative;
top:40px;
}
a{
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
</style>
| <css><html><web> | 2016-06-17 14:17:19 | LQ_EDIT |
37,884,521 | Can't read json_encode | <p>I'm having an issue. I have a json_encode array in php. With ajax, I get back in my javascript script. </p>
<p><strong>php</strong></p>
<pre><code><?php
$code = 'xyz';
$email = 'xyz@gmail.com';
$back = array();
array_push($back, array("code" => $code,"email" => $email));
echo json_encode($back);
?>
</code></pre>
<p><strong>ajax callback function</strong></p>
<pre><code>function(data){
alert(data);
alert(data[0].code);
}
</code></pre>
<p>When I try to alert data, I get <code>[{"code":"xyz","email":"xyz@gmail.com"}]</code></p>
<p>Now when I try to alert the code (or the email) it says <code>undefined</code>. </p>
<p>Can you help me alert data[0].code properly ? </p>
| <javascript><php><jquery><ajax> | 2016-06-17 14:47:24 | LQ_CLOSE |
37,884,558 | Keep an integer within bounds? | <p>To keep an integer within certain bounds, currently I'm doing:</p>
<pre><code>frame.X = frame.X <= 0 ? 0 : frame.X;
frame.X = frame.X + frame.Width > Image.Width ? Image.Width - frame.Width : frame.X;
frame.Y = frame.Y <= 0 ? 0 : frame.Y;
frame.Y = frame.Y + frame.Height > Image.Height ? Image.Height - frame.Height : frame.Y;
</code></pre>
<p>Is there a cleaner way for bound checking?</p>
| <c#> | 2016-06-17 14:49:14 | LQ_CLOSE |
37,884,741 | Any way to get JavaScript numbers without Euler's number | <p>I try to get</p>
<p><code>Math.pow(2,1000);</code></p>
<p>The result is " 1.2676506002282294e+30 "</p>
<p>I need the number without Euler's number "e+30"</p>
| <javascript><math><eulers-number> | 2016-06-17 14:59:02 | LQ_CLOSE |
37,885,213 | Azure Service Fabric activation error | <p>The deployment of one of my apps to a <code>Service Fabric Cluster</code> failed and triggered an Unhealthy Evaluation with an error event saying: <code>There was an error during CodePackage activation.The service host terminated with exit code:3762504530</code></p>
<p>However, on the node where the app is deployed, Health State indicates: <code>The application was activated successfully.</code></p>
<p>Is there any way to get a more detailed report on the error event?</p>
| <azure><azure-service-fabric><azure-deployment> | 2016-06-17 15:24:54 | HQ |
37,885,518 | SoftLayer API: Need php sample code to verify order for power 8 servers (package id 242) | <p>Can somebody please provide sample php code to verify order for power 8 servers (package Id 242). </p>
<p>The power8 servers seems using presetIds. Will the parameters for SoftLayer_Product_Order.verifyOder(...) be similar to the ones for hourly baremetal server ?</p>
| <php><ibm-cloud-infrastructure> | 2016-06-17 15:41:40 | LQ_CLOSE |
37,886,276 | provideRouter and RouterConfig not found in new @angular/router 3.0.0-alpha.3^ | <p>I am migrating an angular2 app to RC2 and trying to use the router's version 3 alpha.</p>
<p>I have followed the set up of the <a href="http://plnkr.co/edit/ER0tf8fpGHZiuVWB7Q07?p=preview">plunker given</a> by the <a href="https://angular.io/docs/ts/latest/guide/router.html">angular docs</a> for routing
But i keep getting the following errors:</p>
<blockquote>
<p>/@angular/router/index"' has no exported member 'provideRouter'</p>
<p>/@angular/router/index"' has no exported member 'RouterConfig'</p>
</blockquote>
<p>when trying to use the following imports in my app.router.ts file:</p>
<pre><code>import { provideRouter, RouterConfig } from '@angular/router';
</code></pre>
<p>I am using typescript in visual studio with commonjs module format.</p>
<p>Here are the dependecies from my packages.json</p>
<pre><code>"@angular/common": "2.0.0-rc.2",
"@angular/compiler": "2.0.0-rc.2",
"@angular/core": "2.0.0-rc.2",
"@angular/http": "2.0.0-rc.2",
"@angular/platform-browser": "2.0.0-rc.2",
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
"@angular/router": "3.0.0-alpha.3",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.2",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.12"
</code></pre>
<p>Even if I set the angular/route to the npm cdn in my system.config.js like so:</p>
<blockquote>
<p>'@angular/router': '<a href="https://npmcdn.com/@angular/router@3.0.0-alpha.3">https://npmcdn.com/@angular/router@3.0.0-alpha.3</a>'</p>
</blockquote>
<p>I still get the error.</p>
<p>I even tried using the alpha.4, alpha.5 and latest alpha.6 version.</p>
<p>I tried deleting the nodule module folder and forcing the npm install to get new files.</p>
<p>QUESTION:</p>
<p>Can someone help me figure out why the exported memebers <strong>provideRouter</strong>, <strong>RouterConfig</strong> can not be found?</p>
<p>Thanks</p>
| <angularjs><typescript><angular><npm><angular2-routing> | 2016-06-17 16:27:25 | HQ |
37,886,473 | Setting up a windows web hosting in virtual private server | <p>I have 2 virtual private servers which i got from cloudatcost.com with 2 static IPs for one server and 1 static IP for another.
I have installed windows server 2008 R2 on both of them. All I wanted to do is to make one as a webserver and the other as a email and database server and I waanted to use some free control panel to create websites and maintain them. But before doing that I need to setup DNS server and static IP setup which I am not aware of. Someone please help me directing in a correct path of how to setup a server with a domain name and allow it to point as a server for different domains I host in future. I am pretty new to this networking stuff. I am .Net developer please help.
Thanks in advance.</p>
| <dns><windows-server-2008><web-hosting><vps> | 2016-06-17 16:41:03 | LQ_CLOSE |
37,886,600 | iOS 10 doesn't print NSLogs | <p>Nothing prints from <code>NSLog</code> on Xcode 8.0 beta (8S128d). <code>printf</code> is unchanged</p>
<p>Here's my code:</p>
<pre><code>NSLog(@"hello from NSLog");
printf("hello from printf");
</code></pre>
<p>Here's the output on iOS 9 Simulator:</p>
<pre><code>2016-06-17 09:49:10.887 calmapp-dev[28517:567025] hello from NSLog
hello from printf
</code></pre>
<p>Here's the output on iOS 10 Simulator:</p>
<pre><code>hello from printf
</code></pre>
| <ios><xcode><nslog><xcode8><ios10> | 2016-06-17 16:49:57 | HQ |
37,887,398 | What are the things hiding in abstraction? | <p>Most of the people says that abstraction is hiding something and showing only functionality to the user. Can anyone explain me what are all the things you are hiding and what are all the things you are showing?? please don't explain with the examples of animal, engine, vehicle.</p>
| <java> | 2016-06-17 17:45:27 | LQ_CLOSE |
37,887,789 | Android development software for ubuntu linux | <p>I currently moved from windows to ubuntu-linux. So I want to know what would be the best software for making android applications aside from android-studio for ubuntu-linux OS</p>
| <android> | 2016-06-17 18:08:48 | LQ_CLOSE |
37,887,847 | Rating (flex svg) float issues on chrome/ff | There is a float issue when i use a flex svg image on chrome and firefox, only it showed correct on IE.
The rating is showed half on the other column.
Framework: Bootstrap 2
Bootplay: <http://www.bootply.com/RYY7WvZsYj>
| <css><svg><flexbox> | 2016-06-17 18:12:23 | LQ_EDIT |
37,888,376 | How case works in if-case | <p>An old C programmer could use some help with Swift.</p>
<p>I don't understanding something about the if-case syntax. E.g.:</p>
<pre><code>if case 20...30 = age {
print ("in range.")
}
</code></pre>
<p>The <code>case 20...30 = age</code> appears to be the conditional test for the <code>if</code> statement. So I was initially confused to see the assignment operator ('=') used instead of a comparison operator ('==').</p>
<p>Ok, I thought to myself, that probably means the <code>case</code> statement is actually a function call that returns a boolean value. The returned value will then satisfy the comparison test in the <code>if</code> statement.</p>
<p>As an experiment, I tried treating the the <code>case</code> statement like a regular conditional test and placed parentheses around it. Swift will happily accept <code>if (x == 5)</code> or <code>if (true)</code>. But <code>if (case 20...30 = age)</code> generates an error. So the <code>case</code> statement doesn't seem to behave like function.</p>
<p>I'm just curious to understand what's happening here. Any insight would be greatly appreciated.</p>
| <swift> | 2016-06-17 18:45:36 | HQ |
37,888,536 | When I start android studio I got errors | Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher | <java><android> | 2016-06-17 18:54:40 | LQ_EDIT |
37,888,614 | How to check if collection contains any element from other collection in Scala? | <p>Title says it all, what is the best practice for finding out if collection contains any element of other collection?</p>
<p>In java I would execute it like this</p>
<pre><code>CollectionUtils.containsAny(a, b)
</code></pre>
<p>using common apache collection utils, where variables a/b are collections.</p>
<p>How to implement this behavior in scala? Or is there library like CollectionUtils from above?</p>
<p>I dont want to use the common-apache library because i would have to convert scala collection to java collection.</p>
| <java><scala><collections><apache-commons> | 2016-06-17 18:59:11 | HQ |
37,888,960 | Redirect and store URL parameters in CVS | I looking for solution that will allowed me to use redirection and store in CVS files the parameters from specific URL.
I have a link:
http://my-server.com/?url={link}&campaign={campaign_name}&date={date}
Example:
http://my-server.com/?url=google.com&campaign=web&date=17062016
When the user will click in the link, they will be redirect to google.com, but the 3 parameters: url, campaign and date, will be store in CSV files on my server.
When I'm using 'window.location.href' I lost the all parameters.
Thanks for the help in advance.
DK | <javascript><url><parameters> | 2016-06-17 19:22:26 | LQ_EDIT |
37,889,263 | How to use break in if (Command) | <p>I am using <strong><em>$i</em></strong> string for limit in foreach loop.</p>
<pre><code>$i = 0;
foreach($string as $menu){
$i++;
if($i == 6){
break;
}
$menu_name = $menu['name'];
$menu_style = $menu['style'];
// i want to show total 5 menu names.
if($menu_style == 'magazine'){
// i have 5+ menus names (magazine style)
// butt here i want to show just one last magazine
echo $menu_name;
}
if($menu_style == 'normal'){
// i have 5+ names menus (normal style)
// butt here i want to show 4 last normal style
echo $menu_name.'<br>';
}
}
</code></pre>
<p>I can't want to use LIMIT in SQL query.</p>
<blockquote>
<p>And tell me when i use <em>if($i == 5){ break; }</em> then code display just 4
menu name</p>
</blockquote>
<p>Tell me how is display menu name as my required.</p>
| <php> | 2016-06-17 19:44:13 | LQ_CLOSE |
37,889,698 | Swift 3 method to create utf8 encoded Data from String | <p>I know there's a bunch of pre Swift3 questions regarding NSData stuff. I'm curious how to go between a Swift3 <code>String</code> to a utf8 encoded (with or without null termination) to Swift3 <code>Data</code> object.</p>
<p>The best I've come up with so far is:</p>
<pre><code>let input = "Hello World"
let terminatedData = Data(bytes: Array(input.nulTerminatedUTF8))
let unterminatedData = Data(bytes: Array(input.utf8))
</code></pre>
<p>Having to do the intermediate <code>Array()</code> construction seems wrong.</p>
| <string><utf-8><swift3> | 2016-06-17 20:13:18 | HQ |
37,890,183 | Keep only numbers between spesific letters | I want to keep a value in several seperated long text strings with one part in common. One of the text strings:
N-05-0040(119) f 2005 svart hp Ml:153 - 160 - 20 - 75 Tot 31- 3- 3- 6- 13 (4)29,7M - (4)28,2aK Kr 204.500, 2pr 2010, Trener: Ole Olesen
The common part is "Kr 204.500," and i only need the numbers, so i can use them for calculation, | <php><regex> | 2016-06-17 20:49:22 | LQ_EDIT |
37,890,284 | .ini file load environment variable | <p>I am using <a href="http://alembic.readthedocs.io/en/latest/" rel="noreferrer">Alembic</a> for migrations implementation in a <code>Flask</code> project. There is a <code>alembic.ini</code> file where the database configs must be specified:</p>
<p><code>sqlalchemy.url = driver://user:password@host/dbname</code></p>
<p>Is there a way to specify the parameters from the environment variables? I've tried to load them in this way <code>$(env_var)</code> but with no success. Thanks!</p>
| <python><flask><ini><alembic> | 2016-06-17 20:58:40 | HQ |
37,890,391 | How to include end date in pandas date_range method? | <p>From <code>pd.date_range('2016-01', '2016-05', freq='M', ).strftime('%Y-%m')</code>, the last month is <code>2016-04</code>, but I was expecting it to be <code>2016-05</code>. It seems to me this function is behaving like the <code>range</code> method, where the end parameter is not included in the returning array. </p>
<p>Is there a way to get the end month included in the returning array, without processing the string for the end month?</p>
| <python><string><datetime><pandas><range> | 2016-06-17 21:08:38 | HQ |
37,890,903 | Json string desrialazation c# | [I have this json][1]
and i want to desrialize it so i can get each object's value for example `"icon_url": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpouLWzKjhzw8zFdC5K092kl5SClMj3PLXFhGpC_Pp8j-3I4IG7i1Hn_UI-Nmj3ItDGe1BoN1mCr1G4xL_vhMS8tcmcn3JhuihwsHvbzQv3309k3tBw8A",` the problem is that i can make the class(es) that i need so i can deserialze the json because the json string has nested objects.
[1]: http://steamcommunity.com/profiles/76561198297267814/inventory/json/730/2/?trading=1 | <c#><json><jsonobject><json-deserialization> | 2016-06-17 21:53:37 | LQ_EDIT |
37,891,223 | React, why use super(props) inside of ES6 class constructor? | <p>I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor. </p>
<p>Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?</p>
<pre><code> constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
</code></pre>
| <reactjs><ecmascript-6><super> | 2016-06-17 22:26:57 | HQ |
37,891,280 | Goroutine: time.Sleep or time.After | <p>I wonder what is the better way to do a wait in a goroutine, <code>time.Sleep()</code> or <code><-time.After()</code>? What's the difference between the two and how to make choices? Thanks.</p>
| <go> | 2016-06-17 22:32:25 | HQ |
37,891,811 | Rails sorting based on 2 fields | I have a product model with 'price' field and 'sale_price' field. I want to sort the records according to price in ascending order. But if a product has sale_price value then it should be sorted according to sale_price not by price.
E.g
Product.id:1, Product.name:watch, Product.price:100, Product.sale_price:nil
Product.id:2, Product.name:Bag, Product.price:200, Product.sale_price:50
Product.id:3, Product.name:Shoes, Product.price:300, Product.sale_price:nil
I want this to be sorted as
1.Bag
2.watch
3.Shoes
Thanks | <ruby-on-rails><ruby><sqlite><activerecord><rails-activerecord> | 2016-06-17 23:38:38 | LQ_EDIT |
37,892,012 | How to change data in notepad using python | <p>Ok so I want to make a simple game where it's essential for the game to save. I wish to store all the data in notepad. However how do I pull notepad into python. I have tried saving notepad into the same folder where my .py file is. Then in the program im not sure what to do. Im just very confused on how to do this. I do know how to program in python, but how do I pull data out of notepad into python.</p>
<p>Also I wish to know how would I change the inside of the notepad file. Let's just say it has a couple of variables with certain numbers. I want to change those in game.</p>
<p>Thank you for any answers. :)</p>
| <python><notepad> | 2016-06-18 00:09:32 | LQ_CLOSE |
37,892,093 | How to enable PHP redis extension on Travis | <p>I'm running Travis CI for running my tests. I'm using the Trusty container with php v5.6.</p>
<p>Here is my entire .travis.yml file:</p>
<pre><code>language: php
dist: trusty
php:
- '5.4'
before_script:
- phpenv config-rm xdebug.ini
- before_script: echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
sudo: required
install:
- npm install -g gulp
- composer install
env:
- APP_ENV=circleci
script:
- gulp test
</code></pre>
<p>The <code>before_script:</code> syntax is copied directly from <a href="https://docs.travis-ci.com/user/languages/php#Enabling-preinstalled-PHP-extensions">the travis documentation</a> but my builds fail with a composer error saying:</p>
<pre><code>- The requested PHP extension ext-redis * is missing from your system. Install or enable PHP's redis extension.
</code></pre>
| <php><continuous-integration><travis-ci><phpredis> | 2016-06-18 00:25:52 | HQ |
37,892,312 | Adding custom hosting domain: "Unexpected TXT records found. Continuing to watch for changes." | <p>I'm attempting to add a custom domain to firebase hosting.</p>
<p>Added the TXT records as instructed, and I get this message in the firebase dashboard:</p>
<p>"Unexpected TXT records found. Continuing to watch for changes."</p>
<p>There is one additional TXT record in my DNS settings, but I can't remove it. I don't see how it would get in the way of firebase's verification of my domain either.</p>
<p>I'm using Namecheap if that helps.</p>
<p>Thanks in advance!</p>
| <firebase><firebase-realtime-database><firebase-hosting> | 2016-06-18 01:02:54 | HQ |
37,892,574 | Which DB technology is sued to solve the following search issue? | <p>Assume I have built a video sharing site such as youtube, and I want to build a recommendation system.</p>
<p>Assume I have a simple database [ video title, link/url to database ]</p>
<p>Lets assume user watches a video simply tiled - 'Sachin Tendulkar'.
How can I run a query to return me other videos whose search title <code>includes</code> sachin tendulkar ?</p>
<p>eg: other videos could be titled -</p>
<p><code>Straight drive by Sachin Tendulkar</code> or <code>Sachin Tendulkars famous reply to Bret Lee</code>.</p>
<p>In other words, which query can I run to fetch all the videos whose title contains Sachin ?</p>
| <mysql><sql><database> | 2016-06-18 01:59:20 | LQ_CLOSE |
37,892,621 | How can I disambiguate a type and a module with the same name? | <p>I'm trying to use Károly Lőrentey's <a href="https://github.com/lorentey/BTree">B-tree based <code>OrderedSet</code></a> in a project. However, I'm running into an issue where I can't declare an unqualified <code>OrderedSet<T></code> because the name conflicts between Foundation's <code>NSOrderedSet</code> (imported as <code>OrderedSet</code> in Swift 3) and <code>BTree</code>'s <code>OrderedSet</code>.</p>
<pre><code>let set = OrderedSet<Int>()
// error: 'OrderedSet' is ambiguous for type lookup in this context
// Found this candidate: Foundation.OrderedSet:3:14
// Found this candidate: BTree.OrderedSet:12:15
</code></pre>
<p>To resolve this conflict, you would normally qualify the name, and that would give you <code>BTree.OrderedSet<T></code>. However, the <code>BTree</code> module also contains a class named <code>BTree</code>. If I write <code>BTree.OrderedSet</code>, Swift thinks that I'm referring to a type named <code>OrderedSet</code> that is nested in the <code>BTree.BTree</code> type.</p>
<pre><code>let set = BTree.OrderedSet<Int>()
// error: reference to generic type 'BTree' requires arguments in <...>
</code></pre>
<p>If I don't <code>import BTree</code>, I can't use the <code>BTree</code> name at all.</p>
<pre><code>// no import BTree
let set = BTree.OrderedSet<Int>()
// error: use of undeclared type 'BTree'
</code></pre>
<p>How can I resolve this ambiguity between the <code>BTree</code> type and the <code>BTree</code> module?</p>
| <swift><swift3> | 2016-06-18 02:11:12 | HQ |
37,893,755 | Tensorflow set CUDA_VISIBLE_DEVICES within jupyter | <p>I have two GPUs and would like to run two different networks via ipynb simultaneously, however the first notebook always allocates both GPUs. </p>
<p>Using CUDA_VISIBLE_DEVICES, I can hide devices for python files, however I am unsure of how to do so within a notebook.</p>
<p>Is there anyway to hide different GPUs in to notebooks running on the same server?</p>
| <python><environment-variables><tensorflow> | 2016-06-18 05:55:39 | HQ |
37,893,822 | how to get the firstname and email from the JSON responce in IBMworklight | {
"userId": 1,
"userName": "username",
"firstName": "firstname",
"lastName": "lname",
"middleInitial": null,
"email": "nsk@gmail.com",
"dob": -250666200000,
"phoneNo": 2066628405,
"workPhone": null,
"mobileNo": 2036321543,
"status": null,
"address": null,
"group": null
} | <javascript><json> | 2016-06-18 06:05:20 | LQ_EDIT |
37,893,945 | Some of the Entris in Sql are Empty I dont want to print them . Can someone Help ? its urgent | i want to print only those entries that are not empty
for example amv=video1 and vs=video2 and vidbull is empty and vl is empty
to print only amv and vs and if vidbull and vl is not empty they should also print automatically
Can Some one help .. please its urgent
[Check This Image my coding][1]
[1]: http://i.stack.imgur.com/AMXnt.png | <php><mysql><phpmyadmin> | 2016-06-18 06:24:09 | LQ_EDIT |
37,894,142 | React: To know size of the element before it gets rendered | <p>Suppose that a component needs to know its size before it renders. With my knowledge I can do this:
render the component, in componentDidMount get the DOM node and extract size out of it, update state with that size, and then render again (lets not make it complicated with event listeners I'd attach to window's resize event, lets assume that window doesn't resize)
It works but seems dirty, the first render is just waste of resources, I wanna know the size of the element (or its container) before it's rendered, I know most of the time the element itself declares the size, but there are some situations when parent element declares the size and my case is one of those situations.
So to sum it up, is there any way to access parent element of a react component before it gets rendered (in componentWillMount)?</p>
<p>P.S. I know react-dimmensions, but I'd like a simpler solution that doesn't need external plugins. I just wanna know if it's possible to access parent node in componentWillMount in react or not.</p>
| <reactjs> | 2016-06-18 06:49:10 | HQ |
37,894,188 | Extract n words from string | i have a text containing sentences in each line, and in front of each word its lemmetize form exemple:
he "he" went "go" to "to" school "school" with "with" his "his" freinds "freind"
i would like to extract for example three by three word in in each line. The result seems like this:
he "he" went "go" to "to" \n
went "go" to "to" school "school" \n
to "to" school "school" with "with" \n
school "school" with "with" his "his" \n
with "with" his "his" freinds "freind" \n
Please, have you any idea to do this, many thanks,
| <perl> | 2016-06-18 06:55:39 | LQ_EDIT |
37,894,448 | Exact match in elastic search query | <p>I want to exactly match the string <code>":Feed:"</code> in a <code>message</code> field and go back a day pull all such records. The json I have seems to also match the plain word <code>" feed "</code>. I am not sure where I am going wrong. Do I need to add <code>"constant_score"</code> to this query JSON? The JSON I have currently is as shown below:</p>
<pre><code>{
"query": {
"bool": {
"must": {
"query_string": {
"fields": ["message"],
"query": "\\:Feed\\:"
}
},
"must": {
"range": {
"timestamp": {
"gte": "now-1d",
"lte": "now"
}
}
}
}
}
}
</code></pre>
| <elasticsearch> | 2016-06-18 07:25:57 | HQ |
37,894,644 | Error:NullPointerException when put button.setOnclickListener in onResponse method | <p>When i click my button in my activity, it will stop and show an error like this :</p>
<pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
</code></pre>
<p>In my activity, i put button.setOnclickListener in onResponse() method from Response.Listener. I do this because i want to get the data from JSONObject and use that data when i click my button.</p>
<p>Sorry, I'm not too fluent in English :)</p>
<p>My activity code:</p>
<pre><code>public class MenuDaftarNilai2 extends AppCompatActivity {
TextView tvMatkulDN, tvKlpDN, tvMhsDN;
Button bUasDN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_daftar_nilai2);
tvMatkulDN = (TextView) findViewById(R.id.tvMatkulDN) ;
tvKlpDN = (TextView) findViewById(R.id.tvKlpDN) ;
tvMhsDN = (TextView) findViewById(R.id.tvMhsDN) ;
bUasDN = (Button) findViewById(R.id.bUasDN) ;
Intent intent = getIntent();
final String nama_matkul = intent.getStringExtra("nama_matkul");
final String nama_klp = intent.getStringExtra("nama_klp");
final String nama_mhs = intent.getStringExtra("nama_mhs");
tvMatkulDN.setText(nama_matkul);
tvKlpDN.setText(nama_klp);
tvMhsDN.setText(nama_mhs);
Response.Listener responseListener1 = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
final String nilai_uas = jsonResponse.getString("nilai_uas");
final String id_uas = jsonResponse.getString("id_uas");
bUasDN.setText("Nilai Uas : " + nilai_uas);
bUasDN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MenuDaftarNilai2.this, EditUas.class);
intent.putExtra("nilai_uas", nilai_uas);
intent.putExtra("nama_matkul", nama_matkul);
intent.putExtra("nama_klp", nama_klp);
intent.putExtra("nama_mhs", nama_mhs);
intent.putExtra("id_uas", id_uas);
MenuDaftarNilai2.this.startActivity(intent);
finish();
}
});
}catch (JSONException e) {
e.printStackTrace();
}
}
};
ResponUas resUas = new ResponUas(nama_klp,nama_mhs, responseListener1);
RequestQueue queue1 = Volley.newRequestQueue(MenuDaftarNilai2.this);
queue1.add(resUas);
</code></pre>
<p>My XML code:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LoginAsis.MenuAsisten.MenuDaftarNilai.MenuDaftarNilai2"
android:background="#ad4f4f">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama Mata Kuliah"
android:id="@+id/textView54"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama Kelompok"
android:id="@+id/textView58"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView54"
android:layout_alignParentLeft="true"
android:textColor="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama Mahasiswa"
android:id="@+id/textView59"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView58"
android:layout_alignParentLeft="true"
android:textColor="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:id="@+id/textView60"
android:textColor="#ffffff"
android:layout_alignParentTop="true"
android:layout_alignLeft="@+id/textView61"
android:layout_alignStart="@+id/textView61" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:id="@+id/textView61"
android:textColor="#ffffff"
android:layout_below="@+id/textView60"
android:layout_alignLeft="@+id/textView62"
android:layout_alignStart="@+id/textView62" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:id="@+id/textView62"
android:textColor="#ffffff"
android:layout_marginLeft="68dp"
android:layout_marginStart="40dp"
android:layout_below="@+id/textView61"
android:layout_toRightOf="@+id/textView54"
android:layout_toEndOf="@+id/textView54" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="@+id/tvMatkulDN"
android:layout_alignTop="@+id/textView60"
android:layout_toRightOf="@+id/textView60"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="@+id/tvKlpDN"
android:layout_below="@+id/tvMatkulDN"
android:layout_toRightOf="@+id/textView60"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="@+id/tvMhsDN"
android:layout_below="@+id/tvKlpDN"
android:layout_toRightOf="@+id/textView61"
android:textColor="#ffffff"
android:layout_alignRight="@+id/tvKlpDN"
android:layout_alignEnd="@+id/tvKlpDN"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Belum ada nilai uas"
android:id="@+id/bUasDN"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@id/textView59"
android:gravity="left|center_vertical"
android:drawableRight="@drawable/ic_create_black_24dp"/>
</RelativeLayout>
</code></pre>
| <android> | 2016-06-18 07:52:13 | LQ_CLOSE |
37,894,825 | pycharm analysis complete. One typo found. Where is it? | <p>I use Pycharm 2016.1.4 (latest version at the moment) and it has a small box on the right top corner of the window (a checkbox if everything is correct).</p>
<p><a href="https://i.stack.imgur.com/6Hc2W.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6Hc2W.png" alt="enter image description here"></a></p>
<p>When you click on it, it tells you some information about warnings/errors/typos.</p>
<p>Now that I understood that I have some problems, I would try to fix them. It is easy to see where errors and warnings are (their lines are highlighted on the right side of the scroll). But how can I quickly (without looking through whole text for a curly underline) identify positions of the typos?</p>
| <pycharm><jetbrains-ide> | 2016-06-18 08:17:18 | HQ |
37,894,831 | rand() function doesn't works properly | <p>I have a problem with rand() function
I want to build a program that shows the number of each face of dice when you throw it 6000 times</p>
<p>I wrote this code </p>
<pre><code>#include <iostream>
using namespace std;
#include <iomanip>
using std::setw;
#include <cstdlib>
#include <ctime>
int main()
{
int face ;
int frequency1 =0;
int frequency2 =0;
int frequency3 =0;
int frequency4 =0;
int frequency5 =0;
int frequency6 =0;
for(int counter =1;counter <=6000;counter++){
face = 1+rand()%6;
switch(face){
case 1:
++frequency1;
break;
case 2:
++frequency1;
break;
case 3:
++frequency1;
break;
case 4:
++frequency1;
break;
case 5:
++frequency1;
break;
case 6:
++frequency1;
break;
default:
cout<<"program should never get here!!! ";
break;
}}
cout<<"the number of face 1 is : "<<frequency1<<endl;
cout<<"the number of face 2 is : "<<frequency2<<endl;
cout<<"the number of face 3 is : "<<frequency3<<endl;
cout<<"the number of face 4 is : "<<frequency4<<endl;
cout<<"the number of face 5 is : " <<frequency5<<endl;
cout<<"the number of face 6 is : " <<frequency6<<endl;
return 0;
}
</code></pre>
<p>Every time that i run this code it shows the same thing</p>
<pre><code>the number of face 1 is : 6000
the number of face 2 is : 0
the number of face 3 is : 0
the number of face 4 is : 0
the number of face 5 is : 0
the number of face 6 is : 0
</code></pre>
| <c++> | 2016-06-18 08:17:38 | LQ_CLOSE |
37,895,157 | Why constructor isn't called? | <p>Why constructor of class A isn't called when object of this class is passed as an argument to function taking the argument by value? </p>
<pre><code>class A
{
public:
A()
{
cout << "A\n";
}
};
void f_n(A val)
{
}
int main()
{
A a;
f_n(a);
return 0;
}
</code></pre>
| <c++> | 2016-06-18 08:58:05 | LQ_CLOSE |
37,895,278 | How to load assemblies located in a folder in .net core console app | <p>I'm making a console app on .Net Core platform and was wondering, how does one load assemblies (.dll files) and instantiate classes using C# dynamic features? It seems so much different than .Net 4.X and it's not really documented...</p>
<p>For example let's say I have a class library (.Net Core) and it has only one class:</p>
<pre><code>namespace MyClassLib.SampleClasses
{
public class Sample
{
public string SayHello(string name)
{
return $"Hello {name}";
}
public DateTime SayDateTime()
{
return DateTime.Now;
}
}
}
</code></pre>
<p>So the name of the dll file would be <code>MyClassLib.dll</code> and its located in <code>/dlls/MyClassLib.dll</code>.</p>
<p>Now I want to load this in a simple console app (.Net Core) and instantiate the <code>Sample</code> class and call the methods using dynamic features of C# in the following console app:</p>
<pre><code>namespace AssemblyLoadingDynamic
{
public class Program
{
public static void Main(string[] args)
{
// load the assembly and use the classes
}
}
}
</code></pre>
<p><strong>Note:</strong>
By .Net Core I mean RC2 version.</p>
| <c#><.net><.net-core><.net-core-rc2> | 2016-06-18 09:13:11 | HQ |
37,895,944 | react-transform-catch-errors does not look like a React component | <p>I'm working on a react project and we are using react starter kit. I am new to the project and when I clone the project from github and start the project using <code>npm start</code> it start the server but in web inspector I get following error.</p>
<p><code>Uncaught Error: imports[1] for react-transform-catch-errors does not look like a React component.</code></p>
<p>People who already working in the project doesn't get this error. But when I ask from one friend to get a new clone and do the same thing I did he also got the same error.</p>
<p>I don't know what details need to post so if anybody need more details please ask.</p>
| <javascript><reactjs> | 2016-06-18 10:27:57 | HQ |
37,896,170 | RST: how to present the output of a `tree` command? | <p>I would like to present the output of a <code>tree</code> command in a Restructured Text document. I am using this code:</p>
<pre><code>.. code-block:: bash
project
├── demo.py
├── LICENCE.txt
├── processes
│ ├── area.py
│ └── bboxinout.py
├── pywps.cfg
├── requirements.txt
├── server.py
├── setup.py
├── static
├── templates
└── tests
</code></pre>
<p>Which is producing the following output:</p>
<p><a href="https://i.stack.imgur.com/4O7gs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4O7gs.png" alt="enter image description here"></a></p>
<p>I then tried to replace the <code>tree</code> characters with unicode definitions, such as:</p>
<p><code>.. |hbar| unicode:: 01C0 ..</code></p>
<p>But the <code>|hbar|</code> sequence is printed verbatim when used inside a code block.</p>
<p>Is there any other way to force these characters to be printed correctly?</p>
| <restructuredtext> | 2016-06-18 10:55:48 | HQ |
37,896,186 | Cannot find symbol java netbeans | <p>Can someone tell me why I'm getting the error Cannot find symbol when I'm creating an object? in <code>bank_account Christine = new bank_account();</code> </p>
<pre><code>public class BankAccountTester
{
public static void main (String []args)
{
bank_account Christine = new bank_account();
Christine.deposit(10000);
Christine.withdraw(2000);
System.out.println(Christine.getBalance());
}
}
</code></pre>
<p>this is my class</p>
<pre><code>public class bank_account{
private double balance;
public bank_account()
{
balance = 0;
}
public bank_account (double initialBalance)
{
balance = initialBalance;
}
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw (double amount)
{
balance = balance - amount;
}
public double getBalance()
{
return balance;
}
}
</code></pre>
| <java><netbeans> | 2016-06-18 10:57:01 | LQ_CLOSE |
37,896,874 | problems with if in a function [python] | I am doing a simple program just to the program say if a number is even or not and to when the raw_input isn't a number, the program will complain about it:
def f():
t = raw_input('Enter a number and we will send an inormation: ')
if t != type(int):
print 'is this a number?'
elif int(t) % 2 == 0:
print t
print 'it is an even number'
elif int(t) % 2 > 0:
print t
print 'it is an odd number'
else:
print '???'
but when the program run it returns ONLY the if condition (when i write 90 or a word it returns 'is this a number?'. it should only return this if I Write a string). And I can't figure out where is the problem.
| <python><function><if-statement> | 2016-06-18 12:21:58 | LQ_EDIT |
37,897,147 | Simulate history.go(-1) with Javascript/JQuery | <p>I have three different html files (<strong>page1.html</strong>, <strong>page2.html</strong>, <strong>page3.html</strong>) that each contain a link to the same target in a fourth html file (<strong>glossary.html</strong>).</p>
<p>For technical reasons, I can't use <strong>history.go(-1)</strong> or other brower-specific functions, but I can use JavaScript and JavaScript libraries, e.g. JQuery, and LocalStorage.</p>
<p>What would be the best way to mimic the functionality of <strong>history.go(-1)</strong> with JavaScript?</p>
<p>The technical details are as follows:</p>
<p><strong>page1.html</strong> contains the following link:</p>
<pre><code><a id="page1" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>page2.html</strong> contains the following link:</p>
<pre><code><a id="page2" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>page3.html</strong> contains the following link:</p>
<pre><code><a id="page3" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>glossary.html</strong> contains the following link:</p>
<pre><code><a id="fn1" href="#">↵ Back </a>Term 1: Definition of term one.
</code></pre>
<p>I.e., the script(s) should do the following:</p>
<ol>
<li><p>Retrieve the id of the calling html page (<strong>page1</strong>, <strong>page2</strong> or <strong>page3</strong>) and save it as a LocalStorage item or in another suitable persistent manner.</p></li>
<li><p>When the user clicks the <strong>↵ Go back</strong> link, the href of the definition in glossary.html needs to be updated so that it points to <strong>page1.html#page1</strong>, <strong>page2.html#page2</strong> or <strong>page3.html#page3</strong>, depending on the html page that the glossary link was clicked on. </p></li>
</ol>
<p>What would be the easiest way to solve this problem?</p>
| <javascript><jquery><html><dynamic><href> | 2016-06-18 12:48:23 | LQ_CLOSE |
37,897,252 | Plot confusion matrix in R using ggplot | <p>I have two confusion matrices with calculated values as true positive (tp), false positives (fp), true negatives(tn) and false negatives (fn), corresponding to two different methods. I want to represent them as
<a href="https://i.stack.imgur.com/r3lu5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r3lu5.png" alt="enter image description here"></a></p>
<p>I believe facet grid or facet wrap can do this, but I find difficult to start.
Here is the data of two confusion matrices corresponding to method1 and method2</p>
<pre><code>dframe<-structure(list(label = structure(c(4L, 2L, 1L, 3L, 4L, 2L, 1L,
3L), .Label = c("fn", "fp", "tn", "tp"), class = "factor"), value = c(9,
0, 3, 1716, 6, 3, 6, 1713), method = structure(c(1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L), .Label = c("method1", "method2"), class = "factor")), .Names = c("label",
"value", "method"), row.names = c(NA, -8L), class = "data.frame")
</code></pre>
| <r><ggplot2><confusion-matrix> | 2016-06-18 13:01:11 | HQ |
37,897,685 | how to predict the demand for electrician,plumber etc | <p>We have a platform where user comes and book services like plumber,electrician service and choose a slot for service,we wanted to predict the demand of this system so that we can adjust the supply.
we are currently calculating and feeding supply for city a category b hub c time-slot combinations.
We would like to introduce a self learning algorithm that can calculate the capacity in these combinations and also tell us about the expected demand so we can build up supply accordingly</p>
| <machine-learning><deep-learning> | 2016-06-18 13:46:55 | LQ_CLOSE |
37,897,695 | how to close dialog in primfaces by click outside dialog? | close to dialog in primefaces by click outside of dialog ! Provided that when click in dialog do not close , but by click outside dialog close to dialog ! | <primefaces> | 2016-06-18 13:48:11 | LQ_EDIT |
37,898,030 | Async Spring Controllers vs normal Controllers | <p>I wanted to analyze the improvement I may see by enabling Async Controllers in Spring Boot over normal controller</p>
<p>So here is my test code. One API returns a Callable and another is normal controller API. Both APIs block for <strong>10secs</strong> simulating a long running task</p>
<pre><code>@RequestMapping(value="/api/1",method=RequestMethod.GET)
public List<String> questions() throws InterruptedException{
Thread.sleep(10000);
return Arrays.asList("Question1","Question2");
}
@RequestMapping(value="/api/2",method=RequestMethod.GET)
public Callable<List<String>> questionsAsync(){
return () -> {
Thread.sleep(10000);
return Arrays.asList("Question2","Question2");
};
}
</code></pre>
<p>I set up embedded tomcat with this configuration i.e only one tomcat processing thread:</p>
<pre><code>server.tomcat.max-threads=1
logging.level.org.springframework=debug
</code></pre>
<p><strong>Expectations for /api/1</strong>
Since there is only one tomcat thread, another request will not be entertained untill this is processed after 10secs</p>
<p><strong>Results:</strong>
Meet expectations</p>
<hr>
<p><strong>Expectations for /api/2</strong>
Since we are returning a callable immediately, the single tomcat thread should get free to process another request. Callable would internally start a new thread. So if you hit the same api it should also gets accepted.</p>
<p><strong>Results:</strong>
This is not happening and untill the callable executes completely, no further request is entertained.</p>
<p><strong>Question</strong>
Why is /api/2 not behaving as expected?</p>
| <spring><spring-mvc><spring-boot><spring-web> | 2016-06-18 14:25:04 | HQ |
37,898,567 | Azure Service Fabric Explorer returns always 403 | <p>I just deployed an secured Service Fabric Cluster (EncryptAndSign) with a LoadBalancer to an Azure Subscription. Deployment took some time but it worked as expected. Also I can connect to the cluster via PowerShell:</p>
<pre><code>$connectionEndpoint = ("{0}.{1}.cloudapp.azure.com:19000" -f
"mycluster", "somewhere")
Connect-serviceFabricCluster -ConnectionEndpoint $connectionEndpoint `
-KeepAliveIntervalInSec 10 `
-X509Credential `
-ServerCertThumbprint "..." `
-FindType FindByThumbprint `
-FindValue $clusterCertificate.Thumbprint `
-StoreLocation CurrentUser -StoreName My
</code></pre>
<p>It is also possible for me to deploy an application to the Cluster via Port 19000 using VisualStudio. Within in the Azure Portal everything looks good, no warning, no errors. </p>
<p>Unforunately I am not able to connect via Port 19080 to the Explorer. As I try to connect via the LoadBalancer I receive a Connection-Timeout. So established a RDP-Connection to one of the Nodes in the Cluster and tried to access the Explorer locally via </p>
<pre><code>localhost:19080/Explorer
</code></pre>
<p>But here I receive a Http-Error 403 (Forbidden) which might be the reason for the Connection timeout via Load-Balancer (as the probe is always receiving 403). Accroding to the <a href="https://azure.microsoft.com/en-us/documentation/articles/service-fabric-visualizing-your-cluster/#connect-to-a-remote-service-fabric-cluster">Azure Documentation</a>: </p>
<blockquote>
<p>"If you attempt to connect to Service Fabric Explorer on a secure
cluster, your browser will ask you to present a certificate in order
to gain access."</p>
</blockquote>
<p>Well, I was not prompted to present any certificate. Did I miss something? Is there anything special to configure? Thanks in advance.</p>
| <azure><azure-service-fabric> | 2016-06-18 15:21:16 | HQ |
37,898,873 | I don't know how to use android json parser | I'm new to android and i'm developing an Android App, i want to get JSON data
I can't bring my json from server
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
This is the code am using to parse it:
package com.centre.anapa;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDialog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
.penaltyLog()
.build());
TextView dust = (TextView) findViewById(R.id.dust);
TextView humid = (TextView) findViewById(R.id.humid);
TextView temp = (TextView) findViewById(R.id.temp);
TextView tim = (TextView) findViewById(R.id.tim);
JSONObject json = null;
String str = "";
HttpResponse response;
HttpClient myClient = new DefaultHttpClient();
HttpPost myConnection = new HttpPost("http://mase.everypython.com/get_data");
try {
response = myClient.execute(myConnection);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try{
JSONArray jArray = new JSONArray(str);
json = jArray.getJSONObject(0);
if (dust != null) {
dust.setText(json.getString("dust"));
}
if (humid != null) {
humid.setText(json.getString("humid"));
}
if (temp != null) {
temp.setText(json.getString("temp"));
}
if (tim != null) {
tim.setText(json.getString("time"));
}
} catch ( JSONException e) {
e.printStackTrace();
}
}
@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);
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
I don't know how to use Android son parse
| <java><android><json> | 2016-06-18 15:52:33 | LQ_EDIT |
37,899,376 | How can I get the text at the bottom of a particular div using css? I have tried, but the text goes to main div | {<body>
<div id="img1" style="background-color:red;width:100%;height:100%;">
<div id="abc">
<img id="image" src="punj.jpg" alt="PUNJ icon" style="width:5%; height:15%; float:left;">
</div>
<div id="img1" style="background-color:#B1C7E8;width:95%;height:15%; float :left;">
<h1 id="head">
University
</h1>
</div>} this is code of html aaaaa | <javascript><java><html><css> | 2016-06-18 16:46:58 | LQ_EDIT |
37,899,778 | How do you create custom notifications in Swift 3? | <p>In Objective-C, a custom notification is just a plain NSString, but it's not obvious in the WWDC version of Swift 3 just what it should be.</p>
| <swift><nsnotificationcenter><nsnotifications><nsnotification><swift3> | 2016-06-18 17:28:32 | HQ |
37,900,005 | Error running: Project has no JDK configured in IntelliJ IDEA Ultimate | <p>When I try to execute program ergo, it gives me an error. </p>
<p><strong>Error running: Project has no JDK configured</strong></p>
<p>Can anybody help me? I'm newbie in IntelliJ IDEA.</p>
| <java><intellij-idea><settings> | 2016-06-18 17:54:08 | HQ |
37,900,611 | Image Upload Javascript | <p>My problem here is uploading images.. BUT I already know how to upload Base64 Images. Right now , i can upload Base64 Images and put them to databse. You can already see that is ridicolous as it will take tons of space and is hard to load. I was just checking if there is like this API Where you can upload and it gives you URL(And No I dont want Imgur, because it is banned a lot of places.) Or if there is a custom way to shorten Base64? Something that wont take as much space as Base64 Images do...</p>
| <javascript><base64><image-uploading> | 2016-06-18 19:01:39 | LQ_CLOSE |
37,900,780 | In tensorflow what is the difference between tf.add and operator (+)? | <p>In tensorflow tutorials, I see both codes like <code>tf.add(tf.matmul(X, W), b)</code> and <code>tf.matmul(X, W) + b</code>, what is the difference between using the math function <code>tf.add()</code>, <code>tf.assign()</code>, etc and the operators <code>+</code> and <code>=</code>, etc, in precision or other aspects? </p>
| <tensorflow> | 2016-06-18 19:19:27 | HQ |
37,901,223 | React.js: submit form programmatically does not trigger onSubmit event | <p>I want to submit a React form after a click on a link.</p>
<p>To do so I need to submit the form programmatically if the link is clicked.</p>
<p><strong>my problem is : <code>onSubmit</code> handler is not being fired after the form submit .</strong></p>
<p>Here is a code snipped that I made for this purpose: </p>
<pre><code>var MyForm = React.createClass({
handleSubmit: function(e){
console.log('Form submited');
e.preventDefault();
},
submitForm : function(e){
this.refs.formToSubmit.submit();
},
render: function() {
return (
<form ref="formToSubmit" onSubmit={this.handleSubmit}>
<input name='myInput'/>
<a onClick={this.submitForm}>Validate</a>
</form>);
}
});
ReactDOM.render(
<MyForm name="World" />,
document.getElementById('container')
);
</code></pre>
<p>The <code>handleSubmit</code> is not invoked and the default behavior is executed (the form being submitted).
Is this a ReactJs bug or a normal behavior?
Is there a way to get the onSubmit handler invoked ?</p>
| <forms><reactjs><onsubmit> | 2016-06-18 20:13:25 | HQ |
37,901,245 | Can C's restrict keyword be emulated using strict aliasing in C++? | <h2>The Problem</h2>
<p>The <code>restrict</code> keyword in C is missing in C++, so out of interest I was looking for a way to emulate the same feature in C++. </p>
<p>Specifically, I would like the following to be equivalent:</p>
<pre><code>// C
void func(S *restrict a, S *restrict b)
// C++
void func(noalias<S, 1> a, noalias<S, 2> b)
</code></pre>
<p>where <code>noalias<T, n></code></p>
<ul>
<li>behaves just like <code>T*</code> when accessed with <code>-></code> and <code>*</code></li>
<li>can be constructed from an <code>T*</code> (so that the function can be called as <code>func(t1, t2)</code>, where <code>t1</code> and <code>t2</code> are both of type <code>T*</code>)</li>
<li>the index <code>n</code> specifies the "aliasing class" of the variable, so that variables of type <code>noalias<T, n></code> and <code>noalias<T, m></code> may be assumed never to alias for n != m.</li>
</ul>
<h2>An Attempt</h2>
<p>Here is my deeply flawed solution:</p>
<pre><code>template <typename T, int n>
class noalias
{
struct T2 : T {};
T *t;
public:
noalias(T *t_) : t(t_) {}
T2 *operator->() const {return static_cast<T2*>(t);} // <-- UB
};
</code></pre>
<p>When accessed with <code>-></code>, it casts the internally-stored <code>T*</code> to a <code>noalias<T, n>::T2*</code> and returns that instead. Since this is a different type for each <code>n</code>, the strict aliasing rule ensures that they will never alias. Also, since <code>T2</code> derives from <code>T</code>, the returned pointer behaves just like a <code>T*</code>. Great!</p>
<p>Even better, the code compiles and the assembly output confirms that it has the desired effect.</p>
<p>The problem is the <code>static_cast</code>. If <code>t</code> were really pointing to an object of type <code>T2</code> then this would be fine. But <code>t</code> points to a <code>T</code> so this is UB. In practice, since <code>T2</code> is a subclass which adds nothing extra to <code>T</code> it will probably have the same data layout, and so member accesses on the <code>T2*</code> will look for members at the same offsets as they occur in <code>T</code> and everything will be fine.</p>
<p>But having an <code>n</code>-dependent class is necessary for strict aliasing, and that this class derives from <code>T</code> is also necessary so that the pointer can be treated like a <code>T*</code>. So UB seems unavoidable.</p>
<h2>Questions</h2>
<ul>
<li><p>Can this be done in c++14 without invoking UB - possibly using a completely different idea?</p></li>
<li><p>If not, then I have heard about a "dot operator" in c++1z; would it be possible with this?</p></li>
<li><p>If the above, will something similar to <code>noalias</code> be appearing in the standard library?</p></li>
</ul>
| <c++><c++14><restrict><strict-aliasing> | 2016-06-18 20:16:17 | HQ |
37,901,505 | Java OpenCV from Maven | <p>Is there any way to get OpenCV from repository? Which artifact should I add to <code>pom.xml</code>? Every tutorial I'd found is from '14 and it seems like something changed - they say it is'nt in official Maven repository yet, but I've found entry:</p>
<pre><code><!-- https://mvnrepository.com/artifact/nu.pattern/opencv -->
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-7</version>
</dependency>
</code></pre>
<p>Sadly, I get error</p>
<pre><code>Caused by: java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path
</code></pre>
<p>when I'm using <code>System.loadLibrary(Core.NATIVE_LIBRARY_NAME)</code>. Can I add this library in a way that would make my project include it and 'forget' about manually adding it to classpath?</p>
| <java><maven><opencv> | 2016-06-18 20:51:07 | HQ |
37,901,600 | IdentationError: unident does not match any outer identation level. (Python) | <p>I'm pretty new to coding Python and I'm learning it.</p>
<p>Now I've made a piece of code but keep getting the following error:</p>
<p>'IdentationError: unident does not match any outer identation level.'</p>
<p>I hope you guys can help me out.</p>
<pre><code>password = test123
if password == raw_input('What is the password?'):
print("Acces given")
else:
print("Acces forbidden")
</code></pre>
| <python> | 2016-06-18 21:03:51 | LQ_CLOSE |
37,902,076 | Tkinter Function attached to Button executed immediately | <p>What I need is to attach a function to a button that is called with a parameter. When I write the code as below however, the code is executed once when the button is created and then no more. Also, the code works fine if I get rid of the parameter and parentheses when I declare the function as an attribute of the button. How can I call the function with a parameter only when the button is pressed?</p>
<pre><code>from Tkinter import *
root =Tk()
def function(parameter):
print parameter
button = Button(root, text="Button", function=function('Test'))
button.pack()
root.mainloop()
</code></pre>
| <python><button><tkinter> | 2016-06-18 22:08:50 | LQ_CLOSE |
37,902,441 | What does event.waitUntil do in service worker and why is it needed? | <p>MDN suggests that you do the following to create and populate service worker cache:</p>
<pre><code>this.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/sw-test/',
'/sw-test/index.html',
... etc ...
]);
})
);
});
</code></pre>
<p>I do not understand that code. The <code>waitUntil</code> method is documented too, and it seems the code above is the single purpose of it's existence at the moment:</p>
<blockquote>
<p>The ExtendableEvent.waitUntil() method extends the lifetime of the
event. When called in an EventHandler associated to the install event,
it delays treating the installing worker as installed until the passed
Promise resolves successfully. This is primarily used to ensure that a
service worker is not considered installed until all of the core
caches it depends on are populated.</p>
</blockquote>
<p>What I do not understand is:</p>
<ul>
<li>How does <code>waitUntil</code> generally affect code flow? Does it stop event from propagating until it's promise resolves?</li>
<li>Why is it needed in the context of opening worker cache?</li>
</ul>
<p>I am asking this question because I have problems with the code above and I would like to understand it.</p>
| <javascript-events><promise><service-worker> | 2016-06-18 23:07:58 | HQ |
37,903,244 | How to read a zip entry in a zip file, ad nauseum for c# or vb.net | While there is a response to this question using the java libraries (http://stackoverflow.com/questions/11287486/read-a-zip-file-inside-zip-file), I cannot find an example of this anywhere in c# or vb.net.
What I have to do for a client is use the .NET 4.5 ZipArchive library to traverse zip files for specific entries. Before anyone asks, the client refuses to allow me to use dotnetzip, because his chief architect has experience with that library and says it is too buggy to be used in a real application. He's pointed out a couple to me, and it doesn't matter what I think anyway!
If I have a zip file, that itself contains other zip files, I need a way of opening the inner zip files, and read the entries for that zip file. Eventually I will also have to actually open the zip entry for the zip in a zip, but for now I just have to be able to get at the zipentries of an inner zip file.
Here's what I have so far:
public string PassThruZipFilter(string[] sfilters, string sfile, bool buseregexp, bool bignorecase, List<ZipArchiveZipFile> alzips)
{
bool bpassed = true;
bool bfound = false;
bool berror = false;
string spassed = "";
int ifile = 0;
try
{
ZipArchive oarchive = null; ;
int izipfiles = 0;
if (alzips.Count == 0)
{
oarchive = ZipFile.OpenRead(sfile);
izipfiles = oarchive.Entries.Count;
}
else
{
//need to dig into zipfile n times in alzips[i] where n = alzips.Count
oarchive = GetNthZipFileEntries(alzips, sfile); <------ NEED TO CREATE THIS FUNCTION!
izipfiles = oarchive.Entries.Count;
}
while (((ifile < izipfiles) & (bfound == false)))
{
string sfilename = "";
sfilename = oarchive.Entries[ifile].Name;
//need to take into account zip files that contain zip files...
bfound = PassThruFilter(sfilters, sfilename, buseregexp, bignorecase);
if ((bfound == false) && (IsZipFile(sfilename)))
{
//add this to the zip stack
ZipArchiveZipFile ozazp = new ZipArchiveZipFile(alzips.Count, sfile, sfilename);
alzips.Add(ozazp);
spassed = PassThruZipFilter(sfilters, sfilename, buseregexp, bignorecase, alzips);
if (spassed.Equals(sISTRUE))
{
bfound = true;
}
else
{
if (spassed.Equals(sISFALSE))
{
bfound = false;
}
else
{
bfound = false;
berror = true;
}
}
}
ifile += 1;
}
}
catch (Exception oziperror)
{
berror = true;
spassed = oziperror.Message;
}
if ((bfound == false))
{
bpassed = false;
}
else
{
bpassed = true;
}
if (berror == false)
{
spassed = bpassed.ToString();
}
return (spassed);
}
So the function I have to create is 'GetNthZipFileEntries(List<ZipFileZipEntry>, sfile)', where the ZipFileZipEntry is just a structure that contains an int index, string szipfile, string szipentry.
I cannot figure out how read a zip file inside a zip file (or G-d forbid, a zip file inside a zip file inside a zip file...the 'PassThruZipFilter is a function **inside** a recursive function) using .NET 4.5. Obviously microsoft does it, because you can open up a zip file inside a zip file in explorer. Many thanks for anyone that can help.
**So, I truly need your help on how to open zip files inside of zip files in .NET 4.5 without writing to the disk**. There are NO examples on the web I can find for this specific purpose. I can find tons of examples for reading zip file entries, but that doesn't help. **To be clear, I cannot use a hard disk to write anything**. I can use a memory stream, but that is the extent of what I can do. **I cannot use the dotnetzip library**, so any comments using that won't help, but of course I'm thankful for any help at all. I could use another library like the Sharp zip libs, but I'd have to convince the client that it is impossible with .NET 4.5. | <c#><asp.net><.net><vb.net><zip> | 2016-06-19 01:50:20 | LQ_EDIT |
37,904,012 | How to change the overall font of wordpress site? | I am using Duster as my theme. I wan to change the default font. Is there a way to do that? | <css><wordpress><fonts><wordpress-theming> | 2016-06-19 04:42:12 | LQ_EDIT |
37,904,682 | How do I use Docker environment variable in ENTRYPOINT array? | <p>If I set an environment variable, say <code>ENV ADDRESSEE=world</code>, and I want to use it in the entry point script concatenated into a fixed string like:</p>
<pre><code>ENTRYPOINT ["./greeting", "--message", "Hello, world!"]
</code></pre>
<p>with <code>world</code> being the value of the environment varible, how do I do it? I tried using <code>"Hello, $ADDRESSEE"</code> but that doesn't seem to work, as it takes the <code>$ADDRESSEE</code> literally.</p>
| <docker><dockerfile> | 2016-06-19 06:49:35 | HQ |
37,904,817 | i am new to android studio.I got error while building in android studio | [enter image description here][1]
[1]: http://i.stack.imgur.com/aC1ns.jpg
after deleting menu1.xml file i am getting this error.
why android studio is still mentioning error even afer deleting the file which was unused? | <android><android-studio><build> | 2016-06-19 07:11:33 | LQ_EDIT |
37,905,207 | How can I convert required string in Java? | <p>convert given string as per requirement. abc123 need to be convert 012onetwothree</p>
<p>What is the best way to implement such kind of program, i used the enum for this to implement </p>
| <javascript><java> | 2016-06-19 08:07:29 | LQ_CLOSE |
37,905,456 | Subclassing NSManagedObject with swift 3 and Xcode 8 beta | <p>I've began to try use Core data with swift 3 and Xcode 8 beta. When I try to generate NSManagedObject subclasses from core data model and Create NSManagedObject subclass… option in Editor menu, Xcode 8 beta generates three files one of them is <strong>_COREDATA_DATAMODELNAME_</strong>+CoreDataModel.swift with the following content:</p>
<pre><code>import Foundation
import CoreData
___COREDATA_DATAMODEL_MANAGEDOBJECTCLASSES_IMPLEMENTATIONS___
</code></pre>
<p>In addition, the content of this file shows two warnings:</p>
<pre><code>Expressions are not allowed at the top level.
Use of unresolved identifier '___COREDATA_DATAMODEL_MANAGEDOBJECTCLASSES_IMPLEMENTATIONS___'
</code></pre>
<p>Has anyones faced the same issue? Which is the meaning of this new file?</p>
<p>Thanks</p>
| <core-data><nsmanagedobject><swift3><xcode8> | 2016-06-19 08:48:11 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.