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
20,398,799
Find K nearest Points to Point P in 2-dimensional plane
<p><em><strong>Source: AMAZON INTERVIEW QUESTION</em></strong></p> <p>Given a <strong>point P and other N points</strong> in two dimensional space, find <strong>K points</strong> out of the N points which are <strong>nearest</strong> to P.</p> <p>What is the most optimal way to do this ?</p> <p>This <a href="http://...
20,399,027
9
4
null
2013-12-05 11:28:25.327 UTC
13
2021-01-26 15:48:33.593 UTC
2013-12-05 11:34:03.46 UTC
null
2,426,101
null
2,426,101
null
1
26
performance|algorithm|math|language-agnostic
35,335
<p><strong>Solution 1</strong> make heap of size K and collect points by minimal distance <strong>O(NLogK)</strong> complexity.</p> <p><strong>Solution 2</strong>: Take and array of size N and Sort by distance. Should be used QuickSort (Hoare modification). As answer take first K points. This is too NlogN complexity b...
20,540,831
Java object analogue to R data.frame
<p>I really like data.frames in R because you can store different types of data in one data structure and you have a lot of different methods to modify the data (add column, combine data.frames,...), it is really easy to extract a <em>subset</em> from the data,...</p> <p>Is there any Java library available which have ...
32,481,425
6
6
null
2013-12-12 10:24:08.303 UTC
11
2018-08-16 00:45:10.98 UTC
null
null
null
null
1,054,451
null
1
46
java|r|dataframe
26,456
<p>I have just open-sourced a first draft version of <a href="https://github.com/netzwerg/paleo" rel="noreferrer">Paleo</a>, a Java 8 library which offers data frames based on typed columns (including support for primitive values). Columns can be created programmatically (through a simple builder API), or imported from...
20,886,911
PHP: self:: vs parent:: with extends
<p>I'm wondering what is the difference between using self:: and parent:: when a static child class is extending static parent class e.g.</p> <pre><code>class Parent { public static function foo() { echo 'foo'; } } class Child extends Parent { public static function func() { self::foo(); ...
20,887,205
2
6
null
2014-01-02 16:11:42.023 UTC
13
2014-01-02 17:04:38.99 UTC
null
null
null
null
1,509,200
null
1
26
php|class|static|parent|self
25,990
<pre><code> Child has foo() Parent has foo() self::foo() YES YES Child foo() is executed parent::foo() YES YES Parent foo() is executed self::foo() YES NO Child foo() is executed parent...
10,995,972
Get validation error messages without saving
<pre><code>Post :belongs_to :user User :has_many :posts </code></pre> <p>In my signup workflow they draft a Post first, then on the next page enter their User information to signup.</p> <pre><code># intermediate step, validate that Post is valid before moving on to User creation # posts_controller: @post = Post...
10,996,090
2
0
null
2012-06-12 11:44:59.813 UTC
3
2012-06-12 11:51:46.613 UTC
null
null
null
null
811,111
null
1
32
ruby-on-rails|ruby-on-rails-3
24,283
<p>If I understand your question correctly you want to get the errors without saving the model?</p> <p>That is exactly what is happening. <code>@post.valid?</code></p> <p>will return true or false depending on whether there are any errors. If there are errors. they will be added to <code>@post.errors</code>hash. </p>...
10,987,444
How to use global variable in node.js?
<p>For example I want to use custom logger:</p> <pre><code>logger = require('basic-logger'), logger.setLevel('info') var customConfig = { showMillis: true, showTimestamp: true } var log = new logger(customConfig) </code></pre> <p>How to use this logger in other modules instead of console.log ?</p>
10,987,543
7
4
null
2012-06-11 20:59:17.603 UTC
18
2019-07-09 12:09:56.933 UTC
2012-06-11 21:16:06.427 UTC
null
1,407,156
null
418,507
null
1
101
node.js
264,890
<p>Most people advise against using global variables. If you want the same logger class in different modules you can do this</p> <p>logger.js</p> <pre><code> module.exports = new logger(customConfig); </code></pre> <p>foobar.js</p> <pre><code> var logger = require('./logger'); logger('barfoo'); </code></pre> <...
48,201,729
Difference between np.dot and np.multiply with np.sum in binary cross-entropy loss calculation
<p>I have tried the following code but didn't find the difference between <strong>np.dot</strong> and <strong>np.multiply with np.sum</strong> </p> <p>Here is <strong>np.dot</strong> code</p> <pre><code>logprobs = np.dot(Y, (np.log(A2)).T) + np.dot((1.0-Y),(np.log(1 - A2)).T) print(logprobs.shape) print(logprobs) cos...
48,202,241
4
7
null
2018-01-11 07:21:47.19 UTC
19
2021-02-22 09:35:59.09 UTC
2019-05-08 18:41:35.553 UTC
null
2,956,066
null
4,539,906
null
1
34
python|numpy|neural-network|sum|difference
55,812
<p>What you're doing is calculating the <a href="https://en.wikipedia.org/wiki/Cross_entropy#Cross-entropy_loss_function_and_logistic_regression" rel="nofollow noreferrer"><strong>binary cross-entropy loss</strong></a> which measures how bad the predictions (here: <code>A2</code>) of the model are when compared to the ...
12,965,296
How to get maximum document scrolltop value
<p>I am making some plugin and I need to get maximum <code>scrollTop</code> value of the document. Maximum <code>scrollTop</code> value is <code>2001</code> , but <code>$(document).height()</code> returns <code>2668</code> and <code>$('body')[0].scrollHeight</code> gives me <code>undefined</code>.</p> <p>How to get <c...
12,965,383
5
6
null
2012-10-18 23:30:43.08 UTC
4
2021-06-26 04:40:22.38 UTC
2012-10-18 23:44:48.617 UTC
null
498,031
null
855,705
null
1
21
javascript|jquery|scrolltop
45,883
<p>The code in your comments should work:</p> <pre><code>$(document).height() - $(window).height() </code></pre> <p>Here's an example that alerts when you scroll to the maximum scroll position: <a href="http://jsfiddle.net/DWn7Z/">http://jsfiddle.net/DWn7Z/</a></p>
12,750,864
Temporary e-mail accounts for integration tests
<p>I would like to write some integration tests which verify if user receive registration confirmation e-mails.</p> <p>Ideally, for this purpose I would like:</p> <ol> <li>Create temporary e-mail account.</li> <li>Pass it in registration form.</li> <li>Check if we receive e-mail.</li> <li>Delete e-mail account.</li> ...
13,053,612
5
4
null
2012-10-05 17:03:24.763 UTC
10
2020-10-13 23:10:48.26 UTC
null
null
null
null
341,181
null
1
36
email|testing|integration-testing
56,625
<p><a href="http://mailinator.com">http://mailinator.com</a> supports POP3.</p> <p>Connect to the server via POP3 with any username and check e-mail.</p>
13,013,781
How to draw a rectangle over a specific region in a matplotlib graph
<p>I have a graph, computed from some data, drawn in matplotlib. I want to draw a rectangular region around the global maximum of this graph. I tried <code>plt.axhspan,</code> but the rectangle doesn't seem to appear when I call <code>plt.show()</code></p> <p>So, how can a rectangular region be drawn onto a matplotl...
13,014,729
2
0
null
2012-10-22 14:39:00.767 UTC
6
2021-10-23 17:58:19.67 UTC
null
null
null
null
1,084,573
null
1
43
python|matplotlib
59,972
<p>The most likely reason is that you used data units for the x arguments when calling axhspan. From <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.axhspan.html" rel="nofollow noreferrer">the function's docs</a> (my emphasis):</p> <blockquote> <p>y coords are in data units and <em>x coords are ...
12,709,074
How do you explicitly set a new property on `window` in TypeScript?
<p>I setup global namespaces for my objects by explicitly setting a property on <code>window</code>.</p> <pre><code>window.MyNamespace = window.MyNamespace || {}; </code></pre> <p>TypeScript underlines <code>MyNamespace</code> and complains that:</p> <blockquote> <p>The property 'MyNamespace' does not exist on val...
12,709,880
29
1
null
2012-10-03 13:01:15.793 UTC
178
2022-06-29 10:02:33.567 UTC
null
null
null
null
31,308
null
1
1,076
typescript
627,061
<p>I just found the answer to this in <a href="https://stackoverflow.com/a/12703866/31308">another Stack Overflow question's answer</a>.</p> <pre><code>declare global { interface Window { MyNamespace: any; } } window.MyNamespace = window.MyNamespace || {}; </code></pre> <p>Basically, you need to extend the existin...
12,731,428
jQuery "Does not have attribute" selector?
<p>I can find a div that has an attribute like so:</p> <pre><code>$('.funding-plan-container[data-timestamp]') </code></pre> <p>But if I try to find a div that does not have that attribute, I get an error - my code is:</p> <pre><code>$('.funding-plan-container[!data-timestamp]') </code></pre> <p>Is there a "does no...
12,731,439
3
0
null
2012-10-04 16:13:47.49 UTC
10
2020-05-29 15:10:46.067 UTC
null
null
null
null
726,221
null
1
158
javascript|jquery
89,121
<p>Use the <a href="http://api.jquery.com/not-selector/" rel="noreferrer"><code>:not()</code></a> selector.</p> <pre><code>$('.funding-plan-container:not([data-timestamp])') </code></pre> <hr> <p>This, by the way, is a valid <a href="http://www.w3.org/TR/selectors-api/" rel="noreferrer"><em>Selectors API</em></a> se...
17,075,577
Database Design with Change History
<p>I am looking to design a database that keeps track of every set of changes so that I can refer back to them in the future. So for example:</p> <pre><code>Database A +==========+========+==========+ | ID | Name | Property | 1 Kyle 30 </code></pre> <p>If I change the row's 'property' fiel...
17,075,789
4
4
null
2013-06-12 21:21:05.773 UTC
22
2020-03-17 23:20:29.517 UTC
2019-08-02 14:30:51.543 UTC
null
1,828,296
null
1,109,360
null
1
39
sql|postgresql|change-tracking
28,497
<p>One way is to have a <code>MyTableNameHistory</code> for every table in your database, and make its schema identical to the schema of table <code>MyTableName</code>, except that the Primary Key of the History table has one additional column named <code>effectiveUtc</code> as a DateTime. For example, if you have a t...
16,824,355
Logging in Ruby on Rails in Production Mode
<p>I would like to view some variables in controller, it tried the following:</p> <p><code>Rails.logger.debug "Year: #{Time.now.year}"</code></p> <p><code>puts "Year: #{Time.now.year}, Month: #{@month}"</code></p> <p>where can I see the output for Logger or Puts in production mode? Do I need so set something up to ...
16,832,519
3
0
null
2013-05-29 21:41:24.237 UTC
8
2021-10-12 14:54:41.417 UTC
2014-04-14 19:29:40.58 UTC
null
2,800,417
null
1,135,541
null
1
51
ruby-on-rails|logging|production
66,893
<p>The normal log level in production is <code>info</code>, so <code>debug</code> logs are not shown.<br> Change your logging to</p> <pre><code>Rails.logger.info "Year: #{Time.now.year}" </code></pre> <p>to show it in <code>production.log</code>.</p> <p>Alternatively (but not a good idea) you can raise the logging l...
17,095,324
Fastest way to determine if an integer is between two integers (inclusive) with known sets of values
<p>Is there a faster way than <code>x &gt;= start &amp;&amp; x &lt;= end</code> in C or C++ to test if an integer is between two integers?</p> <p><em>UPDATE</em>: My specific platform is iOS. This is part of a box blur function that restricts pixels to a circle in a given square.</p> <p><em>UPDATE</em>: After trying ...
17,095,534
7
31
2013-08-19 15:24:53.37 UTC
2013-06-13 19:21:42.93 UTC
199
2021-02-16 02:47:53.837 UTC
2017-05-23 12:09:54.79 UTC
null
-1
null
56,079
null
1
409
c++|c|performance|math
82,296
<p>There's an old trick to do this with only one comparison/branch. Whether it'll really improve speed may be open to question, and even if it does, it's probably too little to notice or care about, but when you're only starting with two comparisons, the chances of a huge improvement are pretty remote. The code looks l...
4,380,054
Calling Clojure from .NET
<p>I have been spending some time playing with Clojure-CLR. My REPL is working, I can call .NET classes from Clojure, but I have not been able to figure out calling compiled Clojure dlls from C# classes. </p> <p>I have been trying to adapt the java example found <a href="https://stackoverflow.com/questions/2181774/cal...
4,394,405
2
0
null
2010-12-07 18:11:36.07 UTC
12
2013-07-26 19:00:50.397 UTC
2017-05-23 12:17:00.903 UTC
null
-1
null
388,187
null
1
21
.net|clojure|clojureclr
3,742
<p>I was able to get it to work doing the following:</p> <p>First I changed your code a bit, I was having trouble with the namespace and the compiler thinking the dots were directories. So I ended up with this.</p> <pre><code>(ns hello (:require [clojure.core]) (:gen-class :methods [#^{:static true} [output [...
10,037,887
How can I put titles in ViewPager using fragments?
<p>I am using ViewPager to allow user to swipe between fragments.</p> <p>How can I add a the title of each fragment to the screen?</p> <pre><code>package com.multi.andres; import java.util.List; import java.util.Vector; import com.viewpagerindicator.TitlePageIndicator; import com.viewpagerindicator.TitleProvider; ...
10,039,279
4
1
null
2012-04-06 00:39:14.157 UTC
11
2016-02-15 08:26:36.16 UTC
2014-12-13 15:21:09.27 UTC
null
844,882
null
1,314,019
null
1
7
java|android|android-fragments|android-viewpager|android-fragmentactivity
25,790
<p>You can also use Jake Wharton's <a href="http://viewpagerindicator.com/" rel="noreferrer">ViewPagerIndicator</a> library to get the desired effect. Davek804's answer works too, but it requires you to reference the entire ActionBarSherlock library, which isn't as preferable if you only need a <code>ViewPager</code> t...
9,906,571
Semantic Grid with Bootstrap + LESS Mixins ¿ HOW?
<p>Twitter bootstrap documentation talks about three mixins to generate grid systems:</p> <pre><code>.container-fixed(); #grid &gt; .core(); #grid &gt; .fluid(); </code></pre> <p>I know how to setup the page to use bootstrap and less... But I don't know how to use the grid system semantically. The documentation says ...
11,569,397
1
1
null
2012-03-28 11:30:05.127 UTC
9
2012-08-25 04:04:47.64 UTC
2012-03-28 15:55:45.11 UTC
null
1,267,307
null
1,092,437
null
1
9
css|twitter|twitter-bootstrap|less|mixins
5,207
<p>In navbar.less of bootstrap you will find the following.</p> <h1>grid and .core are used to namespace the .span()</h1> <pre><code>.navbar-fixed-top .container, .navbar-fixed-bottom .container { #grid &gt; .core &gt; .span(@gridColumns); } </code></pre> <p>In cases where you want to keep &quot;span3&quot; etc out of ...
10,061,597
Creating materialized view that refreshes every 5 min
<p>I created a materialized view that refreshed every 5 min but when I do insert and perform select on materialized view I get same old data? Do I need to refresh manually?</p> <pre><code>CREATE MATERIALIZED VIEW MVW_TEST REFRESH FORCE ON DEMAND START WITH TO_DATE('01-01-2009 00:01:00', 'DD-MM-YYYY HH24:MI:SS') NEXT ...
10,062,283
2
3
null
2012-04-08 08:51:24.957 UTC
9
2017-04-20 12:30:22.543 UTC
2012-04-08 09:15:01.7 UTC
null
2,214,674
null
2,214,674
null
1
12
oracle|oracle11g
89,373
<p>I have demonstrated in steps where a materialized view refresh after every <code>one minute</code> ,for having a mv which refresh after 5 minute use <code>next(sysdate+5/1440)</code></p> <p>Step1: </p> <pre><code>Create table temp (A int); </code></pre> <p>Step2:</p> <pre><code>Create Materialized view temp_...
10,087,782
Error: Specified cast is not valid. (SqlManagerUI)
<p>I have a backup from database in SQL Server 2008 R2. When I want to restore this backup to SQL Server, I get this error: "Error: Specified cast is not valid. (SqlManagerUI)" How to I resolve this error? Thanks.</p>
10,125,525
4
1
null
2012-04-10 11:22:05.733 UTC
2
2017-08-17 20:05:08.91 UTC
null
null
null
null
492,361
null
1
16
sql-server-2008-r2|database-restore
121,954
<p>There are some <a href="http://social.msdn.microsoft.com/forums/en-us/sqlsetupandupgrade/thread/071DA5BB-32C5-4C3F-9378-7E67C5DF2D44" rel="noreferrer">funnies</a> restoring old databases into SQL 2008 via the guy; have you tried doing it via TSQL ?</p> <pre><code>Use Master Go RESTORE DATABASE YourDB FROM DISK = 'C...
10,217,489
methods in foreach and for loops in java
<p>My question is regarding optimization in java using the Android compiler. Will map.values() in the following be called every iteration, or will the Android compiler optimize it out.</p> <pre><code>LinkedHashMap&lt;String, Object&gt; map; for (Object object : map.values()) { //do something with object } </code>...
10,217,534
1
4
null
2012-04-18 20:32:27.563 UTC
4
2016-07-17 22:19:32 UTC
2012-04-18 21:02:54.937 UTC
null
758,074
null
758,074
null
1
28
java|android
87,566
<p>In the first example, <code>map.values()</code> will be evaluated once. According to the <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.14.2" rel="noreferrer">Section 14.4.2 of the Java Language Specification</a>, it is equivalent to:</p> <pre><code>for (Iterator&lt;Object&gt; i = map....
10,225,727
Should ConditionalWeakTable<TKey, TValue> be used for non-compiler purposes?
<p>I've recently come across the <a href="http://msdn.microsoft.com/en-us/library/dd287757.aspx" rel="noreferrer"><code>ConditionalWeakTable&lt;TKey,TValue&gt;</code></a> class in my search for an <code>IDictionary</code> which uses weak references, as suggested in answers <a href="https://stackoverflow.com/questions/2...
10,267,942
1
0
null
2012-04-19 10:00:25.85 UTC
8
2016-06-09 13:40:43.29 UTC
2017-05-23 10:34:12.23 UTC
null
-1
null
177,117
null
1
33
c#|garbage-collection|clr|weak-references|ephemeron
5,206
<p>I don't see anything wrong with using <code>ConditionalWeakTable</code>. If you need ephemerons, you pretty much have no other choice.</p> <p>I don't think future .NET versions will be a problem - even if only compilers would use this class, Microsoft still couldn't change it without breaking compatibility with exi...
10,021,847
For loop in multidimensional javascript array
<p>Since now, I'm using this loop to iterate over the elements of an array, which works fine even if I put objects with various properties inside of it.</p> <pre><code>var cubes[]; for (i in cubes){ cubes[i].dimension cubes[i].position_x ecc.. } </code></pre> <p>Now, let's suppose cubes[] is declared th...
10,021,901
8
0
null
2012-04-05 02:22:11.003 UTC
30
2022-01-18 20:33:45 UTC
2022-01-18 20:33:45 UTC
null
215,552
null
1,307,020
null
1
49
javascript|loops|multidimensional-array
210,183
<p>You can do something like this:</p> <pre><code>var cubes = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]; for(var i = 0; i &lt; cubes.length; i++) { var cube = cubes[i]; for(var j = 0; j &lt; cube.length; j++) { display("cube[" + i + "][" + j + "] = " + cube[j]); } } </code></pre> <p>Working jsF...
9,666,471
jQuery advantages/differences in .trigger() vs .click()
<p>In terms of performance, what are the gains (or just differences) between:</p> <pre><code>$('.myEl').click(); </code></pre> <p>and </p> <pre><code>$('.myEl').trigger('click'); </code></pre> <p>Are there any at all?</p>
9,666,577
4
0
null
2012-03-12 11:49:47.777 UTC
11
2015-06-16 19:52:41.81 UTC
null
null
null
null
478,144
null
1
78
jquery
26,877
<p><a href="http://james.padolsey.com/jquery/#v=1.7.2&amp;fn=$.fn.click" rel="noreferrer">This is the code for the <code>click</code> method</a>: </p> <pre><code>jQuery.fn.click = function (data, fn) { if (fn == null) { fn = data; data = null; } return arguments.length &gt; 0 ? this.on("cl...
9,679,375
How can I run an EXE file from my C# code?
<p>I have an EXE file reference in my C# project. How do I invoke that EXE file from my code?</p>
9,679,614
4
0
null
2012-03-13 06:35:57.36 UTC
47
2021-08-31 13:21:47.817 UTC
2021-08-31 13:21:47.817 UTC
null
63,550
null
969,188
null
1
210
c#|.net
410,409
<pre><code>using System.Diagnostics; class Program { static void Main() { Process.Start("C:\\"); } } </code></pre> <p>If your application needs cmd arguments, use something like this:</p> <pre><code>using System.Diagnostics; class Program { static void Main() { LaunchCommandLineA...
8,246,520
Does Python's os.system() wait for an end of the process?
<p>The <a href="http://docs.python.org/library/os.html#os.system">Python manual</a> says nothing about whether <code>os.system("cmd")</code> waits or not for a process to end:</p> <p>To quote the manual:</p> <blockquote> <p>Execute the command (a string) in a subshell.</p> </blockquote> <p>It looks like it does wa...
8,246,562
3
1
null
2011-11-23 17:24:09.103 UTC
1
2021-02-12 11:21:57.783 UTC
2011-11-23 20:03:28.72 UTC
null
102,441
Adobe
788,700
null
1
30
python
38,197
<p>Yes it does. The return value of the call is the exit code of the subprocess.</p>
7,891,697
Numpy Adding two vectors with different sizes
<p>If I have two numpy arrays of different sizes, how can I superimpose them.</p> <pre><code>a = numpy([0, 10, 20, 30]) b = numpy([20, 30, 40, 50, 60, 70]) </code></pre> <p>What is the cleanest way to add these two vectors to produce a new vector (20, 40, 60, 80, 60, 70)?</p> <p>This is my generic question. For back...
7,891,889
3
1
null
2011-10-25 15:28:03.683 UTC
6
2020-07-02 00:55:57.343 UTC
2011-10-25 15:41:44.07 UTC
null
53,850
null
454,217
null
1
36
python|numpy|linear-algebra
35,629
<p>This could be what you are looking for</p> <pre><code>if len(a) &lt; len(b): c = b.copy() c[:len(a)] += a else: c = a.copy() c[:len(b)] += b </code></pre> <p>basically you copy the longer one and then add in-place the shorter one</p>
11,698,935
Jquery element+class selector performance
<p>I was hoping <code>$('#childDiv2 .txtClass')</code> or <code>$('#childDiv2 input.txtClass')</code> perform better when selecting <code>&lt;input type="text" id="txtID" class="txtClass"/&gt;</code> element. But according to this <a href="http://jsperf.com/selectors-perf/3" rel="noreferrer">performance analysis</a> <c...
11,699,147
4
3
null
2012-07-28 06:45:04.73 UTC
21
2013-10-16 13:56:40.737 UTC
2012-07-28 07:37:48.447 UTC
null
106,224
null
857,956
null
1
30
jquery|jquery-selectors|performance
61,762
<p>Modern browsers expose a very efficient <a href="https://developer.mozilla.org/en/DOM/document.getElementsByClassName" rel="noreferrer">getElementsByClassName()</a> method that returns the elements having a given class. That's why a single class selector is faster in your case.</p> <p>To elaborate on your examples:...
11,989,746
Escape special chars in RegEx?
<p>I have a form, that sends the contents of a text field to my Rails application and I have to generate a regular expression of this string. </p> <p>I tried it like this:</p> <pre><code>regex = /#{params[:text]}/ </code></pre> <p>In general this is working, but if brackets or special characters are contained in th...
11,989,938
2
0
null
2012-08-16 14:44:49.327 UTC
4
2018-01-03 08:59:33.957 UTC
2012-08-16 14:59:04.597 UTC
null
128,421
null
1,414,540
null
1
32
ruby-on-rails|ruby|regex
13,935
<p>You should use <a href="http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-c-escape" rel="noreferrer"><code>Regexp.escape</code></a></p> <pre><code>regex = /#{Regexp.escape(params[:text])}/ # in rails models/controllers with mongoid use: # ::Regexp.escape(params[:text]) instead. ([more info][2]) </code></pre>
11,587,119
Is this a web page or an image?
<p><a href="http://lcamtuf.coredump.cx/squirrel/" rel="noreferrer">http://lcamtuf.coredump.cx/squirrel/</a></p> <p>According to the author, </p> <blockquote> <p>This is an embedded landing page for an image. You can link to this URL and get the HTML document you are viewing right now (soon to include essential ...
11,587,183
2
4
null
2012-07-20 21:23:50.353 UTC
25
2015-03-06 16:52:40.03 UTC
2015-03-06 16:52:40.03 UTC
null
616,443
null
616,443
null
1
46
html|image|encoding
4,604
<p>The file you linked is a polyglot - a combination of languages. It can be read and understood as <strong>both</strong> an image and an HTML file. It's a simple trick. If you look at the HTML source you can see this at the top:</p> <pre><code>ÿØÿà </code></pre> <p>A quick Google shows this looks like a JPEG header....
11,976,223
How to deal with missing src/test/java source folder in Android/Maven project?
<p>I'm not very experienced with Maven in combination with Android yet, so I followed <a href="http://rgladwell.github.com/m2e-android/" rel="noreferrer">these</a> instructions to make a new Android project. When the project has been created, I get the following error message: </p> <blockquote> <p>Project 'xxx-1.0-S...
11,978,134
10
4
null
2012-08-15 19:51:58.51 UTC
12
2021-12-18 20:46:16.333 UTC
2021-12-18 20:46:16.333 UTC
null
1,824,361
null
319,773
null
1
49
java|android|eclipse|maven|m2eclipse
136,733
<p>I realise this annoying thing too since latest m2e-android plugin upgrade (version 0.4.2), it happens in both new project creation and existing project import (if you don't use src/test/java).</p> <p>It looks like m2e-android (or perhaps m2e) now always trying to add <code>src/test/java</code> as a source folder, r...
11,525,717
When does the App Engine scheduler use a new thread vs. a new instance?
<p>If I set <code>threadsafe: true</code> in my <code>app.yaml</code> file, what are the rules that govern when a new instance will be created to serve a request, versus when a new thread will be created on an existing instance?</p> <p>If I have an app which performs something computationally intensive on each request...
11,882,719
3
2
null
2012-07-17 15:23:33.387 UTC
12
2012-08-09 16:45:00.83 UTC
null
null
null
null
23,786
null
1
60
python|google-app-engine
2,840
<p>The following set of rules are currently used to determine if a given instance can accept a new request:</p> <pre><code>if processing more than N concurrent requests (today N=10): false elif exceeding the soft memory limit: false elif exceeding the instance class CPU limit: false elif warming up: false else true </...
11,930,996
PGError: ERROR: permission denied for relation (when using Heroku)
<p>I've recently gone through the database migration process as outlined here:</p> <p><a href="https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-postgres" rel="noreferrer">https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-postgres</a></p> <p>Now I'm seeing a n...
11,935,926
6
1
null
2012-08-13 08:56:45.63 UTC
13
2019-02-28 01:54:23.193 UTC
2014-02-05 19:47:46.707 UTC
null
2,229,277
null
492,242
null
1
78
database|postgresql|heroku|permissions
37,880
<p>I had a similar problem but the root cause was that my app was pointing to the old dev database which had exceeded it's limit of 10,000 rows.</p> <p>Although I created a new Basic db and backed everything up, the app was still pointing the old dev DB.</p> <pre><code>heroku pg:info </code></pre> <p>Check to see th...
3,984,019
MySQL user-defined variable in WHERE clause
<p>I want to know if there is a way to use a user-defined variable in <code>WHERE</code> clause, as in this example:</p> <pre><code>SELECT id, location, @id := 10 FROM songs WHERE id = @id </code></pre> <p>This query runs with no errors but doesn't work as expected.</p>
6,021,738
4
2
null
2010-10-21 03:14:45.467 UTC
1
2016-12-01 11:32:13.697 UTC
2012-04-16 12:16:26.513 UTC
null
225,037
null
222,758
null
1
25
mysql|where-clause
42,876
<p>Not far from what Mike E. proposed, but one statement:</p> <pre><code>SELECT id, location FROM songs, ( SELECT @id := 10 ) AS var WHERE id = @id; </code></pre> <p>I used similar queries to emulate window functions in MySQL. E.g. <a href="http://explainextended.com/2009/03/05/row-sampling/" rel="noreferrer">Row sam...
3,289,198
Custom attribute on property - Getting type and value of attributed property
<p>I have the following custom attribute, which can be applied on properties:</p> <pre><code>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class IdentifierAttribute : Attribute { } </code></pre> <p>For example:</p> <pre><code>public class MyClass { [Identifier()] public string Nam...
3,289,235
4
0
null
2010-07-20 10:51:49.987 UTC
11
2019-11-27 10:55:33.057 UTC
2014-06-12 17:45:42.543 UTC
null
1,804,678
null
131,809
null
1
37
c#|.net|custom-attributes
77,932
<p>Something like the following,, this will use only the first property it comes accross that has the attribute, of course you could place it on more than one..</p> <pre><code> public object GetIDForPassedInObject(T obj) { var prop = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance) ...
3,840,784
Appending turns my list to NoneType
<p>In Python Shell, I entered: </p> <pre><code>aList = ['a', 'b', 'c', 'd'] for i in aList: print(i) </code></pre> <p>and got </p> <pre><code>a b c d </code></pre> <p>but when I tried: </p> <pre><code>aList = ['a', 'b', 'c', 'd'] aList = aList.append('e') for i in aList: print(i) </co...
3,840,802
4
0
null
2010-10-01 15:45:13 UTC
7
2021-07-14 10:57:25.683 UTC
2010-10-01 15:52:33.863 UTC
null
12,855
null
460,847
null
1
37
python|mutators
72,068
<p><code>list.append</code> is a method that modifies the existing list. It doesn't return a new list -- it returns <code>None</code>, like most methods that modify the list. Simply do <code>aList.append('e')</code> and your list will get the element appended.</p>
3,580,802
How to use git (git config --global)?
<p>The <a href="http://www.pragprog.com/titles/pg_git/pragmatic-guide-to-git" rel="noreferrer">Pragmatic Guide to GIT</a> has the following "Git uses both to calculate the commit ID—a SHA-111 hash—that identifies each commit." in page 21.</p> <p>And in page 22, I can use the following command to 'Configure Git to know...
3,580,841
4
1
null
2010-08-27 01:53:08.877 UTC
5
2018-09-13 11:43:11.09 UTC
2010-08-27 02:20:25.653 UTC
null
260,127
null
260,127
null
1
43
git|configuration
68,764
<p>Not sure where "smcho" comes from, but the setting to set your name is <code>user.name</code>:</p> <pre><code>git config --global user.name "Your Name" </code></pre> <p>You can set your e-mail address too:</p> <pre><code>git config --global user.email "name@domain.example" </code></pre> <p>I guess the reason it ...
3,643,580
Is there a portable C compiler for windows?
<p>I want to carry one in my flash drive and run it. </p> <p>Thanks</p>
3,643,595
6
0
null
2010-09-04 18:59:37.287 UTC
6
2017-08-01 13:36:25.607 UTC
null
null
null
null
88,447
null
1
16
c|windows|compiler-construction|portability
48,211
<p><a href="http://www.mingw.org/" rel="noreferrer">MinGW</a> is a pretty good one and can be easily copied to a flash drive. Admittedly this is a port of GCC, but it works well in Windows. A drawback of this compiler is that it does not understand some of the specific Microsoft <a href="http://msdn.microsoft.com/en-...
3,494,115
What does $_ mean in PowerShell?
<p>I've seen the following a lot in PowerShell, but what does it do exactly?</p> <pre><code>$_ </code></pre>
3,494,138
7
1
null
2010-08-16 14:33:33.923 UTC
58
2022-02-22 14:00:19.43 UTC
2016-02-01 19:54:15.27 UTC
null
63,550
null
17,744
null
1
280
powershell
301,349
<p>This is the variable for the current value in the pipe line, which is called <code>$PSItem</code> in Powershell 3 and newer. </p> <pre><code>1,2,3 | %{ write-host $_ } </code></pre> <p>or</p> <pre><code>1,2,3 | %{ write-host $PSItem } </code></pre> <p>For example in the above code the <code>%{}</code> block i...
3,515,264
Can I change the Android startActivity() transition animation?
<p>I am starting an activity and would rather have a alpha fade-in for <code>startActivity()</code>, and a fade-out for the <code>finish()</code>. How can I go about this in the Android SDK?</p>
3,515,625
10
2
null
2010-08-18 18:16:33.777 UTC
37
2021-12-03 12:46:29.81 UTC
null
null
null
null
69,634
null
1
120
android|animation|fade|transition
154,739
<p>In the same statement in which you execute finish(), execute your animation there too. Then, in the new activity, run another animation. See this code:</p> <p>fadein.xml</p> <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true"&gt; &lt;alpha android:fromA...
3,453,085
What is :: (double colon) in Python when subscripting sequences?
<p>I know that I can use something like <code>string[3:4]</code> to get a substring in Python, but what does the 3 mean in <code>somesequence[::3]</code>?</p>
3,453,103
11
3
null
2010-08-10 20:21:53.817 UTC
105
2021-07-22 21:39:48.077 UTC
2017-02-03 23:08:27.097 UTC
null
15,168
null
414,064
null
1
370
python|syntax|slice
310,879
<p>it means 'nothing for the first argument, nothing for the second, and jump by three'. It gets every third item of the sequence sliced. <a href="http://docs.python.org/release/2.3.5/whatsnew/section-slices.html">Extended slices</a> is what you want. New in Python 2.3</p>
8,330,838
VBA Date as integer
<p>is there a way to get the underlying integer for <code>Date</code> function in VBA ? I'm referring to the integer stored by Excel to describe dates in memory in terms of number of days (when time is included it can be a float then I guess). I'm only interest in the integer part though. Is there just another function...
8,330,916
4
0
null
2011-11-30 18:16:43.997 UTC
2
2020-07-06 10:15:41.483 UTC
2020-07-06 10:15:41.483 UTC
null
6,296,561
null
1,029,944
null
1
24
excel|vba|date|datetime
180,879
<p>Date is not an Integer in VB(A), it is a Double.</p> <p>You can get a Date's value by passing it to <code>CDbl()</code>.</p> <pre class="lang-vb prettyprint-override"><code>CDbl(Now()) ' 40877.8052662037 </code></pre> <p>From the <a href="https://docs.microsoft.com/en-us/office/troubleshoot/excel/1900-and-1...
8,118,741
CSS Font "Helvetica Neue"
<p>I often see the websites using font "Helvetica Neue". Is this font safe to use, like eg. Arial? Or do the browsers have trouble rendering it or not many machines have this font? Thanks.</p>
8,118,772
5
2
null
2011-11-14 07:57:33.903 UTC
18
2020-07-12 16:15:08.657 UTC
null
null
null
null
523,364
null
1
45
css|fonts
176,639
<p>This font is not standard on all devices. It is installed by default on some Macs, but rarely on PCs and mobile devices.</p> <p>To use this font on all devices, use a <a href="http://www.css3.info/preview/web-fonts-with-font-face/" rel="noreferrer">@font-face declaration</a> in your CSS to link to it on your domain...
8,158,987
rails 3.1 asset pipeline css caching in development
<p>I'm a bit confused as it seems like the application.css is including itself twice, once when it lists the resources from the manifest and then a cache of that. So when I delete an individual file it still seems to stay alive inside the application.css file.</p> <h1>application.css (source)</h1> <pre><code>/* *= ...
8,164,860
10
3
null
2011-11-16 21:28:56.18 UTC
13
2013-09-27 01:38:28.02 UTC
2011-11-16 21:35:24.587 UTC
null
116,522
null
116,522
null
1
36
ruby-on-rails-3|ruby-on-rails-3.1|asset-pipeline|sass
20,552
<p>I had a problem like this before. It was caused after I had precompiled the assets it was going after the applcation.css inside the public folder as well as in the apps directory. I'm not sure how to fix it so that it doesn't keep happening while in dev mode but if you delete your <code>/public/assets</code> direc...
4,091,441
How do I index and search text files in Lucene 3.0.2?
<p>I am newbie in Lucene, and I'm having some problems creating simple code <strong>to query a text file collection</strong>.</p> <p>I tried <a href="http://www.avajava.com/tutorials/lessons/how-do-i-use-lucene-to-index-and-search-text-files.html" rel="noreferrer">this example</a>, but is incompatible with the new ver...
4,092,172
3
0
null
2010-11-03 20:36:41.607 UTC
9
2015-11-27 09:47:58.927 UTC
2011-08-08 22:11:04.413 UTC
null
709,202
null
284,932
null
1
11
java|indexing|lucene|text-files
17,546
<p>Lucene is a quite big topic with a lot of classes and methods to cover, and you normally cannot use it without understanding at least some basic concepts. If you need a quickly available service, use <a href="http://lucene.apache.org/solr/" rel="noreferrer">Solr</a> instead. If you need full control of Lucene, go on...
4,264,540
Grand Central Dispatch (GCD) with CoreData
<p>I'm using Grand Central Dispatch (GCD) in my application to do some heavy lifting. The application is using Core-Data for data storage purposes. Here's my scenario (along with relevant question):</p> <pre><code>dispatch_queue_t main_queue = dispatch_get_main_queue(); dispatch_queue_t request_queue = dispatch_queue_...
4,264,911
3
0
null
2010-11-24 07:55:02.77 UTC
44
2012-08-20 14:13:23.603 UTC
2011-09-16 00:06:02.79 UTC
user557219
null
null
49,739
null
1
22
iphone|core-data|objective-c-blocks|grand-central-dispatch
15,170
<p>As you probably know or have noticed you must perform UI operations on the main thread. As you mention it is when you save the UI update takes place. You can solve this by nesting a call to <code>dispatch_sync</code> on the main thread.</p> <pre><code>dispatch_queue_t main_queue = dispatch_get_main_queue(); dispatc...
4,454,861
How do I edit a table in order to enable CASCADE DELETE?
<p>I have a table representing users. When a user is deleted I get: </p> <blockquote> <p>DELETE statement conflicted with the REFERENCE constraint</p> </blockquote> <p>Apparently, <code>CASCADE DELETE</code> is not as easy as I imagined in SQL Server, and the option needs to be added to the table.</p> <p>The probl...
4,454,994
3
0
null
2010-12-15 21:03:45.227 UTC
5
2016-03-09 08:46:09.177 UTC
2015-10-20 10:18:05.677 UTC
null
2,771,704
null
208,827
null
1
26
sql|sql-server|sql-server-2008|cascading-deletes
46,946
<p>Read this Microsoft article first. <a href="http://msdn.microsoft.com/en-us/library/ms186973.aspx" rel="noreferrer">Read Me</a>. I use the GUI during design so here is a picture of how it is selected in SSMS. <img src="https://i.stack.imgur.com/Y3cVQ.jpg" alt="alt text"> The syntax added to the foreign key is " ON ...
4,483,972
Only select text directly in node, not in child nodes
<p>How does one retrieve the text in a node without selecting the text in the children?</p> <pre><code>&lt;div id="comment"&gt; &lt;div class="title"&gt;Editor's Description&lt;/div&gt; &lt;div class="changed"&gt;Last updated: &lt;/div&gt; &lt;br class="clear"&gt; Lorem ipsum dolor sit amet. &lt;/d...
4,484,036
3
0
null
2010-12-19 16:50:23.633 UTC
15
2019-04-15 17:14:46.967 UTC
2019-04-15 17:14:46.967 UTC
user357812
81,785
null
81,785
null
1
47
xpath|xquery
27,412
<p>In the provided XML document:</p> <pre><code>&lt;div id="comment"&gt; &lt;div class="title"&gt;Editor's Description&lt;/div&gt; &lt;div class="changed"&gt;Last updated: &lt;/div&gt; &lt;br class="clear"&gt; Lorem ipsum dolor sit amet. &lt;/div&gt; </code></pre> <p>the top element <code>/d...
4,394,273
What's the difference between update and pull?
<p>Can someone clarify what's the exact difference between <em>update</em> and <em>pull</em> commands?</p> <p>Thanks.</p>
4,394,287
4
2
null
2010-12-09 02:17:47.417 UTC
10
2020-03-17 16:46:48.89 UTC
null
null
null
null
504,715
null
1
37
version-control|mercurial
29,932
<p>hg update : <a href="http://www.selenic.com/mercurial/hg.1.html#update" rel="noreferrer">http://www.selenic.com/mercurial/hg.1.html#update</a></p> <ul> <li>Update the repository's working directory (the "working copy") to the specified revision of the repository</li> </ul> <p>hg pull : <a href="http://www.selenic....
4,494,708
Using CSS selectors to access specific table rows with selenium
<p>If I have the following HTML:</p> <pre><code>&lt;tbody id="items"&gt; &lt;tr&gt;&lt;td&gt;Item 1&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item 2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item 3&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item 4&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Item 5&lt;/td&gt;&lt;/tr&gt; &...
4,494,743
5
0
null
2010-12-20 22:42:04.713 UTC
4
2018-11-01 15:18:11.67 UTC
null
null
null
null
462,112
null
1
12
css|selenium|css-selectors
51,372
<p>You can use nth-child selector:</p> <pre><code>#items tr:nth-child(4) {color:#F00;} </code></pre> <p>Live example: <a href="https://jsfiddle.net/7ow15mv2/1/" rel="noreferrer">https://jsfiddle.net/7ow15mv2/1/</a></p> <p>But no idea if it works with Selenium.</p> <p>But according to docs it should.</p> <blockquot...
4,147,707
Python - mysqlDB, sqlite result as dictionary
<p>When I do someting like</p> <pre><code>sqlite.cursor.execute("SELECT * FROM foo") result = sqlite.cursor.fetchone() </code></pre> <p>I think have to remember the order the columns appear to be able to fetch them out, eg</p> <pre><code>result[0] is id result[1] is first_name </code></pre> <p>is there a way to ret...
4,147,752
5
1
null
2010-11-10 18:23:21.84 UTC
13
2019-10-02 18:22:43.93 UTC
2017-12-13 21:18:12.71 UTC
null
42,223
null
133,498
null
1
22
python|mysql|sqlite|dictionary|dataformat
16,784
<p>David Beazley has a nice example of this in his <a href="https://rads.stackoverflow.com/amzn/click/com/0672329786" rel="nofollow noreferrer" rel="nofollow noreferrer">Python Essential Reference</a>.<br> I don't have the book at hand, but I think his example is something like this:</p> <pre><code>def dict_gen(curs):...
4,584,089
What is the function of the push / pop instructions used on registers in x86 assembly?
<p>When reading about assembler I often come across people writing that they <em>push</em> a certain register of the processor and <em>pop</em> it again later to restore it's previous state.</p> <ul> <li>How can you push a register? Where is it pushed on? Why is this needed?</li> <li>Does this boil down to a single pr...
4,584,131
5
2
null
2011-01-03 11:36:03.06 UTC
57
2022-02-06 12:35:51.933 UTC
2021-12-12 06:31:06.167 UTC
null
224,132
null
561,174
null
1
131
assembly|x86|terminology|stack-memory|stack-pointer
389,601
<p><em>pushing</em> a value (not necessarily stored in a register) means writing it to the stack.</p> <p><em>popping</em> means restoring whatever is on top of the stack <em>into</em> a register. Those are basic instructions:</p> <pre><code>push 0xdeadbeef ; push a value to the stack pop eax ; eax i...
4,591,889
Get default value of an input using jQuery
<pre><code>$(".box_yazi2").each(function () { var default_value = this.value; $(this).css('color', '#555'); // this could be in the style sheet instead $(this).focus(function () { if (this.value == default_value) { this.value = ''; $(this).css('color', '#000'); } ...
4,591,938
6
5
null
2011-01-04 08:50:34.367 UTC
2
2016-03-18 15:27:00.623 UTC
2015-01-23 14:08:42.943 UTC
null
87,015
null
532,309
null
1
19
javascript|jquery|html|input|default-value
81,522
<p>The solution is quite easy; you have an extra <code>});</code> in your code (thanks @ Box9).</p> <p>I would encourage you to reuse the variable and not create dozens of jQuery objects.</p> <p>I've changed your example to <code>background-color</code> but it will work.</p> <pre><code>$('.box_yazi2').each(function(...
4,726,768
Function returning a lambda expression
<p>I wonder if it's possible to write a function that returns a lambda function in C++11. Of course one problem is how to declare such function. Each lambda has a type, but that type is not expressible in C++. I don't think this would work:</p> <pre><code>auto retFun() -&gt; decltype ([](int x) -&gt; int) { return...
4,727,021
6
6
null
2011-01-18 17:01:00.303 UTC
27
2020-07-27 17:33:55.007 UTC
2016-06-29 10:15:06.957 UTC
null
3,919,155
null
90,088
null
1
101
c++|function|c++11|lambda
42,676
<p>You don't need a handcrafted function object, just use <code>std::function</code>, to which lambda functions are convertible:</p> <p>This example returns the integer identity function:</p> <pre><code>std::function&lt;int (int)&gt; retFun() { return [](int x) { return x; }; } </code></pre>
4,205,317
Capture keyboardinterrupt in Python without try-except
<p>Is there some way in Python to capture <code>KeyboardInterrupt</code> event without putting all the code inside a <code>try</code>-<code>except</code> statement?</p> <p>I want to cleanly exit without trace if user presses <kbd><strong>Ctrl</strong></kbd>+<kbd><strong>C</strong></kbd>.</p>
4,205,386
6
0
null
2010-11-17 14:24:51.997 UTC
40
2020-07-09 14:34:16.213 UTC
2018-09-16 12:19:23.643 UTC
null
3,702,377
null
483,265
null
1
115
python|try-catch|keyboardinterrupt
134,951
<p>Yes, you can install an interrupt handler using the module <a href="https://docs.python.org/3/library/signal.html" rel="noreferrer">signal</a>, and wait forever using a <a href="https://docs.python.org/3/library/threading.html#threading.Event" rel="noreferrer">threading.Event</a>:</p> <pre><code>import signal impor...
4,830,900
How do I find the index of an item in a vector?
<p>Any ideas what <code>????</code> should be? Is there a built in? What would be the best way to accomplish this task?</p> <pre><code>(def v ["one" "two" "three" "two"]) (defn find-thing [ thing vectr ] (????)) (find-thing "two" v) ; ? maybe 1, maybe '(1,3), actually probably a lazy-seq </code></pre>
4,831,043
9
2
null
2011-01-28 16:56:57.723 UTC
17
2021-04-14 22:18:50.453 UTC
2017-06-30 16:09:23.643 UTC
null
254,837
null
254,837
null
1
90
clojure
63,679
<p>Built-in:</p> <pre><code>user&gt; (def v ["one" "two" "three" "two"]) #'user/v user&gt; (.indexOf v "two") 1 user&gt; (.indexOf v "foo") -1 </code></pre> <p>If you want a lazy seq of the indices for all matches:</p> <pre><code>user&gt; (map-indexed vector v) ([0 "one"] [1 "two"] [2 "three"] [3 "two"]) user&gt; (f...
4,674,623
Why do we have to normalize the input for an artificial neural network?
<p>Why do we have to normalize the input for a neural network?</p> <p>I understand that sometimes, when for example the input values are non-numerical a certain transformation must be performed, but when we have a numerical input? Why the numbers must be in a certain interval?</p> <p>What will happen if the data is not...
4,674,770
10
1
null
2011-01-12 22:16:11.363 UTC
58
2021-02-20 00:04:37.75 UTC
2021-02-20 00:04:37.75 UTC
null
4,685,471
null
481,828
null
1
180
machine-learning|neural-network|normalization
129,801
<p>It's explained well <a href="http://www.faqs.org/faqs/ai-faq/neural-nets/part2/" rel="noreferrer">here</a>.</p> <blockquote> <p>If the input variables are combined linearly, as in an MLP [multilayer perceptron], then it is rarely strictly necessary to standardize the inputs, at least in theory. The reason is ...
14,729,475
Can I make a Java HttpServer threaded/process requests in parallel?
<p>I have built a simple HttpServer following tutorials i have found online, using Sun's lightweight HttpServer.</p> <p>Basically the main function looks like this:</p> <pre><code>public static void main(String[] args) throws Exception { HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); ...
14,729,886
2
4
null
2013-02-06 12:47:35.233 UTC
8
2019-02-25 13:55:37.787 UTC
null
null
null
null
1,985,558
null
1
11
java|httpserver
18,754
<p>As you can see in <a href="http://www.docjar.com/html/api/sun/net/httpserver/ServerImpl.java.html" rel="noreferrer">ServerImpl</a>, the default executor just "run" the task :</p> <pre><code> 157 private static class DefaultExecutor implements Executor { 158 public void execute (Runnable task) { ...
2,928,325
What is the definition of a Service object?
<p>I've been working a lot with PHP.</p> <p>But recently I was assigned some work which uses Java. In PHP I used to do a lot of Singleton object but this pattern has not the same signification in Java that it has in PHP.</p> <p>So I wanted to go for an utility class (a class with static method) but my chief doesn't lik...
2,928,521
2
0
null
2010-05-28 10:50:05.363 UTC
10
2020-07-31 04:33:26.18 UTC
2020-07-31 04:33:26.18 UTC
null
214,143
null
352,808
null
1
31
java|design-patterns|terminology
16,473
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0321125215" rel="noreferrer" rel="nofollow noreferrer">Domain-Driven Design</a> defines a Service as:</p> <blockquote> <p>A SERVICE is an operation offered as an interface that stands alone in the model, without encapsulating state... [p. 105]</p> </blockquot...
3,156,778
No matching function for call to operator new
<p>I'm trying to wrap a class from a library I'm using in Lua. Specifially, I'm trying to wrap the color class from SFML. The full source for the color class can be seen <a href="http://www.sfml-dev.org/documentation/1.6/Color_8cpp-source.htm" rel="noreferrer">here</a> and <a href="http://www.sfml-dev.org/documentation...
3,156,822
2
1
null
2010-07-01 10:05:17.03 UTC
5
2022-09-11 12:36:45.22 UTC
2010-07-02 00:40:10.27 UTC
null
63,791
null
63,791
null
1
43
c++|new-operator
17,998
<p>To use the standard placement form of <code>new</code> you have to <code>#include &lt;new&gt;</code>.</p> <p>The form of <code>new</code> that you are using requires a declaration of <code>void* operator new(std::size_t, void*) throw();</code>.</p> <p>You don't have to <code>#include &lt;new&gt;</code> to use non-...
1,504,261
java override during object creation
<p>in the following java code a JButton is created but at the same time one of its methods gets overridden. Qestion: is there a name for overriding in this way while creating the object?</p> <p>the code:</p> <pre><code> JButton myButton; myButton = new JButton ("ok"){ @Override public void setTe...
1,504,271
1
0
null
2009-10-01 14:21:59.637 UTC
9
2013-01-20 18:12:29.81 UTC
2013-01-20 18:12:29.81 UTC
karl
1,592,796
karl
null
null
1
20
java|overriding|instantiation
10,419
<p>That's an anonymous class. From <a href="http://hell.org.ua/Docs/oreilly/javaenterprise/jnut/ch03_12.htm" rel="noreferrer">Java in a Nutshell</a></p> <blockquote> <p>An anonymous class is a local class without a name. An anonymous class is defined and instantiated in a single succinct expression using the n...
27,070,269
Ripple effect for lollipop views
<p>I have been developing an app for Lollipop (API 21). </p> <p>When I change the <code>Button</code> color to something, the ripple effect doesn't works. </p> <p>I found some third party libraries for the ripple effect, but I want to do this with standard API. </p> <p>This <a href="https://stackoverflow.com/questio...
27,071,381
4
0
null
2014-11-21 21:00:51.427 UTC
8
2016-10-04 16:01:35.2 UTC
2017-05-23 11:53:49.037 UTC
null
-1
null
2,203,061
null
1
20
android|material-design
21,211
<p>You have to set your button's background to a RippleDrawable which you can define in XML. (I'll name it <code>holo_blue_ripple.xml</code>)</p> <pre><code>&lt;ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@android:color/white"&gt; &lt;!-- ripple color --&gt; &lt;item andro...
55,897,065
Terraform: Validation error ... Member must satisfy regular expression pattern: arn:aws:iam::
<p>I'm trying to stream rds through kinesis data stream but it is giving me this error:</p> <blockquote> <p>botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutRecord operation: 1 validation error detected: Value 'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-lea...
55,897,749
3
0
null
2019-04-29 04:41:59.203 UTC
4
2021-10-04 02:04:11.137 UTC
2021-10-04 02:04:11.137 UTC
null
10,907,864
null
7,806,643
null
1
17
python|amazon-rds|amazon-kinesis
45,880
<p>remove 'arn:aws:kinesis:us-west-2:xxxxxxxxxx:stream/rds-temp-leads-stream' this from stream name. Just put the name of stream there like "rds-temp-leads-stream"</p>
38,717,543
How do I filter date range in DataTables?
<p>I have a large dataTable which contains ride information. Every row has a start datetime and an end datetime of the following format(yyyy-mm-dd HH:mm:ss). How can I use a datepicker for setting a filter range in dataTables? I want to have a datepicker which only selects a day and not the time. I've searched everywhe...
38,718,922
7
1
null
2016-08-02 10:09:34.07 UTC
18
2021-02-16 22:17:12.76 UTC
2016-08-02 11:15:03.953 UTC
null
6,666,514
null
3,397,167
null
1
25
javascript|datetime|filter|datatables
145,973
<p>Here is <code>DataTable</code> with Single <code>DatePicker</code> as "from" Date Filter</p> <p><kbd><a href="http://plnkr.co/edit/8z7cojpJoCSJXRn9prNj?p=preview" rel="noreferrer">LiveDemo</a></kbd></p> <p>Here is <code>DataTable</code> with Two <code>DatePickers</code> for DateRange (To and From) Filter</p> <p><...
27,768,033
ui router - nested views with shared controller
<p>I have an abstract parent view that is meant to share a controller with its nested views.</p> <pre><code>.state('edit', { abstract: true, url: '/home/edit/:id', templateUrl: 'app/templates/editView.html', controller: 'editController' }) .state('edit.details', { url: '/details', templateUrl: ...
27,768,108
4
0
null
2015-01-04 17:04:08.63 UTC
13
2018-04-04 19:57:51.493 UTC
null
null
null
null
2,124,351
null
1
32
angularjs|angular-ui-router
40,563
<p>The issue here would be related to this Q &amp; A: <a href="https://stackoverflow.com/q/27696612/1679310">How do I share $scope data between states in angularjs ui-router?</a>.</p> <p>The way how to solve it is hidden in the:</p> <h3><a href="https://github.com/angular/angular.js/wiki/Understanding-Scopes" rel="no...
35,326,115
Laravel5 how to pass array to view
<p>I am confuse as how to pass variable from controller to view. I know there is a lot about this already on stockoverflow but unable to find one that works, please point me in the right direction. Thank you. </p> <p>CONTROLLER</p> <pre><code> class StoreController extends Controller { public function index() ...
35,326,267
9
0
null
2016-02-10 21:19:09.167 UTC
4
2021-01-05 18:10:21.23 UTC
null
null
null
null
1,975,187
null
1
19
laravel
75,008
<pre><code>public function index() { $store = Store::all(); // got this from database model return view('store')-&gt;with('store', $store); } </code></pre> <p>You've three options in general. </p> <ol> <li><p><code>return view('store')-&gt;with('store', $store);</code> </p></li> <li><p><code>return view('store'...
29,401,626
How do I return a reference to something inside a RefCell without breaking encapsulation?
<p>I have a struct that has inner mutability.</p> <pre><code>use std::cell::RefCell; struct MutableInterior { hide_me: i32, vec: Vec&lt;i32&gt;, } struct Foo { //although not used in this particular snippet, //the motivating problem uses interior mutability //via RefCell. interior: RefCell&lt;...
29,401,865
3
0
null
2015-04-01 22:02:00.03 UTC
14
2018-12-18 17:54:46.987 UTC
2018-12-18 17:54:46.987 UTC
null
493,729
null
116,834
null
1
48
rust|encapsulation|contravariance|mutability|interior-mutability
9,555
<p>You can create a new struct similar to the <code>Ref&lt;'a,T&gt;</code> guard returned by <code>RefCell::borrow()</code>, in order to wrap this <code>Ref</code> and avoid having it going out of scope, like this:</p> <pre><code>use std::cell::Ref; struct FooGuard&lt;'a&gt; { guard: Ref&lt;'a, MutableInterior&gt...
45,163,256
How to format numbers as percentage values in JavaScript?
<p>Was using ExtJS for formatting numbers to percentage earlier. Now as we are not using ExtJS anymore same has to be accomplished using normal JavaScript.</p> <p>Need a method that will take number and format (usually in %) and convert that number to that format. </p> <pre><code>0 -&gt; 0.00% = 0.00% 25 -&gt; 0.00% ...
45,163,358
6
0
null
2017-07-18 09:52:22.36 UTC
4
2022-01-05 20:50:40.113 UTC
null
null
null
null
2,160,616
null
1
37
javascript
71,708
<p>Here is what you need.</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-js lang-js prettyprint-override"><code>var x=150; console.log(parseFloat(x).toFixed(2)+"%"); x=0; console.log(parseFloat(x).toFixed(2)+"%"); ...
64,500,342
Creating requirements.txt in pip compatible format in a conda virtual environment
<p>I have created a conda virtual environment on a Windows 10 PC to work on a project. To install the required packages and dependencies, I am using <code>conda install &lt;package&gt;</code> instead of <code>pip install &lt;package&gt;</code> as per the best practices mentioned in <a href="https://docs.conda.io/projec...
64,501,566
2
0
null
2020-10-23 12:48:45.99 UTC
8
2022-08-05 15:22:49.747 UTC
2020-10-23 13:14:08.167 UTC
null
14,477,880
null
14,477,880
null
1
9
python|pip|conda|requirements.txt
18,217
<p>The best solution I've found for the above is the combination I will describe below. For <code>conda</code>, I would first export the environment list as <code>environment.yml</code> and omit the package build numbers, which is often what makes it hard to reproduce the environment on another OS:</p> <pre><code>conda...
32,087,809
How to change bottom layout constraint in iOS, Swift
<p>I have scroll view as @IBOutlet</p> <pre><code>@IBOutlet weak var mainScrollView: UIScrollView! </code></pre> <p>I want to change the </p> <pre><code>"Bottom space to: Bottom Layout Guide" </code></pre> <p>constraint programmatically.</p> <pre><code>First Item : Bottom Layout Guide.Top Relation : Equal Second ...
32,087,869
3
0
null
2015-08-19 06:17:08.007 UTC
8
2015-08-19 06:30:10.117 UTC
null
null
null
null
4,582,207
null
1
18
ios|xcode|swift|storyboard|nslayoutconstraint
38,768
<p>Take the constraint as <code>IBOutlet</code> of <code>NSLayoutConstraint</code>.</p> <p><img src="https://i.stack.imgur.com/gtitj.png" alt="enter image description here"></p> <p>Set the constraint outlets and change <code>constant</code> value by :</p> <pre><code>self.sampleConstraint.constant = 20 self.view.layo...
27,945,031
OpenID Connect delegation with Google now that they are deprecating their OpenID2 provider?
<p>For years I have used OpenID delegation to log in to Stack Overflow (among other sites) using my own URI as OpenID but having Google handle the authentication. I use the technique described in <a href="https://stackoverflow.com/questions/2541526/delegate-openid-to-google-not-google-apps">this Stack Overflow questio...
28,054,173
3
0
null
2015-01-14 14:15:53.307 UTC
6
2015-01-21 04:01:03.407 UTC
2017-05-23 12:06:46.683 UTC
null
-1
null
394,431
null
1
32
openid|google-openid|openid-connect|stackexchange
2,072
<p>OpenID Connect <em>only</em> supports Discovery that is meant to <strong>find</strong> your Provider based on some hint you give it (e-mail, account, URL, domain etc.); it won't give you a persistent identifier for which you can <strong>delegate</strong> authentication to a configurable Provider of your choice.</p> ...
40,358,434
TypeScript TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'
<p>Im getting this compilation error in my Angular 2 app:</p> <blockquote> <p>TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.</p> </blockquote> <p>The piece of code causing it is:</p> <pre><code>getApplicationCount(state:string) { return this.applicationsByState[state]...
40,358,512
5
2
null
2016-11-01 10:40:55.9 UTC
16
2022-05-05 07:29:14.697 UTC
2021-10-14 09:31:57.67 UTC
null
209,259
null
69,349
null
1
135
javascript|angular|typescript
210,492
<p>If you want a key/value data structure then don't use an array.</p> <p>You can use a regular object:</p> <pre><code>private applicationsByState: { [key: string]: any[] } = {}; getApplicationCount(state: string) { return this.applicationsByState[state] ? this.applicationsByState[state].length : 0; } </code></p...
40,484,717
PrimeNG dropdown hidden by dialog
<p>I have an Angular2 app using PrimeNG components.</p> <p>I want a dropdown inside a dialog box. However, when i have implemented this, the dropdown is cut off by the limit of the dialog box as shown in the screenshot below. What i want is for it to display above the dialog and have all the options visible. </p> <p>...
42,930,704
6
3
null
2016-11-08 10:36:20.66 UTC
7
2021-07-05 20:20:31.833 UTC
2021-07-05 20:20:31.833 UTC
null
1,077,309
null
2,858,948
null
1
31
angular|typescript|primeng|primeng-dropdowns|primeng-dialog
38,547
<p>It is necessary to add an attribute <code>appendTo</code>.</p> <p>e.g.</p> <pre><code>&lt;p-dropdown appendTo="body" [options]="tables" [(ngModel)]="selectedTable" [style]="{width: '100%'}"&gt;&lt;/p-dropdown&gt; </code></pre>
39,194,917
How to use Laravel Passport with a custom username column
<p>Now I'm using something like that for authenticating the user on my base site:</p> <pre><code>if (Auth::attempt($request-&gt;only(['id', 'password']))) { // } </code></pre> <p>How can I modify this code for using custom column as username? <a href="https://laravel.com/docs/5.3/passport#password-grant-t...
39,194,932
2
0
null
2016-08-28 19:18:05.89 UTC
9
2021-02-24 05:20:53.383 UTC
2018-02-19 17:24:29.467 UTC
null
100,297
null
4,417,142
null
1
45
php|laravel|oauth-2.0|laravel-passport
23,296
<p>You can use findForPassport method in your user model.</p> <p>This method take username as argument, and return user model</p> <p>For example:</p> <pre><code>class User extends Authenticatable { use HasApiTokens, Notifiable; // ... some code public function findForPassport($username) { retur...
6,255,796
What does the 'N' command do in sed?
<p>It looks like the 'N' command works on every other line:</p> <pre class="lang-sh prettyprint-override"><code>$ cat in.txt a b c d $ sed '=;N' in.txt 1 a b 3 c d </code></pre> <p>Maybe that would be natural because command 'N' joins the next line and changes the current line number. But (I saw this <a href=...
6,257,542
1
0
null
2011-06-06 17:33:17.13 UTC
7
2021-07-10 10:53:39.303 UTC
2021-07-10 10:53:39.303 UTC
null
11,407,695
null
766,330
null
1
18
sed
43,120
<p>Excerpt from <code>info sed</code>: </p> <pre><code>`sed' operates by performing the following cycle on each lines of input: first, `sed' reads one line from the input stream, removes any trailing newline, and places it in the pattern space. Then commands are executed; each command can have an address associated ...
38,034,049
is optionality (mandatory, optional) and participation (total, partial) are same?
<p>As i know optionality means the minimum cardinality of a relationship which is denoted as optional to optional, mandatory to optional, mandatory to mandatory.. </p> <p>And Participation denoted as bold line and a normal line. </p> <p>In the Internet some refer participation as the dependency of the entity to the r...
38,035,173
1
0
null
2016-06-26 00:07:17.293 UTC
12
2021-01-27 10:46:41.073 UTC
null
null
null
null
5,719,870
null
1
13
entity-relationship
31,315
<p>Let's start with definitions and examples of each of the concepts:</p> <p><strong>Total and partial participation:</strong></p> <p>Total participation (indicated by a double or thick association line) means that all the entities in an entity set must participate in the relationship. Partial participation (indicate...
28,794,089
Calling a Swift class factory method with leading dot notation?
<p>In a recent question, the poster had this interesting line of code:</p> <pre><code>self.view.backgroundColor = .whiteColor() </code></pre> <p>I was surprised to see this. I've only ever seen the <em>leading dot</em> notation used for enum values. In this case, <code>backgroundColor</code> is of type <code>UIColo...
28,808,977
3
0
null
2015-03-01 13:31:00.407 UTC
9
2020-07-14 10:53:14.557 UTC
null
null
null
null
1,630,618
null
1
41
swift
12,355
<p>This <strong>feature</strong> is called &quot;<a href="https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID394" rel="noreferrer">Implicit Member Expression</a>&quot;</p> <blockquote> <p>An implicit member expression is an abbreviated way to access a member of a type, such as an enumeration case <str...
23,874,281
Scala - How to compile code from an external file at runtime?
<p>I want to design a Scala program that accepts Scala files as parameters which can customize the execution of the program. In particular, I want to supply at runtime files that contain implementations of methods that will be invoked by the program. How can I properly depend on external files and invoke their method...
23,879,115
2
0
null
2014-05-26 16:24:52.813 UTC
12
2014-05-27 16:24:53.05 UTC
2014-05-27 00:11:59.583 UTC
null
1,763,356
null
506,971
null
1
14
scala|scala-compiler|external-dependencies
4,912
<p>Here's how to do it using only standard Scala. The non-obvious stuff is all in <code>GreenhouseFactory</code>:</p> <pre><code>package customizable abstract class Plant case class Rose() extends Plant abstract class Greenhouse { def getPlant(): Plant } case class GreenhouseFactory(implFilename: String) { imp...
43,166,214
Merging http observables using forkjoin
<p>I'm trying to avoid nested observables by using <code>forkjoin</code>. The current (nested) version looks like this:</p> <pre><code> this.http.get('https://testdb1.firebaseio.com/.json').map(res =&gt; res.json()).subscribe(data_changes =&gt; { this.http.get('https://testdb2.firebaseio.com/.json').map(res =&gt;...
43,166,302
1
0
null
2017-04-02 08:24:45.97 UTC
15
2017-10-24 10:08:33.14 UTC
null
null
null
null
2,278,894
null
1
29
angular|typescript|ionic2|observable
30,028
<p>Try to use <code>combineLatest</code> instead of <code>forkJoin</code> :</p> <p><strong>With <code>combineLatest</code> :</strong></p> <pre><code>const combined = Observable.combineLatest( this.http.get('https://testdb1.firebaseio.com/.json').map((res: Response) =&gt; res.json()), this.http.get('https://testdb...
35,969,728
How to change TODO highlight in atom editor
<p>In my opinion the higlighting of a TODO "flag" in the atom editor is too weak/unobtrusively.</p> <p>How can I change this? I DON'T wanna list the todos in a sidebar (<a href="https://atom.io/packages/todo-show" rel="noreferrer">https://atom.io/packages/todo-show</a>).</p> <p>Here to compare:</p> <p>In Vim editor ...
36,200,468
1
0
null
2016-03-13 11:35:32.547 UTC
8
2019-08-06 06:50:21.973 UTC
2016-03-17 19:34:40.287 UTC
null
2,518,200
null
3,567,888
null
1
13
editor|highlight|atom-editor|todo
5,360
<p>As GitHub's Atom Editor is built around HTML5 and CSS3 you can very easily change your style sheet, I've done a little recording on how to make this specific change below although you can apply the same principals to any styled element within the editor:</p> <p><a href="https://i.stack.imgur.com/QJcdp.gif" rel="nor...
36,188,429
Retrieve length of slice from slice object in Python
<p>The title explains itself, how to get 2 out of the object</p> <pre><code>slice(0,2) </code></pre> <p>The documentation is somewhat confusing, or it is the wrong one</p> <p><a href="https://docs.python.org/2/c-api/slice.html" rel="noreferrer">https://docs.python.org/2/c-api/slice.html</a></p> <p>In particular I d...
36,188,683
7
0
null
2016-03-23 20:50:01.863 UTC
3
2022-04-03 15:38:24.017 UTC
null
null
null
null
5,748,462
null
1
30
python|list|slice
14,073
<p>There is no complete answer for this. <code>slice</code> doesn't give you a length because the length of the result is always dependent on the size of the sequence being sliced, a short sequence (including an empty sequence) will produce fewer items, and if the <code>slice</code> is unbounded, then the length will g...
56,895,273
How to use `GlobalKey` to maintain widgets' states when changing parents?
<p>In Emily Fortuna's article (and video) she mentions:</p> <blockquote> <p>GlobalKeys have two uses: they allow widgets to change parents anywhere in your app without losing state, or they can be used to access information about another widget in a completely different part of the widget tree. An example of t...
62,226,807
3
0
null
2019-07-05 00:23:32.757 UTC
16
2021-05-26 15:00:05.797 UTC
2019-07-05 00:30:58.163 UTC
null
1,032,613
null
1,032,613
null
1
39
flutter
71,375
<p><strong>I would not recommend using GlobalKey for this task.</strong></p> <p>You should pass the data around, not the widget, not the widget state. For example, if you want a <code>Switch</code> and a <code>Slider</code> like in the demo, you are better off just pass the actual <code>boolean</code> and <code>double...
21,129,699
How does Symfony2 session fixation work?
<p>According to the standard 2.4 documentation, the security.yml config file allows for the following configuration option:</p> <pre><code>session_fixation_strategy: none | migrate | invalidate </code></pre> <p>source: <a href="http://symfony.com/doc/current/reference/configuration/security.html">http://symfony.com/d...
23,952,177
1
0
null
2014-01-15 05:24:30.403 UTC
8
2014-05-30 10:15:28.473 UTC
null
null
null
null
1,155,721
null
1
20
security|symfony
4,845
<p>In short:</p> <ul> <li>NONE: the session is not changed </li> <li>MIGRATE: the session id is updated, attributes are kept </li> <li>INVALIDATE: the session id is updated, attributes are lost</li> </ul> <p>In detail: </p> <ol> <li><p>None strategy: Nothing is (supposed to be) done in the default session implement...
43,567,577
What is the different between force push and normal push in git
<p>I want to know what is the different between force push and normal push and at what kind of situations i should do force push in git?Is it a good practice to do force push into master branch?</p>
43,567,591
2
0
null
2017-04-23 05:02:58.17 UTC
9
2017-04-23 05:17:17.47 UTC
null
null
null
null
7,764,309
null
1
33
git|push
28,252
<p>You only force a push when you need to replace the remote history by your local history.</p> <p>This happens when you rewrite the local history, typically <a href="https://git-scm.com/book/es-ni/v1/Git-Branching-Rebasing" rel="noreferrer">through a <code>git rebase</code></a>.<br> For instance, if you just pushed a...
49,572,786
Bootstrap 4 datepicker
<p>I want to use datepicker <a href="https://bootstrap-datepicker.readthedocs.io/en/latest/index.html" rel="noreferrer">https://bootstrap-datepicker.readthedocs.io/en/latest/index.html</a> with Bootstrap 4.</p> <p>Following the examples on above page, I can make it work with Bootstrap 3.</p> <p><div class="snippet" d...
49,586,564
3
1
null
2018-03-30 10:31:00.94 UTC
4
2020-06-11 05:51:29.953 UTC
null
null
null
null
184,041
null
1
14
datepicker|bootstrap-4|bootstrap-datepicker
109,113
<p>You can too override default datepicker classes like the following:</p> <p>the default bootstrap font size is 1rem or 16px so update .datepicker class <code>font-size: 0.875em;</code> or/and update the cell width and height:</p> <pre><code>.datepicker td, .datepicker th { width: 1.5em; height: 1.5em; } </...
26,132,451
How to add bash command completion for Docker on Mac OS X?
<p>I am running docker and I want <code>bash</code> command completion for <code>docker</code> commands and parameters.</p>
26,132,452
8
0
null
2014-10-01 00:46:02.59 UTC
10
2020-07-27 01:02:40.093 UTC
2014-10-01 00:53:03.643 UTC
null
2,297,345
null
2,297,345
null
1
54
macos|docker
21,920
<p>If you have already <a href="http://brew.sh" rel="noreferrer">homebrew</a> <code>bash-completion</code> <a href="https://superuser.com/a/288491/231893">installed</a> just install the docker completion script into the <code>bash_completion.d</code> </p> <pre><code>curl -XGET https://raw.githubusercontent.com/docker/...
26,005,641
Are cookies in UIWebView accepted?
<p>I have to question for you.</p> <p>1 : I'm using <code>UIWebView</code>s in my iPhone App. I wan't the users be able to add comments in the news. But, to comment they have to log-in. </p> <p>If not, how can I accept cookies in <code>UIWebView</code>s ?</p> <p>2 : Are the cookies created in on <code>UIWebView</cod...
26,006,163
8
0
null
2014-09-23 22:23:03.543 UTC
10
2019-01-20 11:58:11.467 UTC
2017-07-17 08:14:15.563 UTC
null
7,456,236
null
4,059,455
null
1
17
ios|objective-c|iphone|cookies|uiwebview
32,161
<p>The <code>UIWebView</code> will automatically store the cookies in the <code>[NSHTTPCookieStorage sharedHTTPCookieStorage]</code> collection, and should be available in all other <code>UIWebView</code>s within your app, during the same app launch. However the <code>UIWebView</code> class does not automatically store...
26,275,736
How to pass a Map<String, String> with application.properties
<p>I have implemented some authorization in a webservice that needs be configured.</p> <p>Currently the user/password combo is hardcoded into the bean configuration. I would like to configure the map with users and passwords into the application.properties so the configuration can be external.</p> <p>Any clue on how ...
26,276,729
4
0
null
2014-10-09 10:10:04.447 UTC
10
2019-11-21 16:51:07.297 UTC
2019-11-21 16:51:07.297 UTC
null
117,347
null
185,432
null
1
26
spring|spring-boot
93,871
<p>A <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html" rel="noreferrer"><code>java.util.Properties</code></a> object is already a <code>Map</code>, actually a <code>HashTable</code> which in turn implements <code>Map</code>.</p> <p>So when you create a properties file (lets name it <code>use...
41,998,222
Best practice for handling error in Angular2
<p>Hi i am trying to receive error sent from catch block (service). in multiple components i need to show a popup with the error message displayed. please let me know how to create a generic method and call it inside service block. Like what i am doing now with "showErrorPage()".</p> <pre><code>import { Injectable }...
41,999,180
1
0
null
2017-02-02 09:14:24.853 UTC
12
2017-10-10 11:58:59.857 UTC
null
null
null
null
1,867,584
null
1
27
angular|angular2-services
28,887
<p>According to the <a href="https://angular.io/guide/styleguide#style-08-01" rel="noreferrer">angular style guide</a></p> <blockquote> <p>The details of data management, such as headers, HTTP methods, caching, error handling, and retry logic, are irrelevant to components and other data consumers.</p> </blockquote> ...
21,979,782
How to push values to property array in Cypher?
<p>I have two nodes <code>user</code> and <code>files</code> with a relationship <code>:contains</code>, the relationship has a property <code>id</code>which is an array, represented as</p> <pre><code>(:user)-[:contains{id:[12345]}]-&gt;(:files) </code></pre> <p>However I want to populate the property array <code>id</c...
21,980,719
3
0
null
2014-02-24 05:45:07.333 UTC
9
2021-12-10 03:45:48.82 UTC
2021-12-10 03:45:48.82 UTC
null
3,416,774
null
2,472,111
null
1
30
arrays|neo4j|cypher
17,436
<p>Adding values to an array is analogous to incrementing an integer or concatenating a string and is signified the same way, in your case (let <code>c</code> be your <code>[c:contains {id:[12345]}]</code>)</p> <pre><code>c.id = c.id + 1111 // [12345,1111] c.id = c.id + 14567 // [12345,1111,14...
3,089,475
How Can I create A 5 second Countdown timer with jquery that ends with a login popup?
<p>How would i create a jquery timer that starts when a link is 'mouse-overed', Displays a 1,2,3, 4 and 5, one after the other. Then on 5 pops up a login box?</p> <p>Cheers.</p>
3,089,490
3
0
null
2010-06-22 00:48:29.21 UTC
16
2017-09-26 19:48:54.503 UTC
null
null
null
null
276,809
null
1
34
jquery
82,744
<p>How about:</p> <pre><code>var counter = 0; var interval = setInterval(function() { counter++; // Display 'counter' wherever you want to display it. if (counter == 5) { // Display a login box clearInterval(interval); } }, 1000); </code></pre>
2,413,427
How to use SQL Order By statement to sort results case insensitive?
<p>I have a SQLite database that I am trying to sort by Alphabetical order. The problem is, SQLite doesn't seem to consider A=a during sorting, thus I get results like this:</p> <p>A B C T a b c g</p> <p>I want to get:</p> <p>A a b B C c g T</p> <p>What special SQL thing needs to be done that I don't know about?</...
2,413,833
3
1
null
2010-03-09 23:30:55.843 UTC
26
2020-04-26 23:13:23.79 UTC
null
null
null
null
131,871
null
1
157
sql|sqlite|sorting|sql-order-by
118,583
<p>You can also do <code>ORDER BY TITLE COLLATE NOCASE</code>.</p> <p>Edit: If you need to specify <code>ASC</code> or <code>DESC</code>, add this after <code>NOCASE</code> like</p> <pre><code>ORDER BY TITLE COLLATE NOCASE ASC </code></pre> <p>or</p> <pre><code>ORDER BY TITLE COLLATE NOCASE DESC </code></pre>
13,129,805
MatLab algorithm for composite Simpson's rule
<p>I have tried, just for the fun of it, to write a MatLab-code for the composite Simpson's rule. As far as I can see, the code is correct, but my answers are not as accurate as I would like. If I try my code on the function f = cos(x) + e^(x^2), with a = 0, b = 1 and n = 7, my answer is roughly 1,9, when it should b...
13,129,903
4
0
null
2012-10-29 21:15:24.643 UTC
2
2017-05-02 13:14:24.133 UTC
2012-10-29 21:41:12.13 UTC
null
933,410
null
933,410
null
1
0
matlab|numerical-integration
52,714
<p>Your interval <code>[a,b]</code> should be split into <code>n</code> intervals. This results in <code>n+1</code> values for <code>x</code> that form the boundary of each partition. Your vector <code>x</code> contains only <code>n</code> elements. It appears that your code is only dealing with <code>n</code> terms in...
40,635,107
Why does unique_ptr instantiation compile to larger binary than raw pointer?
<p>I was always under the impression that a <code>std::unique_ptr</code> had no overhead compared to using a raw pointer. However, compiling the following code</p> <pre><code>#include &lt;memory&gt; void raw_pointer() { int* p = new int[100]; delete[] p; } void smart_pointer() { auto p = std::make_unique&lt;in...
40,635,268
1
7
null
2016-11-16 14:49:01.423 UTC
3
2016-11-17 13:11:07.22 UTC
null
null
null
null
4,089,452
null
1
39
c++|assembly|smart-pointers
1,424
<p>Because <code>std::make_unique&lt;int[]&gt;(100)</code> performs <a href="http://en.cppreference.com/w/cpp/language/value_initialization" rel="nofollow noreferrer">value initialization</a> while <code>new int[100]</code> performs <a href="http://en.cppreference.com/w/cpp/language/default_initialization" rel="nofollo...
37,149,466
Axios spread() with unknown number of callback parameters
<p>I need to process an unknown number of AJAX requests (1 or more) with axios, and I am not sure how to handle the response. I want something along the lines of:</p> <pre><code>let urlArray = [] // unknown # of urls (1 or more) axios.all(urlArray) .then(axios.spread(function () { let temp = []; for (let i = 0; i...
37,149,547
1
0
null
2016-05-10 21:42:32.257 UTC
10
2016-05-10 22:22:19.353 UTC
2016-05-10 22:22:19.353 UTC
user6246005
null
null
3,606,440
null
1
22
javascript|ajax|axios
19,930
<p>You somewhere will need to make the actual requests. And then don't use <code>spread</code> but only <code>then</code> to receive the array of results:</p> <pre><code>let urlArray = [] // unknown # of urls (1 or more) let promiseArray = urlArray.map(url =&gt; axios.get(url)); // or whatever axios.all(promiseArray)...
52,785,125
MySQL Workbench: Error in query (1064): Syntax error near 'VISIBLE' at line 1
<p>Any ideas why <code>VISIBLE</code> below is causing an issue?</p> <pre><code>CREATE TABLE IF NOT EXISTS `setting` ( `uuid` INT(10) NOT NULL, `type` VARCHAR(255) NOT NULL, `code` VARCHAR(255) NOT NULL COMMENT 'An unique name.', `value` MEDIUMTEXT NULL DEFAULT NULL, `comment` LONGTEXT NULL DEFAULT NULL, `...
52,785,302
3
0
null
2018-10-12 18:22:48.95 UTC
4
2019-04-28 06:16:05.397 UTC
null
null
null
null
413,225
null
1
34
mysql|mysql-workbench
20,358
<p>The problem here is the difference in syntax across different MySQL server versions. It seems that <strong>MySQL Workbench 8.0.12</strong> is auto-generating <code>CREATE UNIQUE INDEX</code> statement for the MySQL server <strong>version 8.0</strong>.</p> <p>From the <a href="https://dev.mysql.com/doc/refman/8.0/en...
3,072,205
How to use Maven in my Java Project and Why?
<p>I am trying to figure out the use of <a href="http://maven.apache.org/" rel="noreferrer">Maven</a> and I got many articles describing its features and uses. But I am just not able to understand the actual use of Maven from productivity standpoint. </p> <p>From what I am used to in our school projects was just creat...
3,072,246
7
1
null
2010-06-18 18:30:42.253 UTC
13
2020-12-31 18:14:14.473 UTC
2012-11-11 22:07:42.507 UTC
null
231,917
null
231,917
null
1
20
java|maven-2
14,857
<p>Maven is used to manage the build, testing, and deployment processes. It can separate the unit tests and integration tests so you only run them when necessary and cut down on build time. </p> <p>It is also a <em>dependency manager</em>, which means when you realize the server piece of your project needs <code>apach...
3,058,164
Android: Scrolling an Imageview
<p>I have an ImageView that is twice the height of a normale screen ( 960 dip). I would like to scroll it nicely up and down on the screen. The bottom of the screen should contain a button. I have tried various combinations of ScrollView and Imageviews without any success. I have also thinkered with the :isScrollContai...
3,732,377
8
1
null
2010-06-17 00:36:39.923 UTC
41
2019-11-04 12:45:17.183 UTC
2011-08-15 21:01:55.883 UTC
null
156,771
null
368,819
null
1
26
android|scroll|imageview
97,959
<p>@cV2 Thank you so much for that code. It got me going in the direction I needed. Here's my modified version which stops scrolling at the edges of the image...</p> <pre><code> // set maximum scroll amount (based on center of image) int maxX = (int)((bitmapWidth / 2) - (screenWidth / 2)); int maxY = (int...
2,929,175
What is the difference between a static class and a normal class?
<p>When should I prefer either a static or a normal class? Or: what is the difference between them?</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace staticmethodlar { class Program { static void Main(string[] args) { Sin...
2,929,251
9
2
null
2010-05-28 13:06:57.447 UTC
12
2020-12-14 16:35:21.007 UTC
2015-06-04 06:21:54.18 UTC
null
419,956
null
52,420
null
1
21
c#|.net|oop
40,538
<p>Static classes contain static objects that can't be instantiated multiple times. Usually what I use static classes for are to house static methods that provide calculations, general processing patterns, string output formats, etc. Static classes are light weight and don't need instantiation.</p> <p>For instance <co...
2,603,363
Good Form Security - no CAPTCHA
<p>Is there a good method of form security that does <code>not</code> involve CAPTCHA? CAPTCHA is so annoying, but I need security because I am getting form spam. My form is PHP.</p>
2,603,377
9
0
null
2010-04-08 20:49:32.667 UTC
10
2019-07-22 07:10:33.037 UTC
null
null
null
null
290,051
null
1
35
php|security|forms
10,206
<p>Try <a href="http://akismet.com/" rel="nofollow noreferrer">akismet</a>. It's great at flagging spam. The API is easy to use and completely transparent to your users.</p>
3,200,329
View AJAX response content in Chrome developer tools?
<p>Traditionally I use FireBug to debug my AJAX requests. It lets you examine both the contents of your request as well as the response that was sent back from the server. (it also notifies you in the console when these occur, which is a useful feature that Chrome seems to lack).</p> <p>In Chrome, I only seem to be ab...
3,205,078
9
3
null
2010-07-08 02:33:09.927 UTC
13
2022-01-31 07:53:13.473 UTC
2010-07-08 02:40:52.453 UTC
null
134,658
null
134,658
null
1
55
ajax|google-chrome|webkit|developer-tools|web-developer-toolbar
80,045
<p>The content of ajax responses is not visible yet if the request is generated by a plugin. There is some chance that this problem will be fixed soon.</p>