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
31,034,847
How to find all rows with a NULL value in any column using PostgreSQL
<p>There are many <em>slightly similar</em> questions, but none solve precisely this problem. "<a href="https://stackoverflow.com/questions/14488859/find-all-rows-with-null-values-in-any-column">Find All Rows With Null Value(s) in Any Column</a>" is the closest one I could find and offers an answer for SQL Server, but...
31,035,052
1
2
null
2015-06-24 19:01:56.413 UTC
13
2017-06-09 23:53:58.963 UTC
2017-06-09 23:53:58.963 UTC
null
128,421
null
241,142
null
1
32
sql|postgresql
38,043
<p>You can use <code>NOT(&lt;table&gt; IS NOT NULL)</code>.</p> <p>From <a href="http://www.postgresql.org/docs/9.4/static/functions-comparison.html" rel="noreferrer">the documentation</a> :</p> <blockquote> <p>If the expression is row-valued, then IS NULL is true when the row expression itself is null or when al...
13,350,036
C# Charts add multiple series from datatable
<p>I retrieve several datatables from my DB, which vary in size. This one of 2 is just an example.</p> <p>See the structure here! <br><img src="https://i.stack.imgur.com/iHIBF.png" alt="enter image description here"> <br> I managed to create the 2 different series and have them show up on the legend. </p> <p>My quest...
13,352,323
3
2
null
2012-11-12 19:18:15.287 UTC
2
2020-10-25 15:55:53.723 UTC
2017-08-22 15:04:31.6 UTC
null
1,460,225
null
1,128,380
null
1
3
c#|charts
69,375
<p>I managed to do it myself, but you Gregor Primar pushed me in the right direction!</p> <p>What was important was that you set the valuetype for the X and Y-axis. As decimal type was not an option I used auto as type.</p> <pre><code>Chart1.DataSource = dt; int amountofrows = Convert.ToInt32(dt.Rows[0]["antal"].ToS...
37,703,609
Using python Logging with AWS Lambda
<p>As the AWS documentation suggests:</p> <pre><code>import logging logger = logging.getLogger() logger.setLevel(logging.INFO) def my_logging_handler(event, context): logger.info('got event{}'.format(event)) logger.error('something went wrong') </code></pre> <p>Now I made:</p> <pre><code>import logging loggi...
56,579,088
9
4
null
2016-06-08 13:15:55.5 UTC
20
2022-04-29 08:12:38.297 UTC
2016-06-08 15:07:46.023 UTC
null
312,444
null
312,444
null
1
113
python|amazon-web-services|logging|aws-lambda
76,941
<p>The reason that logging does not seem to work is because the AWS Lambda Python runtime <a href="https://gist.github.com/alanjds/000b15f7dcd43d7646aab34fcd3cef8c#file-awslambda-bootstrap-py-L463" rel="noreferrer">pre-configures a logging handler</a> that, depending on the version of the runtime selected, might modify...
21,216,228
PHP Manager for IIS fails to install
<p>I am trying to install PHP on IIS 8. </p> <p>Every time I start the PHP installation, PHP installs but I get the follow error:</p> <p><img src="https://i.stack.imgur.com/kUiR4.png" alt="enter image description here"></p>
32,302,012
4
4
null
2014-01-19 11:38:01.877 UTC
15
2019-07-01 10:04:29.123 UTC
2018-08-02 15:33:11.077 UTC
null
11,182
null
3,018,332
null
1
59
php|windows-10|web-platform-installer|php-manager
60,432
<p>As Abhi says: fire up regedit.exe and change the decimal value of <code>Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\MajorVersion</code> from 10 (as set by Windows 10) to e.g. 8. Installer should work now. Afterwards, you can set the value back to 10 (or whatever value your Windows ...
20,889,126
Bootstrap: adding gaps between divs
<p>If my page uses the Bootstrap class <code>row</code>, <code>col-md-x</code> and such to arrange the content, what would be the proper way to create a distance between each div containing a whole element semantically speaking?</p> <p>I am adding a div with a padding between the divs to simulate the gap, is this a go...
20,889,189
5
5
null
2014-01-02 18:15:27.85 UTC
6
2020-08-27 16:46:49.987 UTC
null
null
null
null
3,120,489
null
1
61
html|css|twitter-bootstrap
190,428
<p>Adding a padding between the divs to simulate a gap might be a hack, but why not use something Bootstrap provides. It's called offsets. But again, you can define a class in your <strong>custom.css</strong> (you shouldn't edit the core stylesheet anyway) file and add something like <code>.gap</code>. However, <code>....
20,909,492
MySQL not showing databases created in phpMyAdmin
<p>I'm trying to build a database for my server in phpmyadmin but when I finish building it I can't access it using PHP and it won't show when I list the databases in MySQL. But when I create a database in mySql it shows up in phpmyadmin. Also I'm running phpmyadmin version 4.0.3, and theres a statement at the bottom o...
20,910,882
4
7
null
2014-01-03 17:37:49.803 UTC
1
2022-05-07 07:01:41.133 UTC
null
null
null
null
1,109,115
null
1
6
php|sql|ubuntu|amazon-ec2|phpmyadmin
38,385
<p>This sounds like a permissions issue. I'd guess that your phpMyAdmin is connecting to MySQL as root (or another user with the superuser privilege) and can therefore see all databases. Your app is probably connected using a different, lower privileged user.</p> <p>Try running <code>select user();</code> from your ...
44,217,376
Fetch API not working with localhost/127.0.0.1
<p>Just as background, I have a react app sitting on a remote EC2 Ubuntu instance. The same server also runs a Go app listening on port 8080 (port has been opened to everyone from the Security settings).</p> <p>I am trying to make a request with Fetch API, from the React app, as follows:</p> <pre><code>var bearer = '...
44,221,708
3
2
null
2017-05-27 13:22:49.077 UTC
9
2020-10-30 06:46:38.26 UTC
2020-01-12 04:06:15.267 UTC
null
441,757
null
7,119,728
null
1
15
reactjs|amazon-ec2|fetch
73,886
<p>When you write <code>localhost</code> it calls your (localhost) machine (on which the browser is present) because the <code>js</code> code is running in your browser. </p> <p>You should create a domain/sub-domain for your API endpoint and use it instead of localhost or continue to use the hard-coded IP address.</p>...
63,001,988
how to remove background of images in python
<p>I have a dataset that contains full width human images I want to remove all the backgrounds in those Images and just leave the full width person,</p> <p>my questions:</p> <p>is there any python code that does that ?</p> <p>and do I need to specify each time the coordinate of the person object?</p> <p><a href="https:...
63,003,020
1
1
null
2020-07-20 18:49:11.457 UTC
8
2021-06-06 13:19:21.42 UTC
null
null
null
null
13,604,953
null
1
7
python|image|opencv|image-processing|background
40,151
<p>Here is one way using Python/OpenCV.</p> <ul> <li>Read the input</li> <li>Convert to gray</li> <li>Threshold and invert as a mask</li> <li>Optionally apply morphology to clean up any extraneous spots</li> <li>Anti-alias the edges</li> <li>Convert a copy of the input to BGRA and insert the mask as the alpha channel</...
2,323,505
How to keep track of model history with mapping table in Ruby on Rails?
<h2>dream</h2> <p>I'd like to keep record of when a user changes their address.</p> <p>This way, when an order is placed, it will always be able to reference the user address that was used at the time of order placement.</p> <h2>possible schema</h2> <pre><code>users ( id username email ... ) user_addresses ( ...
2,324,231
5
2
null
2010-02-24 03:33:02.467 UTC
9
2020-12-15 15:30:57.29 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
184,600
null
1
11
ruby-on-rails|activerecord|schema
14,326
<p>Use the <a href="http://github.com/laserlemon/vestal_versions" rel="noreferrer">Vestal versions plugin</a> for this:</p> <p>Refer to <a href="http://railscasts.com/episodes/177-model-versioning" rel="noreferrer">this</a> screen cast for more details.</p> <pre><code>class Address &lt; ActiveRecord::Base belongs_t...
2,185,846
Why I can't purchase my own application on the Android market?
<p>I just uploaded my application in the market, but I'm not able to purchase it (it's a pay app).</p> <p>I saw <a href="http://market.android.com/support/bin/answer.py?hl=en&amp;answer=141659" rel="nofollow noreferrer">here</a> that it seems to be <em>made by design</em>, but then why the error message is <code>Serve...
2,185,905
5
0
null
2010-02-02 16:45:51.613 UTC
1
2014-01-08 11:32:34.523 UTC
2014-01-08 11:32:34.523 UTC
null
309,086
null
231,417
null
1
28
android|google-play
7,173
<p>Do you have an Android Developer Phone? If so, you can't purchase your own app by design. Since ADPs are unlocked, there's nothing preventing an ADP from easily pirating any app it downloads, so they are purposely cut off from downloading paid apps.</p>
1,656,727
How to generate a PHP soap client code?
<p>Is there a way to generate a PHP Soap Client from a WSDL file?</p> <p>I mean something like <code>wsdl.exe</code> or <code>svcutil.exe</code> in .net, that generates code for a class that can be the client of a service, not something like:</p> <pre><code>$WSDL = new SOAP_WSDL($wsdl_url); $client = $WSDL-&gt...
1,656,763
6
0
null
2009-11-01 09:25:45.54 UTC
6
2016-03-01 00:45:00.243 UTC
2013-01-02 18:43:47.24 UTC
null
367,456
null
19,956
null
1
12
php|soap|wsdl|soap-client
48,580
<p>You can use the method [<code>generateProxyCode</code>] provided in the package SOAP_WSDL (<a href="http://pear.php.net/reference/SOAP-0.9.4/SOAP/SOAP_WSDL.html#methodgenerateProxyCode" rel="nofollow noreferrer">http://pear.php.net/reference/SOAP-0.9.4/SOAP/SOAP_WSDL.html#methodgenerateProxyCode</a>) method instead ...
1,587,407
Iphone device token - NSData or NSString
<p>I am receiving iPhone device token in the form of <code>NSData</code> object. When I tested my notifications script function, I have only copied that object from log and the notifications went fine. However when I try now to automatically do it, I am sending the device token as ASCII encoded string in the form of v...
1,587,441
6
2
null
2009-10-19 07:44:33.27 UTC
10
2016-12-06 16:07:36.763 UTC
2013-06-03 07:16:24.647 UTC
null
1,571,232
null
115,873
null
1
33
iphone|device-driver|token
28,565
<p>Ok, I found a solution. If anyone has the same problem, forget about ASCII encoding, just make the string with the following lines:</p> <pre><code>NSString *deviceToken = [[webDeviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"&lt;&gt;"]]; deviceToken = [de...
1,579,846
Django returning HTTP 301?
<p>I have a django view that returns HTTP 301 on a curl request:</p> <pre><code>grapefruit:~ pete$ curl -I http://someurl HTTP/1.1 301 MOVED PERMANENTLY Date: Fri, 16 Oct 2009 19:01:08 GMT Server: Apache/2.2.9 (Win32) mod_wsgi/2.5 Python/2.6.2 PHP/5.2.6 Location: http://someurl Content-Type: text/html; charset=utf-8 <...
1,579,859
6
0
null
2009-10-16 19:08:35.587 UTC
13
2022-06-10 06:25:39.607 UTC
2016-06-06 15:00:43.197 UTC
null
123,201
null
123,201
null
1
71
django|curl|libcurl
37,728
<p>You are probably requesting the URL without a trailing slash, and have <code>APPEND_SLASH</code> set to True (the default) in settings.py, so Django is redirecting to the URL including a slash.</p>
2,056,628
Hot Code Replace Failed (eclipse)
<p>"Hot Code Replace Failed - add method not implemented". I get this error message every time I change something in my test class (and save it). Can't figure out what it means. Can somebody help?</p>
2,056,706
7
2
null
2010-01-13 12:41:24.637 UTC
9
2021-09-06 12:42:27.563 UTC
2013-12-02 19:28:19.717 UTC
null
125,389
null
110,028
null
1
44
eclipse|hotdeploy
61,547
<p>Possibly, you have a test which is still running (in debug mode). Try finishing all tests (you can see them in the debug view: window->show view->debug) and try again...</p>
1,981,670
Programmatically get a screenshot of a page
<p>I'm writing a specialized crawler and parser for internal use, and I require the ability to take a screenshot of a web page in order to check what colours are being used throughout. The program will take in around ten web addresses and will save them as a bitmap image.</p> <p>From there I plan to use LockBits in or...
2,496,277
7
6
null
2009-12-30 18:25:53.74 UTC
45
2019-08-05 14:24:44.163 UTC
2013-04-13 07:03:39.597 UTC
null
63,550
null
3,609
null
1
48
c#|screenshot|cutycapt|iecapt
60,019
<p><a href="https://screenshotlayer.com/documentation" rel="noreferrer">https://screenshotlayer.com/documentation</a> is the only free service I can find lately...</p> <p>You'll need to use HttpWebRequest to download the binary of the image. See the provided url above for details.</p> <pre><code>HttpWebRequest reques...
2,279,471
What's the difference between 'for' and 'foreach' in Perl?
<p>I see these used interchangeably. What's the difference?</p>
2,279,497
8
1
null
2010-02-17 09:19:53.677 UTC
null
2014-10-16 07:28:39.807 UTC
2012-02-23 20:09:31.927 UTC
null
579,750
null
275,088
null
1
39
perl|loops|syntax|for-loop|foreach
13,705
<p>There is no difference. From <a href="http://perldoc.perl.org/perlsyn.html#Foreach-Loops" rel="noreferrer">perldoc perlsyn</a>:</p> <blockquote> <p>The <code>foreach</code> keyword is actually a synonym for the <code>for</code> keyword, so you can use <code>foreach</code> for readability or <code>for</code> for b...
1,470,334
List all active ASP.NET Sessions
<p>How can I list (and iterate through) all current ASP.NET sessions?</p>
1,470,571
9
2
null
2009-09-24 08:04:45.513 UTC
25
2018-11-09 13:03:18.353 UTC
null
null
null
null
114,916
null
1
50
asp.net|session|session-state
66,193
<p>You can collect data about sessions in global.asax events Session_Start and Session_End (only in in-proc settings):</p> <pre><code>private static readonly List&lt;string&gt; _sessions = new List&lt;string&gt;(); private static readonly object padlock = new object(); public static List&lt;string&gt; Sessions { ...
2,013,091
Coloured Git diff to HTML
<p>I enjoy using <code>git diff --color-words</code> to clearly see the words that have changed in a file:</p> <p><img src="https://i.stack.imgur.com/HnM4B.png" alt="Screenshot"></p> <p>However I want to share that diff with someone without git or a colour terminal for that matter. So does anyone know of a tool or tr...
2,031,457
9
0
null
2010-01-06 13:13:21.113 UTC
47
2021-05-16 19:29:07.327 UTC
2014-06-21 19:26:50.78 UTC
user456814
null
null
4,534
null
1
74
html|git|colors|diff|terminal
44,034
<pre class="lang-bash prettyprint-override"><code>wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh chmod +x /tmp/ansi2html.sh git diff --color-words --no-index orig.txt edited.txt | \ /tmp/ansi2html.sh &gt; 2beshared.html </code></pre> <p>What I really needed was an <a href="http://en.wikipedi...
2,334,134
How to make C# Switch Statement use IgnoreCase
<p>If I have a switch-case statement where the object in the switch is string, is it possible to do an ignoreCase compare?</p> <p>I have for instance:</p> <pre><code>string s = &quot;house&quot;; switch (s) { case &quot;houSe&quot;: s = &quot;window&quot;; } </code></pre> <p>Will <code>s</code> get the value &quot;wi...
2,334,241
10
0
null
2010-02-25 13:07:13.19 UTC
12
2022-09-14 15:11:37.057 UTC
2020-11-05 23:44:19.467 UTC
null
1,402,846
null
141,414
null
1
100
c#|switch-statement
108,355
<p>As you seem to be aware, lowercasing two strings and comparing them is not the same as doing an ignore-case comparison. There are lots of reasons for this. For example, the Unicode standard allows text with diacritics to be encoded multiple ways. Some characters includes both the base character and the diacritic in ...
8,459,988
CSS Nested Comments
<p>Is there any way to nest comments in CSS?</p> <p>For example, when I try to comment out the following two statements, the outer comment ends when it encounters the */ in the nested comment, leaving the rest of the first statement and second statement uncommented.</p> <pre><code>/* #container { width: 9...
8,460,194
5
2
null
2011-12-10 21:24:31.22 UTC
11
2017-06-30 03:54:36.75 UTC
2017-05-23 10:31:29.113 UTC
null
-1
null
723,007
null
1
44
css|comments
13,193
<p>CSS does not have a nestable comment syntax.</p> <p>You could instead wrap the rules in something which does nest, but will not match anything, such as a non-existent media type:</p> <pre><code>@media DISABLED { #container { width: 90%; /* nested comment here */ margin: 0 auto; } #...
46,493,613
What is the replacement for javax.activation package in java 9?
<p>Seems like <code>javax.activation</code> package is deprecated in Java 9. Oracle migration guide proposes to use <code>--add-modules java.activation</code> option during JVM start. </p> <p>However, I would like to avoid this and replace <code>javax.activation</code> package's classes, as it is deprecated and will b...
46,493,809
6
3
null
2017-09-29 16:55:53.937 UTC
17
2021-03-31 14:46:19.557 UTC
2017-10-06 11:43:37.42 UTC
null
2,525,313
null
7,110,799
null
1
79
java|jvm|java-9|javax.activation
88,709
<p><a href="https://github.com/eclipse-ee4j/jaf" rel="noreferrer">JavaBeans Activation Framework (JAF)</a> is possibly the alternative you are looking for to the existing package.</p> <blockquote> <p>This standalone release of JAF uses a Java Platform Module System <strong><em>automatic module</em></strong> name o...
15,752,667
WARN SqlExceptionHelper:143 - SQL Error: 0, SQLState: 08S01- SqlExceptionHelper:144 - Communications link failure
<p>I have problem with Hibernate (<strong>hibernate-core-4.1.9.Final.jar</strong>)</p> <p>Case 1: Hibernate testing inside for loop. Everything went well.</p> <pre><code>for(int i = 0; i &lt; 1500; i++){ UserDAO.getInstance.getById(1); } </code></pre> <p>Case 2: <strong>Thread.sleep()</strong> inside loop. Resultin...
16,504,965
2
3
null
2013-04-01 22:00:26.573 UTC
2
2020-12-02 12:09:29.66 UTC
2020-12-02 12:09:29.66 UTC
null
1,073,748
null
1,073,748
null
1
6
mysql|hibernate
38,294
<p>The problem was happening because of the small value for <code>time_out</code> variable on the MySQL server.</p> <p>In my situation, <code>time_out</code> was set to 1 minute. Using <code>C3PO</code> pooling mechanism we can optimize <code>JDBC</code>.</p> <p>Download <strong>c3p0</strong> -&gt; <a href="http://sour...
15,989,030
MySQL Error 1045, "Access denied for user 'user'@'localhost' (using password: YES)"
<p>This question seem to be asked a lot however I cannot find a definitive answer.</p> <p>I am making some webapp tests using MySQL, and at the beginning I used the <em>'root'</em> user (with a non-empty password). My root user is working fine from the apps (tested from PHP and Python's Django), from the command line...
15,989,067
2
5
null
2013-04-13 14:47:58.7 UTC
1
2017-02-12 23:38:41.78 UTC
2013-04-13 14:55:53.893 UTC
null
13,508
null
2,029,629
null
1
6
mysql|mysql-error-1045
40,167
<p>% means that the new user can access the database from any host.</p> <p>However, if you supplied the CREATE USER statement would be much more useful.</p> <p>In addition, check MySQL Manual below, where it explains why a user should have both <code>@'localhost'</code> and <code>@'%'</code>:</p> <p><a href="http://...
34,088,373
"Call to undefined function mysql_connect()" after upgrade to php-7
<p>After I upgraded <strong>php5</strong> to <strong>php7</strong>, I get an error 500 with</p> <blockquote> <p>PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()</p> </blockquote> <p>I put this into my apt sources in order to get php7 right now:</p> <blockquote> <p>deb <a href="http://...
34,088,446
1
7
null
2015-12-04 12:24:58.54 UTC
9
2020-05-05 18:54:15.207 UTC
null
null
null
null
1,199,684
null
1
62
php|debian|php-7
230,265
<p>From the <a href="http://php.net/manual/en/function.mysql-connect.php" rel="noreferrer">PHP Manual</a>:</p> <blockquote> <p>Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alt...
27,763,340
DOCKER_OPTS do not work in config file /etc/default/docker
<p>I have changed <code>/etc/default/docker</code> with <code>DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"</code> (docker version 1.4.1 in ubuntu 14.04), but it do not take any effect for me (not listening at port <code>2375</code>). It seems that docker do not read this initial config file beca...
32,406,293
9
2
null
2015-01-04 07:13:48.073 UTC
11
2019-08-16 11:22:58.82 UTC
2016-06-29 18:58:14.72 UTC
null
143,224
null
4,162,734
null
1
27
ubuntu|docker|upstart|systemd
44,513
<p>According to <a href="https://docs.docker.com/install/linux/linux-postinstall/#configuring-remote-access-with-systemd-unit-file" rel="noreferrer">docker documentation</a>, The recommended way to configure the daemon flags and environment variables for your Docker daemon is to use a <strong>systemd</strong> <em>drop...
27,871,226
Jackson: Deserialize to a Map<String, Object> with correct type for each value
<p>I have a class that looks like the following</p> <pre><code>public class MyClass { private String val1; private String val2; private Map&lt;String,Object&gt; context; // Appropriate accessors removed for brevity. ... } </code></pre> <p>I'm looking to be able to make the round trip with Jackson from ...
27,875,728
1
3
null
2015-01-09 23:58:27.367 UTC
3
2019-06-07 13:30:53.907 UTC
2019-06-07 13:30:53.907 UTC
null
1,523,648
null
618,059
null
1
35
java|json|spring|jackson
55,853
<p>I think the simplest way of achieve what you want is using:</p> <pre><code>ObjectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); </code></pre> <p>This will add type information in the serialized json.</p> <p>Here you are a running example, that you will need to adapt to Spring:</p> <pre><code>p...
5,046,320
A grid layout of icon/text buttons
<p>I am attempting to create a 3 x 3 grid of items. Each Item consists of an <code>ImageView</code> on top of a <code>TextView</code>. Unfortunately, I am having issues getting everything to play nicely.</p> <p>Here is my attempt to get 2 such items side by side. The text views don't even show, and the icons are sq...
5,046,586
2
0
null
2011-02-18 20:40:48.717 UTC
5
2011-10-25 14:30:49.26 UTC
2011-02-18 20:48:13.693 UTC
null
107,455
null
107,455
null
1
16
android|grid|android-layout
58,852
<p>Your best bet in my opinion would be to use the gridView that way it supports scrolling and spacing and you can be very dynamic in what each items layout and events are. Another option is to just create a lay out the images with a combination of Relative/Linear Layouts.</p> <p>GridView layout:</p> <pre><code>&lt;G...
5,405,236
How to correctly write UTF-8 strings into MySQL through JDBC interface
<p>Connect to db:</p> <pre><code>public DBSource(ConnectionInfo ci) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { Class.forName(&quot;com.mysql.jdbc.Driver&quot;).newInstance(); String dbPath = String.format( &quot;jdbc:mysql://%s:%d/%s?use...
5,405,448
2
1
null
2011-03-23 12:28:25.19 UTC
6
2021-06-11 19:14:02.9 UTC
2021-06-11 19:14:02.9 UTC
null
626,311
null
658,346
null
1
16
java|mysql|jdbc|utf-8
47,089
<p>Ensure that your MySQL configuration encoding is defined correctly. Check your settings and the correctness of the modifications with these commands: </p> <pre><code>show variables like 'character%'; </code></pre> <p>and <code>show variables like 'collation%';</code></p> <p>Add these lines to either <strong>my.cn...
16,502,905
How to fix "'ddlAssignedTo' has a SelectedValue which is invalid because it does not exist in the list of items
<p>I load the gridview and the gridview has an edit and delete buttons.</p> <p>I click on Edit and I get, "<code>ddlAssignedTo' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value</code></p> <p>I know that I am getting this error because the value fo <code>ddlAss...
17,063,221
4
4
null
2013-05-12 00:05:24.547 UTC
1
2018-05-29 08:59:00.577 UTC
2013-05-12 09:39:57.007 UTC
null
745,969
null
935,573
null
1
7
asp.net|vb.net|gridview
38,760
<p>Take a look at the solution provided by @cosmin.onea in the question <a href="http://forums.asp.net/t/1056921.aspx/2/10" rel="nofollow noreferrer">'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items</a></p> <p>This solution sets <code>AppendDataBoundItems="true"</code...
16,165,666
How to determine the window size of a Gaussian filter
<p>Gaussian smoothing is a common image processing function, and for an introduction of Gaussian filtering, please refer to <a href="http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm" rel="noreferrer">here</a>. As we can see, one parameter: standard derivation will determine the shape of Gaussian function. However, w...
16,167,851
3
2
null
2013-04-23 09:24:40.47 UTC
10
2021-06-19 20:29:15.333 UTC
null
null
null
null
1,264,018
null
1
8
image-processing|signal-processing|matlab
37,522
<p>The <code>size</code> of the mask drives the filter amount. A larger <code>size</code>, corresponding to a larger convolution mask, will generally result in a greater degree of filtering. As a kinda trade-off for greater amounts of noise reduction, larger filters also affect the details quality of the image. </p> <...
313,432
C++ extend a vector with another vector
<p>I'm a C/Python programmer in C++ land working with the STL for the first time.</p> <p>In Python, extending a list with another list uses the <code>.extend</code> method:</p> <pre><code>&gt;&gt;&gt; v = [1, 2, 3] &gt;&gt;&gt; v_prime = [4, 5, 6] &gt;&gt;&gt; v.extend(v_prime) &gt;&gt;&gt; print(v) [1, 2, 3, 4, 5, 6...
313,444
7
1
null
2008-11-24 04:49:39.657 UTC
6
2022-07-25 05:02:35.383 UTC
2017-02-11 17:08:43.597 UTC
null
1,459,669
cdleary
3,594
null
1
70
c++|vector
49,756
<p>From <a href="http://www.cplusplus.com/reference/stl/vector/insert.html" rel="noreferrer">here</a></p> <pre><code>// reserve() is optional - just to improve performance v.reserve(v.size() + distance(v_prime.begin(),v_prime.end())); v.insert(v.end(),v_prime.begin(),v_prime.end()); </code></pre>
972,602
Limitations of Intel Assembly Syntax Compared to AT&T
<p>To me, Intel syntax is much easier to read. If I go traipsing through assembly forest concentrating only on Intel syntax, will I miss anything? Is there any reason I would want to switch to AT&amp;T (outside of being able to read others' AT&amp;T assembly)? My first clue is that gdb uses AT&amp;T by default.</p> <p...
972,614
7
0
null
2009-06-09 21:28:04.623 UTC
33
2021-01-22 19:56:06.74 UTC
2021-01-22 19:56:06.74 UTC
null
224,132
null
115,711
null
1
93
linux|assembly|x86|att|intel-syntax
42,079
<p>There is really no advantage to one over the other. I agree though that Intel syntax is <strong>much</strong> easier to read. Keep in mind that, AFAIK, all GNU tools have the option to use Intel syntax also.</p> <p>It looks like you can make GDB use Intel syntax with this:</p> <pre> set disassembly-flavor intel </...
582,723
How to import classes defined in __init__.py
<p>I am trying to organize some modules for my own use. I have something like this:</p> <pre><code>lib/ __init__.py settings.py foo/ __init__.py someobject.py bar/ __init__.py somethingelse.py </code></pre> <p>In <code>lib/__init__.py</code>, I want to define some classes to be used if I impor...
583,065
7
1
null
2009-02-24 17:35:55.93 UTC
34
2015-06-30 14:27:43.993 UTC
2009-02-24 19:39:20.017 UTC
scotty2012
53,007
scotty2012
53,007
null
1
131
python|package
173,177
<ol> <li><p>'<code>lib/</code>'s parent directory must be in <code>sys.path</code>. </p></li> <li><p>Your '<code>lib/__init__.py</code>' might look like this:</p> <pre><code>from . import settings # or just 'import settings' on old Python versions class Helper(object): pass </code></pre></li> </ol> <p>Then the ...
1,091,030
How do I create, write, and read session data in CakePHP?
<p>can anyone give me an example on how to create Sessions and write data to it. I've seen syntax on how to write data to a session using write command. But how to create a session and retrieve the values in it.</p> <p>In my application, I have two data, form_id and user_id that needs to be used in all the page reques...
1,151,986
8
0
null
2009-07-07 08:31:23.677 UTC
2
2020-06-25 03:54:04.333 UTC
2019-08-21 11:34:01.667 UTC
null
979
null
86,038
null
1
12
session|cakephp-2.0
57,578
<p>I found out the reason why the uid wasn't being echoed(edit 3 part of the question). It is due to a silly mistake, had a white space after the end tag ?> in the controller. Now it is working fine. </p>
266,688
How do you know the correct path to use in a PHP require_once() statement
<p>As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like:</p> <pre><code>require_once("config.php"); </code></pre> <p>or sometimes</p> <pre><code>require_once("../config.php"); </code></pre> <p>or even</p> <pre><code>re...
266,775
9
0
null
2008-11-05 21:12:12.697 UTC
10
2013-12-01 01:47:50.093 UTC
2009-08-17 18:04:15.95 UTC
null
54,964
null
28,565
null
1
12
php
29,792
<p>The current working directory for PHP is the directory in which the called script file is located. If your files looked like this:</p> <pre><code>/A foo.php tar.php B/ bar.php </code></pre> <p>If you call foo.php (ex: <a href="http://example.com/foo.php" rel="noreferrer">http://example.com/foo.php<...
333,367
Books/Tutorials to Learn SVG
<p>Does anyone here know SVG? If so, how did you learn it?</p> <p>Any books/tutorial pointer will be beneficial. Also I am a programmer, not a designer, so I want to pick up some skills there too.</p>
358,683
9
0
null
2008-12-02 08:40:36.007 UTC
14
2016-11-22 13:21:03.667 UTC
2011-05-13 11:26:15.71 UTC
null
56,338
versesane
38,306
null
1
13
graphics|svg
4,882
<p>I learned it developing <a href="http://www.w3.org/TR/SVGMobile12/" rel="nofollow noreferrer">SVG Tiny</a> software, mostly by reading the spec. SVG Tiny is basically a subset of full SVG and is focused on use in mobile phones and other "devices".</p> <p>Adding to the links from previous answers, <a href="http://ww...
974,964
best practice when returning smart pointers
<p>What is the best practice when returning a smart pointer, for example a boost::shared_ptr? Should I by standard return the smart pointer, or the underlying raw pointer? I come from C# so I tend to always return smart pointers, because it feels right. Like this (skipping const-correctness for shorter code): </p> <pr...
975,011
9
0
null
2009-06-10 11:12:33.817 UTC
9
2014-05-30 11:27:03.313 UTC
2009-06-10 11:28:51.303 UTC
null
91,683
null
91,683
null
1
33
c++|boost|smart-pointers
26,669
<p>There is no "right" way. It really depends on the context.</p> <p>You can internally handle memory with a smart pointer and externally give references or raw pointers. After all, the user of your interface doesn't need to know how you manage memory internally. In a synchronous context this is safe and efficient. In...
1,088,648
SQL: sum 3 columns when one column has a null value?
<pre><code>SELECT sum(TotalHoursM) + (TotalHoursT) + (TotalHoursW) + (TotalHoursTH) + (TotalHoursF) AS TOTAL FROM LeaveRequest </code></pre>
1,088,655
9
1
null
2009-07-06 18:50:13.983 UTC
9
2020-06-18 15:42:26.677 UTC
2009-07-08 08:20:46.333 UTC
null
116
null
1,709,270
null
1
82
sql
230,410
<p>If the column has a 0 value, you are fine, my guess is that you have a problem with a Null value, in that case you would need to use <code>IsNull(Column, 0)</code> to ensure it is always 0 at minimum.</p>
163,591
Bash autocompletion in Emacs shell-mode
<p>In the GNOME Terminal, Bash does smart auto-completion. For example</p> <pre><code>apt-get in&lt;TAB&gt; </code></pre> <p>becomes</p> <pre><code>apt-get install </code></pre> <p>In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source <code>/etc/bash_completion</code>. The above exa...
8,152,737
9
2
null
2008-10-02 17:37:02.493 UTC
27
2020-01-16 06:59:54.9 UTC
2008-11-14 19:17:54.62 UTC
Kevin Fairchild
3,743
Chris Conway
1,412
null
1
98
bash|shell|emacs|autocomplete
30,332
<p>I know this question is three years old, but it's something that I've also been interested in solving. A Web search directed me to a piece of elisp that makes Emacs use bash for completion in shell mode. It works for me, in any case.</p> <p>Check it out at <a href="https://github.com/szermatt/emacs-bash-completion"...
278,439
Creating a temporary directory in Windows?
<p>What's the best way to get a temp directory name in Windows? I see that I can use <code>GetTempPath</code> and <code>GetTempFileName</code> to create a temporary file, but is there any equivalent to the Linux / BSD <a href="http://linux.die.net/man/3/mkdtemp" rel="noreferrer"><code>mkdtemp</code></a> function for c...
278,457
9
3
null
2008-11-10 16:50:34.673 UTC
22
2020-12-14 14:29:34.993 UTC
2012-04-27 17:21:23.11 UTC
null
168,868
Josh Kelley
25,507
null
1
150
c#|.net|windows|temporary-directory
101,620
<p>No, there is no equivalent to mkdtemp. The best option is to use a combination of <a href="https://docs.microsoft.com/en-us/dotnet/api/system.io.path.gettemppath" rel="noreferrer">GetTempPath</a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getrandomfilename" rel="noreferrer">GetRandomFile...
1,008,668
How secure is a HTTP POST?
<p>Is a POST secure enough to send login credentials over?</p> <p>Or is an SSL connection a <strong>must</strong>?</p>
1,008,671
14
7
null
2009-06-17 18:05:31.43 UTC
28
2020-02-22 22:33:26.61 UTC
null
null
null
null
123,908
null
1
77
security|post|httpwebrequest|xmlhttprequest
88,021
<p><strong>SSL is a must.</strong></p> <p>POST method is not more secure than GET as it also gets sent unencrypted over network.</p> <p>SSL will cover the whole HTTP communication and encrypt the HTTP data being transmitted between the client and the server.</p>
648,196
Random row from Linq to Sql
<p>What is the best (and fastest) way to retrieve a random row using Linq to SQL when I have a condition, e.g. some field must be true?</p>
648,247
14
2
null
2009-03-15 17:37:16.343 UTC
55
2017-10-08 13:44:29.117 UTC
2016-12-27 15:20:12.653 UTC
Julien Poulin
1,033,581
Julien Poulin
65,060
null
1
116
c#|.net|linq-to-sql
71,819
<p>You can do this at the database, by using a fake UDF; in a partial class, add a method to the data context:</p> <pre><code>partial class MyDataContext { [Function(Name="NEWID", IsComposable=true)] public Guid Random() { // to prove not used by our C# code... throw new NotImplementedExcept...
318,888
Solving "Who owns the Zebra" programmatically?
<p>Edit: this puzzle is also known as "Einstein's Riddle"</p> <p>The <a href="https://en.wikipedia.org/wiki/Zebra_Puzzle" rel="noreferrer">Who owns the Zebra</a> (you can <a href="https://www.brainzilla.com/logic/zebra/einsteins-riddle/" rel="noreferrer" title="Einstein&#39;s Riddle">try the online version here</a>) i...
320,981
15
4
null
2008-11-25 21:14:26.783 UTC
115
2022-01-10 10:59:05.423 UTC
2017-02-23 12:21:03.753 UTC
Gortok
55,283
divideandconquer.se
20,444
null
1
129
language-agnostic|logic|constraint-programming|zebra-puzzle
27,323
<p>Here's a solution in Python based on constraint-programming:</p> <pre class="lang-py prettyprint-override"><code>from constraint import AllDifferentConstraint, InSetConstraint, Problem # variables colors = "blue red green white yellow".split() nationalities = "Norwegian German Dane Swede English".split() ...
41,319
Checking if a list is empty with LINQ
<p>What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type <code>IEnumerable&lt;T&gt;</code> and doesn't have a Count property.</p> <p>Right now I'm tossing up between this:</p> <pre><code>if (myList.Count() == 0) { ... } </code></pre> <p>an...
41,324
16
4
null
2008-09-03 08:35:24.98 UTC
26
2015-05-11 15:10:42.53 UTC
2012-10-31 15:02:17.293 UTC
Matt Hamilton
1,707,081
Matt Hamilton
615
null
1
128
c#|.net|linq|list
155,173
<p>You could do this:</p> <pre><code>public static Boolean IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; source) { if (source == null) return true; // or throw an exception return !source.Any(); } </code></pre> <p><strong>Edit</strong>: Note that simply using the .Count method will be fast if the underly...
338,667
Is there an upside down caret character?
<p>I have to maintain a large number of classic ASP pages, many of which have tabular data with no sort capabilities at all. Whatever order the original developer used in the database query is what you're stuck with.</p> <p>I want to to tack on some basic sorting to a bunch of these pages, and I'm doing it all client s...
338,691
17
3
null
2008-12-03 21:03:02.047 UTC
50
2022-06-17 06:57:56.343 UTC
2022-02-04 15:05:03.893 UTC
Joel Coehoorn
3,043
Joel Coehoorn
3,043
null
1
318
html|sorting|user-interface|character-encoding|character
442,959
<p>There's &#9650;: <a href="http://www.fileformat.info/info/unicode/char/25b2/index.htm" rel="noreferrer">&amp;#9650;</a> and &#9660;: <a href="http://www.fileformat.info/info/unicode/char/25bc/index.htm" rel="noreferrer">&amp;#9660;</a></p>
94,101
How to type faster
<p>I've typed around 75wpm for the last few years but I've always wondered how people type +100wpm. </p> <p>I've searched but I primarily find typing tutors that teach you to type.. not teach you to type faster. So far the only tip I've come across is to learn dvorak. </p> <p>Are there exercises or tips to help break...
94,137
25
3
null
2008-09-18 16:20:46.463 UTC
21
2019-05-21 05:41:01.19 UTC
2008-09-18 16:32:25.627 UTC
Mark Biek
305
raema
17,177
null
1
25
typing|touch-typing|performance|wpm
11,649
<p>Setting yourself up in an ergonomic typing position is a good start. Take a look at the diagram <a href="http://www.yale.edu/ergo/neutral.htm" rel="noreferrer">here</a> - notice the arms in a straight line, feet on the floor, etc. </p> <p>In my experience most people tend to slow down when they get to unusual keys ...
285,793
What is a serialVersionUID and why should I use it?
<p>Eclipse issues warnings when a <code>serialVersionUID</code> is missing. </p> <blockquote> <p>The serializable class Foo does not declare a static final serialVersionUID field of type long</p> </blockquote> <p>What is <code>serialVersionUID</code> and why is it important? Please show an example where missing...
285,809
25
1
null
2008-11-12 23:24:56.797 UTC
807
2021-08-05 12:50:59.94 UTC
2015-03-17 22:44:09.937 UTC
null
260,990
askgelal
33,203
null
1
3,324
java|serialization|serialversionuid
1,084,940
<p>The docs for <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html" rel="noreferrer"><code>java.io.Serializable</code></a> are probably about as good an explanation as you'll get:</p> <blockquote> <p>The serialization runtime associates with each serializable class a version...
6,360,024
jQuery each() with a delay
<p>So, I would like an element to fade in and wait half a second, then fade the next in etc...</p> <p>My code:</p> <pre><code>$('.comment').each(function() { $(this).css({'opacity':0.0}).animate({ 'opacity':1.0 }, 450).delay(500); ...
6,360,189
5
3
null
2011-06-15 15:14:15.853 UTC
4
2016-08-16 12:43:34.097 UTC
null
null
null
null
285,178
null
1
17
javascript|jquery
43,465
<p>Or, something like this:</p> <pre><code>$.each($('.comment'), function(i, el){ $(el).css({'opacity':0}); setTimeout(function(){ $(el).animate({ 'opacity':1.0 }, 450); },500 + ( i * 500 )); }); </code></pre> <p>demo => <a href="http://jsfiddle.net/steweb/9uS56/" rel="noreferrer"...
6,782,658
How to get default gateway in Mac OSX
<p>I need to retrieve the default gateway on a Mac machine. I know that in Linux route -n will give an output from which I can easily retrieve this information. However this is not working in Mac OSX(Snow Leopard). </p> <p>I also tried <code>netstat -nr | grep 'default'</code>, but I was hoping for a cleaner output li...
7,627,059
5
2
null
2011-07-21 20:54:22.247 UTC
46
2019-12-02 11:46:53.897 UTC
2013-03-05 19:53:28.143 UTC
null
537,031
null
478,199
null
1
132
macos|routes|netstat|ifconfig
246,054
<p>You can try with:</p> <pre><code>route -n get default </code></pre> <p>It is not the same as GNU/Linux's <code>route -n</code> (or even <code>ip route show</code>) but is useful for checking the default route information. Also, you can check the route that packages will take to a particular host. E.g.</p> <pre><code...
6,773,866
Download file and automatically save it to folder
<p>I'm trying to make a UI for downloading files from my site. The site have zip-files and these need to be downloaded to the directory entered by the user. However, I can't succeed to download the file, it just opens up from a temporary folder.</p> <p>Code:</p> <pre><code>private void webBrowser1_Navigating(object s...
6,866,340
6
10
null
2011-07-21 09:19:33.913 UTC
10
2018-03-30 08:50:49.227 UTC
2011-07-21 09:47:00.303 UTC
null
5,772,384
null
360,186
null
1
10
c#|file|download|save
145,357
<p>Why not just bypass the WebClient's file handling pieces altogether. Perhaps something similar to this:</p> <pre><code> private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { e.Cancel = true; WebClient client = new WebClient(); client.DownloadDataComple...
6,617,620
mysql WHERE IN array string / username
<p>Code:</p> <pre><code>$friendsArray = array("zac1987", "peter", "micellelimmeizheng1152013142"); $friendsArray2 = join(', ',$friendsArray); $query120 = "SELECT picturemedium FROM users WHERE username IN ('$friendsArray2')"; echo $query120; </code></pre> <p>This is the output :</p> <pre><code>SELECT picturemedium...
6,617,658
6
0
null
2011-07-07 21:57:04.133 UTC
6
2022-02-06 06:48:18.85 UTC
2018-02-18 17:34:17.45 UTC
null
4,907,496
null
650,312
null
1
14
php|mysql|arrays
82,431
<p>Let's loop through each name one by one, escaping each.</p> <p>I'm going to recommend that you use an actual MySQL escaping function rather than just wrapping quotes around, to ensure that the data actually goes into the query correctly. (Otherwise, if I entered a name like <code>It's me!</code>, the single quote w...
6,850,276
How to convert dataURL to file object in javascript?
<p>I need to convert a dataURL to a File object in Javascript in order to send it over using AJAX. Is it possible? If yes, please tell me how.</p>
7,261,048
6
6
null
2011-07-27 19:42:09.963 UTC
38
2022-02-13 09:20:14.667 UTC
2018-07-17 14:02:48.897 UTC
null
860,857
null
733,612
null
1
71
javascript|jquery|fileapi
104,351
<p>If you need to send it over ajax, then there's no need to use a <code>File</code> object, only <code>Blob</code> and <code>FormData</code> objects are needed.</p> <p>As I sidenote, why don't you just send the base64 string to the server over ajax and convert it to binary server-side, using PHP's <code>base64_decode...
6,840,332
Rename multiple files by replacing a particular pattern in the filenames using a shell script
<blockquote> <p>Write a simple script that will automatically rename a number of files. As an example we want the file *001.jpg renamed to user defined string + 001.jpg (ex: MyVacation20110725_001.jpg) The usage for this script is to get the digital camera photos to have file names that make some sense.</p> </blockqu...
6,840,404
8
4
null
2011-07-27 06:38:51.08 UTC
74
2022-07-01 06:00:18.35 UTC
2013-03-23 10:47:22.867 UTC
null
488,657
null
567,797
null
1
204
shell
218,387
<p>An example to help you get off the ground.</p> <pre><code>for f in *.jpg; do mv &quot;$f&quot; &quot;$(echo &quot;$f&quot; | sed s/IMG/VACATION/)&quot;; done </code></pre> <p>In this example, I am assuming that all your image files contain the string <code>IMG</code> and you want to replace <code>IMG</code> with <co...
6,817,870
ASP.NET strange compilation error
<p>I don't know what's wrong with my machine, but it's a while that I'm getting the following strange error from ASP.NET (for all my applications).</p> <pre><code>Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specifi...
6,929,129
20
1
null
2011-07-25 14:43:47.96 UTC
19
2019-11-27 19:37:34.667 UTC
2016-12-17 18:09:30.05 UTC
null
63,550
null
452,830
null
1
58
.net|asp.net|iis
141,196
<p>OK, after days struggling with this issue, I finally fixed it.</p> <ul> <li>Not by clearing ASP.NET temp</li> <li>Not by reinstalling the .NET framework!</li> </ul> <p>Simple!</p> <ul> <li>I changed the application pool identity from "Local system" to "ApplicationPoolIdentity"</li> </ul> <p>Apparently there was ...
15,683,975
IF, ELIF, ELSE in T-SQL
<p>I am working in SQL Server 2008 and trying to use a <code>IF, ELIF, ELSE</code> statement in the <code>SELECT</code> section of my code. What I want to do is the following:</p> <pre><code>IF BO.VALUE &lt; BO.REFERENCELOWERLIMIT THEN (BO.VALUE - BO.REFERENCELOWERLIMIT) #I WANT THIS TO BE NEGATIVE ELSE IF BO.REFE...
15,684,026
2
4
null
2013-03-28 14:06:58.4 UTC
1
2016-07-21 21:46:05.007 UTC
2013-03-28 14:08:18.993 UTC
null
330,315
null
1,510,267
null
1
13
sql-server-2008|tsql
70,017
<p>You want a <code>CASE</code> expression. <code>CASE</code> evaluates in order and the first match is what is returned in the query.</p> <pre><code>SELECT CASE WHEN BO.VALUE &lt; BO.REFERENCELOWERLIMIT THEN (BO.VALUE - BO.REFERENCELOWERLIMIT) WHEN BO.VALUE BETWEEN BO.REFERENCELOWERLIMIT AND BO....
15,966,726
How to change method behaviour through reflection?
<p>I have a a static method in some legacy code, which is called by multiple clients. I obviously have no options to override it, or change behaviour through dependency injection. I am not allowed to modify the existing class.</p> <p>What I want to do now is change the behaviour (that method - with the same signature ...
15,966,918
3
5
null
2013-04-12 08:38:31.617 UTC
4
2022-03-24 10:03:55.827 UTC
2013-04-12 09:00:05.613 UTC
null
430,720
null
430,720
null
1
32
java|android|design-patterns|legacy-code
47,378
<p>Sounds like a weird requirement... </p> <p>Anyway, reflection does not allow you to change code behaviour, it can only explore current code, invoke methods and constuctors, change fields values, that kind of things.</p> <p>If you want to actually change the behaviour of a method you would have to use a bytecode ma...
25,157,642
How to repeatedly run bash script every N seconds?
<p>I have a shell script printing some statistics like disk info, memory use and so on. But it shows information only once after the script runs and exits. Can I make this script be run repeatedly (like <code>htop</code> for example) or something like that? I want this info to be updated every 5-10 seconds.</p>
25,158,585
2
5
null
2014-08-06 10:09:49.273 UTC
10
2019-04-30 20:01:17.53 UTC
2019-04-30 20:01:17.53 UTC
null
648,658
null
3,812,402
null
1
25
linux|bash
34,273
<p>A slight improvement to my comment: if your script exits with <em>true</em> (e.g. when it ends with <code>exit 0</code>), you can run</p> <pre><code>while script; do sleep 10; done </code></pre> <p>This is the canonical way to repeat a command as long as it doesn't fail.</p>
10,278,683
How safe is it to store sessions with Redis?
<p>I'm currently using MySql to store my sessions. It works great, but it is a bit slow.</p> <p>I've been asked to use Redis, but I'm wondering if it is a good idea because I've heard that Redis delays write operations. I'm a bit afraid because sessions need to be real-time.</p> <p>Has anyone experienced such problem...
10,279,573
3
10
null
2012-04-23 10:19:18.91 UTC
48
2018-03-27 04:24:41.12 UTC
2018-03-24 02:55:34.097 UTC
null
3,260,543
null
962,602
null
1
108
session|redis
76,364
<p>Redis is perfect for storing sessions. All operations are performed in memory, and so reads and writes will be fast. </p> <p>The second aspect is persistence of session state. Redis gives you a lot of flexibility in how you want to persist session state to your hard-disk. You can go through <a href="http://redis.io...
33,312,175
matching any character including newlines in a Python regex subexpression, not globally
<p>I want to use <a href="https://docs.python.org/2/library/re.html#re.MULTILINE" rel="noreferrer"><code>re.MULTILINE</code></a> but <strong>NOT</strong> <a href="https://docs.python.org/2/library/re.html#re.DOTALL" rel="noreferrer"><code>re.DOTALL</code></a>, so that I can have a regex that includes both an "any chara...
33,312,193
2
5
null
2015-10-23 22:13:37.923 UTC
13
2022-03-14 18:16:18.41 UTC
2015-11-13 13:27:03.093 UTC
null
44,330
null
44,330
null
1
87
python|regex
77,261
<p>To match a newline, or &quot;any symbol&quot; without <code>re.S</code>/<code>re.DOTALL</code>, you may use any of the following:</p> <ol> <li><p><code>(?s).</code> - the <a href="https://www.regular-expressions.info/modifiers.html" rel="noreferrer">inline modifier group</a> with <code>s</code> flag on sets a scope ...
13,765,995
ELMAH - MVC 3 - 403 - Forbidden: Access is denied
<p>I have installed <a href="https://github.com/alexanderbeletsky/elmah.mvc">Elmah for MVC</a> using NuGet, I'am able to login with success error in the db. The only problem is that I cannot access the <code>/elmah</code> URL to access the Error Log Page.</p> <p>Here part of my configuration, could you please point ou...
13,766,103
3
1
null
2012-12-07 15:24:34.407 UTC
3
2019-01-11 06:11:27.85 UTC
2012-12-07 15:33:22.57 UTC
null
13,302
null
379,008
null
1
35
asp.net-mvc|elmah|elmah.mvc
15,645
<p>(This is all from the documentation/getting started)</p> <p>You don't need the following line:</p> <pre><code>routes.IgnoreRoute("elmah.axd"); </code></pre> <p>The next line takes care of it.</p> <p>Everything you need to configure is in your <code>web.config</code> file. Something like:</p> <pre><code>&lt;elm...
13,761,934
Xcode derived data location
<p>Xcode keeps writing derived data to the project folder even though its set to default in the xcode project settings, its there any way to force this other than the project settings?</p>
13,762,600
1
1
null
2012-12-07 11:11:31.873 UTC
3
2016-10-13 06:59:20.78 UTC
null
null
null
null
692,770
null
1
36
ios|xcode
25,929
<p>By default Xcode stores the derived data for all projects in a single shared folder under your home directory at the following location:</p> <pre><code>~/Library/Developer/Xcode/DerivedData </code></pre> <p>Update:</p> <p>From Xcode 6, you can access or change derived data location from <strong>Preferences -> Loc...
13,395,391
Z3: finding all satisfying models
<p>I am trying to retrieve all possible models for some first-order theory using Z3, an SMT solver developed by Microsoft Research. Here is a minimal working example:</p> <pre><code>(declare-const f Bool) (assert (or (= f true) (= f false))) </code></pre> <p>In this propositional case there are two satisfying assignm...
13,398,853
2
0
null
2012-11-15 10:18:06.767 UTC
16
2022-01-13 09:33:27.47 UTC
null
null
null
null
1,563,701
null
1
38
z3|smt|theorem-proving
18,928
<p>One way to accomplish this is using one of the APIs, along with the model generation capability. You can then use the generated model from one satisfiability check to add constraints to prevent previous model values from being used in subsequent satisfiability checks, until there are no more satisfying assignments....
13,322,485
How to get the primary IP address of the local machine on Linux and OS X?
<p>I am looking for a command line solution that would return me the primary (first) IP address of the localhost, other than 127.0.0.1</p> <p>The solution should work at least for Linux (Debian and RedHat) and OS X 10.7+</p> <p>I am aware that <code>ifconfig</code> is available on both but its output is not so consis...
13,322,549
31
7
null
2012-11-10 13:32:11.317 UTC
162
2021-07-25 16:44:50.47 UTC
2019-08-11 15:07:02.99 UTC
user3956566
null
null
99,834
null
1
410
bash|unix|ip|ifconfig
687,788
<p>Use <code>grep</code> to filter IP address from <code>ifconfig</code>: </p> <p><code>ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'</code></p> <p>Or with <code>sed</code>:</p> <p><code>ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[...
13,242,469
How to use sed/grep to extract text between two words?
<p>I am trying to output a string that contains everything between two words of a string:</p> <p>input:</p> <pre><code>"Here is a String" </code></pre> <p>output:</p> <pre><code>"is a" </code></pre> <p>Using: </p> <pre><code>sed -n '/Here/,/String/p' </code></pre> <p>includes the endpoints, but I don't want to i...
13,242,517
14
3
null
2012-11-06 00:08:45.847 UTC
73
2022-08-11 07:10:42.1 UTC
2017-05-25 04:39:00.103 UTC
null
793,796
null
1,190,650
null
1
188
string|bash|sed|grep
628,243
<pre><code>sed -e 's/Here\(.*\)String/\1/' </code></pre>
13,573,653
CSS margin terror; Margin adds space outside parent element
<p>My css margins doesn't behave the way I want or expect them to. I seems like my header margin-top affect the div-tags surrounding it.</p> <p><strong>This is what I want and expect:</strong> <img src="https://i.stack.imgur.com/Uf7E7.png" alt="What I want...."></p> <p><strong>...but this is what I end up with:</stro...
13,573,739
8
6
null
2012-11-26 21:44:28.69 UTC
39
2022-06-22 19:38:38.973 UTC
2022-06-22 19:38:38.973 UTC
null
8,620,333
null
266,642
null
1
196
html|css|overflow|margin
111,738
<p>Add <code>overflow:auto</code> to your <code>#page</code> div.</p> <p><strong><a href="http://jsfiddle.net/j08691/464jW/">jsFiddle example</a></strong></p> <p>And check out <a href="http://www.w3.org/TR/CSS2/box.html#collapsing-margins">collapsing margins</a> while you're at it.</p>
3,847,294
Replace all characters not in range (Java String)
<p>How do you replace all of the characters in a string that do not fit a criteria. I'm having trouble specifically with the NOT operator. </p> <p>Specifically, I'm trying to remove all characters that are not a digit, I've tried this so far:</p> <pre><code>String number = "703-463-9281"; String number2 = number.re...
3,847,299
2
0
null
2010-10-02 19:54:36.98 UTC
8
2016-09-07 08:56:09.353 UTC
2010-10-02 20:30:23.763 UTC
null
276,101
null
84,131
null
1
29
java|regex|character-class
38,242
<p>To explain: The ^ at the start of a character class will negate that class But it has to be inside the class for that to work. The same character outside a character class is the anchor for start of string/line instead.</p> <p>You can try this instead:</p> <pre><code>"[^0-9]" </code></pre>
28,827,196
How to call a codebehind function from javascript in asp.net?
<p>I want to call a function from my code behind using javascript. I used the below code:</p> <pre><code>function fnCheckSelection() { some script; window["My"]["Namespace"]["GetPart"](null); } </code></pre> <p>...where <code>"GetPart"</code> is the function name. However, this is not working. Please help me on this....
28,827,816
4
13
null
2015-03-03 08:30:45.19 UTC
2
2020-06-26 17:00:40.443 UTC
2017-12-20 17:00:37.697 UTC
null
6,530,134
null
3,355,228
null
1
15
javascript|c#|asp.net
88,764
<p>in JavaScript:</p> <pre><code> document.getElementById(&quot;btnSample&quot;).click(); </code></pre> <p>Server side control:</p> <pre><code> &lt;asp:Button runat=&quot;server&quot; ID=&quot;btnSample&quot; ClientIDMode=&quot;Static&quot; Text=&quot;&quot; style=&quot;display:none;&quot; OnClick=&quot;btnSample...
9,024,724
How do I put double quotes in a string in vba?
<p>I want to insert an if statement in a cell through vba which includes double quotes.</p> <p>Here is my code:</p> <pre><code>Worksheets("Sheet1").Range("A1").Value = "=IF(Sheet1!B1=0,"",Sheet1!B1)" </code></pre> <p>Due to double quotes I am having issues with inserting the string. How do I handle double quotes?</p...
9,024,764
4
2
null
2012-01-26 20:18:31.9 UTC
21
2019-05-27 08:49:17.403 UTC
2019-05-27 08:49:17.403 UTC
null
2,190,175
null
793,468
null
1
150
excel|vba|double-quotes
561,777
<p>I find the easiest way is to double up on the quotes to handle a quote.</p> <pre><code>Worksheets("Sheet1").Range("A1").Formula = "IF(Sheet1!A1=0,"""",Sheet1!A1)" </code></pre> <p>Some people like to use CHR(34)*:</p> <pre><code>Worksheets("Sheet1").Range("A1").Formula = "IF(Sheet1!A1=0," &amp; CHR(34) &amp; CHR...
16,062,072
How to add certificate chain to keystore?
<p>I have file with chain of certificates - certificate.cer: </p> <pre><code>subject=/C... issuer=/C=US/O=VeriSign, Inc... -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- subject=/C=US/O=VeriSign, Inc... issuer=/C=US/O=VeriSign, Inc... -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- subject=/C=U...
16,062,331
3
3
null
2013-04-17 13:56:23.05 UTC
18
2022-03-04 04:19:48.503 UTC
2016-10-28 19:26:51.793 UTC
null
608,639
null
167,739
null
1
42
java|openssl|certificate|keystore|keytool
173,854
<p>From the keytool man - it imports certificate chain, if input is given in PKCS#7 format, otherwise only the single certificate is imported. You should be able to convert certificates to PKCS#7 format with openssl, via openssl crl2pkcs7 command.</p>
17,404,165
How to run a command on command prompt startup in Windows
<blockquote> <p><strong>EDIT</strong></p> <p>If you want to perform any task at computer startup or based on an event this is very helpful</p> <p><a href="http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/how-to-schedule-computer-to-shut-down-at-a-certain/800ed207-f630-480d-8c92-dff23...
17,404,355
6
0
null
2013-07-01 12:08:50.193 UTC
40
2021-02-26 15:41:02.02 UTC
2016-10-29 00:12:30.34 UTC
null
1,630,171
null
840,669
null
1
65
windows|cmd|command|command-prompt
118,415
<p>I found my answer: I should use the <code>/K</code> switch, using which I can enter a new command on the opened command prompt.</p> <p>E.g. <code>cmd /K cls</code> will open a command prompt for me and clear it. (Answer for question 1)</p> <p>and </p> <p><code>cmd /K MyBatchFile.bat</code> will start a command pr...
17,267,218
Perforce for Git users?
<p>There is a lot of "Git for Perforce users" documentation out there, but seemingly very little of the opposite.</p> <p>I have only used Git previously and recently started a job where I have to use Perforce a lot, and find myself getting very confused a lot of the time. The concepts I'm used to from Git seem not to ...
17,331,274
3
0
null
2013-06-24 02:24:42.95 UTC
132
2019-03-19 13:00:25.933 UTC
null
null
null
null
242,814
null
1
175
git|perforce
52,983
<p>This something I've been working on over the past couple weeks on and off. It's still evolving, but it may be helpful. Please note I'm a Perforce employee.</p> <h1>An intro to Perforce for Git users</h1> <p>To say that moving from Git to Perforce or from Perforce to Git is non-trivial is a grand understatement. Fo...
30,572,605
ViewPager show next and before item preview on screen
<p>I want to show viewpager next and before page preview in screen. Before and next page show deep in screen and slide next page with deep animation.</p> <p>You can look this image</p> <p>How can i do it? </p> <p><img src="https://i.stack.imgur.com/f6yHc.png" alt="enter image description here"></p>
30,594,487
5
4
null
2015-06-01 11:42:31.49 UTC
23
2020-07-23 14:37:53.327 UTC
2016-02-17 13:30:11.333 UTC
null
3,800,712
null
3,800,712
null
1
40
android|android-viewpager|pager
30,340
<p>Finally, i did it :) I modify this answer <a href="https://stackoverflow.com/questions/10001503/android-carousel-like-widget-which-displays-a-portion-of-the-left-and-right-el">Android - Carousel like widget which displays a portion of the left and right elements</a></p> <p>You can look this code.</p> <pre><code>//...
36,988,681
time.Time Round to Day
<p>I have a timestamp coming in, I wonder if there's a way to round it down to the start of a day in PST. For example, ts: <code>1305861602</code> corresponds to <code>2016-04-14, 21:10:27 -0700</code>, but I want to round it to a timestamp that maps to <code>2016-04-14 00:00:00 -0700</code>. I read through the time.Ti...
36,988,882
6
3
null
2016-05-02 18:00:03.737 UTC
9
2022-08-12 13:53:29.527 UTC
2018-08-23 06:58:00.687 UTC
null
13,860
null
2,190,546
null
1
56
go
55,562
<p>The simple way to do this is to create new <code>Time</code> using the previous one and only assigning the year month and day. It would look like this;</p> <pre><code>rounded := time.Date(toRound.Year(), toRound.Month(), toRound.Day(), 0, 0, 0, 0, toRound.Location()) </code></pre> <p>here's a play example; <a href...
25,865,270
How to install Python MySQLdb module using pip?
<p>How can I install the <a href="http://mysql-python.sourceforge.net/MySQLdb.html" rel="noreferrer">MySQLdb</a> module for Python using pip?</p>
25,865,271
20
2
null
2014-09-16 09:31:57.003 UTC
94
2022-06-28 13:08:17.143 UTC
2018-04-24 19:30:19.29 UTC
null
1,228,491
null
1,228,491
null
1
339
python|mysql|pip
643,281
<p>It's easy to do, but hard to remember the correct spelling:</p> <pre><code>pip install mysqlclient </code></pre> <p>If you need 1.2.x versions (legacy Python only), use <code>pip install MySQL-python</code></p> <p>Note: Some dependencies might have to be in place when running the above command. Some hints on how ...
9,193,214
Why does overflow hidden stop floating elements escaping their container?
<p>A common problem that I have with web pages is floating <code>div</code> tags creeping outside of their containers, like shown in the snippet.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettypr...
9,193,270
2
3
null
2012-02-08 12:22:21.673 UTC
12
2021-09-14 02:09:02.41 UTC
2021-09-14 02:09:02.41 UTC
null
5,372,008
null
1,022,228
null
1
30
html|css
10,367
<p>It creates a <a href="https://developer.mozilla.org/en/CSS/block_formatting_context">block formatting context</a>.</p> <blockquote> <p><em>Block formatting contexts are important for the positioning (see float) and clearing (see clear) of floats. The rules for positioning and clearing of floats apply only to th...
9,589,381
Remove extra line breaks after Html.fromHtml()
<p>I am trying to place html into a TextView. Everything works perfectly, this is my code.</p> <pre><code>String htmlTxt = "&lt;p&gt;Hellllo&lt;/p&gt;"; // the html is form an API Spanned html = Html.fromHtml(htmlTxt); myTextView.setText(html); </code></pre> <p>This sets my TextView with the correct html. But my prob...
10,187,511
4
5
null
2012-03-06 18:06:17.927 UTC
14
2019-01-24 14:23:19.567 UTC
2012-03-06 18:07:54.023 UTC
user658042
null
null
1,240,803
null
1
44
android|html|line-breaks|spanned
13,894
<p>Nice answer @Christine. I wrote a similar function to remove trailing whitespace from a CharSequence this afternoon:</p> <pre><code>/** Trims trailing whitespace. Removes any of these characters: * 0009, HORIZONTAL TABULATION * 000A, LINE FEED * 000B, VERTICAL TABULATION * 000C, FORM FEED * 000D, CARRIAGE RETU...
18,361,750
Correct approach to global logging
<p>What's the pattern for application logging in Go? If I've got, say, 5 goroutines I need to log from, should I... </p> <ul> <li>Create a single <code>log.Logger</code> and pass it around?</li> <li>Pass around a pointer to that <code>log.Logger</code>?</li> <li>Should each goroutine or function create a logger?</li> ...
18,362,952
7
0
null
2013-08-21 15:35:44.81 UTC
40
2021-07-26 14:30:59.157 UTC
2021-07-26 14:30:59.157 UTC
null
1,744,107
null
200,619
null
1
143
logging|go
71,300
<blockquote> <ul> <li>Create a single log.Logger and pass it around?</li> </ul> </blockquote> <p>That is possible. A <a href="http://golang.org/pkg/log/#Logger">log.Logger</a> can be used concurrently from multiple goroutines.</p> <blockquote> <ul> <li>Pass around a pointer to that log.Logger?</li> </ul> ...
18,552,901
How to merge videos by avconv?
<p>I have several chunks in folder.</p> <pre><code>0001.mp4 0002.mp4 0003.mp4 ... 0112.mp4 </code></pre> <p>I would like to merge them into full.mp4</p> <p>I tried to use:</p> <pre><code>avconv -f concat -i &lt;(printf "file '%s'\n" /root/chunk/*.mp4) -y \ -c copy /root/test/full.mp4 </code></pre> <p>Unknown input...
19,314,483
10
4
null
2013-08-31 21:15:42.383 UTC
14
2019-06-24 19:00:39.687 UTC
2015-12-03 19:06:22.933 UTC
null
895,245
null
1,603,227
null
1
38
video|avconv
42,798
<pre><code>avconv -i concat:file1.mp4\|file2.mp4 -c copy output.mp4 </code></pre> <p>I don't know if works with any container's type ( worked for me with <code>AVI</code> ).</p>
14,958,543
View Pager with Universal Image Loader Out of Memory Error
<p>I am not really sure if a ViewPager with Universal Image Loader can/should be used as an alternate for a gallery like interface since I have run into an Out of Memory error while loading images from SD Card and viewing them in full screen mode. No matter what the number, it works all fine with a GridView but while v...
15,053,683
7
0
null
2013-02-19 13:19:16.96 UTC
8
2016-01-21 18:35:01.687 UTC
2013-02-20 10:51:05.677 UTC
null
1,149,279
null
1,149,279
null
1
11
android|android-viewpager|out-of-memory|universal-image-loader
11,425
<p>Try to apply next suggestions:</p> <ol> <li>Use <code>ImageScaleType.EXACTLY</code></li> <li>Enable caching on disc (in display options).</li> <li>Finally try to use <code>.discCacheExtraOptions(maxImageWidthForDiscCache, maxImageHeightForDiscCache, CompressFormat.PNG, 0);</code> </li> </ol>
15,199,980
How to put an image in the center of navigationBar of a UIViewController?
<p>I have this snippet of code used in viewDidLoad of a UIViewController. I'va no errors. Images exists. I get the background but not the image. Image is a sort of logo.</p> <pre><code>if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) { /* Background o...
15,200,267
7
2
null
2013-03-04 11:00:20.97 UTC
9
2020-04-29 11:55:55.15 UTC
null
null
null
null
1,420,625
null
1
22
ios|uinavigationbar
33,704
<p>The <code>UINavigationController</code> manages the navigation bar by looking at the <code>navigationItem</code> property of the top-most view controller on the navigation stack. So to change the view to a logo, you need to set this up in the view controller that uses the logo (i.e. the root view controller or anoth...
14,948,406
How to start Postgres server?
<p>Ive actually had this problem for a while but I've finally decided to take it on. Postgres was initially installed using Brew. </p> <p>After my upgrade to OSX 10.8.2 to receive a</p> <pre><code>psql: could not connect to server: No such file or directory Is the server running locally and accepting connecti...
14,949,578
1
6
null
2013-02-19 01:38:46.143 UTC
12
2015-07-02 19:55:05.5 UTC
2015-07-02 19:55:05.5 UTC
null
54,964
null
1,319,172
null
1
26
postgresql|osx-lion|django-postgresql
32,173
<p>You haven't started the Postgres server. Some of the dmg packages for Postgres set it to run as a service on startup. But not however you did the install.</p> <p>You need to init a data directory, start postgres, and then go from there.</p> <pre><code>initdb /some/directory # just do this ONCE pg_ctl -D /some/dire...
15,388,897
Google Maps inside iframe not loading
<p>I ran into a strange issue, and I don't know what the problem is. The following jQuery code is a simplified version of what I want to achieve:</p> <pre><code>var iframe = $('&lt;iframe /&gt;'); iframe.prop('src', 'https://maps.google.com/maps?q=London&amp;hl=en&amp;sll=37.0625,-95.677068&amp;sspn=46.677964,93.07617...
15,389,189
5
0
null
2013-03-13 15:01:35.987 UTC
4
2022-08-28 14:18:00.737 UTC
2013-03-13 15:10:52.787 UTC
null
367,401
null
367,401
null
1
29
javascript|jquery|google-maps
60,449
<p>Appending <code>&amp;output=embed</code> to the end of the URL fixes the problem.</p> <p><strong>Update</strong>: Google disabled this feature, which was working at the time the answer was originally posted. This solution no longer works.</p>
14,935,755
How to get data from old offset point in Kafka?
<p>I am using zookeeper to get data from kafka. And here I always get data from last offset point. Is there any way to specify the time of offset to get old data?</p> <p>There is one option autooffset.reset. It accepts smallest or largest. Can someone please explain what is smallest and largest. Can autooffset.reset h...
17,084,401
7
0
null
2013-02-18 11:57:47.747 UTC
19
2017-01-20 06:06:46.183 UTC
2016-12-20 16:04:12.167 UTC
null
2,893,839
null
648,626
null
1
39
apache-kafka|offset|zookeeper|apache-zookeeper
49,523
<p>The consumers belong always to a group and, for each partition, the Zookeeper keeps track of the progress of that consumer group in the partition.</p> <p>To fetch from the beginning, you can delete all the data associated with progress as Hussain refered</p> <pre><code>ZkUtils.maybeDeletePath(${zkhost:zkport}", "/...
15,093,376
JConsole over ssh local port forwarding
<p>I'd like to be able to remotely connect to a Java service that has JMX exposed, however it is blocked by a firewall. I have tried to use ssh local port forwarding, however the connection fails. Looking at wireshark, it appears that when you try to connect with jconsole, it wants to connect via some ephemeral ports...
15,093,889
4
1
null
2013-02-26 15:47:44.153 UTC
47
2020-02-05 21:26:10.527 UTC
2019-11-12 15:16:58.2 UTC
null
-1
null
290,541
null
1
68
java|ssh|jmx
62,103
<blockquote> <p>Is there any way to make jconsole only connect through 9999 or use a proxy? Is <a href="https://web.archive.org/web/20150202095729/https://blogs.oracle.com/jmxetc/entry/connecting_through_firewall_using_jmx" rel="noreferrer">this article</a> still the best solution? Or, am I missing something?</p> </b...
7,954,022
Javascript Regular Expression multiple match
<p>I'm trying to use javascript to do a regular expression on a url (window.location.href) that has query string parameters and cannot figure out how to do it. In my case, there is a query string parameter can repeat itself; for example "quality", so here I'm trying to match "quality=" to get an array with the 4 values...
7,954,044
2
1
null
2011-10-31 12:58:09.84 UTC
1
2020-04-03 05:39:12.13 UTC
2011-10-31 13:35:04.38 UTC
null
31,671
null
815,460
null
1
17
javascript|regex
46,740
<p>You can use a regex to do this.</p> <pre><code>var qualityRegex = /(?:^|[&amp;;])quality=([^&amp;;]+)/g, matches, qualities = []; while (matches = qualityRegex.exec(window.location.search)) { qualities.push(decodeURIComponent(matches[1])); } </code></pre> <p><a href="http://jsfiddle.net/alexdickson...
8,305,015
When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?
<p>Can <strong>/etc/hosts</strong> be used instead of <strong>resolver</strong> when using <strong>proxy_pass</strong>?</p> <p>I need to perform a proxy_pass to the same nginx machine. Is there a way to resolve the domains using the machine's /etc/hosts file instead of specifying a DNS server thru the "resolver" prope...
8,559,797
2
3
null
2011-11-29 02:14:12.553 UTC
15
2017-07-19 15:41:00.597 UTC
2011-11-30 03:07:18.217 UTC
null
255,523
null
255,523
null
1
37
url-rewriting|nginx|reverse-proxy
22,469
<p>You can get around this by installing <code>dnsmasq</code> and setting your resolver to <code>127.0.0.1</code>. Basically this uses your local DNS as a resolver, but it only resolves what it knows about (among those things is your <code>/etc/hosts</code>) and forwards the rest to your default DNS.</p>
5,370,164
disabling Devise registration for production environment only
<p>I am launching a beta site with a select group of users. I want to disable registration in the production environment only, and only for a short period of time (i.e. I don't want to nuke my registration altogether). I know I can simply hide the "sign up" link, but I suspect that hackers smarter than I can still use ...
8,291,318
4
6
null
2011-03-20 17:27:12.597 UTC
40
2014-03-09 03:33:55.763 UTC
2011-03-20 19:58:40.637 UTC
null
366,853
null
366,853
null
1
70
ruby-on-rails|devise|registration|production-environment
28,103
<p>Since others are having the problem I'm having (see my comments). Here is exactly how I fixed it. I used murphyslaw's idea. But you also need to make sure devise uses your new controller for the registration routing, or it won't do much for you.</p> <p>Here is my controller override:</p> <pre><code>class Regist...
4,924,365
SQL to return first two columns of a table
<p>Is there any <code>SQL</code> lingo to return JUST the first two <code>columns</code> of a table <strong>WITHOUT</strong> knowing the field <strong>names</strong>?</p> <p>Something like </p> <pre><code>SELECT Column(1), Column(2) FROM Table_Name </code></pre> <p>Or do I have to go the long way around and find out...
4,924,418
8
2
null
2011-02-07 17:26:41.46 UTC
3
2013-04-29 00:31:22.007 UTC
2013-04-29 00:31:22.007 UTC
null
135,152
null
584,776
null
1
12
sql|sql-server-2008
59,273
<p>You have to get the column names first. Most platforms support this:</p> <pre><code>select column_name,ordinal_position from information_schema.columns where table_schema = ... and table_name = ... and ordinal_position &lt;= 2 </code></pre>
41,511,568
Get the full route to current action
<p>I have a simple API with basic routing. It was setup using the default Visual Studio 2015 ASP.NET Core API template.</p> <p>I have this controller and action:</p> <pre><code>[Route("api/[controller]")] public class DocumentController : Controller { [HttpGet("info/{Id}")] public async Task&lt;Data&gt; Get(s...
41,512,292
4
3
null
2017-01-06 18:01:44.537 UTC
1
2021-06-30 01:13:37.807 UTC
2021-03-17 10:35:46.197 UTC
null
3,934,994
null
6,361,127
null
1
33
c#|asp.net-core|.net-core|asp.net-core-mvc
42,433
<p>You can get the complete requested url using the <strong>Request</strong> option (HttpRequest) in .Net Core.</p> <pre><code>var route = Request.Path.Value; </code></pre> <p>Your final code.</p> <pre><code>[Route("api/[controller]")] public class DocumentController : Controller { [HttpGet("info/{Id}")] pu...
12,381,408
Python: Split, strip, and join in one line
<p>I'm curious if their is some python magic I may not know to accomplish a bit of frivolity </p> <p>given the line:</p> <pre><code>csvData.append(','.join([line.split(":").strip() for x in L])) </code></pre> <p>I'm attempting to split a line on <code>:</code>, trim whitespace around it, and join on <code>,</code></...
12,381,435
3
0
null
2012-09-12 04:51:01.827 UTC
3
2012-09-12 15:36:27.61 UTC
2012-09-12 15:36:27.61 UTC
null
841,721
null
841,721
null
1
13
python|join|split|list-comprehension|trim
47,658
<pre><code>&gt;&gt;&gt; line = 'a: b :c:d:e :f:gh ' &gt;&gt;&gt; ','.join(x.strip() for x in line.split(':')) 'a,b,c,d,e,f,gh' </code></pre> <p>You can also do this:</p> <pre><code>&gt;&gt;&gt; line.replace(':',',').replace(' ','') 'a,b,c,d,e,f,gh' </code></pre>
12,153,255
How to view the nearest neighbors in R?
<p>Let me start by saying I have no experience with R, KNN or data science in general. I recently found <a href="http://kaggle.com" rel="noreferrer">Kaggle</a> and have been playing around with the <a href="http://www.kaggle.com/c/digit-recognizer" rel="noreferrer">Digit Recognition</a> competition/tutorial.</p> <p>I...
12,153,565
1
0
null
2012-08-28 05:27:01.403 UTC
10
2017-03-03 20:34:58.753 UTC
2017-03-03 20:34:58.753 UTC
null
769,871
null
226,897
null
1
15
r|kaggle
19,597
<p>1) You can get the nearest neighbors of a given row like so:</p> <pre><code>k &lt;- knn(train, test, labels, k = 10, algorithm="cover_tree") indices &lt;- attr(k, "nn.index") </code></pre> <p>Then if you want the indices of the 10 nearest neighbors to row 20 in the training set:</p> <pre><code>print(indices[20, ]...
12,051,440
Create a directory in Perl for a logfile if it does not exist
<p>I have a Perl script which takes a few arguments. It is executed like this:</p> <pre><code>exec myscript.pl --file=/path/to/input/file --logfile=/path/to/logfile/logfile.log </code></pre> <p>I have the following line in the script:</p> <pre><code>open LOGFILE, "&gt;&gt;$logFilePath" or die "Can't open '$logFilePa...
12,051,893
2
4
null
2012-08-21 08:58:59.897 UTC
3
2017-06-22 19:07:02.147 UTC
2017-06-22 19:07:02.147 UTC
null
63,550
null
1,546,927
null
1
17
perl|directory|mkdir
52,221
<p>Suppose you have the path to the logfile (which may or may not include the filename: <code>logfile.log</code>) in the variable <code>$full_path</code>. Then, you can create the respective directory tree if needed:</p> <pre><code>use File::Basename qw( fileparse ); use File::Path qw( make_path ); use File::Spec; my...
12,241,084
How to insert data into SQL Server
<p>What the problem on my coding? I cannot insert data to ms sql.. I'm using C# as front end and MS SQL as databases...</p> <pre><code>name = tbName.Text; userId = tbStaffId.Text; idDepart = int.Parse(cbDepart.SelectedValue.ToString()); string saveStaff = "INSERT into tbl_staff (staffName,userID,idDepartment) " + ...
12,241,114
3
4
null
2012-09-03 01:34:24.08 UTC
12
2021-04-13 09:30:39.49 UTC
2012-09-03 03:50:42.657 UTC
null
76,337
null
1,642,583
null
1
25
c#|sql|sql-server
205,618
<p>You have to set Connection property of Command object and use parametersized query instead of hardcoded SQL to avoid <a href="http://msdn.microsoft.com/en-us/library/ms161953%28v=sql.105%29.aspx" rel="noreferrer">SQL Injection</a>.</p> <pre><code> using(SqlConnection openCon=new SqlConnection("your_connection_Strin...
12,283,184
How is Elastic Net used?
<p>This is a beginner question on regularization with regression. Most information about Elastic Net and Lasso Regression online replicates the information from Wikipedia or the original 2005 paper by Zou and Hastie (Regularization and variable selection via the elastic net). </p> <p><strong><em>Resource for simple th...
12,294,769
3
3
null
2012-09-05 13:59:32.897 UTC
21
2020-08-26 12:35:40.963 UTC
null
null
null
null
1,406,413
null
1
28
python|statistics|machine-learning|regression|scikit-learn
20,361
<p>The documentation is lacking. I created a new <a href="https://github.com/scikit-learn/scikit-learn/issues/1118">issue</a> to improve it. As Andreas said the best resource is probably <a href="http://www-stat.stanford.edu/~tibs/ElemStatLearn/">ESL II</a> freely available online as PDF.</p> <p>To automatically tune ...
24,233,084
How do I add a tuple to a Swift Array?
<p>I'm trying to add a tuple (e.g., 2-item tuple) to an array.</p> <pre><code>var myStringArray: (String,Int)[]? = nil myStringArray += ("One", 1) </code></pre> <p>What I'm getting is: <br/></p> <blockquote> <p>Could not find an overload for '+=' that accepts the supplied arguments</p> </blockquote> <p><br/> <s...
25,838,682
8
9
null
2014-06-15 19:03:45.993 UTC
21
2018-03-27 03:25:05.06 UTC
2017-08-31 23:23:32.75 UTC
null
4,763,963
null
715,747
null
1
56
arrays|tuples|swift
65,976
<p>Since this is still the top answer on google for adding tuples to an array, its worth noting that things have changed slightly in the latest release. namely:</p> <p>when declaring/instantiating arrays; the type is now nested within the braces:</p> <pre><code>var stuff:[(name: String, value: Int)] = [] </code></pr...
37,001,004
Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings."
<p>Important notice:</p> <p>If you register for testing, go to your profile settings and to your <strong>interests</strong> add <strong>delete profile</strong>.</p> <p>Trying to login with Facebook to my <a href="http://openstrategynetwork.com/" rel="noreferrer">website</a>:</p> <p>I get the following error: </p> <...
37,009,374
17
6
null
2016-05-03 09:55:03.39 UTC
26
2022-07-28 22:57:52.923 UTC
2017-08-06 08:57:28.41 UTC
null
1,240,203
null
1,240,203
null
1
148
facebook|facebook-graph-api|meteor|oauth
296,309
<p>The login with Facebook button on your site is linking to:</p> <p><code>https://www.facebook.com/v2.2/dialog/oauth?client_id=1500708243571026&amp;redirect_uri=http://openstrategynetwork.com/_oauth/facebook&amp;display=popup&amp;scope=email&amp;state=eyJsb2dpblN0eWxlIjoicG9wdXAiLCJjcmVkZW50aWFsVG9rZW4iOiIwSXhEU05Xam...
8,870,982
How do I get a lognormal distribution in Python with Mu and Sigma?
<p>I have been trying to get the result of a <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html" rel="noreferrer">lognormal</a> distribution using <a href="http://www.scipy.org/" rel="noreferrer">Scipy</a>. I already have the Mu and Sigma, so I don't need to do any other prep work. ...
8,871,222
7
6
null
2012-01-15 15:47:59.6 UTC
20
2022-09-22 19:45:49.873 UTC
2017-05-23 12:32:35.72 UTC
null
-1
null
227,644
null
1
29
python|statistics|scipy
53,243
<p>It sounds like you want to instantiate a "frozen" distribution from known parameters. In your example, you could do something like:</p> <pre><code>from scipy.stats import lognorm stddev = 0.859455801705594 mean = 0.418749176686875 dist=lognorm([stddev],loc=mean) </code></pre> <p>which will give you a lognorm distr...
20,514,240
What's the difference setting Embed Interop Types true and false in Visual Studio?
<p>In Visual Studio, when adding one reference to the project, the properties window has an option <code>Embed Inteop Types</code>, should we set it to <code>True</code> or <code>False</code>? What's the difference?</p> <p>Since we have a lot of projects, among some of them, reference was set to <code>False</code>, ot...
20,515,311
2
6
null
2013-12-11 08:35:48.887 UTC
21
2021-12-26 15:46:19.797 UTC
2017-05-23 11:47:11.08 UTC
null
-1
null
3,022,229
null
1
135
c#|visual-studio
111,933
<p>This option was introduced in order to remove the need to deploy very large PIAs (Primary Interop Assemblies) for interop.</p> <p>It simply embeds the managed bridging code used that allows you to talk to unmanaged assemblies, but instead of embedding it all it only creates the stuff you actually use in code.</p> <p...
26,002,415
What does Haskell's <|> operator do?
<p>Going through Haskell's documentation is always a bit of a pain for me, because all the information you get about a function is often nothing more than just: <code>f a -&gt; f [a]</code> which could mean any number of things.</p> <p>As is the case of the <code>&lt;|&gt;</code> function.</p> <p>All I'm given is thi...
26,002,623
4
6
null
2014-09-23 18:39:18.953 UTC
20
2021-02-22 04:55:40.46 UTC
2021-02-22 04:55:40.46 UTC
null
2,751,851
null
1,351,298
null
1
74
haskell|applicative|alternative-functor
17,548
<p>Typically it means "choice" or "parallel" in that <code>a &lt;|&gt; b</code> is either a "choice" of <code>a</code> or <code>b</code> or <code>a</code> and <code>b</code> done in parallel. But let's back up.</p> <p>Really, there is no practical meaning to operations in typeclasses like <code>(&lt;*&gt;)</code> or <...
10,895,331
How to check multiple radio button, radio buttons having same name?
<p>I want to check multiple radio buttons, all radio buttons having same name but different ids.</p> <p>Here is my html code,</p> <pre><code> &lt;span style="float:left;margin:0 0 0 10px"&gt;Proactivity&lt;/span&gt; &lt;label for="q11" style="width:auto;margin:0 60px 0 0;padding:0;"&gt;&lt;input type="radio" ...
10,895,342
6
2
null
2012-06-05 10:06:18.043 UTC
1
2015-12-11 12:22:27.827 UTC
2014-06-25 17:11:23.243 UTC
null
2,246,344
null
1,103,302
null
1
10
html|radio-button
67,069
<p>You can't. Radio buttons are there for a <strong>single choice</strong>. For multiple choices, you need checkboxes.</p>