id
int64
4
73.8M
title
stringlengths
10
150
body
stringlengths
17
50.8k
accepted_answer_id
int64
7
73.8M
answer_count
int64
1
182
comment_count
int64
0
89
community_owned_date
stringlengths
23
27
creation_date
stringlengths
23
27
favorite_count
int64
0
11.6k
last_activity_date
stringlengths
23
27
last_edit_date
stringlengths
23
27
last_editor_display_name
stringlengths
2
29
last_editor_user_id
int64
-1
20M
owner_display_name
stringlengths
1
29
owner_user_id
int64
1
20M
parent_id
null
post_type_id
int64
1
1
score
int64
-146
26.6k
tags
stringlengths
1
125
view_count
int64
122
11.6M
answer_body
stringlengths
19
51k
1,023,768
Sieve of Atkin explanation
<p>I am doing a project at the moment and I need an efficient method for calculating prime numbers. I have used the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="noreferrer">sieve of Eratosthenes</a> but, I have been searching around and have found that the <a href="http://en.wikipedia.org/wiki/Siev...
1,023,777
5
3
null
2009-06-21 12:13:35.36 UTC
9
2019-01-04 09:04:04.283 UTC
2010-10-05 23:08:50.43 UTC
Roger Pate
null
null
47,204
null
1
22
primes|sieve-of-eratosthenes|sieve-of-atkin
21,470
<p>The <a href="http://en.wikipedia.org/wiki/Sieve_of_atkin" rel="nofollow noreferrer">wiki page</a> is always a good place to start, since it explains the algorithm in full and provides commented pseudocode. (N.B. There's a lot of detail, and since the wiki website is reliably up, I won't quote it here.)</p> <p>For r...
888,965
What methods are available to stop multiple postbacks of a form in ASP.NET MVC?
<p>A common web problem is where a user clicks the submit button of a form multiple times so the server processes the form more than once. This can also happen when a user hits the back button having submitted a form and so it gets processed again.</p> <p>What is the best way of stopping this from happening in ASP.NE...
889,739
6
0
null
2009-05-20 16:29:59.383 UTC
18
2015-08-02 04:47:42.673 UTC
null
null
null
null
94,898
null
1
21
asp.net-mvc|postback|submit|action-filter
8,129
<p>Often people overlook the most conventional way to handle this which is to use <strong>nonce keys</strong>.</p> <p>You can use <strong><a href="http://en.wikipedia.org/wiki/Post/Redirect/Get" rel="noreferrer">PRG</a></strong> as others have mentioned but the downside with PRG is that it doesn't solve the double-cli...
625,241
How can I use OpenOffice in server mode as a multithreaded service?
<p>What is the experience of working with <a href="http://en.wikipedia.org/wiki/OpenOffice.org" rel="noreferrer">OpenOffice</a> in server mode? I know OpenOffice is not multithreaded and now I need to use its services in our server.<br> What can I do to overcome this problem? </p> <p>I'm using Java.</p>
628,069
6
2
null
2009-03-09 06:53:22.777 UTC
13
2018-06-14 12:18:55.11 UTC
2010-03-06 19:29:19.613 UTC
Dave Webb
63,550
null
63,898
null
1
23
java|multithreading|openoffice.org
24,977
<p>Yes, I am using OpenOffice as a document conversion server.</p> <p>Unfortunately, the solution to your problem is to spawn a pool of OpenOffice processes.</p> <p>The <a href="http://jodconverter.svn.sourceforge.net/viewvc/jodconverter/branches/3.0.x-200801-commons-pool/" rel="noreferrer">commons-pool</a> branch of...
914,951
Show and hide divs at a specific time interval using jQuery
<p>I would like to show divs at a specific interval (10 seconds) and show next div and as go on and repeat the same. <br/></p> <p>**</p> <blockquote> <p><strong><em>Sequence :</em></strong></p> </blockquote> <p>** On 10th second show div1 , hide other divs ,<br> After 5seconds interval Show div 2 and hide other d...
915,016
6
0
null
2009-05-27 10:10:17.7 UTC
21
2019-07-23 05:03:17.863 UTC
2009-05-27 10:21:04.387 UTC
null
1,450
null
98,807
null
1
27
javascript|jquery|css|html|timeout
139,084
<p><strong><a href="http://jsbin.com/acumo" rel="nofollow noreferrer">Working Example</a></strong> here - add <strong>/edit</strong> to the URL to play with the code</p> <p>You just need to use JavaScript <a href="https://developer.mozilla.org/En/Window.setInterval" rel="nofollow noreferrer"><code>setInterval</code></...
1,217,180
How do I byte-compile everything in my .emacs.d directory?
<p>I have decided to check out Emacs, and I liked it very much. Now, I'm using the <a href="http://github.com/technomancy/emacs-starter-kit/tree/master" rel="noreferrer">Emacs Starter Kit</a>, which sort of provides better defaults and some nice customizations to default install of Emacs.</p> <p>I have customized it a...
1,217,249
6
0
null
2009-08-01 18:34:01.33 UTC
77
2020-08-19 20:00:15.763 UTC
null
null
null
null
141,147
null
1
144
emacs|elisp|bytecode|dot-emacs
43,810
<p><code>C-u 0 M-x byte-recompile-directory</code></p> <p>will compile all the .el files in the directory and in all subdirectories below.</p> <p>The <code>C-u 0</code> part is to make it not ask about every .el file that does not have a .elc counterpart.</p>
32,234,711
Which sorting algorithm works best on very large data set that won't fit in the main memory
<p>I was searching on the Internet to find which sorting algorithm is best suitable for a very large data set. I found that many have an opinion that merge sort is best because it is fair, as well as that it ensures that time complexity is O(n log n) and quick sort is not safe: It is also true that variations of quicks...
32,234,821
2
10
null
2015-08-26 19:04:44.87 UTC
11
2022-06-04 09:28:25.25 UTC
2022-06-04 09:28:25.25 UTC
null
1,145,388
null
5,151,912
null
1
22
algorithm|sorting
53,295
<p>There's no one algorithm that's clearly the &quot;best&quot; algorithm. If there were, we'd be using it everywhere! Instead, it depends on a bunch of factors.</p> <p>For starters, can you fit your data into main memory? If you can't, then you'd need to rely on an external sorting algorithm. These algorithms are ofte...
35,689,431
determine OS distribution of a docker image
<p>I need to determine the OS distribution name for any docker image. I can tag <strong>ubuntu:latest</strong> as <strong>image1:latest</strong>, but I should be able to get the distribution information of image1:latest when it is launched.</p> <p>For achieving this, I used the below mentioned command to determine the...
35,690,567
5
3
null
2016-02-28 23:07:05.48 UTC
7
2020-08-06 10:28:19.107 UTC
2016-02-28 23:15:18.473 UTC
null
670,629
null
670,629
null
1
28
python|docker|dockerfile
24,372
<p>The Filesystem Hierarchy Standard has a <a href="https://www.freedesktop.org/software/systemd/man/os-release.html" rel="noreferrer">standard definition for <code>/etc/os-release</code></a>, which should be available on most distributions:</p> <blockquote> <p>The /etc/os-release and /usr/lib/os-release files contain ...
44,352,870
How to handle database migrations in Spring Boot with Hibernate?
<p>My database background comes from the Django framework (python). In Django, getting started with database migrations was easy: <a href="https://docs.djangoproject.com/en/1.11/topics/migrations/" rel="noreferrer">Django migrations</a>. The Django framework provided tool for creating the migrations based on your model...
44,353,848
1
2
null
2017-06-04 10:01:03.92 UTC
8
2017-06-04 14:25:35.483 UTC
null
null
null
null
4,662,347
null
1
31
java|spring|hibernate|jpa|spring-boot
18,025
<p>Liquibase or Flyway are the two main options for versioning/handling database migrations. <code>ddl-auto</code> is quick and dirty, but it does not, nor can it, take into account everything that needs to be handled. THere's also the chance of race-conditions (two instances trying to update the DDL at the same time)....
23,128,353
zsh shortcut 'ctrl + A' not working
<p>I recently switch from bash to zsh shell. To be more precise, the <a href="https://github.com/robbyrussell/oh-my-zsh">oh-my-zsh</a> Very nice, but the shortcut I most often use; jumping to the beginning/end of the line doesn't work anymore. From the <a href="http://www.geekmind.net/2011/01/shortcuts-to-improve-your-...
23,134,765
3
2
null
2014-04-17 08:36:52.507 UTC
5
2019-05-24 05:09:26.427 UTC
null
null
null
null
419,425
null
1
29
shell|keyboard-shortcuts|zsh|shortcut
11,585
<p>you don't have to config the <kbd>Ctrl</kbd>+<kbd>A</kbd> behavior if you use default keymap (<code>emacs</code> keymap). It does what you are expecting.</p> <p>However if you set your zle to use <code>vi</code> keymap, you have to define the <code>keybind</code> for <code>vi-beginning-of-line</code>. same for <kbd...
2,041,859
Javascript - how to find hebrew?
<p>i"m trying to fint if a string starts(first letter) width an RTL language/ hebrew.</p> <p>any ideas?</p>
2,041,895
5
0
null
2010-01-11 12:47:56.177 UTC
9
2020-09-20 04:33:03.847 UTC
2013-06-05 11:40:33.45 UTC
null
569,101
Gilad
null
null
1
24
javascript|regex|hebrew|right-to-left
16,102
<p>This will find hebrew letters encoded in the <a href="http://www.alanwood.net/unicode/hebrew.html" rel="noreferrer">Hebrew</a> Unicode code point range: <code>[\u0590-\u05FF]</code></p>
2,299,339
User Control vs. Windows Form
<p>What is the difference between a user control and a windows form in Visual Studio - C#?</p>
2,299,368
5
0
null
2010-02-19 20:29:52.943 UTC
12
2022-07-21 18:45:32.02 UTC
null
null
null
null
258,482
null
1
64
c#|visual-studio|winforms
62,003
<p>Put very simply:</p> <p>User controls are a way of making a custom, reusable component. A user control can contain other controls but must be hosted by a form.</p> <p>Windows forms are the container for controls, including user controls. While it contains many similar attributes as a user control, it's primary pur...
1,734,896
R - capturing elements of R output into text files
<p>I am trying to run an analysis by invoking R through the command line as follows: </p> <pre><code>R --no-save &lt; SampleProgram.R &gt; SampleProgram.opt </code></pre> <p>For example, consider the simple R program below: </p> <pre><code>mydata = read.csv("test.txt", header=T) attach(mydata) summary(Variable1) q()...
1,735,807
6
0
null
2009-11-14 17:15:32.253 UTC
13
2014-09-24 23:23:19.797 UTC
2010-04-08 17:44:31.517 UTC
null
168,225
null
211,082
null
1
21
command-line|r
49,660
<p>You can also access individual attributes of the <code>summary</code> command. For example</p> <pre><code>&gt; x=summary(seq(1:10)) &gt; attributes(x) &gt; attributes(x) $names [1] "Min." "1st Qu." "Median" "Mean" "3rd Qu." "Max." $class [1] "table" &gt; x["1st Qu."] 1st Qu. 3.25 </code></pre>
1,685,221
accurately measure time python function takes
<p>I need to measure the time certain parts of my program take (not for debugging but as a feature in the output). Accuracy is important because the total time will be a fraction of a second.</p> <p>I was going to use the <a href="http://docs.python.org/library/time.html" rel="noreferrer">time module</a> when I came a...
1,685,263
7
2
null
2009-11-06 03:25:04.083 UTC
20
2019-12-26 16:43:03.507 UTC
null
null
null
null
105,066
null
1
49
python|time|profiling|timeit
36,448
<p>According to the Python <a href="http://docs.python.org/library/timeit.html" rel="noreferrer">documentation</a>, it has to do with the accuracy of the time function in different operating systems:</p> <blockquote> <p>The default timer function is platform dependent. On Windows, time.clock() has microsecond gr...
1,581,551
download webpage and dependencies, including css images
<p>Often I need to download a webpage and then edit it offline. I have tried a few tools and the main feature they lack is downloading images referenced in the CSS files.</p> <p>Is there a tool (for Linux) that will download everything so that the webpage will render the same offline (excluding AJAX)?</p>
1,581,553
7
3
null
2009-10-17 06:07:06.357 UTC
34
2020-04-15 14:43:47.497 UTC
2016-12-02 14:33:06.1 UTC
null
773,263
null
105,066
null
1
75
html|css|image|download
75,837
<pre><code>wget --page-requisites http://example.com/your/page.html </code></pre> <blockquote> <p><a href="http://www.gnu.org/software/wget/manual/wget.html#index-page-requisites" rel="noreferrer">This option</a> causes Wget to download all the files that are necessary to properly display a given html page. This inc...
1,962,389
What is the state of the art in HTML content extraction?
<p>There's a lot of scholarly work on HTML content extraction, e.g., Gupta &amp; Kaiser (2005) <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.60.357" rel="nofollow noreferrer">Extracting Content from Accessible Web Pages</a>, and some signs of interest here, e.g., <a href="https://stackoverflow.com/qu...
1,962,521
8
3
null
2009-12-26 01:22:48.48 UTC
27
2015-03-18 21:25:45.807 UTC
2017-05-23 12:01:55.357 UTC
null
-1
null
222,815
null
1
18
html|html-content-extraction|text-extraction
5,673
<p>Extraction can mean different things to different people. It's one thing to be able to deal with all of the mangled HTML out there, and Beautiful Soup is a clear winner in this department. But BS won't tell you what is cruft and what is meat.</p> <p>Things look different (and ugly) when considering content extracti...
1,757,097
How to determine file age using PHP?
<p>Any way to determine file age of an image in a folder using PHP?</p> <p>I want to delete older files than 2 hours, is this possible without adding timestamp-names to their filenames on upload to the folder?</p> <p>If so, please give me an example!</p> <p>thanks</p>
1,757,115
8
0
null
2009-11-18 16:09:36.78 UTC
6
2020-03-07 02:04:31.09 UTC
null
null
null
user188962
null
null
1
55
php
40,211
<p>You can use <a href="http://www.php.net/manual/en/function.filemtime.php" rel="noreferrer">filemtime</a> function to get the last modified date/time and use that to see how old the file is.</p>
2,066,917
Overriding equals() & hashCode() in sub classes ... considering super fields
<p>Is there a specific rule on how Overriding <code>equals()</code> &amp; <code>hashCode()</code> in <strong>sub classes</strong> considering <strong>super fields</strong> ?? knowing that there is many parameters : super fields are private/public , with/without getter ...</p> <p>For instance, Netbeans generated equals...
2,067,401
10
1
null
2010-01-14 19:26:43.393 UTC
24
2018-06-06 12:34:11.417 UTC
null
null
null
null
236,223
null
1
73
java|inheritance|overriding|equals|hashcode
66,283
<p><b>Children should not examine the private members of their parents</b></p> <p>But <em>obviously</em>, all significant fields should be taken into account for equality and hashing.</p> <p>Fortunately, you you can easily satisfy both rules.</p> <p>Assuming you're not stuck using the NetBeans-generated equals and h...
1,710,476
How to print a query string with parameter values when using Hibernate
<p>Is it possible in Hibernate to print generated SQL queries with real values instead of question marks?</p> <p>How would you suggest to print queries with real values if it is not possible with Hibernate API?</p>
1,713,464
32
1
null
2009-11-10 19:17:59.55 UTC
181
2021-12-08 18:18:47.893 UTC
2017-12-13 04:14:50.137 UTC
null
7,848,065
null
162,461
null
1
482
java|sql|hibernate|orm
482,538
<p>You need to enable <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-logging" rel="noreferrer">logging</a> for the the following categories:</p> <ul> <li><code>org.hibernate.SQL</code> &nbsp;&nbsp;- set to <code>debug</code> to log all SQL DML statements as...
8,587,321
Are Github pages created automatically in the fork of a repo which has a gh-pages branch?
<p>Are github pages within my account created automatically when I fork a repo which already includes gh-pages branch?</p>
8,592,337
6
2
null
2011-12-21 09:07:47.97 UTC
6
2016-07-11 23:38:50.903 UTC
2015-04-12 06:32:29.887 UTC
null
895,245
null
217,288
null
1
41
github|github-pages
9,792
<p>There needs to be at least one push to trigger a page build so by doing a <code>git push origin master</code>, I got the page to rebuild.</p>
18,179,915
One line if/else condition in linux shell scripting
<p>I would like to have the equivelant of the following in a one line if/else condition.</p> <pre><code>$maxline=`cat journald.conf | grep "#SystemMaxUse="` if [ $maxline == "#SystemMaxUse=" ] then sed 's/\#SystemMaxUse=/SystemMaxUse=50M/g' journald.conf &gt; journald.conf2 mv journald.conf2 journald.conf; els...
18,180,051
4
3
null
2013-08-12 05:13:31.147 UTC
12
2022-08-15 14:52:32.023 UTC
null
null
null
null
2,529,482
null
1
61
linux|shell|if-statement
155,702
<p>It looks as if you were on the right track. You just need to add the else statement after the ";" following the "then" statement. Also I would split the first line from the second line with a semicolon instead of joining it with "&amp;&amp;".</p> <pre><code>maxline='cat journald.conf | grep "#SystemMaxUse="'; if [ ...
17,939,556
How to get the execution directory path in java
<p>I have made a pure java app which tells me about number of files in a given directory. Now I set current directory by using the following code:</p> <pre><code>`File f = new File(".");` </code></pre> <p>After that I made an installer with its jar file and installed it in my windows 8 and then I add it to the window...
17,939,617
5
2
null
2013-07-30 06:16:26.977 UTC
5
2017-04-05 12:20:01.717 UTC
2017-04-05 12:20:01.717 UTC
null
617,450
null
2,229,597
null
1
24
java
94,753
<p>As Jarrod Roberson states in <a href="https://stackoverflow.com/a/3153440/19679">his answer here</a>:</p> <blockquote> <p>One way would be to use the <a href="http://java.sun.com/javase/6/docs/api/java/lang/System.html#getProperty%28java.lang.String%29" rel="noreferrer">system property</a> <code>System.getPrope...
44,806,474
Disable error reporting entirely in Laravel production?
<p>I would like to disable error reporting entirely on production, because we have some very old code we still need to fix but for now does work (yes I don't like it either). We cannot fix everything in a few days, so we need to just supress the warnings and exceptions like we always did.</p> <p>The real problem is th...
44,862,789
8
15
null
2017-06-28 15:13:19.15 UTC
7
2020-12-30 13:45:08.623 UTC
2017-07-04 20:13:08.027 UTC
null
2,754,599
null
2,754,599
null
1
21
php|laravel|laravel-5|laravel-5.3|laravel-5.4
48,616
<p>Yes you can change the error reporting. In fact, the framework provides a place to intercept the exceptions: <code>App\Exceptions\Handler</code>. By default the <code>render</code> method will convert the exception thrown to a HTML response. The <code>APP_ENV</code> and <code>APP_DEBUG</code> values will only change...
18,869,141
Using Python mock to spy on calls to an existing object
<p>I'm using the Python mock module for tests. I would like to replace an active object with a mock, and automatically have all calls made to the mock object forwarded to the original object. I think this is called a "Spy" in standard testing terminology. At the moment I'm doing inside a test:</p> <pre><code># Insert ...
20,130,972
6
2
null
2013-09-18 09:55:50.22 UTC
6
2022-07-26 14:48:57.913 UTC
2013-09-18 17:45:17.46 UTC
null
64,633
null
1,113,345
null
1
53
python|unit-testing|mocking
36,916
<p>I seem to have stumbled across the solution:</p> <pre><code>import mock class A(object): def meth(self, a): return a a = A() ma = mock.Mock(wraps=a) </code></pre> <p>Seems to work okay for functions, methods and properties, but not for class or instance attributes.</p> <p>See <a href="https://docs.py...
19,110,668
Static table view inside UIViewController [Xcode 5]
<p>I'm aware of the problem that one is not able to have static table view content in a UIViewController in <p>I don't get a warning/error but he also doesn't compile. Is there a trick to it or do I have to use the old ways around it?</p> <p>Thanks in advance.</p>
19,110,821
5
2
null
2013-10-01 07:44:34.48 UTC
10
2014-03-27 09:10:36.563 UTC
null
null
null
null
2,818,444
null
1
26
objective-c|xcode
27,014
<p><strong>UPDATE: With the latest update (Xcode 5.1) it seems that it's no longer possible to put static cells inside regular UIViewController. My answer still applies for UITableViewController though.</strong></p> <hr> <p>Yes, you can have static table view content in UIViewController.</p> <p>All you need to do is...
34,933,146
Prevent Captive Portal auto-close after authentication (Android)
<p>So the simple idea is that we have a RADIUS server setup to allow users to authenticate with our Ruckus controller via user credentials. On authentication the user should be redirected to a page that allows them to manage MAC authenticated devices.</p> <p>On everything we have tested so far, including "older" Andro...
44,331,058
3
6
null
2016-01-21 19:58:10.427 UTC
11
2019-11-18 19:33:06.493 UTC
2019-11-18 19:33:06.493 UTC
null
1,839,439
null
2,387,054
null
1
14
javascript|android|authentication|captivenetwork
14,973
<p>We have managed to keep the UAM Browser / captive portal browser open on lollipop by adding firewall rules blocking : </p> <ul> <li>clients3.google.com</li> <li>clients1.google.com , </li> <li>android.clients.google.com</li> <li>connectivitycheck.android.com</li> <li>connectivitycheck.gstatic.com</li> </ul> <p>...
40,973,687
Create new dataframe in pandas with dynamic names also add new column
<p>I have a dataframe df </p> <pre><code> df = pd.DataFrame({'A':['-a',1,'a'], 'B':['a',np.nan,'c'], 'ID':[1,2,2], 't':[pd.tslib.Timestamp.now(),pd.tslib.Timestamp.now(), np.nan]}) </code></pre> <p>Added a new column </p> <pre><code>df['YearMonth'] =...
40,974,699
2
4
null
2016-12-05 11:53:39.103 UTC
4
2022-07-07 07:19:07.063 UTC
2016-12-05 15:39:59.157 UTC
null
4,245,148
null
4,245,148
null
1
9
python|pandas|numpy
44,169
<p>Creating variables with dynamic names is typically a bad practice.</p> <p>I think the best solution for your problem is to store your dataframes into a dictionary and dynamically generate the name of the key to access each dataframe.</p> <pre><code>import copy dict_of_df = {} for ym in [201511, 201612, 201710]: ...
4,877,326
How can I tell if a string contains multibyte characters in Javascript?
<p>Is it possible in Javascript to detect if a string contains multibyte characters? If so, is it possible to tell which ones?</p> <p>The problem I'm running into is this (apologies if the Unicode char doesn't show up right for you)</p> <pre><code>s = ""; alert(s.length); // '2' alert(s.charAt(0)); // '��' alert(...
4,885,062
2
6
null
2011-02-02 16:56:21.523 UTC
17
2022-08-10 13:49:38.347 UTC
2011-02-03 17:18:58.293 UTC
null
9,021
null
9,021
null
1
27
javascript|string|internationalization|multibyte
11,299
<p>JavaScript strings are UCS-2 encoded but can represent Unicode code points outside the Basic Multilingual Pane (<code>U+0000</code> - <code>U+D7FF</code> and <code>U+E000</code> - <code>U+FFFF</code>) using two 16 bit numbers (a UTF-16 <em>surrogate pair</em>), the first of which must be in the range <code>U+D800</c...
5,376,387
Do you know of any free SOAP webservices (for tutorial purpose)
<p>Only for tutorial purpose, I would like to try to use a free SOAP web services available.</p> <p>Which ones come to your mind ?</p> <p>The business implied behind is not important/relevant: Only the ease of access (free access), and simplicity of the service contract.</p> <p>Any indication welcome !</p>
5,376,425
2
1
null
2011-03-21 10:30:49.293 UTC
3
2016-04-11 20:41:39.85 UTC
2016-04-11 20:41:39.85 UTC
null
356,440
null
356,440
null
1
30
soap|webservice-client
72,955
<p>You can look at this post</p> <p><a href="https://stackoverflow.com/questions/311654/public-free-web-services-for-testing-soap-client">Public free web services for testing soap client</a></p>
939,563
C# return a variable as read only from get; set;
<p>I swear I have seen an example of this but have been googling for a bit and can not find it.</p> <p>I have a class that has a reference to an object and need to have a GET; method for it. My problem is that I do not want anyone to be able to fiddle with it, i.e. I want them to get a read only version of it, (note ...
939,591
7
3
null
2009-06-02 13:33:38.01 UTC
7
2016-03-21 14:18:29.837 UTC
2009-06-02 13:37:41.373 UTC
null
3,043
null
6,486
null
1
36
c#|properties|readonly
24,365
<p>No, there's no way of doing this. For instance, if you return a <code>List&lt;string&gt;</code> (and it's not immutable) then callers <em>will</em> be able to add entries.</p> <p>The normal way round this is to return an immutable wrapper, e.g. <a href="http://msdn.microsoft.com/en-us/library/ms132474.aspx" rel="no...
220,149
How do I access the HTTP request header fields via JavaScript?
<p>I want to capture the HTTP request header fields, primarily the Referer and User-Agent, within my client-side JavaScript. How may I access them?</p> <hr> <p>Google Analytics manages to get the data via JavaScript that they have you embed in you pages, so it is definitely possible.</p> <blockquote> <p><strong>R...
220,169
7
1
null
2008-10-20 22:21:21.14 UTC
12
2020-10-31 18:28:31.397 UTC
2017-05-23 11:47:19.92 UTC
dacracot
-1
dacracot
13,930
null
1
66
javascript|http|http-headers
166,762
<p>If you want to access referrer and user-agent, those are available to client-side Javascript, but not by accessing the headers directly.</p> <p>To retrieve the referrer, use <a href="https://developer.mozilla.org/en-US/docs/DOM/document.referrer" rel="noreferrer"><code>document.referrer</code></a>.<br> To access th...
602,237
Where does 'Hello world' come from?
<p>'<code>hello, world</code>' is usually the first example for any programming language. I've always wondered where this sentence came from and where was it first used.</p> <p>I've once been told that it was the first sentence ever to be displayed on a computer screen, but I've not been able to find any reference to ...
12,785,204
7
0
2009-03-02 15:13:31.43 UTC
2009-03-02 12:55:27.487 UTC
24
2021-02-24 15:18:22.76 UTC
2016-11-30 09:06:15.257 UTC
Jacco
22,674
Jacco
22,674
null
1
119
history
79,104
<p>Brian Kernighan actually wrote the first &quot;hello, world&quot; program as part of the documentation for the BCPL programming language developed by Martin Richards. BCPL was used while C was being developed at Bell Labs a few years before the publication of Kernighan and Ritchie's C book in 1972.</p> <p><a href="h...
916,190
VS2010 and VS2008 project compatibility
<p>Does anyone know if VS2010 will use the same project &amp; solution file format as 2008, or will the 2008 project files need to be upgraded to 2010 format before they'll open in that version?</p>
916,229
8
1
null
2009-05-27 14:51:07.587 UTC
9
2013-03-05 08:25:05.923 UTC
null
null
null
null
36,297
null
1
21
visual-studio-2008|visual-studio-2010
61,355
<p>"Visual Studio 2010 will allow you to move your projects from previous versions of Visual Studios to VS 2010 with ease, I will call this process as “Converting” the project from VS 200X to VS 2010… </p> <p>VS 2010 will also allow you to change your project’s Target Framework Version to .NET 4.0 from .NET 2.0, 3.0...
1,268,738
ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller
<p>What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I'd like to be able to temporarily work with an .xml file and I don't want to hardcode the path.</p> <p>This does not work: </p> <pre><code>[HandleError] public class HomeController : Controller {...
1,268,755
8
1
null
2009-08-12 21:06:30.573 UTC
62
2021-07-21 12:22:22.037 UTC
null
null
null
null
36,590
null
1
294
.net|asp.net-mvc|absolute-path
281,618
<h3>ASP.NET MVC1 -> MVC3</h3> <pre><code>string path = HttpContext.Current.Server.MapPath("~/App_Data/somedata.xml"); </code></pre> <hr> <h3>ASP.NET MVC4</h3> <pre><code>string path = Server.MapPath("~/App_Data/somedata.xml"); </code></pre> <p><hr> MSDN Reference:</p> <p><a href="http://msdn.microsoft.com/en-us/l...
876,115
How can I determine if a div is scrolled to the bottom?
<p>How do I determine, without using jQuery or any other JavaScript library, if a div with a vertical scrollbar is scrolled all the way to the bottom?</p> <p>My question is not how to scroll to the bottom. I know how to do that. I want to determine if the the div is scrolled to the bottom already.</p> <p>This does no...
876,134
8
2
null
2009-05-18 03:19:05.747 UTC
25
2021-07-03 18:02:56.513 UTC
2010-03-24 22:23:04.203 UTC
Roger Pate
null
null
66,475
null
1
117
javascript|scroll|scrollbar
75,480
<p>You're pretty close using <code>scrollTop == scrollHeight</code>.</p> <p><code>scrollTop</code> refers to the top of the scroll position, which will be <code>scrollHeight - offsetHeight</code></p> <p>Your if statement should look like so (don't forget to use triple equals):</p> <pre><code>if( obj.scrollTop === (o...
156,438
What Does It Mean For a C++ Function To Be Inline?
<p>See title: what does it mean for a C++ function to be inline?</p>
156,458
9
1
null
2008-10-01 06:25:18.093 UTC
10
2022-02-28 00:36:06 UTC
2015-02-19 21:52:38.87 UTC
Lars Westergren
3,001,761
Tim Sally
7,545
null
1
32
c++|inline-functions
18,988
<p>The function is placed in the code, rather than being called, similar to using macros (conceptually).</p> <p>This can improve speed (no function call), but causes code bloat (if the function is used 100 times, you now have 100 copies).</p> <p>You should note this does not force the compiler to make the function inli...
528,648
How to structure my javascript/jquery code?
<p>I am toying around with a pretty intensive ajax based jquery web application. It is getting to a point where I almost loose track of what events that should trigger what actions etc.</p> <p>I am sort of left with a feeling that my javascript structure is wrong, on a more basic level. How do you guys structure your ...
8,127,152
10
1
null
2009-02-09 15:36:39.697 UTC
59
2018-05-12 06:51:38.783 UTC
null
null
null
Egil Hansen
32,809
null
1
65
javascript|jquery
24,704
<p>AMDS!</p> <p>It's been awhile since first answers got posted to this question and many things have changed. First and foremost, the JS browser world seems to be moving towards AMDs (asynchronous module definition) for code organization.</p> <p>The way that works is you write ALL your code as AMD modules, e.g.:</p>...
853,405
What does the Subversion status symbol "~" mean?
<p>I am getting a tilde symbol when I do an <code>svn status</code>.</p> <p>Here is the output of the project after editing it in XCode.</p> <pre><code>svn status M build/Currency_Converter.build/Currency_Converter.pbxindex/imports.pbxbtree M build/Currency_Converter.build/Currency_Converter.pbxindex/pbxindex...
853,418
11
1
null
2009-05-12 15:36:49.503 UTC
23
2021-02-19 16:19:35.66 UTC
2021-02-19 16:19:35.66 UTC
null
1,783,163
null
78,093
null
1
114
svn|xcode|status
75,330
<p>The <a href="http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.status.html" rel="noreferrer">SVN Book</a> says:</p> <blockquote> <p>Item is versioned as one kind of object (file, directory, link), but has been replaced by different kind of object.</p> </blockquote> <p>So perhaps it was originally a single file, b...
965,694
What's the official way of storing settings for Python programs?
<p><code>Django</code> uses real Python files for settings, <code>Trac</code> uses a <code>.ini</code> file, and some other pieces of software uses XML files to hold this information.</p> <p>Are one of these approaches blessed by Guido and/or the Python community more than another?</p>
965,795
13
3
null
2009-06-08 16:13:02.43 UTC
15
2021-11-27 17:59:26.927 UTC
2021-05-05 00:41:28.193 UTC
null
98,855
null
98,855
null
1
65
python|settings
44,343
<p>Depends on the predominant intended audience.</p> <p>If it is programmers who change the file anyway, just use python files like settings.py</p> <p>If it is end users then, think about ini files.</p>
262,727
How do you measure the quality of your unit tests?
<p>If you (or your organization) aspires to thoroughly unit test your code, how do you measure the success or quality of your efforts? </p> <ul> <li>Do you use code coverage, what percentage do you aim for? </li> <li>Do you find that philosophies like TDD have a better impact than metrics?</li> </ul>
262,888
14
0
null
2008-11-04 17:57:22.653 UTC
9
2021-09-22 02:19:55.407 UTC
2013-11-14 22:01:06.173 UTC
user1228
null
vfilby
24,279
null
1
41
unit-testing|testing|tdd
12,971
<p>My tip is not a way to determine whether you have good unit tests per se, but it's a way to grow a good test suite over time.</p> <p>Whenever you encounter a bug, either in your development or reported by someone else, fix it twice. You first create a unit test that reproduces the problem. When you've got a failing...
209,418
What are some JavaScript unit testing and mocking frameworks you have used?
<p>My main JavaScript framework is <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>, so I would like my unit test and mocking frameworks to be compatible with that. I'd rather not have to introduce another JavaScript framework.</p> <p>I am currently using <a href="http://docs.jquery.com/QUnit" rel="nof...
209,692
14
3
null
2008-10-16 16:56:34.497 UTC
29
2021-06-27 09:38:00.55 UTC
2021-01-11 07:13:13.517 UTC
JasonBunting
63,550
Elijah Manor
4,481
null
1
42
javascript|jquery|unit-testing|mocking|qunit
22,518
<p><a href="http://docs.jquery.com/QUnit" rel="nofollow noreferrer">QUnit</a> <br/> <a href="http://code.google.com/p/jqunit/" rel="nofollow noreferrer">jqUnit</a> <br/> <a href="http://wiki.fluidproject.org/display/fluid/Writing+JavaScript+Unit+Tests" rel="nofollow noreferrer">Writing JavaScript tests with QUnit and j...
1,070,354
How do I get the current date in Cocoa
<p>I'm getting started developing for the iPhone and as such I am looking at different tutorials online as well as trying some different things out myself. Currently, I'm trying to create a countdown until midnight. To get the number of hour, minutes, and seconds, I do the following (which I found somewhere):</p> <pre...
1,070,412
14
0
null
2009-07-01 17:25:18.233 UTC
23
2015-12-13 10:17:22.347 UTC
2009-07-01 21:26:26.603 UTC
null
120,292
null
91,632
null
1
60
objective-c|cocoa|nsdate
131,526
<p>You must use the following:</p> <pre><code>NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *dateComponents = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:yourDateHere]; NSInteger hour = [dateComponent...
228,620
Garbage Collection in C++ -- why?
<p>I keep hearing people complaining that C++ doesn't have garbage collection. I also hear that the C++ Standards Committee is looking at adding it to the language. I'm afraid I just don't see the point to it... using RAII with smart pointers eliminates the need for it, right?</p> <p>My only experience with garbage co...
228,722
16
3
null
2008-10-23 05:24:59.43 UTC
26
2015-05-06 16:43:12.703 UTC
2008-10-23 05:31:03.677 UTC
coppro
16,855
Head Geek
12,193
null
1
48
c++|garbage-collection|c++11
15,071
<h2>I keep hearing people complaining that C++ doesn't have garbage collection.</h2> <p>I am so sorry for them. Seriously.</p> <p>C++ has RAII, and I always complain to find no RAII (or a castrated RAII) in Garbage Collected languages.</p> <h2>What advantages could garbage collection offer an experienced C++ developer?...
434,597
Open document with default OS application in Python, both in Windows and Mac OS
<p>I need to be able to open a document using its default application in Windows and Mac OS. Basically, I want to do the same thing that happens when you double-click on the document icon in Explorer or Finder. What is the best way to do this in Python?</p>
434,612
16
1
null
2009-01-12 06:23:51.247 UTC
43
2022-08-17 11:59:22.387 UTC
2019-05-08 05:57:13.53 UTC
null
202,229
Abdullah Jibaly
47,110
null
1
165
python|windows|macos
122,492
<p><code>open</code> and <code>start</code> are command-interpreter things for Mac OS/X and Windows respectively, to do this.</p> <p>To call them from Python, you can either use <code>subprocess</code> module or <code>os.system()</code>. </p> <p>Here are considerations on which package to use:</p> <ol> <li><p>You ca...
202,302
Rounding to an arbitrary number of significant digits
<p>How can you round <em>any</em> number (not just integers > 0) to N significant digits?</p> <p>For example, if I want to round to three significant digits, I'm looking for a formula that could take:</p> <p>1,239,451 and return 1,240,000</p> <p>12.1257 and return 12.1</p> <p>.0681 and return .0681</p> <p>5 and re...
1,581,007
17
1
null
2008-10-14 18:37:17.603 UTC
23
2020-07-12 13:28:07.47 UTC
2017-05-04 20:18:18.193 UTC
Cristi&#225;n Romo
63,550
DougN
7,442
null
1
85
algorithm|rounding|significant-digits
41,788
<p>Here's the same code in Java without the 12.100000000000001 bug other answers have</p> <p>I also removed repeated code, changed <code>power</code> to a type integer to prevent floating issues when <code>n - d</code> is done, and made the long intermediate more clear</p> <p>The bug was caused by multiplying a large...
101,055
When is a language considered a scripting language?
<p>What makes a language a scripting language? I've heard some people say &quot;when it gets interpreted instead of compiled&quot;. That would make PHP (for example) a scripting language. Is that the only criterion? Or are there other criteria?</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/question...
101,077
40
10
2010-06-15 21:34:53.79 UTC
2008-09-19 10:51:26.717 UTC
72
2014-07-03 10:04:39.903 UTC
2020-06-20 09:12:55.06 UTC
Andy Lester
-1
Sietse de Kaper
6,400
null
1
107
programming-languages|scripting|terminology|semantics
129,137
<p>A scripting language is a language that "scripts" other things to do stuff. The primary focus isn't primarily building your own apps so much as getting an existing app to act the way you want, e.g. JavaScript for browsers, VBA for MS Office.</p>
487,073
How to check if element is visible after scrolling?
<p>I'm loading elements via AJAX. Some of them are only visible if you scroll down the page. Is there any way I can know if an element is now in the visible part of the page?</p>
488,073
46
11
null
2009-01-28 10:00:55.303 UTC
509
2022-02-25 09:01:26.353 UTC
2020-07-02 19:59:13.703 UTC
user10758159
362,780
yoavf
1,011
null
1
1,336
javascript|jquery|scroll
850,959
<p>This should do the trick:</p> <pre><code>function isScrolledIntoView(elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top; var elemBottom = elemTop + $(elem).height(); return ((elemBottom &lt;= docViewBottom) &a...
6,958,413
Xcode: show documentation for my custom classes
<p>How can I force Xcode to show my own documentation for custom classes, methods, etc.? I'm used to Java and Eclipse, which shows me documentation for my classes as shown here:</p> <p><img src="https://i.stack.imgur.com/czyo4.png" alt="Eclipse showing Javadocs documentation"></p> <p>How can I achieve the same in Xco...
19,258,190
5
2
null
2011-08-05 15:02:07.197 UTC
21
2015-06-23 17:44:49.837 UTC
2015-02-05 14:36:00.55 UTC
null
3,366,929
null
47,190
null
1
49
xcode
15,946
<p>As of Xcode 5.0, Doxygen and HeaderDoc formatting for variables and methods is automatically parsed and rendered in the Quick Help popover. More information about it <a href="http://confusatory.org/post/63488534619/documentation-in-xcode-5" rel="noreferrer">here</a>, but here's some key bits:</p> <pre><code>/** * ...
6,892,044
Add virtual attribute to json output
<p>Let's say I have an app that handles a TODO list. The list has finished and unfinished items. Now I want to add two virtual attributes to the list object; the count of finished and unfinished items in the list. I also need these to be displayed in the json output.</p> <p>I have two methods in my model which fetches...
6,892,207
8
1
null
2011-07-31 20:16:34.54 UTC
11
2021-01-26 11:28:30.497 UTC
2015-03-29 16:31:02.467 UTC
null
650,711
null
650,711
null
1
68
ruby-on-rails|json
32,826
<p>The serialization of objects in Rails has two steps:</p> <ul> <li>First, <code>as_json</code> is called to convert the object to a simplified Hash.</li> <li>Then, <code>to_json</code> is called on the <code>as_json</code> return value to get the final JSON string.</li> </ul> <p>You generally want to leave <code>to...
6,953,487
Hide Tab Header on C# TabControl
<p>I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.</p>
6,953,766
10
7
null
2011-08-05 08:31:09.053 UTC
22
2020-10-27 02:36:39.687 UTC
2015-04-24 14:06:12.407 UTC
null
4,516,316
null
860,721
null
1
54
c#|winforms|tabcontrol
54,196
<p>You can replace tabcontrol with a hand made panel that mimic like you want:</p> <pre><code>class MultiPagePanel : Panel { private int _currentPageIndex; public int CurrentPageIndex { get { return _currentPageIndex; } set { if (value &gt;= 0 &amp;&amp; value &lt; Controls.Count) { ...
57,507,832
Unable to allocate array with shape and data type
<p>I'm facing an issue with allocating huge arrays in numpy on Ubuntu 18 while not facing the same issue on MacOS.</p> <p>I am trying to allocate memory for a numpy array with shape <code>(156816, 36, 53806)</code> with </p> <pre><code>np.zeros((156816, 36, 53806), dtype='uint8') </code></pre> <p>and while I'm getti...
57,511,555
8
13
null
2019-08-15 09:48:35.317 UTC
77
2022-08-12 13:35:28.977 UTC
2019-08-15 15:29:28.85 UTC
null
1,968
null
5,123,537
null
1
188
python|numpy|data-science
620,677
<p>This is likely due to your system's <a href="https://www.kernel.org/doc/Documentation/vm/overcommit-accounting" rel="noreferrer">overcommit handling</a> mode.</p> <p>In the default mode, <code>0</code>,</p> <blockquote> <p>Heuristic overcommit handling. Obvious overcommits of address space are refused. Used for a ty...
16,028,678
AngularJS - access elements outside of ng-view
<p>I have a setup with an ng-view (an admin panel) that lets me display orders. I have a search box outside of ng-view that I would like to use to modify my json request. I've seen some posts on accessing things such as the title but was not able to get them to work - perhaps outdated.</p> <p>Main app stuff:</p> <pr...
16,030,862
3
0
null
2013-04-16 04:15:05.27 UTC
11
2014-08-18 12:56:29.113 UTC
null
null
null
null
856,498
null
1
20
javascript|angularjs
30,732
<p>If you're going to access stuff outside the <code>&lt;div ng-view&gt;&lt;/div&gt;</code>, I think a better approach would be to create a controller for the outer region as well. Then you create a service to share data between the controllers:</p> <pre class="lang-html prettyprint-override"><code>&lt;body ng-app="my...
15,923,664
Rendering different views in one action
<p>I want to have 2 kinds of views for the same posts in my rails application. For instance - in one where a logged in user can update and edit the post, and in the other any user can just view it and comment on it or select it.</p> <p>How should I go about this? Do I need a separate class? I know I need a separate vi...
15,923,870
1
0
null
2013-04-10 10:45:52.377 UTC
6
2014-08-22 08:27:39.457 UTC
2013-04-10 12:37:40.823 UTC
null
1,279,707
null
1,043,612
null
1
29
ruby-on-rails|ruby-on-rails-3|class|model-view-controller|view
18,590
<p><strong><em>1.case:</em></strong> your views are going to have similar content, but only the signed in users will have extra options like editing. </p> <p>You should use a partial view and in your main view you should write something like this:</p> <pre><code>&lt;% if signed_in? %&gt; &lt;%= render 'edit_form'...
15,746,271
Point of declaration in C++
<p>Why isn't the output <code>101</code> while I assigned the previous <code>x</code> to the new <code>x</code>?</p> <pre><code>int x = 101; { int x = x; std::cout &lt;&lt; x &lt;&lt; std::endl; } </code></pre> <p>Output (garbage):</p> <blockquote> <p>422634</p> </blockquote> <p>I thought the second <code...
15,746,272
3
2
null
2013-04-01 15:26:28.28 UTC
6
2015-01-27 07:23:48.437 UTC
2013-10-02 07:04:56.73 UTC
null
952,747
null
952,747
null
1
33
c++
2,095
<h2><em>Point of declaration</em></h2> <blockquote> <p>The point of declaration for a name is immediately after its complete declarator and before its initializer... [C++ Standard § 3.3.2/1]</p> </blockquote> <p>Compiler completes the declaration when it knows enough about declarator.</p> <p>Above code is equal ...
10,325,095
ThreeJS camera.lookAt() has no effect, is there something I'm doing wrong?
<p>In Three.js, I want a camera to be pointed at a point in 3D space.</p> <p>For this purpose, I tried using the <code>camera.lookAt</code> function like so:</p> <pre><code>camera.lookAt(new THREE.Vector3(-100,-100,0)); </code></pre> <p>However, I found out that the call has no effect whatsoever. It just does nothin...
10,337,588
6
6
null
2012-04-25 23:12:32.05 UTC
5
2022-02-23 23:54:04.727 UTC
2012-04-26 12:29:16.533 UTC
null
363,078
null
363,078
null
1
38
javascript|macos|google-chrome|3d|three.js
25,644
<p>Looking at the source code of <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/controls/TrackballControls.js"><code>THREE.TrackballControls</code></a>, I figured out that I can make the camera look where I want by setting <code>trackballControls.target</code> to the <code>THREE.Vector3</code> I wan...
25,368,337
Tuple or list when using 'in' in an 'if' clause?
<p>Which approach is better? Using a tuple, like:</p> <pre><code>if number in (1, 2): </code></pre> <p>or a list, like:</p> <pre><code>if number in [1, 2]: </code></pre> <p>Which one is recommended for such uses and why (both logical and performance wise)? </p>
25,368,371
1
7
null
2014-08-18 16:58:06.463 UTC
12
2020-05-14 04:11:02.29 UTC
2014-08-18 17:16:18 UTC
null
100,297
null
433,940
null
1
36
python|list|optimization|tuples|python-internals
2,475
<p>The CPython interpreter <em>replaces the second form with the first</em>.</p> <p>That's because loading the tuple from a constant is one operation, but the list would be 3 operations; load the two integer contents and build a new list object.</p> <p>Because you are using a list literal that isn't otherwise reachab...
40,027,974
Interesting 16x16 grid sum
<p>EDIT: Path, not line --- it can wind around and stuff. The path connects adjacent squares. You cannot go diagonally.</p> <p>Also, my proposed solution was an attempt to take every possible string of 50-digit numbers base 4 - so that, you start at each square, and move left, right, up or down --- in every possible c...
40,062,500
3
12
null
2016-10-13 18:04:16.73 UTC
10
2016-10-17 20:50:47.003 UTC
2016-10-13 23:01:18.807 UTC
null
6,392,876
null
6,392,876
null
1
5
java|algorithm|sum
7,400
<p>EDIT: Here is some sample code demonstrating some of the techniques I've outlined. It solves this problem reasonably well. While experimenting, I did find some improvements that are not in code below. Improving the speed/efficiency of this program is 100% possible, but left as an exercise to any future reader</p> <...
13,322,108
MVC Layout VS MVC Master Page
<p>I'm starting learning MVC4. I came across the two possibilities of creating a View based on a Razor template or a Master Page.</p> <p><em>I would like to understand the practical differences between the two</em>.</p> <p>For now, I can see that if I create a View using a Master Page, I can override several sections...
13,322,309
2
1
null
2012-11-10 12:35:22.997 UTC
5
2018-09-24 15:20:33.66 UTC
2014-01-13 14:59:40.557 UTC
null
2,579,850
null
471,213
null
1
19
razor|asp.net-mvc-4|master-pages
48,614
<p>You could use sections with Razor. Scott Gu blogged about them here: <a href="http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx">http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx</a></p> <p>In your Layout you could...
13,660,118
Running a flask app with nginx and gunicorn
<p>I'm new at this and have only been using nginx to serve static files. I have now installed flask and gunicorn. If I run <code>gunicorn -b 127.0.0.2:8000 hello:app</code> and then wget it from the server it works well. If I try to access it from a browser, however, it returns a 404 error (I am running this on a serve...
13,661,593
1
1
null
2012-12-01 13:54:38.393 UTC
19
2013-03-18 22:40:33.07 UTC
2013-03-18 22:40:33.07 UTC
null
1,626,395
null
1,856,869
null
1
20
python|nginx|flask|gunicorn
18,905
<p>This is how I serve my flask apps in Nginx:</p> <p>Run gunicorn daemonized using a socket:</p> <pre><code> sudo gunicorn app:app --bind unix:/tmp/gunicorn_flask.sock -w 4 -D </code></pre> <p>Related nginx config:</p> <pre><code> upstream flask_server { # swap the commented lines below to switch betwe...
13,728,041
Move markers in google map v2 android
<p>I am doing map clustering in Android Google maps v2. I just want to animate the marker from one geopoint to another. Is there a way to move a marker in Google maps v2?</p>
13,912,034
5
0
null
2012-12-05 16:39:48.337 UTC
26
2019-09-24 16:20:38.723 UTC
2014-03-01 23:41:02.063 UTC
null
2,460,971
null
1,434,806
null
1
28
android|google-maps-api-2
72,792
<p>There's one example of moving marker in google map v2 <a href="https://github.com/googlemaps/android-samples" rel="nofollow noreferrer">demo app</a> .. in the sample of the play library!! </p> <p>I have looked into that!! here the code for moving an marker : -- ></p> <pre><code> public void animateMarker(final ...
13,355,233
Python lambda closure scoping
<p>I am trying to use closures to eliminate a variable from a function signature (the application is to make writing all the functions needed for connecting Qt signals for an interface to control a largish number of parameters to the dictionary that stores the values ). </p> <p>I do not understand why the case of usi...
13,355,291
1
0
null
2012-11-13 03:34:45.557 UTC
11
2018-01-20 03:15:35.643 UTC
2018-01-20 03:15:35.643 UTC
null
380,231
null
380,231
null
1
34
python|lambda|closures
8,343
<p>The reason is that closures (lambdas or otherwise) close over names, not values. When you define <code>lambda x: test_fun(n, x)</code>, the n is not evaluated, because it is inside the function. It is evaluated when the function is <em>called</em>, at which time the value that is there is the last value from the l...
13,380,590
Is it possible to start activity through adb shell?
<p>I want to start activity through adb shell. So that I can launch a specific activity that is needed</p>
13,380,685
6
1
null
2012-11-14 14:21:39.847 UTC
41
2019-07-11 04:45:59.473 UTC
null
null
null
null
1,369,752
null
1
143
android
199,081
<p>Launch adb shell and enter the command as follows</p> <pre><code>am start -n yourpackagename/.activityname </code></pre>
13,237,623
Copy data into another table
<p>How to copy/append data from one table into another table with same schema in SQL Server?</p> <p><strong>Edit:</strong></p> <p>let's say there is a query </p> <pre><code>select * into table1 from table2 where 1=1 </code></pre> <p>which creates <code>table1</code> with the same schema as well as data as in <c...
13,237,661
11
3
null
2012-11-05 17:54:44.22 UTC
46
2021-10-19 10:07:38.597 UTC
2020-04-21 12:25:43.247 UTC
null
857,475
null
857,475
null
1
201
sql|sql-server|sql-server-2008
615,450
<p>If both tables are truly the same schema:</p> <pre><code>INSERT INTO newTable SELECT * FROM oldTable </code></pre> <p>Otherwise, you'll have to specify the column names (the column list for <code>newTable</code> is optional if you are specifying a value for all columns and selecting columns in the same order as <c...
9,128,015
Getting "Cannot read property 'nodeType' of null" when calling ko.applyBindings
<p>I have this knockout code:</p> <pre><code>function Task(data) { this.title = ko.observable(data.title); this.isDone = ko.observable(data.isDone); } function TaskListViewModel() { // Data var self = this; self.tasks = ko.observableArray([]); self.newTaskText = ko.observable(); self.incom...
9,128,306
4
2
null
2012-02-03 11:33:21.46 UTC
8
2015-03-18 10:44:14.79 UTC
2015-01-26 22:37:10.803 UTC
null
419,956
user745235
null
null
1
100
javascript|knockout.js
78,407
<p>This problem was happening because I was trying to bind an <code>HTML</code> element before it was created.</p> <p>My script was loaded on top of the <code>HTML</code> (in the head) but it needed to be loaded at the bottom of my <code>HTML</code> code (just before the closing body tag).</p> <p>Thanks for your atte...
29,722,270
Is it possible to import modules from all files in a directory, using a wildcard?
<p>With ES6, I can import several exports from a file like this:</p> <pre><code>import {ThingA, ThingB, ThingC} from 'lib/things'; </code></pre> <p>However, I like the organization of having one module per file. I end up with imports like this:</p> <pre><code>import ThingA from 'lib/things/ThingA'; import ThingB fro...
29,722,646
14
3
null
2015-04-18 20:10:41.293 UTC
80
2022-07-25 14:43:16.23 UTC
2018-08-23 02:22:09.127 UTC
null
4,642,212
null
1,253,312
null
1
340
javascript|ecmascript-6|es6-modules
330,758
<p>I don't think this is possible, but afaik the resolution of module names is up to module loaders so there might a loader implementation that does support this.</p> <p>Until then, you could use an intermediate "module file" at <code>lib/things/index.js</code> that just contains</p> <pre><code>export * from 'ThingA'...
16,117,043
Regular expression replace in C#
<p>I'm fairly new to using regular expressions, and, based on a few tutorials I've read, I'm unable to get this step in my Regex.Replace formatted properly.</p> <p>Here's the scenario I'm working on... When I pull my data from the listbox, I want to format it into a <a href="http://en.wikipedia.org/wiki/Comma-separate...
16,117,150
4
6
null
2013-04-20 05:37:39.543 UTC
6
2021-11-03 11:14:21.677 UTC
2013-10-22 17:28:29.267 UTC
null
63,550
null
1,626,856
null
1
48
c#|regex
166,996
<p>You can do it this with two replace's</p> <pre><code>//let stw be "John Smith $100,000.00 M" sb_trim = Regex.Replace(stw, @"\s+\$|\s+(?=\w+$)", ","); //sb_trim becomes "John Smith,100,000.00,M" sb_trim = Regex.Replace(sb_trim, @"(?&lt;=\d),(?=\d)|[.]0+(?=,)", ""); //sb_trim becomes "John Smith,100000,M" sw.Write...
16,521,472
Assignment operator in Go language
<p>Lately I was playing with google's new programming language <a href="http://golang.org/" rel="nofollow noreferrer">Go</a> and was wondering why the assignment operator <code>:=</code> has a <em>colon</em> in front of the equal sign <code>=</code>.</p> <p>Is there a particular reason why the authors of the language w...
16,521,530
7
2
null
2013-05-13 11:56:27.713 UTC
10
2022-05-03 20:30:22.753 UTC
2022-05-03 20:30:22.753 UTC
null
814,702
null
555,983
null
1
96
syntax|go
31,075
<p>The <code>:=</code> notation serves both as a declaration and as initialization.</p> <pre><code>foo := "bar" </code></pre> <p>is equivalent to</p> <pre><code>var foo = "bar" </code></pre> <p>Why not using only <code>foo = "bar"</code> like in any scripting language, you may ask ? Well, that's to avoid typos.</p>...
16,196,268
Where should I put my own python module so that it can be imported
<p>I have my own package in python and I am using it very often. what is the most elegant or conventional directory where i should put my package so it is going to be imported without playing with PYTHONPATH or sys.path?</p> <p>What about site-packages for example? <code>/usr/lib/python2.7/site-packages</code>.<br> Is...
16,196,400
6
3
null
2013-04-24 15:38:18.97 UTC
43
2020-07-01 10:45:18.827 UTC
2013-04-24 16:17:25.75 UTC
null
347,777
null
1,508,904
null
1
106
python|python-2.7
105,980
<p>I usually put the stuff i want to have ready to import in the user site directory:</p> <pre><code>~/.local/lib/pythonX.X/site-packages </code></pre> <p>To show the right directory for your platform, you can use <code>python -m site --user-site</code></p> <hr> <p>edit: it will show up in <code>sys.path</code> onc...
55,417,410
Kubernetes create deployment unexpected SchemaError
<p>I'm following that tutorial (<a href="https://www.baeldung.com/spring-boot-minikube" rel="noreferrer">https://www.baeldung.com/spring-boot-minikube</a>) I want to create Kubernetes deployment in yaml file (simple-crud-dpl.yaml):</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: simple-crud spec:...
55,564,032
18
4
null
2019-03-29 12:25:58.26 UTC
11
2020-05-21 21:44:44.2 UTC
2019-03-29 12:41:21.94 UTC
null
9,958,058
null
4,072,507
null
1
73
kubernetes|kubectl|kubernetes-deployment
40,297
<p>After installing kubectl with brew you should run: </p> <ol> <li><p><code>rm /usr/local/bin/kubectl</code></p></li> <li><p><code>brew link --overwrite kubernetes-cli</code></p></li> </ol> <p>And also optionally:</p> <p><code>brew link --overwrite --dry-run kubernetes-cli</code>.</p>
15,174,798
render partial on click
<p>I would like to call partials on some standard operations. I am using this method for calling the partial:</p> <pre><code> %li= link_to 'Delete Event', 'javascript:void(0);', :class =&gt; 'alert tiny button', :data =&gt; {'reveal-id' =&gt; :RevealDelete} = render 'layouts/reveal_delete', :item =&gt; event_display(@...
15,174,908
3
0
null
2013-03-02 13:02:10.953 UTC
11
2018-06-06 08:51:55.747 UTC
2018-06-06 08:51:55.747 UTC
null
314,166
null
1,448,378
null
1
8
ruby-on-rails|jquery|renderpartial
29,876
<p>You can do that with javascript like:</p> <pre><code>&lt;%= link_to "Delete", delete_content_path, :remote =&gt; true %&gt; </code></pre> <p>The action in your corresponding controller then will be this:</p> <p><strong>My Controller:</strong></p> <pre><code>def delete_content respond_to do |format| ...
24,736,427
How to get Date from a resultSet
<p>I have a problem when getting a Date object from a ResultSet. In database it has a value (for example 2014-08-01) and after getting it from resultSet, it has another value (2014-08-31). I know that ResultSet's getDate method returns java.sql.Date, but I tried a few solutions, such as:<br/><br/> <code>Date date=n...
24,737,131
2
5
null
2014-07-14 12:20:43.893 UTC
2
2014-07-14 13:08:35.957 UTC
null
null
null
null
3,836,820
null
1
3
java|mysql|sql|jdbc
47,105
<p>In your case you were not providing the columnName of the Date field to be retrieved.</p> <p>This should do the job</p> <pre><code> while (rs.next()) { java.sql.Time dbSqlTime = rs.getTime("columnName"); java.sql.Date dbSqlDate = rs.getDate("columnName"); java.sql.Timestamp dbSqlTimestamp = rs.getTimes...
55,563,598
Why is this code using strlen heavily 6.5x slower with GCC optimizations enabled?
<p>I wanted to benchmark <code>glibc</code>'s <code>strlen</code> function for some reason and found out it apparently performs <em>much</em> slower with optimizations enabled in GCC and I have no idea why.</p> <p>Here's my code:</p> <pre class="lang-c prettyprint-override"><code>#include &lt;time.h&gt; #include &lt;...
55,563,916
2
10
null
2019-04-07 20:54:34.727 UTC
11
2022-05-31 08:21:36.43 UTC
2021-03-12 08:01:31.497 UTC
null
224,132
null
4,924,866
null
1
70
c|performance|gcc|glibc
5,508
<p>Testing your code on <a href="https://godbolt.org/z/Ej4woo" rel="nofollow noreferrer">Godbolt's Compiler Explorer</a> provides this explanation:</p> <ul> <li>at <code>-O0</code> or without optimisations, the generated code calls the C library function <code>strlen</code>;</li> <li>at <code>-O1</code> the generated c...
17,247,189
Spring @RequestBody containing a list of different types (but same interface)
<p>Let's say that I have a domain class :</p> <pre><code> public class Zoo{ private List&lt;Animal&gt; animals; .... </code></pre> <p>where an Animal is an interface with different implementations (Cat,Dog). Let's say that I want to be able to save a Zoo object :</p> <pre><code> @RequestMapping...
17,247,382
2
1
null
2013-06-22 04:02:09.073 UTC
9
2019-02-17 11:21:47.96 UTC
null
null
null
null
1,936,950
null
1
28
java|json|spring|spring-mvc
15,139
<p>You should use the Jackson annotations <a href="http://jackson.codehaus.org/1.9.0/javadoc/org/codehaus/jackson/annotate/JsonTypeInfo.html" rel="noreferrer"><code>@JsonTypeInfo</code></a> and <a href="http://jackson.codehaus.org/1.5.2/javadoc/org/codehaus/jackson/annotate/JsonSubTypes.html" rel="noreferrer"><code>@Js...
17,199,113
psycopg2 leaking memory after large query
<p>I'm running a large query in a python script against my postgres database using psycopg2 (I upgraded to version 2.5). After the query is finished, I close the cursor and connection, and even run gc, but the process still consumes a ton of memory (7.3gb to be exact). Am I missing a cleanup step?</p> <pre><code>impor...
27,940,340
3
0
null
2013-06-19 18:55:55.513 UTC
15
2016-01-30 14:46:07.64 UTC
null
null
null
null
1,026,542
null
1
32
python|postgresql|psycopg2
18,825
<p>I ran into a similar problem and after a couple of hours of blood, sweat and tears, found the answer simply requires the addition of one parameter.</p> <p>Instead of</p> <pre><code>cursor = conn.cursor() </code></pre> <p>write</p> <pre><code>cursor = conn.cursor(name="my_cursor_name") </code></pre> <p>or simple...
17,274,329
svn 1.7.8 database is locked, cannot release
<p>when I run: </p> <pre><code>svn cleanup </code></pre> <p>I get the error message:</p> <pre><code>svn: E200033: database is locked, executing statement 'RELEASE s0' </code></pre> <p>or any other command to change DB, e.g. <code>commit</code>, <code>update</code> etc.</p> <p>This is on linux server, the directo...
17,346,612
14
4
null
2013-06-24 11:25:56.637 UTC
19
2020-09-15 08:55:22.107 UTC
2013-06-24 12:05:13.937 UTC
null
398,670
null
21,274
null
1
56
svn
70,982
<p>This helped me solve the problem (subversion 1.7.10):</p> <pre><code>$ cd /my/repository/.svn $ mv wc.db wc.db.old $ sqlite3 wc.db.old sqlite&gt; .backup main wc.db sqlite&gt; .exit </code></pre> <p>After making sure it works, you can remove wc.db.old.</p> <p>See also: <a href="http://technosophos.com/content/sql...
30,689,526
How to call python script from NodeJs
<p>I need to call this python script in NodeJs.</p> <p><strong>Read.py</strong></p> <pre><code>#!/usr/bin/env python # -*- coding: utf8 -*- import RPi.GPIO as GPIO import MFRC522 import signal continue_reading = True # Capture SIGINT for cleanup when the script is aborted def end_read(signal,frame): global con...
30,689,597
6
2
null
2015-06-07 02:34:35.04 UTC
13
2021-06-19 10:13:35.013 UTC
null
null
null
null
1,574,779
null
1
17
javascript|python|node.js|python-2.7|raspberry-pi
62,416
<p>There are multiple ways of doing this. </p> <ul> <li>first way is by doing <code>npm install python-shell</code> </li> </ul> <p>and here's the code</p> <pre><code>var PythonShell = require('python-shell'); //you can use error handling to see if there are any errors PythonShell.run('my_script.py', options, functio...
18,290,863
Right approach to building SAAS in Laravel 4
<p>Ok, so about a year ago I wrote a web app that helps organize appointments for my dads company. He now "couldn't do business without it". I have decided that I want to build a SAAS subscription model out of it and open it up to the public.</p> <p>It's currently built on codeigniter and php which I do not think is a...
18,293,859
2
0
null
2013-08-17 16:14:37.33 UTC
13
2013-08-18 16:06:10.903 UTC
2013-08-17 16:22:44.177 UTC
null
1,317,935
user1157393
null
null
1
14
database|laravel|laravel-4|saas|stripe-payments
5,349
<p>You are in for a lot of reading and a ton of work!</p> <p>First of all, let's completely ignore the billing aspect of this for now — at the end of the day that portion of the application is really fairly trivial. Take a page out of <a href="http://37signals.com/rework">37signals <em>Rework</em></a> (page 93 and 94)...
12,550,184
Throw a format exception C#
<p>I'm trying to throw a format exception in the instance someone tries to enter a non-integer character when prompted for their age. </p> <pre><code> Console.WriteLine("Your age:"); age = Int32.Parse(Console.ReadLine()); </code></pre> <p>I'm unfamiliar with C# language and could use help in ...
12,550,197
4
4
null
2012-09-23 06:19:08.937 UTC
0
2021-09-16 16:28:42.81 UTC
null
null
null
null
1,513,637
null
1
5
c#|try-catch|formatexception
76,548
<p>That code will already throw an <code>FormatException</code>. If you mean you want to <em>catch</em> it, you could write:</p> <pre><code>Console.WriteLine("Your age:"); string line = Console.ReadLine(); try { age = Int32.Parse(line); } catch (FormatException) { Console.WriteLine("{0} is not an integer", lin...
32,062,894
Take advantage of ARM unaligned memory access while writing clean C code
<p>It used to be that ARM processors were unable to properly handle unaligned memory access (ARMv5 and below). Something like <code>u32 var32 = *(u32*)ptr;</code> would just fail (raise exception) if <code>ptr</code> was not properly aligned on 4-bytes.</p> <p>Writing such a statement would work fine for x86/x64 thoug...
32,095,106
2
19
null
2015-08-18 03:09:44.17 UTC
14
2017-03-26 20:06:48.263 UTC
2015-08-18 19:04:23.727 UTC
null
646,947
null
646,947
null
1
33
c|arm|memory-alignment
12,864
<p>OK, the situation is more confusing than one would like. So, in an effort to clarify, here are the findings on this journey : </p> <h2><em>accessing unaligned memory</em></h2> <ol> <li>The only portable C standard solution to access unaligned memory is the <code>memcpy</code> one. I was hoping to get another one t...
5,583,401
Serialize datetime to JSON
<p>How do I get DateTimeField from the Mysql database in Django in JSON format? I got an error when I executed the code <code>Date.time cannot be serialized in json</code> (data holds a lot of values):</p> <pre class="lang-py prettyprint-override"><code>data = json.dumps(data) </code></pre> <p>But this was fixed by add...
5,781,657
3
0
null
2011-04-07 15:14:48.85 UTC
9
2021-09-25 22:20:09.193 UTC
2021-09-25 22:20:09.193 UTC
null
11,573,842
null
532,312
null
1
25
python|django
29,250
<p><a href="https://docs.djangoproject.com/en/stable/topics/serialization/#djangojsonencoder" rel="noreferrer"><strong>DjangoJSONEncoder</strong></a> solved my problem.</p> <pre><code>import json from django.core.serializers.json import DjangoJSONEncoder data = json.dumps(data, cls=DjangoJSONEncoder) </code></pre>
5,385,039
Naming convention to differentiate partial views from normal views
<p>Is there any unofficial standard naming convention for partial views? I've seen someone suggested prefixing with "_", others postfixing with "Partial", I know the question is subjective, but since there is no official guideline, I'd like to know what the majority here uses for naming their partial views. Perhaps the...
5,398,840
3
6
null
2011-03-21 23:39:23.207 UTC
4
2011-03-22 22:52:36.307 UTC
2011-03-22 02:14:33.157 UTC
null
8,411
null
8,411
null
1
45
asp.net-mvc|naming-conventions|razor
14,279
<p>If you look at WebMatrix, the convention is to prefix Razor files that are not meant to be served directly with a leading underscore. That includes partials and layout pages. Then if you look at <a href="http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/" r...
4,854,148
PHP & MySql check if table is empty
<p>I'm a bit of a noob- and I'm having a hard time...</p> <p>I need a bit of of code that searches a db table to find the row that matches the $id variable. There's a field in that table 'description' that I need to grab. If it's null, I need to show one message, if not another. Here's the code I have (I know I need t...
4,854,174
4
4
null
2011-01-31 17:42:40.42 UTC
2
2012-03-31 13:11:19.38 UTC
2011-01-31 17:53:58.26 UTC
null
300,897
null
517,593
null
1
6
php|mysql|if-statement
50,741
<p><code>mysqli_fetch_array</code> will fetch a row regardless of if the columns in that row are null. You want to be checking if <code>$row['description']</code> is set instead of if <code>$row</code> is set:</p> <pre><code>$query = "SELECT description FROM posts WHERE id = $id"; $result = mysqli_query($dbc, $query);...
9,244,824
How to remove &quot; from my Json in javascript?
<p>I am trying to inject json into my backbone.js app. My json has <code>&amp;quot;</code> for every quote.</p> <p>Is there a way for me to remove this? <br>I've provided a sample below:</p> <pre><code>[{&amp;quot;Id&amp;quot;:1,&amp;quot;Name&amp;quot;:&amp;quot;Name}] </code></pre>
9,244,845
9
3
null
2012-02-11 23:03:53.873 UTC
15
2021-10-24 13:11:37.12 UTC
2012-02-11 23:06:10.087 UTC
null
138,475
null
1,074,003
null
1
102
javascript
146,377
<p>Presumably you have it in a variable and are using <code>JSON.parse(data);</code>. In which case, use:</p> <pre><code>JSON.parse(data.replace(/&amp;quot;/g,'"')); </code></pre> <p>You might want to fix your JSON-writing script though, because <code>&amp;quot;</code> is not valid in a JSON object.</p>
18,223,402
How to start GUI from command line in Android-x86
<p>I managed to get Android-x86 running in VMware player, but if I need to go to the command line by pressing Alt+F1 I cannot go back to the GUI. How do I restart the GUI from the command line?</p>
18,225,031
4
0
null
2013-08-14 04:46:26.593 UTC
9
2022-04-04 15:09:36.953 UTC
2019-04-20 11:52:24.947 UTC
null
472,495
null
1,693,203
null
1
28
android|android-x86
101,627
<p>To go back to GUI try use Alt+F7</p>
19,929,186
Combobox null in if statement
<p>I am trying to code an if statement where if a certain combobox is null, then it runs a certain part of code if it has data in it then it runs another. I wrote up this:</p> <pre><code>Private Sub ProjectAddSetDateAutoBtn_Click() If ProjectAddAllDueDateAutoCmBx = Null Then 'Code1 Msgbox("ComboBox Is Null") Else 'Cod...
19,929,496
5
3
null
2013-11-12 12:27:53.593 UTC
1
2013-11-12 13:40:18.803 UTC
2013-11-12 12:32:57.003 UTC
null
2,915,607
null
2,915,607
null
1
13
ms-access|vba|ms-access-2013
66,678
<p><a href="https://stackoverflow.com/a/13869017/77335">Nothing is ever equal to Null, not even another Null</a>.</p> <p>Use <a href="http://office.microsoft.com/en-us/access-help/isnull-function-HA001228867.aspx" rel="noreferrer">IsNull()</a> to check whether the combo box is Null.</p> <pre class="lang-vb prettyprin...
20,310,209
How to perform Stream functions on an Iterable?
<p>In Java 8, the <code>Stream</code> class does not have any method to wrap a an <code>Iterable</code>.</p> <p>Instead, I am obtaining the <code>Spliterator</code> from the <code>Iterable</code> and then obtaining a <code>Stream</code> from <code>StreamSupport</code> like this:</p> <pre><code>boolean parallel = true...
22,870,302
3
3
null
2013-12-01 08:24:18.89 UTC
5
2015-02-17 16:41:51.64 UTC
2015-02-17 16:41:51.64 UTC
null
1,441,122
null
1,584,255
null
1
32
java|java-8|java-stream|iterable|spliterator
14,265
<p>My similar question got marked as duplicate, but here is the helper methods I've used to avoid some of the boilerplate:</p> <pre><code>public static &lt;T&gt; Stream&lt;T&gt; stream(Iterable&lt;T&gt; in) { return StreamSupport.stream(in.spliterator(), false); } public static &lt;T&gt; Stream&lt;T&gt; parallelS...
14,931,510
Android - Gesture Detection (Swipe up/down) on particular view
<p>I am trying to implement the OnGestureListener in Android. <br/>I have three TextViews in my layout. <br/>What i am trying to achieve is to set Gesture Listener for two of the textViews .<br/> Here is the <strong>layout</strong> - <br/></p> <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.c...
14,931,627
3
0
null
2013-02-18 07:42:22.037 UTC
5
2020-03-05 08:26:51.6 UTC
2020-03-05 08:26:51.6 UTC
null
3,891,036
null
1,997,711
null
1
28
android|swipe|gesture-recognition|onfling
52,262
<p>Do this in your <code>onCreate</code> method.</p> <pre><code>findViewById(R.id.tvOne).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event){ return gestureScanner.onTouchEvent(event); } }); </code></pre>
14,993,855
Android ADB device offline, can't issue commands
<p>I can't connect to my device anymore using <a href="http://en.wikipedia.org/wiki/Android_Debug_Bridge" rel="noreferrer">ADB</a> through the command line or in <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29" rel="noreferrer">Eclipse</a>.</p> <p>Running the command</p> <pre><code>adb devices </code></p...
15,000,565
66
13
2014-01-10 08:07:56.2 UTC
2013-02-21 03:01:29.557 UTC
64
2022-06-16 22:52:07.617 UTC
2014-02-20 14:21:07.53 UTC
null
63,550
null
461,631
null
1
361
android|adb|android-2.2-froyo
834,083
<p>I just got the same problem today after my <a href="https://en.wikipedia.org/wiki/Nexus_7_%282013_version%29">Nexus 7</a> and <a href="https://en.wikipedia.org/wiki/Galaxy_Nexus">Galaxy Nexus</a> were updated to Android 4.2.2.</p> <p>The thing that fixed it for me was to upgrade the SDK platform-tools to r16.0.1. F...
43,669,773
Angular 2: formGroup expects a FormGroup instance. Please pass one in
<p>I am creating a form in Angular 2. My goal is to get data from the API and pass it into the form for editing purposes. However, I am running into this error:</p> <blockquote> <p>EXCEPTION: Uncaught (in promise): Error: Error in ./EditPatientComponent class EditPatientComponent - inline template:1:10 caused by: fo...
43,669,848
5
3
null
2017-04-27 23:55:36.387 UTC
10
2020-12-21 09:31:30.597 UTC
null
null
null
null
5,711,574
null
1
60
forms|angular
107,148
<p>Your <code>patientForm</code> is <code>undefined</code> until the <code>patient</code> in the subscription is populated. As such, you're trying to bind to a value that doesn't exist in the template at the time the template is parsed.</p> <p>Add an <code>*ngIf</code> to render the form only when patient is truthy, o...
28,256,923
Import cycle not allowed
<p>I have a problem with</p> <blockquote> <p>import cycle not allowed</p> </blockquote> <p>It appears when I am trying to test my controller. Here is the output:</p> <pre><code>can't load package: import cycle not allowed package project/controllers/account imports project/controllers/base imports project/compo...
28,258,647
8
2
null
2015-01-31 21:50:08.067 UTC
33
2022-09-02 06:18:32.323 UTC
2021-06-08 13:03:22.83 UTC
null
321,731
null
1,743,843
null
1
204
go
220,645
<p>Here is an illustration of your first import cycle problem.</p> <pre><code> project/controllers/account ^ \ / \ / \ / \/ ...
7,958,816
How to get multiple rows into one line as a string?
<p>I have two tables "one to many":</p> <p>Table1</p> <pre><code>ID Name 1 Abe 2 David 3 Orly </code></pre> <p>Table2</p> <pre><code>ID email 1 a@zz.com 1 ab@zz.com 1 abe@zz.com 2 dav@zz.com 2 d@zz.com 3 orly@zz.com 3 o@zz.com </code></pre> <p>I need an output like thi...
7,959,662
2
3
null
2011-10-31 19:41:31.277 UTC
9
2013-05-28 08:32:28.01 UTC
2011-11-01 06:56:58.217 UTC
null
1,010,730
null
1,010,730
null
1
14
sql|sql-server
39,445
<p>One of the neatest ways to achieve this is to combine For XML Path and STUFF as follows:</p> <pre><code>SELECT ID, Name, Emails = STUFF(( SELECT ', ' + Email FROM Table2 WHERE Table2.ID = Table1.ID FOR XML PATH ('')),1,2,'') FROM Table1 </code></pre>
19,397,873
UIImagePickerController bug
<p>I think I found a bug in latest iOS 7 by running an app with Base SDK set to iOS 6.1 (possibly even lower versions too, haven't tested that out yet)</p> <p>I have this image in my photo library: <a href="https://i.imgur.com/7KUIGLt.jpg" rel="noreferrer">http://i.imgur.com/7KUIGLt.jpg</a></p> <p>I present a UIImage...
19,479,635
4
9
null
2013-10-16 07:49:48.013 UTC
8
2014-05-18 09:34:18.923 UTC
2013-12-18 08:18:41.53 UTC
null
1,578,927
null
903,643
null
1
25
ios|objective-c|cocoa-touch|ios7|uiimagepickercontroller
7,363
<p>Your question is "What's causing this?" So I'll focus on that instead of giving a workaround. This is definitely a bug in iOS 7 dealing with edited images in lower base SDKs. We can also rule out that XCode 5 &amp; Base SDK 6.1 causing this because I'm getting the same issue with XCode 4.6.3 &amp; 6.1 SDK running on...
8,613,535
Does Java have 'Debug' and 'Release' build mode like C#?
<p>In C#, we have 2 modes to build projects : <code>Debug</code> and <code>Release</code>, I wonder if Java has the same thing. I am using IntelliJ IDEA as Java IDE and so far I haven't seen anywhere to configure a build mode like in VS IDE.</p>
8,613,589
3
3
null
2011-12-23 07:53:35.623 UTC
12
2011-12-25 10:34:44.077 UTC
null
null
null
null
458,773
null
1
47
c#|java|.net|debugging|release
25,638
<pre><code>javac -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info </code></pre> <p>You can choose to include debug symbols in the compiled classes (this is the default) or to not do so. There...
8,537,516
How to use an user variables in MySQL LIKE clause?
<p>I am trying to setup a few simple SQL scripts to help with some short term DB administration. As such, I'm setting up variables to try to make it easier to reuse these scripts.</p> <p>The problem I'm having is specifically with the LIKE clause.</p> <pre><code>SET @email = 'test@test.com'; SELECT email from `user`...
8,537,547
7
4
null
2011-12-16 16:59:26.957 UTC
11
2022-01-30 06:45:24.777 UTC
2011-12-20 17:37:03.467 UTC
null
962,289
null
962,289
null
1
59
mysql|sql|database
93,642
<pre><code>SET @email = 'test@test.com'; SELECT email from `user` WHERE email LIKE CONCAT('%', @email, '%'); </code></pre>
31,098,831
EXC_BAD_ACCESS tapping uisearchbar three times
<p>I am trying to implement a search bar in a UICollectionView as a UICollectionViewReusableView</p> <p>This way I am not using a UISearchController but I am changing the datasource of the collectionview</p> <p>In my custom layout I am adding the searchbar this way:</p> <pre><code>override func prepareLayout() { ...
36,830,488
2
29
null
2015-06-28 10:37:17.023 UTC
5
2016-04-25 00:32:06.92 UTC
2015-09-30 18:26:14.017 UTC
null
3,515,302
null
3,515,302
null
1
32
ios|swift|exc-bad-access|uiresponder
1,428
<p>I came up with a workaround for this in iOS 8. I discovered that the crash only occurred if the <code>kind</code> string of my supplementary view was a Swift string. There was no crash when I used an Objective-C string bridged to Swift. I tried the obvious idea of creating a <code>NSString</code> explicitly in Swift...
5,169,471
Is there an "after submit" jQuery option?
<p>I have a form that uploads a file and targets an iframe on the page. When the user clicks submit, I want the file contents to "clear" out.</p> <p>I tried this</p> <pre><code>$('#imageaddform').submit(function(){ $('#imagefile').val(''); }); </code></pre> <p>But it clears the form before the submit, so nothing...
5,169,572
4
2
null
2011-03-02 15:12:33.403 UTC
7
2018-09-25 14:32:50.51 UTC
2018-09-25 14:32:50.51 UTC
null
814,702
null
456,782
null
1
48
javascript|jquery|forms|form-submit
87,621
<p>If you have no other handlers bound, you could do something like this:</p> <pre><code>$('#imageaddform').submit(function(e) { e.preventDefault(); // don't submit multiple times this.submit(); // use the native submit method of the form element $('#imagefile').val(''); // blank the input }); </code></pre...
5,483,423
How to write unicode strings into a file?
<p>I am using python 2.6.5 I want to write some japanese characters to a file. I am getting this error &amp; I don't know how to change the encoding.</p> <pre><code>Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01) [GCC 4.3.4 20090804 (release) 1] on cygwin &gt;&gt;&gt; s = u'\u5E73\u621015' &gt;&gt;&gt; with open("yop...
5,483,534
4
0
null
2011-03-30 07:48:40.393 UTC
21
2015-03-09 03:59:33.033 UTC
null
null
null
null
450,278
null
1
54
python|unicode
77,623
<p>you're going to have to 'encode' the unicode string.</p> <pre><code>s = u'\u5E73\u621015' with open("yop", "wb") as f: f.write(s.encode("UTF-8")) </code></pre> <p>try this out for a bit of a friendly look at unicode and python: <a href="http://farmdev.com/talks/unicode/" rel="noreferrer">http://farmdev.com/talk...
5,453,708
Android how to use Environment.getExternalStorageDirectory()
<p>How can i use <code>Environment.getExternalStorageDirectory()</code> to read a a stored image from the SD card or is there a better way to do it?</p>
5,453,753
4
0
null
2011-03-28 01:06:36.84 UTC
31
2020-06-16 19:36:52.333 UTC
2011-06-08 11:58:30.727 UTC
null
55,093
null
650,269
null
1
58
android|sd-card
184,948
<pre><code>Environment.getExternalStorageDirectory().getAbsolutePath() </code></pre> <p>Gives you the full path the SDCard. You can then do normal File I/O operations using standard Java.</p> <p>Here's a simple example for writing a file:</p> <pre><code>String baseDir = Environment.getExternalStorageDirectory().getA...
4,920,072
keytool -genkey error: Keystore file does not exist
<p>I try to create a new self certified keystore file</p> <p>The command I use is:</p> <pre><code>keytool -genkey -selfcert -dname "cn=My Name, ou=Orga unit" -alias selfcertified -keypass somepass -keystore keystore.jks -storepass anotherpass -validity 365 </code></pre> <p>but I always get this annoying error:</p> ...
4,920,659
5
0
null
2011-02-07 10:14:19.973 UTC
7
2019-10-21 11:22:10.083 UTC
2016-01-18 12:35:42.113 UTC
null
3,885,376
null
606,235
null
1
16
java|certificate|keystore|keytool
88,673
<p>Generating a key pair (and a new keystore) has to be done as a separate operation to creating a self-signed certificate for that key.</p> <p>i.e.</p> <pre><code>keytool -genkey -alias myKey -keystore store.jks keytool -selfcert -alias myKey -keystore store.jks </code></pre>
5,490,025
C# reflection and finding all references
<p>Given a DLL file, I'd like to be able to find all the calls to a method within that DLL file. How can I do this?</p> <p>Essentially, how can I do programmatically what Visual Studio already does?</p> <p>I don't want to use a tool like <a href="http://en.wikipedia.org/wiki/.NET_Reflector" rel="noreferrer">.NET Refl...
5,490,526
6
3
null
2011-03-30 17:44:32.23 UTC
20
2022-05-31 13:44:45.867 UTC
2013-09-17 19:12:56.09 UTC
null
63,550
null
420,667
null
1
41
c#|reflection|reference|reflector
35,355
<p>To find out where a method <code>MyClass.Foo()</code> is used, you have to analyse all classes of all assemblies that have a reference to the assembly that contains <code>MyClass</code>. I wrote a simple proof of concept of how this code can look like. In my example I used <a href="http://evain.net/blog/articles/200...
4,897,149
How to convert Session Variable to Integer Type in C#
<p>I am using C#</p> <p>I am trying to check whether my login attempt is not more than 3, I mean with the below condition:</p> <pre><code>if (((int)Session["LoginAttempt"]) != 3) { } </code></pre> <p>In Login failed condition I am doing increment like below:</p> <pre><code>Session["LoginAttempt"] = ((int) Session[...
4,897,343
8
0
null
2011-02-04 10:51:58.747 UTC
2
2019-10-09 14:15:17.977 UTC
2019-10-09 14:15:17.977 UTC
null
436,341
null
30,394
null
1
13
c#
63,784
<p>Sorry Guys,</p> <p>I just changed the integer converting code from</p> <pre><code>((int) Session["LoginAttempt"]) </code></pre> <p>to</p> <pre><code>Convert.ToInt32(Session["LoginAttempt"]) + 1; </code></pre> <p>and now it is working fine for me, please suggest incase of any issues in it.</p> <p>Thanks!</p>