Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
34,846,146
How to calculate differences between consecutive rows in pandas data frame?
<p>I've got a data frame, <code>df</code>, with three columns: <code>count_a</code>, <code>count_b</code> and <code>date</code>; the counts are floats, and the dates are consecutive days in 2015.</p> <p>I'm trying to figure out the difference between each day's counts in both the <code>count_a</code> and <code>count_b</code> columns — meaning, I'm trying to calculate the difference between each row and the preceding row for both of those columns. I've set the date as the index, but am having trouble figuring out how to do this; there were a couple of hints about using <code>pd.Series</code> and <code>pd.DataFrame.diff</code> but I haven't had any luck finding an applicable answer or set of instructions. </p> <p>I'm a bit stuck, and would appreciate some guidance here. </p> <p>Here's what my data frame looks like: </p> <pre><code>df=pd.Dataframe({'count_a': {Timestamp('2015-01-01 00:00:00'): 34175.0, Timestamp('2015-01-02 00:00:00'): 72640.0, Timestamp('2015-01-03 00:00:00'): 109354.0, Timestamp('2015-01-04 00:00:00'): 144491.0, Timestamp('2015-01-05 00:00:00'): 180355.0, Timestamp('2015-01-06 00:00:00'): 214615.0, Timestamp('2015-01-07 00:00:00'): 250096.0, Timestamp('2015-01-08 00:00:00'): 287880.0, Timestamp('2015-01-09 00:00:00'): 332528.0, Timestamp('2015-01-10 00:00:00'): 381460.0, Timestamp('2015-01-11 00:00:00'): 422981.0, Timestamp('2015-01-12 00:00:00'): 463539.0, Timestamp('2015-01-13 00:00:00'): 505395.0, Timestamp('2015-01-14 00:00:00'): 549027.0, Timestamp('2015-01-15 00:00:00'): 595377.0, Timestamp('2015-01-16 00:00:00'): 649043.0, Timestamp('2015-01-17 00:00:00'): 707727.0, Timestamp('2015-01-18 00:00:00'): 761287.0, Timestamp('2015-01-19 00:00:00'): 814372.0, Timestamp('2015-01-20 00:00:00'): 867096.0, Timestamp('2015-01-21 00:00:00'): 920838.0, Timestamp('2015-01-22 00:00:00'): 983405.0, Timestamp('2015-01-23 00:00:00'): 1067243.0, Timestamp('2015-01-24 00:00:00'): 1164421.0, Timestamp('2015-01-25 00:00:00'): 1252178.0, Timestamp('2015-01-26 00:00:00'): 1341484.0, Timestamp('2015-01-27 00:00:00'): 1427600.0, Timestamp('2015-01-28 00:00:00'): 1511549.0, Timestamp('2015-01-29 00:00:00'): 1594846.0, Timestamp('2015-01-30 00:00:00'): 1694226.0, Timestamp('2015-01-31 00:00:00'): 1806727.0, Timestamp('2015-02-01 00:00:00'): 1899880.0, Timestamp('2015-02-02 00:00:00'): 1987978.0, Timestamp('2015-02-03 00:00:00'): 2080338.0, Timestamp('2015-02-04 00:00:00'): 2175775.0, Timestamp('2015-02-05 00:00:00'): 2279525.0, Timestamp('2015-02-06 00:00:00'): 2403306.0, Timestamp('2015-02-07 00:00:00'): 2545696.0, Timestamp('2015-02-08 00:00:00'): 2672464.0, Timestamp('2015-02-09 00:00:00'): 2794788.0}, 'count_b': {Timestamp('2015-01-01 00:00:00'): nan, Timestamp('2015-01-02 00:00:00'): nan, Timestamp('2015-01-03 00:00:00'): nan, Timestamp('2015-01-04 00:00:00'): nan, Timestamp('2015-01-05 00:00:00'): nan, Timestamp('2015-01-06 00:00:00'): nan, Timestamp('2015-01-07 00:00:00'): nan, Timestamp('2015-01-08 00:00:00'): nan, Timestamp('2015-01-09 00:00:00'): nan, Timestamp('2015-01-10 00:00:00'): nan, Timestamp('2015-01-11 00:00:00'): nan, Timestamp('2015-01-12 00:00:00'): nan, Timestamp('2015-01-13 00:00:00'): nan, Timestamp('2015-01-14 00:00:00'): nan, Timestamp('2015-01-15 00:00:00'): nan, Timestamp('2015-01-16 00:00:00'): nan, Timestamp('2015-01-17 00:00:00'): nan, Timestamp('2015-01-18 00:00:00'): nan, Timestamp('2015-01-19 00:00:00'): nan, Timestamp('2015-01-20 00:00:00'): nan, Timestamp('2015-01-21 00:00:00'): nan, Timestamp('2015-01-22 00:00:00'): nan, Timestamp('2015-01-23 00:00:00'): nan, Timestamp('2015-01-24 00:00:00'): 71.0, Timestamp('2015-01-25 00:00:00'): 150.0, Timestamp('2015-01-26 00:00:00'): 236.0, Timestamp('2015-01-27 00:00:00'): 345.0, Timestamp('2015-01-28 00:00:00'): 1239.0, Timestamp('2015-01-29 00:00:00'): 2228.0, Timestamp('2015-01-30 00:00:00'): 7094.0, Timestamp('2015-01-31 00:00:00'): 16593.0, Timestamp('2015-02-01 00:00:00'): 27190.0, Timestamp('2015-02-02 00:00:00'): 37519.0, Timestamp('2015-02-03 00:00:00'): 49003.0, Timestamp('2015-02-04 00:00:00'): 63323.0, Timestamp('2015-02-05 00:00:00'): 79846.0, Timestamp('2015-02-06 00:00:00'): 101568.0, Timestamp('2015-02-07 00:00:00'): 127120.0, Timestamp('2015-02-08 00:00:00'): 149955.0, Timestamp('2015-02-09 00:00:00'): 171440.0}}) </code></pre>
<python><pandas>
2016-01-18 01:56:19
HQ
34,846,530
JAVA: adding and removing elements from a defined variable within a class
I'm trying to get this class to run but I keep running into issues. I'm new to Java and not sure if I am doing this correctly. If someone could just help me out with the addition of elements to a list I can figure out the rest! class ListPractice implements Testable { def mylist = [4,5,6] /** * Adds a set of elements to the mylist variable * * @param elts The elements to be added */ def addToList(List elts) { def newlist = getMylist()+List return newlist } @Override void testMe() { addToList([7,8,9]) assert getMylist() == [4,5,6,7,8,9] assert getMylist() == [7,8,9] } }
<list><groovy>
2016-01-18 02:45:15
LQ_EDIT
34,846,636
Is it possible to continuing running JavaScript code after a redirect?
<p>So, on my website, a user types in a subject they want the gist of, then after searching, it redirects them to a Wikipedia API displaying the general idea of the subject. However, there's a bunch of information about the API that gets in the way on the webpage, so I need to use JavaScript to get rid of that excess stuff.</p> <p>Unfortunately, after changing webpages, it seems I can't run any more code from my website. Any solution to this?</p>
<javascript><html><ajax><api>
2016-01-18 02:58:22
LQ_CLOSE
34,847,089
How do you write (9.5*(4.5)-2.5*3)/(45.5-3.5) in Java?
<p>How do you write (9.5*(4.5)-2.5*3)/(45.5-3.5) in Java?</p>
<java><math><expression>
2016-01-18 03:58:02
LQ_CLOSE
34,847,190
how to check for an empty array java
<p>I wanted to know if this code is valid for checking whether an array is empty, or should I check for null?</p> <pre><code>if(arrayName={}) System.out.println("array empty"); else System.out.println("array not empty"); </code></pre> <p>Thank you!</p>
<java><arrays>
2016-01-18 04:09:21
HQ
34,847,699
Swift Tuple Not a Collection?
In Swift, why isn't a tuple considered a collection type? Of course this is fussbudget territory, but I find a certain amount of fussing helps me understand, retain, and organize what I'm learning. Thanks.
<swift><collections><tuples>
2016-01-18 05:14:52
LQ_EDIT
34,848,401
Divide elements on groups in RecyclerView
<p>I need to divide elements in RecyclerView on groups with titles (like in the Inbox app on the picture below) so help me please to figure out what approach would be better for my case: 1) I can use Heterogenous layouts for it but it is not so convenient to insert new elements in groups (because I need check if elements of the same group is already added or I need to add new divider). So in this case I'll wrap all operations with such data structure into a separate class.</p> <p>2) Theoretically I can wrap each group in its own RecyclerView with label is it a good idea?</p> <p><a href="https://i.stack.imgur.com/XlxLu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XlxLu.png" alt="Inbox app"></a></p>
<android><material-design><android-recyclerview>
2016-01-18 06:23:18
HQ
34,848,505
How to make a loading animation in Console Application written in JavaScript or NodeJs?
<p>How to make a loading animation in Console Application written in JavaScript or NodeJs?</p> <p>Example animation or other animation.</p> <pre><code>1. -- 2. \ 3. | 4. / 5. -- </code></pre>
<javascript><node.js>
2016-01-18 06:31:05
HQ
34,848,634
Multiple input smoothly
<p>I need a form that have such a row need to be repeated multiple times. Row consist of text field, radio, checkbox, select box all types of input field. After typing first input field, cursor should be shown on next field by pressing just enter. Add button should be added to add each row. After submitting form data should be saved in mysql DB.</p> <p>check the screenshot below : - <a href="http://i.stack.imgur.com/TtKRM.png" rel="nofollow">enter image description here</a></p>
<php><mysql><forms>
2016-01-18 06:40:54
LQ_CLOSE
34,849,492
When i am runnig my objective-c code i am facing This error in this Code
Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:6509 2016-01-18 12:35:16.816 ALJ Jobs[1008:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' *** First throw call stack: Here is This code where i am facing problem in objective-c programming. @implementation myCV { NSMutableArray *CvArr; NSMutableArray *address; } -(void) viewDidLoad { [super viewDidLoad]; CvArr = [[NSMutableArray alloc] initWithObjects:@"My Cv_0",@"My Cv_1",@"My Cv_2",@"My Cv_3",@"My Cv_4", nil]; address = [[NSMutableArray alloc] initWithObjects:@"Pakistan_0",@"Pakistan_1",@"pakistan_2",@"pakistan_3",@"pakistan_4",nil]; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [CvArr count]; } - (UITableViewCell *)tabelView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath: indexPath]; Cell.textLabel.text = [CvArr objectAtIndex:indexPath.row]; return Cell; }
<ios><objective-c><uitableview>
2016-01-18 07:42:15
LQ_EDIT
34,849,841
Inhibit all warnings option in Xcode project doesn't hide warning when building
<ol> <li><p>Cocoapods inhibit_all_warnings! doesn't set the Pods project "Inhibit all warnings" to "Yes"</p></li> <li><p>Xcode still displays pods warning after settings Pods project and individual pods "Inhibit all warnings" option to "Yes"</p></li> </ol> <p>Cocoapods version: 0.39.0 Xcode version: 7.2</p> <p>My pod is here:</p> <pre><code>source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! # ignore all warnings from all pods inhibit_all_warnings! pod 'SnapKit', '~&gt; 0.15.0' pod 'Crashlytics' pod 'YLGIFImage' pod 'Fabric' pod "AFNetworking", "~&gt; 2.0" pod 'SDWebImage', '~&gt;3.7' # Changes build active architecture only post_install do |installer_representation| installer_representation.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' end end end </code></pre>
<ios><xcode><compilation><cocoapods>
2016-01-18 08:07:30
HQ
34,850,089
Simple bulls and cows java game
<p>I try to create a verry simple Bulls and Cows game (<a href="https://en.wikipedia.org/wiki/Bulls_and_Cows" rel="nofollow">https://en.wikipedia.org/wiki/Bulls_and_Cows</a>). The game is for my school project. My knowledge is limited, so I need to make the game using only loops, IF-else constructions and other simple functions.</p> <p>The written code works somewhat - generate code and understands that number is hited, but did not indicate how many cows and bulls have in the wrong assumptions.</p> <p>I would be glad if someone point me in the right direction :) Thanks in advance</p> <pre><code>import java.util.Random; import java.util.Scanner; public class BCgame{ public static void main(String[] args){ Random r= new Random(); int number= 0; int trynum = 0; while(uniq(number= (r.nextInt(9000) + 1000))); String targetStr = number +""; boolean game = true; Scanner input = new Scanner(System.in); do{ System.out.println(number); int bulls = 0; int cows = 0; System.out.print("Guess a number: "); int guess; guess = input.nextInt(); if (uniq(guess) || guess &lt; 1000) continue; trynum++; String guessStr = guess + ""; for(int i= 0;i &lt; 4;i++){ if(guessStr.charAt(i) == targetStr.charAt(i)){ bulls++; }else if(targetStr.contains(guessStr.charAt(i)+"")){ cows++; } } if(bulls == 4){ game = false; }else{ System.out.println(cows+" Cows and "+bulls+" Bulls."); } }while(game); System.out.println("You won after "+trynum+" guesses!"); } public static boolean uniq(int num){ String checknum = num+""; if(checknum.charAt(0) == checknum.charAt(1)) return false; else if(checknum.charAt(1) == checknum.charAt(2)) return false; else if(checknum.charAt(2) == checknum.charAt(3)) return false; return true; }; } </code></pre>
<java><methods>
2016-01-18 08:23:46
LQ_CLOSE
34,850,121
Why forbidden to use a remote function inside a guard
<p>Why I can't to use <code>String</code> or other module in guard?</p> <p>Code:</p> <pre><code>def foo(s1, s2) when String.length(s1) == String.length(s2) do # something end </code></pre> <p>And how I can elegantly reformat such case, when I wish to use module functions?</p>
<elixir>
2016-01-18 08:25:55
HQ
34,850,734
adb cannot bind 'tcp:5037'
<p>It used to work fine, but today after I connected my Android phone to my machine, and run <code>adb devices</code>, I got the following error:</p> <pre><code>* daemon not running. starting it now on port 5037 * cannot bind 'tcp:5037': Address already in use ADB server didn't ACK * failed to start daemon * error: cannot connect to daemon: Operation timed out </code></pre> <p>How to solve this problem? (I am using a MacBook)</p>
<android><adb>
2016-01-18 09:00:49
HQ
34,851,713
Sort Javascript array based on a substring in the array element
<pre><code>var arr = ["This is three", "This is four", "This is one", "This is two", ...]; </code></pre> <p>If I have an array like the one shown above, and I need to sort the array based on the substring value in the strings - i.e one, two, three.., What is the best approach to the problem? </p> <p>My final result should be </p> <pre><code>var sortedArr = ["This is one", "This is two", "This is three", "This is four", ...]; </code></pre>
<javascript><arrays><sorting><substr>
2016-01-18 09:52:45
LQ_CLOSE
34,851,839
How to handle Web Workers "standard" syntax with webpack?
<p>I wonder if it's actually possible to handle Web Worker "standard syntax" in webpack (e.g <code>var worker = new Worker('my-worker-file.js');</code>) and how? </p> <p>I know about <a href="https://github.com/webpack/worker-loader">worker-loader</a> but as far as I understand it needs a specific syntax and is not compatible with the standard one.</p> <p>In other words, is it possible to bundle that file with webpack without changing the code? -> <a href="https://github.com/mdn/simple-web-worker/blob/gh-pages/main.js#L8">https://github.com/mdn/simple-web-worker/blob/gh-pages/main.js#L8</a></p> <p>With <a href="http://browserify.org/">browserify</a>, I would use <a href="https://www.npmjs.com/package/workerify">workerify</a> transform, but I can't find anything in webpack's world.</p>
<webpack><web-worker>
2016-01-18 09:58:02
HQ
34,852,604
Failed to implement a search widget
<p>I'm trying to implement a search widget in my app . I found a useful tutorial from <a href="http://developer.android.com/intl/es/training/search/setup.html" rel="nofollow">here</a>.</p> <p><a href="http://i.stack.imgur.com/T6bEp.png" rel="nofollow">My Activity A</a></p> <p>But my app crashed.</p> <p><strong>Activity A</strong></p> <pre><code> @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.create_menu, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo( searchManager.getSearchableInfo(getComponentName())); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.add: // create new file View menuItemView = findViewById(R.id.add); PopupMenu po = new PopupMenu(HomePage.this, menuItemView); //for drop-down menu po.getMenuInflater().inflate(R.menu.popup_menu, po.getMenu()); po.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // Toast.makeText(MainActivity.this, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show(); if ("Create New File".equals(item.getTitle())) { Intent intent = new Intent(HomePage.this, Information.class); // go to Information class startActivity(intent); } else if ("Edit File".equals(item.getTitle())) { Intent intent = new Intent(HomePage.this, Edit.class); startActivity(intent); } return true; } }); po.show(); //showing popup menu } return super.onOptionsItemSelected(item); } </code></pre> <p><strong>searchable in xml folder</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_name" android:hint="Search by date" /&gt; </code></pre> <p><strong>create_menu</strong></p> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"&gt; &lt;item android:id="@+id/search" android:title="Search by date" android:icon="@mipmap/search" app:showAsAction="collapseActionView|ifRoom" android:actionViewClass="android.widget.SearchView" /&gt; &lt;item android:icon="@mipmap/menu" android:id="@+id/add" android:orderInCategory="100" android:title="Main Menu" app:showAsAction="always" /&gt; &lt;/menu&gt; </code></pre> <p>declare this in mainfest</p> <pre><code> &lt;meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /&gt; </code></pre> <p><strong>Error LogCat</strong></p> <pre><code>01-18 18:31:09.298 9215-9215/com.example.project.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.project.myapplication, PID: 9215 java.lang.NullPointerException at com.example.project.myapplication.GUI.HomePage.onCreateOptionsMenu(HomePage.java:104) at android.app.Activity.onCreatePanelMenu(Activity.java:2646) at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:298) at android.support.v7.internal.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallback </code></pre> <p>This is the line where error pointed to <code>searchView.setSearchableInfo(</code></p>
<android><search><nullpointerexception><appbar>
2016-01-18 10:36:01
LQ_CLOSE
34,852,836
Remove underscore from a string in R
<p>In my data.frame, I have a column of type <code>character</code>, where all the values look like this : <code>123_456</code> (three digits, an underscore, three digits).</p> <p>I need to transform these values to a <code>numeric</code>, and <code>as.numeric(my_dataframe$my_column)</code> gives me a <code>NA</code>. Therefore I need to remove the underscore first, in order to do <code>as.numeric</code>.</p> <p>How would I do that please ?</p> <p>Thanks</p>
<r>
2016-01-18 10:48:36
LQ_CLOSE
34,853,034
find primers and palindromes in python
A palindromic prime is a prime number that is also palindromic. For example, 131 is a prime and also a palindromic prime, as are 313 and 757. I need to write a function that displays the first n palindromic prime numbers. Display 10 numbers per line and align the numbers properly, as follows: 2 3 5 7 11 101 131 151 181 191 313 353 373 383 727 757 787 797 919 929 my code is: def paliPrime(n): a=0 b=n a+=1 for i in range(a,b): paliPrime=True if str(i) == str(i)[::-1]: if i>2: for a in range(2,i): if i%a==0: paliPrime=False break if paliPrime: print i the code works but not in the way i wanted: >>> >>> paliPrime(10) 3 5 7 >>> And what I want is a function that displays the first n palindromic prime numbers. It should display 10 numbers per line and align the numbers properly.
<python><function><loops><primes><palindrome>
2016-01-18 10:58:48
LQ_EDIT
34,853,252
Can anyone help me ? How to access this json data using Angularjs?
[{"_id":"5693413efc055b0011ac7891","attribute":[{"Size":"asd","Brand":"asds","product_id":"1"}]},{"_id":"569cb82c079bfa80094dc936","attribute":[{"Size":"SA","Brand":"123","product_id":"2"}]}]
<javascript><angularjs><mean>
2016-01-18 11:08:55
LQ_EDIT
34,853,620
how can I pass parameter from javascript to php
<p>the javascript code as below...how can I pass x to php?And there is not any button. </p> <pre><code> function f(){ var x = document.getElementById("point").innerHTML; } </code></pre> <p>And if I pass x to the php file,how can I receive it?</p>
<javascript><php><html>
2016-01-18 11:27:31
LQ_CLOSE
34,853,934
Need help, specifically with removing repeated word in list
I need to develop a program in which it takes in a user inputted string, e.g. ‘to be or not to be’. Then separate the string into its separate words, ‘to’, ’be’, ’or’, ’not’, ’to’, ’be’. The words are then put into a list, [‘to’, ’be’, ’or’, ’not’, ’to’, ’be’] where they are changed into their position in the list. However, if a word is repeated, only the first use of the word is counted and replaced with its position number. So, for example, both ‘to’s in ‘to be or not to be’ will be counted as 1. This is because the word ‘to’ is repeated and so the first appearance of ‘to’ accounts for both of the words. After the words are replaced with their position number, the sentence should be recreated with these numbers. So ‘to be or not to be’ should become ‘1, 2, 3, 4, 1, 2’. The list of both words and numbers should be saved as either separate files or one single file. This is all i have so far: UserSentence = input('Enter your chosen sentence: ') #this is where the user inputs their sentence UserSentence = UserSentence.split()#.split()takes the inputted string and breaks it down into individual words... #... and turns it into a list List1 = UserSentence List2 = UserSentence
<python><python-3.x>
2016-01-18 11:43:53
LQ_EDIT
34,854,618
Shorting the columns of data frame under a specific group
<p>I have a data frame from which the columns has this format:</p> <pre><code>name stock1 stock2 value1 value2 stoc_from_csv Google Yahoo 50 21 stock up to date Opel Tayoota 42 44 </code></pre> <p>How can I reshape the column to have all with 1 the one next to other, same for 2 etc. An example of output:</p> <pre><code> name stock1 value1 stock2 value2 stoc_from_csv Google 50 Yahoo 21 stock up to date Opel 42 Tayoota 44 </code></pre>
<r>
2016-01-18 12:17:37
LQ_CLOSE
34,854,697
CSS display: block, animate H1.. jQuerry
How to slideDown h2 using jQuerry? html <body> <hr> <h2>Text</h2> script $(window).load(function(){ $("h2").slideDown(); }); not working
<jquery><html><css>
2016-01-18 12:22:29
LQ_EDIT
34,854,737
C: Why does semi-colon after a macro cause illegal else compile error
I'm relatively new to C, and apparently I have a fundamental misunderstanding of how macros work. I thought a macro just caused the preprocessor to replace the `@define`d macro with the replacement text. But apparently that's not always the case. My code follows: **TstBasInc.h** #pragma once #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdint.h> #include <stdbool.h> #include <stdarg.h> #include <time.h> // copy macro #define Cpy(ToVar, FrmVar) do { \ errno = strncpy_s(ToVar, sizeof(ToVar), FrmVar, _TRUNCATE); \ if (errno == STRUNCATE) \ fprintf(stderr, "string '%s' was truncated to '%s'\n", FrmVar, ToVar); \ } while(0); // clear numeric array macro #define ClrNumArr(ArrNam, ArrCnt) \ for (s = 0; s < ArrCnt; s++) \ ArrNam[s] = 0; uint32_t s; // subscript typedef struct { short C; short YY; short MM; short DD; } SysDat; **TstMacCmpErr:** #include "stdafx.h" #include "TstBasInc.h" // test basic include file #define ARRCNT 3 int main() { char Cnd = 'E'; // define to use 'else' path char ToVar[7 + 1]; // Cpy To-Variable int IntArr[ARRCNT]; // integer array Cpy(ToVar, "short") // compiles with or without the semi-colon if (Cnd != 'E') // Cpy(ToVar, "short string"); // won't compile: illegal else without matching if Cpy(ToVar, "short string") // will compile else Cpy(ToVar, "extra long string"); // compiles with or without the semi-colon { \ errno = strncpy_s(ToVar, sizeof(ToVar), "short str", _TRUNCATE); \ if (errno == STRUNCATE) \ fprintf(stderr, "string '%s' was truncated to '%s'\n", "short str", ToVar); \ } if (Cnd == 'E') { ClrNumArr(IntArr, ARRCNT) // compiles with or without the semi-colon printf("intarr[0] = %d\n", IntArr[0]); } else printf("intarr[0] is garbage\n"); return 0; } The results follow: string 'extra long string' was truncated to 'extra l' string 'short str' was truncated to 'short s' intarr[0] = 0; As the comments say, when I have a semi-colon after `Cpy(ToVar, "short string");` it won't even compile because I get an `"C2181 illegal else without matching if"` error. As you see, I tried adding a do-while in the macro as suggested [in this post][1], but it didn't make any difference. When the macro code is copied directly (even without the do-while) that code works okay. I would have thought just adding the braces in the macro would have fixed the problem but it didn't. It must have something to do with the `Cpy` ending in an `if` because the `ClrNumArr` macro compiles with or without the semi-colon. So can someone tell me why the `Cpy` macro doesn't just replace the text? I must be missing something simple. I apologize in advance if that's so. I'm using VS 2015 Community Edition Update 1. [1]: http://stackoverflow.com/questions/154136/do-while-and-if-else-statements-in-c-c-macros
<c><macros>
2016-01-18 12:24:46
LQ_EDIT
34,854,860
Sparql Select all diffirent languages appear on Warehouse
I am trying to select all diffirent language that appear on warehouse to display them as a list, but with no luck until now. Is there any way to select languages efficiently? Any idea ? Thanks in advance.
<sparql><rdf><semantic-web>
2016-01-18 12:30:40
LQ_EDIT
34,855,039
delete pairs of data out of a range
I'm trying to delete from a matrix like this: x y 37.013930 048.775597 43.015619 348.803652 06.017302 349.831709 05.018978 348.859767 37.020646 300.887827 23.022307 348.915887l . . . . . . the data pairs (x, y) that are not in the range (44,350.5)=>(4.5,35.8). Does anyone know how to do it?
<python><numpy><pandas>
2016-01-18 12:40:36
LQ_EDIT
34,855,049
Using HMAC SHA256 in Ruby
<p>I'm trying to apply HMAC-SHA256 for generate a key for an Rest API.</p> <p>I'm doing something like this:</p> <pre><code>def generateTransactionHash(stringToHash) key = '123' data = 'stringToHash' digest = OpenSSL::Digest.new('sha256') hmac = OpenSSL::HMAC.digest(digest, key, data) puts hmac end </code></pre> <p>The output of this is always this: (if I put '12345' as parameter or 'HUSYED815X', I do get the same)</p> <pre><code>ۯw/{o���p�T����:��a�h��E|q </code></pre> <p>The API is not working because of this... Can some one help me with that?</p>
<ruby-on-rails><ruby><sha256><hmac>
2016-01-18 12:41:03
HQ
34,856,036
Visual C# - How to write a file comfortable and easy
I'm pretty new in developing C#, and my problem is to write a text file. I found some solution with StreamWriter lik this... StreamWriter file = new StreamWriter(C:\Downloads\test.txt); file.WriteLine("this is line one"); file.WriteLine("\r\n"); file.WriteLine("this is line 2"); file.close(); Is there a more comfortable way to write a file? Maybe without the hardcoded "\r\n"? Kind regards proto
<c#><file><c#-4.0><c#-3.0><filewriter>
2016-01-18 13:33:15
LQ_EDIT
34,856,780
Leaflet : tiles didn't load
<p>I try to use the leaflet-map with polymer. I add the leaflet-map tag inside my template, but when loading (and waiting) there is only one tile which is displayed (in the top left) with the original configuration (no leaflet-tilelayer, only set the latitude, longitude and zoom)</p> <p>I switch to non-polymer version of leaflet, and try invalidateSize function, and there is always the same problem? I think i've missed something, but I don't know why.</p> <p>Does anyone have any idea? Thanks a lot</p>
<javascript><polymer><leaflet>
2016-01-18 14:12:15
LQ_CLOSE
34,856,910
Why does this implicit cast not result in compile-time error?
<p>Just trying to understand C#. Just considering the following simplified example.</p> <pre><code>void Main() { IList&lt;IAnimal&gt; animals = new List&lt;IAnimal&gt; { new Chicken(), new Cow(), }; // Shouldn't this line result in a compile-time error? foreach (Chicken element in animals) { } } public interface IAnimal { } public class Cow : IAnimal { } public class Chicken : IAnimal { } </code></pre> <p>Although the first iteration succeeds, the second does not. Honestly I expected this to fail on compile time. Does anyone understand why it only fails at runtime?</p>
<c#><.net><implicit-cast>
2016-01-18 14:18:30
LQ_CLOSE
34,856,932
How do i install gradle on WINDOWS 10
<p>I tried some ways with the path thing but it didnt work because when i edit the path in System variables it opens up all the paths not like in tutorials where i should just put the ;%GRADLE_HOME%\bin at the end.</p> <p><a href="https://i.stack.imgur.com/CJTlf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CJTlf.png" alt="enter image description here"></a> </p> <p><a href="https://i.stack.imgur.com/mZUTk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mZUTk.png" alt="enter image description here"></a></p>
<gradle>
2016-01-18 14:19:18
HQ
34,857,049
R.java file is not generated
<p>I'm new to Android development. I listen Eclipse is better for beginners. So i downloaded and installed in my laptop, Setup also successfully done. My problem is that errors while run the project because R.java file is not generated. Please help me.</p>
<android>
2016-01-18 14:24:40
LQ_CLOSE
34,857,179
How to index a .PDF file in ElasticSearch
<p>I am new to ElasticSearch. I have gone through very basic tutorial on creating Indexes. I do understand the concept of a indexing. I want ElasticSearch to search inside a .PDF File. Based on my understanding of creating Indexes, it seems I need to read the .PDF file and extract all the keywords for indexing. But, I do not understand what steps I need to follow. How do I read .PFD file to extract keywords.</p>
<elasticsearch>
2016-01-18 14:31:18
HQ
34,857,857
Validate a email field with jquery
<p>I need to validate a email field with jquery but the program doesn't work.</p> <pre><code> var email_form=$('#email'); if(email_form!=null){ console.log("HI"); $('#email').on('input', function(){ console.log("show "); }); } </code></pre> <p>The program prints "HI" but it doesn't print in "show".My purpose is to every time that an user writes a character in a email field I must validate this text. Anyone can help me?</p>
<jquery>
2016-01-18 15:05:01
LQ_CLOSE
34,858,402
Issue to make click on <a> tag in funcional test with selenium
i am to make a functional test and i need to make click on `<a>` tag, but i try some ways and really i don't know, i try with the commands in this url https://saucelabs.com/resources/articles/the-selenium-2018click2019-command, nothing has worked, if somebody can help me , i would apreciate it. Thanks. import time from selenium import webdriver from unittest import TestCase #driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path. class GoToLogin(TestCase): driver = webdriver.Firefox() driver.get('http://192.168.56.101:8000/login/'); #time.sleep(5) # Let the user actually see something! user_field = driver.find_element_by_id('id_username') user_field.send_keys('lruedc') password_field = driver.find_element_by_id('id_password') password_field.send_keys('lejoruca123') button_field = driver.find_element_by_id('btnlogin') button_field.click() #time.sleep(5) # Let the user actually see something! user_field.submit() self.driver.quit()
<python><django><selenium>
2016-01-18 15:31:47
LQ_EDIT
34,859,497
Chrome custom tabs not opening other apps
<p>The <code>Chrome custom tabs</code> doesn't seem to launch other apps by deeplinking.</p> <p>For example a PayPal payment, when <code>Chrome</code> is launched with this URL. It will ask the user if the URL has to be opened with the PayPal app or with Chrome.</p> <p>But this is not the case with <code>Chrome custom tabs</code>.</p> <p>If I use an custom scheme(<code>myapp://deeplinkurl/</code>) it works correctly.</p> <p>How can I allow to let apps override the http scheme?</p>
<android><chrome-custom-tabs>
2016-01-18 16:26:49
HQ
34,859,635
How to get the replication factor of C* cluster?
<p>I cant find it in cassandra.yaml, maybe nodetool can get me the configured replication factor of my cluster?</p> <p>What is the default value of the replication factor?</p>
<cassandra><nodetool>
2016-01-18 16:33:15
HQ
34,859,919
what does the ! mean in Angular? i.e $scope.selected = !$scope.selected;
<p>I was wondering what does the ! actually mean in this method</p> <pre><code> $scope.toggleSelected = function () { $scope.selected = !$scope.selected; }; </code></pre> <p>I understand it's allowing me to set a selected item and it won't work without it but what exactly is the ! for?</p>
<javascript><angularjs>
2016-01-18 16:47:39
LQ_CLOSE
34,860,397
Spacemacs hybrid line numbers
<p>How do I get hybrid line numbering (relative line numbers, but the current line shows the absolute line number instead of 0) in spacemacs for all files?</p> <p>I tried setting relative line numbers in user-config but that doesn't seem to be working, and can't figure out how to replace the 0 in relative mode either:</p> <pre><code>(global-linum-mode) (setq-default dotspacemacs-line-numbers 'relative) </code></pre>
<emacs><spacemacs>
2016-01-18 17:15:01
HQ
34,861,215
Airflow - how to make EmailOperator html_content dynamic?
<p>I'm looking for a method that will allow the content of the emails sent by a given EmailOperator task to be set dynamically. Ideally I would like to make the email contents dependent on the results of an xcom call, preferably through the html_content argument.</p> <pre><code>alert = EmailOperator( task_id=alertTaskID, to='please@dontreply.com', subject='Airflow processing report', html_content='raw content #2', dag=dag ) </code></pre> <p>I notice that the Airflow docs say that xcom calls can be embedded in templates. Perhaps there is a way to formulate an xcom pull using a template on a specified task ID then pass the result in as html_content? Thanks</p>
<airflow>
2016-01-18 18:04:59
HQ
34,861,257
How can i set a tag for viewpager fragments?
<p>I,m using slidingTabLayout with 4 tabs and a viewpager and 4 fragment class for every tab. </p> <p>i need to reload one of my fragments (first tab) in my project when user click some button, and for this i need to have a tag for that fragment</p> <p>my question is : how can i set a tag for one of viewpagers fragment???</p> <p>My MainActivity tab and viewpager codes:</p> <pre><code>public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { Toolbar toolbar; ViewPager pager; ViewPagerAdapter adapter; SlidingTabLayout tabs; CharSequence Titles[]={"نوع","قیمت","برند","همه"}; int Numboftabs = 4; @Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "درج آگهی رایگان", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs. adapter = new ViewPagerAdapter(getSupportFragmentManager(),Titles,Numboftabs); // Assigning ViewPager View and setting the adapter pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(adapter); // Assiging the Sliding Tab Layout View tabs = (SlidingTabLayout) findViewById(R.id.tabs); tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width // Setting Custom Color for the Scroll bar indicator of the Tab View tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @Override public int getIndicatorColor(int position) { return getResources().getColor(R.color.colorWhite); } }); // Setting the ViewPager For the SlidingTabsLayout tabs.setViewPager(pager); pager.setCurrentItem(3); } and .... </code></pre> <p>Thank you a lot</p>
<android><android-fragments><android-viewpager>
2016-01-18 18:07:31
HQ
34,861,729
How do I undo mix phoenix.gen.html?
<p><code>mix phoenix.gen.html</code> generates a bunch of files. How do I do undo this generation? or do i have to do it by hand?</p>
<elixir><phoenix-framework>
2016-01-18 18:37:07
HQ
34,862,219
how to architect/organize a react application
<p>From a maintenance/architecture/performance perspective, when writing a react application, is it better to put all components in a super/parent component and bind it once to a page, or to have multiple mount nodes on the page for each piece of functionality?</p> <p>My current approach is to have multiple mount nodes on the page so I can have a more flexible design. Basically like a bunch of 'component boxes' in different parts of the page, that way I can easily move an entire box to another part of the page and everything still works the same without being dependent on each other.</p> <p>Is there a "best practice" for this (in terms of future maintenance), or has react not been around long enough to establish such a thing?</p>
<reactjs>
2016-01-18 19:07:29
LQ_CLOSE
34,862,324
I am implementing a Minimum Spanning Forrest algorihm in java. But stuck on how to write a loop
Algorithmm: **input :** Graph G **output:** Set of MSTs T **begin** T=null; E=G.Edges; for all vertices in G, Create a tree t having single vertex b add t to T end for repeat Find an edge e ∈ E having minimum weight such that one end belongs to t ∈ T and the other end does not belongs to any of the trees in T Add e to t until e = NULL I'm stuck on the logic for the highlighted block. I've used simple objects for vertex,edge and tree. And for their sets, used array of Objects.
<java><algorithm><graph-algorithm>
2016-01-18 19:14:57
LQ_EDIT
34,862,378
Randomizing a list in Python
<p>I am wondering if there is a good way to "shake up" a list of items in Python. For example <code>[1,2,3,4,5]</code> might get shaken up / randomized to <code>[3,1,4,2,5]</code> (any ordering equally likely).</p>
<python><list><random>
2016-01-18 19:18:00
HQ
34,862,484
Querying a MYSQL database with a GET variable
<p>I would like to query my database with the contents of my Get variable, then retrieve the matching url and put the matching url into a variable, what's the best and safest way of doing this? </p>
<php><mysql>
2016-01-18 19:25:02
LQ_CLOSE
34,862,779
Why does -u mean remember for git push [-u]
In the manual it states that `-u` will tell git to remember where to push to. However, I think this is a strange abbreviation. `-r` would make more sense. It works fine I'm just wondering where these abbreviations come from. Any one?
<git><git-push>
2016-01-18 19:42:00
LQ_EDIT
34,863,114
Dockerfile ONBUILD instruction
<p>I read on the docker documentation how ONBUILD instruction can be used, but it is not clear at all.<br> Can someone please explain it to me?</p>
<docker>
2016-01-18 20:03:05
HQ
34,863,374
how to use CMake file (GLOB SRCS *. ) with a build directory
<p>this is my current CMakeLists.txt file </p> <pre><code>cmake_minimum_required(VERSION 3.3) set(CMAKE_C_FLAGS " -Wall -g ") project( bmi ) file( GLOB SRCS *.cpp *.h ) add_executable( bmi ${SRCS}) </code></pre> <p>This builds from my source directory, but I have to clean up all the extra files after. My question is how do I build this from a build directory if all my source files are in the same source directory? </p> <p>thanks </p>
<cmake>
2016-01-18 20:20:02
HQ
34,863,453
How to set "Selection" scope of search & replace in VS 2015
<p>When I select a text block in text editor and open the search &amp; replace window (Ctrl+H), the search &amp; replace scope is set to "Selection" automatically in VS 2013 and the olders. </p> <p>In VS 2015, the scope is always set to "Current document".</p> <p>I've not found any information about this change. Does anybody know it is a bug or a feature (and can it be re-configured to the former behavior somehow)?</p>
<visual-studio-2015>
2016-01-18 20:24:53
HQ
34,863,645
How can I keep a docker debian container open?
<p>I want to use a debian Docker container to test something, and by this I mean execute some commands in the debian bash console. I tried downloading the image using <code>docker pull debian</code> and then running it using <code>docker run debian</code>, but I get no output. What am I doing wrong? Shouldn't the docker container stay open until I close it?</p>
<bash><ubuntu><docker><debian><dockerfile>
2016-01-18 20:37:28
HQ
34,863,711
How should I save the data from the json response in Android?
<p>lets say I'm creating an app to browse reddit using their API. I'm getting a json response containing submissions, which I plan to populate a listview with. My question is how I should save this data? Should I create a bunch of objects or is there a better way to save it? I will need to be able to identify which submission the user clicks on so they can view the full thread etc.</p>
<android><json>
2016-01-18 20:42:11
LQ_CLOSE
34,864,533
iOS Universal Device App with SpriteKit, how to scale nodes for all views?
<p>I want to make a <strong><em>landscape</em> app</strong> to be <strong>universal</strong>, so that the sprite nodes scale proportionally to whatever view size is running the app. I'd like an <em>entirely programmatic</em> solution because I don't like the IB. </p> <p>My game is pretty simple, and I don't need scrolling or zooming of any kind, so the whole game will always be present and take up the entire view.</p> <p>Is it possible that what I'm looking for is to change the size of the scene to always fit the view? If so, can you explain this thoroughly because I've tried changing this section of my view controller</p> <pre><code> if let scene = GameScene(fileNamed:"GameScene") </code></pre> <p>to be the constructor method that takes size as a parameter but Xcode doesn't like that.</p> <hr> <p><strong>Things I've tried</strong></p> <ol> <li>Using fractions of self.view.bounds.width/height. This usually makes all iPhones look good, but on iPads stretches and skews nodes and the boundary box around thew view.</li> <li>Changing the scaleMode among all four types. I'd like to keep good practice and feel like .AspectFill (default) is the one I should make my app work with, but open to suggestions. Note; I don't want black edges on any device, just the entire view displayed/scaled proportionally.</li> <li>Applying programmatic constraints. Now I'm fairly new to this and don't understand constraints completely, but no tutorials I've seen even from RayWenderlich talk about constraints on nodes so I didn't delve to deep in this.</li> <li><p>Using a method like this to convert points among views. This actually worked pretty well for point positioning of nodes, and if possible I would like this method to work out, but then I still have the problem of sizes of nodes. Also when I build for iPad with this method the view seems to start off as portrait and the nodes look fine but then I have to manually switch it to landscape and the sprites and view boundaries once again get messed up. Here's the method:</p> <pre><code>func convert(point: CGPoint)-&gt;CGPoint { return self.view!.convertPoint(CGPoint(x: point.x, y:self.view!.frame.height-point.y), toScene:self) } </code></pre></li> <li><p>Countless vid tutorials on RW and everywhere else on internet.</p></li> </ol> <p>Thanks in advance! I appreciate the help. I know this topic is weird because a lot of people ask questions about it but everyone's situation seems to be different enough that one solution doesn't fit all.</p>
<ios><swift><sprite-kit><universal>
2016-01-18 21:37:48
HQ
34,864,581
Vector is not clearing
<p>I have created a function that gets a series of guesses (a sequence of colors) from a user and puts them in a vector, and this function is called within a while loop in main().</p> <p>Each time it is called by the while loop, the guess should be cleared before being refilled with inputs. However, within the second loop, entering a color I entered during the first loop activates my error message ("Invalid or repeated color entry..."), suggesting that the vector was not successfully cleared.</p> <p>I've tried to clear it with a space, various strings, etc., but nothing seems to clear it. What am I missing?</p> <p>Function:</p> <pre><code>void getGuess(vector&lt;string&gt; &amp;currentGuessPegs, vector&lt;string&gt; &amp;colorChoices, int maxPegSlots) { string input; // stores input temporarily // ---clear previous guess--- for (int i = 0; i &lt; maxPegSlots; i++) { currentGuessPegs[i] == ""; } // ---prompt player for each peg guess and store in currentGuessPegs--- for (int i = 0; i &lt; maxPegSlots; i++) { cout &lt;&lt; "Peg " &lt;&lt; i+1 &lt;&lt; ": "; cin &gt;&gt; input; while (find(currentGuessPegs.begin(), currentGuessPegs.end(), input) != currentGuessPegs.end() // Loops if color entry has already been used || find(colorChoices.begin(), colorChoices.end(), input) == colorChoices.end()) { // or is an invalid choice cout &lt;&lt; "Invalid or repeated color entry. See color choices and re-enter a color you have not used.\n"; cout &lt;&lt; "Peg " &lt;&lt; i + 1 &lt;&lt; ": "; cin &gt;&gt; input; } currentGuessPegs[i] = input; } } </code></pre> <p>And here is my call to the function from main():</p> <pre><code>// ---get and check guesses until maximum # of guesses is exceeded or solution is guessed--- while (guessCount &lt; maximumGuesses &amp;&amp; solutionGuessed == false) { getGuess(currentGuess, colorOptions, numberOfPegs); // get the guess solutionGuessed = checkGuess(currentGuess, solution, numberOfPegs, red, white); // check the guess; returns true if solution was guessed cout &lt;&lt; "r: " &lt;&lt; red &lt;&lt; " w: " &lt;&lt; white &lt;&lt; endl &lt;&lt; endl; guessCount++; } </code></pre>
<c++>
2016-01-18 21:41:50
LQ_CLOSE
34,864,690
Apple PushKit didUpdatePushCredentials is never called on iOS 9+
<p>I am developing a VoIP app for iPhone. To receive calls, Apple developed PushKit so developers can send VoIP notifications using APNS.</p> <p>Everything was working fine on iOS 8. When I updated to iOS 9, the <code>PKRegistryDelegate</code> does not fire the method <code>didUpdatePushCredentials</code> after registration.</p> <p>Any ideas/suggestions?</p>
<ios><iphone><apple-push-notifications><voip><pushkit>
2016-01-18 21:49:43
HQ
34,864,695
Saving prediction results to CSV
<p>I am storing the results from a sklearn regression model to the varibla prediction.</p> <pre><code>prediction = regressor.predict(data[['X']]) print(prediction) </code></pre> <p>The values of the prediction output looks like this</p> <pre><code>[ 266.77832991 201.06347505 446.00066136 499.76736079 295.15519906 214.50514991 422.1043505 531.13126879 287.68760191 201.06347505 402.68859792 478.85808879 286.19408248 192.10235848] </code></pre> <p>I am then trying to use the to_csv function to save the results to a local CSV file:</p> <pre><code>prediction.to_csv('C:/localpath/test.csv') </code></pre> <p>But the error I get back is:</p> <pre><code>AttributeError: 'numpy.ndarray' object has no attribute 'to_csv' </code></pre> <p>I am using Pandas/Numpy/SKlearn. Any idea on the basic fix?</p>
<python><numpy><pandas><scikit-learn>
2016-01-18 21:50:07
HQ
34,865,072
How to refresh the page after a ServiceWorker update?
<p>I've consulted a lot of resources on Service Workers:</p> <ul> <li><a href="https://jakearchibald.com/2014/using-serviceworker-today/#updating-your-serviceworker" rel="noreferrer">Updating your ServiceWorker</a></li> <li><a href="https://ponyfoo.com/articles/serviceworker-revolution" rel="noreferrer">ServiceWorker: Revolution of the Web Platform</a></li> <li>Jake Archibald's lovely <a href="https://github.com/jakearchibald/svgomg/blob/6c21157b65dd779bbf2dd2adf9831aaf71d4bb08/src/js/sw/index.js" rel="noreferrer">SVGOMG</a>. </li> </ul> <p>However, I can't for the life of me figure out how to update the page after a new ServiceWorker has been installed. No matter what I do, my page is stuck on an old version, and only a hard refresh (Cmd-Shift-R) will fix it. No combination of 1) closing the tab, 2) closing Chrome, or 3) <code>location.reload(true)</code> will serve the new content.</p> <p>I have a <a href="https://github.com/nolanlawson/serviceworker-update-demo" rel="noreferrer">super simple example app</a> mostly based on SVGOMG. On installation, I cache a bunch of resources using <code>cache.addAll()</code>, and I also do <code>skipWaiting()</code> if the current version's major version number doesn't match the active version's number (based on an IndexedDB lookup):</p> <pre><code>self.addEventListener('install', function install(event) { event.waitUntil((async () =&gt; { var activeVersionPromise = localForage.getItem('active-version'); var cache = await caches.open('cache-' + version); await cache.addAll(staticContent); var activeVersion = await activeVersionPromise; if (!activeVersion || semver.parse(activeVersion).major === semver.parse(version).major) { if (self.skipWaiting) { // wrapping in an if while Chrome 40 is still around self.skipWaiting(); } } })()); }); </code></pre> <p>I'm using a semver-inspired system where the major version number indicates that the new ServiceWorker can't be hot-swapped for the old one. This works on the ServiceWorker side - a bump from v1.0.0 to v1.0.1 causes the worker to be immediately installed on a refresh, whereas from v1.0.0 to v2.0.0, it waits for the tab to be closed and reopened before being installed.</p> <p>Back in the main thread, I'm manually updating the ServiceWorker after registration &ndash; otherwise the page never even gets the memo that there's a new version of the ServiceWorker available (oddly I found very few mentions of this anywhere in the ServiceWorker literature):</p> <pre><code>navigator.serviceWorker.register('/sw-bundle.js', { scope: './' }).then(registration =&gt; { if (typeof registration.update == 'function') { registration.update(); } }); </code></pre> <p>However, the content that gets served to the main thread is always stuck on an old version of the page ("My version is 1.0.0"), regardless of whether I increment the version to 1.0.1 or 2.0.0.</p> <p>I'm kind of stumped here. I was hoping to find an elegant semver-y solution to ServiceWorker versioning (hence my use of <code>require('./package.json').version</code>), but in my current implementation, the user is perpetually stuck on an old version of the page, unless they hard-refresh or manually clear out all their data. :/</p>
<javascript><service-worker><progressive-web-apps>
2016-01-18 22:16:15
HQ
34,865,717
use conda environment in sublime text 3
<p>Using Sublime Text 3, how can I build a python file using a conda environment that I've created as in <a href="http://conda.pydata.org/docs/using/envs.html" rel="noreferrer">http://conda.pydata.org/docs/using/envs.html</a></p>
<python><sublimetext3><anaconda>
2016-01-18 23:03:30
HQ
34,866,380
Android Studio: Load a File into an Array
<p>I have made a class that can save an array to file, yet, I need it to load the file back into an array inside of an Activity named SampleGridViewAdapter.</p> <p>Text file format named gallerydump_img.txt:</p> <pre><code>https://mywebsite.com/path/samplefile.rtf https://anotherwebsite.com/ https://thirdwebsite.com/example/ </code></pre> <p>I have tried <code>strings = LIST[i]</code>, with <code>strings</code> being the output from the file, <code>i</code> being the loop, and <code>LIST</code> being the array to output the file data to, line by line. More code below:</p> <pre><code>@Override protected void onPostExecute(String[] strings) { for(int i = 0; i &lt; strings.length; i++) { Log.e("GalleryFileDump", strings[i]); ArrayToFile.writeArrayToFile(strings, Environment.getExternalStorageDirectory() + "/gallerydump_img.txt", "Eww, errors. Want a cookie? :: Unable to write to file gallerydump.bin. Check the report below for more information. :)"); strings = LIST[i] } } </code></pre> <p>Any help appreciated. Thanks!</p>
<java><android><android-studio>
2016-01-19 00:07:35
LQ_CLOSE
34,866,447
SaaS app with angularjs and nodejs, how do i organize different clients?
<p>I’m trying to decide what to do I this scenario:</p> <p>I want to create a product that I want to sell in a SaaS business model, I already have the backend more or less thought out and some code in place in nodejs. It handles oAuth, sessions, and controls the roles of the users when accessing a certain endpoint.</p> <p>The doubt is in the frontend architecture: Each client will share the same functionality, but the design of their page will be completely different from one another. I want to put as much of the app logic that I can in services, so I can reuse it, my idea is to only change controllers/templates/directives from client to client, is this ok?</p> <p>Should I have different folders and serve the static files for each client from nodejs? ex: in nodejs I would know the url for client1 was called so I would serve client1-index.html?</p> <p>should I put each client in their own nodejs server and their own host?</p> <p>what other ways are there?</p> <p>I would like to be able to easily reuse the services as I’ll be introducing changes to the features or adding more, and I want to do this upgrades easily.</p> <p>There will also be an admin panel that will be exactly the same for all of them, the part that will change is the one my client's users see.</p> <p>Think of it as having many clients and giving each of them a store, so they can sell their stuff. They want an admin page and a public page. The admin page will the same for all, but the public page has to change.</p> <p>So, and app that shares the same functionality across users but looks completely different for each one of them, how would you do it?</p>
<angularjs><node.js><saas><code-reuse><reusability>
2016-01-19 00:14:38
HQ
34,866,674
Logging from ASP.NET 5 application hosted as Azure Web App
<p>I have an ASP.NET 5 Web API that I host in Azure as a Web App. I want to log messages from my code using Azure Diagnostics. There are multiple article including <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/#apptracelogs" rel="noreferrer">Azure docs</a> that suggest that it should be as easy as <code>System.Diagnostics.Trace.WriteLine</code> once enabled. The logs should show up under <code>LogsFiles/Application</code> and in log stream in Azure.</p> <p>I enabled application logging for the web app:</p> <p><a href="https://i.stack.imgur.com/P0cjl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/P0cjl.png" alt="enter image description here"></a></p> <p>But the following calls produces no logs:</p> <pre><code>System.Diagnostics.Trace.TraceError("TEST"); System.Diagnostics.Trace.TraceInformation("TEST"); System.Diagnostics.Trace.TraceWarning("TEST"); System.Diagnostics.Trace.WriteLine("TEST"); </code></pre> <p>I tried to manually define <code>TRACE</code> symbol, but with no luck:</p> <p><a href="https://i.stack.imgur.com/lp1N8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lp1N8.png" alt="enter image description here"></a></p> <p>I also tried to use the new <code>Microsoft.Extensions.Logging</code> framework and use <code>ILogger.Log</code> API, but without any results again:</p> <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Debug; var sourceSwitch = new SourceSwitch("Sandbox.AspNet5.ApiApp-Demo"); sourceSwitch.Level = SourceLevels.All; loggerFactory.AddTraceSource(sourceSwitch, new ConsoleTraceListener(false)); loggerFactory.AddTraceSource(sourceSwitch, new EventLogTraceListener("Application")); } </code></pre> <p>Any ideas on what am I doing wrong?</p>
<c#><azure><logging><asp.net-core><azure-diagnostics>
2016-01-19 00:41:02
HQ
34,866,803
php forum outputs string of text, how to find source of said string?
<p>I'm working on a site which is a simple php forum, and every so often it'll insert an alert/error div on the page, e.g., "Error! You can't do that because of this," or whatever.</p> <p>How do I search each of the files on my server for the string "Error! You can't do that because of this"? Asked differently, how do I find the source of the various errors when they arise, you know, without having to manually look at every single .php file on the server; thanks.</p>
<php><html>
2016-01-19 00:56:13
LQ_CLOSE
34,867,265
I need to find a xpath, so that I can click on the next button using selenium.
<button id="79436c61930112002b29d457b47ffbfa_next" class="list_nav btn btn-icon h_flip_content" title="" data-nav="true" name="vcr_next" data-original-title="Next page"> <span class="sr-only">Next page</span> <span class="icon-vcr-right"></span> </button> I have already tried getDriver().findElement(By.id("//*[@name='vcr_next']")).click(); which is unstable
<html><selenium><xpath>
2016-01-19 01:53:02
LQ_EDIT
34,868,567
Recursion not executing properly
Below is the snippet of my code please note: n=22 m=7 array = 0000110000111101000101 checker[] = false public static boolean ultra(int step) { System.out.println(step); if(step>n) { System.out.println("success1"); win=true; return true; } else if (step+m>n-1) { System.out.println("success2"); win=true; return true; } else if(step<0) { return false; } else { try { if(array[step+m]==0 && checker[step+m]==false) { System.out.println("jump"); checker[step+m]=true; return ultra(step+m); } System.out.println("print "+step); if(array[step+1]==0 && checker[step+1]==false) { System.out.println("forward"); checker[step+1]=true; return ultra(step+1); } if(array[step-1]==0 && checker[step-1]==false) { System.out.println("backward"); checker[step+-1]=true; return ultra(step-1); } else { System.out.println("defeat"); return false; } } catch(Exception e) { System.out.println(e.toString()); return false; } } } When I call ultra(0), I get following output: "0" "jump" "7" "jump" "14" "print 14" "defeat" So basically, recursion is not going into the second if condition. It doesn't even print "print + step" for the first level. Hope it makes sense.
<java><recursion>
2016-01-19 04:34:14
LQ_EDIT
34,868,838
Boolean Validaiton
I am facing a little problem here. I have fetch the data from data using following code, class CreateGrounddetails < ActiveRecord::Migration def change create_table :grounddetails do |t| t.string :name t.datetime :working_hours t.string :address t.string :contact_no t.string :email t.integer :number_of_grounds t.text :description t.boolean :featured_ground #Featured t.timestamps null: false end end end I have a boolean values stored in the field "featured_ground", now i want to fetch only the data which has "TRUE" value for "featured_ground". How can i achieve that ? Thank you in advance.
<ruby-on-rails><ruby><ruby-on-rails-4><sqlite>
2016-01-19 05:06:14
LQ_EDIT
34,870,407
please help me i'm getting the following error.....so please its urgent
please tell me about the error in android..guide me to solve this please.. Error:Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\android\android-sdk_r24.4.1-windows\android-sdk-windows\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
<android>
2016-01-19 07:01:09
LQ_EDIT
34,870,515
I want to edit this HTML design in ul li format but when I am converting its images are breakdown. I am newbie Please help me Thanks in advance
I want to edit this HTML design in ul li format but when i am trying to do that it goes breakdown. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <body> <table bgcolor="#fff" border="0" cellpadding="0" cellspacing="0" width="1132"><tbody><!------------------------------ START ONE -------------------------------------------------------------------------------------><tr><td valign="top"><table border="0" cellpadding="0" cellspacing="0" height="215" width="215"><tbody><tr><td style="padding:5px; background-color:#332F2C; border-bottom: 1px solid #292623;" valign="middle"><a href="http://www.fatkart.com/lehengas" style="text-align:center; font-size:16px; font-family:Verdana, Arial, Helvetica, sans-serif, 'Trebuchet MS'; color:#fff; text-decoration: none; padding-left: 23px; ">LEHENGA CHOLI</a></td></tr><tr><td style="padding:5px; background-color:#332F2C; border-bottom: 1px solid #292623;" valign="middle"><a href="http://www.fatkart.com/lehengas" style="text-decoration:none; font-size:12px;font-family:arial;padding-left:4px; color:#969696;" target="_blank">Designer Lehengas</a></td></tr><tr><td style="padding:5px; background-color:#332F2C; border-bottom: 1px solid #292623;" valign="middle"><a href="http://www.fatkart.com/bollywood-lehengas" style="text-decoration:none;font-size:12px;font-family:arial;padding-left:4px; color:#969696;" target="_blank">Bollywood Lehengas</a></td></tr><tr><td style="padding:5px; background-color:#332F2C; border-bottom: 1px solid #292623;" valign="middle"><a href="http://www.fatkart.com/lehenga-choli-below-3999" style="text-decoration:none;font-size:12px;font-family:arial;padding-left:4px; color:#969696;" target="_blank">Lehengas Below Rs.3999/-</a></td></tr><tr><td style="padding:5px; background-color:#332F2C; border-bottom: 1px solid #292623;" valign="middle"><a href="http://www.fatkart.com/lehenga-choli-below-4999" style="text-decoration:none;font-size:12px;font-family:arial;padding-left:4px;; color:#969696;" target="_blank">Lehengas Below Rs.4999/-</a></td></tr></tbody></table><!---------------------------------- End First COL------------------------------------------------------------------------><!------------------------------ START ----------------------------------------------------------------------></td><td bgcolor="#ffffff" style=" padding-left:10px;" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="185"><tbody><tr><td><a href="http://www.fatkart.com/esha-gupta" style="text-decoration:none" target="_blank"><img alt=" " border="0" height="" src="http://d66kn5h946avo.cloudfront.net//image/data/zas/menu/L1.jpg" style="display:block;color:#ffffff" title=" " width="185"></a></td></tr></tbody></table></td><!-----------------------------End-----------------------------------------------------------------------------><!------------------------------ START ----------------------------------------------------------------------><td bgcolor="#ffffff" style=" padding-left:10px" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="185"><tbody><tr><td><a href="http://www.fatkart.com/alia-bhatt" style="text-decoration:none" target="_blank"><img alt=" " border="0" height="" src="http://d66kn5h946avo.cloudfront.net//image/data/zas/menu/L2.jpg" style="display:block;color:#ffffff" title=" " width="185"></a></td></tr></tbody></table></td><!-----------------------------End-----------------------------------------------------------------------------><!------------------------------ START ----------------------------------------------------------------------><td bgcolor="#ffffff" style=" padding-left:10px" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="185"><tbody><tr><td><a href="http://www.fatkart.com/kriti-sanon" style="text-decoration:none" target="_blank"><img alt=" " border="0" height="" src="http://d66kn5h946avo.cloudfront.net//image/data/zas/menu/L3.jpg" style="display:block;color:#ffffff" title=" " width="185"></a></td></tr></tbody></table></td><!-----------------------------End-----------------------------------------------------------------------------><!------------------------------ START ----------------------------------------------------------------------><td bgcolor="#ffffff" style=" padding-left:10px" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="185"><tbody><tr><td><a href="http://www.fatkart.com/shraddha-kapoor" style="text-decoration:none" target="_blank"><img alt=" " border="0" height="" src="http://d66kn5h946avo.cloudfront.net//image/data/zas/menu/L4.jpg" style="display:block;color:#ffffff" title=" " width="185"></a></td></tr></tbody></table></td><!-----------------------------End-----------------------------------------------------------------------------></tr></tbody></table> </body> </html> <!-- end snippet -->
<html>
2016-01-19 07:08:22
LQ_EDIT
34,870,530
function attached with a button not working after changing its id in ajax success callback
<p>When I click the button its id, name and val attribute change successfully in ajax success. But if If I click it again the old function attached to the previous id is called not the one attached to the new id. I checked other posts but they did not worked for me either.</p> <pre><code>&lt;input type="submit" name="textareaInsert" id="textareaInsert" class="textareaInsert" value="Insert data"&gt; //script $(document).ready(function() { graph_post_data(); graph_update_data(); }); function graph_post_data() { $('#textareaInsert').on("click", function() { var poll_id = $('#poll_id').val(); var graph_data = $('#graphPost').val(); var ownerid = $('#ownerid').val(); var ownername = $('#ownername').val(); var insert = 'insert'; if(ownerid != null || graph_data != '') { $.ajax({ type:"post", url:"reg2.php", data: {insert:insert, poll_id:poll_id, graph_data:graph_data, ownerid:ownerid, ownername:ownername}, success: function() { $('#textareaInsert').attr("id", "textareaUpdate").attr("name","textareaUpdate").val("Update"); } }).error( function() { console.log("Error in inserting graph data") } ).success( function(data) { var Poll_insert_data = jQuery.parseJSON(data); $('#poll_author').text(Poll_insert_data.data.publisherName); $('#owner_input_data').append(Poll_insert_data.data.data); } ); } else { alert('Please write something first.'); } }); } function graph_update_data() { $('#textareaUpdate').on("click", function() { var poll_id = $('#poll_id').val(); var graph_data = $('#graphPost').val(); var ownerid = $('#ownerid').val(); var ownername = $('#ownername').val(); var update = 'update'; if(ownerid != null || graph_data != '') { $.ajax({ type:"post", url:"reg2.php", data: {update:update, poll_id:poll_id, graph_data:graph_data, ownerid:ownerid, ownername:ownername}, }).error( function() { console.log("Error in updating graph page data") } ) .success( function(data) { var Poll_insert_data = jQuery.parseJSON(data); $('#poll_author').text(Poll_insert_data.data.publisherName); $('#owner_input_data').text("").append(Poll_insert_data.data.data); } ); } else { alert('Please write something first.'); } }); } </code></pre> <p>When I click the button first time 'Insert data' successfully changes its attributes to that of "Upload". But when I click "Upload", function graph_post_data() is called instead of graph_update_data(). I'm not getting what's the problem. Please help me figure it out. </p>
<jquery><ajax>
2016-01-19 07:09:06
LQ_CLOSE
34,870,690
Javascript regex replace consecutive strings
I have a string that looks like this "+919357F%7F%7F%7F%00%00%00%29Your%20OTP%20for" I need all the consecutive %7F replaced with ~ I found a nearly working solution with this command "+919357F%7F%7F%7F%00%00%00%29Your%20OTP%20for".replace(/[%7F]{2,}/g, '~'); but for some reason it does eat away a couple of other % marks that i need to keep intact. Also i could not understand what the {2,} stands for. I know it is responsible for the consecutive replaces but not sure why 2 or 3 makes any difference.
<javascript><regex><string><replace>
2016-01-19 07:18:35
LQ_EDIT
34,870,888
Serving static assets in webpack dev server
<p>I run webpack-dev-server from the root folder of my project. I have <em>assets</em> folder in <em>/src/assets</em> that is copied by CopyWebPackPlugin:</p> <pre><code>new CopyWebpackPlugin([ { from: 'src/assets', to: 'assets' } ]) </code></pre> <p>If I put <em>logo.png</em> inside assets folder then After running webpack-dev-server I can't access <em><a href="http://localhost/assets/logo.png">http://localhost/assets/logo.png</a></em> file, but can access <em><a href="http://localhost/src/assets/logo.png">http://localhost/src/assets/logo.png</a></em> file. However if I run in production mode the situation turns upside down.</p> <p>How to configure webpack server to make <em><a href="http://localhost/assets/logo.png">http://localhost/assets/logo.png</a></em> file accessible in development mode?</p>
<webpack><webpack-dev-server>
2016-01-19 07:30:47
HQ
34,871,814
Failed to start namenode in hadoop?
<p>I config Hadoop in windows 7 <a href="http://toodey.com/2015/08/10/hadoop-installation-on-windows-without-cygwin-in-10-mints/">from tutorial</a> It setting up a Single Node Cluster. When run <code>hdfs namenode -format</code> to format namenode it throw exception like: And when <code>start-all.cmd</code> the windows namenode auto forced then I can open namenode GUI in address – <a href="http://localhost:50070">http://localhost:50070</a>.</p> <p><code>16/01/19 15:18:58 WARN namenode.FSEditLog: No class configured for C, dfs.namenode.edits.journal-plugin.C is empty<br> 16/01/19 15:18:58 ERROR namenode.NameNode: Failed to start namenode. java.lang.IllegalArgumentException: No class configured for C at org.apache.hadoop.hdfs.server.namenode.FSEditLog.getJournalClass(FSEditLog.java:1615) at org.apache.hadoop.hdfs.server.namenode.FSEditLog.createJournal(FSEditLog.java:1629) at org.apache.hadoop.hdfs.server.namenode.FSEditLog.initJournals(FSEditLog.java:282) at org.apache.hadoop.hdfs.server.namenode.FSEditLog.initJournalsForWrite(FSEditLog.java:247) at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:985) at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1429) at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1554) 16/01/19 15:18:58 INFO util.ExitUtil: Exiting with status 1 16/01/19 15:18:58 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************</code></p> <p>Core-site.xml</p> <pre><code>&lt;configuration&gt; &lt;property&gt; &lt;name&gt;fs.defaultFS&lt;/name&gt; &lt;value&gt;hdfs://localhost:9000&lt;/value&gt; &lt;/property&gt; &lt;/configuration&gt; </code></pre> <p>hdfs-site.xml</p> <pre><code>&lt;configuration&gt; &lt;property&gt; &lt;name&gt;dfs.replication&lt;/name&gt; &lt;value&gt;1&lt;/value&gt; &lt;/property&gt; &lt;property&gt; &lt;name&gt;dfs.namenode.name.dir&lt;/name&gt; &lt;value&gt;C:/hadoop/data/namenode&lt;/value&gt; &lt;/property&gt; &lt;property&gt; &lt;name&gt;dfs.datanode.data.dir&lt;/name&gt; &lt;value&gt;C:/hadoop/data/datanode&lt;/value&gt; &lt;/property&gt; &lt;/configuration&gt; </code></pre> <p>mapred-site.xml</p> <pre><code>&lt;configuration&gt; &lt;property&gt; &lt;name&gt;mapreduce.framework.name&lt;/name&gt; &lt;value&gt;yarn&lt;/value&gt; &lt;/property&gt; &lt;/configuration&gt; </code></pre> <p>yarn-site.xml</p> <pre><code>&lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt; &lt;value&gt;mapreduce_shuffle&lt;/value&gt; &lt;/property&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.aux-services.mapreduce.shuffle.class&lt;/name&gt; &lt;value&gt;org.apache.hadoop.mapred.ShuffleHandler&lt;/value&gt; &lt;/property&gt; &lt;/configuration&gt; </code></pre>
<java><apache><hadoop>
2016-01-19 08:28:39
HQ
34,872,382
Manually adding aar with dependency pom/iml file
<p>Since I cannot use a private maven in order to share my library, I was thinking in sharing the aar and importing into another project. The problem comes when the aar and jar files does not contain any dependency. So once I manually import the aar in android studio (using Import .JAR/.AA Package) there is no dependency, and I have to manually add all dependencies again. I already generated a pom file through a gradle task, although I cannot find any way to manually import it on the project.</p> <p>On the build.gradle file automatically generated by the "Import .JAR/.AA Package" is:</p> <pre><code>configurations.maybeCreate("default") artifacts.add("default", file('TestSample_1.0.0.aar')) </code></pre> <p>Is there a way to add the pom/iml file too? something like:</p> <pre><code>artifacts.add("default", file('pomDependencies.xml')) </code></pre>
<android><android-studio><gradle><pom.xml><aar>
2016-01-19 08:56:49
HQ
34,872,479
What is significant of cascading in Hibernate?
<p>Why we are using cascading in Java?? What is its importance. Here i am using for save and update</p> <pre><code>Stock stock = new Stock(); StockDailyRecord stockDailyRecords = new StockDailyRecord(); //set the stock and stockDailyRecords data stockDailyRecords.setStock(stock); stock.getStockDailyRecords().add(stockDailyRecords); session.save(stock); session.save(stockDailyRecords); </code></pre> <p>Is there any alternate way for cascading.?</p>
<java><hibernate>
2016-01-19 09:02:05
LQ_CLOSE
34,872,893
Navigation using JSON & underscore JS
I need to set up a navigation using JSON & underscore JS, there are two headings with 5 links in each. This is the way I have my JSON and I cannot get the underscore to work and bring all the links and labels, can anyone please help: var navigations = [ { "main_label" : "GIRLS", "sub_page_reference" : "girls", "links" : [ { "label" : "NEW IN >", "href" : "/uk/newin", "target" : "_self", }, { "label" : "sales >", "href" : "/uk/salesy", "target" : "_self", }, { "label" : "girls >", "href" : "/uk/girls", "target" : "_self", }, { "label" : "boys >", "href" : "/uk/boys", "target" : "_self", }, { "label" : "party >", "href" : "/uk/party", "target" : "_self", } ] }, { "main_label" : "BOYS", "sub_page_reference" : "boys", "links" : [ { "label" : "NEW IN >", "href" : "/uk/newin", "target" : "_self", }, { "label" : "sales >", "href" : "/uk/salesy", "target" : "_self", }, { "label" : "girls >", "href" : "/uk/girls", "target" : "_self", }, { "label" : "boys >", "href" : "/uk/boys", "target" : "_self", }, { "label" : "party >", "href" : "/uk/party", "target" : "_self", } ] } ];
<javascript><underscore.js>
2016-01-19 09:23:42
LQ_EDIT
34,873,496
How to Delete the cell value in a given range if it contains a string value using excel vba
Can anybody tell me how to delete the cells value in a given range if the cell value is String (Not a particular string, in general any String)
<vba><excel>
2016-01-19 09:50:55
LQ_EDIT
34,874,420
Writing audio to server over TCP socket
<p>I'm trying to transmit real time mic recording to server over TCP socket and server to write input stream to a file. The connection is established but after some time, I'm getting connection refused error at my clientside.</p> <p>Server Code:</p> <pre><code> public class auServer extends Thread{ private static ServerSocket serverSocket; private static int port = 3333; public void run() { System.out.println("init success"); while(true) { try { serverSocket = new ServerSocket(port); serverSocket.setSoTimeout(10000); Socket clientSoc = serverSocket.accept(); System.out.println("Waiting for client on port " +serverSocket.getLocalPort() + "..."); System.out.println("Just connected to " + clientSoc.getRemoteSocketAddress()); InputStream in = clientSoc.getInputStream(); while(in!=null) { writeToFile(in); } System.out.println("socket"); clientSoc.close(); }catch(SocketTimeoutException s) { System.out.println("Socket timed out!"); break; }catch(IOException e) { e.printStackTrace(); System.out.println("some io"); break; } catch (Exception e) { System.out.println("some e"); e.printStackTrace(); } } } private void writeToFile(InputStream in) throws IOException { // Write the output audio in byte String filePath = "8k16bitMono1.wav"; short sData[] = new short[1024]; byte[] bData = IOUtils.toByteArray(in); FileOutputStream os = null; try { os = new FileOutputStream(filePath); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("Short wirting to file" + sData.toString()); try { os.write(bData, 0, 2048); } catch (IOException e) { e.printStackTrace(); } try { os.close(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { // TODO Auto-generated method stub try { Thread serverThread = new auServer(); serverThread.run(); System.out.println("runing"); }catch(IOException e){ e.printStackTrace(); } } } </code></pre> <p>and Client :</p> <pre><code>private void streamData(byte[] bData) throws UnknownHostException, IOException, InterruptedException { //bData is byte array to transmit Thread.sleep(500); Socket client = new Socket("10.221.40.41",3333); OutputStream outToServer = client.getOutputStream(); outToServer.write(bData); if(!isRecording) client.close(); } </code></pre> <p>What could be the problem? Thanks in advance.</p>
<java><android><sockets><tcp><stream>
2016-01-19 10:31:14
HQ
34,874,814
Bower install fails to find satisfying version, although there is a matching tag on GitHub
<p>I am having problems installing bower dependencies on a Windows installation. Installation fails for me on Windows 7 x64, with git <code>2.6.4.windows.1</code>, node <code>v5.4.1</code>, npm <code>3.3.12</code>, bower <code>1.7.2</code>.</p> <p>It works for a colleague on OSX (git <code>2.5.4</code>, node <code>v4.1.1</code>, npm <code>2.14.4</code>, bower <code>1.5.3</code>) and for a colleague on Windows 10 (git <code>2.5.0.windows.1</code>, node <code>v4.2.2</code>, npm <code>2.14.7</code>, bower <code>1.3.11</code>).</p> <p>The error message I am getting basically tells mit that <code>bower-angular-translate</code> does not have a version tag that satisfies <code>2.8.1</code>, but the GitHub repository <a href="https://github.com/angular-translate/bower-angular-translate/releases/tag/2.8.1"><em>does</em> have a version 2.8.1</a>.<br> The failing packages are <code>angular-ui-router</code>, <code>angular-local-storage</code> and <code>angular-translate</code>.</p> <p>I tried downgrading node to <code>0.10.x</code> and <code>4.x.x</code> and reinstalling bower, both did not work.</p> <p>If anyone has experienced the same error message behavior with bower (on windows?) and has successfully solved it, <a href="https://xkcd.com/138/">any pointers</a> would be greatly appreciated.</p> <hr> <p>The error message after running <code>bower install</code>:</p> <pre class="lang-none prettyprint-override"><code>bower angular-translate#~2.8.1 ENORESTARGET No tag found that was able to satisfy ~2.8.1 Additional error details: No versions found in git://github.com/PascalPrecht/bower-angular-translate.git </code></pre> <hr> <p>My <code>bower.json</code>:</p> <pre class="lang-json prettyprint-override"><code>{ "name": "My App Name", "version": "0.0.1", "dependencies": { "angular": "1.4.7", "angular-animate": "1.4.7", "angular-aria": "1.4.7", "angular-cookies": "1.4.7", "angular-resource": "1.4.7", "angular-sanitize": "1.4.7", "angular-material": "0.11.2", "angular-ui-router": "0.2.5", "angular-local-storage": "0.2.x", "angular-translate": "~2.8.1" } } </code></pre> <hr> <p>Just in case, my <code>package.json</code>:</p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>{ "author": "My Name", "name": "My App Name", "version": "0.0.1", "dependencies": {}, "devDependencies": { "chai": "2.2.0", "gulp": "3.9.x", "gulp-angular-filesort": "1.1.1", "gulp-bower-files": "0.1.x", "gulp-clean": "0.2.x", "gulp-debug": "2.1.x", "gulp-concat": "2.2.x", "gulp-filter": "1.0.x", "gulp-inject": "0.4.x", "gulp-less": "1.2.3", "gulp-livereload": "1.3.x", "gulp-tsc": "0.10.x", "gulp-uglify": "1.2.x", "gulp-util": "2.2.x", "gulp-watch": "0.6.x", "karma-coverage": "~0.2.4", "karma-mocha": "~0.1.6", "karma-phantomjs-launcher": "^0.1.4", "karma-sinon-chai": "~0.2.0", "merge-stream": "0.1.x", "mocha": "~1.20.1", "phantomjs": "^1.9.17", "q": "1.0.x", "run-sequence": "0.3.x" } }</code></pre> </div> </div> </p>
<bower><bower-install>
2016-01-19 10:49:23
HQ
34,875,066
Trouble with *ngIf in Angular 2 (TypeScript)
<p>I am using Angular 2 beta (TypeScript). I met a weird problem. I tried Chrome, Firefox, Opera, all same results.</p> <p>When I click the "Toggle" button, it can successfully show/hide the text "Hello World!".</p> <p>When I send the command from another browser using socket, the boolean "show" changes successfully background, however, the text does not show/hide, which looks like the page does not refresh.</p> <pre><code>import {Component, View} from 'angular2/core'; import {bootstrap} from 'angular2/bootstrap'; import {NgIf} from 'angular2/common'; @Component({ selector: 'app' }) @View({ directives: [NgIf], template: ` &lt;button (click)="clicked()"&gt;Toggle&lt;/button&gt; &lt;div&gt; &lt;div *ngIf="show"&gt; &lt;h2&gt;Hello World!&lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; ` }) class App { show: boolean = true; constructor() { Socket.on { If (getMessage) { this.show = !this.show; } } } clicked() { this.show = !this.show; } } bootstrap(App); </code></pre>
<typescript><angular>
2016-01-19 11:01:36
HQ
34,875,081
Get rest of string | Javascript
<p>I need to check the head section specifically within the scripts for a specific number which is a string - <code>"/150185454/"</code>.</p> <p>Currently I'm doing this like so which works well: </p> <pre><code>var headContent = document.getElementsByTagName('head')[0].innerHTML; </code></pre> <p>So <code>"/150185454/"</code> will have something like <code>"Home/Sports"</code> on the end of that. </p> <p>If this is true or within the DOM return me the rest of the string. </p> <p>How do I access the rest of the string to return me <code>"/150185454/Home/Sports"</code>? </p>
<javascript><jquery>
2016-01-19 11:02:30
LQ_CLOSE
34,875,609
having a pointer to pointer in main and create an array in other function
I have this : #include <stdio.h> #include <stdlib.h> void mad(int ***,int ,int ); int main(void){ int **x; int n,m; scanf("%d%d",&n,&m); mad(x,n,m); x[0][0] = 5; printf:("%d\n",x[0][0]); return 0; } void mad(int ***x,int n, int m){ int i; **x = malloc(sizeof(int *)); for(i=0;i<n;i++) ***(x + i) = malloc(m * sizeof(int)); } This is wrong can someone explain why this is wrong and give me the right code
<c><arrays><function><pointers>
2016-01-19 11:28:03
LQ_EDIT
34,875,637
How to pass multiple parameters in command line when running gradle task?
<p>I've got a java and groovy classes that are being run by gradle task. I have managed to make it work but I do not like the way I have to pass the parameters in command line. Here is how I do it currently via command line: <code>gradle runTask -Pmode"['doStuff','username','password']"</code><br> my build.gradle code which takes these parameters looks like this: </p> <pre><code>if (project.hasProperty("mode")) { args Eval.me(mode)} </code></pre> <p>and then I use my arguments/parameters in my java code as follows: </p> <pre><code>String action = args[0]; //"doStuff" String name = args[1]; .. //"username" </code></pre> <p>I was wondering is there a way to pass the parameters in a better way such as: </p> <pre><code>gradle runTask -Pmode=doStuff -Puser=username -Ppass=password </code></pre> <p>and how to use them in my java classes.</p>
<java><gradle><build.gradle>
2016-01-19 11:29:02
HQ
34,875,771
How to animate ng-repeat items relative to click events causing the change
<p>I'm trying to animate a user selecting items from different sets of items. The item should animate from the clicked set to it's new position in list of selected items.</p> <p>In the below demo, consider the pink boxes as available items and the bordered box as the list of selected items (blue boxes). User can select an item by clicking on either of the pink boxes:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>angular.module('test', ['ngAnimate']) .controller('testCtrl', function($scope) { $scope.products = [{}, {}, {}, {}]; $scope.purchased = [{}]; $scope.purchase = function(dir) { $scope.direction = dir $scope.purchased.push($scope.products.pop()); }; }) .directive('testDir', function($animate) { return { link: function(scope, element) { $animate.on('enter', element, function(element, phase) { $target = scope.direction == 'left' ? $('.stock:first') : $('.stock:last'); element.position({ my: 'center', at: 'center', of: $target, using: function(pos, data) { $(this).css(pos); $(this).animate({ top: 0, left: 0 }); } }); }); } }; });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.stock { display: inline-block; width: 50px; height: 50px; background: hotpink; } .stock.right { margin-left: 100px; } .product { height: 50px; width: 50px; border: 1px solid; } .purchased { height: 60px; margin-top: 100px; border: 2px dotted; } .purchased .product { display: inline-block; margin: 5px; background: dodgerblue; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://code.jquery.com/jquery-2.1.3.min.js"&gt;&lt;/script&gt; &lt;script src="https://code.jquery.com/ui/1.11.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;script src="https://code.angularjs.org/1.4.8/angular.js"&gt;&lt;/script&gt; &lt;script src="https://code.angularjs.org/1.4.8/angular-animate.js"&gt;&lt;/script&gt; &lt;div ng-app="test" ng-controller="testCtrl"&gt; &lt;div class="stock" ng-click="purchase('left')"&gt;&lt;/div&gt; &lt;div class="stock right" ng-click="purchase('right')"&gt;&lt;/div&gt; &lt;div class="purchased clearfix"&gt; &lt;div class="product" ng-repeat="product in purchased" data-test-dir&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <hr> <p>Well, it kind of works - but I'm using jQuery-ui to find out the starting position (The position of pink boxes will wary in a responsive design) and jquery animate method to animate the element.</p> <p>Also I have to store the clicked direction in scope and I'm setting both the initial position and animating to end position in the <code>enter</code> event listener.</p> <p>I have been reading and experimenting a lot with built in animation hooks in angular, but couldn't figure out a proper way to animate elements from relative/dynamic positions.</p> <p>Is there a better way to achieve the same user experience in angular js way..? </p>
<javascript><jquery><css><angularjs><jquery-ui>
2016-01-19 11:35:47
HQ
34,876,013
Column repeat direction in microsoft report viewer
<p>I am using windows form to generate Identity Card using c# and Microsoft report viewer. Everything is working fine except I could not find column repeat direction in Microsoft report viewer. </p> <p><strong>Current Scenario</strong></p> <p>My report paper size is A4. Each page can display maximum 10 individual cards. There are 2 columns in page. Each column display 5 cards. It is generating card as shown in image. The column repeat direction is vertically. It first list 1st column (1-5) and then list 2nd column (6-10).</p> <p><a href="https://i.stack.imgur.com/dXnog.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dXnog.png" alt="enter image description here"></a></p> <p><strong>My Requirement</strong></p> <p>I want the report column repeat direction to be horizontally like in the image below. First display 1 then 2 and 3 and 4 and so on.</p> <p><a href="https://i.stack.imgur.com/E2lIr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E2lIr.png" alt="enter image description here"></a></p> <p><strong>Why I want to display horizontally rather than vertically?</strong></p> <p>It will save the paper. For example, if the user generate 4 Identity cards only then as per current scenario, it will generate 4 cards in column 1 and the whole page space is wasted because I can not re-use the left space. </p> <p>By repeating the column direction to horizontally, the 4 cards will be displayed as in column 1, card 1 and 3 and in column 2, card 2 and 4 will be displayed. I can then cut the paper and reuse it later.</p> <p>I have searched alot but could not find any solution. Any suggestion, comments or links will be helpful. I can not use any other reports. Thanks in advance.</p>
<c#><reporting-services><reportviewer><microsoft-reporting>
2016-01-19 11:47:09
HQ
34,876,551
Illegal start of expresssion
import java.text.*; import java.util.*; public class Test { public static void main(String args[]) { public void sample(){ System.out.println("Hello Working ...."); } }
<java>
2016-01-19 12:14:15
LQ_EDIT
34,876,740
Google Play App Review doesn't show App Version code or name
<p>I have released an app on play store, and have received some reviews. In google play developer console, I could not see the version of app in few of the reviews. This is what I found under the APPLICATION heading.</p> <p><code>Version code — Version name —</code></p> <p>I tried searching around, but could not find any explanation for these to be absent. What may be the possible reasons?</p>
<google-play><developer-console>
2016-01-19 12:23:33
HQ
34,876,970
js onclick working strange
<p>I have the next code </p> <pre><code>$.ajax({ url: '/data', type: "POST", data: JSON.stringify(formData), contentType: "application/json", dataType: "json", success: function(response){ for (var i=0; i&lt;response.length; i++) { var htmlEdit = "creating button here"; var btnEdit = jQuery(htmlEdit); btnEdit.appendTo(divCollapse); btnEdit.click(function() { editBooking(btnEdit); }); } } }); function editBooking(btn) { btn.button('loading'); } </code></pre> <p>So I have rows with identical items. Buttons are shown as expected. Click to any button invokes loading state for the <strong>last</strong> button. What I'm doing wrong? Thank you.</p>
<javascript><twitter-bootstrap>
2016-01-19 12:34:42
LQ_CLOSE
34,877,411
Android Studio - Adding an imageview with source
<p>When I add an ImageView in Android Studio from the Palette the program doesn't prompt me to select an actual image like it used to be in Eclipse. It just puts an empty ImageView there like this: </p> <pre><code>&lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView2" /&gt; </code></pre> <p>Is this a feature or a bug? Because it's very annoying that I have to select the src manually each time when this was pretty fast in Eclipse ADT.</p> <p>For reference my Android Studio version is 1.5.1</p>
<android><android-studio>
2016-01-19 12:56:27
LQ_CLOSE
34,878,275
How can this be done in perl
<Root> <Top Name=" "> <Tag name="ALU"> <in name="PC"/> <iodirection name="AB"/> </Tag> <Tag name=" "> <in name="CCB"/> <ou name="PC"/> <bi name="AB"/> </Tag> <Tag name=" "> <in name="DB"/> <ou name="DI"/> <bi name="CCB"/> </Tag> <Tag name=" "> <in name="DI"/> <ou name="DB"/> <bi name="CCB"/> </Tag> </Top> </Root> I'm not a perl expert, but some simple things are hard for me to figure out and one such task is this. The above XML as you can see the attributes/elements, they're repeated couple of times but for different `<in> <io> <ou>` tags . Now I'm looking to return only the repeated attributes/elements and Just print them once. Example : DI DB CCB AB My code snippet goes something like this use strict; use XML::Simple; use Data::Dumper; $xml_1 = XMLin('./tmp.xml'); my $root_top = $xml_1->{Top}; my $mod_top= $root_top1->{Tag}; my @mod = keys %$mod_top; foreach my $mods (values %$mod_top) { my $temp=shift(@mod); print XST_FILE "$temp u_$temp(\n"; my $in_mo = $modules->{in}; my @in_1 = keys %$in_mo; foreach my $name_1 (values %$in_mo) { my $inn = shift(@in_1); if($inn=~/\bname\b/){ print" \.$name_1\($name_1\)\,\n"; } else { print " \.$in\($in\)\,\n"; } } P.S: I'd appreciate if this can be modified only in XML::Simple. Though [XML::Simple is discouraged][1], he's not righteous, but he is the one I'm currently using just to finish this task Any help is appreciated! [1]: http://stackoverflow.com/questions/33267765/why-is-xmlsimple-discouraged
<xml><perl><foreach>
2016-01-19 13:38:44
LQ_EDIT
34,878,803
C++ non-static data member initializers, just a little bit confused
<p>I am a little bit confused about why the following code does what it does:</p> <pre><code>class Base { public: Base() = default; Base(const Base &amp;) =delete; Base &amp;operator=(const Base &amp;) = delete; Base(const char*) {} }; class Holder { public: Holder() = default; private: // Base b = Base(); Base b2 = {}; }; int main() { Holder h; } </code></pre> <p>in this incarnation, it compiles, however if I un-comment <code>Base b = Base();</code> it gives the following error:</p> <pre><code>main.cpp:15:17: error: use of deleted function 'Base::Base(const Base&amp;)' Base b = Base(); ^ main.cpp:5:6: note: declared here Base(const Base &amp;) =delete; ^ </code></pre> <p>and I am just unable to find in the standard why it tries to call the copy constructor for the <code>Base b = Base()</code> initializer, and why doesn't it call for the <code>Base b2 = {}</code> ... or is this just one of those little obscurities that is hidden in a few words in a paragraph somewhere?</p> <p>Can you please give a (short) explanation why this happens?</p> <p>(coliru: <a href="http://coliru.stacked-crooked.com/a/c02ba0293eab2ce5">http://coliru.stacked-crooked.com/a/c02ba0293eab2ce5</a> )</p>
<c++><c++11>
2016-01-19 14:01:49
HQ
34,879,092
Reliability issues with Checkpointing/WAL in Spark Streaming 1.6.0
<h1>Description</h1> <p>We have a Spark Streaming 1.5.2 application in Scala that reads JSON events from a Kinesis Stream, does some transformations/aggregations and writes the results to different S3 prefixes. The current batch interval is 60 seconds. We have 3000-7000 events/sec. We’re using checkpointing to protect us from losing aggregations.</p> <p>It’s been working well for a while, recovering from exceptions and even cluster restarts. We recently recompiled the code for Spark Streaming 1.6.0, only changing the library dependencies in the <em>build.sbt</em> file. After running the code in a Spark 1.6.0 cluster for several hours, we’ve noticed the following:</p> <ol> <li>“Input Rate” and “Processing Time” volatility has increased substantially (see the screenshots below) in 1.6.0.</li> <li>Every few hours, there’s an ‘’Exception thrown while writing record: BlockAdditionEvent … to the WriteAheadLog. java.util.concurrent.TimeoutException: Futures timed out after [5000 milliseconds]” exception (see complete stack trace below) coinciding with the drop to 0 events/sec for specific batches (minutes).</li> </ol> <p>After doing some digging, I think the second issue looks related to this <a href="https://github.com/apache/spark/pull/9143" rel="noreferrer">Pull Request</a>. The initial goal of the PR: “When using S3 as a directory for WALs, the writes take too long. The driver gets very easily bottlenecked when multiple receivers send AddBlock events to the ReceiverTracker. This PR adds batching of events in the ReceivedBlockTracker so that receivers don’t get blocked by the driver for too long.”</p> <p>We are checkpointing in S3 in Spark 1.5.2 and there are no performance/reliability issues. We’ve tested checkpointing in Spark 1.6.0 in S3 and local NAS and in both cases we’re receiving this exception. It looks like when it takes more than 5 seconds to checkpoint a batch, this exception arises and we’ve checked that the events for that batch are lost forever.</p> <h1>Questions</h1> <ul> <li><p>Is the increase in “Input Rate” and “Processing Time” volatility expected in Spark Streaming 1.6.0 and is there any known way of improving it?</p></li> <li><p>Do you know of any workaround apart from these 2?:</p> <p>1) To guarantee that it takes less than 5 seconds for the checkpointing sink to write all files. In my experience, you cannot guarantee that with S3, even for small batches. For local NAS, it depends on who’s in charge of infrastructure (difficult with cloud providers).</p> <p>2) Increase the spark.streaming.driver.writeAheadLog.batchingTimeout property value.</p></li> <li><p>Would you expect to lose any events in the described scenario? I'd think that if batch checkpointing fails, the shard/receiver Sequence Numbers wouldn't be increased and it would be retried at a later time.</p></li> </ul> <h1>Spark 1.5.2 Statistics - Screenshot</h1> <p><a href="https://i.stack.imgur.com/4P0tY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4P0tY.png" alt="enter image description here"></a></p> <h1>Spark 1.6.0 Statistics - Screenshot</h1> <p><a href="https://i.stack.imgur.com/JgAON.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JgAON.png" alt="enter image description here"></a></p> <h1>Full Stack Trace</h1> <pre><code>16/01/19 03:25:03 WARN ReceivedBlockTracker: Exception thrown while writing record: BlockAdditionEvent(ReceivedBlockInfo(0,Some(3521),Some(SequenceNumberRanges(SequenceNumberRange(StreamEventsPRD,shardId-000000000003,49558087746891612304997255299934807015508295035511636018,49558087746891612304997255303224294170679701088606617650), SequenceNumberRange(StreamEventsPRD,shardId-000000000004,49558087949939897337618579003482122196174788079896232002,49558087949939897337618579006984380295598368799020023874), SequenceNumberRange(StreamEventsPRD,shardId-000000000001,49558087735072217349776025034858012188384702720257294354,49558087735072217349776025038332464993957147037082320914), SequenceNumberRange(StreamEventsPRD,shardId-000000000009,49558088270111696152922722880993488801473174525649617042,49558088270111696152922722884455852348849472550727581842), SequenceNumberRange(StreamEventsPRD,shardId-000000000000,49558087841379869711171505550483827793283335010434154498,49558087841379869711171505554030816148032657077741551618), SequenceNumberRange(StreamEventsPRD,shardId-000000000002,49558087853556076589569225785774419228345486684446523426,49558087853556076589569225789389107428993227916817989666))),BlockManagerBasedStoreResult(input-0-1453142312126,Some(3521)))) to the WriteAheadLog. java.util.concurrent.TimeoutException: Futures timed out after [5000 milliseconds] at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223) at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:107) at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) at scala.concurrent.Await$.result(package.scala:107) at org.apache.spark.streaming.util.BatchedWriteAheadLog.write(BatchedWriteAheadLog.scala:81) at org.apache.spark.streaming.scheduler.ReceivedBlockTracker.writeToLog(ReceivedBlockTracker.scala:232) at org.apache.spark.streaming.scheduler.ReceivedBlockTracker.addBlock(ReceivedBlockTracker.scala:87) at org.apache.spark.streaming.scheduler.ReceiverTracker.org$apache$spark$streaming$scheduler$ReceiverTracker$$addBlock(ReceiverTracker.scala:321) at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverTrackerEndpoint$$anonfun$receiveAndReply$1$$anon$1$$anonfun$run$1.apply$mcV$sp(ReceiverTracker.scala:500) at org.apache.spark.util.Utils$.tryLogNonFatalError(Utils.scala:1230) at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverTrackerEndpoint$$anonfun$receiveAndReply$1$$anon$1.run(ReceiverTracker.scala:498) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) </code></pre> <h1>Source Code Extract</h1> <pre><code>... // Function to create a new StreamingContext and set it up def setupContext(): StreamingContext = { ... // Create a StreamingContext val ssc = new StreamingContext(sc, Seconds(batchIntervalSeconds)) // Create a Kinesis DStream val data = KinesisUtils.createStream(ssc, kinesisAppName, kinesisStreamName, kinesisEndpointUrl, RegionUtils.getRegionByEndpoint(kinesisEndpointUrl).getName(), InitialPositionInStream.LATEST, Seconds(kinesisCheckpointIntervalSeconds), StorageLevel.MEMORY_AND_DISK_SER_2, awsAccessKeyId, awsSecretKey) ... ssc.checkpoint(checkpointDir) ssc } // Get or create a streaming context. val ssc = StreamingContext.getActiveOrCreate(checkpointDir, setupContext) ssc.start() ssc.awaitTermination() </code></pre>
<scala><apache-spark><spark-streaming><amazon-kinesis><checkpointing>
2016-01-19 14:15:54
HQ
34,879,525
Code .php gets commented out
<p><strong>1 - Here's a image of my error code .. <em>The purple color zone is the zone commented out automatically and I don't know why it happens...</em></strong></p> <p><a href="https://i.stack.imgur.com/nV5ih.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nV5ih.jpg" alt="enter image description here"></a></p> <p><strong>2 - I use Mozilla Firefox and Chrome, and bothwhere happens this.</strong> <strong>3 - I use XAMPP to connect 80 Apache and 3306 to MySQL ... db works good</strong></p> <p><strong>...WHY MY CODE GETS COMMENTED OUT? SOME HELP? I can give more info if needed thx</strong></p>
<php><html><mysql><google-chrome><xampp>
2016-01-19 14:34:58
LQ_CLOSE
34,879,657
C# passing single quotes through query showing error
string query = "Select * from getLabelDetails where itemlookupCode='"+S"';"; The above query is showing error as it is missing semi column. - "';" - How can I pass single quotes for this query?
<c#><sql>
2016-01-19 14:41:21
LQ_EDIT
34,880,341
How to write 2 byte arrays to a file c#?
I have 2 arrays from my own created zip program.<br> farArray and bytes.<br> they are both byte arrays.<br><br> Now I want to save that in a file (example: "file.zip").<br><br> I know that I can write bytes with this code:<br> File.WriteAllBytes(savefile.FileName, bytes); But I only save 1 byteArray now.<br> How to save 2 of them?<br><br> And can I get back the 2 arrays if I open the file in my script?<br>
<c#><arrays><savefiledialog>
2016-01-19 15:13:17
LQ_EDIT
34,880,551
Write something in .txt file using javascript
<p>How do I write something in a .txt file using javascript?</p> <p>I created a variable holding a specific value and now I want to safe it into a .txt file</p>
<javascript><file>
2016-01-19 15:22:24
LQ_CLOSE
34,880,638
Compound literal lifetime and if blocks
<p>This is a theoretical question, I know how to do this unambiguously, but I got curious and dug into the standard and I need a second pair of standards lawyer eyes.</p> <p>Let's start with two structs and one init function:</p> <pre><code>struct foo { int a; }; struct bar { struct foo *f; }; struct bar * init_bar(struct foo *f) { struct bar *b = malloc(sizeof *b); if (!b) return NULL; b-&gt;f = f; return b; } </code></pre> <p>We now have a sloppy programmer who doesn't check return values:</p> <pre><code>void x(void) { struct bar *b; b = init_bar(&amp;((struct foo){ .a = 42 })); b-&gt;f-&gt;a++; free(b); } </code></pre> <p>From my reading of the standard there's nothing wrong here other than potentially dereferencing a NULL pointer. Modifying <code>struct foo</code> through the pointer in <code>struct bar</code> should be legal because the lifetime of the compound literal sent into <code>init_bar</code> is the block where it's contained, which is the whole function <code>x</code>.</p> <p>But now we have a more careful programmer:</p> <pre><code>void y(void) { struct bar *b; if ((b = init_bar(&amp;((struct foo){ .a = 42 }))) == NULL) err(1, "couldn't allocate b"); b-&gt;f-&gt;a++; free(b); } </code></pre> <p>Code does the same thing, right? So it should work too. But more careful reading of the C11 standard is leading me to believe that this leads to undefined behavior. (emphasis in quotes mine)</p> <blockquote> <p>6.5.2.5 Compound literals</p> <p>5 The value of the compound literal is that of an unnamed object initialized by the initializer list. If the compound literal occurs outside the body of a function, the object has static storage duration; otherwise, <em>it has automatic storage duration associated with the enclosing block</em>.</p> <p>6.8.4 Selection statements</p> <p>3 <em>A selection statement is a block</em> whose scope is a strict subset of the scope of its enclosing block. Each associated substatement is also a block whose scope is a strict subset of the scope of the selection statement.</p> </blockquote> <p>Am I reading this right? Does the fact that the <code>if</code> is a block mean that the lifetime of the compound literal is just the if statement?</p> <p>(In case anyone wonders about where this contrived example came from, in real code <code>init_bar</code> is actually <code>pthread_create</code> and the thread is joined before the function returns, but I didn't want to muddy the waters by involving threads).</p>
<c>
2016-01-19 15:27:09
HQ
34,880,756
Java beginner - using the 'int counter' more than once within a button action
<p>I am a Java beginner and would like to know if I can use 'int counter' more than once as part of a button action. If I try to use this a second time I receive the error 'variable counter is already defined in method jButton1ActionPerformed(ActionEvent)'. Is there a way of re-setting the counter so I can use it again for a different action?</p>
<java><counter>
2016-01-19 15:33:28
LQ_CLOSE
34,881,006
sparse list of values using ranges
<p>is there a more terse way of writing</p> <pre><code>listOf('a'..'z','A'..'Z').flatMap { it } </code></pre> <p>The idea here is to iterate over some values in a range, like the numbers from 1 through 100, skipping 21 through 24</p> <pre><code>listOf(1..20, 25..100).flatMap { it } </code></pre>
<kotlin>
2016-01-19 15:45:02
HQ
34,881,079
pandas distinction between str and object types
<p>Numpy seems to make a distinction between <code>str</code> and <code>object</code> types. For instance I can do ::</p> <pre><code>&gt;&gt;&gt; import pandas as pd &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; np.dtype(str) dtype('S') &gt;&gt;&gt; np.dtype(object) dtype('O') </code></pre> <p>Where dtype('S') and dtype('O') corresponds to <code>str</code> and <code>object</code> respectively.</p> <p>However pandas seem to lack that distinction and coerce <code>str</code> to <code>object</code>. ::</p> <pre><code>&gt;&gt;&gt; df = pd.DataFrame({'a': np.arange(5)}) &gt;&gt;&gt; df.a.dtype dtype('int64') &gt;&gt;&gt; df.a.astype(str).dtype dtype('O') &gt;&gt;&gt; df.a.astype(object).dtype dtype('O') </code></pre> <p>Forcing the type to <code>dtype('S')</code> does not help either. ::</p> <pre><code>&gt;&gt;&gt; df.a.astype(np.dtype(str)).dtype dtype('O') &gt;&gt;&gt; df.a.astype(np.dtype('S')).dtype dtype('O') </code></pre> <p>Is there any explanation for this behavior? </p>
<python><numpy><pandas>
2016-01-19 15:48:18
HQ
34,881,537
How to printf real digit of float in printf
<p>for instance:</p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char **argv) { my_printf("%f\n", 1.233239208938208); my_printf("%f\n", 1.23); return (0); }; </code></pre> <p>I hope output is </p> <pre><code>1.233239208938208 1.23 </code></pre> <p>How should I do?</p>
<c>
2016-01-19 16:08:34
LQ_CLOSE