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
39,320,836
Explain like I'm LITERALLY five...what does it mean to "format" a string?
<p>When you make a string...what does it mean to "format" that string?</p> <p>CHALLENGE: Explain this to me like I'm an absolute idiot. Like, take it to a condescending level. Be mean about it. I'm talking how you would explain a lemonade stand to a very, very stupid child.</p>
<ruby-on-rails><ruby>
2016-09-04 19:44:19
LQ_CLOSE
39,320,961
Uploading Image into R Markdown
<p>I have an image stored on my hard drive and I want to import it into an R-Markdown document I have.</p> <p>I have 2 copies in both PNG and JPEG format, but for the life of me I cannot figure out how the read functions work in the "png" and "jpg" packages.</p> <p>Can someone please help?</p>
<r><markdown>
2016-09-04 20:00:02
LQ_CLOSE
39,320,990
Google Code Archive to Github
<p>I want to migrate this project <a href="https://code.google.com/archive/p/majesticuo" rel="noreferrer">https://code.google.com/archive/p/majesticuo</a> to GitHub maintaining the history.</p> <p>When i try to use the 'Export to GitHub' button, it says 'The Google Code project export tool is no longer available</p> <p>The Google Code to GitHub exporter tool is no longer available. The source code for Google Code projects can now be found in the Google Code Archive.'</p> <p>What would be the best way to do it manually? I have no svn knowledge and know a little bit of git. Thanks so much! </p>
<git><svn><google-code>
2016-09-04 20:02:44
HQ
39,321,625
Delphi 10. String not compiling properly (No crash, Possibly a glitch?)
Today I stumbled upon something mysterious. This line of code: showmessage(menuMain.player[2] + ' ready!'); Generates this message (For example menuMain.player[2] = Player): > Player But if I put code this way (For example menuMain.player[2] = Player): showmessage('Test: ' + menuMain.player[2]); It will generate this message: > Test: Player I do honestly believe this is a compiler glitch, because I have EXACT same line in the other block of code, and it works flawlessly. Now the tough part for me, is that me being dumb, or this is indeed a glitch? Professional help required :P Thanks in advance for help! :)
<string><delphi><delphi-10-seattle>
2016-09-04 21:24:40
LQ_EDIT
39,321,820
error: two or more data types in declaration of ‘setTime’
I am getting this error-> error: two or more data types in declaration of ‘setTime’ for this line of code void ClockType::setTime (int hours, int minutes, int seconds)
<c++>
2016-09-04 21:55:18
LQ_EDIT
39,322,019
Using a map to find subarray with given sum (with negative numbers)
<p>Consider the following problem statement:</p> <blockquote> <p>Given an unsorted array of integers, find a subarray which adds to a given number. If there are more than one subarrays with sum as the given number, print any of them.</p> </blockquote> <pre><code>Examples: Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33 Ouptut: Sum found between indexes 2 and 4 Input: arr[] = {10, 2, -2, -20, 10}, sum = -10 Ouptut: Sum found between indexes 0 to 3 Input: arr[] = {-10, 0, 2, -2, -20, 10}, sum = 20 Ouptut: No subarray with given sum exists </code></pre> <p>On this <a href="http://www.geeksforgeeks.org/find-subarray-with-given-sum-in-array-of-integers/" rel="noreferrer">site</a>, the following linear time solution was suggested involving the use of a map to store the sums of the current subsets as the algorithm iterates through the array:</p> <pre><code>// Function to print subarray with sum as given sum void subArraySum(int arr[], int n, int sum) { // create an empty map unordered_map&lt;int, int&gt; map; // Maintains sum of elements so far int curr_sum = 0; for (int i = 0; i &lt; n; i++) { // add current element to curr_sum curr_sum = curr_sum + arr[i]; // if curr_sum is equal to target sum // we found a subarray starting from index 0 // and ending at index i if (curr_sum == sum) { cout &lt;&lt; "Sum found between indexes " &lt;&lt; 0 &lt;&lt; " to " &lt;&lt; i &lt;&lt; endl; return; } // If curr_sum - sum already exists in map // we have found a subarray with target sum if (map.find(curr_sum - sum) != map.end()) { cout &lt;&lt; "Sum found between indexes " &lt;&lt; map[curr_sum - sum] + 1 &lt;&lt; " to " &lt;&lt; i &lt;&lt; endl; return; } map[curr_sum] = i; } // If we reach here, then no subarray exists cout &lt;&lt; "No subarray with given sum exists"; } // Driver program to test above function int main() { int arr[] = {10, 2, -2, -20, 10}; int n = sizeof(arr)/sizeof(arr[0]); int sum = -10; subArraySum(arr, n, sum); return 0; } </code></pre> <p>With the test case that is provided in the post, the second if statement checking whether current_sum - sum is never entered. Instead, the sum is found and is printed in the first if statement. <strong>So there a few points of confusion here</strong>:</p> <p><strong>1: What is the purpose of looking up <code>current_sum-sum</code> in the map?</strong></p> <p><strong>2: In which cases would the second if statement even be entered to put the map to use in solving the problem?</strong></p>
<c++><arrays><algorithm>
2016-09-04 22:25:28
HQ
39,322,024
Turn Off Whole Line Copy in Visual Studio Code
<p>I'm trying to disable the function in Visual Studio Code where if you don't have a selection highlighted, ctrl+c copies the entire line. I have never tried to do this on purpose, but I am always doing it accidentally when I hit ctrl+c instead of ctrl+v.</p> <p>Here's what I have tried, which seems like it should work:</p> <p>Under File->Preferences->Keyboard Shortcuts, there is the default setting:</p> <pre><code>{ "key": "ctrl+c", "command": "editor.action.clipboardCopyAction", "when": "editorTextFocus" }, </code></pre> <p>I have attempted to change this, so that it only copies when something is selected, by placing the following in my keybindings.json file:</p> <pre><code>{ "key": "ctrl+c", "command": "-editor.action.clipboardCopyAction"}, { "key": "ctrl+c", "command": "editor.action.clipboardCopyAction", "when": "editorHasSelection" } </code></pre> <p>I think this should clear the previous binding before re-binding the copy action to only function when something is actually selected. HOWEVER, it doesn't work. The editor still copies a whole line when nothing is selected. If I only have the first line in there, it successfully removes the binding completely, so I know it's doing something, but the "when" tag doesn't seem to be functioning the way it should.</p> <p>Is there any way to get the editor to do what I want?</p>
<visual-studio-code>
2016-09-04 22:26:25
HQ
39,322,241
Sending a message to a single user using django-channels
<p>I have been trying out <a href="https://channels.readthedocs.io/en/latest/" rel="noreferrer">django-channels</a> including reading the docs and playing around with the examples.</p> <p>I want to be able to send a message to a single user that is triggered by saving a new instance to a database.</p> <p>My use case is creating a new notification (via a celery task) and once the notification has saved, sending this notification to a single user.</p> <p>This sounds like it is possible (from the <a href="http://channels.readthedocs.io/en/latest/concepts.html" rel="noreferrer">django-channels docs</a>)</p> <blockquote> <p>...the crucial part is that you can run code (and so send on channels) in response to any event - and that includes ones you create. You can trigger on model saves, on other incoming messages, or from code paths inside views and forms.</p> </blockquote> <p>However reading the docs further and playing around with the <a href="https://github.com/andrewgodwin/channels-examples/" rel="noreferrer">django-channels examples</a>, I can't see how I can do this. The databinding and liveblog examples demonstrate sending to a group, but I can't see how to just send to a single user.</p> <p>Any suggestions would be much appreciated.</p>
<django><django-channels>
2016-09-04 23:10:39
HQ
39,322,904
How to return value from webView.evaluateJavascript callback?
<p>So I have a class named <strong>JavascriptBridge</strong> that I use to communicate between Java and Javascript.</p> <p>To send commands to javascript, I simply use this:</p> <pre><code>public void sendDataToJs(String command) { webView.loadUrl("javascript:(function() { " + command + "})()"); } </code></pre> <p>My problem is that I would also need a function that return a response from the Javascript. I try using <strong>webView.evaluateJavascript</strong>, but it skip the callback, as evaluateJavascript is done on another thread.</p> <pre><code>public String getDataFromJs(String command, WebView webView) { String data = null; webView.evaluateJavascript("(function() { return " + command + "; })();", new ValueCallback&lt;String&gt;() { @Override public void onReceiveValue(String s) { Log.d("LogName", s); // Print "test" // data = s; // The value that I would like to return } }); return data; // Return null, not "test" } </code></pre> <p>The call to the method:</p> <pre><code>String result = getDataFromJs("test", webView); // Should return "test" from the webView </code></pre> <p>I've also tried using a <strong>@JavascriptInterface</strong>, but it gives the same result.</p>
<javascript><java><android><callback>
2016-09-05 01:32:08
HQ
39,322,985
How to create multiple language site when load data from database?
<p>Normal, I usually define like this to create multiple languages for my site.</p> <p>Like this:</p> <pre><code>en-en.php define("HOMEPAGE", "Home Page"); </code></pre> <hr> <pre><code>vi-vi.php define("HOMEPAGE", "Trang chủ"); </code></pre> <p>Current, I load this menu from my database.</p> <p>Has anything to create multiple language sites when load data from the database?</p> <p>Thank you very much.</p>
<php>
2016-09-05 01:48:48
LQ_CLOSE
39,323,181
I'm trying to create a formula to work out the number of answers in a single cell. Each line in entered with ALT+Enter
[Sample of the data. Column A is imported data and Column B is the result.][1] [1]: http://i.stack.imgur.com/oJntG.png
<excel><excel-formula>
2016-09-05 02:30:45
LQ_EDIT
39,323,549
Create quote summary of calculated fields
<p>I have a form that allows users calculate cost of services. I can use the form to output the total price of the selected services via checkbox and input values * the data-price. However, I would also like to create a summary of the services they selected. </p> <p>I sample of the results I am trying to achieve from my provided fiddle:</p> <p>This assumes Text 1 has an input of 3 and the first two checkboxes are checked</p> <pre><code>Quote Text 1 $29.85 Checkbox 1 $19.90 Checkbox 1 $45.95 Total $95.70 </code></pre> <p>I want to use a data attribute (like how I use data-price) inside the input and checkbox fields due to the actual complex of my input labels. </p> <p><a href="https://jsfiddle.net/evvaw9ta/" rel="noreferrer">https://jsfiddle.net/evvaw9ta/</a></p>
<javascript><jquery>
2016-09-05 03:30:38
HQ
39,323,920
Default Access Specifier of constructor in Inheritance
I did a little web search and came to know that default constructor's access specifier is same as the access level of class, but take a look here her's one class package package2; `public class TestClass1 { TestClass1() { System.out.println("In parent's contructor"); } } and here another which inherits the previous one package package2; public class TestClass2 extends TestClass1 { TestClass2() { System.out.println("In TestClass2's contructor"); } } ` but when i try to create the object of `TestClass2` import package2.*; class MainClass { public static void main(String[] args) { TestClass2 t2 = new TestClass2(); //Says the constructor TestClass2() is not visible. } } I don't understand both classes `TestClass1` and `TestClass2` have public access so their constructors must also be implicitly public, Which concept am I missing here ? o.O
<java><inheritance><constructor><access-modifiers><default-constructor>
2016-09-05 04:24:09
LQ_EDIT
39,324,039
Highlight typos in the jupyter notebook markdown
<p>When I write something in the jupyter notebook markdown field, the typos are not highlighted and often I ended up with something like this:</p> <p><a href="https://i.stack.imgur.com/e7eNg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e7eNg.png" alt="enter image description here"></a></p> <p>In almost all IDEs I have used so far, the typos are highlighted with a curly underline which was very convenient for me. Something like this:</p> <p><a href="https://i.stack.imgur.com/SD64c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SD64c.png" alt="enter image description here"></a></p> <p>Up till now I have not found anything that allows me to see this type of highlights. Does it exist?</p>
<jupyter><jupyter-notebook>
2016-09-05 04:41:28
HQ
39,324,144
In Java (android), what is a good way to create accurate consecutive timers?
<p>What would be the most accurate solution to have multiple consecutive timers in Java / android? Or in other words, what is the best option to delay the next piece of code until the current timer has finished?</p> <p>Background information if the question is unclear: To practice coding, I would like to create a free app w/o ads to help practice freediving. The basic idea is to have several timers that run after each other. Example:</p> <ol> <li>2 minutes breath up</li> <li>hold your breath for 2 minutes</li> <li>2 minutes breath up</li> <li>hold your breath for 2 minutes + 15 seconds</li> <li>2 minutes breath up</li> <li>hold your breath for 2 minutes + 15 seconds + 15 seconds and so on; usually 8 rounds of breath holding which leads to 16 consecutive timers</li> </ol> <p>At first I thought I can use the timer class but I don't know how to pause the code until the timer is finished. So all the timers ran simultaneously. I have read about CountDownLatch and Handler but I don't have enough experience to judge what would be best for my purpose. I did a python version before and used sleep. It worked fine, but for longer timers it was inaccurate by a few seconds which is a problem. </p> <p>Another option, I believe, is to use a regular timer but run a while loop until the displayed text == 0. I don't know if this infinite loop would crash the application, interfere with the timer's accuracy or has any other negative side effects.</p> <p>Any help / thoughts would be appreciated. Thanks!</p>
<java><android><timer><countdown>
2016-09-05 04:55:36
LQ_CLOSE
39,324,557
Java usage() method
<p>Hi Stackoverflow community</p> <p>I have been trying to find a resource or reference that explains what the usage() method does. Unfortunately the word 'usage' is indexed so often in different contexts that I simply can't find a good resource. Would anybody be able to point me in the right direction?</p> <pre><code>public static void main(String[] args) { if (args.length == 0) { usage(); } else if ("parse".equals(args[0])) { final String[] parseArgs = new String[args.length - 1]; etc .... </code></pre> <p>I know that in C getusage() is used to get memory and CPU usage statistics. Is this the same case in Java? Any pointers would be highly appreciated. Mike</p>
<java>
2016-09-05 05:48:17
LQ_CLOSE
39,324,883
generic Cryptarithmetic prblem asked in my exam
ONE + ONE +TWO = FOUR Can anybody can solve this cryptarithmetic in step by step process Thank you
<artificial-intelligence><cryptarithmetic-puzzle>
2016-09-05 06:24:15
LQ_EDIT
39,324,970
Python Requests - Dynamically Pass HTTP Verb
<p>Is there a way to pass an HTTP verb (PATCH/POST) to a function and dynamically use that verb for Python requests?</p> <p>For example, I want this function to take a 'verb' variable which is only called internally and will either = post/patch.</p> <pre><code>def dnsChange(self, zID, verb): for record in config.NEW_DNS: ### LINE BELOW IS ALL THAT MATTERS TO THIS QUESTION json = requests.verb(headers=self.auth, url=self.API + '/zones/' + str(zID) + '/dns_records', data={"type":record[0], "name":record[1], "content":record[2]}) key = record[0] + "record with host " + record[1] result = json.loads(json.text) self.apiSuccess(result,key,value) </code></pre> <p>I realize I cannot requests.'verb' as I have above, it's meant to illustrate the question. Is there a way to do this or something similar? I'd like to avoid an:</p> <pre><code>if verb == 'post': json = requests.post(headers=self.auth, url=self.API + '/zones/' + str(zID) + '/dns_records', data={"type":record[0], "name":record[1], "content":record[2]} else: json = requests.patch(headers=self.auth, url=self.API + '/zones/' + str(zID) + '/dns_records', data={"type":record[0], "name":record[1], "content":record[2]} </code></pre> <p>Thanks guys!</p>
<python><http><request><httpverbs>
2016-09-05 06:32:07
HQ
39,325,275
How to train TensorFlow network using a generator to produce inputs?
<p>The TensorFlow <a href="https://www.tensorflow.org/versions/r0.10/how_tos/reading_data/index.html" rel="noreferrer">docs</a> describe a bunch of ways to read data using TFRecordReader, TextLineReader, QueueRunner etc and queues.</p> <p>What I would like to do is much, much simpler: I have a python generator function that produces an infinite sequence of training data as (X, y) tuples (both are numpy arrays, and the first dimension is the batch size). I just want to train a network using that data as inputs. </p> <p>Is there a simple self-contained example of training a TensorFlow network using a generator which produces the data? (along the lines of the MNIST or CIFAR examples)</p>
<python><tensorflow>
2016-09-05 06:57:38
HQ
39,325,299
How TO Generate Number Incrementing by previous number in php
I want TO generate A Number In Sequence in php On Page Refresh. Like if I start with 1 then after Page Refresh It Should Be 2.Please Help
<php>
2016-09-05 06:59:46
LQ_EDIT
39,325,637
audio auto play next song when previous is finished
<p>I want to create an audio background player where user can only click on image to play or stop the playback. I have trouble creating or rewirting existing codes to make a playlist for it, that automatically plays next song when previous is finished. I want to do it in vanilla js. <br> Here is what I have so far: <br><a href="https://jsfiddle.net/rockarou/ad8Lkkrj/">https://jsfiddle.net/rockarou/ad8Lkkrj/</a></p> <pre><code>var imageTracker = 'playImage'; swapImage = function() { var image = document.getElementById('swapImage'); if (imageTracker == 'playImage') { image.src = 'http://findicons.com/files/icons/129/soft_scraps/256/button_pause_01.png'; imageTracker = 'stopImage'; } else { image.src = 'http://findicons.com/files/icons/129/soft_scraps/256/button_play_01.png'; imageTracker = 'playImage'; } }; var musicTracker = 'noMusic'; audioStatus = function() { var music = document.getElementById('natureSounds'); if (musicTracker == 'noMusic') { music.play(); musicTracker = 'playMusic'; } else { music.pause(); musicTracker = 'noMusic'; } }; </code></pre>
<javascript><html><html5-audio>
2016-09-05 07:24:40
HQ
39,327,510
Share Image element transition display incorrect size
<p>I have a recycle view to show all photo thumbnail items. When click on item, I use transition for imageview in this item to Detail activity. The problem is that image source is gotten from internet by <a href="https://github.com/nostra13/Android-Universal-Image-Loader" rel="noreferrer">UIL</a>. And <strong>sometime (not always) the images not reload correct size</strong> like this:</p> <p><a href="https://i.stack.imgur.com/aqDV4.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/aqDV4.jpg" alt="transition error"></a> </p> <pre><code> // on view holder item click final Pair&lt;View, String&gt;[] pairs = TransitionHelper.createSafeTransitionParticipants(this, false, new Pair&lt;&gt;(((ItemViewHolder) viewHolder).thumbnail, getString(R.string.TransitionName_Profile_Image)), new Pair&lt;&gt;(((ItemViewHolder) viewHolder).tvName, getString(R.string.TransitionName_Profile_Name))); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, pairs); startActivityForResult(intent, requestCode, transitionActivityOptions.toBundle()); </code></pre> <p><strong>Detail activity</strong></p> <pre><code>// try to post pone transition until UIL load finish ActivityCompat.postponeEnterTransition(this); getSupportFragmentManager().beginTransaction().replace(R.id.layoutContent, new DetailFragment()).commit(); </code></pre> <p><strong>Fragment Detail</strong></p> <pre><code>ImageLoader.getInstance().displayImage(url, imageViewDetail, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { finishAnimation(); } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { finishAnimation(); } @Override public void onLoadingCancelled(String imageUri, View view) { finishAnimation(); } }); private void finishAnimation(){ ActivityCompat.startPostponedEnterTransition(getActivity()); imageViewDetail.invalidate(); } </code></pre> <p><strong>fragment_detail.xml</strong></p> <pre><code> &lt;FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ImageView android:transitionName="@string/TransitionName.Profile.Image" android:id="@+id/imageViewDetail" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustViewBounds="true" android:scaleType="centerCrop"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>I even wait views are laid out before load image but still not work:</p> <pre><code>imageViewDetail.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // code load image from UIL return false; } }); </code></pre> <p>Is there any way to avoid this issue?</p>
<android><android-animation><universal-image-loader><android-transitions>
2016-09-05 09:24:53
HQ
39,327,868
Print Kafka Stream Input out to console?
<p>I've been looking through a lot of the Kafka documentation for a java application that I am working on. I've tried getting into the lambda syntax introduced in Java 8, but I am a little sketchy on that ground and don't feel too confident that it should be what I use as of yet.</p> <p>I've a Kafka/Zookeeper Service running without any troubles, and what I want to do is write a small example program that based on the input will write it out, but not do a wordcount as there are so many examples of already.</p> <p>As for sample data I will be getting a string of following structure:</p> <h1>Example data</h1> <pre><code>This a sample string containing some keywords such as GPS, GEO and maybe a little bit of ACC. </code></pre> <h1>Question</h1> <p>I want to be able to extract the 3 letter keywords and print them with a <code>System.out.println</code>. How do I get a string variable containing the input? I know how to apply regular expressions or even just searching through the string to get the keywords.</p> <h1>Code</h1> <pre><code>public static void main(String[] args) { Properties props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, "app_id"); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "0:0:0:0:0:0:0:1:9092"); props.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "0:0:0:0:0:0:0:1:2181"); props.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); props.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); final Serde&lt;String&gt; stringSerde = Serdes.String(); KStreamBuilder builder = new KStreamBuilder(); KStream&lt;String, String&gt; source = builder.stream(stringSerde, stringSerde, "in-stream"); KafkaStreams streams = new KafkaStreams(builder, props); streams.start(); //How do I assign the input from in-stream to the following variable? String variable = ? } </code></pre> <p>I have zookeeper, kafka, producer and consumer running all hooked up to the same topic so I want to basically see the same <code>String</code> appear on all of the instances (producer, consumer and stream).</p>
<java><stream><apache-kafka><apache-kafka-streams>
2016-09-05 09:45:49
HQ
39,327,906
ClickListener in PagerAdapter fires on wrong position
<p>I'm using <a href="https://github.com/crosswall/Android-Coverflow">this project (Android-Coverflow)</a> in my app, which works as expected with one exception: when setting a <code>View.OnClickListener</code> on the single items in <code>instantiateItem</code> I do get wrong positions, i.e.:</p> <ul> <li>the middle item returns the correct position.</li> <li>the item on the right of the middle item displays the correct position (middle-item + 1)</li> <li>the item to the left of the middle item displays the wrong position: the same as the item to the right.</li> </ul> <p>So if I'm scrolling so far that item with index 3 is in the middle, I get</p> <ul> <li>3 for the middle item (correct)</li> <li>4 for the item to the right (correct)</li> <li>4 for the item to the left (wrong)</li> </ul> <p>I add the <code>ClickListener</code> inside the <code>instantiateItem</code> method, so I would expect it to be correct...</p> <p>What could I probably be missing here?</p> <p>I uploaded the adapted project to Github: <a href="https://github.com/haemi/Android-Coverflow-Clicklistener-Issue">https://github.com/haemi/Android-Coverflow-Clicklistener-Issue</a> - inside "transformer coverflow 2" the issue is visible. The according code is here: <a href="https://github.com/haemi/Android-Coverflow-Clicklistener-Issue/blob/master/app/src/main/java/me/crosswall/coverflow/demo/Normal2Activity.java#L63">https://github.com/haemi/Android-Coverflow-Clicklistener-Issue/blob/master/app/src/main/java/me/crosswall/coverflow/demo/Normal2Activity.java#L63</a></p>
<android>
2016-09-05 09:47:51
HQ
39,328,586
explanation for simple "saving file " code
**Hello everyone** i am new in _Android studio_ i just want to learn more in android apps . So, i want an explanation the **out=context.openFileOutput** arguments . **Thanks in advance** public void saveImage(Context context, Bitmap b,String name,String extension){ name=name+"."+extension; FileOutputStream out; try { out = context.openFileOutput(name, Context.MODE_PRIVATE); b.compress(Bitmap.CompressFormat.JPEG, 90, out); out.close(); } catch (Exception e) { e.printStackTrace(); } }
<android><storage><android-fileprovider>
2016-09-05 10:26:04
LQ_EDIT
39,329,077
C programming, segmentation fault core dunmp
I am trying to make a program which takes in a input of "Hello" and outputs "olleH" from reversing the order of the characters. However I keep getting a segmentation fault and I don't understand why #include <stdio.h> #include<string.h> int main() { int i; int size; char s[100],a[100]; printf("Enter the word you want to get reversed: "); scanf("%s",s); while(s[i]!='\0') { a[i]=s[i]; i++; } size=sizeof(s); while(i<sizeof(s)) { s[i]=a[size]; } printf("The reversed string is : %s",s); }
<c><arrays><string><reverse>
2016-09-05 10:53:47
LQ_EDIT
39,329,228
pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts
<p>I'm trying to dump my pg db but got these errors please suggest</p> <pre><code>pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts pg_dump: [archiver (db)] query was: LOCK TABLE public.abouts IN ACCESS SHARE MODE </code></pre>
<ruby><postgresql><ruby-on-rails-3>
2016-09-05 11:03:27
HQ
39,329,566
Bootstrap column and row
<p>I'm using bootstrap columns which allows a maximum of 12. I need two different divs in one row, one having 12 cols and the other 4. I need the one of 4 cols to appear on the one of 12. Means both of divs will be in the same row. Please how do I achieve this. Thanks.</p>
<html><css><twitter-bootstrap>
2016-09-05 11:24:28
LQ_CLOSE
39,329,580
Exporting data from Google Cloud Storage to Amazon S3
<p>I would like to transfer data from a table in BigQuery, into another one in Redshift. My planned data flow is as follows:</p> <p>BigQuery -> Google Cloud Storage -> Amazon S3 -> Redshift</p> <p>I know about Google Cloud Storage Transfer Service, but I'm not sure it can help me. From Google Cloud documentation:</p> <blockquote> <p><strong>Cloud Storage Transfer Service</strong></p> <p>This page describes Cloud Storage Transfer Service, which you can use to quickly import online data into Google Cloud Storage.</p> </blockquote> <p>I understand that this service can be used to import data into Google Cloud Storage and not to export from it.</p> <p>Is there a way I can export data from Google Cloud Storage to Amazon S3?</p>
<amazon-s3><google-bigquery><google-cloud-storage>
2016-09-05 11:25:23
HQ
39,329,732
specify sysctl values using docker-compose
<p>I am trying to set a few sysctl values.<br> Basically the following </p> <pre><code>sysctl -w \ net.ipv4.tcp_keepalive_time=300 \ net.ipv4.tcp_keepalive_intvl=60 \ net.ipv4.tcp_keepalive_probes=9 </code></pre> <p>in a docker container.<br> When log into to the container directly and execute the command, I get the following error</p> <pre><code>sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_time: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_intvl: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_probes: No such file or directory </code></pre> <p>Then I found out the --sysctl option in <code>docker run</code> in <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="noreferrer">here</a> But I did not find the equivalent option via docker-compose. I have few services that start by default so using docker run instead of docker-compose is not an option for me.</p> <p>Anyone knows of a way to supply --sysctl options to the container via compose?</p>
<docker><docker-compose>
2016-09-05 11:34:59
HQ
39,330,546
C++ abstract class inheritance
<p>Suppose that I have this piece of code:</p> <pre><code>class Vehicle { virtual const char* media() const = 0; virtual unsigned speed() const = 0; } V, *PV; class LandVehicle : public Vehicle { const char* media() const override{ return "Land";} } L, *PL; class Train : public LandVehicle{ virtual unsigned speed() const override {return 130;} } T, *PT; </code></pre> <p>I have a few questions about it :D</p> <p>1) LandVehicle doesn't implement speed(). is that an error and if so, what kind of error? or does it just make it an abstract class as well ?</p> <p>2) is the keyword <strong>override</strong> in class LandVehicle in method media() used correctly? as a derived class from an abstract class is it really overriding the method?</p> <p>3) same as 2 for <strong>override</strong> in Train's speed() method.</p> <p>4) is Train a concrete class now?</p> <p>5) is it necessary to add the keyword <strong>virtual</strong> in the declaration of LandVehicle's media() method?</p> <p>6) if I add this method in Train class:</p> <pre><code>const char* media() const{ return "Just a train";} </code></pre> <p>does it hide LandVehicle's media() or does it override it ?</p> <p>7) after adding the method in 6, can LandVehicle's media() be accessed in Train class?</p>
<c++><inheritance>
2016-09-05 12:22:47
LQ_CLOSE
39,331,125
Angular2 Call Function When the Input Changes
<p>Child component:</p> <pre><code>export class Child { @Input() public value: string; public childFunction(){...} } </code></pre> <p>Parent component: </p> <pre><code>export class Parent { public value2: string; function1(){ value2 = "a" } function2(){ value2 = "b" } } </code></pre> <p>Parent view: </p> <pre><code>&lt;child [value]="value2"&gt; </code></pre> <p>Is there any way to call childFunction() every time the value2 is changed in this structure? </p>
<javascript><angular><data-binding>
2016-09-05 12:57:32
HQ
39,331,693
DateTime.now in Elixir and Ecto
<p>I want to get the current date-time stamp in Phoenix/Elixir without a third-party library. Or simply, I want something like <code>DateTime.now()</code>. How can I do that?</p>
<elixir><phoenix-framework><ecto>
2016-09-05 13:28:30
HQ
39,331,817
How to extract a single datapoint from multiple CSV files to a new file
I have hundreds of CSV files on my disk, and one file added daily and I want to extract one data point (value) from each of them and put them in a new file. Then I want to daily add values to that same file. CSV files looks like this: business_day,commodity,total,delivery,total_lots . . 20160831,CTC,,201710,10 20160831,CTC,,201711,10 20160831,CTC,,201712,10 20160831,CTC,Total,,385 20160831,HTC,,201701,30 20160831,HTC,,201702,30 . . I want to fetch the row that contains 'Total' from each file. The new file should look like: business_day,commodity,total,total_lots 20160831,CTC,Total,385 20160901,CTC,Total,555 . . The raw files on my disk are named '20160831_foo.CSV', '20160901_foo.CSV etc.. After Googling this I have yet not seen any examples on how to extract only one value from a CSV file. Any hints/help much appreciated. Happy to use pandas if that makes life easier.
<python><python-3.x><csv><pandas>
2016-09-05 13:35:30
LQ_EDIT
39,332,010
Django: How to rollback (@transaction.atomic) without raising exception?
<p>I'm using Django's command to perform some tasks involving database manipulation:</p> <pre><code>class SomeCommand(BaseCommand): @transaction.atomic def handle(self, *args, **options): # Some stuff on the database </code></pre> <p>If an exception is thrown during execution of my program, <code>@transaction.atomic</code> guarantees rollback. Can I force this behavior without throwing exception? Something like:</p> <pre><code># Doing some stuff, changing objects if some_condition: # ABANDON ALL CHANGES AND RETURN </code></pre>
<django>
2016-09-05 13:46:32
HQ
39,332,339
ChartJS canvas not displaying rgba colors in IE, Safari and Firefox
<p>Im using ChartJS to display some data but it's not rendering the canvas element correctly in IE, Firefox and Safari. </p> <p>My guess is that the background color property lacks any of the used prefixes for the other browser since it works fine in Chrome.</p> <p>Anyone else had this issue? </p> <p><strong>Chrome</strong>: </p> <p><a href="https://i.stack.imgur.com/WXPgx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WXPgx.png" alt="enter image description here"></a></p> <p><strong>Firefox, Safari and IE:</strong> <a href="https://i.stack.imgur.com/ZtW4T.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZtW4T.png" alt="enter image description here"></a></p> <p>The code: </p> <pre><code> window.onload = function() { var ctx = document.getElementById("canvas"); var myChart = new Chart(ctx, { type: 'line', data: { labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"], datasets: [{ label: '# of Value', data: [12, 19, 3, 5, 2, 3, 10, 29], backgroundColor: [ 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)' ], borderColor: [ 'rgba(33, 145, 81, 1)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)', 'rgba(33, 145, 81, 0.2)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); }; }); </code></pre>
<javascript><canvas><chart.js><rgba>
2016-09-05 14:04:21
HQ
39,332,406
Install libc++ on ubuntu
<p>I am wondering what is the right/easy way to install a binary libc++ on Ubuntu, in my case Trusty aka 14.04?</p> <p>On the LLVM web site there are apt packages <a href="http://apt.llvm.org/" rel="noreferrer">http://apt.llvm.org/</a> and I have used these to install 3.9. However these packages don't seem to include libc++. I install the libc++-dev package but that seems to be a really old version. There are also binaries that can be downloaded <a href="http://llvm.org/releases/download.html#3.9.0" rel="noreferrer">http://llvm.org/releases/download.html#3.9.0</a>. These do seem to contain libc++ but I'm not sure if I can just copy bits of this into places like /usr/include/c++/v1, in fact I'm not really sure what bits I would need to copy. I am aware I can use libc++ from an alternate location as documented here <a href="http://libcxx.llvm.org/docs/UsingLibcxx.html" rel="noreferrer">http://libcxx.llvm.org/docs/UsingLibcxx.html</a> which I have tried. However I can't modify the build system of the large code base I work on to do this.</p> <p>So is three any reason the apt packages don't include libc++ and any pointers to installing a binary would be gratefully recieved.</p>
<clang><libc++>
2016-09-05 14:07:59
HQ
39,333,129
Define a Class Function Operator
<p>How can I define in PHP a class <code>Foo</code> that allows to do something like:</p> <pre><code>$foo = new Foo(); $foo-&gt;bar; $foo(); </code></pre>
<php>
2016-09-05 14:50:44
LQ_CLOSE
39,333,529
DateDiff return different result for each timezones
<p>I have problem with PHP DateDiff, i dont understand why each timezone returns different results, for example in this case Prague return 0 month, and US return 1 month.</p> <p>What do this difference and how i return 1 month (instead 30 days, when i adding 1 month) as expected?</p> <p>code Europe/Prague:</p> <pre><code>date_default_timezone_set("Europe/Prague"); $from = new \DateTimeImmutable('2016-09-01'); $to = $from-&gt;add(new \DateInterval('P1M')); var_dump($from); var_dump($to); var_dump($from-&gt;diff($to)-&gt;m); var_dump($from-&gt;diff($to)-&gt;d); </code></pre> <p>result Europe/Prague:</p> <pre><code>object(DateTimeImmutable)#1 (3) { ["date"]=&gt; string(26) "2016-09-01 00:00:00.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(13) "Europe/Prague" } object(DateTimeImmutable)#3 (3) { ["date"]=&gt; string(26) "2016-10-01 00:00:00.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(13) "Europe/Prague" } int(0) int(30) </code></pre> <p>--</p> <p>code US/Pacific:</p> <pre><code>date_default_timezone_set("US/Pacific"); $from = new \DateTimeImmutable('2016-09-01'); $to = $from-&gt;add(new \DateInterval('P1M')); var_dump($from); var_dump($to); var_dump($from-&gt;diff($to)-&gt;m); var_dump($from-&gt;diff($to)-&gt;d); </code></pre> <p>result US/Pacific:</p> <pre><code>object(DateTimeImmutable)#2 (3) { ["date"]=&gt; string(26) "2016-09-01 00:00:00.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(10) "US/Pacific" } object(DateTimeImmutable)#4 (3) { ["date"]=&gt; string(26) "2016-10-01 00:00:00.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(10) "US/Pacific" } int(1) int(0) </code></pre>
<php><date><datetime><datediff>
2016-09-05 15:15:18
HQ
39,333,692
Request header does not include HTTP_X_CSRF_TOKEN when using AWS JS SDK
<p>I have a Rails application where I can post answers to questions via ajax, it works fine, however, I have added the <code>aws-js-sdk</code> script to be able to upload images in my answer from the browser, the image will be uploaded to s3 which sends back the url of the newly uploaded image in a callback, then I save the answer.</p> <p>I included the library like this : </p> <pre><code> &lt;%= javascript_include_tag "//sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js" %&gt; </code></pre> <p><strong>Expected behaviour</strong> : when I submit an answer with an image, the request header should include <code>HTTP_X_CSRF_TOKEN</code> to verify the form is submitted from within my website. </p> <p><strong>Problem</strong> : request header does not include <code>HTTP_X_CSRF_TOKEN</code>, which is leading to the error <code>ActionController::InvalidAuthenticityToken</code></p>
<javascript><ruby-on-rails><ajax><amazon-web-services><aws-sdk>
2016-09-05 15:26:21
HQ
39,333,716
How to do if pattern matching with multiple cases?
<p>I'm searching for the syntax to do pattern matching with multiple cases in an if case statement. The example would be this:</p> <pre><code>enum Gender { case Male, Female, Transgender } let a = Gender.Male </code></pre> <p>Now I want to check, if a is .Male OR .Female. But I would like to avoid using switch for this. However the switch statement would be like this:</p> <pre><code>switch a { case .Male, .Female: // do something } </code></pre> <p>Is it possible to write this with if case? I would expect this, but it didn't work :(</p> <pre><code>if case .Male, .Female = a { } </code></pre>
<swift>
2016-09-05 15:28:13
HQ
39,334,107
Flag N+1 queries with bullet in Rspec
<p>I'm trying to flag N+1 and places in the code where I can add counter caches, using the <a href="https://github.com/flyerhzm/bullet" rel="noreferrer">bullet gem</a>. But doing everything manually to check N+1 queries, seems very painfully, so I tried to use Bullet with Rspec, using the setup steps they recommend:</p> <pre><code># config/environments/test.rb config.after_initialize do Bullet.enable = true Bullet.bullet_logger = true Bullet.raise = true # raise an error if n+1 query occurs end # spec/spec_helper.rb if Bullet.enable? config.before(:each) do Bullet.start_request end config.after(:each) do Bullet.perform_out_of_channel_notifications if Bullet.notification? Bullet.end_request end end </code></pre> <p>But when I run the specs, seems to flag N+1 queries within specs itself rather than the app. Do you know if it's possible to achieve what I want?</p>
<ruby-on-rails><ruby><rspec>
2016-09-05 15:56:30
HQ
39,334,231
My else statement is not effective but if statement is. Java
<p>I was going to let user enter 10 names and make it as array. Then again I will let user to enter the names they want to search, then present the search result. However, when I search something that was not in the array, the result still shows it. Is any problem in my code? Hope anyone could help, thanks.</p> <pre><code>import java.util.Scanner; import java.util.*; public class Main { static List&lt;String&gt; name = new ArrayList&lt;String&gt;(); public static void main (String[]args) { Scanner input=new Scanner(System.in); Scanner input2=new Scanner(System.in); int i; String sname; System.out.println("Please enter 10 student names."); for(i=1;i&lt;11;i++){ name.add(input.next()); } System.out.println("Namelist is " + name); String[] namearray = name.toArray(new String[0]); System.out.println("Arraylist is "+ Arrays.toString(namearray)); System.out.println("Please enter the names that you want to search."); sname=input2.nextLine(); search(namearray, sname); } public static void search(String[]namearray,String sname) { int i; boolean check; for(i = 0; i &lt; namearray.length; i++){ if(namearray[i].equals(sname)) check=true; else check=false; } if(check=true){ System.out.println("Found Result: "+sname); } else if (check=false){ System.out.println("Not Found."); } } } </code></pre> <p>Thank you.</p>
<java>
2016-09-05 16:06:05
LQ_CLOSE
39,334,271
how to count the total amount of selected boxes on html table
How can i count the amount of the selectedboxes from the table <tbody> <tr> <td><center><form> <input type="checkbox" value="<?php echo $rws['amount']; ?>" /></center></td> </tr> </tbody>
<javascript><php><html>
2016-09-05 16:08:49
LQ_EDIT
39,334,958
Changing assigned user in sql using SelectOneMenu primeface
I have been searching for similar issue but I could not find any. so here is the thing I am trying to create a web application that deals with HR stuff, like employee requests (Resign, loan, vacation, etc..) I am using primeface and I have the following problem that I cant figure out. The thing is I am trying to do is : 1- When user first creates the request and assigns the user and submit the form the next step is 2- the manager would sees the request and then change the "Person responsible for the request" to a new one using the drop menu in the datatable and I have been trying to solve this problem with no luck. Here is the dialog script <h:form id='resignf'> <p:dialog id='res' header="Resign Request" widgetVar="resign" minHeight="40"> <p:outputLabel value="Employee name" /> <p:inputText value="#{controller.resignName}" required="true" requiredMessage="This field is required" /> <p:outputLabel value="Employee Number" /> <p:inputText value="#{controller.resignEmployeNum}" required="true" /> <p:inputText value{controller.resignNationalIDNum}" required="true" /> <p:inputText value="#{controller.resignNotes}" required="true" /> <p:outputLabel for="AssignUser" value="User" /> <p:selectOneMenu id="AssignUser" value="#{controller.assignUser}" style="width:150px" converter="UConverter"> <f:selectItems value="#{controller.usersList}" var="user" itemLabel="#{user.username}"/> </p:selectOneMenu > <p:commandButton action="#{controller.createResignRequest()}" onclick="PF('resign').hide();" update="@all"/> </p:panelGrid> </p:dialog> And the code is my `controller.java` file below to create the request in the table /* Request to resign*/ private List<ResignationRequest> resignList; private ResignationRequestController rController = new ResignationRequestController(); private String resignName; private String resignEmployeNum; private String resignNationalIDNum; private String ResignNotes; private int AutoAssignToIDNUM; /* end of request to resign*/ public void createResignRequest() { System.out.println("createResignRequest"); ResignationRequest newResign = new ResignationRequest(); newResign.setName(resignName); newResign.setEmployeeNum(resignEmployeNum); newResign.setNationalID(resignNationalIDNum); newResign.setNotes(ResignNotes); newResign.setUserID(AssignUser); rController.create(newResign); resignList = rController.findResignationRequestEntities(); //retrieves all the resigns from the database } Now all that is working perfectly, but when I try to change the old user with the new one here I get confused! so far what I have been thinking is I need to find the old user and then switch him, but I could not figure a way to do it using the select list. The script for for changing the "User responsible for the request" below <p:dataTable id="resignTable1" cellSeparator="true" editMode="cell" editable="true" var="resign" value="#{controller.resignList}" paginator="true" rows="10" rowIndexVar="index1"> <p:ajax id="aj" event="cellEdit" listener="#{controller.editUser(user)}" update="resignTable1"/> <p:column headerText="Employee number"> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{resign.employeeNum}" /></f:facet> <f:facet name="input"> <h:inputText value="#{resign.employeeNum}" /></f:facet> </p:cellEditor> </p:column> <p:column headerText="name"> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{resign.name}" /></f:facet> <f:facet name="input"> <h:inputText value="#{resign.name}" /></f:facet> </p:cellEditor> </p:column> <p:column headerText="Request Number"> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{resign.id}" /></f:facet> <f:facet name="input"> <h:inputText value="#{resign.id}" /></f:facet> </p:cellEditor> </p:column> <p:column headerText="User responsible for the request"> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{resign.userID}" /></f:facet> <f:facet name="input"> <h:inputText value="#{resign.userID}" /></f:facet> </p:cellEditor> </p:column> <p:column headerText="Comments"> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{resign.notes}" /></f:facet> <f:facet name="input"> <h:inputText value="#{resign.notes}" /></f:facet> </p:cellEditor> </p:column> <p:column headerText="Send the request to the next employee"> <p:selectOneMenu id="AssignUser" value="#{controller.assignUser}" style="width:150px" converter="UConverter" onchange="submit();"> <f:selectItems value="#{controller.usersList}" var="user" itemLabel="#{user.username}" actionListener="#{controller.editRequestStep(resign)}" > </f:selectItems> </p:selectOneMenu > In my controller file public void editRequestStep(ResignationRequest r) { System.out.println("Edit resign"); try { System.out.println("Edit resign"); rController.edit(r); } catch (Exception ex) { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex); } } I tried to get as much as I could from the code but I have a lot of stuff that I am not sure if I should submit. I tried ajax NOTE: I am using mySQL, apache tomcat in case if it matters.
<java><jsf-2><primefaces>
2016-09-05 16:59:52
LQ_EDIT
39,335,295
Swift 3 - PHFetchResult - enumerateObjects - Ambiguous use of 'enumerate objects'
<p>Not so sure why I'm getting "Ambiguous use of 'enumerate objects' in Swift 3. </p> <pre><code>let collections = PHAssetCollection.fetchAssetCollections(with: .moment, subtype: .any, options: nil) collections.enumerateObjects { (collection, start, stop) in collection as! PHAssetCollection let assets = PHAsset.fetchAssets(in: collection, options: nil) assets.enumerateObjects({ (object, count, stop) in content.append(object) }) } </code></pre> <p>Any thoughts? This code was working fine in Swift 2.2</p>
<swift><swift3>
2016-09-05 17:28:42
HQ
39,335,568
How I Catch What Event While Action of Dynamic Child inside Dynamic Parent vice-versa
I am still not statisfy regarding Dynamic Child Inside Dynamic Parent where a lot of confusing for me and more worst how to know which once and how I can manipulate them to what I want. For yours informations I am very very new on Javascript and Jquery, but I can catch up if someone give a right directions and a rights syntax. I love clean code where from that code I can learn more and understand. Let say I have this structure html where it's same on firebugs:- <div name="div0" class="div0"> <input name="txt0" class="txt0"> <div name="div1[]" class="divL1"> 'index 0 <button class="btn1"> <button class="btn2"> <input name="txtL1_a[]" class="cLtxt1"> <input name="txtL1_b[]" class="cLtxt1"> < div name="div2[]" class="divL2"> <div id="ui-widget"> <input name="txtL2_a[]" class="cLtxt2 autosuggest"> </div> <input name="txtL2_b[]" class="cLtxt2"> </div> </div> <div name="div1[]" class="divL1"> 'index 1 <button class="btn1"> <button class="btn2"> <input name="txtL1_a[]" class="cLtxt1"> <input name="txtL1_b[]" class="cLtxt1"> < div name="div2[]" class="divL2"> <div id="ui-widget"> <input name="txtL2_a[]" class="cLtxt2 autosuggest"> </div> <input name="txtL2_b[]" class="cLtxt2"> </div> </div> Actually on my head have a lot of question but let me ask a few question first. **1.** I want to run .autosuggest where it's complicated for me because on normal form before this I can manage run it, but when .autosuggest inside dynamic parent div and located on dynamic input I cannot get a value and show a autocomplete. By given id "txtL2_a[]" function SearchText cannot performance autocomplete and don't know which index are doing that. function SearchText() { $(".autosuggest").autocomplete({ source: function (request, response) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "frmsetuptrip.aspx/GetAutoCompleteData", minLength: 3, data: "{'presearch':'" + document.getElementById('txtL2_a[]').value + "'}", dataType: "json", success: function (data) { if ((data.d).length == 0) { //$('#button9').show(); var result = [ { label: 'No matches found', value: response.term } ]; response(result); } else { response(data.d); } }, error: function (result) { alert("Error"); } }); } }); } **2.** Let say on <div name="div1[]" class="divL1"> //index 1 I need some auto fill up - let say when I fill up <input name="txtL2_a[]" class="cLtxt2 autosuggest"> //index :1 automatically value inside <input name="txtL2_b[]" class="cLtxt2"> 'Index 1 will change only based parents index. **3.** There is anyway a one function where I can catch all event and elaborate that by IF before go specific sub function or task like this pseudo code below:- $("div.div0").each(function (event) { if (event=="keyup" on child=="divL1"+index[0]){ //detect more spesific which object are doing that if (whoisdoing=="txtL1_a[]"+index[0] { //then do action etc: fill up parent input $("div0.txt0").val($(txtL1_a.index[0]).val()); } if (whoisdoing=="txtL1_b[]"+index[0] { //then do action etc: fill up childs input $("div2[index[0]].txtL2_b[index[0]].val( $(txtL1_b[index[0]]).val() ); } } //event - keypress //event - click //and many more }); I cannot find on internet regarding all this matter I mention above. If anybody have a solution or already develop that function please sharing and I believe this is not easy to handle. Anyway thanks on advance to you for reading and replying my question. Best Regards.
<javascript><jquery><html><css>
2016-09-05 17:53:56
LQ_EDIT
39,335,608
Java join() concept
<p>See my code in with <a href="http://collabedit.com/92yma" rel="nofollow">link</a>. My understanding with join concept is that if I created a thread "t2" in main thread. And I am writing like t2.join(). Than first all things under run method of t object will be executed than execution of main thread will be started back. But if I have created one more thread "t1" in main thread before "t2". At that time "t2"'s execution should be done first and than "t1"'s. Correct? But if you see in my linked code. t1 and t2 runs simultaneously. Why is it so? </p>
<java><multithreading>
2016-09-05 17:56:57
LQ_CLOSE
39,336,033
Does an Application Load Balancer support WebSockets?
<p>I have an Elastic Beanstalk application which was initially configured to use a Classic Load Balancer. I found that this caused errors when connecting via WebSocket. Because of this, I configured the application to use an Application Load Balancer instead, because I was told that ALBs support WebSockets. However, it seems that they do not: I get exactly the same error when attempting to connect to my ALB via WebSocket.</p> <p>Do ALBs actually support WebSocket? The AWS documentation is contradictory on this. <a href="http://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/what-is-load-balancing.html" rel="noreferrer">This page</a> says it only supports HTTP and HTTPS. There are no guides to setting up an ALB to support WebSocket.</p>
<amazon-web-services><websocket><elastic-load-balancer>
2016-09-05 18:34:58
HQ
39,336,054
Using App namespace in style
<p>I am going to give an example to demonstrate the greater point.</p> <p>Imagine my app has a number of FloatingActionButtons. Consequently, I want to create one style and reuse it. So I do the following:</p> <pre><code>&lt;style name="FabStyle” parent ="Widget.Design.FloatingActionButton"&gt; &lt;item name="android:layout_width"&gt;wrap_content&lt;/item&gt; &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt; &lt;item name="android:layout_margin"&gt;16dp&lt;/item&gt; &lt;item name="app:backgroundTint"&gt;@color/accent&lt;/item&gt; &lt;item name="app:layout_anchorGravity"&gt;end|bottom&lt;/item&gt; &lt;/style&gt; </code></pre> <p>The problem I am having is that the code is not compiling because it is complaining about</p> <pre><code>Error:(40, 5) No resource found that matches the given name: attr 'app:backgroundTint'. </code></pre> <p>I tried bringing the namespace in through the <code>resources</code> tag but that is not working</p> <pre><code>&lt;resources xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" &gt; </code></pre> <p>Any ideas how I might get this to work?</p>
<android><android-layout><android-theme><android-styles>
2016-09-05 18:36:53
HQ
39,336,330
someone please help me solve this thank you
total=0 output=("enter next sales value") sales=input total_sales=total+sales i keep getting this error Traceback (most recent call last): File "python", line 4, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'builtin_function_or_method'
<python><runtime-error>
2016-09-05 19:01:26
LQ_EDIT
39,336,793
'CGPointMake' is unavailable in swift
<p>I have a Gradient class which I am trying to convert to Swift 3 but I get the following error</p> <blockquote> <p>'CGPointMake' is unavailable in swift</p> </blockquote> <p>for </p> <pre><code>func configureGradientView() { let color1 = topColor ?? self.tintColor as UIColor let color2 = bottomColor ?? UIColor.black as UIColor let colors: Array &lt;AnyObject&gt; = [ color1.cgColor, color2.cgColor ] let layer = self.layer as! CAGradientLayer layer.colors = colors layer.startPoint = CGPointMake(startX, startY) layer.endPoint = CGPointMake(endX, endY) } </code></pre> <p>Can anyone help me out with what I can use instead of <code>CGPointMake</code> </p> <p>Here's the full class; </p> <pre><code>@IBDesignable public class XGradientView: UIView { @IBInspectable public var topColor: UIColor? { didSet { configureGradientView() } } @IBInspectable public var bottomColor: UIColor? { didSet { configureGradientView() } } @IBInspectable var startX: CGFloat = 0.0 { didSet{ configureGradientView() } } @IBInspectable var startY: CGFloat = 1.0 { didSet{ configureGradientView() } } @IBInspectable var endX: CGFloat = 0.0 { didSet{ configureGradientView() } } @IBInspectable var endY: CGFloat = 0.0 { didSet{ configureGradientView() } } public class func layeredClass() -&gt; AnyClass { return CAGradientLayer.self } public required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder)! configureGradientView() } override init(frame: CGRect) { super.init(frame: frame) configureGradientView() } public override func tintColorDidChange() { super.tintColorDidChange() configureGradientView() } func configureGradientView() { let color1 = topColor ?? self.tintColor as UIColor let color2 = bottomColor ?? UIColor.black as UIColor let colors: Array &lt;AnyObject&gt; = [ color1.cgColor, color2.cgColor ] let layer = self.layer as! CAGradientLayer layer.colors = colors layer.startPoint = CGPointMake(startX, startY) layer.endPoint = CGPointMake(endX, endY) } } </code></pre>
<ios><swift><swift3>
2016-09-05 19:44:44
HQ
39,337,268
How to detect real click using mouse or using .click() on tag button , a?
<p>I want to detect if some of my users really click on vote button or using click() function. My vote button is in button tag or a tag. </p>
<javascript><javascript-events>
2016-09-05 20:25:32
LQ_CLOSE
39,337,523
Backtracing variable UIBezlerPath
What to do? I'm getting this Error when i setted the Backtracing Variable... This Code is causing the Error for sure: UIBezierPath* ovalPath = [UIBezierPath bezierPath]; [ovalPath addArcWithCenter: CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect)) radius: CGRectGetWidth(ovalRect) / 2 startAngle: 180 * M_PI/180 endAngle: 0 * M_PI/180 clockwise: YES]; [ovalPath addLineToPoint: CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))]; [ovalPath closePath]; [UIColor.grayColor setFill]; [ovalPath fill]; CGContextSetFlatness: invalid context 0x0. Backtrace: <<redacted>+48> <-[ViewController viewDidLoad]+2868> <<redacted>+996> <<redacted>+28> <<redacted>+76> <<redacted>+252> <<redacted>+48> <<redacted>+3456> <<redacted>+1684> <<redacted>+168> <<redacted>+36> <<redacted>+168> <<redacted>+56> <<redacted>+24> <<redacted>+540> <<redacted>+724> <CFRunLoopRunSpecific+384> <<redacted>+460> <UIApplicationMain+204> <main+124> Sep 5 21:55:56 Motion Tracking Radar - Aliem[2934] <Error>:
<ios><objective-c><uibezierpath>
2016-09-05 20:46:55
LQ_EDIT
39,337,586
How do Git LFS and git-annex differ?
<p><a href="https://git-annex.branchable.com/">git-annex</a> has been around for quite some time, but never really gained momentum.<br> <a href="https://git-lfs.github.com/">Git LFS</a> is rather young and is already supported by GitHub, Bitbucket and GitLab.</p> <p>Both tools handle binary files in git repositories. On the other hand, GitLab seems to have replaced <a href="https://about.gitlab.com/2015/02/17/gitlab-annex-solves-the-problem-of-versioning-large-binaries-with-git/">git-annex</a> with <a href="https://about.gitlab.com/2015/11/23/announcing-git-lfs-support-in-gitlab/">Git LFS</a> within one year.</p> <ul> <li>What are the technical differences?</li> <li>Do they solve the same problem?</li> </ul>
<git><github><git-lfs><git-annex>
2016-09-05 20:52:29
HQ
39,337,842
A simple "for loop" doesnt work - django
<p>When i do a simple code in django, its just shows me the next messege:</p> <pre><code>Could not parse the remainder: '[0,1,2]' from '[0,1,2]' </code></pre> <p>And there is the code:</p> <pre><code> {% for i in [0,1,2] %} &lt;div class="coverw-block-welcome"&gt; &lt;/div&gt; {% endfor %} </code></pre> <p>The smae thing if i do "range". For some reason django dont let me using "for loop". Its a problem with django</p>
<django>
2016-09-05 21:22:56
LQ_CLOSE
39,338,130
In Word - How to find all occurrences of a regex between square brackets?
I'm opening a word doc using `Microsoft.Office.Interop.Word` word.Application wordApp = new word.Application { Visible = true }; word.Document aDoc = wordApp.Documents.Open(fileName, ReadOnly: false, Visible: true); aDoc.Activate(); What I want to do is find all text that is between `[]` for example `[Fruit]` or `[Pears]` So this is a two part question - How do you find all text in a word doc between [] - What is the appropriate regex for anything between square brackets []
<c#><regex><ms-word><office-interop>
2016-09-05 21:55:48
LQ_EDIT
39,338,136
why the array is static
<p>i have watched tutorial that explain how to return array from function</p> <p>and this is similar code</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; int *grn(); int main() { int *a; a=grn(); for(int i = 0;i&lt;10;i++){ printf("%d\n",a[i]); } return 0; } int *grn(){ static int arrayy[10]; srand((unsigned) time(NULL)); for(int i=0;i&lt;10;i++){ arrayy[i]=rand(); } return arrayy; } </code></pre> <p>and i have some questions about it.. it is work fine and generate random values inside the array but </p> <ul> <li><p>why the function <code>grn</code> is pointer</p></li> <li><p>and why <code>a variable</code> in the <code>main function</code> is pointer ?</p></li> <li>why the <code>arrayy array</code> is static?</li> <li>and why should i make the grn function pointer?</li> </ul> <p>when i try to run this code but the arrayy variable is not static i get <code>segmentation fault</code></p>
<c><arrays><function><pointers>
2016-09-05 21:56:43
LQ_CLOSE
39,338,764
Find the highest value with the given constraints (Python)
c = [416,585,464] A0 = [100,50,200] A1 = [100,100,200] A2 = [100,150,100] A3 = [100,200,0] A4 = [100,250,0] b = [300,300,300,300,300] for num in A0,A1,A2,A3,A4: t0 = num[0]*1 + num[1]*1 + num[2]*1 t1 = num[0]*0 + num[1]*1 + num[2]*0 t2 = num[0]*0 + num[1]*0 + num[2]*0 t3 = num[0]*0 + num[1]*0 + num[2]*1 t4 = num[0]*1 + num[1]*0 + num[2]*0 t5 = num[0]*0 + num[1]*1 + num[2]*1 t6 = num[0]*1 + num[1]*1 + num[2]*0 t7 = num[0]*1 + num[1]*0 + num[2]*1 Now check each of the value in t0 against each of its corresponding value in the "b" array. If any of the values from t0 is greater than 300, then t0 is discarded. If not, then the nultiplied values to that t_ should be multiplied with each corresponding "c" array value, and after that determine the highest value and print it. For ex: t1 has 50,100,150,200,250, all of which are equal to or below 300, so we take 0*c[0]+1*c[1]+0*c[2], which gives us 585. However, that isn't the highest value. The highest value is 1049, which is acquired by t5. It has 250,300,250,200,250. Taking 0*c[0]+1*c[1]+1*c[2]=1049 I am stuck here.
<python><arrays><list>
2016-09-05 23:29:24
LQ_EDIT
39,339,510
the object does not have the specified attribute error in python
<p>I am new to python. The following is the code.</p> <pre><code>class simple: def __init__(self, str): print("inside the simple constructor") self.s = str # two methods: def show(self): print(self.s) def showMsg(self, msg): print(msg + ":", self.show()) if __name__ == "__main__": # create an object: x = simple("constructor argument") x.show() x.showMsg("A message") </code></pre> <p>After I run it, I got the </p> <pre><code>AttributeError: 'simple' object has no attribute 'show' </code></pre> <p>So, does anyone know what's going on here? 'show' is not an attribute, right? For my understanding, it should be a method. Does anyone understand what's going on here? Many thanks for your time and attention.</p>
<python>
2016-09-06 01:45:08
LQ_CLOSE
39,339,640
Access current req object everywhere in Node.js Express
<p>I wonder how to access req object if there's no 'req' parameter in callback.</p> <p>This is the scenario:<br> In ExpressJs, I have a common function, it uses to handle something with 'req' object, but not pass req into it.</p> <pre><code>module.exports = { get: function(){ var req = global.currentRequest; //do something... } } </code></pre> <p>My current solution is that I write a middleware for all request, I put the 'req' in global variable, then I can access the 'req' everywhere with 'global.currentRequest'. </p> <pre><code>// in app.js app.use(function (req, res, next) { global.currentRequest= req; next(); }); </code></pre> <p>But I don't know if it's good? Can anyone have suggestions?<br> Thanks a lot!</p>
<node.js><express>
2016-09-06 02:05:59
HQ
39,339,653
use a while loop to display letters entered by a user in vertical order in javascript?
I'm trying to create a script that will ask a user to input a word and then display back the letters entered by the user in vertical order. The problem is that I'm required to use a while loop, any ideas??????
<java><words>
2016-09-06 02:08:11
LQ_EDIT
39,339,914
convert Java to javascript code
<p>Someone can help me,i have stuck here,i have code java like this:</p> <pre><code>List&lt;Object&gt; lstObject = new ArrayList&lt;&gt;(); Object o = lstObject.get(0); </code></pre> <p>and now im confiuse how to change in the code javascript. i hope some one can answer my question,and explain the logic.</p> <p>thanks,</p>
<javascript><java><arraylist>
2016-09-06 02:47:41
LQ_CLOSE
39,340,055
How to constantly execute an if statement
<p>I guess it is not possible, but I just wanted to know if it could be possible to have an if statement always "active". I am creating a text-based game and the health variable of the character is changing often, so when it reaches 0 or below, i want to execute a "dead" function. </p> <pre><code>if (health &lt; 1) { //code }; </code></pre> <p>Do I have to include that if-statement everytime in the object, when the health variable changes? </p> <p>Thank you a lot :)</p>
<javascript><if-statement>
2016-09-06 03:07:19
LQ_CLOSE
39,340,322
How to reset the use/password of jenkins on windows?
<p>Maybe a fool question, I installed jenkins on windows by default, have set no user/password, it worked at first, no need to login. But when launch the 8080 webpage now, it hangs the login page, I've tried some normal user/password combinations, none could pass. Also searched the resolution on website, only find some about linux, no about windows, so need help. <a href="http://i.stack.imgur.com/Y1MUM.png" rel="noreferrer">jenkins login page</a></p>
<windows><jenkins>
2016-09-06 03:44:22
HQ
39,340,682
Why .substring() does not work well in my java proyect?
I'm trying to erase a row from a csv file with this function: public void borrarAlumno(String id) throws IOException { BufferedReader br = new BufferedReader(new FileReader(archivo)); StringBuffer sb = new StringBuffer(""); String line; while ((line = br.readLine()) != null) { System.out.println(line.substring((5))); if(line != " " && line != null){ if(!line.substring(0, 6).equals(id)){ sb.append(line); } } } br.close(); FileWriter fw = new FileWriter(new File(archivo)); fw.write(sb.toString()); fw.close(); } But i get this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -5 at java.lang.String.substring(Unknown Source The firt line of the file is : Matricula,Nombre,Apellido i.e. it has something i dont get why the IndexOutOfBounds problem Help me please,
<java><string><file><csv>
2016-09-06 04:30:24
LQ_EDIT
39,340,942
How to remove .php, .html, .htm extensions with .htacess?
<p>I'm Developing one website and want to remove the extensions from my website <a href="https://s7info.in" rel="nofollow">s7info</a> in order to make the URLs more user and search friendly. I stumbled across tutorials on how to remove the .php extension from a PHP page. What about the .html? i want to remove those as well..!! </p>
<php><html>
2016-09-06 04:59:20
LQ_CLOSE
39,341,381
I have something like this List<Map<String, String>> need to process list and map both any idea
I have something like this List<Map<String, String>> need to process list and map both any idea
<java><collections>
2016-09-06 05:41:59
LQ_EDIT
39,341,455
Indexoutboundexception error for arraylist
Can someone help me explain why this piece of code is throwing an indexoutbound error public static Hull merging(Hull HullA, Hull HullB) { Hull finalHull = new Hull(); int i=0; int j=0; if (HullA.list.get(i) >= HullB.list.get(j)) { finalHull.list.add(HullA.list.get(i)); i++; }else { finalHull.list.add(HullB.list.get(j)); j++; } return finalHull; }
<java><algorithm><merge>
2016-09-06 05:49:09
LQ_EDIT
39,341,892
PHPUnit mock function?
<p>I have an interesting scenario in that I need a function to be defined in order to make tests for another function. The function I want to test looks something like this:</p> <pre><code>if (function_exists('foo') &amp;&amp; ! function_exists('baz')) { /** * Baz function * * @param integer $n * @return integer */ function baz($n) { return foo() + $n; } } </code></pre> <p>The reason I am checking for the existence of <code>foo</code> is because it may or may not be defined in a developer's project and the function <code>baz</code> relies on <code>foo</code>. Because of this, I only want <code>baz</code> to be defined if it can call <code>foo</code>. </p> <p>The only problem is that so far it has been impossible to write tests for. I tried creating a bootstrap script in the PHPUnit configuration that would define a fake <code>foo</code> function and then require the Composer autoloader, but my main script still thinks <code>foo</code> is not defined. <code>foo</code> is not a Composer package and can not otherwise be required by my project. Obviously Mockery will not work for this either. My question is if anyone more experienced with PHPUnit has come across this issue and found a solution.</p> <p>Thanks!</p>
<php><unit-testing><mocking><phpunit>
2016-09-06 06:23:14
HQ
39,341,986
Three SQL TABLES Payment, Appointment, Doctor Find average salary of each patient
Create Table Doctor( doctorID varchar(50) Primary key, doctorFName varchar(50), ); Create Table Appointment( appID varchar(50) Primary Key, doctorID varchar(50) Foreign Key References Doctor(doctorID), ); Create Table Payment( paymentID varchar(50) Primary Key, paymentAmount int, appID varchar(50) Foreign Key References Appointment(appID), ); paymentAmount is also known as payment for each appointment How can i get the average payment amount of each doctor?
<mysql><sql><multiple-tables>
2016-09-06 06:30:36
LQ_EDIT
39,342,529
Getting values from strings.xml in andoid studio
I want to get the item value from strings.xml file in android studio. I have set up spinners and buttons. I have found many ways to parse the document which could not answer my questions. If I am allowed to ask a noob question can it be this? Thank you. <string-array name="angles"> <item value="1">Radian</item> <item value="(Math.PI/3200)">Mil</item> <item value="(Math.PI/200)">Grad</item> </string-array>
<android><xml><android-resources>
2016-09-06 07:00:16
LQ_EDIT
39,342,798
Android Application Craches on version 6 (Marshmallow)
I am building an Android Application with API 23. But on Marshmallow my app gets crashed as it launches. The error message I got is as follows: E/DropboxRealtime: null InputStream java.io.IOException: null InputStream at xjr.a(:com.google.android.gms:187) at xjr.b(:com.google.android.gms:131) at xiw.a(:com.google.android.gms:88) at com.google.android.gms.stats.service.DropBoxEntryAddedChimeraService.onHandleIntent(:com.google.android.gms:1180) at bhe.handleMessage(:com.google.android.gms:65) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.os.HandlerThread.run(HandlerThread.java:61) Please assist me to resolve this problem asap.
<android><crash><dropbox-api>
2016-09-06 07:16:44
LQ_EDIT
39,343,108
How do make a H1 move down page whilst page scrolls?
<p>Hi Im looking to make a heading keep its position at the top of the page whilst the user scrolls down or up. How do I go about doing this. </p> <p>Many Thanks</p> <p>:)</p>
<html>
2016-09-06 07:33:33
LQ_CLOSE
39,343,495
Eroor in command django-admin manage.py make migrations
<p><a href="http://i.stack.imgur.com/GccvD.png" rel="nofollow">this is the entire output of this command then the output is looked like this.now as a beginner its very difficult for me to solve it </a></p>
<django><django-models><django-templates>
2016-09-06 07:54:20
LQ_CLOSE
39,343,700
Why immutable state with redux
<p>I'm learning redux and am struggling to understand why state has to be immutable. Could you provide me with an example, in code preferably, where breaking the immutable contract results in an not so obvious side effect.</p>
<redux>
2016-09-06 08:04:57
HQ
39,344,237
StdOut not recognized in Java
<p>I'm new to Java and am trying to implement some example code from a book on algorithms:</p> <pre><code>public class ThreeSum { public static int count(int[] a) { int N = a.length; int cnt = 0; for (int i = 0; i &lt; N; i++) for (int j = i+1; j &lt; N; j++) for (int k = j+1; k &lt; N; k++) if (a[i] + a[j] + a[k] == 0) cnt++; return cnt; } public static void main(String[] args) { int[] a = In.readInts(args[0]); StdOut.println(count(a)); } } </code></pre> <p>In Netbeans 7.2, I entered this code in a New File in a New Project. However, I notice that the lines in the client program with <code>In</code> and <code>StdOut</code> are underlined with red squiggly lines and have warnings leading to suggestions to create the class (see below).</p> <p><a href="https://i.stack.imgur.com/26WAT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/26WAT.png" alt="enter image description here"></a></p> <p>How could I get rid of these warnings? Do I have to import any libraries? Also, how could I run the main program with some example input in the Netbeans environment?</p>
<java>
2016-09-06 08:32:16
LQ_CLOSE
39,344,378
When using a JMX server with ephemeral port, how to get the server port number?
<p>When launching a Java application with these options:</p> <pre><code>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.local.only=false </code></pre> <p>Java uses an ephemeral port, which is very useful to avoid collisions.</p> <p>Is it possible to get the actual port (or connection URL) programmatically from within the application ?</p>
<java><rmi><jmx><mbeans>
2016-09-06 08:39:06
HQ
39,344,746
SQL PrepareStatement using 'IN'
I would like to know how I can return a result set from a query as a map. This is my query where 'nameCodesString' is a list of strings: try (PreparedStatement stmt = conn .prepareStatement("select n.CODE, l.VALUE" + " from TNAME n join TPROPERTIES l on n.UIDPK = l.OBJECT_UID" + " where n.CODE IN (" + nameCodesString + ")")) { try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { log.info("rs {}",rs); nameCode = rs.getString(1); displayName = rs.getString(2); Person.add(new PersonDTO(nameCode, displayName, "")); } } } The result should be a code and a value. I am not sure how I can do this all in one connection to the database. Thanks
<java><sql><oracle><java-8>
2016-09-06 08:56:16
LQ_EDIT
39,344,769
Spark DataFrame - Select n random rows
<p>I have a dataframe with multiple thousands of records, and I'd like to randomly select 1000 rows into another dataframe for demoing. How can I do this in Java? </p> <p>Thank you!</p>
<java><apache-spark><dataframe>
2016-09-06 08:57:02
HQ
39,344,846
Task orphaned for request in react-native – what does it mean?
<p>I am trying to build a grid system for tiles with buttons and other actions. I forked trying with the react native playground grid images source, that you can find <a href="https://rnplay.org/apps/sXriww" rel="noreferrer">here</a>. It produces the following "stacktrace" and error when adding <code>zIndex</code> to individual pics. Images are never portrayed.</p> <p><a href="https://i.stack.imgur.com/9MIIk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9MIIk.png" alt="enter image description here"></a></p> <p>In case you are interested this is the exact component I am using:</p> <pre><code>export default class GridLayout extends Component { constructor () { super() const { width, height } = Dimensions.get('window') this.state = { currentScreenWidth: width, currentScreenHeight: height } } handleRotation (event) { var layout = event.nativeEvent.layout this.setState({ currentScreenWidth: layout.width, currentScreenHeight: layout.height }) } calculatedSize () { var size = this.state.currentScreenWidth / IMAGES_PER_ROW return { width: size, height: size } } renderRow (images) { return images.map((uri, i) =&gt; { return ( &lt;Image key={i} style={[styles.image, this.calculatedSize()]} source={{uri: uri}} /&gt; ) }) } renderImagesInGroupsOf (count) { return _.chunk(IMAGE_URLS, IMAGES_PER_ROW).map((imagesForRow) =&gt; { console.log('row being painted') return ( &lt;View key={uuid.v4()} style={styles.row}&gt; {this.renderRow(imagesForRow)} &lt;/View&gt; ) }) } render () { return ( &lt;ScrollView style={styles.grid} onLayout={(ev) =&gt; this.handleRotation(ev)} contentContainerStyle={styles.scrollView}&gt; {this.renderImagesInGroupsOf(IMAGES_PER_ROW)} &lt;/ScrollView&gt; ) } } var styles = StyleSheet.create({ grid: { flex: 1, backgroundColor: 'blue' }, row: { flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', backgroundColor: 'magenta' }, image: { zIndex: 2000 } }) </code></pre>
<javascript><reactjs><react-native>
2016-09-06 09:01:06
HQ
39,345,809
Wipe AsyncStorage in react native
<p>I notice that I am wasting a certain amount of time debugging <strong>redux</strong> actions that I am persisting to <code>AsyncStorage</code> in <strong>react-native</strong> thanks to <a href="https://github.com/rt2zz/redux-persist" rel="noreferrer">redux-persist</a>. Sometimes I'd just like to wipe AsyncStorage to save some development time and try with fresh data.</p> <p>EDIT: Best case the solution should work on simulators and real devices, iOS and Android. Maybe there are different work arounds for different platforms.</p> <p>Thanks</p>
<javascript><react-native><redux><asyncstorage>
2016-09-06 09:45:57
HQ
39,347,123
Way to create only one reference for all my js files in my html page
<p>I have a lot of js files in my View(html page),and I wonder if there is a way to combine all my js reference to one ref . </p>
<javascript><html><angularjs><web>
2016-09-06 10:46:17
LQ_CLOSE
39,347,392
How to fix Connection reset by peer message from apache-spark?
<p>I keep getting the the following exception very frequently and I wonder why this is happening? After researching I found I could do <code>.set("spark.submit.deployMode", "nio");</code> but that did not work either and I am using spark 2.0.0 </p> <pre><code>WARN TransportChannelHandler: Exception in connection from /172.31.3.245:46014 java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:192) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:221) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:898) at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) </code></pre>
<apache-spark><spark-streaming>
2016-09-06 10:59:40
HQ
39,348,478
Initialize data on dockerized mongo
<p>I'm running a dockerized mongo container.</p> <p>I'd like to create a mongo image with some initialized data.</p> <p>Any ideas?</p>
<mongodb><docker>
2016-09-06 11:57:02
HQ
39,348,812
I have this join sql statement but i cant seem to get the output that i want
SELECT * FROM tblcheck as ch INNER JOIN rooms as r on ch.room_id = r.room_id INNER JOIN roomtype as c on c.RoomType_id = r.RoomType_id INNER JOIN guest as g on g.room_id = ch.room_id the i output i want is to display this Guest Name || Room Name || Roomtype || Check-in Date and Time but i have an error in the guest name. It displays everyone in the Guest Table :( Please help me
<sql><join>
2016-09-06 12:14:08
LQ_EDIT
39,349,043
How can find the label position in panell in winForm in during the vertical scrolling
Hello I have a question <br> I have a panel for example 1000 label controls that the height of each label is variable in win form app and I am going to when scrolling vertically the panel find the position of the first label is seen in the panel [enter image description here][1] [1]: http://i.stack.imgur.com/qstqD.jpg
<c#><winforms><panel>
2016-09-06 12:28:10
LQ_EDIT
39,349,700
Convert a nullable type to its non-nullable type?
<p>I have a bunch of beans that have nullable properties like so:</p> <pre><code>package myapp.mybeans; data class Foo(val name : String?); </code></pre> <p>And I have a method in the global space like so:</p> <pre><code>package myapp.global; public fun makeNewBar(name : String) : Bar { ... } </code></pre> <p>And somewhere else, I need to make a <code>Bar</code> from the stuff that's inside <code>Foo</code>. So, I do this:</p> <pre><code>package myapp.someplaceElse; public fun getFoo() : Foo? { } ... val foo : Foo? = getFoo(); if (foo == null) { ... return; } // I know foo isn't null and *I know* that foo.name isn't null // but I understand that the compiler doesn't. // How do I convert String? to String here? if I do not want // to change the definition of the parameters makeNewBar takes? val bar : Bar = makeNewBar(foo.name); </code></pre> <p>Also, doing some conversion here with <code>foo.name</code> to cleanse it every time with every little thing, while on the one hand provides me compile-time guarantees and safety it is a big bother most of the time. Is there some short-hand to get around these scenarios?</p>
<kotlin>
2016-09-06 13:02:37
HQ
39,349,753
explain logics of dealing with objects in setOnItemClickListener in android
Look at the following code: listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { word word = words.get(position); mMediaPlayer = MediaPlayer.create(FamilyActivity.this, word.getAudioResourceId()); mMediaPlayer.start(); //*************Releasing resources mMediaPlayer.setOnCompletionListener(mCompletionListener); } }); } It belongs to a listview. when a row in that listview is clicked, this method recognize the click and plays the corresponding song for that item. In the forth line you see this code :` word word = words.get(position);`What is "position"?And what is ".get()" method?and can we save them in a word object?Would you explain this specific line of code,please? Thank you in advance! -------------------------------------------------- PS:For more detail I'm gonna show you the "word" class and also "words" arraylist in case you needed to explain: public class word { //////Atributes private String mDefaultTranslation; private String mMiwokTranslation; private int mImageResourceId=NO_IMAGE_PROVIDED; private static final int NO_IMAGE_PROVIDED=-1; private int mAudioResourceId; //Constructor public word(String defaultTranslation,String miwokTranslation,int audioResourceId){ mDefaultTranslation=defaultTranslation; mMiwokTranslation=miwokTranslation; mAudioResourceId=audioResourceId; } public word(String defaultTranslation,String miwokTranslation,int ImageResourceId,int audioResourceId){ mDefaultTranslation=defaultTranslation; mMiwokTranslation=miwokTranslation; mImageResourceId=ImageResourceId; mAudioResourceId=audioResourceId; } //Getters public String getDefaultTranslation(){ return mDefaultTranslation; } public String getMiwokTranslation(){ return mMiwokTranslation; } public int getImageResourceId(){return mImageResourceId;} public boolean hasImage(){return mImageResourceId != NO_IMAGE_PROVIDED;} public int getAudioResourceId(){return mAudioResourceId;} and this is "words" arraylist: final ArrayList<word> words = new ArrayList<word>(); words.add(new word("father", "әpә", R.drawable.family_father, R.raw.family_father)); words.add(new word("mother", "әṭa", R.drawable.family_mother, R.raw.family_mother)); words.add(new word("son", "angsi", R.drawable.family_son, R.raw.family_son)); words.add(new word("daughter", "tune", R.drawable.family_daughter, R.raw.family_daughter)); words.add(new word("older brother", "taachi", R.drawable.family_older_brother, R.raw.family_older_brother)); words.add(new word("younger brother", "chalitti", R.drawable.family_younger_brother, R.raw.family_younger_brother)); words.add(new word("older sister", "teṭe", R.drawable.family_younger_sister, R.raw.family_older_sister)); words.add(new word("ounger sister", "kolliti", R.drawable.family_younger_sister, R.raw.family_younger_sister)); words.add(new word("grandmother", "ama", R.drawable.family_grandmother, R.raw.family_grandmother)); words.add(new word("grandfather", "paapa", R.drawable.family_grandfather, R.raw.family_grandfather));
<java><android><onitemclicklistener>
2016-09-06 13:05:04
LQ_EDIT
39,350,042
`return` in Ruby Array#map
<p>I have a method where I would like to decide what to return within a map function. I am aware that this can be done with assigning a variable, but this is how I though I could do it;</p> <pre><code>def some_method(array) array.map do |x| if x &gt; 10 return x+1 #or whatever else return x-1 end end end </code></pre> <p>This does not work as I expect because the first time <code>return</code> is hit, it returns from the method, and not in the map function, similar to how the return is used in javascript's map function.</p> <p>Is there a way to achieve my desired syntax? Or do I need to assign this to a variable, and leave it hanging at the end like this:</p> <pre><code>def some_method(array) array.map do |x| returnme = x-1 if x &gt; 10 returnme = x+1 #or whatever end returnme end end </code></pre>
<arrays><ruby><return><enumerator>
2016-09-06 13:18:43
HQ
39,350,754
Score function on python
I have to create a basic 3 question quiz on farming. It needs to ask the 3 questions, output whether you got it correct or incorrect and if you got it incorrect you can try again. It also needs to have a score function. I have completed the questions and the incorrect/correct part of the specification but no matter what I try I cannot get the score function to work. I have tried: score = 0 def counter(score) score = score + 1 def counter(score) score = 0 score = score + 1 def counter(score) global score score = 0 score = score + 1 and then following that once the answer was correct the line read : counter(score) I have also tried score = 0 then score = score + 1 but nothing is working and I cannot figure out what is going wrong. It also needs to print how many the user got right at the end. CODE: score = 0 def quiz(): print("Here is a quiz to test your knowledge of farming...") print() print() print("Question 1") print("What percentage of the land is used for farming?") print() print("a. 25%") print("b. 50%") print("c. 75%") answer = input("Make your choice: ") if answer == "c": print("Correct!") score = score + 1 else: print("Incorrect.") answer = input("Try again! ") if answer == "c": print("Correct") score = score + 1 else: print("Incorrect! Sorry the answer was C.") print() print() print("Question 2") print("Roughly how much did farming contribute to the UK economy in 2014.") print() print("a. £8 Billion.") print("b. £10 Billion.") print("c. £12 Billion.") answer = input("Make your choice: ") if answer == "b": print("Correct!") score = score + 1 else: print("Incorrect.") answer = input("Try again! ") if answer == "b": print("Ccrrect!") score = score + 1 else: print("Incorrect! Sorry the answer was B.") print() print() print("Question 3.") print("This device, which was invented in 1882 has revolutionised farming. What is it called?") print() print("a. Tractor") print("b. Wagon.") print("c. Combine.") answer == input("Make your choice. ") if answer == "a": print("Correct!") score = score + 1 else: print("Incorrect.") answer == input("Try again! ") if answer == "a": print("Correct!") score = score + 1 else: print("Incorrect! Sorry the answer was A.") print("You got {0}/3 right!".format(score))
<python>
2016-09-06 13:51:36
LQ_EDIT
39,351,653
distribution from percentage with R
<p>I have distribution of parameter (natural gas mixture composition) expressed in percents. How to test such data for distribution parameters (it should be gamma, normal or lognormal distribution) and generate random composition based on that parameters in R?</p>
<r><distribution><percentage>
2016-09-06 14:34:11
LQ_CLOSE
39,351,746
C++ primer array?
It might be a boring question! thanks! Here's the code: #include <iostream> #include <cstring> using namespace std; int main() { int a[5] = {0}; int b[5]; cout << a << endl; cout << b << endl; for (int i = 0; i < 5; i++) { cout << a[i] << " "; } cout << endl; for (int i = 0; i < 5; i++) { cout << b[i] << " "; } cout << endl; return 0; } in Ubuntu: g++ a.cpp [![enter image description here][1]][1] In windows with DEV C++ ,MinGW GCC 4.7.2: [![enter image description here][2]][2] So the question is focused on the array b: I know I haven't initialized the array b. Array b is full of garbage values, but why there is always having '0' with the fixed position like "X 0 X 0 X"?? What happens inside?? Just a protection mechanism? [1]: http://i.stack.imgur.com/YjAwY.png [2]: http://i.stack.imgur.com/QoNZw.png
<c++><arrays><c++11>
2016-09-06 14:38:49
LQ_EDIT
39,352,145
Change icon when click button ionic 2
<p>i'm trying to change the icon when click the button its show hidden content i need to change up and down arrow icon </p> <pre><code>&lt;button clear text-center (click)="toggle()"&gt; &lt;ion-icon name="arrow-dropdown-circle"&gt;&lt;/ion-icon&gt; &lt;/button&gt; &lt;ion-col [hidden]="!visible" class="accountBalance animated slideInUp"&gt; &lt;ion-list&gt; &lt;ion-item&gt; &lt;h3&gt;limit&lt;/h3&gt; &lt;ion-note item-right&gt; &lt;h2&gt;&amp;#x20B9; 55000.00&lt;/h2&gt; &lt;/ion-note&gt; &lt;/ion-item&gt; &lt;ion-list&gt;&lt;/ion-col&gt; </code></pre> <p>file.ts</p> <pre><code>visible = false; toggle() { this.visible = !this.visible; } </code></pre>
<angular><ionic-framework><ionic2>
2016-09-06 14:58:04
HQ
39,352,644
How to change tab width in git diff?
<p>The standard spacing for a tab is 8 characters.</p> <p>I prefer to view that as 4 characters in my editors and console. I can easily change this default behavior on console with the <code>tabs</code> command:</p> <pre><code>tabs -4 </code></pre> <p>However, when using <code>git diff</code> or <code>git show</code> it displays in the default 8 character tab whitespace.</p> <p>How can I get <code>git diff</code> to render tabs as 4 character spaces?</p>
<git><whitespace><git-diff>
2016-09-06 15:22:03
HQ
39,353,285
Confused with comma's in PHP
<p>I know is a stupid question but well i am trying so hard but i can't figure out on where i am missing the comma i am totally confused ,The below code is giving me an error.</p> <p>it would be great if someone can help me out with a referencing on comma and tips / Tricks on them :) </p> <p>i tried replacing the commas in different places but still it didn't worked out.</p> <pre><code> &lt;td&gt;&lt;?php echo &lt;a href="test1.php?id=&lt;?php echo $row['ID'];?&gt;"/&gt;Download! ?&gt;&lt;/a&gt;&lt;/td&gt; </code></pre> <p>Thanks :) </p>
<php>
2016-09-06 16:00:21
LQ_CLOSE
39,353,462
How does it call id with html?
## Heading ## <asp:LinkButton ID="lnkDelete" Font-Bold="true" ForeColor="Black" runat="server" CommandName="Sil" OnClientClick="OpenPopup('<%# Eval("YolcuId") %>')" Text="Sil"/> ---------- function OpenPopup(id) { $('#sill').modal(); $('#hfsilId').val(id); }
<javascript><asp.net>
2016-09-06 16:10:20
LQ_EDIT
39,354,115
How to enable Gzip Compression in php
<p>i have developed a website in PHP . I want to enable gzip compression to reduce response time of website.how can i do it . </p>
<php><gzip>
2016-09-06 16:49:41
LQ_CLOSE
39,354,159
Issue when copying blocks of memory using memcpy
<p>In my following code, I made <code>buffer</code> as a 2D array created using <code>malloc(r * c * sizeof(double*));</code>. I want to copy the first 12 elements of <code>buffer</code> (i.e. the first 4 rows) into the second one <code>temp</code> using <code>memcpy</code>.</p> <pre><code>double *buffer = malloc(10 * 3 * sizeof(double*)); double *temp = malloc(4 * 3 * sizeof(double*)); for (int i = 0; i &lt; 4; ++i) { memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double)); } </code></pre> <p>I get this error:</p> <pre><code>memcpy(*(temp+ i*3), *(buffer + i*3), 3 * sizeof(double)); ^~~~~~~~~~~~~~~~~~~~~~~~~~ </code></pre> <p>Can someone tell me why?</p> <p>Thank you in advance.</p>
<c>
2016-09-06 16:52:48
LQ_CLOSE
39,354,212
Cordova / Ionic build android Gradle error: Minimum supported Gradle version is 2.14.1. Current version is 2.13
<p>This is a solution to the above error that I want to document. I found other similar posts, but none described how this error can be associated with Cordova or Ionic.</p> <p>If you are not careful, there can be a mismatch between the version of Gradle that Android Studio uses and the version of Gradle that Cordova / cordova-android specifies in its auto-generated application code. As you know, running</p> <pre><code>$ cordova platform add android </code></pre> <p>(or <code>$ ionic platform add android</code>, if you are building an Ionic app) creates the native application code at the-project/platforms/android. </p> <p>Inside that folder, the file: /the-project/platforms/android/cordova/lib/builders/GradleBuilder.js exports a variable as shown below:</p> <pre><code>var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-x.y-all.zip'; </code></pre> <p>Where x and y depened on which version of Cordova / cordova-android are being used to build the native application code. </p> <p>When you run</p> <pre><code>$ cordova build android </code></pre> <p>The version of Gradle specified in the <code>distributionUrl</code> var is the version used for the build.</p> <p>Now here comes the tricky part. When you import the project into Android Studio, you will most likely get a message strongly recommending that you upgrade Gradle to a newer version, as shown below: </p> <p><a href="https://i.stack.imgur.com/N1ytd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N1ytd.png" alt="enter image description here"></a> If you do this, Android Studio will download a new version of Gradle and store it locally and configure the project to use the newly download local Gradle distribution, which is the radio option below the selected “Use default grade wrapper”, which I ended up deselecting because this will cause errors.</p> <p><a href="https://i.stack.imgur.com/geQN9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/geQN9.png" alt="enter image description here"></a> </p> <p>This will cause problems because Android Studio and Cordova will now be attempting to build the application with different versions of Gradle and you will get build errors within Android Studio and also with </p> <pre><code>$ cordova build android </code></pre> <p>in the command line. The solution with Cordova apps is to always keep the Android Studio project set to "Use default gradle wrapper" and ignore the tempting messages to upgrade. If you do want to use a newer version of Gradle, you can always change the distributionUrl var in the file mentioned above (however Cordova strongly discourages modifying code within the platforms folder since it is easily overwritten). At the time of writing this, I cannot tell is there is a way to set the Gradle version at the </p> <pre><code>$ cordova platform add android </code></pre> <p>step, which is when you would want to do it so you are never directly modifiying code inside of the-project/platforms</p>
<android><cordova><android-studio><gradle><ionic-framework>
2016-09-06 16:56:25
HQ