Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
35,921,180 | In Java How to convert a numeric string to a Char | I have to convert a numeric string into an asc ii char. The charAt method does not work here.
I have a string string c =4;
How do i convert it to its sac ii char. | <java><string><char> | 2016-03-10 15:50:02 | LQ_EDIT |
35,921,255 | What should ls $GOROOT and ls $GOPATH look like (not a repeat)? | This is not a repeat of this question:
http://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
I don't want to know what the values should be. I want to know what I should see when I type `ls $GOROOT` or `ls $GOPATH` into console. I'm pretty sure I set things up wrong following a tutorial almost a year ago, and I want to be able to confirm that these two are pointing to where they should be by simply checking that what they point to looks right.
Here's where I am right now. It looks like `$GOROOT` is pointing nowhere. I'm pretty sure it should be pointing at `usr/local/go`, but it would be a lot easier to confirm if I knew what the expected result of `ls $GOROOT` is supposed to be.
As for `$GOPATH` I'm not totally sure if my "workspace" is where all my go code is, or maybe just the github stuff, or maybe the particular folder I'm working within. I know it's supposed to point to my "work space," but I don't know what that work space I'm looking for looks like.
Sephs-MBP:ThumbzArt seph$ $GOROOT
Sephs-MBP:ThumbzArt seph$ $GOPATH
-bash: /Users/seph/code/golang: is a directory
Sephs-MBP:ThumbzArt seph$ ls $GOROOT
Bman.jpg README.md ThumbzArt.sublime-workspacescripts thumbzart.go
LICENSE.md ThumbzArt.sublime-project public templates ticktock.go
Sephs-MBP:ThumbzArt seph$ $GOPATH
-bash: /Users/seph/code/golang: is a directory
Sephs-MBP:ThumbzArt seph$ ls $GOPATH
- bin p pkg src
Sephs-MBP:ThumbzArt seph$ ls /usr/local/go
AUTHORS CONTRIBUTORS PATENTS VERSION bin doc lib pkg src
CONTRIBUTING.md LICENSE README.md api blog favicon.ico misc robots.txt test
Sephs-MBP:ThumbzArt seph$
I know this question seems ridiculous, but it's hard to confirm things for which you have no expected results.
Thanks you | <go> | 2016-03-10 15:53:24 | LQ_EDIT |
35,923,522 | how to fix andriod java ListViewAdapter | Please i need help to fix is problem with my ListView Adapter, when i scroll down the list of country change to only one country.
this my
Nraeby_ListViewAdapter
public class Nraeby_ListViewAdapter extends BaseAdapter {
private String Liked;
Context mContext;
// Declare Variables
LayoutInflater inflater;
private ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
public Nraeby_ListViewAdapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.data = arraylist;
mContext = context;
imageLoader = new ImageLoader(mContext);
inflater = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public class ViewHolder {
// Declare Variables
TextView rank;
TextView country;
TextView population;
test.Droidlogin.CircleImage flag;
test.Droidlogin.material.AnimateCheckBox checkBox;
ImageButton btnFavourite;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = inflater.inflate(R.layout.nearby_listview_item, null);
// Get the position
resultp = data.get(position);
// Locate the TextViews in nearby_listview_item.xmltem.xml
holder.rank = (TextView) view.findViewById(R.id.rank);
holder.country = (TextView) view.findViewById(R.id.country);
// Locate the ImageView in nearby_listview_item.xmltem.xml
holder.flag = (test.Droidlogin.CircleImage) view.findViewById(R.id.flag);
holder.checkBox = (test.Droidlogin.material.AnimateCheckBox) view.findViewById(R.id.checkbox);
holder.btnFavourite = (ImageButton) view.findViewById(R.id.like);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
// Capture position and set results to the TextViews
holder.rank.setText(resultp.get(NearbyUsers.RANK));
holder.country.setText(resultp.get(NearbyUsers.COUNTRY));
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
imageLoader.DisplayImage(resultp.get(NearbyUsers.FLAG), holder.flag);
TinyDB tinydb = new TinyDB(mContext);
Liked = tinydb.getString("MyUsers");
//This handle and change icon when click on.
holder.btnFavourite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TinyDB tinydb = new TinyDB(mContext);
holder.btnFavourite.setImageResource(R.drawable.icon_liked);
tinydb.putString("MyUsers",resultp.get(NearbyUsers.COUNTRY));
holder.btnFavourite.setImageResource(R.drawable.icon_liked);
}
});
// Capture ListView item click
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Get the position
Intent intent = new Intent(mContext, SingleItemViewNearbyProfile.class);
// Pass all data rank
intent.putExtra("rank", resultp.get(NearbyUsers.RANK));
// Pass all data country
intent.putExtra("country", resultp.get(NearbyUsers.COUNTRY));
// Pass all data population
intent.putExtra("population",resultp.get(NearbyUsers.POPULATION));
// Pass all data flag
intent.putExtra("flag", resultp.get(NearbyUsers.FLAG));
// Start SingleItemView Class
mContext.startActivity(intent);
}
});
return view;
}
}
pls i need help on how to fix the error
so that when scroll down it will show the list of all country and a button
| <java><android><arrays><listview><arraylist> | 2016-03-10 17:40:09 | LQ_EDIT |
35,923,549 | How can I do a telnet to a local HTTP server? | <p>I know how to do it to a remote server, it would be like: </p>
<pre><code>telnet www.esqsoft.globalservers.com 80
</code></pre>
<p>But I don't know to a local server (written in C).</p>
| <c><http><server><telnet> | 2016-03-10 17:41:35 | LQ_CLOSE |
35,924,476 | convert array from inches to cm | <p>I was tasked with having an array that starts with size 10, then have user input heights in inches and stores it inside the array and then a new array converts all of those elements inside the initial array to cm. I have absolutely no idea what to do and really need help. How do I fix this?</p>
<pre><code>double[] heightInches = new double[10];
int currentSize = 0;
Scanner in = new Scanner(System.in);
System.out.print("Please enter heights (inches), Q to quit: ");
while (in.hasNextDouble() && currentSize < heightInches.length)
{
heightInches[currentSize] = in.nextDouble();
currentSize++;
}
double[] result = convert(heightInches);
System.out.println("Heights in cm: " + result);
}
public static double[] convert(double[] inches) {
double heightCm[] = new double[inches.length];
for( int i = 0; i < inches.length; i++)
{
heightCm[i] = inches[i] * 2.54;
}
return heightCm;
}
}
</code></pre>
| <java><arrays> | 2016-03-10 18:30:48 | LQ_CLOSE |
35,924,623 | Java Sorting Error | <pre><code>public class Main {
public static void main(String[] args) {
int z;
int [] a = new int[5];
a[0]=4;
a[1]=8;
a[2]=5;
a[3]=1;
a[4]=3;
for(;;){
z=0;
for(int i=1;i<a.length;i++){
if(a[i-1]>a[i]){
int tmp = a[i];
a[i-1]=a[i];
a[i]=tmp;
z++;
}
}
if(z==0){
break;
}
}
for(int i=0;i<a.length;i++)
{
System.out.println(a[i]);
}
}}
</code></pre>
<p>Hi. I have this problem. I want to sort array items, but result of this code is 1 1 1 1 3. I can't understand where is problem.
Thanks you very much! </p>
| <java> | 2016-03-10 18:39:00 | LQ_CLOSE |
35,924,736 | Objective-c Change date format | I have a date like so:
22-04-2016 8:00:00 AM
how do I change the format to `04-22-2016 8:00:00 AM`
I have tried the following:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM-dd-yyyy"];
NSLog(@"%@", [dateFormat dateFromString:[cell scheduledDate]]);
but this returns null :( how can I change the format of this string? `[cell scheduledDate]` is a string. | <objective-c><cocoa><cocoa-touch><nsstring><nsdateformatter> | 2016-03-10 18:45:23 | LQ_EDIT |
35,925,830 | Python max() not working? Not actually giving me the maximum | <p>Having a problem recently when using the max() function in python. Here is my code:</p>
<pre><code>x = ["AJK","exit","Down","World","HappyASD"]
max(x)
</code></pre>
<p>But instead of getting "HappyASD", I get "exit".
Any help?</p>
| <python><list><max> | 2016-03-10 19:45:53 | LQ_CLOSE |
35,925,835 | jQuery change logo on section | <p>I have for so long searched on how to do like this website has done with their logo:</p>
<p><a href="http://www.shiftbrain.co.jp/works/dcc_2015" rel="nofollow">http://www.shiftbrain.co.jp/works/dcc_2015</a></p>
<p>The logo changes, what I believe on reaching a section. Does anyone know how to make this with jQuery?</p>
<p>Say I have 2 different sections, one with the class "white" and the other with the class "dark". On reaching the "white" section, I'd like a logo to swap to a dark logo and vice versa. </p>
| <jquery><html><css> | 2016-03-10 19:46:13 | LQ_CLOSE |
35,926,857 | What does this code concerning sys.args mean? | <p>What does the following chunk of code mean? I don't understand the concept of sys.argv. I heard it has something to do with command-line prompts but my vocabulary isn't good enough to understand that. Also the output is strange. I don't understand how a list is pulled up nor how the elements get in there or even where they come from and what they mean. This is really confusing me, so help understanding it would be much appreciated. Please use beinner terms so I can understand it.</p>
<pre><code>import sys
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
</code></pre>
| <python><argv><sys> | 2016-03-10 20:42:26 | LQ_CLOSE |
35,926,998 | multiple if statemant in AWK | Please help.
I have a file, that look like
01/11/2015;998978000000;4890********3290;5735;ITUNES.COM/BILL;LU;Cross_border_rub;4065;17;915;INSUFF FUNDS;51;0;
delimeter ";" (13 cols)
I'm trying to calculate 9 column for all line
awk -F';' -vOFS=';' '{ gsub(",", ".", $9); print }' file | awk -F ';' '$0 = NR-1";"$0' | awk -F ';' -vOFS=';' '{bar[$1]=$1;a[$1]=$2;b[$1]=$3;c[$1]=$4;d[$1]=$5;e[$1]=$6;f[$1]=$7;g[$1]=$8;h[$1]=$9;k[$1]=$10;l[$1]=$11;l[$1]=$12;m[$1]=$13;p[$1]=$14;};
if($7="International") {income=0.0162*h[i]+0.0425*h[i]};
else if($7="Domestic") {income=0.0188*h[i]};
else if($7="Cross_border_rub") {income=0.0162*h[i]+0.025*h[i]}END{for(i in bar) print income";"a[i],b[i],c[i],d[i],e[i],f[i],g[i],h[i],k[i],l[i],m[i],p[i]}'
How exactly multiple if statement correctly work in awk?
Big thanks!!! | <bash><unix><awk> | 2016-03-10 20:50:31 | LQ_EDIT |
35,927,985 | Why I can't declare and run method in main method of Java class | <p>Probably I missed something during checking Java core, but please help me to understand why I cannot use method declared in java main method which is commented</p>
<pre><code>class R {
public int cal(int a, int b) {
return a + b;
}
public int cal3(int a, int b) {
return a * b;
}
}
public class Rect {
public static void main(String arg[]) {
/*public static int cal2 ( int a, int b){
return a + b;
}
int ab2 = cal2(2,2);
System.out.println(ab2);*/
R r = new R();
int ab = r.cal(2, 2);
System.out.println(ab);
int ab3 =r.cal3(2,3);
System.out.println(ab3);
}
}
</code></pre>
| <java> | 2016-03-10 21:48:29 | LQ_CLOSE |
35,929,696 | Get values of variables inside of a php array | <p>I'm very new to this and I need help. I have been searching and searching for days on end. My question is how to get it so my code I have here, returns just the values of one variable from inside the different object(stdClass)'s. Like I said I am very new and inexperienced with any sort of programming but I have self taught myself quite a bit.</p>
<p>Here is my current php code:</p>
<pre><code>$rc = get_data('https://xboxapi.com/v2/2535433396471499/friends');
$rc2 = json_decode($rc);
</code></pre>
<p>Here is what I get when it is printed in the browser:</p>
<pre><code>object(stdClass)#1 (13) {
["id"]=>
int(2535472804586102)
["hostId"]=>
NULL
["Gamertag"]=>
string(11) "Unikornz119"
["GameDisplayName"]=>
string(11) "Unikornz119"
["AppDisplayName"]=>
string(11) "Unikornz119"
["Gamerscore"]=>
int(3190)
["GameDisplayPicRaw"]=>
string(5) "a.png"
["AppDisplayPicRaw"]=>
string(180) "b.png"
["AccountTier"]=>
string(4) "Gold"
["XboxOneRep"]=>
string(10) "GoodPlayer"
["PreferredColor"]=>
string(0) ""
["TenureLevel"]=>
int(1)
["isSponsoredUser"]=>
bool(false)
}
</code></pre>
<p>Thank you all, I hope to hear some positive responses! :)</p>
| <php> | 2016-03-10 23:56:51 | LQ_CLOSE |
35,931,324 | "Swift Core Data" How to add a Scope Bars to UISearchBar? | <p>So, I have a <code>tableView</code> with <code>NSFetchedResultsController</code>! I have also a <code>UISearchController</code>, and works perfectly! But I need a Scope Bars to the <code>UISearchBar</code>. How to create and how to add a Scope Bars in Swift Core Data?</p>
<p>Thanks!</p>
| <swift><core-data><uisearchbar><nsfetchedresultscontroller><uisearchcontroller> | 2016-03-11 02:44:48 | LQ_CLOSE |
35,933,233 | i want to add product Id , product name and product details in mysql table. i made the form in simple Html.?can you help me out.? this is my form | <p>i want to add product Id , product name and product details in mysql table. i made the form in simple Html.?can you help me out.? this is my form.</p>
| <java><mysql><jsp> | 2016-03-11 05:52:34 | LQ_CLOSE |
35,933,429 | iOS Undo the deleted cells in my tableview | <p>In my project i just want to hide the cells when swipe happend. if i hide the cell from tableview undo button will generate top of my navigation bar. Click on undo button the hidden cells should reappear.</p>
<p>Here is my code..</p>
<pre><code>-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
Download *download = [self.downloadManager.downloads objectAtIndex:indexPath.row];
// Get path to documents directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
// Get zip file from path..
NSString *fileInDocumentsPath = [documentsPath stringByAppendingPathComponent:download.name];
NSLog(@"Looking for zip file %@", fileInDocumentsPath);
if ([[NSFileManager defaultManager] fileExistsAtPath:fileInDocumentsPath])
{
UITableViewRowAction *HideAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Hide" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
//insert your editAction here
[self.downloadManager.downloads removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[tableView endUpdates];
UIBarButtonItem *UndoButton = [[UIBarButtonItem alloc] initWithTitle:@"Undo" style:UIBarButtonItemStyleBordered target:self action:@selector(UndoAction:)];
self.navigationItem.rightBarButtonItem=UndoButton;
}];
HideAction.backgroundColor = [UIColor blueColor];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
//insert your deleteAction here
}];
deleteAction.backgroundColor = [UIColor redColor];
return @[deleteAction,HideAction];
}
else
{
UITableViewRowAction *HideAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Hide" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
//insert your editAction here
}];
HideAction.backgroundColor = [UIColor blueColor];
return @[HideAction];
}
}
</code></pre>
| <ios><objective-c><uitableview> | 2016-03-11 06:09:28 | LQ_CLOSE |
35,933,981 | how to display div id value in form input | i am trying to show JavaScript output value in form input. bellow my div which output the value.
<div id="geo" class="geolocation_data"></div>
but i want to show in input box. i tried bellow code but not showing any
<input type="text" placeholder="Please type a location" class="form-control input-lg noredius geolocation_data" value="" id="geo"> | <javascript><jquery><html> | 2016-03-11 06:52:34 | LQ_EDIT |
35,934,354 | How to Convert NSString to Hexadecimal Value | <p>I am having NSString value as ,</p>
<pre><code>NSString *str_Value = @"12345FTY642493AF3556K7880D46676F9";
</code></pre>
<p>I need the Output in the below format ,</p>
<pre><code>Byte byte_Value[]={0x12,0x34,0x5F,0xF9,0x64,0x24,0x93,0xAF,0x35,0x56,0xA7,0x88,0x0D,0x46,0x67,0x6F};
</code></pre>
<p>How do i convert NSSTring Value to Byte[] ,Any one could please suggest solution for this.</p>
| <ios><objective-c> | 2016-03-11 07:18:06 | LQ_CLOSE |
35,935,504 | Database Design for bus timing information system | <p>I need Database design for bus timing information system like below format.</p>
<p>before one more question for bus stop. </p>
<p><strong>Same Bus Stop name but different different area/route.</strong><br>
<strong>how to store this type bus stop name in bus_stop table ?</strong> like below images see below </p>
<p><a href="https://i.stack.imgur.com/AqcB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AqcB2.png" alt="enter image description here"></a></p>
<p>this bus stops bus arrive and departure some timing
my questions </p>
<p>How to create Bus information table and Route and Stops and bus stop map to bus and timing store ?</p>
<p>and Search between stops </p>
| <sql><database> | 2016-03-11 08:32:32 | LQ_CLOSE |
35,935,731 | Why cant I use the three method startLeScan,stopLeScan | [enter image description here][1]
[1]: http://i.stack.imgur.com/svly5.png
Why cant I use the three method startLeScan,stopLeScan and how to solve it | <android><bluetooth-lowenergy> | 2016-03-11 08:46:57 | LQ_EDIT |
35,936,459 | CountDownTimer in my class service stop when i destroy my class activity | <p>i have countdowntimer in my service class and when i destroy my activity class then it stop my countdown timer in my service class but it didnt destroy my service class.
Can someone help me why my countdown timer stop?
I need call another activity when my countdown is finish.</p>
| <java><android> | 2016-03-11 09:29:20 | LQ_CLOSE |
35,936,864 | data paramter showing nil and its crashing | - (IBAction)loginAction:(id)sender {
// [self.eMail resignFirstResponder];
// [self.password resignFirstResponder];
NSString *post =[NSString stringWithFormat:@"Email=%@&Password=%@",self.eMail.text,self.password.text];
NSString * loginURL = @"http://75.101.159.160:8222/api/mobileappapi/user/login"; // Login URL
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSHTTPURLResponse * response;
NSError * error;
NSMutableURLRequest * request;
request = [[NSMutableURLRequest alloc]initWithURL:nil cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPBody:postData];
request.URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",loginURL]];
error = nil;
response = nil;
NSData* jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:response error:&error];
NSDictionary* resultsDictionary = [NSJSONSerialization JSONObjectWithData:jsonUpdateDate options:0 error:&error];
NSLog(@"%@",resultsDictionary);
NSString *userRole = [resultsDictionary objectForKey:@"UserRole"];
if (userRole != (NSString*)[NSNull null]) {
if ([userRole isEqualToString:@"Passenger"]) {
// SuccessuserRole
HomeScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeScreen"];
[self presentViewController:obj animated:NO completion:nil];
}
else if ([userRole isEqualToString:@"Driver"]){
SelectVehicle *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"SelectVehicle"];
[self presentViewController:obj animated:NO completion:nil];
}
}
}**strong text** | <ios> | 2016-03-11 09:49:18 | LQ_EDIT |
35,937,801 | I WANT TO USE CASE WHEN COMMAND WITH THREEN CONTIATION PLZ GIVE U R SUGGESTIONTHIS IS MY QUERY BUT SHOW ING ERROR |
SELECT DISTINCT A.PHONE, OTHER,STARTTIME,duration,imeinumber,imsinumber,CALL_TYPE,a.provider_key, A.CELLTOWERID, SITEADDRESS,
LAT, LONG, AZIMUTH FROM cdat A
LEFT JOIN CDATDUPL.DBO.CDATCELLTOWERAREANEW B ON case when a.provider_key!='9' then a.tower_key=b.TOWER_KEY else
A.celltowerid = B.CELLTOWERID
AND A.PROVIDER_key=B.PROVIDER_KEY and a.state_key end=b.state_key | <sql-server-2008> | 2016-03-11 10:30:11 | LQ_EDIT |
35,937,842 | How do I make a function in Scheme? | <p>I need to create a function in Scheme using drRacket that gets a list of numbers as an argument and returns the largest number.
I've never coded using Scheme before so I really need help!
The testcase is something like this:
(maximEl '(3 5 7 9 1 3))
9</p>
| <list><function><scheme><racket> | 2016-03-11 10:32:07 | LQ_CLOSE |
35,938,240 | Change mysql code to PDO | <p>but i have this project for school,
i need to make a blog with a database connection.
I have one using mysqli but we are only allowed to use PDO, and in don't know how i can convert it in to PDO can someone help me?</p>
| <php><mysqli><pdo> | 2016-03-11 10:47:55 | LQ_CLOSE |
35,938,279 | CSV file to list in C# | <p>I have a CSV file with the following format: first name, last name, date of birth, date of death. How can i get all the datas from my CSV file and convert them into an object list?</p>
<p>I was thinking about implementing the following class</p>
<pre><code>public class Person
{
private string f_name;
private string l_name;
private int dob;
private int dod;
public Person(string first, string second, int dob, int dod)
{
this.f_name = first;
this.l_name = second;
this.dob = dob;
this.dod = dod;
}
}
</code></pre>
| <c#><csv><object> | 2016-03-11 10:50:22 | LQ_CLOSE |
35,938,944 | Reformat JSON data | <p><strong>Problem</strong></p>
<p>I have the following example json data which is not formatted how I need it:</p>
<pre><code>"stations": {
"st1": "station 1",
"st2": "station 2",
"st3": "Station 3",
}
</code></pre>
<p><strong>Question</strong></p>
<p>How can I reformat the data to be:</p>
<pre><code>"stations": [
{
"id": "st1",
"name": "station 1",
},
{
"id": "st2",
"name": "station 2",
},
{
"id": "st3",
"name": "station 3",
}
]
</code></pre>
<p><strong>Tried</strong></p>
<p>I tried to simply log the data to test first but am struggling how to actually even iterate between the key/value pairs as they are essentially strings</p>
<p>This is what i tried:</p>
<pre><code>$.get( '/js/ajax/tube-data.json', function( data ) {
$.each(data.stations, function () {
// I was expecting st1, st2, st3 to show in the console
// but got first letter of each station
console.log(this[0])
});
}).error(function() {console.log(arguments) });
</code></pre>
<p>Is there a better way to do this?</p>
| <javascript><jquery><json> | 2016-03-11 11:21:00 | LQ_CLOSE |
35,940,765 | How to Display ajax responseText? | <p>Hi friends How do I get only the main message here is to show my j44?</p>
<pre><code>error: function (xhr, status, errorThrown) {
alert(xhr.responseText);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/gxTid.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gxTid.jpg" alt="enter image description here"></a></p>
| <javascript><jquery><ajax><xmlhttprequest> | 2016-03-11 12:51:54 | LQ_CLOSE |
35,940,841 | Defining a function outside main | <pre><code>#include <stdio.h>
#include <math.h>
main()
{
float i;
float x,N,sum;
printf("enter x and N respectively");
scanf ("%f %f", &x, &N);
sum = 0;
for (i=1;i<=N;i++){
sum = sum + ((pow(x,i))/(fact(i)));
}
printf ("%f", sum);
}
int fact(int n){
int i,temp;
temp = 1;
for (i=1;i<=n;i++){
temp = temp*i;
return temp;
}
}
</code></pre>
<p>this is to print the summation of the terms accordingly. I tried defining fact inside main but there was some control flow warning and I tried the same outside this time, yet wrong answer. Any help?</p>
| <c> | 2016-03-11 12:55:41 | LQ_CLOSE |
35,943,514 | Does anybody know how to run parallel a Python application? | <p>I would like to use Python for my project but I need to distribute the computation on a set of resources.</p>
| <python><parallel-processing> | 2016-03-11 15:05:02 | LQ_CLOSE |
35,944,122 | How set variable in alamofire and get to another function | import Alamofire
import SwiftyJson
public class MyExample{
var myarray=[String]()
func onCreate(){
Alamofire.request(.GET, "https://myurl.org/get", ).responseJSON {
response in
let json = JSON(value)
let list: Array<JSON> = json.arrayValue
for element in list{
myarray.append(element["name"].stringValue)
}
}
func getMyArray(){return myarray}
}
| <ios><swift><alamofire> | 2016-03-11 15:32:27 | LQ_EDIT |
35,945,006 | Why didn't they design array index to start from 1? | <p>In many programming languages, the array index begins with 0. Is there a reason why it was designed so?</p>
<p>According to me, it would have been more convenient if the length of the array was equal to the last index. We could avoid most of the <code>ArrayIndexOutOfBounds</code> exceptions. </p>
<p>I can understand when it comes to a language like <code>C</code>. <code>C</code> is an old language and the developers may have not thought about the issues and discomfort. But in case of modern languages like java, they still had a chance to redefine the design. Why have they chosen to keep it the same?</p>
<p>Is it somehow related to working of operating systems or did they actually wanted to continue with the familiar behaviour or design structure (though new programmers face a lot of problems related to this)?</p>
| <java><arrays><indexoutofboundsexception> | 2016-03-11 16:16:12 | LQ_CLOSE |
35,945,643 | Custom list implementation iterator can't access last element (c++) | <p>I'm implementing a custom list for a personal project & I can't seem to access the last element with an iterator.</p>
<p>It's basically a flat doubly linked list (with next & previous node pointers). </p>
<p><strong>expression.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_HPP
#define TPP_EXPRESSION_HPP
#include <cstddef>
#include <globals.hpp>
#include "node.hpp"
#include "iterator.hpp"
#include <iostream>
namespace tpp {
namespace expression {
class Expression {
std::size_t _size;
Node* left;
Node* right;
public:
void print() {
Node* node = left;
while (node != nullptr) {
std::cout << node->value << "\t";
node = node->next;
}
}
void append(byte val) {
Node* node = new Node(val);
if (right != nullptr) {
Node* tmp = right;
tmp->next = node;
right = node;
right->prev = tmp;
} else {
left = right = node;
}
_size++;
}
Iterator begin() {
std::cout << "Left: " << left->value << std::endl;
return Iterator(left);
}
const ConstIterator cbegin() const {
return ConstIterator(left);
}
Iterator end() {
std::cout << "Right: " << right->value << std::endl;
return Iterator(right);
}
const ConstIterator cend() const {
return ConstIterator(right);
}
bool is_empty() {
return _size == 0;
}
std::size_t size() {
return _size;
}
Expression() : _size(0), left(nullptr), right(nullptr) {
}
~Expression() {
Node* node = right;
while (node != nullptr) {
Node* old_back = node;
node = node->prev;
delete old_back;
}
left = nullptr;
right = nullptr;
}
};
} // expression
} // tpp
#endif //TPP_EXPRESSION_HPP
</code></pre>
<p><strong>iterator.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_ITERATOR_HPP
#define TPP_EXPRESSION_ITERATOR_HPP
#include <globals.hpp>
#include "node.hpp"
#include <iostream>
namespace tpp {
namespace expression {
class Iterator {
Node* node;
public:
Iterator(Node* ptr) : node(ptr) {}
Iterator(const Iterator& rhs) : node(rhs.node) {}
Iterator& operator++() { std::cout << "Current: " << node->value << std::endl; node = node->next; std::cout << "Now: " << node->value << std::endl;return *this; }
Iterator& operator--() { node = node->prev; return *this; }
bool operator!=(const Iterator& rhs) { bool stats = node != rhs.node; std::cout << (stats ? "Not equal" : "Equal") << std::endl; return stats; }
bool operator==(const Iterator& rhs) { return node == rhs.node; }
byte& operator*() { std::cout << "Dereferencing " << node->value << std::endl; return node->value; }
};
class ConstIterator {
const Node* node;
public:
ConstIterator(const Node* ptr) : node(ptr) {}
ConstIterator(const ConstIterator& rhs) : node(rhs.node) {}
ConstIterator& operator++() { node = node->next; return *this; }
ConstIterator& operator--() { node = node->prev; return *this; }
bool operator!=(const ConstIterator& rhs) { return node != rhs.node; }
bool operator==(const ConstIterator& rhs) { return node == rhs.node; }
const byte& operator*() const { return node->value; }
};
} // expression
} // tpp
#endif //TPP_EXPRESSION_ITERATOR_HPP
</code></pre>
<p><strong>node.hpp</strong></p>
<pre><code>#ifndef TPP_EXPRESSION_NODE_HPP
#define TPP_EXPRESSION_NODE_HPP
#include <globals.hpp>
namespace tpp {
namespace expression {
struct Node {
Node* prev;
Node* next;
byte value;
Node(byte value) : value(value), prev(nullptr), next(nullptr) {}
Node() : value('\0'), prev(nullptr), next(nullptr) {}
};
}
} // tpp
#endif //TPP_EXPRESSION_NODE_HPP
</code></pre>
<p><strong>main.cpp</strong></p>
<pre><code>#include <iostream>
#include <globals.hpp>
#include <expression/include.hpp>
using namespace std;
int main()
{
tpp::expression::Expression e;
e.append('0');
e.append('1');
e.append('0');
e.append('1');
for (auto elem : e) {
std::cout << elem << std::endl;
}
e.print();
}
</code></pre>
<p><strong>Example output</strong></p>
<pre><code>Left: 0
Right: 1
Not equal
Dereferencing 0
0
Current: 0
Now: 1
Not equal
Dereferencing 1
1
Current: 1
Now: 0
Not equal
Dereferencing 0
0
Current: 0
Now: 1
Equal
0 1 0 1
</code></pre>
<p>Code is a mess, I was more focused on getting it working before I cleaned it up. Any help would be useful, thanks.</p>
| <c++><list><iterator> | 2016-03-11 16:48:03 | LQ_CLOSE |
35,946,078 | Java Eclipse Debug and Deploy Issues | <p>I'm working on a big project and the test component is consumed me the most part of the time.
Why ?
When I made some changes in a project during the debug, to suffer effect I have to stop the debug, deply and debug again. And I know if I change the configurations, I can do some changes during the debug. Anyone know what I need to do?</p>
<p>Another problem:
To do the deploy of some changes, how can I do without deploy all of the project ? This consume more than 7 minutes.</p>
<p>Thanks in advance</p>
| <java><eclipse><debugging><testing><deployment> | 2016-03-11 17:11:55 | LQ_CLOSE |
35,947,602 | how can I store a variable(Int) permanently after app closes and Display it? | I am trying to store a variable named *total* which holds the number of rows in UItableView. Since the user types strings for UITableView, the variable is *listTable* which is String array.
I have my *total* as total = listTable.count
ISSUE:
Every time the app launches it displays 0 as number of rows used, however once you go to the UITableView ViewController and come back to the main ViewController it automatically corrects its self to the current amount of rows.
Code Used:
import UIKit
var listTable = [String]()
var total = listTable.count
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var numberOfRows: UILabel!
@IBOutlet weak var TypeToCreateRow: UITextField!
@IBOutlet weak var AddRow: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
total = listTable.count
NSUserDefaults.standardUserDefaults().setObject(total, forKey: "rows")
let showRow = NSUserDefaults.standardUserDefaults().objectForKey("rows")!
numberOfRows.text = "\(showRow)"
print(showRow)
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func RowAdd(sender: UIButton) {
listTable.append(TypeToCreateRow.text!)
TypeToCreateRow.text = " "
numberOfRows.text = "\(total)" }
| <ios><swift> | 2016-03-11 18:41:40 | LQ_EDIT |
35,948,556 | How do I get started with Cordova | <p>Are there any good tutorials or books to get started with Cordova?</p>
<p>I have already visited the official website but I didn't think the documentation they have is a good starting point.</p>
| <cordova> | 2016-03-11 19:41:08 | LQ_CLOSE |
35,949,019 | Reorder a list of string randomly but constant in a period of time | <p>I need to reorder a list in a random way but I want to have the same result on a short period of time ... So I have:</p>
<pre><code>var list = new String[] { "Angie", "David", "Emily", "James" }
var shuffled = list.OrderBy(v => "4a78926c")).ToList();
</code></pre>
<p>But I always get the same order ... I could use Guid.NewGuid() but then I would have a different result in a short period of time.</p>
<p>How can I do this?</p>
| <c#> | 2016-03-11 20:09:08 | LQ_CLOSE |
35,949,099 | VectorDrawable rendering issue | <p>I'm having problems with the VectorDrawables introduced by the support library.</p>
<p>Looking around, I read about similar issues regarding bad scaling or incorrect preview in Android Studio. Well, my problem is unluckily different.</p>
<p>PROBLEM:</p>
<p>In fact, my VectorDrawable renders perfectly in the Android Studio preview but gets messed up at runtime on device (Android v. 5.1.1 and 6.0).</p>
<p>EXPORTING:</p>
<p>Starting from an SVG file (with only one compounded path), I imported it with the Android Studio tool (but I also tried many other tools to convert it).
The file was made in the same way as a bunch of others, though only some render bad.</p>
<p>WHAT I ALREADY TRIED:</p>
<p>I tried to set it in an imageview with app:srcCompat (even with src:).
I tried to use it in a menu (directly setting the icon, or using a
selector).</p>
<p>SVG CODE:</p>
<pre><code><svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 626.96 610.53"><title>PATHOLOGIES</title><path d="M5766.55,588.54a54.73,54.73,0,0,0-4.23-3.81,248.33,248.33,0,0,0,31.34-121.54c-0.23-138.68-114.72-251.15-253.38-249-134.71,2.07-243.52,110.91-245.54,245.64a249.48,249.48,0,0,0,390.59,209.52l0.21,0.22,155.12,155.12,81-81Zm-222.36,64.92c-104.85,0-189.85-85-189.85-189.85s85-189.85,189.85-189.85S5734,358.76,5734,463.61,5649,653.46,5544.19,653.46ZM5452,347.1l7.72-22.08a161.29,161.29,0,0,1,52.5-20.55l-19.84,56.75A19.25,19.25,0,0,1,5467.83,373l-4-1.41A19.25,19.25,0,0,1,5452,347.1Zm20.13,82.62L5430,502.57a19.25,19.25,0,0,1-26.29,7l-3.71-2.14a19.25,19.25,0,0,1-7-26.29L5435,408.33a19.25,19.25,0,0,1,26.29-7l3.71,2.14A19.25,19.25,0,0,1,5472.1,429.72Zm-82.73-14.9A161.59,161.59,0,0,1,5408.85,374l9.06,9.06a19.25,19.25,0,0,1,0,27.22l-3,3A19.24,19.24,0,0,1,5389.37,414.82Zm151.76-54A19.25,19.25,0,0,1,5552,335.85l55.51-21.72a162.36,162.36,0,0,1,43.87,27.64A19.17,19.17,0,0,1,5646,345l-78.34,30.65a19.25,19.25,0,0,1-24.94-10.91Zm-13.43,29.12,66.74,51.21a19.25,19.25,0,0,1,3.55,27l-2.61,3.4a19.25,19.25,0,0,1-27,3.55l-66.74-51.21a19.25,19.25,0,0,1-3.55-27l2.61-3.4A19.25,19.25,0,0,1,5527.69,389.91Zm83.57,191.47-2.82,3.23a19.25,19.25,0,0,1-27.15,1.86l-63.41-55.28A19.25,19.25,0,0,1,5516,504l2.82-3.23a19.25,19.25,0,0,1,27.16-1.86l63.41,55.28A19.25,19.25,0,0,1,5611.26,581.38Zm60.09-191.15,4,1.59a19.25,19.25,0,0,1,10.71,25l-31.28,78.09a19.25,19.25,0,0,1-25,10.71l-4-1.59A19.25,19.25,0,0,1,5615,479l31.28-78.09A19.25,19.25,0,0,1,5671.34,390.24ZM5504.73,604.39a19.19,19.19,0,0,1-4.85,15.4,161.36,161.36,0,0,1-38.43-16.53l-9.92-76.83a19.25,19.25,0,0,1,16.62-21.55l4.25-.55A19.25,19.25,0,0,1,5494,521ZM5686.4,538L5685,544.4a163.11,163.11,0,0,1-56.5,57.93l16.12-73.51a19.25,19.25,0,0,1,22.92-14.68l4.19,0.92A19.25,19.25,0,0,1,5686.4,538Z" transform="translate(-5294.72 -214.14)"/></svg>
</code></pre>
<p>VECTORDRAWABLE CODE:</p>
<pre><code><vector android:height="24dp" android:viewportHeight="610.53"
android:viewportWidth="626.96" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M471.8,374.4a54.7,54.7 0,0 0,-4.2 -3.8,248.3 248.3,0 0,0 31.3,
-121.5c-0.2,-138.7 -114.7,-251.1 -253.4,-249 -134.7,2.1 -243.5,110.9 -245.5,245.6a249.5,249.5 0,0 0,390.6 209.5l0.2,
0.2 155.1,155.1 81,-81ZM249.5,439.3c-104.8,0 -189.9,-85 -189.9,-189.9s85,-189.9 189.9,-189.9S439.3,144.6 439.3,
249.5 354.3,439.3 249.5,439.3ZM157.3,133l7.7,-22.1a161.3,161.3 0,0 1,52.5 -20.5l-19.8,56.8A19.3,19.3 0,0 1,
173.1 158.9l-4,-1.4A19.3,19.3 0,0 1,157.3 133ZM177.4,215.6L135.3,288.4a19.3,19.3 0,0 1,-26.3 7l-3.7,-2.1a19.3,
19.3 0,0 1,-7 -26.3L140.3,194.2a19.3,19.3 0,0 1,26.3 -7l3.7,2.1A19.3,19.3 0,0 1,177.4 215.6ZM94.7,200.7A161.6,
161.6 0,0 1,114.1 159.9l9.1,9.1a19.3,19.3 0,0 1,0 27.2l-3,3A19.2,19.2 0,0 1,94.6 200.7ZM246.4,146.7A19.3,19.3 0,
0 1,257.3 121.7l55.5,-21.7a162.4,162.4 0,0 1,43.9 27.6A19.2,19.2 0,0 1,351.3 130.9l-78.3,30.6a19.3,19.3 0,0 1,
-24.9 -10.9ZM233,175.8 L299.7,227a19.3,19.3 0,0 1,3.5 27l-2.6,3.4a19.3,19.3 0,0 1,-27 3.5l-66.7,-51.2a19.3,19.3 0,
0 1,-3.5 -27l2.6,-3.4A19.3,19.3 0,0 1,233 175.8ZM316.6,367.3 L313.8,370.5a19.3,19.3 0,0 1,-27.1 1.9l-63.4,-55.3A19.3,
19.3 0,0 1,221.3 289.9l2.8,-3.2a19.3,19.3 0,0 1,27.2 -1.9l63.4,55.3A19.3,19.3 0,0 1,316.5 367.2ZM376.7,176.1 L380.7,
177.7a19.3,19.3 0,0 1,10.7 25l-31.3,78.1a19.3,19.3 0,0 1,-25 10.7l-4,-1.6A19.3,19.3 0,0 1,320.3 264.9l31.3,-78.1A19.3,
19.3 0,0 1,376.6 176.1ZM210,390.3a19.2,19.2 0,0 1,-4.8 15.4,161.4 161.4,0 0,1 -38.4,-16.5l-9.9,-76.8a19.3,19.3 0,0 1,
16.6 -21.5l4.3,-0.6A19.3,19.3 0,0 1,199.3 306.9ZM391.7,323.9L390.3,330.3a163.1,163.1 0,0 1,-56.5 57.9l16.1,-73.5a19.3,
19.3 0,0 1,22.9 -14.7l4.2,0.9A19.3,19.3 0,0 1,391.7 323.9Z"/>
</code></pre>
<p></p>
<p>As rendered on Android Studio:</p>
<p><a href="https://i.stack.imgur.com/pOHsx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pOHsx.png" alt="As rendered on Android Studio"></a></p>
<p>As rendered on device (after AndroidStudio import):</p>
<p><a href="https://i.stack.imgur.com/wjCXi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wjCXi.png" alt="As rendered on device"></a></p>
<p>I can't really figure out what's causing the bad rendering. I'm pretty sure it's not an svg problem (correct me if I'm wrong, please) since the other drawables are rendering correctly. I wouldn't even call for a library bug since I happen to be the only one experiencing the problem. What am I doing wrong?</p>
<p>Thanks for the help</p>
| <android><svg><rendering><android-vectordrawable> | 2016-03-11 20:14:17 | HQ |
35,949,439 | Splitting a string arrays into two different arrays | <p>It's required to split each string from networkList array into <code>addresses</code> and <code>ports</code> arrays.</p>
<pre><code>string[] networkList = { "127.0.0.1:8000", "127.0.0.1:8888", "8.8.8.8:80" };
string[] addresses, ports;
</code></pre>
<p>I'm really sorry of asking so dumby question, but I couldn't find a good function to do this. I know there are few that could help.</p>
| <c#> | 2016-03-11 20:37:15 | LQ_CLOSE |
35,949,554 | Invoking a function without parentheses | <p>I was told today that it's possible to invoke a function without parentheses. The only ways I could think of was using functions like <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply"><code>apply</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call"><code>call</code></a>.</p>
<pre><code>f.apply(this);
f.call(this);
</code></pre>
<p>But these require parentheses on <code>apply</code> and <code>call</code> leaving us at square one. I also considered the idea of passing the function to some sort of event handler such as <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout"><code>setTimeout</code></a>:</p>
<pre><code>setTimeout(f, 500);
</code></pre>
<p>But then the question becomes "how do you invoke <code>setTimeout</code> without parentheses?"</p>
<p>So what's the solution to this riddle? How can you invoke a function in Javascript without using parentheses?</p>
| <javascript> | 2016-03-11 20:44:23 | HQ |
35,950,120 | How can I update an arrayList that contains multiple values?? Thanks | I am creating a basket that stores into an arraylist (Item key, qty and the price of the item). How can I update just the quantity and not to create another line with the same Item key.
Here is the outcome that the program below does. Thanks for your help!!1
Java Book 1 Β£48.90
Samsung Galaxy S7 1 Β£639.50
Speakers 3 Β£59.80
Java Book 2 Β£48.90
Samsung Galaxy S7 2 Β£639.50
//////////////////////////////////////////////////
private void ItemsBasket(String name, int qty, String key) throws HeadlessException {
if (name == null) {
JOptionPane.showMessageDialog(null, "Please Selecet a key");
String imageFileName = "./images/" + key + ".png";
File imageFile = new File(imageFileName);
if (!imageFile.exists()) {
imageFileName = "./images/empty.png";
}
} else if (qty <= StockData.getQuantity(key)) {
arList.add(StockData.getName(key) + "\t\t " + qty + " " + pounds.format(StockData.getPrice(key)));
bagtotal += StockData.getPrice(key) * qty;
JOptionPane.showMessageDialog(null, "Sucessfully added to the basket");
} else {
JOptionPane.showMessageDialog(null, "Insuffcient stock");
JOptionPane.showMessageDialog(null, "Available items qty : " + "**" + StockData.getQuantity(key) + "**");
}
} | <java><arraylist> | 2016-03-11 21:19:34 | LQ_EDIT |
35,950,211 | bash script to search directory only specific file types | <p>I'm trying to write a bash script that will search a folder for specific file extensions (lets say .txt and .csv). The folder can have thousands of each type of extension. If the folder has only these two extensions across all files then the script can proceed. If any other extensions are present (and the two allowed extesions may also be preset), the script copies the folder to a holding bucket and writes to a log file.
The folder that is being searched will never have subfolders.</p>
<p>So, if the folder has:
.txt and .csv, this passes
If the folder has:
.mp3, this fails
If the folder has:
.txt, .csv and .mp3, this also fails.</p>
<p>Thanks!</p>
| <linux><bash> | 2016-03-11 21:25:41 | LQ_CLOSE |
35,950,393 | ports for openvpn and websockets | <p>this will sound a silly question....
but id like to know the following.
i was going to install a freeswitch voip server on small intel nuc and on another intel nuc (nucs are small low powered desktop like units ) i planned to install openvpn to be used as a very useful vpn for when im on a dodgy wifi connection.</p>
<p>since id like openvpn to be running on port 443 tcp and since freeswitch ideally runs on 443 tcp i figured id need two seperate computers - hence the two machines on 2 completely different remote internet connections .</p>
<p>however im rather inclined to install both openvpn port 443 tcp ( running all the time) and also freeswitch websocket server ( listening on 443 tcp) running on the same computer and behind one router on a friends broadband connection port forwarding anything coming in for 443 tcp to the same local ip add of the same server running both freeswitch websocket and openvpn - is this a good idea?</p>
<p>id sooner not change the listening port on openvpn - since the default 1194 may well be blocked from hotel wifi etc and web sockets will undoubtedly respond more reliably if its listening on 443 tcp.</p>
<p>can two services listening on the same port / protocol work ok (nat wise )behind the router ?</p>
| <websocket><openvpn> | 2016-03-11 21:37:17 | LQ_CLOSE |
35,951,336 | java how to parse xml and save data into mysql database | <p>I have a question.</p>
<p>I want to parse XML file using SAX or JAXB and save the parsed file into a database using java, any help please.</p>
| <java><sql><xml><jaxb><sax> | 2016-03-11 22:51:36 | LQ_CLOSE |
35,951,452 | How to set dpi in JPEG Image in java | <p>How can I set DPI to a JPEG image such that even if the size of the image gets shorter the quality of the picture stays good</p>
| <java><jpeg> | 2016-03-11 23:02:43 | LQ_CLOSE |
35,952,035 | How take date in class constructor? | <p>have json</p>
<pre><code>{"id":1,"name":"123","dateoff":"2016-01-12T13:30:46.358+05:00","available":true}
</code></pre>
<p>and have class</p>
<pre><code>export class Compaing {
constructor(public id: number, public name: string,
public dateoff: Date, public available:boolean) { }
}
</code></pre>
<p>But when i use in angular2 </p>
<pre><code><Compaing>res.json()
</code></pre>
<p>It dont work. In compaing.dateoff not date, it's string.
How parse json string date to Date with constructor?</p>
| <typescript><angular> | 2016-03-12 00:03:23 | LQ_CLOSE |
35,952,128 | Is there a way to get the app group identifier from host app and share extension on iOS? | <p>I have set up App Groups for both my host app and the share extension. The identifier looks like "group.com.abc.xyzApp". Is there a way to get this string out programmatically?
Also, how do I detect if app groups are set programmatically? Is trying to initialize a file container or user defaults with the app group identifier enough to know?
Eg: </p>
<p><code>[[NSUserDefaults alloc] initWithSuiteName:@"group.com.abc.xyzApp"].</code></p>
| <ios><objective-c><share-extension> | 2016-03-12 00:15:59 | HQ |
35,952,491 | android button switch text with imageButton | <p>I have button1 with text "ohio", button2 with text "alaska", and ImageButton with arrow as background. I want to switch text Button1 to Button2 and vice versa when ImageButton clicked, how do I achieve this? or is there any reference in github that I can try?</p>
| <android><button> | 2016-03-12 01:03:18 | LQ_CLOSE |
35,952,538 | How can I disable or hide the scrollbar within an Ionic 2 <ion-content> | <p>I have an Angular 2 app wrapped in Ionic 2. I'm using <code><ion-tabs></code>, and within each tab is an <code><ion-content></code>. The content in this area needs to be scrollable, but Ionic 2 adds a scrollbar that I don't want displayed. It appears that, when compiled, an <code><ion-content></code> has a <code><scroll-content></code> injected into it. I don't want this behavior. </p>
<p>I have tried many of the solutions that <em>used to</em> work in Ionic 1, but they do not work in Ionic 2:</p>
<ul>
<li>Setting <code>scroll="false"</code> on the <code><ion-content></code></li>
<li>Setting <code>scrollbar-y="false"</code> on the <code><ion-content></code></li>
<li>Setting <code>overflow-scroll="false"</code> on the <code><ion-content></code></li>
<li><p>Setting the following in css:</p>
<p><code>.scroll-bar-indicator
{
display: none;
}</code></p></li>
</ul>
<p>etc...</p>
<p>Setting the following actually does work to remove the scrollbar, but I'd rather not hijack the browser behavior, and also it removes scrollbars from content internal to the <code><ion-content></code> tag, which I don't want. </p>
<pre><code>::-webkit-scrollbar,
*::-webkit-scrollbar {
display: none;
}
</code></pre>
| <ionic-framework><angular><ionic2> | 2016-03-12 01:11:44 | HQ |
35,952,564 | Convert RGB to sRGB? | <p>I am trying to convert an RGB to the perceptually uniform color space, CIELAB. Wikipedia states: </p>
<blockquote>
<p>"The RGB or CMYK values first must be transformed to a specific
absolute color space, such as sRGB or Adobe RGB. This adjustment will
be device-dependent, but the resulting data from the transform will be
device-independent, allowing data to be transformed to the CIE 1931
color space and then transformed into L*a * b*."</p>
</blockquote>
<p>I know there are some straightforward transformations once converting to sRGB, but I have not found any material to go from RGB to sRGB. So, what methods exist to do such a conversion?</p>
| <image><image-processing><colors> | 2016-03-12 01:14:48 | HQ |
35,952,698 | in C++ what does the not operator '~' do when it is beside a method? and Pure virtual method | Example Code Below,
#include <string>
namespace vehicle
{
class Vehicle
{
public:
Vehicle(int a);
virtual ~Vehicle(); <------ not method?
protected:
int a;
};
}
Also, I don't fully get the concept of the 'Pure Virtual Method' where you declare a method as
virtual method() = 0;
Why do we need this?
Thanks alot,
| <c++><operators><virtual> | 2016-03-12 01:37:56 | LQ_EDIT |
35,953,242 | Only input boxes of bootstrap | <p>I am currently building a site and I wanted to style my input boxes like bootstrap ones, however I don't want to use other features provided by bootstrap. Could someone recommend me how I could just export that feature and include in my CSS. There maybe some JavaScript too I believe.</p>
<p>Thank you in advance.</p>
| <css><twitter-bootstrap><stylesheet><frontend> | 2016-03-12 03:00:04 | LQ_CLOSE |
35,953,394 | Calculating length of 95%-CI using dplyr | <p>Last time I asked how it was possible to calculate the average score per measurement occasion (week) for a variable (procras) that has been measured repeatedly for multiple respondents. So my (simplified) dataset in long format looks for example like the following (here two students, and 5 time points, no grouping variable):</p>
<pre><code>studentID week procras
1 0 1.4
1 6 1.2
1 16 1.6
1 28 NA
1 40 3.8
2 0 1.4
2 6 1.8
2 16 2.0
2 28 2.5
2 40 2.8
</code></pre>
<p>Using dplyr I would get the average score per measurement occasion</p>
<pre><code>mean_data <- group_by(DataRlong, week)%>% summarise(procras = mean(procras, na.rm = TRUE))
</code></pre>
<p>Looking like this e.g.:</p>
<pre><code>Source: local data frame [5 x 2]
occ procras
(dbl) (dbl)
1 0 1.993141
2 6 2.124020
3 16 2.251548
4 28 2.469658
5 40 2.617903
</code></pre>
<p>With ggplot2 I could now plot the average change over time, and by easily adjusting the group_data() of dplyr I could also get means per sub groups (for instance, the average score per occasion for men and women).
Now I would like to add a column to the mean_data table which includes the length for the 95%-CIs around the average score per occasion.</p>
<p><a href="http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/" rel="noreferrer">http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/</a> explains how to get and plot CIs, but this approach seems to become problematic as soon as I wanted to do this for any subgroup, right? So is there a way to let dplyr also include the CI (based on group size, ect.) automatically in the mean_data?
After that it should be fairly easy to plot the new values as CIs into the graphs I hope.
Thank you.</p>
| <r><ggplot2><linechart><confidence-interval><trend> | 2016-03-12 03:26:40 | HQ |
35,953,417 | How to make sublists comprised of unique values from a larger list - python | <p>I have a large list that I want to divide into smaller lists with unique values.</p>
<pre><code>BigList = [2, 1, 0, 2, 2, 1, 2, 1, 0, 3, 0, 1, 3]
</code></pre>
<p>How do I divide it into smaller lists of unique values, which were originally in the bigger list (desired output below):</p>
<pre><code>L1 = [2, 1, 0]
L2 = [2]
L3 = [2, 1]
L4 = [2, 1, 0, 3]
L5 = [0, 1, 3]
</code></pre>
<p>Note that each of the sublists don't have duplicate values, they can have a different number of indexes and all the values in all the sublists are present in the original list.</p>
| <python><list><python-3.x><unique> | 2016-03-12 03:31:46 | LQ_CLOSE |
35,953,507 | PHP Calculation - Modulus 10 check digit generation | <p>I got a problem here figuring out how to do this:</p>
<ol>
<li>I got a document no for example <code>5843</code></li>
<li>Starting with the right-most digit, multiply every other digit by 2 and 1 (For example, <code>(3x2)+(4x1)+(8x2)+(5x1)</code> and so on)</li>
<li>For every multiplication that results a number more than 9, add them digits. (For example, from the calculation on (no.2) we will get this :
<code>(6)+(4)+(16)+(5)</code>. So we got a number (16) which is more that 9. We need to add them <code>(1+6=7)</code>. Now the output will be like this : <code>(6)+(4)+(7)+(5)</code>.</li>
<li>Next, we add them <code>(6)+(4)+(7)+(5)=22</code></li>
<li>Now, we <code>divide 22 by 10</code> and get the remainder which is <code>2</code> in this case.</li>
<li>Lastly we minus the remainder with <code>10</code>. </li>
<li>So the last output will be <code>8</code></li>
</ol>
<p>Can you guys guide me on how to do this? Thank you very much !</p>
| <php><modulus> | 2016-03-12 03:46:45 | LQ_CLOSE |
35,953,732 | Creating an advanced e-commerce website in Rails | <p>Okay, so, as the title suggests I'm supposed to create a rails app. - an e-commerce platform. I've done some background research and found a few useful gems like shoppe, spree. Specifications of my website are:</p>
<ol>
<li>Searching using wide variety of options like price, company, title etc</li>
<li>Companies' accounts for uploading/updating products</li>
<li>Users' accounts for purchasing them</li>
<li>A staff panel (separate from companies' accounts) showing latest orders etc</li>
</ol>
<p>What I want to ask is, is there anyone who has created some sort of a similar app in rails? Which gems are the most useful? With one gem, let's say shoppe, extending its functionality: is it going to be easy like adding companies accounts, user accounts and admin panel? Any general guidelines that you have?</p>
| <ruby-on-rails><ruby><e-commerce><shopping-cart> | 2016-03-12 04:23:31 | LQ_CLOSE |
35,953,848 | What are "Ambient Typings" in the Typescript Typings tool? | <p>I hear the term "ambient" used to describe type definitions downloaded with the <a href="https://github.com/typings/typings">typings</a> tool. What does that mean, though?</p>
<p>I can't seem to find a straightforward definition of it or the <code>--ambient</code> flag.</p>
| <typescript> | 2016-03-12 04:40:54 | HQ |
35,954,161 | With My Navigation Bar Is Messed Up | <p>Need help with the text on my navigation bar. The items in it are all messed up, and jumbled I know my code is really sloppy I am new to coding. This is the link with JS bin here <a href="http://jsbin.com/cibuvozido/edit?html,output" rel="nofollow">http://jsbin.com/cibuvozido/edit?html,output</a></p>
| <javascript> | 2016-03-12 05:30:34 | LQ_CLOSE |
35,954,171 | The length of childNodes XML | <blockquote>
<p>I have 2 same together,First: </p>
</blockquote>
<pre><code><!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var x, i, xmlDoc;
var txt = "";
var text = "<book>" +
"<title>Everyday Italian</title>" +
"<author>Giada De Laurentiis</author>" +
"<year>2005</year>" +
"</book>";
parser = new DOMParser();
xmlDoc = parser.parseFromString(text,"text/xml");
x = xmlDoc.documentElement.childNodes;
document.write(x.length);
</script>
</body>
</html>
</code></pre>
<blockquote>
<p>Second File</p>
</blockquote>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM XML</title>
<script language = "javascript" type = "text/javascript">
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xhttp.readyState == 4 && xhttp.status == 200){
xmlDoc = xhttp.responseXML;
x = xmlDoc.documentElement.childNodes;
document.write(x.length);
}
};
xhttp.open('get','book3.xml',true);
xhttp.send();
</script>
</head>
<body>
</body>
</html>
</code></pre>
<blockquote>
<p>and book3.xml file </p>
</blockquote>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
</book>
</code></pre>
<p>I think text variable in the first code same with code in book3.xml, but when I print x.length, so the result in top is "3" and below in is "7". I try to many times but It's not change. Can you help me for the reason ???</p>
| <javascript><php><jquery><xml><dom> | 2016-03-12 05:31:57 | LQ_CLOSE |
35,954,550 | Linux Map many internal IPs to one external IP | <p>I have one Linux machine with many services which needed to be accessed from outside users, each service has one port, how can i make all these service be accessible by one external public IP?</p>
<p>Thank you.</p>
| <linux><networking><port><centos6> | 2016-03-12 06:29:51 | LQ_CLOSE |
35,954,725 | Error: EACCES: permission denied when trying to install ESLint using npm | <p>I'm trying to install <a href="http://eslint.org/docs/user-guide/getting-started">ESLint</a> with npm by going:</p>
<pre><code>npm install -g eslint
</code></pre>
<p>However I get the following error:</p>
<pre><code>Deans-Air:~ deangibson$ npm install -g eslint
npm ERR! tar.unpack untar error /Users/deangibson/.npm/eslint/2.4.0/package.tgz
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "eslint"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/eslint
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/deangibson/npm-debug.log
</code></pre>
<p>And to be honest I get this every single time I try and install something with npm. Sometimes using 'sudo' works, sometimes it doesn't... How can I fix this once and for all?</p>
| <node.js><macos><npm><eslint> | 2016-03-12 06:55:10 | HQ |
35,955,265 | What's the prob with it? | I am getting error "use of unassigned variable ch" at while(ch != 'n').
I am using visual studio 2015
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
char ch;
do
{
Console.WriteLine("Enter any number");
int i = Convert.ToInt32(Console.ReadLine());
for (int j = 1; j <= 200; j++)
{
int c = i * j;
Console.Write(" " + c);
if (j % 10 == 0)
{
Console.WriteLine();
}
Console.WriteLine("again? " + "(y//n)");
ch = Convert.ToChar(Console.ReadLine());
if (ch == 'y' || ch == 'n')
continue;
else
{
Console.WriteLine("invalid choice");
break;
}
}
}while (ch != 'n');
}
}
} | <c#> | 2016-03-12 08:08:18 | LQ_EDIT |
35,955,387 | Regex to get text between two Special Characters | <p><%=NAME=%>
Your Payment is <%=Payment=%>
Regards
Rakesh Patel</p>
| <vb.net> | 2016-03-12 08:23:09 | LQ_CLOSE |
35,955,494 | Is it possible to implement bottom tab bar functionality like iOS in android? | <p>In iOS , bottom tab bar functionality is very basic. But in android , I can't implement this functionality.
My idea is as follows.
Tab bar contains SMS, Call, Camera - 3 tab bar icons.
Whenever taps this icons, I want to run SMS, Phone call and Camera installed on my android device.
But these should be the same as iOS tab View. (shouldn't be full screen)
I have found solution for a long time, but I can't find the correct way.
Please help me
Thanks</p>
| <android><android-layout><android-tabhost> | 2016-03-12 08:38:02 | LQ_CLOSE |
35,955,571 | Can i do network connections in doInBackground of AsyncTask | <p>Can i do network connections in doInBackground of AsyncTask. If not what to use for this.</p>
<p>As per i know i can use intentService for long running operation but this will lead some complexity in code.</p>
<p>Please suggest for the same.</p>
| <android> | 2016-03-12 08:47:20 | LQ_CLOSE |
35,955,758 | missing ) after argument list. What am I doing wrong? | <p>multiplayerpiano.com</p>
<p>Can I mix JavaScript and jQuery at once?</p>
<pre><code>$(document).on("mousemove".function(evt) {
if (ebsprite.start = true) {
ebsprite.stop()}
)}
</code></pre>
| <javascript><jquery> | 2016-03-12 09:09:31 | LQ_CLOSE |
35,955,946 | My C code is kinda drunk | I'm so confused here... why this code of mine doesn't work as it SHOULD be..
Here's the code:
void print(int x) {
x = 140;
int i,total, length, XLength;
if (x < 10){XLength = 0;}
else {
int sum = 1;
for (i = 0 ; i < 10 ; i++){
total = 10 * sum; sum = total; length = x / total;
if (length < 10 && 1 <= length){ XLength = i+1; break;}
}}
XLength = pow(10,XLength);
printf("%d\n",XLength);
}
Let me explain how the code should works first: It takes an integer x and print out the highest power of 10 value it can be divided by.
So if X = 80, it should print 10 and if x = 12435, it should print 10000.
But... this doesn't work with my code perfectly... if x = 140, it prints 99 but.. if x = 1400, it prints 1000.. then again, if x = 14000 it prints 9999 and if x = 140000 it prints 100000 and the sequence continues...
I've already tried exactly the same code in Java and it works perfectly!!
Why does it not works in C??
| <c> | 2016-03-12 09:33:29 | LQ_EDIT |
35,956,106 | unexpected behaviour of ACL linux | <p>Found the strangest behaviour in using acl using the <code>d</code> switch:</p>
<p>Test with the <code>d:</code> in the setfacl commando</p>
<pre><code>create directory: mkdir /var/tmp/tester
create three users: useradd userA -d /tmp etcβ¦
remove the other permission of the directory: chmod 750 /var/tmp/tester
grant acl permissions for userA: # file: setfacl -md:u:userA:rwx var/tmp/tester/
grant acl permissions for userB: setfacl -m d:u:userB:rx /var/tmp/tester
grant acl permissions for userC(not really needed): setfacl -m d:u:userC:rwx /var/tmp/tester
list the acl of the directory: getfacl /var/tmp/tester
# owner: root
# group: root
user::rwx
group::r-x
other::---
default:user::rwx
default:user:userA:rwx
default:user:userB:r-x
default:user:userC:---
default:group::r-x
default:mask::rwx
default:other::---
Become userA and navigate to the tester dir: ''su - userA cd /var/tmp''/tester
</code></pre>
<p>Result: -bash: cd: /var/tmp/tester: Permission denied</p>
<p>Now same test but not using the <code>d:</code> in my acl setfacl commando </p>
<pre><code>create directory: mkdir /var/tmp/tester
create three users: useradd userA -d /tmp etcβ¦
remove the other permission of the directory: chmod 750 /var/tmp/tester
grant acl permissions for userA: # file: setfacl -m u:userA:rwx var/tmp/tester/
grant acl permissions for userB: setfacl -m u:userB:rx /var/tmp/tester
grant acl permissions for userC(not really needed): setfacl -m u:userC:rwx /var/tmp/tester
list the acl of the directory: getfacl /var/tmp/tester
# owner: root
# group: root
user::rwx
group::r-x
other::---
default:user::rwx
default:user:userA:rwx
default:user:userB:r-x
default:user:userC:---
default:group::r-x
default:mask::rwx
default:other::---
Become userA and navigate to the tester dir: ''su - userA cd /var/tmp''/tester
</code></pre>
<p>Result: Success!?</p>
<p>is this expected behaviour?
Why does the getfacl does not show any difference in the tests?</p>
| <linux><bash><acl> | 2016-03-12 09:51:17 | LQ_CLOSE |
35,956,516 | Send asynchronous request without waiting the response using guzzle | <p>I have the following two functions</p>
<pre><code>public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait')->wait();
$this->logger->debug("I shouldn't wait");
}
public function doNotWait(){
sleep(10);
$this->logger->debug("You shouldn't wait");
}
</code></pre>
<p>Now what I need to see in my logs is:</p>
<pre><code>Started
I shouldn't wait
You shouldn't wait
</code></pre>
<p>But what I see </p>
<pre><code>Started
You shouldn't wait
I shouldn't wait
</code></pre>
<p>Also I tried using the following ways:</p>
<p><strong>Way #1</strong></p>
<pre><code>public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait', ['synchronous' => false])->wait();
$this->logger->debug("I shouldn't wait");
}
</code></pre>
<p><strong>Way #2</strong></p>
<pre><code>public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait');
$queue = \GuzzleHttp\Promise\queue()->run();
$this->logger->debug("I shouldn't wait");
}
</code></pre>
<p>But the result is never the desired one. Any idea? I am using Guzzle 6.x.</p>
| <php><asynchronous><guzzle><guzzle6> | 2016-03-12 10:31:35 | HQ |
35,956,538 | How to read QR code from static image | <p>I know that you can use <code>AVFoundation</code> to scan a QR code using the device's camera. Now here comes the problem, how can I do this from an static <code>UIImage</code> object?</p>
| <ios><qr-code> | 2016-03-12 10:34:18 | HQ |
35,957,077 | How to remove all files with specific extension in folder? | <p>I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.</p>
<p>Thanks!</p>
| <cmd><terminal> | 2016-03-12 11:30:12 | HQ |
35,957,264 | Developer name constraints in App Store | <p>I'm creating my developer account and I have to choose developer name now. I wonder if I can use any name that is availeable or should I use my own name and surname. The problem is that I dont have company with that name. Can google ban my account because I have same name as some other company(even if they created their developer account after me)?</p>
| <android> | 2016-03-12 11:49:12 | LQ_CLOSE |
35,957,344 | What is the simplest way to listen for incoming http traffic in Java/make a REST API? | <p>I have a Java JSVC application in which I would like to expose a web/REST API from.</p>
<p>What is the simplest way to do so?</p>
<p>Every time I try to find a simple tutorial it wants me to install at least a framework and a web server (jersey, tomcat, Java EE, gradle, glassfish, spring and maven has been mentioned a lot)...</p>
<p>Is there a lightweight way to do it with as few dependencies as possible?</p>
<p>My app needs to be able to be deployed as a standalone daemon/service.
It would be problematic if people had to set up a tomcat webserver and/or other stuff.</p>
<p>Isn't any Java app be able to bind to a port and listen for data?</p>
| <java><rest><http><service><jsvc> | 2016-03-12 11:57:00 | LQ_CLOSE |
35,957,463 | Creating a Behavior for a continuously measurable phenomenon | <p>I would like to create a <code>Behavior t a</code> from an <code>IO a</code>, with the intended semantics that the IO action would be run every time the behavior is <code>sample</code>d:</p>
<pre><code>{- language FlexibleContexts #-}
import Reflex.Dom
import Control.Monad.Trans
onDemand :: (MonadWidget t m, MonadIO (PullM t)) => IO a -> m (Behavior t a)
</code></pre>
<p>I hoped I could do this by just executing the <code>measurement</code> in a <code>pull</code>:</p>
<pre><code>onDemand measure = return $ pull (liftIO measure)
</code></pre>
<p>However, the resulting <code>Behavior</code> never changes after an initial <code>measure</code>ment.</p>
<p>The workaround I could come up with was to create a dummy <code>Behavior</code> that changes "frequently enough" and then create a fake dependency on that:</p>
<pre><code>import Data.Time.Clock as Time
hold_ :: (MonadHold t m, Reflex t) => Event t a -> m (Behavior t ())
hold_ = hold () . (() <$)
onDemand :: (MonadWidget t m, MonadIO (PullM t)) => IO a -> m (Behavior t a)
onDemand measure = do
now <- liftIO Time.getCurrentTime
tick <- hold_ =<< tickLossy (1/1200) now
return $ pull $ do
_ <- sample tick
liftIO measure
</code></pre>
<p>This then works as expected; but since <code>Behavior</code>s can only be sampled on demand anyway, this shouldn't be necessary. </p>
<p>What is the correct way to create a <code>Behavior</code> for a continuous, observable-at-any-time phenomenon?</p>
| <haskell><ghcjs><reflex> | 2016-03-12 12:10:07 | HQ |
35,957,842 | Working with Logical And and multiple return values Ruby | I'm trying to check multiple conditions in a function.
So i have written following code
def validate
value,message = check_length(name) && is_valid(id)
end
check_length and is_valid returns 2 values. so i store these values in value and message.
Now if check_length returns value as false, it shouldn't evaluate second method is_valid. Ideally with logical and, if first condition fails, it doesn't execute other method. But for above code even if check_length returns value as false, it evaluates is_valid and value is overridden by return value of is_valid.
How can we break if first condition value is false and return from validate function?
| <ruby> | 2016-03-12 12:51:34 | LQ_EDIT |
35,957,986 | Where should one put a bin directory in Linux? | <p>If i have the source folder of a program containing a /bin directory, what is the "classic" directory to put it in Linux ?</p>
<p>Thanks</p>
| <linux> | 2016-03-12 13:04:50 | LQ_CLOSE |
35,958,051 | apply event only on single class with same class in multiple container | I am trying to creating my own read More/less function for comments.
[ReadMore ReadLess Image][1].
During developing this, I followed by a problem.
Suppose, I have 3 comments(**see first Image**) with more than 500 chars. In these comments all/full text is not shown, so i add *ReadMore* Links to read all comment. Show Only that class where i clicked..
Problem : When i click on one of these links *ReadMore* its shows me all three comments with full text Instead to show me only clicked class text.
Problem Image: img.ctrlv.in/img/16/03/12/56e4110ccb82d.png
My jsBin : https://jsbin.com/waqoror/1/edit?html,js,console,output
Paste my Snippet also here Now
<!-- begin snippet: js hide: true -->
<!-- language: lang-js -->
function mangeText(text) {
var minCharLength = 50;
var readL ="Read Less";
var readM = "Read More";
var txt = text,
txtLength = 0,
totLength = "";
var startDisplayText = "",
startupCont = "",
hiddenContent = "";
txtLength = txt.length;
for (var i = 0; i < minCharLength; i++) {
totLength += txt[i];
//console.log("["+i+"] "+totLength);
}
if (txt.length >= (minCharLength + 50)) {
startupCont += "<span class='yughi501 _po2075 tetb_apndShw umoriRut' style='display:inline-block'> " + totLength +
" <span>" +
"<a href='#' onclick='ReadMoreLess()' class='txb_rdM _d1e301 _oijd51 _pedu' style='display:inline-block'> " +
readM +
"</a>" +
"</span>" +
"</span>";
hiddenContent = "<span class='yughi411 _po21075 _umori120Rut tetb_apndhd' style='display:none'> " + txt +
" <span>" +
"<a href='#' onclick='ReadMoreLess()' class='txb_rdL _pedu'> " +
readL +
" </a>" +
"</span>" +
"</span>";
txt = startupCont;
txt += hiddenContent;
}
return txt;
}
function ReadMoreLess(){
if($(".tetb_apndhd").css("display") == "none"){
console.log("IF");
$(".tetb_apndhd").css({"display":"inline-block"});
$(".tetb_apndShw").css({"display":"none"});
}else if(($(".tetb_apndhd").css("display") == "inline-block")){
console.log("ELSE IF");
$(".tetb_apndShw").css({"display":"inline-block"});
$(".tetb_apndhd").css({"display":"none"});
}
}
$(".apndbtn").click(function (){
var txt = mangeText($(".txt").val());
$(".dclr").append(txt);
});
<!-- language: lang-css -->
.txt{width:300px;height:150px;resize:none}
<!-- language: lang-html -->
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<textarea class="txt" id="tt">Etiam vitae faucibus urna. Cras in enim ac eros cursus euismod. Aenean tristique arcu eu quam pharetra rutrum. Proin tincidunt magna at nibh tristique, eu finibus ipsum ultricies. Nunc eget lorem ac diam dictum condimentum. Vestibulum eu nisi a lorem ornare finibus.</textarea><br/>
<button class="apndbtn">Append</button>
<div class="dclr"></div>
</body>
</html>
<!-- end snippet -->
I tried My best to explain my problem. I hope you will understand.
Ty In advance and used your time on my problem.
[1]: http://i.stack.imgur.com/A2xUQ.png | <javascript><jquery><html><javascript-events> | 2016-03-12 13:11:57 | LQ_EDIT |
35,958,997 | How do i add more than 1 to i every time my for loop runs? | import java.util.Scanner;
public class TxFnd {
public static void main(String [] args){
int i;
for(i=75000;i<125001;i++){
System.out.println(i);
System.out.println("");
}
}
}
| <java><for-loop> | 2016-03-12 14:39:42 | LQ_EDIT |
35,959,258 | Horizontal scroll in ionic 2 | <p>I have been trying to implement horizontal scroll in ionic 2 page. But the content always gets vertically scrolled. </p>
<p>I tried writing my own css by setting 'overflow-x to scroll'. But it didn't work. I also tried ionic's <strong>ion-scroll</strong> component by setting 'scrollX= true'. But the entire content got hidden. i.e it was not visible on the page at all. Below is the sample code i used for ion-scroll. Not sure what exactly i am missing here. </p>
<p>Any guidance on this pls?. (I am new to Ionic 2 and CSS. So sorry if the question is too simple.)</p>
<pre><code><ion-navbar *navbar primary>
<ion-title>
Title
</ion-title>
</ion-navbar>
<ion-content>
<ion-scroll scrollX="true">
<ion-card>
<ion-card-content>
content
</ion-card-content>
</ion-card>
<ion-card>
<ion-card-content>
content
</ion-card-content>
</ion-card>
</ion-scroll>
</ion-content>
</code></pre>
| <ionic-framework><ionic2> | 2016-03-12 15:02:07 | HQ |
35,959,350 | React-Native, Android, Genymotion: ADB server didn't ACK | <p>I am working with React-Native, Android, and Genymotion on Mac. When I run <code>react-native run-android</code> I get this lines at the end of the launch operation:</p>
<pre><code>...
04:54:40 E/adb: error: could not install *smartsocket* listener: Address already in use
04:54:40 E/adb: ADB server didn't ACK
04:54:40 E/ddms: '/Users/paulbrie/Library/Android/sdk/platform-tools/adb,start-server' failed -- run manually if necessary
04:54:40 E/adb: * failed to start daemon *
04:54:40 E/adb: error: cannot connect to daemon
:app:installDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: Timeout getting device list.
...
</code></pre>
<p>However, <code>adb devices</code> returns this:</p>
<pre><code>List of devices attached
192.168.59.101:5555 device
</code></pre>
<p>So far I've found no solution to run my app on the emulator. Has anyone encountered the same issue?</p>
<p>Thanks,
Paul</p>
| <android><react-native><genymotion> | 2016-03-12 15:09:46 | HQ |
35,959,387 | MPU6050 issue explain working | can anubody pls explain me these code to me i didnt understand I2C protocol well via these code but plz altleast give em basic idea how it is working
#include<Wire.h>
const int MPU=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; //int16_t is a 16bit integer. uint16_t is an unsigned 16bit integer
void setup(){
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
Serial.print("AcX = "); Serial.print(AcX);
Serial.print(" | AcY = "); Serial.print(AcY);
Serial.print(" | AcZ = "); Serial.print(AcZ);
Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53); //equation for temperature in degrees C from datasheet
Serial.print(" | GyX = "); Serial.print(GyX);
Serial.print(" | GyY = "); Serial.print(GyY);
Serial.print(" | GyZ = "); Serial.println(GyZ);
delay(333);
} | <arduino-uno> | 2016-03-12 15:13:00 | LQ_EDIT |
35,960,546 | Firebase still retrieving authData after deletion | <p>After I manually deleted the account connected to the uid that my iphone simulator is on (from firebase dashboard), when I run the code below it's somehow still authenticating and retrieving a uid. How is this possible?</p>
<pre><code>let ref = Firebase(url: "https://moviebuffapp.firebaseio.com/")
override func viewDidLoad() {
super.viewDidLoad()
if ref.authData != nil {
let uid = ref.authData.uid
print(uid)
</code></pre>
| <firebase><firebase-authentication> | 2016-03-12 16:54:51 | HQ |
35,960,814 | my task is to write a method that takes 2 arrays containing doubles and takes the larger of the two numbers at each index and returns them | <p>Write a method that takes two arrays containing doubles and returns a new array<br>
that contains the larger of the two values at each index. The method should handle<br>
cases in which one array is longer than the other. I'm not really sure how to go about this, So far I have this in the main:</p>
<pre><code> public static void main(String[] args){
double[] test1 = {3.3, 8.2, 19.0, 38.1, 2.1, 3.7};
double[] test2 = {4.8, 2.1, 27.3, 6.0};
double[] maxResult = maximize(test1, test2);
System.out.println(Arrays.toString(test1));
System.out.println(Arrays.toString(test2));
System.out.println(Arrays.toString(maxResult));
}
</code></pre>
<p>the output I'm trying to get is:</p>
<pre><code> [3.3, 8.2, 19.0, 38.1, 2.1, 3.7]
[4.8, 2.1, 27.3, 6.0]
[4.8, 8.2, 27.3, 38.1, 2.1, 3.7]
</code></pre>
<p>I don't know what to put inside the method to have it take the larger of the two arrays. </p>
| <java> | 2016-03-12 17:15:36 | LQ_CLOSE |
35,960,883 | How to "Unlock Jenkins"? | <p>I am installing Jenkins 2 on windows,after installing,a page is opened,URL is:<br>
<a href="http://localhost:8080/login?from=%2F">http://localhost:8080/login?from=%2F</a> </p>
<p><strong>content of the page is like this:</strong><br>
<a href="https://i.stack.imgur.com/EeLNT.png"><img src="https://i.stack.imgur.com/EeLNT.png" alt="enter image description here"></a></p>
<p><strong>Question:</strong><br>
How to "Unlock Jenkins"? </p>
<p>PS:I have looked for the answer in documentation and google.</p>
| <jenkins> | 2016-03-12 17:21:17 | HQ |
35,961,109 | How to solve this i don't add data using by $_Post Method, but without $_POST method showing undefine variable? | if (isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['age'])){
//Getting values
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$age = $_POST['age'];
//Creating an sql query
$sql = "INSERT INTO info (firstname,lastname,age) VALUES ('$firstname','$lastname','$age')";
//Importing our db connection script
require_once('connect.php');
//Executing query to database
if(mysqli_query($con,$sql)){
echo 'Employee Added Successfully';
}else{
echo 'Could Not Add Employee';
}
//Closing the database
mysqli_close($con);
} | <php><mysql><json><localhost> | 2016-03-12 17:39:41 | LQ_EDIT |
35,961,216 | How to train a RNN with LSTM cells for time series prediction | <p>I'm currently trying to build a simple model for predicting time series. The goal would be to train the model with a sequence so that the model is able to predict future values.</p>
<p>I'm using tensorflow and lstm cells to do so. The model is trained with truncated backpropagation through time. My question is how to structure the data for training.</p>
<p>For example let's assume we want to learn the given sequence:</p>
<pre><code>[1,2,3,4,5,6,7,8,9,10,11,...]
</code></pre>
<p>And we unroll the network for <code>num_steps=4</code>.</p>
<p><strong>Option 1</strong></p>
<pre><code>input data label
1,2,3,4 2,3,4,5
5,6,7,8 6,7,8,9
9,10,11,12 10,11,12,13
...
</code></pre>
<p><strong>Option 2</strong></p>
<pre><code>input data label
1,2,3,4 2,3,4,5
2,3,4,5 3,4,5,6
3,4,5,6 4,5,6,7
...
</code></pre>
<p><strong>Option 3</strong></p>
<pre><code>input data label
1,2,3,4 5
2,3,4,5 6
3,4,5,6 7
...
</code></pre>
<p><strong>Option 4</strong></p>
<pre><code>input data label
1,2,3,4 5
5,6,7,8 9
9,10,11,12 13
...
</code></pre>
<p>Any help would be appreciated.</p>
| <time-series><tensorflow><prediction><lstm> | 2016-03-12 17:49:07 | HQ |
35,961,245 | How to remove all emoji from string - php | <p>How to remove all emoji in following string ?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. π¬π§ππππ°ππΏπΎπΌπ»</p>
| <php><regex> | 2016-03-12 17:52:16 | HQ |
35,961,321 | C++ Problems modifying string with numbers | <p>I have made a simple encryption function,which encrypts everything except 0-9 numbers (ignoring the special characters).</p>
<p>Here is the code.</p>
<pre><code>#include <iostream>
using namespace std;
void encrypt(char s[])
{
char *ptr;
ptr=s;
while(*ptr)
{
switch (*ptr)
{
case 'a': *ptr='b';
break;
case 'b': *ptr='a';
break;
case 'c': *ptr='z';
break;
case 'd': *ptr='y';
break;
case 'e': *ptr='c';
break;
case 'f': *ptr='d';
break;
case 'g': *ptr='x';
break;
case 'h': *ptr='g';
break;
case 'i': *ptr='i';
break;
case 'j': *ptr='h';
break;
case 'k': *ptr='f';
break;
case 'l': *ptr='j';
break;
case 'm': *ptr='q';
break;
case 'n': *ptr='o';
break;
case 'o': *ptr='p';
break;
case 'p': *ptr='m';
break;
case 'q': *ptr='n';
break;
case 'r': *ptr='l';
break;
case 's': *ptr='k';
break;
case 't': *ptr='x';
break;
case 'u': *ptr='w';
break;
case 'v': *ptr='u';
break;
case 'w': *ptr='v';
break;
case 'x': *ptr='t';
break;
case 'y': *ptr='s';
break;
case 'z': *ptr='r';
break;
case 1: *ptr=5;
break;
case 2: *ptr=6;
break;
case 3: *ptr=0;
break;
case 4: *ptr=1;
break;
case 5: *ptr=2;
break;
case 6: *ptr=7;
break;
case 7: *ptr=4;
break;
case 8: *ptr=3;
break;
case 9: *ptr=8;
break;
case 0: *ptr=9;
break;
default: *ptr=*ptr;
break;
}
*ptr++;
}
*ptr='\0';
}
int main()
{
char password[10];
cout<<"Enter the password\n";
cin>>password;
encrypt(password);
cout<<password<<endl;
return 0;
}
</code></pre>
<p>Here is a sample output
sh-4.3$ main<br>
Enter the password<br>
thisisanex!!1234567<br>
xgikikboct!!1234567 </p>
| <c++><pointers> | 2016-03-12 17:59:15 | LQ_CLOSE |
35,961,782 | Why doesn't jQuery/JavaScript work in Safari? | I'm developing a website for a client, and although all jQuery/Javascript code works fine on chrome (e.g. floating navbar, and smooth scroll when you click a navbar item), none of it seems to work in chrome? I've looked at other questions on StackOverflow, and the only advice i've found is to use a HTML validator, because safari can be iffy like that. Although I'm in the process of doing that now, I have a feeling it's something deeper, because most of the HTML issues revolve around obsolete center tags.
At the moment, the site is up at: http://www.grahamcafe.net23.net/Padre/index.html
Any ideas are much appreciated! | <javascript><jquery><html><css><safari> | 2016-03-12 18:39:12 | LQ_EDIT |
35,962,034 | Given a singly linked list, group all odd nodes together followed by the even nodes. | Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
Example:
Given 1->2->3->4->5->NULL,
return 1->3->5->2->4->NULL.
I have seen the solution but I can't understand it, I need someone to visually explain the solution to the problem. | <java><c++><algorithm><linked-list> | 2016-03-12 19:05:24 | LQ_EDIT |
35,962,352 | hi please help me. Not an allowed type in Turbo C++ | So I'm trying to make a grading system. I've already made a program that does it but I just recently found at that we need to use procedures and functions, this is what I've done so far.So what i want to do is take 1/3 of the value of outputgrade and add it with 2/3 of the value of outputgrade2, I tried midterm1=(outputgrade()*1/3)+(outputgrade2*2/3) but I receive an error which is "Not an allowed type". Please somebody help me on what to do.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
double AAO,Quizzes,Project,MajorExam,Midterm;
void inputprelim()
{
clrscr();
gotoxy(3,4);cout<<"Input Prelim Grade";
gotoxy(1,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(1,7);cout<<"Project: ";cin>>Project;
gotoxy(1,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(1,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(1,11);cout<<"Prelim Grade: ";
}
int getgrade(double a, double b, double c, double d)
{
double result;
result=(a*0.10)+(b*0.20)+(c*0.30)+(d*0.40);
cout<<setprecision(1)<<result;
return result;
}
void outputgrade()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void inputmidterm()
{
gotoxy(33,4);cout<<"Input Midterm Grade";
gotoxy(29,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(29,7);cout<<"Project: ";cin>>Project;
gotoxy(29,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(29,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(29,11);cout<<"Temporary Midterm Grade: ";
gotoxy(29,12);cout<<"Final Midterm Grade: ";
}
void outputgrade2()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void main()
{
inputprelim();
gotoxy(15,11);outputgrade();
inputmidterm();
gotoxy(54,11);outputgrade2();
gotoxy(55,11);
Midterm1=(outputgrade()*1/3)+(outputgrade2()*2/3);
}
| <turbo-c++><turbo-c> | 2016-03-12 19:33:37 | LQ_EDIT |
35,962,372 | Return pointer to a structure - C | i have this program, where you enter two dates into two structures (same type), and then I want a function to find which date i entered is the later date. It compares only year and month. Once the later date is found, i want the function to return a pointer to the structure with the later date. I then want to print out the later date.
This is what I have so far, but I get errors and I'm not sure about the pointer syntax.
#include <stdio.h>
struct date{
int year;
int month;
int day;
};
main()
{
struct date dates[2];
int i = 0, res = 0;
for ( i = 0 ; i < 2 ; i++){
printf("Enter a year!");
scanf("%d", &dates[i].year);
printf("Enter a month!");
scanf("%d", &dates[i].month);
printf("Enter a day!");
scanf("%d", &dates[i].day);
}
res = later(&dates[1], &dates[2]);
printf("%d", &res);
}
int later(struct date *one, struct date *two){
if (one->year > two->year){
return *one;
}
else if (one->year == two->year){
if(one->month > two->month){
return *one;
}
else
return *two;
}
else {
return *two;
}
} | <c><pointers><struct><return> | 2016-03-12 19:35:25 | LQ_EDIT |
35,962,754 | GIT: How can I prevent foxtrot merges in my 'master' branch? | <p>A foxtrot merge is a merge where 'origin/master' merges in as a 2nd (or later) parent, like so:</p>
<p><a href="https://i.stack.imgur.com/yZMCS.png"><img src="https://i.stack.imgur.com/yZMCS.png" alt="Commit 'D' is a foxtrot merge because 'origin/master' is its 2nd parent."></a></p>
<p><sup><i>Commit 'D' is a foxtrot merge because 'origin/master' is its 2nd parent. Notice how first-parent history from 'origin/master' contains commit 'B' at this moment. </i></sup></p>
<p>But in my git repo I need all merges involving 'origin/master' to keep 'origin/master' as the 1st parent. Unfortunately git doesn't care about parent-order when it evaluates whether a commit is eligible for fast-forward. This causes the first parent history on my master branch to sometimes lose commits that used to be there (e.g., output of "git log --first-parent").</p>
<p>Here's what happens when commit 'D' from the earlier diagram is pushed:</p>
<p><a href="https://i.stack.imgur.com/ACgpr.png"><img src="https://i.stack.imgur.com/ACgpr.png" alt="How can I prevent this push? First-parent history of 'origin/master' no longer contains commit 'B' after the foxtrot merge is pushed!"></a></p>
<p><sup><i>How can I prevent this push? First-parent history of 'origin/master' no longer contains commit 'B' after the foxtrot merge is pushed!</i></sup></p>
<p>Obviously no commits or work are actually lost, it's just that in my environment I really need "git log --first-parent" to be a stable accumulative record of commits - if you like, a kind of "Write-Once Read-Many" (WORM) database. I have scripts and processes that use "git log --first-parent" to generate changelogs and release notes, as well as to manage ticket transitions in my ticketing system (JIRA). Foxtrot merges are breaking my scripts!</p>
<p>Is there some kind of pre-receive hook I could install in my git repositories to prevent foxtrot merges from getting pushed?</p>
<p><sup><i>p.s. The commit graphs in this stackoverflow question were generated using <a href="http://bit-booster.com/graph.html">http://bit-booster.com/graph.html</a>.</sup></i></p>
| <git><merge><git-merge> | 2016-03-12 20:12:54 | HQ |
35,963,057 | How do I make a regular HTML audio play with a thumbnailed audio track here's my Code | This is my code so if you can help me it'd be great thank's StackExchange
<DOCTYPE! html>
<body>
<script>
function play(){
var audio =
document.getElementById("audio");
audio.play();
}
</script>
<img src="SoundWave.gif"
width="200"
height="200"value="play"
onclick="play()">
<audio id="audio" src="01.mp3">
</audio>
</body> | <html><css> | 2016-03-12 20:42:50 | LQ_EDIT |
35,963,144 | No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating') | <p>I am getting these two error messages when trying to compile:</p>
<pre><code>/Users/dericw/coding/myApplication/lfdate/android/app/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.2.1/res/values-v23/values-v23.xml
Error:(3, 5) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/dericw/Library/Android/sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
</code></pre>
<p>Android Studio then opens up <code>v23/values-23.xml</code> with this style:</p>
<pre><code> <style name="CardView" parent="Base.CardView">
<item name="cardBackgroundColor">?android:attr/colorBackgroundFloating</item>
</style>
</code></pre>
<p>But I don't have that defined anywhere in my app. It is a generated file that is giving me the error. I am pretty stumped on how to fix this issue? Has anyone every encountered this before? How do I fix this?</p>
<p><strong>Project Build File</strong></p>
<pre><code>buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
allprojects {
repositories {
jcenter()
}
}
</code></pre>
<p><strong>App Build File</strong></p>
<pre><code>buildscript {
repositories {
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.something.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 200
versionName "1.7.1"
}
buildTypes {
debug {
versionNameSuffix '-debug'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
sourceSets {
androidTest.setRoot('src/test')
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
transitive = true;
}
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile project(':viewPagerIndicator')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'joda-time:joda-time:2.+'
compile 'com.koushikdutta.async:androidasync:2.+'
compile 'com.edmodo:rangebar:1.+'
compile 'org.lucasr.twowayview:twowayview:0.+'
compile 'com.github.amlcurran.showcaseview:library:5.4.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.+'
compile 'com.getbase:floatingactionbutton:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.wefika:flowlayout:0.+'
compile 'com.hudomju:swipe-to-dismiss-undo:1.+'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.squareup.picasso:picasso:2.+'
}
apply plugin: 'com.google.gms.google-services'
</code></pre>
| <android><android-support-library><android-cardview><build-tools> | 2016-03-12 20:49:47 | HQ |
35,963,585 | Replace string in array | <p>I want to replace a string within an array with another string.<br>
In my example <code>cat</code> should be replaced with <code>mouse</code>:</p>
<pre><code>var arr1 = [ "dog", "cat"];
for(i=0; i<arr1.length; i++){
arr1[i].replace("cat", "mouse");
}
</code></pre>
<p>Unfortunately, the array remains unchanged.</p>
<p>Where is the error?</p>
| <javascript><arrays> | 2016-03-12 21:35:33 | LQ_CLOSE |
35,964,116 | How do I extend another VueJS component in a single-file component? (ES6 vue-loader) | <p>I am using vue-loader (<a href="http://vuejs.github.io/vue-loader/start/spec.html" rel="noreferrer">http://vuejs.github.io/vue-loader/start/spec.html</a>) to construct my <code>*.vue</code> single-file components, but I am having trouble with the process from extending a single-file component from another.</p>
<p>If one component follows the spec to <code>export default { [component "Foo" definition] }</code>, I would think it is just a matter of importing this component (as I would with any child component) and then <code>export default Foo.extend({ [extended component definition] })</code></p>
<p>Unfortunately this does not work. Can anyone please offer advice?</p>
| <javascript><ecmascript-6><vue.js><es6-module-loader> | 2016-03-12 22:30:13 | HQ |
35,964,147 | IllegalArgumentException in Retrofit / must not have replace block | <p>I have the following code : </p>
<pre><code> @GET("api.php?company_name={name}")
Call<Model> getRoms_center(@Query("name") String name);
</code></pre>
<p>According to the official docs, I must use @Query, and i'm using it, but i'm getting the following error : </p>
<pre><code>java.lang.IllegalArgumentException: URL query string "company_name={name}" must not have replace block. For dynamic query parameters use @Query.
</code></pre>
| <android><retrofit> | 2016-03-12 22:34:30 | HQ |
35,964,173 | html css3 how to center multiple divs in other div vertically and horizonally with multiple lines of divs made by clear: both | I have such a html:
<div id="content">
<div id="letter1">T</div>
<div id="letter2">H</div>
<div id="letter3">A</div>
<div id="letter4">T</div>
<div id="letter5" style="clear: both;">W</div>
<div id="letter6">O</div>
<div id="letter7">R</div>
<div id="letter8">K</div>
<div id="letter9">S</div>
</div>
As you can see I have a string divided on chars, each char in another div. **I want to have each word in separate line, each centered horizontally. Take under consideration `clear: both;` to start new line.** Vertical alignment woudl be nice but is not necessity. Number of words (lines) and letters vary depeneding on situation.
All the guides i have found about centering tell about centering multiple divs but they are in one line or are centered after free break line (there is no space for next div in line so it takes next line with remaining divs and center the line). Can anybody help me? | <html><css><centering> | 2016-03-12 22:36:58 | LQ_EDIT |
35,965,466 | Android 6 EditText.setError not working correctly | <p>I have upgraded to android 6 and seeing some strange things when trying to set validation for some editTexts.
I am using android-saripaar for validation:</p>
<pre><code>@Email(messageResId = R.string.error_email)
private EditText email;
@Password(min = 6, scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS)
private EditText password;
@ConfirmPassword
private EditText repassword;
@NotEmpty(messageResId = R.string.error_name)
private EditText firstname;
@NotEmpty(messageResId = R.string.error_name)
private EditText lastname;
private Validator mValidator;
</code></pre>
<p>For some reason the email, password, confirm password are not showing the error message on the popup, while the last and first name are fine</p>
<p><a href="https://i.stack.imgur.com/BcHbk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BcHbk.png" alt="enter image description here"></a></p>
<p>I have tried without the library and the same issue occurred.
Using editText.setError("Some Message")
This did not happen prior to android 6 and was working fine on 5.</p>
<p>Anybody experienced similar to this? if so how did you fix it?</p>
| <android><android-edittext><android-6.0-marshmallow><saripaar> | 2016-03-13 01:37:07 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.