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 |
|---|---|---|---|---|---|
34,552,656
|
Java: Repeat Task Every Random Seconds
|
<p>I'm already familiar with repeating tasks every n seconds by using Java.util.Timer and Java.util.TimerTask. But lets say I want to print "Hello World" to the console every random seconds from 1-5. Unfortunately I'm in a bit of a rush and don't have any code to show so far. Any help would be apriciated. </p>
|
<java><repeat>
|
2016-01-01 00:21:59
|
LQ_CLOSE
|
34,553,034
|
Why are Java Optionals immutable?
|
<p>I'd like to understand why Java 8 Optionals were designed to be immutable. Is it just for thread-safety?</p>
|
<java><optional>
|
2016-01-01 02:03:20
|
HQ
|
34,553,174
|
Text Overlay Image with Darkened Opacity React Native
|
<p>I am attempting to overlay a title over an image - with the image darkened with a lower opacity. However, the opacity effect is changing the overlaying text as well - making it dim. Any fix to this? Here is what is looks like:</p>
<p><a href="https://i.stack.imgur.com/1HzD7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1HzD7.png" alt="enter image description here"></a></p>
<p>And here is my code for the custom component (article preview - which the above image is a row of article preview components): </p>
<pre><code>//component for article preview touchable image
/* will require the following
- rss feed and api
- user's keyword interests from parse In home.js
- parse db needs to be augmented to include what they heart
- parse db needs to be augmented to include what they press on (like google news)
*/
var React = require('react-native');
var {
View,
StyleSheet,
Text,
Image,
TouchableHighlight,
} = React;
//dimensions
var Dimensions = require('Dimensions');
var window = Dimensions.get('window');
var ImageButton = require('../../common/imageButton');
var KeywordBox = require('../../authentication/onboarding/keyword-box');
//additional libraries
module.exports = React.createClass({
//onPress function that triggers when button pressed
//this.props.text is property that can be dynamically filled within button
/* following props:
- source={this.props.source}
- onPress={this.props.onPress}
- {this.props.text}
- {this.props.heartText}
- key={this.props.key}
- text={this.props.category}
- this.props.selected
*/
render: function() {
return (
<TouchableHighlight
underlayColor={'transparent'}
onPress={this.props.onPress} >
<Image
source={this.props.source}
style={[styles.articlePreview, this.border('red')]}>
<View style={[styles.container, this.border('organge')]}>
<View style={[styles.header, this.border('blue')]}>
<Text style={[styles.previewText]}>{this.props.text}</Text>
</View>
<View style={[styles.footer, this.border('white')]}>
<View style={[styles.heartRow, this.border('black')]}>
<ImageButton
style={[styles.heartBtn, , this.border('red')]}
resizeMode={'contain'}
onPress={this.onHeartPress}
source={require('../../img/heart_btn.png')} />
<Text style={[styles.heartText]}>{this.props.heartText + ' favorites'}</Text>
</View>
<KeywordBox
style={[styles.category, this.border('blue')]}
key={this.props.key}
text={this.props.category}
onPress={this.props.categoryPress}
selected={this.props.selected} />
</View>
</View>
</Image>
</TouchableHighlight>
);
},
onHeartPress: function() {
//will move this function to a general module
},
border: function(color) {
return {
//borderColor: color,
//borderWidth: 4,
}
},
});
var styles = StyleSheet.create({
heartText: {
color: 'white',
fontSize: 12,
fontWeight: 'bold',
alignSelf: 'center',
marginLeft: 5,
fontFamily: 'SFCompactText-Medium'
},
heartRow: {
flexDirection: 'row',
justifyContent: 'space-around',
alignSelf: 'center',
justifyContent: 'center',
},
heartBtn: {
height: (92/97)*(window.width/13),
width: window.width/13,
alignSelf:'center',
},
category: {
fontFamily: 'Bebas Neue',
fontSize: 10,
fontWeight: 'bold'
},
header: {
flex: 3,
alignItems: 'center',
justifyContent: 'space-around',
marginTop: window.height/30,
},
footer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
margin: window.height/50,
},
container: {
flex: 1,
backgroundColor: 'black',
opacity: 0.6,
},
articlePreview: {
flex: 1,
height: window.height/3.2,
width: window.width,
flexDirection: 'column'
},
previewText: {
fontFamily: 'Bebas Neue',
fontSize: 23,
color: 'white',
alignSelf: 'center',
textAlign: 'center',
margin: 5,
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0
},
});
</code></pre>
|
<javascript><image><overlay><react-native><opacity>
|
2016-01-01 02:48:24
|
HQ
|
34,553,318
|
Why ternary operator in swift is so picky?
|
<p>The question is very simple, but I just could not find the answer!</p>
<p>Why doesn't</p>
<pre><code>return x == 0? "" : "Hello"
</code></pre>
<p>compile but</p>
<pre><code>return x == 0 ? "" : "Hello"
</code></pre>
<p>does?</p>
<p>This is really weird because all the other operators don't need an extra white space. e.g.</p>
<pre><code>let x = 1+1
let y = 1 + 1
</code></pre>
<p>are the same.</p>
<p>I think it has something to do with optionals. But when you use a <code>?</code> operator on a variable, it must be used like this:</p>
<pre><code>let s: String? = nil
let x = s?.startIndex
</code></pre>
<p>I mean it must follow another operator, right?</p>
|
<swift><operators><whitespace><ternary-operator><optional>
|
2016-01-01 03:30:17
|
HQ
|
34,553,755
|
hide/show fab with scale animation
|
<p>I'm using custom floatingactionmenu. I need to implement scale animation on show/hide menu button like here
<a href="https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsZU1kZWhRYWZpUDg/components-buttons-fab-behavior_01_xhdpi_012.mp4" rel="noreferrer">floating action button behaviour</a></p>
<p>Is there any way to do this ?</p>
|
<android><material-design><floating-action-button>
|
2016-01-01 05:21:48
|
HQ
|
34,554,026
|
Accessing pointer member of the structure using structure pointer
|
<p>I have defined integer pointer inside the structure.And i want to use that member pointer using the structure pointer.My code is as shown below:</p>
<pre><code>#include<stdio.h>
#include<stdlib.h>
struct abc
{
int *x;
};
int main()
{
struct abc *p = (struct abc*)malloc(sizeof(struct abc));
p->x = (int*)malloc(sizeof(int));
p->x = 10;
printf("The value is %d\n",p->x);
free(p);
}
</code></pre>
<p>Now i am getting output as per my expectation.But i have got warning message while compiling.The warning messages are:</p>
<pre><code>temp.c:14:7: warning: assignment makes pointer from integer without a cast [enabled by default]
temp.c:15:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat]
</code></pre>
<p>I have also tried,</p>
<pre><code>*p->x = 10
printf("The value is %d\n",*p->x);
</code></pre>
<p>but it is not working.</p>
<p>How to solve this warning?</p>
|
<c><pointers><data-structures>
|
2016-01-01 06:21:17
|
LQ_CLOSE
|
34,554,206
|
How To Disable 2nd Saturday 4th Saturday ,Sunday And Holiday Date Using JQuery Calendar
|
i want to Disable 2nd Saturday 4th saturday, Sunday And Public Holiday Date Using jQuery calendar
All year of 2nd Saturday And 4th Saturday ,Sunday Disable from Calendar
Please Help Me
|
<javascript><jquery><jquery-ui>
|
2016-01-01 06:55:18
|
LQ_EDIT
|
34,554,671
|
Resizing containers in bootstrap
|
I am new to bootstrap and i would like to find out how do i automatically resize my image to fit it into the container. And i would like to have a blank background for my container. Currently it is like this
<div class="row">
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<img src ="haha.png"/>
</div>
</div>
</div>
</div>
[![enter image description here][1]][1]
I plugged the whole code from some template form and i was playing around with it.
I would like to have a container where i could fit the image inside automatically resizing the image.
[1]: http://i.stack.imgur.com/s16WB.png
|
<jquery><html><css><twitter-bootstrap>
|
2016-01-01 08:32:05
|
LQ_EDIT
|
34,554,871
|
Changing Theme in Windows 10 UWP App Programmatically
|
<p>I was able to change theme using <code>this.RequestedTheme = ElementTheme.Dark;</code>
But what I need is the whole application level, since this one only change the theme of the current page to dark.</p>
<p>Whenever I try this <code>App.Current.RequestedTheme = ApplicationTheme.Dark;</code>
I always get this error</p>
<blockquote>
<p>An exception of type 'System.NotSupportedException' occurred in UWPApp.exe but was not handled in user code</p>
</blockquote>
<p>Is there such a way that I can change the whole application theme from Light to Dark or vice versa?</p>
<p>I'm using VS2015</p>
|
<c#><windows-10><windows-10-mobile><windows-10-universal>
|
2016-01-01 09:05:45
|
HQ
|
34,554,982
|
TextBox Value Disappears VB6
|
I my case I am having two form Form 1 and Form 2.
Form 1 having two Buttons and Form 2 is having one textbox.
On Button 1 Click event I am writing "My Text" in my Form 2 TextBox and on button 2 I am showing Form 2.
What is happening is When I close my Form 2 using close [X] button and reopen it value in my Form 2 Textbox Disappears.
Please Help how can I resolve this,
|
<vb6>
|
2016-01-01 09:27:44
|
LQ_EDIT
|
34,555,603
|
MongoDB Failing to Start - ***aborting after fassert() failure
|
<p>I am new to Ubuntu (Linux tbh). I encountered problem with starting MongoDB service. I want to created web app using Ruby on Rails and MongoDB but mongo seems to fail to start.</p>
<p>I followed this <a href="https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-ubuntu/">MongoDB installation on Ubuntu</a> all of installation went without problems until I got to <code>sudo service mongod start</code> </p>
<p><strong>mongod.log</strong></p>
<pre><code>2016-01-01T10:58:15.545+0000 I CONTROL ***** SERVER RESTARTED *****
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] MongoDB starting : pid=3868 port=27017 dbpath=/var/lib/mongodb 64-bit host=damian-CX61-0NC-CX61-0ND-CX61-0NF-CX61-0NE
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] db version v3.0.8
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] build info: Linux ip-10-187-89-126 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-01-01T10:58:15.567+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-01T10:58:15.567+0000 I - [initandlisten] Fatal Assertion 28578
2016-01-01T10:58:15.567+0000 I - [initandlisten]
***aborting after fassert() failure
</code></pre>
<p>So what I am doing wrong or its different issue?</p>
|
<linux><mongodb><ubuntu><ubuntu-14.04><startup>
|
2016-01-01 11:08:53
|
HQ
|
34,555,643
|
What's the best way to store text data?
|
<p>I am kinda new to Android development, but I coded a lot of C#(WinF,WPF). I created an quiz app (German words) for app and I'm not quite sure how to store and load dictionaries (a file, where lines contain 2 words). What is the best way to store these dictionaries? I googled a bit, but didn't find exact answers. At the moment I generate the words directly in the code.
Thanks!</p>
|
<android><android-file>
|
2016-01-01 11:15:21
|
LQ_CLOSE
|
34,556,569
|
ios/objective-c/xcode: Expand Label based on quantity of text using Storyboard
|
I have a UIlabel linked to a property that can contain text of many different possible lengths.
How can I get the label to expand vertically to accommodate different quantities of text?
I have set lines to 0 in storyboard. And I've experimented with different heights in the Size Inspector. But the label is not adjusting and I am only seeing one line of text that ends at edge of label.
Would prefer not to use auto layout if possible unless there is no other way.
Thanks in advance for any suggestions.
|
<ios><storyboard><uilabel>
|
2016-01-01 13:33:36
|
LQ_EDIT
|
34,556,906
|
output FILE ,is this a fault?
|
my code here
#include <stdio.h>
#include<iostream>
#include<conio.h>
char filename[100];
FILE *stream, *stream2;
char s[20];
struct date
{
int day, month, year;
};
struct employee
{
int ID;
char name[100];
date birthdate;
char address[20];
char rank[20];
int money;
};
void main()
{
errno_t err;
// Open for read (will fail if file "crt_fopen_s.c" does not exist)
// Open for write
err = fopen_s(&stream2, "C:/Users/Van/Desktop/LAALAL/fool.txt", "w+");
if (err == 0)
{
employee nv;
std::cout << "\nInput information of an employee:\n";
std::cout << "\tInput ID : ";
std::cin >> nv.ID;
std::cin.sync();
std::cout << "\tInput name : ";
std::cin.clear();
gets_s(s);
gets_s(nv.name);
std::cout << "\tInput birthdate (Day Month Year ) : ";
std::cin >> nv.birthdate.day >> nv.birthdate.month >> nv.birthdate.year;
std::cout << "\tInput address: ";
std::cin.clear();
gets_s(s);
gets_s(nv.address);
std::cout << "\tInput rank : ";
std::cin.clear();
gets_s(s);
gets_s(nv.rank);
std::cout << "\tMoney : ";
std::cin >> nv.money;
std::cin.sync();
std::fwrite(&nv, sizeof(nv), 1, stream2);
std::fclose(stream2);
}
}
Well i don't meet the problem with code but when i input my information to txt file , i cant read the output in txt file ,here is the picture of my output
[enter image description here][1]
What is my problems??
Thanks in advance for your time !!!
[1]: http://i.stack.imgur.com/gaPqY.png
|
<c++>
|
2016-01-01 14:20:01
|
LQ_EDIT
|
34,556,991
|
Pod install displaying error in cocoapods version 1.0.0.beta.1
|
<p>My podfile was working but after updating to cocoapods version 1.0.0.beta.1</p>
<p>pod install displays following error</p>
<pre><code>MacBook-Pro:iOS-TuneIn home$ pod install
Fully deintegrating due to major version update
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
Deleted 1 'Embed Pods Frameworks' build phases.
- libPods.a
- Pods.debug.xcconfig
- Pods.release.xcconfig
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
- libPods.a
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
- libPods.a
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
- libPods.a
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
- libPods.a
- libPods.a
Deleted 1 empty `Pods` groups from project.
Removing `Pods` directory.
Project has been deintegrated. No traces of CocoaPods left in project.
Note: The workspace referencing the Pods project still remains.
Updating local specs repositories
Analyzing dependencies
[!] The dependency `AFNetworking (= 2.6.3)` is not used in any concrete target.
The dependency `MBProgressHUD (~> 0.9.1)` is not used in any concrete target.
The dependency `PDKeychainBindingsController (~> 0.0.1)` is not used in any concrete target.
The dependency `FMDB/SQLCipher` is not used in any concrete target.
The dependency `ZXingObjC (~> 3.1.0)` is not used in any concrete target.
The dependency `SDWebImage (~> 3.7.2)` is not used in any concrete target.
The dependency `SignalR-ObjC (~> 2.0.0.beta3)` is not used in any concrete target.
The dependency `CJPAdController (from `https://github.com/nabeelarif100/CJPAdController.git`)` is not used in any concrete target.
The dependency `ECSlidingViewController (~> 2.0.3)` is not used in any concrete target.
The dependency `VGParallaxHeader` is not used in any concrete target.
The dependency `EMString` is not used in any concrete target.
The dependency `Google/SignIn` is not used in any concrete target.
The dependency `VIPhotoView (~> 0.1)` is not used in any concrete target.
The dependency `EncryptedCoreData (from `https://github.com/project-imas/encrypted-core-data.git`)` is not used in any concrete target.
MacBook-Pro:iOS-TuneIn home$
</code></pre>
<p>Podfile:</p>
<pre><code>source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'AFNetworking', '2.6.3'
pod 'MBProgressHUD', '~> 0.9.1'
pod 'PDKeychainBindingsController', '~> 0.0.1'
pod 'FMDB/SQLCipher'
pod 'ZXingObjC', '~> 3.1.0'
pod 'SDWebImage', '~>3.7.2'
pod 'SignalR-ObjC','~>2.0.0.beta3'
pod 'CJPAdController', :git => 'https://github.com/nabeelarif100/CJPAdController.git'
pod 'ECSlidingViewController', '~> 2.0.3'
pod 'VGParallaxHeader'
pod 'EMString'
pod 'Google/SignIn'
pod 'VIPhotoView', '~> 0.1'
pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
</code></pre>
|
<ios><cocoapods>
|
2016-01-01 14:30:01
|
HQ
|
34,558,002
|
Haskell Stack Ghci test-suite
|
<p>I'm trying to use stack to load my test-suite in ghci and have it load the QuickCheck and hspec dependency.</p>
<p>How can I do this?</p>
<p>I'm using the franklinchen template. <br />
<a href="https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles">https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles</a></p>
<p>I have tried <br />
stack ghci spec <br />
stack ghci test-suite <br />
stack ghci --main-is spec <br /></p>
<p>I modified the test-suite spec to target the main-is: LibSpec.hs file</p>
<pre><code>test-suite spec
default-language: Haskell2010
ghc-options: -Wall
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: LibSpec.hs
build-depends: base
, chapterexercises
, hspec
, QuickCheck
</code></pre>
|
<haskell><cabal><haskell-stack>
|
2016-01-01 16:48:38
|
HQ
|
34,558,390
|
Why does the reverse() function in the Swift standard library return ReverseRandomAccessCollection?
|
<p>Now that I've learned Swift (to a reasonable level) I'm trying to get to grips with the standard library, but in truth it's mainly ελληνικά to me!</p>
<p>So a specific question: I have an array of strings and I can call reverse() on it.</p>
<pre><code>let arr = ["Mykonos", "Rhodes", "Naxos"].reverse()
</code></pre>
<p>Now naively I thought I'd get back a type of Array from this. (Ruby for example has a similar method that you pass an array and get back an array)</p>
<p>But arr is now actually of type</p>
<pre><code>ReverseRandomAccessCollection<Array<String>>
</code></pre>
<p>which is actually a struct, which conforms to CollectionType:</p>
<pre><code>public struct ReverseRandomAccessCollection<Base : CollectionType where Base.Index : RandomAccessIndexType> : _ReverseCollectionType
</code></pre>
<p>This means I can do this:</p>
<pre><code>for item in arr {
print(item)
}
</code></pre>
<p>but I can't do</p>
<pre><code>print(arr[0])
</code></pre>
<p>Why is this designed to be this way?</p>
<p>Dictionaries in Swift also implement CollectionType, so I can do this:</p>
<pre><code>let dict = ["greek" : "swift sometimes", "notgreek" : "ruby for this example"].reverse()
</code></pre>
<p>But dictionaries are not ordered like arrays, so why can I call reverse() on dicts?</p>
<p>Bonus points if anyone can point me in the direction of where I can read up and improve my Swift stdlib foo, Ευχαριστώ!</p>
|
<arrays><swift><standard-library>
|
2016-01-01 17:35:31
|
HQ
|
34,558,996
|
eb deploy does not update the code
|
<p>I am trying to deploy an application version but <code>eb deploy</code> command fails with: </p>
<blockquote>
<p>ERROR: Update environment operation is complete, but with errors. For
more information, see troubleshooting documentation.</p>
</blockquote>
<p>I checked the logs, made some changes to the code, committed and deployed again and guess what, it failed again. The logs indicate the same error, disregarding my changes. The error occurs in a file in this directory <code>/var/app/ondeck/app/</code>, when I go check, I can see the previous version is there. </p>
<p>I tried deploying using the Elastic Beanstalk dashboard, but somehow the instance is not receiving the new version. Can someone help me with this? Thanks.</p>
|
<amazon-web-services><amazon-ec2><amazon-elastic-beanstalk>
|
2016-01-01 18:52:16
|
HQ
|
34,559,058
|
How to create a function that returns a byte array in C++? Arduino project.
|
I am currently starting to learn C++ via Arduino programming. I am programming an 8*8 LED Matrix, and currently have a semi-working code that uses a joystick to control a dot on screen. Only problem is: its nearly 1000 lines long. It's equivalent to writing an 1000 page essay only saying "Pig, blanket, market" over and over again until I get to the actual logic involved.
My friend suggested to make it shorter, I could make a function which returns a byte.
How does one do this?
http://pastebin.com/8ud9ny2U <-- This is my code. !WARNING! Not a pretty code. At all.
Help is much appreciated.
|
<c++><arduino>
|
2016-01-01 18:59:11
|
LQ_EDIT
|
34,559,458
|
bluebird.js vs bluebird.core.js what is the difference?
|
<p>What is the difference between bluebird.js and bluebird.core.js? </p>
<p>When should I use bluebird.core.js instead of bluebird.js? </p>
<p>I haven't been able to find anything in the <a href="http://bluebirdjs.com/docs/getting-started.html">bluebird site</a> or elsewhere.</p>
|
<bluebird>
|
2016-01-01 19:49:23
|
HQ
|
34,559,553
|
Create a temporary directory in PowerShell?
|
<p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2015/08/05/create-temporary-files-with-powershell-5-0.aspx" rel="noreferrer">PowerShell 5 introduces the <code>New-TemporaryFile</code> cmdlet</a>, which is handy. How can I do the same thing but instead of a file create a directory? Is there a <code>New-TemporaryDirectory</code> cmdlet?</p>
|
<powershell><temporary-directory>
|
2016-01-01 19:59:35
|
HQ
|
34,559,616
|
how to make sure a file's integrity in C#
|
<p>I am deploying a file along with a C# application. And I want to make sure that file is same as it was supplied otherwise the C# application will show error. Now, a file's creation and modification date can be changed after it is modified. Is there any checksum/hash etc. in C# to make sure file is not changed by user.</p>
|
<c#><.net>
|
2016-01-01 20:10:18
|
LQ_CLOSE
|
34,559,807
|
Stopwatch and ReadKey doesn't work properly
|
I'm working on my multi threading password cracker, only numbers. It must show the how much time has passed to find the password. I used Stopwatch to find it, but in functions, stopwatch doesn't works..
here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int psw = 14995399;
Stopwatch time = new Stopwatch();
Thread Thread1 = new Thread(islem1);
Thread Thread2 = new Thread(islem2);
Thread Thread3 = new Thread(islem3);
Thread Thread4 = new Thread(islem4);
time.Start();
Thread1.Start();
Thread2.Start();
Thread3.Start();
Thread4.Start();
Thread.Sleep(1000);
time.Stop();
System.Console.WriteLine("Time elapsed: {0}", time.Elapsed);
Console.ReadKey();
}
static void islem1()
{
for (int i = 00000000; i < 25000000; i++)
{
int psw = 14995399;
if (i == psw)
{
System.Console.WriteLine("Şifre=" + i);
time.Stop();
Console.WriteLine("Time elapsed: {0}", time.Elapsed);
Console.ReadKey();
}
}
}
static void islem2()
{
for (int i = 25000000; i < 50000000; i++)
{
int psw = 14995399;
if (i == psw)
{
System.Console.WriteLine("Şifre=" + i);
time.Stop();
Console.WriteLine("Time elapsed: {0}", time.Elapsed);
Console.ReadKey();
}
}
}
static void islem3()
{
for (int i = 50000000; i < 75000000; i++)
{
int psw = 14995399;
if (i == psw)
{
System.Console.WriteLine("Şifre=" + i);
time.Stop();
Console.WriteLine("Time elapsed: {0}", time.Elapsed);
Console.ReadKey();
}
}
}
static void islem4()
{
for (int i = 75000000; i < 100000000; i++)
{
int psw = 14995399;
if (i == psw)
{
System.Console.WriteLine("Şifre=" + i);
time.Stop();
Console.WriteLine("Time elapsed: {0}", time.Elapsed);
Console.ReadKey();
}
}
}
}
}
|
<c#><multithreading><stopwatch><console.readkey>
|
2016-01-01 20:33:57
|
LQ_EDIT
|
34,560,087
|
Vbscript email attachment
|
I'm writing a vbscript to send email notification when file arrives in Test folder
I want to attach that file to my email.please help
The file name is not constant,each time a file arrives with different name.
Below is my code
Const PATH = "F:\Test"
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim folder: set folder = fso.getFolder(PATH)
if folder.files.Count <> 0 then
strSMTPFrom = "errorfile@test.com"
strSMTPTo = "test@test.com"
strSMTPRelay = "127.0.0.1"
strTextBody = "The attached file arrived in Test folder"
strSubject = "File arrived in Test folder"
strAttachment =
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
oMessage.AddAttachment strAttachment
oMessage.Send
end if
|
<vbscript>
|
2016-01-01 21:10:21
|
LQ_EDIT
|
34,560,768
|
Can I throw from class init() in Swift with constant string loaded from file?
|
<p>I'd like my class <em>init()</em> in Swift to throw an error if something goes wrong with loading a file into a string within the class. Once the file is loaded, the string will not be altered, so I would prefer to use <em>let</em>. This works:</p>
<pre><code>class FileClass {
var text: NSString = ""
init() throws {
do {
text = try NSString( contentsOfFile: "/Users/me/file.txt", encoding: NSUTF8StringEncoding ) }
catch let error as NSError {
text = ""
throw error
}
}
}
</code></pre>
<p>but when I replace</p>
<pre><code>var text: NSString = ""
</code></pre>
<p>with</p>
<pre><code>let text: NSString
</code></pre>
<p>I get an <strong>All stored properties of a class instance must be initialized before throwing from an initializer</strong> error.</p>
<p>I've tried various approaches such as to make <em>text</em> optional</p>
<pre><code>let text: NSString?
</code></pre>
<p>but haven't found any that work. It it possible to have <em>text</em> be loaded from a file, immutable, and for <em>init()</em> to throw an error? Can I have my cake and eat it three?</p>
<p>Many thanks in advance!</p>
|
<swift>
|
2016-01-01 22:42:24
|
HQ
|
34,560,942
|
C# - Count a specific word in richTextBox1 and send the result to label1
|
<p>I'm not sure, if this question is unique, but I couldn't find the answer that I was looking for.</p>
<p>I simply need a C# code that counts how many times a word appear in richTextBox1 and send the result to label1.</p>
<p>Example;
label1.text = how many times the word "house" appears in richTextBox1.</p>
<p>I know that I should try first but believe me I tried and I failed. I am new to this so I hope someone can show me.</p>
<p>Regards</p>
|
<c#>
|
2016-01-01 23:06:53
|
LQ_CLOSE
|
34,561,323
|
Android: Create bigger Floating Action Button with bigger icon
|
<p>I want to create a bigger Floating Action Button (FAB), more than the usual 56 dp, with a bigger icon inside.
(For my purpose an icon will never be self-explanatory so I will create a png-file containing a short text and use this png as icon.)</p>
<p>Increasing the size of the FAB works fine:<br>
as i don't use the mini-FloatingActionButton, i redefined the mini-button-size.<br>
in my <strong>layout-xml</strong> i specify: </p>
<pre><code><android.support.design.widget.FloatingActionButton
...
app:fabSize="mini"
....
</code></pre>
<p>and in the <strong>dimensions.xml</strong> i redefine the size for the mini-fab: </p>
<pre><code><dimen name="fab_size_mini">80dp</dimen>
</code></pre>
<p>However, I didn't manage to get a bigger icon on the FAB.
I tried icons with different dp's from the material icons library - no success. Also setting a padding on the FAB-layout did not work.</p>
<p>Any suggestions? Thanks!</p>
|
<android><floating-action-button>
|
2016-01-02 00:00:48
|
HQ
|
34,561,614
|
Should I use the final modifier when declaring case classes?
|
<p>According to <a href="https://github.com/puffnfresh/wartremover">scala-wartremover</a> static analysis tool I have to put "final" in front of every case classes I create: error message says "case classes must be final".</p>
<p>According to <a href="https://github.com/sksamuel/scapegoat">scapegoat</a> (another static analysis tool for Scala) instead I shouldn't (error message: "Redundant final modifier on case class")</p>
<p>Who is right, and why?</p>
|
<scala><static-analysis><case-class><scala-wartremover>
|
2016-01-02 01:07:31
|
HQ
|
34,561,843
|
I need to create an array with numbers given by the user
|
System.out.println("Please enter a coefficients of a polynomial’s terms:");
String coefficents = keyboard.nextLine();
String[] three = coefficents.split(" ");
int[] intArray1 = new int[three.length];
//Does anyone know how i can make this work because right not it builds but when i run it, it gives me [I@33909752
//if someone could show me or explain to me what's wrong that would help
|
<java><arrays><compiler-errors>
|
2016-01-02 01:54:04
|
LQ_EDIT
|
34,562,200
|
How do I make the Kotlin compiler treat warnings as errors?
|
<p>I have a Kotlin project where I'd like to have Kotlin warnings treated as errors. How can I do that?</p>
|
<kotlin>
|
2016-01-02 03:06:44
|
HQ
|
34,562,551
|
c++ vector type function implemetation
|
class City
{
private:
int id;
string name;
int populations;
int nooftourist;
vector<Attraction*>&attractions;
public:
City(int id,string name,int populations,int nooftourist):id(id),name(name),populations(populations),nooftourist(nooftourist){}
void setId(int _id);
void setName(string _name);
int getId();
string getName();
void display(){}
vector<Attraction*>getAttractions() { return attractions;}
};
what wrong with my program,i dont understand the vector type function
|
<c++>
|
2016-01-02 04:17:27
|
LQ_EDIT
|
34,562,708
|
Java and enum [Novice]
|
<p>I've got ome fail in java enums;</p>
<p>I'd like to have individual id number for specified enum created, but number seems to propagate to next enum object unfortunately.
Look at my case:</p>
<pre><code>enum type{ int i;}
int id=1;
type t1.i=id;
id=2;
type t2.i=id;
</code></pre>
<p>But t1 has got t2 id number, but I want to have different id's.</p>
<p>Is there any solution in this case ?</p>
<p>I inform that it's simplification of my case and I can't change enum type to class.</p>
|
<java><enums><integer><int>
|
2016-01-02 04:48:51
|
LQ_CLOSE
|
34,562,730
|
Difference between uwsgi_pass and proxy_pass in Nginx?
|
<p>I'm running uWSGI behind Nginx and have been using <code>proxy_pass</code> to get Nginx to hit uWSGI. Is there any benefit to switch to <code>uwsgi_pass</code>. If so, what is it?</p>
|
<nginx><uwsgi>
|
2016-01-02 04:54:12
|
HQ
|
34,562,879
|
How to play gif in android from url?
|
<p>I want to play animated gif from url in android app like imgur app. Imagur is superb and very fast. I am loading gif with webview but its not up to the mark.</p>
|
<android><animated-gif>
|
2016-01-02 05:21:15
|
HQ
|
34,563,750
|
undefined reference to SIGN in C using GCC
|
<p>Many questions have been asked here about functions from math.h not being found in C code during compilation and I am facing a similar problem. Having gone through all of them, none seems to apply to my problem. I have some C code in a file called test1.c - </p>
<pre><code>#include <math.h>
int main(void) {
int j = SQR(4);
int i = (int)(sqrt(16.0));
}
</code></pre>
<p>Now, I compile this using - </p>
<pre><code>gcc -c -o ../../obj/test1.o test1.c -I../../include
</code></pre>
<p>And it produces the .o file. </p>
<p>Now, I try and create the executable using - </p>
<pre><code>gcc -o ../../bin/test1../../obj/test1.o -I../../include -lm
</code></pre>
<p>But this gives me the error below (most previous questions were solved by the -lm switch but I have that) - </p>
<pre><code>../../obj/test1.o:test1.c:(.text+0x13): undefined reference to `SQR'
../../obj/test1.o:test1.c:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SQR'
</code></pre>
<p>Strangely, sqrt works but a host of other functions like SQR, SIGN etc lead to problems (the case doesn't matter). Note that these commands were generated by a make file - </p>
<pre><code>IDIR =../../include
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=../../obj
LDIR =../../lib
LIBS=-lm
_DEPS = nrutil.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = test1.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
../../bin/svdcmp: $(OBJ)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
</code></pre>
<p>I'm using Cygwin with Windows.</p>
|
<c><makefile>
|
2016-01-02 07:39:41
|
LQ_CLOSE
|
34,563,884
|
What does the double backslash mean in a function parameter in Elixir?
|
<p>I recently came across a code snippet such as:</p>
<pre><code>def loop(ring_pid \\ self, nil, true) do
#some code
end
</code></pre>
<p>What do the double backslashes mean? I googled around and found <a href="http://elixir-lang.org/getting-started/sigils.html" rel="noreferrer">http://elixir-lang.org/getting-started/sigils.html</a>, but that applies to regular expressions not function params.</p>
|
<elixir>
|
2016-01-02 08:01:51
|
HQ
|
34,563,947
|
Sending a positive octet of zero bits over a socket
|
I am currently attempting to communicate with an external application over TCP/IP based socket. I have successfully established a connection with the client and received some data. This manual [here][1] states that
> After this command is received, the client must read an acknowledgement
> octet from the daemon. A positive acknowledgement is an octet of zero bits. A negative acknowledgement is an octet of any other pattern.
I would like to send a positive acknowledgment and I am sending it this way
void WriteData(std::string content)
{
send(newsockfd,content.c_str(),content.length(),0);
}
WriteData("00000000");
My question is if I am sending this data corectly ?
[1]: https://www.ietf.org/rfc/rfc1179.txt
|
<linux><sockets><c++11>
|
2016-01-02 08:15:10
|
LQ_EDIT
|
34,564,198
|
any one can help me with this sql syntax error? what should i use near the select statement
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Len(Trim(TextBox1.Text)) = 0 Then
MsgBox("Please Enter Current Odometer For Specified Vehicle", MsgBoxStyle.Critical, "Error")
TextBox1.Focus()
Else
Dim time As DateTime = DateTimePicker1.Value.Date
Dim format As String = "yy-MM-dd"
Dim newdate = time.ToString(format)
Dim SQLStatement As String = "IF EXISTS (SELECT * FROM services_list WHERE vehicle_id='" & Label7.Text & "' AND service='" & ComboBox1.Text & "') BEGIN UPDATE services_list Set service_date='" & newdate & "', note='" & RichTextBox1.Text & "', odometer='" & TextBox1.Text & "' WHERE vehicle_id='" & Label7.Text & "' AND service='" & ComboBox1.Text & "' End Else BEGIN INSERT INTO services_list(vehicle_id,service,service_date,note,odometer,milesorkm) VALUES('" & Label7.Text & "', '" & ComboBox1.Text & "', '" & newdate & "', '" & RichTextBox1.Text & "', '" & TextBox1.Text & "', '" & Label8.Text & "') END"
Dim Query2 As String = "Select * from customers_cars where vin_number='" & ComboBox3.Text & "'"
Dim cmd As MySqlCommand = New MySqlCommand(Query2, MySqlConn)
Reader = cmd.ExecuteReader
Try
While Reader.Read()
Dim lastod = Reader.GetInt32("last_visit_odometer").ToString
Label9.Text = lastod
If TextBox1.Text <= Label9.Text Then
MsgBox("Incorrect Odometer")
Else
Reader.Dispose()
cmd.CommandText = SQLStatement
cmd.CommandType = CommandType.Text
cmd.Connection = MySqlConn
cmd.ExecuteNonQuery()
MsgBox("Successfully Added!")
End If
Reader.Dispose()
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
|
<mysql><vb.net>
|
2016-01-02 08:57:04
|
LQ_EDIT
|
34,564,253
|
How to make Xcode automatically conform to a protocol
|
<p>When I use a prototype table view, I always have to conform to the protocol <code>TableViewDataSource</code>. I always forget what methods I need to implement, so I have to look at the source of the protocol every time. This is really time consuming.</p>
<p>I think Xcode must have a feature that automatically implements the needed methods for you, right? Just like IntelliJ IDEA, Eclipse, and Visual Studio.</p>
<p>I want to know where can I find this feature. If there's isn't, is there a workaround for this? At least I don't have to open the source code of the protocol each time I conform to it.</p>
<p>If you don't understand what I mean, here's some code:</p>
<p>I have a protocol</p>
<pre><code>protocol Hello {
func doStuff ()
}
</code></pre>
<p>When I conform to it,</p>
<pre><code>class MyClass: Hello {
}
</code></pre>
<p>I often don't remember the names of the methods that I need to implement. If Xcode has a feature that turns the above code, into this:</p>
<pre><code>class MyClass: Hello {
func doStuff () {
code
}
}
</code></pre>
<p>Now you understand what I mean? I just want to ask where to find such a feature.</p>
|
<ios><xcode><swift><interface><code-generation>
|
2016-01-02 09:05:27
|
HQ
|
34,564,466
|
java mongodb driver how do you catch exceptions?
|
<p>I want to be able to detect if a mongo server is available from the java driver for the purpose of reacting to any abnormal events as one would in JDBC land etc. It all works fine when the server is up but I am struggling to understand why it is so difficult to detect errors. I have a feeling its because the mongo client runs in a different thread and it doesn't re throw to me or something?</p>
<pre><code>try {
MongoClient mongoClient = new MongoClient("localhost", 27017);
MongoDatabase db = mongoClient.getDatabase("mydb");
// if db is down or error getting people collection handle it in catch block
MongoCollection<Document> people = commentarr.getCollection("people");
} catch (Exception e) {
// handle server down or failed query here.
}
</code></pre>
<p>The result is </p>
<pre><code>INFO: Exception in monitor thread while connecting to server localhost:27017
</code></pre>
<p>With the resulting stack trace containing a few different exceptions which I have tried to catch but my catch blocks still didn't do anything.</p>
<pre><code>com.mongodb.MongoSocketOpenException: Exception opening socket
Caused by: java.net.ConnectException: Connection refused
</code></pre>
<p>I am using the java mongodb driver 3.0.4, most posts I read are from an older API with hacks like <code>MongoClient.getDatabaseNames()</code> which throws a <code>MongoException</code> if errors, except this is deprecated now and replaced with <code>MongoClient.listDatabaseNames()</code> which doesn't have the same error throwing semantics.</p>
<p>Is there a way to just execute a mongo query from the java driver in a try catch block and actually have the exception caught?</p>
|
<mongodb-java>
|
2016-01-02 09:36:26
|
HQ
|
34,564,543
|
Android Studio Import Failing
|
Ok guys i am trying to implement spinner in in Android Studio
These are my imports
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
This is my java. Here I get the the setOnItemSelectedListner in red and says cannot be resolved. I am importing it above despite that it is showing. What could be the issue.
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListner(this);
The whole code is like this....
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView.OnItemSelectedListener;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListner(this);
List<String> categories = new ArrayList<String>();
categories.add("Automobile");
categories.add("Business Services");
categories.add("Computers");
categories.add("Education");
categories.add("Personal");
categories.add("Travel");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
|
<java><android><android-layout><android-studio><android-spinner>
|
2016-01-02 09:46:27
|
LQ_EDIT
|
34,565,520
|
Is it possible to track user activity in his iDevice
|
As the title Describe to Track,
Is it possible to track every activity of a user in his iphone and display it
For example - A user "X" unlock his iphone(slide to unlock)<br> then he make a call after that played a game<br> then open a camera and taken a picture <br>then enter some reminder<br> and finally he close / lock his iphone
The challenge is to display all details when user unlock his phone, lock his phone and other activity he has done in his iphone<br>
[Example - user open a UITableView application where the tableview data is populated with those activity like the image below<br>
..........
any link or any tutorial for reference
Thanks you in advance friends
[![UITableView][1]][1]
[1]: http://i.stack.imgur.com/zSENr.png
|
<ios><swift><uitableview>
|
2016-01-02 11:46:28
|
LQ_EDIT
|
34,565,872
|
How to delete compiled JS files from previous typescript(.ts) files?
|
<p>I am following <a href="https://angular.io/docs/ts/latest/quickstart.html" rel="noreferrer">Angular 2 quick start</a> tutorial. Following is my folder structure - </p>
<pre><code>├── gulpfile.js
├── index.html
├── js
| ├── app.component.js
| └── boot.js
├── source
| ├── app.component.ts
| └── boot.ts
├── node_modules
├── module 1
└── module 2
</code></pre>
<p>My typescript files are in <code>source/</code> directory. I'm compiling it to <code>js/</code> directory. I'm using gulp-typescript.</p>
<p>The problem is when I, for example, rename the file <code>boot.ts</code> to <code>bootstrap.ts</code> and compile again, corresponding <code>bootstrap.js</code> file is created but the old <code>boot.js</code> file still remains in the js/ directory.</p>
<p>Now the folder structure looks like following-</p>
<pre><code>├── gulpfile.js
├── index.html
├── js
| ├── app.component.js
| └── bootstrap.js
| └── boot.js
├── source
| ├── app.component.ts
| └── bootstrap.ts
├── node_modules
├── module 1
└── module 2
</code></pre>
<p>I want to delete this <code>boot.js</code> autonomically via gulp task. How to achieve this?</p>
|
<javascript><typescript><gulp><angular>
|
2016-01-02 12:27:46
|
HQ
|
34,566,061
|
AndroidStudio show usage of RAM
|
<p>I have seen on other AndroidStudio-pictures, that there is a RAM usage at the right bottom. I tried to setup this statuslist o the bottom. But a rightclick didn`t help me. How can I switch on the RAM usage in AndroidStudio ?</p>
|
<android-studio><ram>
|
2016-01-02 12:49:51
|
HQ
|
34,566,063
|
Why is the const&& overload of as_const deleted?
|
<p>On a <a href="http://talesofcpp.fusionfenix.com/post-23/interlude" rel="noreferrer">blog on the progress of C++17</a> I read the following:</p>
<blockquote>
<p><code>P0007</code> proposes a helper function template <code>as_const</code>, which simply
takes a reference and returns it as a reference to <code>const</code>.</p>
<pre><code>template <typename T> std::add_const_t<T>& as_const(T& t) { return t }
template <typename T> void as_const(T const&&) = delete;
</code></pre>
</blockquote>
<p>Why is the <code>const&&</code> overload deleted?</p>
|
<c++><templates><constants><c++17>
|
2016-01-02 12:49:53
|
HQ
|
34,566,111
|
How to backspace or delete?
|
<p>In Windows 10, when I launch MS PowerShell to ssh through a container in Kitematic at windows, I've noticed that I can't backspace or delete, instead I get ^H for backspace instead of actually delete previous character.</p>
<p>Do I miss something?</p>
|
<powershell><docker><kitematic>
|
2016-01-02 12:55:12
|
HQ
|
34,566,113
|
Has set been deprecated in python 2?
|
<p>Has <code>set</code> been deprecated in python?</p>
<p>I am learning python online <a href="http://www.python-course.eu/sets_frozensets.php" rel="nofollow">here</a> and trying to implement the following command - </p>
<pre><code>x = set(["Perl", "Python", "Java"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
</code></pre>
<p>So has it been deprecated in python 2.7?</p>
|
<python><python-2.7>
|
2016-01-02 12:55:17
|
LQ_CLOSE
|
34,566,176
|
visualvm fails with "No jdkhome found" on Ubuntu 15.10 with Oracle JDK
|
<p>I installed Oracle JDK from the <code>webupd8team/java</code> PPA, and then installed the <code>visualvm</code> package. When starting <code>visualvm</code>, I get the following error message:</p>
<pre><code>[beni:~]$ visualvm
No jdkhome found
</code></pre>
<p>My <code>$JAVA_HOME</code> is set correctly to <code>/usr/lib/jvm/java-7-oracle</code>.</p>
<p>Also, when starting <code>visualvm</code> with the <code>jdkhome</code> property set, I get the same error:</p>
<pre><code>[beni:~]$ visualvm --jdkhome $JAVA_HOME
No jdkhome found
</code></pre>
|
<java><visualvm><oraclejdk>
|
2016-01-02 13:00:27
|
HQ
|
34,566,364
|
japanese and portuguese language cannot support
|
My site Japanese supported. But Portuguese language cannot fully display
Display on In�Cio Sobre N�S.
I have use for header('Content-type: text/html; charset=UTF-8') ;
this only Japanese language support.
I need to both language (Japanese and Portuguese) should be display.
I need to helper for best solution.
Thanks,
|
<php>
|
2016-01-02 13:20:49
|
LQ_EDIT
|
34,566,633
|
Display simple text on vertices
|
<p>So I am trying to make a simple program (I'm a student) and it works fine so far, but I can't figure out how to display the "i" value from the loop in the drawCircle() function in Shapes.cpp </p>
<p>code:</p>
<p><a href="http://pastebin.com/4kDPNjy8" rel="nofollow noreferrer">http://pastebin.com/4kDPNjy8</a></p>
<p>example:
<a href="https://i.stack.imgur.com/Me9kV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Me9kV.png" alt="enter image description here"></a></p>
<p>When I compile my code right now it looks like on the image to the left, but I want to get something like on the right but I have no idea how to do that kind of stuff or what function should I use for that.</p>
<p>Please help </p>
|
<c++><opengl><glut><glew>
|
2016-01-02 13:54:08
|
LQ_CLOSE
|
34,566,697
|
Set ImageView from Real path
|
I have the real path of an image which I am retrieving from my Database. I want to set the imageView using the real path (/storage/emulated/0/DCIM/100MEDIA/image.jpg)
How can this be done.
public void getIMG(){
Cursor res = myDb.GetRow(id);
if(res.moveToFirst()){
String path = res.getString(DatabaseHelper.ROWIMG);
/*img.set'???'*/
}
}
|
<java><android><imageview>
|
2016-01-02 14:00:28
|
LQ_EDIT
|
34,566,724
|
Precision issues with dlmwrite / dlmread
|
<p>I recently discovered, quite harshly, that Matlab's <code>dlmread</code> and <code>dlmwrite</code> don't store numerical values at <code>double</code> accuracy. It effects my code, and I need to store big arrays with more precision.</p>
<p>A (not) working example : </p>
<pre><code>pi1 = pi;
dlmwrite('pi',pi1);
pi2 = dlmread('pi');
pi1-pi2
ans =
-7.3464e-06
</code></pre>
<p>While I'd expect machine-error answer, of 10^-14 accuracy.</p>
<p>I'd much rather keep using a simple function as <code>dlmwrite</code>, but I will consider other solutions.</p>
<p>Thanks</p>
|
<matlab><double><precision><writefile>
|
2016-01-02 14:03:03
|
LQ_CLOSE
|
34,566,806
|
Why use contextlib.suppress as opposed to try/except with pass?
|
<p>Why would one use <a href="https://docs.python.org/3/library/contextlib.html#contextlib.suppress"><code>contextlib.suppress</code></a> to suppress an exception, instead of <code>try</code>/<code>except</code> with a <code>pass</code>?</p>
<p>There is no difference in the amount of characters between these two methods (if anything, <code>suppress</code> has more characters), and even though code is often counted in LOC instead of characters, <code>suppress</code> also seems to be much slower than <code>try</code>/<code>except</code> in both cases, when an error is raised and when it's not:</p>
<pre><code>Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from timeit import timeit
>>> # With an error
>>> timeit("""with suppress(ValueError):
x = int('a')""", setup="from contextlib import suppress")
1.9571568971892543
>>> timeit("""try:
x = int('a')
except ValueError:
pass""")
1.0758466499161656
>>> # With no error
>>> timeit("""with suppress(ValueError):
x = int(3)""", setup="from contextlib import suppress")
0.7513525708063895
>>> timeit("""try:
x = int(3)
except ValueError:
pass""")
0.10141028937128027
>>>
</code></pre>
|
<python><python-3.x>
|
2016-01-02 14:13:03
|
HQ
|
34,566,901
|
In Android Studio 2.0, Cannot find local variable of method in debug mode
|
<p>After Updating the android version 1.5 to 2.0 Preview4. Android studio Debugger unable to find the local variable defined in method definition. For reference, find the below screenshot.</p>
<p><a href="https://i.stack.imgur.com/U971h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U971h.png" alt="enter image description here"></a></p>
|
<android><android-studio><gradle>
|
2016-01-02 14:23:05
|
HQ
|
34,566,903
|
reading data from serial port c#
|
I'm trying to read char from port. writing to the port works perfectly, reading - not so much.
here is my code:
private void Com_Port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
char val;
try
{
val = Convert.ToChar(Com_Port.ReadByte()); // get the new byte from port
label6.Text = Convert.ToString(val);
}
catch (Exception) { }
}
cracking my head over it for the past 4 hours.
|
<c#><serial-port>
|
2016-01-02 14:23:21
|
LQ_EDIT
|
34,566,999
|
Cannot resolve symbol 'RequestQueue'
|
<p>I am new to android studio and volley library so please bear with me.</p>
<p>I've added volley library by GitHub and then and added this line to build gradle file: compile 'com.android.support:appcompat-v7:23.0.1'</p>
<p>And now I am trying some tutorials about request and response from api, but for some reason I cannot make an instance of RequestQueue why?
I am using Android 4.0.3 IceCreamSandwish</p>
<p>Thank you</p>
|
<android><android-studio><android-volley>
|
2016-01-02 14:32:46
|
HQ
|
34,567,027
|
Shell script to mail script output in table format
|
<p>I am new to shell script. I need your help on below scenario.</p>
<p>Script: wc file1 file2 file3 file4</p>
<pre><code>results :
1488 2977 2248 file1
123 345 657 file2
123 896 456 file3
567 987 124 file4
</code></pre>
<p>Now I need to mail this result in below format with header name</p>
<p>Here,2nd column is always default value.</p>
<pre><code>Filename Destname rowcount bytesize
file1 default 1488 2248
file2 default 123 657
file3 default 123 456
file4 default 567 124
</code></pre>
<p>Please some one help me to write this script.</p>
|
<linux><bash><shell>
|
2016-01-02 14:34:26
|
LQ_CLOSE
|
34,567,743
|
Duplicate file is getting created in linux
|
<p>I created a file called <code>file2.txt</code> in Linux, opened it in text editor and saved it. When I closed the text editor I see two files <code>file2.txt</code> and <code>file2.txt~</code></p>
<p>I guess <code>file2.txt~</code> is temporary file created when I am editing the <code>file2.txt</code> but it should get removed when I finished saving and closed text editor.</p>
|
<linux>
|
2016-01-02 15:54:44
|
LQ_CLOSE
|
34,568,008
|
How do I run webpack from SBT
|
<p>I'm developing a Play 2.4 application and would like SBT to run webpack to generate static assets during compilation. </p>
<p>I tried <a href="https://github.com/stejskal/sbt-webpack">https://github.com/stejskal/sbt-webpack</a> but it does't seem to work for me.</p>
|
<playframework><sbt><webpack>
|
2016-01-02 16:26:08
|
HQ
|
34,568,011
|
Add an element on the last Jekyll loop of posts
|
<p>I'm sure this is simple but cant find the answer.</p>
<p>There is a standard Jekyll/Liquid post iterator. How do i use the <code>{% if %}</code> statement below to put the <code><hr></code> element for each post <strong>except</strong> the last?</p>
<pre><code><ul class="post-list">
{% for post in site.posts %}
{% if post.url %}
<br>
<li>
<h2>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
</li>
**** {% if post != $last %} ***** How do i do this??
<hr>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</code></pre>
|
<jekyll><liquid>
|
2016-01-02 16:26:18
|
HQ
|
34,568,045
|
if..else..if..else code not working properly(coding in C)
|
<p>I have a question.I think I may have a mistake in my code because my code program(Dev C++) seems not to recognize the "else if" statement.</p>
<p>Here is the code:</p>
<pre><code>#include <stdio.h>
int main()
{
int a = 80;
if(a == 10);
printf("value of a is 10\n");
else if(a == 20);
printf("value of a is 20\n");
else if(a == 30);
printf("value of a is 30\n");
else
printf("none of the values match");
printf("the real value of a is: &d", a);
system("PAUSE");
return 0;
}
</code></pre>
|
<c>
|
2016-01-02 16:28:47
|
LQ_CLOSE
|
34,568,493
|
why datepicker is lost after window.print
|
I have to print part of my page by `window.print()`.
Here is the code:
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
I know that copy innerHTML and pasting it after print command can cause lost of event listener. But it can be overcome by a `$('body').on` attachment. But as I am novice to jquery, I do not know how can I use this jquery on method in case of datepicker attachment. So, everytime I print part of my webpage using this type of javascript print method, datepicker is lost and it is not attaching in the desired input fields.
Please visit my site to check the situation:
[http://infomamun.xyz][1]
and click on the `#dob` or other input fields to see the workable datepicker. Then please press `Print` button and cancel or done the print job. After that you can see that there is no datepicker attached on click of `#dob` and other input fields of the table.
How to resolve this issue?
[NB: please don't recommend css print system, I have to use this method. Also, please don't downvote my Question. I am very novice to jquery]
[1]: http://infomamun.xyz
|
<jquery><printing>
|
2016-01-02 17:15:25
|
LQ_EDIT
|
34,569,489
|
Getting proportions from data sets in R
|
<p>I have a data set called 'md' which consists of 40 numbers 1-6, I need to get the proportion that the number 1 appears in the list, I've been looking for ways to get proportions but none of which seem to be relevant to my data set, the proportion is easily calculable, however, it is required to be done in R.</p>
|
<r><statistics>
|
2016-01-02 18:52:40
|
LQ_CLOSE
|
34,569,802
|
Using Java, How do I check using orignal image that if shape01(circle) exists in image02(square) after converting both into binary images?
|
I am newbie to openCV and JAVA. It is been two days I am searching for the solutions continuously.
I want to check form this
[Image][1] that red circle exists inside the square after convert getting following binary images.
See Binary Images of [circle and square][1]
Please help me ASAP. Thanks in advance.
[1]: http://i.stack.imgur.com/WrZXq.png
|
<java><opencv>
|
2016-01-02 19:27:00
|
LQ_EDIT
|
34,570,584
|
Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable
|
<blockquote>
<p>bufferutil@1.2.1 install /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil > <strong>node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable</strong>. gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Linux 3.13.0-74-generic gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: <code>node-gyp rebuild</code> npm WARN install:bufferutil@1.2.1 Exit status 1 > utf-8-validate@1.2.1 install /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/utf-8-validate > node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable. gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Linux 3.13.0-74-generic gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/utf-8-validate gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: <code>node-gyp rebuild</code> npm WARN install:utf-8-validate@1.2.1 Exit status 1</p>
</blockquote>
|
<node.js><polymer-1.0><node-gyp><npm-install>
|
2016-01-02 20:49:23
|
HQ
|
34,570,817
|
Empty atom in Ecto changeset
|
<p>Why in an Ecto <code>changeset</code> method do you set the params to the default <code>:empty</code> atom? e.g.</p>
<pre><code>def changeset(user, params \\ :empty) do
...
</code></pre>
<p>Does this allow you to call the changeset method with nil for params?</p>
|
<elixir><ecto>
|
2016-01-02 21:15:44
|
HQ
|
34,570,992
|
Getting parent of AST node in Python
|
<p>I'm working with Abstract Syntax Trees in Python 3. The <code>ast</code> library gives many ways to get children of the node (you can use <code>iter_child_nodes()</code> or <code>walk()</code>) but no ways to get <strong>parent</strong> of one. Also, every node has links to its children, but it hasn't links to its parent.</p>
<p><strong>How I can get the parent of AST node</strong> if I don't want to write some plugin to <code>ast</code> library?</p>
<p>What is the most correct way to do this?</p>
|
<python><python-3.x><abstract-syntax-tree>
|
2016-01-02 21:38:15
|
HQ
|
34,571,593
|
What is .tpl.html files? (angularjs)
|
<p>I'm doing a angularjs blog tutorial, in the code example I see this new file type "<strong>tpl.html</strong>":</p>
<pre><code>$routeProvider
.when('/', {
templateUrl: 'views/post-list.tpl.html',
controller: 'PostListController',
controllerAs: 'postlist'
})
.when('/post/:postId', {
templateUrl: 'views/post-detail.tpl.html',
controller: 'PostDetailController',
controllerAs: 'postdetail'
})
.when('/new', {
templateUrl: 'views/post-create.tpl.html',
controller: 'PostCreateController',
controllerAs: 'postcreate'
});
</code></pre>
<p>What is this file type? Is different to html files?</p>
|
<html><angularjs>
|
2016-01-02 22:58:22
|
HQ
|
34,572,040
|
Restore a mongo DB from a compose.io backup?
|
<p>If you download a compose.io backup of a mongodb instance and uncompress the .tar file you end up with <code>.ns</code> and extensions that are single digits. How do you restore the db from these?</p>
|
<mongodb><restore><compose>
|
2016-01-03 00:07:13
|
HQ
|
34,572,212
|
Is there a naming convention for C language implementation only (private) constants?
|
<p>Let's say that I am writing a library named <code>my</code>, which has a module <code>myString</code>.</p>
<p>Publicly exposed functions and constants for <code>myString</code> are declared in <code>myString.h</code> with the following convention:</p>
<pre><code>typedef struct myString myString;
extern const size_t MY_STRING_MAX_LEN;
myString *my_string_new();
</code></pre>
<p>Private implementation only functions and struct members are declared in <code>myString.c</code> with the following convention:</p>
<pre><code>_grow_buffer(myString *this);
char *_buffer;
</code></pre>
<p>My question: Is there a similar convention for private, implementation only constants?</p>
<p>For example, <code>_CHUNK_SIZE</code> is what I initially wanted to go with. Then I read that the C language specification says not to use an underscore followed by an uppercase letter at the start of a name, as such names may be used in future versions of the language.</p>
<p>I like using the starting underscore convention, as it removes a lot of verbosity. I could use <code>MY_STRING_CHUNK_SIZE</code> or some variation, but that's not as pretty IMO.</p>
|
<c><naming>
|
2016-01-03 00:34:39
|
LQ_CLOSE
|
34,572,553
|
Django: AttributeError: 'NoneType' object has no attribute 'split'
|
<p>I'm trying to build a static site generator using Django (because its resourceful that way), and right now my problems are dealing with the Django command that is supposed to build my static site content into a directory. Apparently my 'NoneType' object has no attribute 'split', but I dont know what that 'NoneType' object is.</p>
<pre><code>(thisSite) C:\Users\Jaysp_000\thisSite\PROJECTx>python prototype.py build
Traceback (most recent call last):
File "prototype.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\__init__.py",
line 338, in execute_from_command_line
utility.execute()
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\__init__.py",
line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\base.py", lin
e 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\base.py", lin
e 441, in execute
output = self.handle(*args, **options)
File "C:\Users\Jaysp_000\thisSite\PROJECTx\sitebuilder\management\commands\build.py", li
ne 38, in handle
response = this_client_will.get(the_page_url)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 500, in
get
**extra)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 303, in
get
return self.generic('GET', path, secure=secure, **r)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 379, in
generic
return self.request(**r)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 466, in
request
six.reraise(*exc_info)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\utils\six.py", line 659, in r
eraise
raise value
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\handlers\base.py", line
132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Jaysp_000\thisSite\PROJECTx\sitebuilder\views.py", line 35, in page
return render(request, 'page.html', context)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\shortcuts.py", line 67, in re
nder
template_name, context, request=request, using=using)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\template\loader.py", line 99,
in render_to_string
return template.render(context, request)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\template\backends\django.py",
line 74, in render
return self.template.render(context)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\template\base.py", line 208,
in render
with context.bind_template(self):
File "C:\Python34\Lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\template\context.py", line 23
5, in bind_template
updates.update(processor(self.request))
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\template\context_processors.p
y", line 56, in i18n
context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\utils\translation\__init__.py
", line 177, in get_language_bidi
return _trans.get_language_bidi()
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\utils\translation\trans_real.
py", line 263, in get_language_bidi
base_lang = get_language().split('-')[0]
AttributeError: 'NoneType' object has no attribute 'split'
</code></pre>
<p>It seems that my problem lies in my command file, which I call <code>build</code>. The traceback also brings up my <code>views</code> file, which works well on its own (that is, my html files can be properly served on the local server), but I will include it anyway.</p>
<p><strong>build.py</strong></p>
<pre><code>import os, shutil
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.core.urlresolvers import reverse
from django.test.client import Client
def get_pages():
for name in os.listdir(settings.STATIC_PAGES_DIRECTORY):
if name.endswith('.html'):
yield name[:-5]
class Command(BaseCommand):
help = 'Build static site output.'
def handle(self, *args, **options):
"""Request pages and build output."""
if os.path.exists(settings.SITE_OUTPUT_DIRECTORY):
shutil.rmtree(settings.SITE_OUTPUT_DIRECTORY)
os.mkdir(settings.SITE_OUTPUT_DIRECTORY)
os.makedirs(settings.STATIC_ROOT)
call_command('collectstatic', interactive=False, clear=True, verbosity=0)
this_client_will = Client()
for page in get_pages():
the_page_url = reverse('page',kwargs={'slug': page}) # PROBLEM SEEMS TO GENERATE STARTING HERE
response = this_client_will.get(the_page_url)
if page == 'index.html':
output_dir = settings.SITE_OUTPUT_DIRECTORY
else:
output_dir = os.path.join(settings.SITE_OUTPUT_DIRECTORY, page)
os.makedirs(output_dir)
with open(os.path.join(output_dir, 'index.html'), 'wb', encoding='utf8') as f:
f.write(response.content)
</code></pre>
<p><strong>views.py</strong></p>
<pre><code>import os
from django.conf import settings
from django.http import Http404
from django.shortcuts import render
from django.template import Template
from django.utils._os import safe_join
# Create your views here.
def get_page_or_404(name):
"""Returns page content as a Django template or raise 404 error"""
try:
file_path = safe_join(settings.STATIC_PAGES_DIRECTORY, name)
except ValueError:
raise Http404("Page Not Found")
else:
if not os.path.exists(file_path):
raise Http404("Page Not Found")
with open(file_path,"r", encoding='utf8') as f:
the_page = Template(f.read())
return the_page
def page(request, slug='index'):
""" Render the requested page if found """
file_name = '{0}.html'.format(slug)
page = get_page_or_404(file_name)
context = {'slug': slug, 'page': page}
return render(request, 'page.html', context) # THE TRACEBACK POINTS AT THIS LINE, TOO
</code></pre>
<p>and just in case it becomes useful to know, here is my <strong>urls.py</strong>:</p>
<pre><code>from django.conf.urls import include, url
urlpatterns = [
url(r'^page/(?P<slug>[-\w]+)/$', 'sitebuilder.views.page', name='page'),
url(r'^page$', 'sitebuilder.views.page', name='homepage'),
]
</code></pre>
<p>I find this frustrating, primarily because this problem seems to be tied to the reverse() function, as seen in the build module, and I havent had a great time using that function for as long as I can remember, but I dont know if this is really my problem. Can someone help me figure out where my issue is coming from and how to solve it (if you have any tips)? It would be much appreciated.</p>
|
<python><django><python-3.x><static-site><django-commands>
|
2016-01-03 01:41:36
|
HQ
|
34,572,580
|
Get superclass name in ES6
|
<p>I have a class, and another class that extends that class.</p>
<pre><code>class Shape {
constructor() {
return this;
}
}
class Circle extends Shape {
constructor() {
super();
return this;
}
}
let foo = new Circle();
</code></pre>
<p>I can get foo's class with</p>
<pre><code>let className = foo.constructor.name
// returns string 'Circle'
</code></pre>
<p>Is it possible to get the name of foo's superclass ('Shape') in a similar manner?</p>
|
<javascript><ecmascript-6>
|
2016-01-03 01:47:22
|
HQ
|
34,572,659
|
Separate Int from String on file input
|
<p>i was wondering if anyone could help me with a little problem in Java:
I have a file with some equations like:</p>
<pre><code>Z=1X1+3X2
-1X1+5X2<=2
1X1-1X2<=56
</code></pre>
<p>and so on..</p>
<p>and i wanted to read this file and separate the values 1 and 3 (of Z=1X1+3X2) in one string and -1,5,2,1,-1,56 in another.</p>
|
<java>
|
2016-01-03 02:06:21
|
LQ_CLOSE
|
34,573,137
|
Codename one - lib install in NetBeans
|
<p>I have downloaded the library for including Toasts in CN1, but I am not sure how to install/add it to NetBeans.</p>
<p>Could you guide me?</p>
|
<codenameone>
|
2016-01-03 03:47:05
|
LQ_CLOSE
|
34,573,248
|
How to call SOAP web services from AngularJS
|
<p>Is there anyway to call soap web services from angularJS ? is there any service like $http to call SOAP web services?</p>
|
<angularjs><soap>
|
2016-01-03 04:11:07
|
LQ_CLOSE
|
34,573,279
|
How to unzip .gz files in a new directory in hadoop?
|
<p>I have a bunch of .gz files in a folder in hdfs. I want to unzip all of these .gz files to a new folder in hdfs. How should i do this?</p>
|
<hadoop><hdfs><gzip>
|
2016-01-03 04:18:19
|
HQ
|
34,573,527
|
how to Mail script output in table format
|
I am very new to shell scripting. I need your help on below senario.
I have the script output like below.
Filename Destname rowcount bytesize
file1 default 1488 2248
file2 default 123 657
file3 default 123 456
file4 default 567 124
Now I need to mail this ouput in table format with proper indentation. Please help me to write the script for the same.
|
<linux><bash><shell><email>
|
2016-01-03 05:09:08
|
LQ_EDIT
|
34,573,546
|
Linux, Android, Lack of Compatablility with C
|
<p>If android is based on the linux kernel and is basicly a linux distro why can't it run C in front end apps. Why can't you download linux apps onto android with out special compilers and software. Should it not be built into the system. In some way i know it is becuase look at NetHunter. Its Kali backend with android frontend. So how dose this work? (Im a newb with Linux, just starting, need help, looking for a mentor) Are .DEB files cross platform and can i take a linux app and compile it as a .APK and it will work on android? Help me plz</p>
|
<android><c><linux>
|
2016-01-03 05:12:03
|
LQ_CLOSE
|
34,573,779
|
es6 - import all named module without alias
|
<p>I know that we can import all named modules with alias as below, </p>
<pre><code>import * as name from "module-name";
</code></pre>
<p>Ref: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import</a></p>
<p>Actually, I have re-exported my modules in A.js and the same is inherited in B.js. PFB. Now, it's two level of inheritance, so it's not a big deal to import the named modules. But, when I'm taking this to 5 level of inheritance (A -> B -> C -> D -> E), I need to import all named modules in all files and need to do the (re)export the same in all. Instead of doing this, </p>
<ul>
<li>Is there any other way to copy scope of all named modules into all level without reiterating the wheel (Import and Export)</li>
<li>Behind the scene of this design is to make them to follow Opps concept and to avoid the redeclaration of the same modules.</li>
</ul>
<p><strong>A.js</strong> </p>
<pre><code>import React from 'react';
import I18n from 'i18n-js';
import m1 from 'module1';
import m2 from 'module2';
export default class A extends React.Component {}
export {React, I18n, m1, m2)
</code></pre>
<p><strong>B.js</strong></p>
<pre><code>import BaseComponent from './A';
import {React, I18n, m1, m2) from './A;
export default class B extends A {}
</code></pre>
<p>Is there any way to import all named modules without alias like <code>import {*} from './A'</code> (instead of 2nd in B.js) </p>
|
<javascript><reactjs>
|
2016-01-03 05:52:11
|
HQ
|
34,573,813
|
How to Take Database Backup without using phpmyadmin?
|
<p>How can I take backup of all tables of a database from ftp without using phpmyadmin and get the backup as a .sql file ??</p>
|
<php><mysql>
|
2016-01-03 05:57:45
|
LQ_CLOSE
|
34,574,650
|
what's wrong with my while loop code in R?
|
<p>I want to using while loop in R.</p>
<p>I want to repeat loop until evt>1 and cpr>0, but it doesn't work.</p>
<p>work_f is function of generating numbers.</p>
<pre><code>if((evt>1)&&(cpr>0)){
work<-work[order(work$z),]
obs<-c(1:length(work$z))
work<-cbind(work,obs)
} else {
while((evt>1)&&(cpr>0)) {
j<-j+1
seed<-settings*1000+h+j
work_f(studysize = studysize,beta=beta,cutpoint = cutpoint,settings = settigns,p=p,alpha = alpha)
evt<-data.frame(ftable(work$event))
evttr<-data.frame(evt=numeric(1),cpr=numeric(1),csr=numeric(1))
if (p==0) {
evttr$evt<-evt$Freq[1]; evttr$cpr<-evt$Freq[2]; evttr$csr<-0
}else {
evttr$evt<-evt$Freq[2]; evttr$cpr<-evt$Freq[3]; evttr$csr<-evt$Freq[1]
}
evttr[is.na(evttr)]<-0
evt<-as.numeric(evttr$evt); cpr<-as.numeric(evttr$cpr)
if((evt>1)&&(cpr>0)){
work<-work[order(work$z),]
obs<-c(1:length(work$z))
work<-cbind(work,obs)
}
}
}
</code></pre>
<p>What's wrong?</p>
|
<r><while-loop>
|
2016-01-03 08:23:17
|
LQ_CLOSE
|
34,574,785
|
How to display a button when there is no network and make it disappear when connection is available in Android App Development?
|
<p>I am creating an Android app and want to disappear retry button when there is network and it should be visible when there is no network, so the user can retry to load.</p>
|
<android>
|
2016-01-03 08:47:20
|
LQ_CLOSE
|
34,575,047
|
Java - Check if input is of Premitive type
|
I have to check for each **input**, print out if it is an instance of a *primitive or referenced* type. But I am getting same output each time. Any Help?
**Note: I do search SO, but no luck.**
Code:
-----
public class Demo {
public static void main(String[] args) throws IOException {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0; i<9; ++i){
String input = br.readLine();
showPremitive(input);
}
}
public static void showPremitive(Object input){
try{
if (input instanceof Short)
System.out.println("Primitive : short");
else if(input instanceof Integer)
System.out.println("Primitive : int");
else if(input instanceof Long)
System.out.println("Primitive : long");
else if(input instanceof Float)
System.out.println("Primitive : float");
else if(input instanceof Double)
System.out.println("Primitive : double");
else if(input instanceof Boolean)
System.out.println("Primitive : bool");
else if(input instanceof Character)
System.out.println("Primitive : char");
else if(input instanceof Byte)
System.out.println("Primitive : byte");
else
System.out.println("Reference : string");
}
catch (InputMismatchException e){
System.out.println("crashing down"+e);
}
}
}
**Output:**
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
|
<java><primitive-types>
|
2016-01-03 09:27:26
|
LQ_EDIT
|
34,575,066
|
How to prevent CMake from issuing /IMPLIB
|
<p>I have a CMake build that sends /IMPLIB to the linker on Windows. This is a problem in my case because the argument to implib is the same path as one of the input files.
It looks to me that CMake will <em>always</em> issue /IMPLIB when building with Visual Studio, and the passed argument cannot be modified.
Is there a way to control this behaviour?</p>
|
<c++><cmake>
|
2016-01-03 09:30:57
|
HQ
|
34,575,102
|
when website is loaded, get news from txt file
|
<script type="text/javascript">
$(document).ready(function() {
$("body").ready(function() {
$.ajax({
url : "helloworld.txt",
dataType: "text",
success : function (data) {
$(".slider").html(data);
}
});
});
});</script>
I want this code to get HTML code from a txt file and add it in here:
<div class="slider"> <!-- News Slider --> </div>
The txt file contains the following:
<div class="callbacks_container">
<ul class="rslides" id="slider">
<li>
<h2><a href="http://services.runescape.com/m=news/christmas--zeah?oldschool=1">Zeah</a></h2>
<h3><a href="http://services.runescape.com/m=news/christmas--zeah?oldschool=1">New continent, 50% expansion</a></h3>
</li>
<li>
<h2><a href="https://www.facebook.com">Sailing</a></h2>
<h3><a href="https://www.facebook.com">Sail around the world</a></h3>
</li>
<li>
<h2><a href="http://services.runescape.com/m=news/old-school-in-2016?oldschool=1">2016</a></h2>
<h3><a href="http://services.runescape.com/m=news/old-school-in-2016?oldschool=1">Christmas event coming to an end</a></h3>
</li>
</ul>
</div>
The function above doesn't work but i cant find a way to fix this, please help! Thanks!
|
<html><onload>
|
2016-01-03 09:34:54
|
LQ_EDIT
|
34,575,561
|
Automatically run gulp tasks after saving some of javascript files in Visual Studio
|
<p>I have a folder in my asp.net project that contains some javascript files. Just before building project, they are minified and copied to "wwwroot" folder using gulp. It works great, but when I make some changes to any of javascript files, I have to restart entire project (to run tasks connected with building) or manually run tasks from "Task Runner Explorer".</p>
<p>It takes some time and it is quite irritating. Is it some way to run those tasks as soon as I save any of javascript files in this folder?</p>
|
<asp.net><visual-studio><visual-studio-2015><gulp>
|
2016-01-03 10:36:40
|
HQ
|
34,575,753
|
Difference between sprite and texture?
|
<p>Can you please explain the difference between texture and sprite? When we zoom in a sprite, it appears blurry because it's basically an image. Is it the same for a texture?</p>
<p>I read this comment on the image below online: </p>
<blockquote>
<p>The background layers are textures and not sprites.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/Rfr5B.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rfr5B.png" alt="enter image description here"></a></p>
<p>Can someone explain?</p>
|
<image><unity3d><textures><sprite><unity5>
|
2016-01-03 10:59:24
|
HQ
|
34,575,897
|
Passing a component as an 'argument' to another component in Angular 2
|
<p>I am new to web development and I have just started building an Angular 2 app. At this point I am trying to create some CRUD components/forms but I find my self duplicating a lot of code. I am not going to ask what are the common best practices to avoid code duplication and achieve component reusability when designing CRUD applications with Angular2, because the post will get locked. I will rather focus on one particular aspect:</p>
<p>I have a "CRUD page" that has a list (it is an html table actually) of resources and several buttons that open up "create", "read", and "edit" forms. The list is a separate component on its own and the create/read/edit separate components as well. Each row of the table includes another component which knows how to render a resource item. I will call this <code><resource-item></code> component. However, I have several of those "CRUD pages", each page for a different resource. So what I want is to reuse the list component for all the resources. So the first thing to do is to add Inputs or Attributes to the list component in order to control its labels. So far so good. </p>
<p>But what about the <code><resource-item></code> component? Each resource of my application might have a completely different structure. As a result I will need different components for different resources, e.g.: <code><resource-a-item></code>, <code><resource-b-item></code>, etc. How can I specify which resource item component I want to use every time I create a list component?</p>
<p>Thank you for your time.</p>
|
<typescript><angular>
|
2016-01-03 11:17:51
|
HQ
|
34,576,004
|
Simple way to reset Django PostgreSQL database?
|
<p>I was able to reset a Django PostgreSQL database using the following steps:</p>
<ol>
<li>Delete migration files</li>
<li>Enter psql command prompt. Connect to database. drop schema public cascade; create schema public;</li>
<li>Step 2 unfortunately seemed to have removed my user role and rights so I went back to the psql command promt and recreated those.</li>
<li>Step 2 also meant I needed to run the following commands in the psql command prompt: grant usage on schema public to public;
grant create on schema public to public;</li>
<li>Step 2 also deleted the standard Django users I had created so I needed to recreate these</li>
<li>python manage.py makemigrations && python manage.py migrate</li>
</ol>
<p>I am currently making changes to my models and testing each change. I don't have any data I need to keep. Is there an easier way than the above to reset the database when migrations donät work?</p>
<p>I would at least like to replace step 2 with something else so that I can skip steps 3-5.</p>
|
<django><postgresql>
|
2016-01-03 11:28:23
|
HQ
|
34,576,493
|
[Android][Listview] Unable to show my ArrayList data in Listview
|
The question is... I put my data in ArrayList and adding to ListView. But there has no data show on ListView but I am sure those data has been retrieved.
The System output for testing is correct.( my data )
Please solve my question...
There is my partial code:
public class query_page extends AppCompatActivity {
public ArrayList<String> show_Location, show_Messages;
public ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_query_page);
show_Location = new ArrayList<String>();
show_Messages = new ArrayList<String>();
listView = (ListView) findViewById(R.id.listView);
ParseQuery<ParseObject> query = ParseQuery.getQuery("Danger");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
for (ParseObject j : list) {
show_Location.add(j.getString("DangerLocation"));
show_Messages.add(j.getString("DangerMessage"));
System.out.println("Location: " + j.getString("DangerLocation"));
System.out.println("Messages: " + j.getString("DangerMessage"));
}
ArrayAdapter adapter = new ArrayAdapter(query_page.this, android.R.layout.simple_list_item_1, show_Location);
listView.setAdapter(adapter);
} else {
System.out.println("Exception occur! ");
}
}
});
}
}
|
<android><android-layout><arraylist><android-listview><android-adapter>
|
2016-01-03 12:24:16
|
LQ_EDIT
|
34,576,542
|
Python - none returns from try and except clauses
|
<p>the return from this code (date) is 'none' if an invalid entry is provided, then a valid entry is given. However if a valid entry is given first time, the correct return for date is given. Any tips on how I can solve it?</p>
<pre><code>def getDate():
date = input("Please enter the date in DD/MM/YYYY format: ")
try:
strptime(date, "%d/%m/%Y")
return date
except:
print ("Invalid Date, please enter again")
getDate()
</code></pre>
|
<python><function><validation><date><try-except>
|
2016-01-03 12:30:24
|
LQ_CLOSE
|
34,576,637
|
Notepad-like GUI text editor for Linux/Ubuntu (SSH into an Ubuntu Server 14.04 LTS AWS instance)
|
<p>I am not so familiar with Linux/Ubuntu bash command line. I am currently ssh'ing (using ConEmu) into an AWS instance (Ubuntu Server 14.04 LTS) in order to setup a Jupyter notebook server. However, in a part of the documentation in requires editing a file using the vim editor. Vim seems a but confusing right now to learn and I just need to edit a couple lines.</p>
<p>Is there something similar in linux to the windows command line:</p>
<pre><code>notepad file_name.txt
</code></pre>
<p>that opens a text file in a GUI for editing/saving. Is there a similar command line argument in Linux? Or something I can install which will give me this ability?</p>
<p>Thanks</p>
|
<linux><bash><ubuntu><amazon-web-services><vim>
|
2016-01-03 12:42:24
|
LQ_CLOSE
|
34,576,659
|
NodeJS Express encodes the URL - how to decode
|
<p>I'm using NodeJS with Express, and when I use foreign characters in the URL, they automatically get encoded.</p>
<p><strong>How do I decode it back to the original string?</strong></p>
<p>Before calling NodeJS, I escape characters.</p>
<p>So the string: <code>אובמה</code></p>
<p>Becomes <code>%u05D0%u05D5%u05D1%u05DE%u05D4</code></p>
<p>The entire URL now looks like: <code>http://localhost:32323/?query=%u05D0%u05D5%u05D1%u05DE%u05D4</code></p>
<p>Now in my NodeJS, I get the escaped string <code>%u05D0%u05D5%u05D1%u05DE%u05D4</code>.</p>
<p>This is the relevant code:</p>
<pre><code>var url_parts = url.parse(req.url, true);
var params = url_parts.query;
var query = params.query; // '%u05D0%u05D5%u05D1%u05DE%u05D4'
</code></pre>
<p>I've tried <code>url</code> and <code>querystring</code> libraries but nothing seems to fit my case.</p>
<pre><code>querystring.unescape(query); // still '%u05D0%u05D5%u05D1%u05DE%u05D4'
</code></pre>
|
<node.js><express><escaping>
|
2016-01-03 12:44:50
|
HQ
|
34,576,679
|
Python for loop - to iterate or not to iterate?
|
I'm writing a hangman game using Python, based on a specific set of instructions. I specifically need to use a for loop in order to replace all the letters in a word with underscores and in fact I am succeeding in doing so. However I have one slight issue, I'm getting a new line of underscores printed for every letter in my word. Is there a way to get rid of this? Can someone guide me on what is wrong with my logic? Thanks in advance.
word = "test"
def createBlank(word):
for letter in word:
blanks = '_' * len(word)
print(blanks)
My result is as you would assume:
>>> word
'test'
>>> createBlank(word)
____ #<- only need this line to be printed.. is it even possible using a for?
____
____
____
|
<python><loops><for-loop><printf><line>
|
2016-01-03 12:47:28
|
LQ_EDIT
|
34,576,731
|
Inherit ES6/TS class from non-class
|
<p>Given the class is extended from non-class (including, but not limited to, function),</p>
<pre><code>function Fn() {}
class Class extends Fn {
constructor() {
super();
}
}
</code></pre>
<p>what are the the consequences? What do the specs say on that?</p>
<p>It looks like the current implementations of Babel, Google V8 and Mozilla Spidermonkey are ok with that, and TypeScript throws</p>
<blockquote>
<p>Type '() => void' is not a constructor function type</p>
</blockquote>
<p>If this is a valid ES2015 code, what's the proper way to handle it in TypeScript?</p>
|
<javascript><typescript><ecmascript-6>
|
2016-01-03 12:53:33
|
HQ
|
34,577,012
|
Creating a stopwatch with redux
|
<p>I've been trying to make a stopwatch in react and redux. I've been having trouble trouble figuring out how to design such a thing in redux. </p>
<p>The first thing that came to mind was having a <code>START_TIMER</code> action which would set the initial <code>offset</code> value. Right after that, I use <code>setInterval</code> to fire off a <code>TICK</code> action over and over again that calculates how much time has passed by using the offset, adds it to the current time, and then updates the <code>offset</code>.</p>
<p>This approach seems to work, but I'm not sure how I would clear the interval to stop it. Also, it seems like this design is poor and there is probably a better way to do it.</p>
<p>Here is a full <a href="https://jsfiddle.net/a94jabzd/1/" rel="noreferrer">JSFiddle</a> that has the <code>START_TIMER</code> functionality working. If you just want to see what my reducer looks like right now, here it is:</p>
<pre><code>const initialState = {
isOn: false,
time: 0
};
const timer = (state = initialState, action) => {
switch (action.type) {
case 'START_TIMER':
return {
...state,
isOn: true,
offset: action.offset
};
case 'STOP_TIMER':
return {
...state,
isOn: false
};
case 'TICK':
return {
...state,
time: state.time + (action.time - state.offset),
offset: action.time
};
default:
return state;
}
}
</code></pre>
<p>I would really appreciate any help.</p>
|
<javascript><reactjs><ecmascript-6><redux>
|
2016-01-03 13:25:52
|
HQ
|
34,578,174
|
Are there any alternatives to T4 templates and EnvDTE for cross platform asp.net 5 development?
|
<p>We currently use T4 templates to generate C# code files based on C# Code (Entity POCO's) and the EDMX (in older applications) </p>
<p>Moving to ASP.NET 5 with a view to support cross platform development, are there any code generation tools available that can read a projects class & meta data structures, and to generate C# files at design time, similar to T4 templates?</p>
|
<code-generation><asp.net-core><t4><entity-framework-core>
|
2016-01-03 15:27:20
|
HQ
|
34,578,181
|
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually
|
<p>Im using Cordova in Linux mint 17 </p>
<p>I installed android sdk , cordova , android studio , nodejs 4 </p>
<p>problem is here
when i wanna build app in codova and run this on terminal :</p>
<p>sudo cordova build android</p>
<p>it shows </p>
<pre><code>Running command: /home/tnt/hello12/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
</code></pre>
<p>I put this code </p>
<pre><code> export HOME="/home/tnt"
export ANDROID_HOME="$HOME/android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export ANT_HOME="/usr/share/ant"
export PATH="$ANT_HOME/bin:$PATH"
export ANDROID_HOME="/home/tnt/android/sdk/tools"
</code></pre>
<p>on my </p>
<pre><code>/home/tnt/.bash_profile
/home/tnt/.bashrc
/home/tnt/.profile
/root/.bash_profile
/root/.bashrc
/root/.profile
</code></pre>
<p>but it wont works</p>
|
<android><linux><cordova>
|
2016-01-03 15:28:05
|
HQ
|
34,578,677
|
How to ignore a particular directory or file for tslint?
|
<p>The IDE being used is WebStorm 11.0.3, the tslint is configured and works, but, it hangs because it tries to parse large *.d.ts library files. </p>
<p>Is there a way to ignore a particular file or directory?</p>
|
<javascript><ide><typescript><webstorm><tslint>
|
2016-01-03 16:16:33
|
HQ
|
34,579,213
|
DBSCAN for clustering of geographic location data
|
<p>I have a dataframe with latitude and longitude pairs.</p>
<p>Here is my dataframe look like.</p>
<pre><code> order_lat order_long
0 19.111841 72.910729
1 19.111342 72.908387
2 19.111342 72.908387
3 19.137815 72.914085
4 19.119677 72.905081
5 19.119677 72.905081
6 19.119677 72.905081
7 19.120217 72.907121
8 19.120217 72.907121
9 19.119677 72.905081
10 19.119677 72.905081
11 19.119677 72.905081
12 19.111860 72.911346
13 19.111860 72.911346
14 19.119677 72.905081
15 19.119677 72.905081
16 19.119677 72.905081
17 19.137815 72.914085
18 19.115380 72.909144
19 19.115380 72.909144
20 19.116168 72.909573
21 19.119677 72.905081
22 19.137815 72.914085
23 19.137815 72.914085
24 19.112955 72.910102
25 19.112955 72.910102
26 19.112955 72.910102
27 19.119677 72.905081
28 19.119677 72.905081
29 19.115380 72.909144
30 19.119677 72.905081
31 19.119677 72.905081
32 19.119677 72.905081
33 19.119677 72.905081
34 19.119677 72.905081
35 19.111860 72.911346
36 19.111841 72.910729
37 19.131674 72.918510
38 19.119677 72.905081
39 19.111860 72.911346
40 19.111860 72.911346
41 19.111841 72.910729
42 19.111841 72.910729
43 19.111841 72.910729
44 19.115380 72.909144
45 19.116625 72.909185
46 19.115671 72.908985
47 19.119677 72.905081
48 19.119677 72.905081
49 19.119677 72.905081
50 19.116183 72.909646
51 19.113827 72.893833
52 19.119677 72.905081
53 19.114100 72.894985
54 19.107491 72.901760
55 19.119677 72.905081
</code></pre>
<p>I want to cluster this points which are nearest to each other(200 meters distance) following is my distance matrix.</p>
<pre><code>from scipy.spatial.distance import pdist, squareform
distance_matrix = squareform(pdist(X, (lambda u,v: haversine(u,v))))
array([[ 0. , 0.2522482 , 0.2522482 , ..., 1.67313071,
1.05925366, 1.05420922],
[ 0.2522482 , 0. , 0. , ..., 1.44111548,
0.81742536, 0.98978355],
[ 0.2522482 , 0. , 0. , ..., 1.44111548,
0.81742536, 0.98978355],
...,
[ 1.67313071, 1.44111548, 1.44111548, ..., 0. ,
1.02310118, 1.22871515],
[ 1.05925366, 0.81742536, 0.81742536, ..., 1.02310118,
0. , 1.39923529],
[ 1.05420922, 0.98978355, 0.98978355, ..., 1.22871515,
1.39923529, 0. ]])
</code></pre>
<p>Then I am applying DBSCAN clustering algorithm on distance matrix.</p>
<pre><code> from sklearn.cluster import DBSCAN
db = DBSCAN(eps=2,min_samples=5)
y_db = db.fit_predict(distance_matrix)
</code></pre>
<p>I don't know how to choose eps & min_samples value. It clusters the points which are way too far, in one cluster.(approx 2 km in distance) Is it because it calculates euclidean distance while clustering? please help.</p>
|
<python><cluster-analysis><dbscan>
|
2016-01-03 17:09:02
|
HQ
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 2