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
412,562
Execute a terminal command from a Cocoa app
<p>How can I execute a terminal command (like <code>grep</code>) from my Objective-C Cocoa application?</p>
412,573
12
3
null
2009-01-05 08:21:32.097 UTC
180
2019-06-21 08:04:50.023 UTC
2011-02-03 01:41:40.08 UTC
Gordon Wilson
213,269
lostInTransit
46,297
null
1
210
objective-c|cocoa|macos
132,412
<p>You can use <code><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTask_Class/Reference/Reference.html" rel="noreferrer">NSTask</a></code>. Here's an example that would run '<code>/usr/bin/grep foo bar.txt</code>'. </p> <pre><code>int pid = [[NSProcessInfo processInfo] process...
906,499
getting type T from IEnumerable<T>
<p>is there a way to retrieve type <code>T</code> from <code>IEnumerable&lt;T&gt;</code> through reflection?</p> <p>e.g.</p> <p>i have a variable <code>IEnumerable&lt;Child&gt;</code> info; i want to retrieve Child's type through reflection</p>
906,513
13
1
null
2009-05-25 12:12:43.407 UTC
27
2020-10-02 12:57:56.4 UTC
2009-05-26 09:36:30.59 UTC
null
105,533
null
105,533
null
1
120
c#|generics|reflection
75,694
<pre><code>IEnumerable&lt;T&gt; myEnumerable; Type type = myEnumerable.GetType().GetGenericArguments()[0]; </code></pre> <p>Thusly,</p> <pre><code>IEnumerable&lt;string&gt; strings = new List&lt;string&gt;(); Console.WriteLine(strings.GetType().GetGenericArguments()[0]); </code></pre> <p>prints <code>System.String<...
917,392
How should I Fix "svn: Inconsistent line ending style"?
<p>When I run "svn propedit svn:ignore ." at the root of my svn repository, I get this error: svn: Inconsistent line ending style</p> <p>I have tried to run this script: <a href="http://blog.eflow.org/archives/130" rel="noreferrer">http://blog.eflow.org/archives/130</a> which runs dos2unix and sets the eol-style on a...
920,709
21
0
null
2009-05-27 18:51:14.34 UTC
13
2022-07-06 08:57:29.343 UTC
null
null
null
null
66,355
null
1
40
svn|line-endings
82,757
<p>Subversion is not complaining about the content of any file, but about the content of the svn:ignore property. One way to fix this is to simply delete the <code>svn:ignore</code> property with <code>svn propdel</code> and then recreate it. </p> <p>Another way which may be easier if you have a lot of lines in your <...
1,102,986
Most powerful examples of Unix commands or scripts every programmer should know
<p>There are many things that all programmers should know, but I am particularly interested in the Unix/Linux commands that we should all know. For accomplishing tasks that we may come up against at some point such as <strong>refactoring</strong>, <strong>reporting</strong>, <strong>network updates</strong> etc.</p> <...
1,124,572
25
4
2009-07-09 10:46:53.067 UTC
2009-07-09 10:07:37.373 UTC
47
2015-06-19 06:04:45.12 UTC
2009-07-16 05:20:28.317 UTC
null
40,002
null
40,002
null
1
27
unix|command-line|scripting
31,489
<h2>Best answers from the Community</h2> <hr> <p><strong>Traverse a directory tree and print out paths to any files that match a regular expression:</strong></p> <pre><code>find . -exec grep -l -e 'myregex' {} \; &gt;&gt; outfile.txt </code></pre> <p><strong>Invoke the default editor(Nano/ViM)</strong> </p> <bloc...
34,728,962
React renderToString() Performance and Caching React Components
<p>I've noticed that the <code>reactDOM.renderToString()</code> method starts to slow down significantly when rendering a large component tree on the server.</p> <h2>Background</h2> <p>A bit of background. The system is a fully isomorphic stack. The highest level <code>App</code> component renders templates, pages, dom...
34,907,209
4
9
null
2016-01-11 18:55:57.94 UTC
16
2020-10-11 18:29:51.577 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
4,086,590
null
1
62
performance|reactjs|isomorphic-javascript|render-to-string|react-dom
24,871
<p>Using react-router1.0 and react0.14, we were mistakenly serializing our flux object multiple times.</p> <p><code>RoutingContext</code> will call <code>createElement</code> for every template in your react-router routes. This allows you to inject whatever props you want. We also use flux. We send down a serialized v...
6,613,110
What is the best way to deal with the NSDateFormatter locale "feechur"?
<p>It seems that <code>NSDateFormatter</code> has a "feature" that bites you unexpectedly: If you do a simple "fixed" format operation such as:</p> <pre><code>NSDateFormatter* fmt = [[NSDateFormatter alloc] init]; [fmt setDateFormat:@"yyyyMMddHHmmss"]; NSString* dateStr = [fmt stringFromDate:someDate]; [fmt release];...
6,735,644
4
9
null
2011-07-07 15:30:14.707 UTC
56
2018-06-22 12:29:37.273 UTC
2017-06-28 14:49:22.833 UTC
null
1,033,581
null
581,994
null
1
173
ios|objective-c|iphone|locale|nsdateformatter
47,040
<h2>Duh!!</h2> <p>Sometimes you have an &quot;Aha!!&quot; moment, sometimes it's more of a &quot;Duh!!&quot; This is the latter. In the category for <code>initWithSafeLocale</code> the &quot;super&quot; <code>init</code> was coded as <code>self = [super init];</code>. This inits the SUPERCLASS of <code>NSDateFormatt...
6,425,062
Passing functions to setTimeout in a loop: always the last value?
<p>I'm trying to use setTimeout to execute an anonymous function that I pass information into and I'm having trouble. This (hard-coded version) would work just fine:</p> <pre><code>setTimeout(function(){alert("hello");},1000); setTimeout(function(){alert("world");},2000); </code></pre> <p>But I'm trying to take the h...
6,425,113
5
3
null
2011-06-21 12:15:16.28 UTC
12
2013-07-16 22:05:59.037 UTC
2011-12-11 07:57:04.417 UTC
user166390
null
null
730,160
null
1
17
javascript|settimeout
14,317
<p>This is the very frequently repeated "how do I use a loop variable in a closure" problem.</p> <p>The canonical solution is to call a function which returns a function that's bound to the current value of the loop variable:</p> <pre><code>var strings = [ "hello", "world" ]; var delay = 1000; for(var i=0;i&lt;string...
6,356,231
android how to convert json array to string array
<p>I have an app where I fetch data from server(json) in the form of array &amp; by using the index i used in my app, like below.</p> <pre><code>JSONObject topobj = new JSONObject(page); JSONObject innerobj = topobj.getJSONObject("restarutant"); JSONArray phone = innerobj.getJSONArray("phone"); textViewPhone.setText("...
6,356,282
6
3
null
2011-06-15 10:20:13.513 UTC
4
2021-11-12 18:00:31.367 UTC
2011-06-15 10:34:31.123 UTC
null
514,945
null
1,147,007
null
1
9
android|json
48,834
<p><a href="https://stackoverflow.com/questions/5983932/converting-from-jsonarray-to-string-then-back-again">This</a> should help you.</p> <p>Edit:</p> <p>Maybe this is what you need:</p> <pre><code>ArrayList&lt;String&gt; stringArray = new ArrayList&lt;String&gt;(); JSONArray jsonArray = new JSONArray(); for(int i ...
6,876,666
Convert float to string in php?
<p>Like:</p> <pre><code>float(1.2345678901235E+19) =&gt; string(20) &quot;12345678901234567890&quot; </code></pre> <p>Can it be done?</p> <p>(it's for json_decode...)</p>
6,876,715
6
0
null
2011-07-29 17:16:48.327 UTC
3
2022-09-01 07:22:17.773 UTC
2022-09-01 07:22:17.773 UTC
null
107,625
null
869,800
null
1
27
php|string|floating-point|type-conversion
70,954
<pre><code>echo number_format($float,0,'.',''); </code></pre> <p>note: this is for integers, increase 0 for extra fractional digits</p>
6,405,127
How do I specify a password to 'psql' non-interactively?
<p>I am trying to automate database creation process with a shell script and one thing I've hit a road block with passing a password to <a href="https://en.wikipedia.org/wiki/PostgreSQL#Database_administration" rel="noreferrer">psql</a>. Here is a bit of code from the shell script:</p> <pre><code>psql -U $DB_USER -h l...
6,405,162
11
2
null
2011-06-19 21:06:06.343 UTC
85
2022-09-08 18:37:58.853 UTC
2021-09-15 20:11:12.87 UTC
null
330,315
null
90,268
null
1
570
postgresql|bash|command-line|psql
517,269
<p>From the <a href="http://www.postgresql.org/docs/8.3/static/app-psql.html" rel="noreferrer">official documentation</a>:</p> <blockquote> <p>It is also convenient to have a ~/.pgpass file to avoid regularly having to type in passwords. See <a href="http://www.postgresql.org/docs/8.3/static/libpq-pgpass.html" rel="...
15,685,975
Google Forms onsubmit
<p>How does one reference the default 'Submit' Forms button to link the <em>'onsubmit'</em> trigger with another action? Thank you.</p> <p>For example, with onsubmit, </p> <pre><code>Logger.log('do something'); </code></pre>
15,689,011
6
1
null
2013-03-28 15:34:20.09 UTC
8
2020-10-27 08:04:43.83 UTC
2016-06-08 14:16:15.607 UTC
null
1,677,912
null
2,012,403
null
1
18
google-apps-script|google-forms
56,451
<p>One doesn't. The Form Service does not allow any programmatic control over the product. There is an <a href="http://code.google.com/p/google-apps-script-issues/issues/detail?id=2383" rel="noreferrer">open issue</a> on the Issue Tracker for this general topic. Star it to "vote", and receive updates.</p> <p>However, ...
16,015,022
WebRTC: How to add stream after offer and answer?
<p>I am working on webRTC video calling. I got datachannel successfully implemented. Now I would like to add video stream to the same peer connection. </p> <p>I have read that stream should be added before answer and offer. Is there a way to add stream after answer or offer?</p> <p>In case I have added stream before ...
16,460,621
3
0
null
2013-04-15 12:20:57.947 UTC
9
2017-07-28 06:53:03.337 UTC
2017-07-28 06:53:03.337 UTC
null
5,894,241
null
1,307,915
null
1
28
javascript|webrtc
12,880
<p>To add stream after creating complete signalling, the Peer connection should <strong>renegotiate</strong> with stream.</p> <pre><code>pc1.addstream(stream) </code></pre> <p>Then once again create offer and send it to other Peer.</p> <p>Remote peer will add stream and send answer SDP.</p> <p>To stop streams:</p> ...
15,521,954
Deleting using LEFT JOIN
<p>I want to delete from a table depending on data that exists on another table that references the first, however, I have the code that works and shows the value to be deleted when I run it as a SELECT stetement, however when I change that to DELETE it gives me errors, that I don't understand why they're there.</p> <...
15,522,132
5
3
null
2013-03-20 11:14:24.8 UTC
3
2015-07-03 21:42:30.387 UTC
2015-07-03 21:42:30.387 UTC
null
4,370,109
null
495,123
null
1
36
sql|postgresql|join|left-join
93,236
<p>From where I see it, you don't actually need a join to perform this...</p> <pre><code>DELETE FROM coursework.leadCustomer WHERE leadCustomer.customerID NOT IN ( SELECT distinct customerID FROM coursework.flightBooking where status IN ('R','H') ) AND leadCustomer.customerID = 8; </code></pre> <p>it will delete ...
15,773,662
Symfony2 Doctrine Expr 'IS NOT NULL'
<p>I'm using the <strong>FormType</strong> for an <strong>Entity</strong> of mine, and setting up an <a href="http://symfony.com/doc/2.1/reference/forms/types/entity.html" rel="nofollow noreferrer">entity field</a>. I need two <code>Where</code> clauses in an <code>And</code>, and from what I've read on <a href="http:/...
15,781,504
3
0
null
2013-04-02 20:23:51.97 UTC
3
2019-11-25 12:24:09.883 UTC
2019-07-16 20:56:35.533 UTC
null
6,349,751
null
212,307
null
1
38
symfony|doctrine-orm
66,805
<p>You can use <a href="https://github.com/doctrine/doctrine2/blob/2.3.2/lib/Doctrine/ORM/Query/Expr.php#L459-L468"><code>isNotNull</code></a>:</p> <pre class="lang-php prettyprint-override"><code>'query_builder' =&gt; function ($er){ $qb = $er-&gt;createQueryBuilder('p'); $qb -&gt;where($qb-&gt;expr()...
50,332,119
Is it possible to make an in-app button that triggers the PWA "Add to Home Screen" install banner?
<p>I understand that with a properly made Progressive Web App mobile browsers will display a banner prompting users to 'Install' the app on their home screen.</p> <p>I have been looking around for a way to trigger that prompt from within the app, but have not been able to find anything.</p> <p>Is there a line of JavaSc...
64,727,286
7
6
null
2018-05-14 13:56:06.023 UTC
14
2021-01-20 13:30:44.677 UTC
2020-11-07 11:44:30.013 UTC
null
8,620,945
null
8,620,945
null
1
50
javascript|service-worker|progressive-web-apps
48,052
<p>Thanks for all the great answers. Recently it appears that things have become more standardized, and there is a solid way of doing things <em>in chrome at least</em> that allows users to click and install the app even if they missed the prompt etc.</p> <p><a href="https://petelepage.com/" rel="noreferrer">Pete LePag...
10,611,927
SimpleCursorTreeAdapter and CursorLoader for ExpandableListView
<p>I am trying to asynchronously query a provider by using a <code>CursorLoader</code> with a <code>SimpleCursorTreeAdapter</code> </p> <p>Here is my <code>Fragment</code> class which implements the <code>CursorLoader</code> </p> <pre><code>public class GroupsListFragment extends ExpandableListFragment impleme...
10,989,548
3
4
2012-05-21 06:45:40.077 UTC
2012-05-16 04:18:42.827 UTC
22
2014-12-17 12:04:21.107 UTC
2012-10-20 22:28:41.73 UTC
null
502,671
null
502,671
null
1
22
android|simplecursoradapter|expandablelistadapter|android-cursorloader
21,918
<p>So i figured out that I needed to map loaderids to groupPositions and this solved my issue:</p> <p>Here is my <code>Fragment</code> class which implements the <code>CursorLoader</code> </p> <pre><code>public class GroupsListFragment extends ExpandableListFragment implements LoaderManager.LoaderCallbacks&lt;Cu...
10,600,863
Overlaying DIVs with z-index
<p>I am trying to overlay a div over my entire page to show a pop-up. The problem is, it won't overlay over the entire page. Here is an approximation of the code:</p> <pre><code>&lt;div style="z-index:902;"&gt; &lt;div style="position: fixed; width: 100%; height: 100%; left: 0; top: 0;"&gt; Overlay &lt...
10,600,924
6
6
null
2012-05-15 12:40:12.87 UTC
1
2018-09-12 17:54:13.89 UTC
null
null
null
null
970,789
null
1
3
css|html|overlay
46,740
<p>Working <a href="http://jsfiddle.net/zuul/H5NB8/" rel="nofollow noreferrer">Fiddle Example!</a></p> <p>If you limit the scope of this problem to the code that you've presented, it is working just fine! e.g., On the Fiddle you can see that I placed a background color to the <code>position:fixed</code> <code>div</cod...
46,358,013
Secure Google Cloud Functions http trigger with auth
<p>I am trying out Google Cloud Functions today following this guide: <a href="https://cloud.google.com/functions/docs/quickstart" rel="noreferrer">https://cloud.google.com/functions/docs/quickstart</a></p> <p>I created a function with an HTTP trigger, and was able to perform a POST request to trigger a function to wr...
46,924,504
7
11
null
2017-09-22 06:14:49.75 UTC
12
2021-10-29 19:30:36.77 UTC
null
null
null
null
1,368,032
null
1
48
security|authentication|google-cloud-datastore|google-cloud-functions
18,252
<p>After looking into this further, and taking a hint from @ricka's answer, I have decided to implement an authentication check for my cloud functions with a JWT token passed in in the form of an Authorization header access token.</p> <p>Here's the implementation in Node:</p> <pre><code>const client = jwksClient({ ...
31,745,168
How to test Classes with @ConfigurationProperties and @Autowired
<p>I want to test small parts of the application that rely on properties loaded with <code>@Autowired</code> and <code>@ConfigurationProperties</code>. I am looking for a solution loading only the required properties and not always the whole <code>ApplicationContext</code>. Here as reduced example:</p> <pre><code>@Tes...
31,748,450
5
5
null
2015-07-31 11:33:07.973 UTC
10
2020-09-28 18:35:13.817 UTC
2019-10-21 10:42:34.267 UTC
null
3,657,460
null
4,494,324
null
1
51
java|properties|spring-boot
78,613
<p>A couple points:</p> <ol> <li><p>You don't need a "TestConfiguration" class in your main package, because all it's doing is configuring the "TestSettings" bean. You can do this simply by annotating the TestSettings class itself.</p></li> <li><p>Normally you would load the context you need for the test using the <s...
10,680,961
mysql - How to concatenate strings and convert to date the strings?
<h2>Please take a look at my stored procedure code.</h2> <pre><code>CREATE DEFINER=`ninjaboy`@`%` PROCEDURE `getMonthlyTotalScore`(IN ninjaId int, IN month int, IN year int) BEGIN DECLARE startDate DATE; DECLARE endDate DATE; DECLARE maxDay INTEGER; SELECT DAY(LAST_DAY(year + '-' + month + '-01')) IN...
10,681,317
3
13
null
2012-05-21 07:20:25.117 UTC
null
2012-05-21 08:15:33.383 UTC
2012-05-21 07:45:52.903 UTC
null
1,066,828
null
991,229
null
1
3
mysql|stored-procedures
68,118
<p><strong>CONCAT() is the key.</strong></p> <h2>BEFORE:</h2> <pre><code>mysql&gt; CREATE PROCEDURE `getMonthlyTotalScore`(IN ninjaId int, IN month int, IN year int) -&gt; BEGIN -&gt; DECLARE startDate DATE; -&gt; DECLARE endDate DATE; -&gt; DECLARE maxDay INTEGER; ...
13,268,361
bootstrap "tooltip" and "popover" add extra size in table
<blockquote> <p><strong>Note:</strong><br> Depending on you Bootstrap version (prior to 3.3 or not), you may need a different answer.<br> Pay attention to the notes.</p> </blockquote> <p>When I activate tooltips (hover over the cell) or popovers in this code, size of table is increasing. How can I avoid this?</p...
13,269,857
7
5
null
2012-11-07 11:01:45.593 UTC
17
2019-01-22 05:30:29.187 UTC
2016-01-19 17:00:19.703 UTC
null
1,238,019
null
1,291,049
null
1
85
javascript|twitter-bootstrap|twitter-bootstrap-3|tooltip
79,108
<blockquote> <p><strong>Note:</strong> Solution for Bootstrap 3.0 ~ 3.2</p> </blockquote> <p>You need to create an element inside a <code>td</code> and apply a tooltip to it, like <a href="http://jsfiddle.net/sZdYE/3/">this</a>, because a tooltip itself is a div, and when it is placed after a <code>td</code> element...
13,400,075
Reflection generic get field value
<p>I am trying to obtain a field's value via reflection. The problem is I don't know the field's type and have to decide it while getting the value.</p> <p>This code results with this exception:</p> <blockquote> <p>Can not set java.lang.String field com....fieldName to java.lang.String</p> </blockquote> <pre class="lan...
13,401,094
9
1
null
2012-11-15 14:55:24.02 UTC
41
2022-07-07 05:29:55.597 UTC
2021-03-11 11:41:22 UTC
null
2,164,365
null
1,012,646
null
1
170
java|reflection
448,392
<p>Like answered before, you should use:</p> <pre><code>Object value = field.get(objectInstance); </code></pre> <p>Another way, which is sometimes prefered, is calling the getter dynamically. example code:</p> <pre><code>public static Object runGetter(Field field, BaseValidationObject o) { // MZ: Find the correc...
39,500,634
Use xcodebuild (Xcode 8) and automatic signing in CI (Travis/Jenkins) environments
<p>With the release of Xcode 8, Apple introduced a new way of managing the signing configuration. Now you have two options <code>Manual</code> and <code>Automatic</code>.</p> <p>According to the WWDC 2016 Session about Code signing <a href="https://developer.apple.com/videos/play/wwdc2016/401/" rel="noreferrer">(WWDC ...
39,598,052
8
5
null
2016-09-14 22:32:07.01 UTC
45
2017-09-28 15:11:43.353 UTC
2016-09-15 04:37:26.527 UTC
null
805,755
null
805,755
null
1
80
xcode|jenkins|continuous-integration|travis-ci|xcodebuild
63,110
<p>After trying a few options, these are the solutions that I was able to use on my CI server:</p> <ul> <li><h3>Include the Developer certificate and private key as well as the auto generated provisioning profiles in the CI environment:</h3></li> </ul> <p>Using <code>Automatic signing</code> forces you to use a <code...
20,532,640
What is the maximum size for the postMessage method that enables inter-frame communication?
<p>It's not clear from searching on Google and looking through documentation. What's the maximum length on a message sent via <code>Window.postMessage</code> (<a href="https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessag...
24,712,574
1
2
null
2013-12-12 00:16:59.113 UTC
4
2021-10-03 08:25:04.59 UTC
2021-10-03 08:25:04.59 UTC
null
4,370,109
null
144,088
null
1
31
javascript|html|iframe|dom-events
11,839
<p>As a data point, the WebKit implementation (used by Safari and Chrome) doesn't currently enforce any limits (other than those imposed by running out of memory).</p> <p>Source : <a href="https://lists.w3.org/Archives/Public/public-whatwg-archive/2009Oct/0546.html" rel="nofollow noreferrer">https://lists.w3.org/Archiv...
24,119,920
How to plot a density map in python?
<p>I have a .txt file containing the x,y values of regularly spaced points in a 2D map, the 3rd coordinate being the density at that point.</p> <pre><code>4.882812500000000E-004 4.882812500000000E-004 0.9072267 1.464843750000000E-003 4.882812500000000E-004 1.405174 2.441406250000000E-003 4.882812500000000E-004 ...
24,122,985
2
2
null
2014-06-09 12:04:27.08 UTC
14
2016-02-04 21:51:11.107 UTC
2014-06-09 13:53:34.243 UTC
null
249,341
null
3,722,235
null
1
32
python|matplotlib|histogram
70,754
<p>Here is my aim at a more complete answer including choosing the color map and a logarithmic normalization of the color axis.</p> <pre><code>import matplotlib.pyplot as plt import matplotlib.cm as cm from matplotlib.colors import LogNorm import numpy as np x, y, z = np.loadtxt('data.txt', unpack=True) N = int(len(z)...
4,032,829
Correct way to poll server in background
<p>Assuming this is possible, I would like my iOS application, when backgrounded, to poll a server (i.e. essentially, retrieve the contents of a URL every 30 minutes and notify the user if it contains something "interesting"), essentially in a similar way to the way the built-in mail client assumedly works if you're no...
4,032,990
2
0
null
2010-10-27 11:46:19.093 UTC
12
2010-10-27 12:13:06.49 UTC
null
null
null
null
48,933
null
1
17
iphone|multitasking
7,607
<p>What you want to do, is not covered under the multitasking features of iOS4. There are only a few types of applications allowed to run in the background for long periods of time (more than 10 minutes), and generic networking applications aren't one of them.</p> <p>However, all is not lost. What you can do, and what...
3,962,939
What's the difference between undefined in Haskell and null in Java?
<p>Both are terms whose type is the intersection of all types (uninhabited). Both can be passed around in code without failing until one attempts to evaluate them. The only difference I can see is that in Java, there is a loophole which allows <code>null</code> to be evaluated for exactly one operation, which is refere...
3,963,464
2
6
null
2010-10-18 20:05:41.483 UTC
11
2011-04-16 20:22:58.563 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
231,853
null
1
52
java|haskell|types|null|option-type
8,026
<blockquote> <p>What's the difference between undefined in Haskell and null in Java?</p> </blockquote> <p>Ok, let's back up a little.</p> <p>"undefined" in Haskell is an example of a "bottom" value (denoted ⊥). Such a value represents any undefined, stuck or partial state in the program.</p> <p>Many different form...
9,639,642
How to round unix timestamp up and down to nearest half hour?
<p>Ok so I am working on a calendar application within my CRM system and I need to find the upper and lower bounds of the half an hour surrorunding the timestamp at which somebody entered an event in the calendar in order to run some SQL on the DB to determine if they already have something booked in within that timesl...
9,639,719
10
2
null
2012-03-09 19:09:20.907 UTC
8
2018-11-12 18:31:23.567 UTC
null
null
null
null
1,232,920
null
1
30
php|datetime|unix-timestamp
44,496
<p>Use modulo.</p> <pre><code>$prev = 1330518155 - (1330518155 % 1800); $next = $prev + 1800; </code></pre> <p>The modulo operator gives the remainder part of division.</p>
16,286,921
How do I remove a specific bullet point within a ul in CSS?
<p>I have a simple list and all I want to do is remove a specific bullet point (just the icon, not the content within the li) within the <code>ul</code>.</p> <p>I've used first-child to take away the first but I'd like to remove the sixth bullet point!</p> <p>I could so it inline but I'd prefer to do it with CSS.</p>...
16,286,954
2
3
null
2013-04-29 19:43:25.357 UTC
null
2013-04-29 20:06:34.46 UTC
2013-04-29 19:54:07.14 UTC
null
2,333,483
null
2,333,483
null
1
26
css
65,418
<p><a href="http://jsfiddle.net/5d4TU/"><strong>jsFiddle here.</strong></a></p> <p>You can use the <a href="http://www.w3schools.com/cssref/sel_nth-child.asp"><strong>nth-child</strong></a> selector to achieve this.</p> <hr> <pre><code>li:nth-child(6) { list-style-type: none; } </code></pre> <hr> <p><strong>Ed...
16,179,293
System.Web.Optimization and Microsoft.Web.Optimization won't load reference in vs 2012
<p>I'm working on an MVC 4 project started in Visual Studio 2010. Right now I'm working on a machine with Visual Studio 2012 as I don't have access to the machine I was originally working on. I tried all morning to find answers, but they don't seem to help my situation.</p> <p>I followed <a href="https://stackoverflow...
16,179,825
12
2
null
2013-04-23 21:13:53.057 UTC
5
2020-05-01 15:05:42.84 UTC
2017-05-23 12:02:14.477 UTC
null
-1
null
1,721,849
null
1
34
asp.net-mvc|asp.net-optimization
69,631
<p>This is a long shot but here it goes anyway, right click on the project --> Property Pages and make sure System.Web.Optimization entry exists. If not, copy the System.Web.Optimization.dll to your bin folder or import it as a reference.</p> <p>Edit: mvc projects don't have the "Property pages" menu option.</p> <p>O...
16,240,581
How to get a Brush from a RGB Code?
<p>How can I get a <code>Brush</code> to set a Background of e.g. a <code>Grid</code> from a RGB Code.</p> <p>I hace the RGB Code as a <code>int</code>:</p> <pre><code>R = 12 B = 0 G = 255 </code></pre> <p>I need to know how to convert it into a <code>Brush</code></p>
16,240,625
1
1
null
2013-04-26 15:57:31.243 UTC
6
2017-11-14 11:04:13.75 UTC
null
null
null
null
437,242
null
1
47
c#|windows-runtime
66,665
<pre><code>var brush = new SolidColorBrush(Color.FromArgb(255, (byte)R, (byte)G, (byte)B)); myGrid.Background = brush; </code></pre>
16,353,211
Check if year is leap year in javascript
<pre><code> function leapYear(year){ var result; year = parseInt(document.getElementById("isYear").value); if (years/400){ result = true } else if(years/100){ result = false } else if(years/4){ result= true } else{ result= false } return result } </c...
16,353,241
7
3
null
2013-05-03 06:49:24.967 UTC
16
2020-09-29 16:53:58.763 UTC
2014-06-25 20:54:48.407 UTC
null
2,246,344
null
2,342,934
null
1
91
javascript|date|conditional-statements|date-arithmetic
133,743
<pre><code>function leapYear(year) { return ((year % 4 == 0) &amp;&amp; (year % 100 != 0)) || (year % 400 == 0); } </code></pre>
37,347,690
How to replace div with another div in javascript?
<p>How to replace div with another div in javascript? </p> <p>This is what I have:</p> <pre><code>&lt;div id="main_place"&gt; main &lt;/div&gt; &lt;button onclick="show(operation1)"&gt;Replace to operation 1&lt;/button&gt; &lt;button onclick="show(operation2)"&gt;Replace to operation 2&lt;/button&gt; &lt;button oncl...
37,347,842
7
4
null
2016-05-20 13:14:40.223 UTC
5
2021-11-28 22:00:55.61 UTC
null
null
null
null
5,515,945
null
1
4
javascript|html
51,691
<p>Pass strings into your method and get the other div</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="main_place"&gt; main &lt;/div&gt; &lt;button onclick="show('operation1')...
26,865,596
No injectable field found in FXML Controller class
<p>It's about JavaFX. When i want to inject fx:id in Scene Builder, i get this warning: <br />No injectable field found in FXML Controller class for the id 'something'. <br />I wanted to ignore it, and created a function, but it didn't work either. I created mainController class and added it into my FXML file. Here are...
26,867,348
2
2
null
2014-11-11 13:03:04.707 UTC
3
2016-08-15 16:22:14.25 UTC
2014-11-11 14:08:10.89 UTC
null
3,497,814
null
3,497,814
null
1
6
java|javafx|fxml|scenebuilder
38,492
<p>In Scene Builder, if the FXML file is associated to a controller class, you know that what makes the connection between the variable in the controller class (<code>pb</code>) and the object in the FXML file (<code>&lt;ProgressBar ... /&gt;</code>) is the value of the object's <code>fx:id</code>.</p> <p>So when you ...
17,462,682
Set element to unclickable and then to clickable
<p>I want to have a div element set to not be clickable and then set it to clickable after another element is clicked.</p> <p>So, when .case is clicked:</p> <pre><code>$('.case').click(function() { $('#patient').addClass('active').on('click'); }); </code></pre> <p>But how do I set #patient to unclickable in the fi...
17,462,715
6
2
null
2013-07-04 05:45:09.287 UTC
7
2017-09-20 01:48:47.76 UTC
null
null
null
null
1,911,619
null
1
20
jquery
61,545
<pre><code>$('#patient').on('click', function() { if ( $(this).hasClass('active') ) { // do whatever when it's active. } return false; }); </code></pre> <p>If you just want it to not accept, you can add this to your css (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events" rel=...
17,336,943
Removing non numeric characters from a string
<p>I have been given the task to remove all non numeric characters including spaces from a either text file or string and then print the new result next to the old characters for example:</p> <p>Before:</p> <pre><code>sd67637 8 </code></pre> <p>After:</p> <pre><code>676378 </code></pre> <p>As i am a beginner i do not k...
17,337,613
8
2
null
2013-06-27 07:19:03.147 UTC
7
2022-09-11 18:13:24.667 UTC
2020-12-02 04:57:32.66 UTC
null
3,691,003
null
1,840,618
null
1
61
python|python-3.x|python-3.3
94,712
<p>The easiest way is with a regexp</p> <pre><code>import re a = 'lkdfhisoe78347834 (())&amp;/&amp;745 ' result = re.sub('[^0-9]','', a) print result &gt;&gt;&gt; '78347834745' </code></pre>
18,731,559
Pass html string to server side with Jquery Ajax
<p>i have seen a lot of answers in this site that have helped me a lot but in this one i need to ask guys to help me out.</p> <p>i have a textarea as a Html editor to pass html content to the server and append it to a newly created Html page( for user POST,etc), but jquery or ASP.NET does not accept the Html content ...
18,733,994
3
2
null
2013-09-11 02:05:19.047 UTC
1
2014-10-20 15:54:47.873 UTC
2013-09-11 02:29:39.373 UTC
null
1,404,239
null
2,766,936
null
1
6
c#|jquery|asp.net|ajax
39,333
<p>Pass it like this</p> <pre><code>JSON.stringify({'num':HTML}); </code></pre> <p>You have to stringify the content to JSON properly. HTML may contain synataxes that would make the JSON notation invalid.</p> <pre><code>var dataToSend = JSON.stringify({'num':HTML}); $.ajax({ url: "EditingTextarea.aspx/GetValue"...
26,019,011
Sql Server Operand type clash: date is incompatible with int
<p>When I try to execute this code I get an error at the 'with DateDimension' line:</p> <blockquote> <p>Msg 206, Level 16, State 2, Line 15<br> Operand type clash: date is incompatible with int</p> </blockquote> <p>This is the SQL query I am using:</p> <pre><code>declare @DateCalendarStart date, @DateCa...
26,019,251
1
3
null
2014-09-24 14:07:27.483 UTC
1
2014-09-24 14:42:34.41 UTC
2014-09-24 14:42:34.41 UTC
null
13,302
null
3,890,722
null
1
2
sql|sql-server
38,937
<p>Your problem is with the <code>DateCalendarValue + 1</code> portion. Try using <code>DATEADD()</code>, as below:</p> <pre><code>declare @DateCalendarStart date, @DateCalendarEnd date, @FiscalCounter date, @FiscalMonthOffset int; set @DateCalendarStart = '2011-01-28'; set @DateCal...
9,272,535
How to get a file via GitHub APIs
<p>I need to get the contents of a file hosted in a GitHub repo. I'd prefer to get a JSON response with metadata along with it. I've tried numerous URLs with cURL with to only get a response of <code>{"message":"Not Found"}</code>. I just need the URL structure. If it matters, it's from an organization on GitHub. Here'...
14,773,895
2
4
null
2012-02-14 06:15:25.75 UTC
6
2021-11-27 15:56:34.86 UTC
null
null
null
null
652,722
null
1
20
api|github
60,552
<p>As the description (located at <a href="http://developer.github.com/v3/repos/contents/">http://developer.github.com/v3/repos/contents/</a>) says:</p> <p>/repos/:owner/:repo/contents/:path</p> <p>An ajax code will be:</p> <pre><code>$.ajax({ url: readme_uri, dataType: 'jsonp', success: function(results...
9,031,023
Filter Map by key set
<p>Is there a shortcut to filter a Map keeping only the entries where the key is contained in a given Set?</p> <p>Here is some example code</p> <pre><code>scala&gt; val map = Map("1"-&gt;1, "2"-&gt;2, "3"-&gt;3) map: scala.collection.immutable.Map[java.lang.String,Int] = Map(1 -&gt; 1, 2 -&gt; 2, 3 -&gt; 3) scala&gt...
9,031,524
3
4
null
2012-01-27 09:08:42.487 UTC
8
2012-02-09 20:23:17.977 UTC
2012-01-27 09:16:34.963 UTC
null
252,552
null
252,552
null
1
29
scala
18,974
<h2>Answering the Question</h2> <p>You can take advantage of the fact that a <code>Set[A]</code> is a predicate; i.e. <code>A =&gt; Boolean</code></p> <pre><code>map filterKeys set </code></pre> <p>Here it is at work:</p> <pre><code>scala&gt; val map = Map("1" -&gt; 1, "2" -&gt; 2, "3" -&gt; 3) map: scala.collectio...
9,024,819
free cloud data stores that use get/post?
<p>I know that there are other key/value stores similar to <a href="http://openkeyval.org">http://openkeyval.org</a> out there but i cannot remember their names. </p> <p>Please enlighten me.</p> <p>i need the following features:</p> <ul> <li>free</li> <li>can be used via 100% clientside code</li> <li>fast and easy t...
30,934,715
5
5
null
2012-01-26 20:25:33.067 UTC
14
2015-08-04 20:15:13.05 UTC
2012-02-08 20:38:29.217 UTC
null
26,188
null
26,188
null
1
36
javascript|hashmap|cloud
20,095
<p>I needed something like that, so I've built this: <a href="http://www.kvstore.io" rel="noreferrer">KVStore.io, a simple key/value API based storage service</a></p> <p>It's still under heavy development (it's an alpha version...) but I'm using it to store some stuffs (like website marketing forms) and it's working n...
18,376,416
The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig
<p>I have incorporate <code>SpatialIite</code> into a Xcode project which uses a header file from <code>Proj.4</code>, just one header. Both are Xcode projects and have static targets.</p> <p>I'm trying to migrate from git submodule to Cocoapods. Since static targets seems to be difficult to use with Cocoapods, I just...
26,077,106
12
1
null
2013-08-22 09:22:45.103 UTC
72
2021-12-18 17:11:17.277 UTC
2016-12-06 06:30:09.54 UTC
null
3,909,115
null
133,747
null
1
250
xcode|cocoapods
146,277
<p>This definitely works most of the time:</p> <p>Go to your target Build Settings -> Other linker flags -> double click . Add <code>$(inherited)</code> to a new line.</p> <p>If you have problem with "...target overrides the GCC_PREPROCESSOR_DEFINITIONS build setting defined in..." then you must add $(inherited) to y...
15,234,959
Cross-compiling for ARM with Autoconf
<p>I am having trouble cross-compiling a library for my arm board using autconf.</p> <p>I am using this line:</p> <pre><code>./configure --target=arm-linux --host=arm-linux --prefix=/bla/bla/bla/linux_arm_tool CFLAGS='-m32' make make install </code></pre> <p>When I do <code>file</code> to check it I get:</p> <pre><...
15,235,752
4
0
null
2013-03-05 21:58:29.753 UTC
6
2018-10-11 02:17:22.427 UTC
2018-10-08 12:24:12.167 UTC
null
608,639
null
1,070,108
null
1
16
c|cross-compiling|autoconf
54,774
<p>So I knew I've cross compiled before using really basic method calls and I figured out why I've gotten away with this before after examining the output:</p> <pre><code>checking for arm-linux-gnueabi-gcc... no checking for gcc... gcc ... ... checking for arm-linux-gnueabi-gcc... gcc </code></pre> <p>In my <code>/us...
14,922,130
Which error message is better when users entered a wrong password?
<p>Is there any differences between the following two error messages from security point of view when users entered a wrong password?</p> <blockquote> <p>Wrong username or password.</p> <p>Wrong password.</p> </blockquote> <p>For example, when you enter a wrong password on the <code>Gmail.com</code>, it will tell you &...
14,922,163
5
2
null
2013-02-17 14:30:25.82 UTC
1
2022-07-27 02:50:06.61 UTC
2021-02-17 22:29:57.62 UTC
null
4,539,709
null
1,109,791
null
1
26
security|authentication|passwords
72,455
<p>The idea is to not give hackers extra information. If you say wrong password, you've told a hacker that they have a correct username, and vice-versa. Although what you've said is true, on some sites it is possible to determine if you've guessed a username via other means. </p>
7,762,838
Forward References - why does this code compile?
<p>Consider this snippet:</p> <pre><code> object A { val b = c val c = "foo" } println( A.b ) // prints "null" </code></pre> <p>As part of a larger program, this would lead to a failure at runtime. The compiler apparently permits the forward reference from 'b' to (uninitialized) 'c' but 'b' is left with...
7,763,041
2
4
null
2011-10-14 03:49:39.93 UTC
8
2018-05-22 08:38:35.76 UTC
2013-06-13 17:21:35.787 UTC
null
442,945
null
820,380
null
1
31
scala|initialization|lazy-evaluation
5,854
<p>The body of a class or an object is the primary constructor. A constructor, like a method, is a sequence of statements that are executed in order -- to do anything else, it would have to be a very different language. I'm pretty sure you wouldn't like for Scala to execute the statements of your methods in any other o...
66,734,015
LateInitializationError: Field '_userData@32329253' has not been initialized
<p>Getting this when trying to initialize data.</p> <blockquote> <p>The following LateError was thrown building UserProfile(dirty, state: _UserProfileState#752a9): LateInitializationError: Field '_userData@32329253' has not been initialized.&quot;</p> </blockquote> <p>Here's the code:</p> <pre><code> late final User...
66,734,486
3
5
null
2021-03-21 15:13:57.627 UTC
2
2022-01-25 08:41:56.597 UTC
2021-03-21 17:40:18.99 UTC
null
7,015,400
null
14,416,421
null
1
25
firebase|flutter|dart|google-cloud-firestore
57,922
<p>Even though you are initializing these variables inside the <code>initUser()</code>, but you will get this error if you are using the variables inside the <code>build()</code> method since <code>initUser()</code> is asynchronous meaning it will take time to get the data from the collection. To solve this you can do:...
8,824,831
Make div stay at bottom of page's content all the time even when there are scrollbars
<p><a href="https://stackoverflow.com/questions/2140763/css-push-div-to-bottom-of-page">CSS Push Div to bottom of page</a></p> <p>Please look at that link, I want the opposite: When the content overflows to the scrollbars, I want my footer to be always at the <strong>complete</strong> bottom of the page, like Stack Ov...
8,824,859
12
3
null
2012-01-11 18:43:22.863 UTC
114
2020-08-07 04:26:50.657 UTC
2017-05-23 12:34:45.403 UTC
null
-1
null
1,020,773
null
1
313
css|positioning|css-position|footer
835,051
<p>This is precisely what <code>position: fixed</code> was designed for:</p> <pre class="lang-css prettyprint-override"><code>#footer { position: fixed; bottom: 0; width: 100%; } </code></pre> <p>Here's the fiddle: <a href="http://jsfiddle.net/uw8f9/">http://jsfiddle.net/uw8f9/</a></p>
8,378,338
What does Connect.js methodOverride do?
<p>The Connect.js <a href="http://www.senchalabs.org/connect/methodOverride.html">very terse documentation</a> says <code>methodOverride</code></p> <blockquote> <p>Provides faux HTTP method support.</p> </blockquote> <p>What does that mean? The <a href="http://www.google.co.uk/#sclient=psy-ab&amp;hl=en&amp;source=h...
8,378,414
1
3
null
2011-12-04 20:23:57.16 UTC
37
2014-12-14 16:15:28.37 UTC
2014-12-14 16:15:28.37 UTC
null
1,779,688
null
707,381
null
1
116
node.js|connect.js
22,939
<ul> <li>If you want to simulate <code>DELETE</code> and <code>PUT</code>, <code>methodOverride</code> is for that.</li> <li>If you pass in the _method post parameter set to <em>'delete'</em> or <em>'put'</em>, then you can use <code>app.delete</code> and <code>app.put</code> in Express instead of using <code>app.post<...
5,437,335
Django Queryset with filtering on reverse foreign key
<p>I have the following Django model:</p> <pre><code>class Make: name = models.CharField(max_length=200) class MakeContent: make = models.ForeignKey(Make) published = models.BooleanField() </code></pre> <p>I'd like to know if it's possible (without writing SQL directly) for me to generate a queryset that co...
5,437,609
5
1
null
2011-03-25 19:40:58.407 UTC
28
2020-01-28 19:21:27.947 UTC
2016-05-23 20:30:44.96 UTC
null
895,245
null
369,722
null
1
86
django|model|filter|django-queryset
74,744
<p>Django doesn't support the <code>select_related()</code> method for reverse foreign key lookups, so the best you can do without leaving Python is two database queries. The first is to grab all the <code>Makes</code> that contain <code>MakeContents</code> where <code>published = True</code>, and the second is to grab...
5,188,224
"throw new Warning" in JavaScript?
<p>At the moment I'm extending my JavaScript project with error handling. The <code>throw</code> statement is playing an important role here:</p> <pre><code>throw new Error("text"); // Error: text </code></pre> <p>However, can I also throw a warning? I tried the following to no avail:</p> <pre><code>throw new Warnin...
5,188,244
6
0
null
2011-03-04 00:09:49.377 UTC
6
2019-03-14 21:23:04.723 UTC
2012-01-30 16:12:25.203 UTC
null
514,749
null
514,749
null
1
63
javascript|error-handling|throw
37,928
<p>Like this:</p> <pre><code>console.warn('Hi!'); </code></pre> <p>Note that unlike exceptions, this will not interrupt your code; the calling function will continue normally.</p> <p>Also note that this will throw an error in any browser except for WebKits or Firefox with Firebug, because <code>console</code> won't ...
4,941,288
How can I get the executing assembly version?
<p>I am trying to get the executing assembly version in C# 3.0 using the following code:</p> <pre><code>var assemblyFullName = Assembly.GetExecutingAssembly().FullName; var version = assemblyFullName .Split(',')[1].Split('=')[1]; </code></pre> <p>Is there another proper way of doing so?</p>
4,941,305
6
0
null
2011-02-09 04:23:02.667 UTC
24
2019-06-06 20:13:31.257 UTC
2015-07-19 11:56:26.283 UTC
null
63,550
null
609,182
null
1
201
c#|.net|.net-assembly
156,150
<p>Two options... regardless of application type you can always invoke:</p> <pre><code>Assembly.GetExecutingAssembly().GetName().Version </code></pre> <p>If a <a href="http://en.wikipedia.org/wiki/Windows_Forms">Windows Forms</a> application, you can always access via application if looking specifically for product v...
4,890,915
Is there a Task based replacement for System.Threading.Timer?
<p>I'm new to .Net 4.0's Tasks and I wasn't able to find what I thought would be a Task based replacement or implementation of a Timer, e.g. a periodic Task. Is there such a thing?</p> <p><em><strong>Update</em></strong> I came up with what I think is a solution to my needs which is to wrap the "Timer" functionality i...
23,814,733
7
1
null
2011-02-03 19:48:22.613 UTC
56
2021-05-03 02:58:29.62 UTC
2013-05-06 15:29:14.673 UTC
null
200,449
null
222,434
null
1
99
c#|.net-4.0|timer|timeout|task-parallel-library
76,490
<p>It depends on 4.5, but this works. </p> <pre><code>public class PeriodicTask { public static async Task Run(Action action, TimeSpan period, CancellationToken cancellationToken) { while(!cancellationToken.IsCancellationRequested) { await Task.Delay(period, cancellationToken); ...
16,784,460
PrimeFaces p:selectOneMenu width
<p>I want <code>p:selectOneMenu</code> width to be auto regarding to the parent cell not regarding to the values it has.</p> <pre><code>&lt;p:panelGrid&gt; &lt;p:row&gt; &lt;p:column&gt;&lt;p:outputLabel value="Value01" for="idInput01"/&gt;&lt;/p:column&gt; &lt;p:column&gt;&lt;p:inputText value="#...
16,807,465
9
1
null
2013-05-28 05:26:44.767 UTC
2
2018-06-19 04:16:39.067 UTC
2013-05-29 09:01:06.487 UTC
null
354,831
null
248,222
null
1
8
css|jsf-2|primefaces
52,748
<p><strong>i overrode</strong> <code>.ui-selectonemenu, .ui-selectonemenu-label</code> to:</p> <pre><code>.ui-selectonemenu{ width: 100% !important; } .ui-selectonemenu-label{ width: 100% !important; } </code></pre>
12,109,642
Loading .NET UserControls in IE with .NET 4.5
<p>There is a similar question: <a href="https://stackoverflow.com/questions/3334664/loading-net-usercontrols-in-ie-with-net-4-0">Loading .NET UserControls in IE with .NET 4.0</a> This question is essentially the same, but for <strong>.NET 4.5</strong></p> <p>That question starts with: <i>I've got a legacy app where ...
12,119,796
1
1
null
2012-08-24 12:44:24.91 UTC
14
2014-03-10 23:10:43.837 UTC
2017-05-23 12:19:20.7 UTC
null
-1
null
111,182
null
1
16
internet-explorer|user-controls|.net-4.5
17,005
<p>This is documented in the .NET 4.5 Application Compatibility Page on MSDN: <a href="http://msdn.microsoft.com/en-us/library/hh367887.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/hh367887.aspx</a> . Hosting managed controls inside IE is no longer supported out of the box (see half-way down under "We...
12,460,712
Convert LPWSTR to string
<p>Function <code>CommandLineToArgvW</code> is giving me commandline arguments in <code>LPWSTR</code> type. I need these arguments in <code>string</code>. Would someone please tell me how to convert <code>LPWSTR</code> to <code>string</code>?<br> I'm using mingw.</p>
12,460,812
4
1
null
2012-09-17 13:51:29.08 UTC
4
2022-07-30 17:33:52.167 UTC
2012-09-17 13:55:19.217 UTC
null
238,902
null
1,677,734
null
1
23
c++|winapi|mingw
46,515
<p>Try to use following API functions :</p> <ol> <li><p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%29.aspx" rel="nofollow noreferrer">WideCharToMultiByte</a> </p></li> <li><p><a href="http://msdn.microsoft.com/en-us/library/5d7tc9zw%28v=vs.71%29.aspx" rel="nofollow noreferrer"...
12,167,654
Fastest way to compute k largest eigenvalues and corresponding eigenvectors with numpy
<p>I have a large NxN dense symmetric matrix and want the eigenvectors corresponding to the k largest eigenvalues. What's the best way to find them (preferably using numpy but perhaps in general using blas/atlas/lapack if that's the only way to go)? In general N is much much larger then k (say N > 5000, k &lt; 10).</...
12,168,664
2
0
null
2012-08-28 21:16:18.98 UTC
11
2012-08-31 10:10:28.657 UTC
null
null
null
null
589,624
null
1
24
python|numpy|scipy|linear-algebra
38,165
<p>In SciPy, you can use the <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html">linalg.eigh</a> function, with the <code>eigvals</code> parameter.</p> <blockquote> <p>eigvals : tuple (lo, hi) Indexes of the smallest and largest (in ascending order) eigenvalues and corresponding ei...
12,501,231
What is the difference between $.proxy() and bind()?
<p>In 2009, ECMAScript 5 added a built-in <code>bind()</code> function which takes an object as a parameter and returns an identical function in which <code>this</code> will always refer to the object you passed it. (I couldn't find anything that looked like a canonical documentation link.)</p> <p>How is this differen...
12,501,276
5
0
null
2012-09-19 19:05:17.027 UTC
6
2015-05-19 17:16:40.903 UTC
2014-01-15 14:41:15.137 UTC
null
1,588,642
null
16,034
null
1
30
javascript|jquery|scope|closures|bind
16,259
<p><code>proxy</code> came first and you should likely favor <code>bind</code> as it is a standard. The way they are called varies slightly (due to being attached to <code>Function.prototype</code> vs just being a function) but their behavior is the same.</p> <p>There is a pretty good post here: <a href="https://stac...
12,593,576
Adapt an iterator to behave like a file-like object in Python
<p>I have a generator producing a list of strings. Is there a utility/adapter in Python that could make it look like a file?</p> <p>For example,</p> <pre><code>&gt;&gt;&gt; def str_fn(): ... for c in 'a', 'b', 'c': ... yield c * 3 ... &gt;&gt;&gt; for s in str_fn(): ... print s ... aaa bbb ccc &gt;&...
12,593,795
8
0
null
2012-09-26 02:04:12.4 UTC
13
2022-09-24 10:36:37.07 UTC
2012-09-26 02:29:15.113 UTC
null
23,643
null
23,643
null
1
32
python
13,171
<p>Here's a solution that should read from your iterator in chunks.</p> <pre><code>class some_magic_adaptor: def __init__( self, it ): self.it = it self.next_chunk = "" def growChunk( self ): self.next_chunk = self.next_chunk + self.it.next() def read( self, n ): if self.next_chunk == None: ...
12,089,655
Oracle client installation error - path too long
<p>I'm trying to install Oracle 11g Release 2 (client). But it gives an error like that :</p> <pre><code>Environment variable: "PATH" - This test checks whether the length of the environment variable "PATH" does not exceed the recommended length. Expected Value: 1023 Actual Value : 1028 List of errors: - PRVF-3929...
19,536,622
12
3
null
2012-08-23 10:31:18.187 UTC
3
2020-02-27 23:26:35.223 UTC
2019-12-13 19:04:45.35 UTC
null
10,908,375
null
1,293,752
null
1
33
oracle|oracle11g|oracleclient
96,778
<p>This limitation is <em>based on older Windows restrictions,</em> where length of environmental variables was important. This limitation is still there in the Oracle installation.</p> <p><strong><em>Work around this:</em></strong></p> <ul> <li>Step 1: Copy the value of your 'path' variable to a text-editor (Ex.: no...
12,272,778
How / Where to find Linux Kernel Bugs to Fix?
<p>I'm trying to find bugs that needs to be fixed in the Linux Kernel but I don't know where to look. I watched the video "How to Submit Your First Linux Kernel Patch" by Greg Kroah-Hartman on Youtube, but he doesn't really mention where to find bugs that needs to be fixed. </p> <p>In the video, he briefly mentions ma...
12,294,564
1
2
null
2012-09-04 23:48:59.353 UTC
17
2016-01-22 06:48:34.473 UTC
null
null
null
null
763,621
null
1
39
linux|kernel|patch
15,963
<p>1. Yes, you are right, one of the places to look is <a href="https://bugzilla.kernel.org/query.cgi?format=advanced">the kernel bug tracker</a>.</p> <p>Searching the Linux kernel mailing list as well as the subsystem-related mailing lists could also be helpful but is probably more difficult.</p> <p>2. The main kern...
12,188,381
Render partial :collection => @array specify variable name
<p>I am rendering a partial like this:</p> <pre><code>$("#box_container").html("&lt;%= escape_javascript( render :partial =&gt; 'contacts/contact_tile', :collection =&gt; @contacts) %&gt;") </code></pre> <p>Problem is that my partial is expecting the variable 'contact'.</p> <pre><code>ActionView::Template::Error (un...
12,755,382
4
0
null
2012-08-30 00:34:56.63 UTC
10
2021-05-18 13:05:31.33 UTC
2012-08-30 00:41:13.14 UTC
null
211,563
null
683,216
null
1
60
ruby-on-rails
44,144
<p>Found this is also helpful from the docs. You aren't limited to having the variable named after the partial:</p> <p><a href="http://guides.rubyonrails.org/layouts_and_rendering.html" rel="noreferrer">http://guides.rubyonrails.org/layouts_and_rendering.html</a></p> <blockquote> <p>To use a custom local variable n...
19,143,857
Pandas: bar plot xtick frequency
<p>I want to create a simple bar chart for pandas DataFrame object. However, the xtick on the chart appears to be too granular, whereas if I change the plot to line chart, xtick is optimized for better viewing. I was wondering if I can bring the same line chart xtick frequency to bar chart? Thanks.</p> <pre><code>lock...
19,387,765
1
3
null
2013-10-02 18:14:04.237 UTC
14
2019-09-22 20:19:00.29 UTC
2014-07-10 01:04:50.313 UTC
null
283,296
null
2,058,335
null
1
20
python|matplotlib|plot|pandas
12,509
<p>You can reduce the number of thicks by setting one every <code>n</code> ticks, doing something like:</p> <pre><code>n = 10 ax = locks.plot(kind='bar', y='SUM') ticks = ax.xaxis.get_ticklocs() ticklabels = [l.get_text() for l in ax.xaxis.get_ticklabels()] ax.xaxis.set_ticks(ticks[::n]) ax.xaxis.set_ticklabels(tickl...
3,732,808
Find index of number from a string in C#
<p>Form the below string I would like to get the index of the starting number.Please let me know how this can be done in C#.net.</p> <p>For example</p> <pre><code>University of California, 1980-85. University of Colorado, 1999-02 </code></pre>
3,732,864
3
3
null
2010-09-17 05:17:15.14 UTC
10
2017-10-06 00:09:59.513 UTC
2017-10-06 00:09:59.513 UTC
null
46,914
null
401,768
null
1
48
c#
52,749
<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace IndexOfAny { class Program { static void Main(string[] args) { Console.WriteLine("University of California, 1980-85".IndexOfAny("0123456789".ToCharArray())); } } } ...
38,213,467
What does intrinsic lock actually mean for a Java class?
<p>In order to properly understand the issues and solutions for concurrency in Java, I was going through the official Java tutorial. In one of the pages they defined <strong>Intrinsic Locks and Synchronization</strong> <a href="https://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html" rel="noreferrer...
38,213,802
7
6
null
2016-07-05 21:57:25.693 UTC
10
2021-11-09 14:22:25.13 UTC
2016-07-06 06:45:35.343 UTC
null
2,606,411
null
2,606,411
null
1
14
java|multithreading|concurrency|synchronization
10,080
<p>So just to repeat my comment above as an answer. Intrinsic locking means that you don't have to create an object to synchronize your methods on. In comparison you can use an extrinsic lock by calling <code>synchronized(myLock) {...}</code>.</p> <p>This is an excerpt from the book <a href="https://www.goodreads.com/b...
8,542,661
General Polymorphism with PHP examples
<p>As only Dogs can play "fetch", is this example a good or a bad idea? I suspect it's a really bad idea due to the usage of instanceof, but I'm not entirely sure why.</p> <pre><code>class Animal { var $name; function __construct($name) { $this-&gt;name = $name; } } class Dog extends Animal { ...
8,542,880
3
10
null
2011-12-17 04:49:17.41 UTC
20
2018-11-13 15:30:08.097 UTC
2011-12-17 06:18:35.693 UTC
null
486,233
null
895,470
null
1
29
php|polymorphism
54,842
<p>In this context it's useful to talk about <em>interfaces</em>.</p> <pre><code>interface Talkative { public function speak(); } class Dog extends Animal implements Talkative { public function speak() { return "Woof, woof!"; } } </code></pre> <p>Any animal <em>or human</em> (or alien) that imple...
11,331,388
from array to datatable
<p>ok i now it supose to be simple y have a multidimensional array, I try to fill my data table using the following code:</p> <pre><code>System.Data.DataTable _myDataTable =new System.Data.DataTable(); for (int j=0; j &lt; ele; j++) { _myDataTable.Columns.Add(); for (int i = 0; i &lt; ca...
11,332,086
6
7
null
2012-07-04 14:51:25.817 UTC
4
2020-09-24 07:19:08.747 UTC
2012-07-04 15:40:49.99 UTC
null
76,337
null
953,227
null
1
13
c#|asp.net
103,472
<p>As pointed out by <strong>chiffre</strong> you actually have 3 problems: You will have to add all columns before you can start to add rows and you will have to create a <code>DataRow</code> before you can add it to your <code>DataTable</code>. Your third problem is your row-dimension counter <code>caract+1</code> wh...
10,938,483
Why can't I specify an environment variable and echo it in the same command line?
<p>Consider this snippet: </p> <pre><code>$ SOMEVAR=AAA $ echo zzz $SOMEVAR zzz zzz AAA zzz </code></pre> <p>Here I've set <code>$SOMEVAR</code> to <code>AAA</code> on the first line - and when I echo it on the second line, I get the <code>AAA</code> contents as expected. </p> <p>But then, if I try to specify the va...
10,938,530
9
0
null
2012-06-07 19:20:26.227 UTC
28
2021-01-26 16:19:28.113 UTC
2019-11-05 14:52:29.003 UTC
null
3,266,847
null
277,826
null
1
111
bash|environment-variables|echo
39,448
<p>What you see is the expected behaviour. The trouble is that the parent shell evaluates <code>$SOMEVAR</code> on the command line before it invokes the command with the modified environment. You need to get the evaluation of <code>$SOMEVAR</code> deferred until after the environment is set.</p> <p>Your immediate o...
11,328,988
Find all files with name containing string
<p>I have been searching for a command that will return files from the current directory which contain a string in the filename. I have seen <code>locate</code> and <code>find</code> commands that can find files beginning with something <code>first_word*</code> or ending with something <code>*.jpg</code>. </p> <p>How ...
11,329,078
8
1
null
2012-07-04 12:19:37.173 UTC
71
2019-04-10 17:31:13.7 UTC
2018-12-03 12:22:35.957 UTC
null
608,639
null
830,554
null
1
248
linux|unix|command-line|locate
394,274
<p>Use <code>find</code>:</p> <p><code>find . -maxdepth 1 -name "*string*" -print</code></p> <p>It will find all files in the current directory (delete <code>maxdepth 1</code> if you want it recursive) containing "string" and will print it on the screen.</p> <p>If you want to avoid file containing ':', you can type:...
16,709,404
how to automate the "commit-and-push" process? (git)
<p>I have a git repo. And after each major change, that I make in the codebase, what I do is that I go to the terminal and execute a set of commands. </p> <pre><code>git add . git commit -m 'some message' git push origin master </code></pre> <p>These are the same each day and the process is quite boring. Can anyone s...
16,709,405
7
7
null
2013-05-23 08:46:53.57 UTC
14
2022-04-08 13:30:42.917 UTC
2013-05-23 09:01:59.503 UTC
null
2,080,089
null
2,080,089
null
1
29
git
38,468
<p>You can very easily automate this using Bash scripting.</p> <pre><code>git add . echo 'Enter the commit message:' read commitMessage git commit -m "$commitMessage" echo 'Enter the name of the branch:' read branch git push origin $branch read </code></pre> <p>store the above code as a <code>.sh</code> file(say...
16,976,523
Why isn't my Stringer interface method getting invoked? When using fmt.Println
<p>Suppose I have the following code:</p> <pre><code>package main import "fmt" type Car struct{ year int make string } func (c *Car)String() string{ return fmt.Sprintf("{make:%s, year:%d}", c.make, c.year) } func main() { myCar := Car{year:1996, make:"Toyota"} fmt.Println(myCar) } </code></pre>...
16,978,611
6
0
null
2013-06-07 04:59:17.49 UTC
21
2019-11-19 15:12:46.07 UTC
2019-06-10 11:35:00.987 UTC
null
13,860
null
71,079
null
1
58
go
15,040
<p>When calling <code>fmt.Println</code>, <code>myCar</code> is implicitly converted to a value of type <code>interface{}</code> as you can see from the function signature. The code from the <code>fmt</code> package then does a <a href="http://golang.org/ref/spec#Switch_statements">type switch</a> to figure out how to ...
17,095,443
How to use Simple Ajax Beginform in Asp.net MVC 4?
<p>I am new in Asp.net MVC and i researched about <code>Ajax.BeginForm</code> but when i apply codes it did not work. Can you share very simple example with <code>Ajax.Beginform</code> with View, Controller, Model? Thanks.</p>
17,096,835
3
2
null
2013-06-13 19:27:45.75 UTC
27
2016-12-06 23:17:10.72 UTC
2015-02-19 21:22:26.803 UTC
null
1,743,997
null
2,483,273
null
1
60
ajax|asp.net-mvc|form-helpers|ajax.beginform
175,459
<p>Simple example: Form with textbox and Search button. </p> <p>If you write "name" into the <code>textbox</code> and submit form, it will brings you patients with "name" in table.</p> <p><strong>View:</strong></p> <pre><code>@using (Ajax.BeginForm("GetPatients", "Patient", new AjaxOptions {//GetPatients is name of ...
16,739,771
How can I change a project's location pointer in Eclipse?
<p>A project has moved to a different location, so Eclipse won't open the project. You'll immediately think about simply changing the pointer to the location, but in Eclipse they try to make this impossible for some reason.</p> <p>You cannot change the project location in the <code>Project Explorer</code> properties.<...
16,740,557
11
1
null
2013-05-24 16:38:28.907 UTC
17
2020-09-16 23:59:38.923 UTC
2020-04-28 09:31:13.717 UTC
null
9,216,858
null
754,174
null
1
68
eclipse|directory|location|project|target
84,894
<p>Delete the project from eclipse. </p> <p><strong>ENSURE THAT THE CHECK BOX is UNSELECTED, during this delete</strong></p> <p>And then import the project by <code>File</code> -> <code>Import</code> -> <code>Import existing project</code> and choose it from the new location.</p> <p><strong>Don't</strong> try to mod...
16,908,476
Object property name as number
<p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals" rel="nofollow noreferrer">MDN JavaScript documentation</a> you can define object literal property names using integers:</p> <blockquote> <p>Additionally, you can use a numeric or string literal fo...
16,908,505
6
3
null
2013-06-04 01:34:58.577 UTC
21
2022-09-01 10:15:28.44 UTC
2022-09-01 10:15:28.44 UTC
null
-1
null
1,798,677
null
1
74
javascript|object
84,989
<p>You can reference the object's properties as you would an array and use either <code>me[123]</code> or <code>me["123"]</code></p>
4,777,070
Hamming distance on binary strings in SQL
<p>I have a table in my DB where I store SHA256 hashes in a BINARY(32) column. I'm looking for a way to compute the Hamming distance of the entries in the column to a supplied value, i.e. something like:</p> <pre><code>SELECT * FROM table ORDER BY HAMMINGDISTANCE(hash, UNHEX(&lt;insert supplied sha256 hash here&gt;...
4,783,415
2
9
null
2011-01-23 22:45:32.08 UTC
15
2021-07-26 05:32:27.377 UTC
2011-02-12 14:18:19.53 UTC
null
414,813
null
414,813
null
1
25
sql|mysql|hash|binary-data|hamming-distance
10,910
<p>It appears that storing the data in a <code>BINARY</code> column is an approach bound to perform poorly. The only fast way to get decent performance is to split the content of the <code>BINARY</code> column in multiple <code>BIGINT</code> columns, each containing an 8-byte substring of the original data.</p> <p>In ...
26,434,923
Parse command line arguments in a Ruby script
<p>I want to call a Ruby script from the command line, and pass in parameters that are key/value pairs.</p> <p>Command line call:</p> <pre><code>$ ruby my_script.rb --first_name=donald --last_name=knuth </code></pre> <p>my_script.rb:</p> <pre><code>puts args.first_name + args.last_name </code></pre> <p>What is the...
26,435,303
7
4
null
2014-10-17 23:48:30.88 UTC
21
2021-02-17 21:27:38.87 UTC
2014-10-18 20:36:14.423 UTC
null
128,421
null
1,001,938
null
1
62
ruby|command-line
44,873
<p>Based on the answer by @MartinCortez here's a short one-off that makes a hash of key/value pairs, where the values must be joined with an <code>=</code> sign. It also supports flag arguments without values:</p> <pre><code>args = Hash[ ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/) ] </code></pre> <p>…or alternativ...
9,930,562
is autoupdating possible in Android without using android market?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/3057771/is-there-a-way-to-automatically-update-application-on-android">Is there a way to automatically update application on Android?</a> </p> </blockquote> <p>As a property of an application(NOT USING GOOGLE P...
9,930,651
3
0
null
2012-03-29 17:41:35.197 UTC
9
2013-02-28 16:17:32.777 UTC
2017-05-23 10:32:41.96 UTC
null
-1
null
1,281,930
null
1
6
android|auto-update
10,930
<p>Check out the CWAC-Updater project: <a href="https://github.com/commonsguy/cwac-updater" rel="noreferrer">https://github.com/commonsguy/cwac-updater</a></p>
10,016,936
In jquery fullcalendar, can I add a new event without refreshing the whole month?
<p>I am using <a href="http://arshaw.com/fullcalendar/">jquery fullcalendar</a> and it works great. My events come in from an ajax call and get returned as json.</p> <p>I am trying to figure out if there is a way to add events from the client side without refreshing the whole server.</p> <p>I have the ability to add...
10,017,476
8
1
null
2012-04-04 18:13:14.813 UTC
6
2020-06-03 10:58:05.42 UTC
2012-04-09 12:26:55.297 UTC
null
4,653
null
4,653
null
1
15
jquery|fullcalendar
51,710
<p>to add events on the client side into the fullCalendar you can call:</p> <pre><code>var myCalendar = $('#my-calendar-id'); myCalendar.fullCalendar(); var myEvent = { title:"my new event", allDay: true, start: new Date(), end: new Date() }; myCalendar.fullCalendar( 'renderEvent', myEvent ); </code></pre> <...
9,809,357
Regex for validating multiple E-Mail-Addresses
<p>I got a Regex that validates my mail-addresses like this:</p> <p><code>([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)</code></p> <p>This works perfectly fine, but only allows one e-mail to be entered. Now I wanted to extend that and allow multipl...
9,809,636
11
4
null
2012-03-21 17:02:10.237 UTC
20
2022-04-05 14:42:49.38 UTC
2012-03-21 17:19:05.643 UTC
null
917,465
null
917,465
null
1
36
c#|regex|validation|email|rfc
58,121
<p>This is your original expression, changed so that it allows several emails separated by semicolon and (optionally) spaces besides the semicolon. It also allows a single email address that doesn't end in semicolon.</p> <p>This allows blank entries (no email addresses). You can replace the final * by + to require at ...
10,087,467
Passing annotation properties to meta-annotations
<p>Say I have an annotation with a property:</p> <pre><code>@Named(name = "Steve") private Person person </code></pre> <p>and I want to create a compound annotation with several meta-annotations, including the one that takes a property</p> <pre><code>@Named @AnotherAnnotation @YetAnotherAnnotation public @interface ...
10,088,998
2
4
null
2012-04-10 11:02:00.18 UTC
9
2022-01-25 00:31:24.803 UTC
2012-04-10 13:18:53.26 UTC
null
996,309
null
996,309
null
1
47
java|annotations
10,034
<blockquote> <p>Is there a way that I can pass properties to the compound annotation to one of the meta annotations?</p> </blockquote> <p>I think the simple answer is "no". There is no way to ask <code>Person</code> what annotations it has on it and get <code>@Named</code> for example.</p> <p>The more complex ans...
28,199,212
Why does libc++'s implementation of shared_ptr use full memory barriers instead of relaxed?
<p>In boost's implementation of <code>shared_ptr</code>, it uses <a href="https://github.com/boostorg/smart_ptr/blob/master/include/boost/smart_ptr/detail/sp_counted_base_clang.hpp#L29" rel="noreferrer">relaxed memory ordering to increment its reference count</a>. This appears safe as decrements use acquire/release to ...
28,204,322
1
5
null
2015-01-28 18:01:35.813 UTC
8
2015-01-28 23:21:47.577 UTC
2015-01-28 20:15:04.707 UTC
null
148,766
null
148,766
null
1
29
c++|boost|thread-safety|shared-ptr|libc++
1,939
<p>Because when I wrote that code, the compiler (clang) had not yet implemented C++11 atomics. And I never got back to it to clean it up. </p> <p>Nothing subtle here. :-)</p>
9,737,616
UITableView: hide header from empty section
<p>i have a UITableView, that displays expenses from a current month (see screenshot):</p> <p>My problem is with the header for empty sections. is there any way to hide them? The data is loaded from coredata.</p> <p>this is the code that generates the header title:</p> <p>TitleForHeader</p> <pre><code>-(NSString *)...
9,737,690
8
0
null
2012-03-16 12:53:13.057 UTC
19
2019-04-16 00:11:53.59 UTC
2012-03-16 16:10:41.63 UTC
null
1,146,393
null
1,146,393
null
1
80
objective-c|ios|uitableview|tableview
68,498
<p>What if in – <code>tableView:viewForHeaderInSection:</code> you <code>return nil</code> if the section count is 0.</p> <p><strong>EDIT</strong> : You can use <code>numberOfRowsInSection</code> for obtaining the number of elements in the section.</p> <p><strong>EDIT</strong>: Probably you should return nil also in...
7,818,277
Is there a standard option workflow in F#?
<p>Is there an option (maybe) wokflow (monad) in the standrd F# library?</p> <p>I've found a dozen of hand-made implementations (<a href="http://stevehorsfield.wordpress.com/2009/09/06/f-delayed-compositional-maybe-monad-workflow-full-source/" rel="noreferrer">1</a>, <a href="https://stackoverflow.com/questions/315715...
7,818,354
3
0
null
2011-10-19 08:06:05.617 UTC
1
2022-08-31 16:44:25.493 UTC
2022-08-31 16:44:25.493 UTC
null
3,744,182
null
599,628
null
1
29
f#|workflow|option-type|monads
4,901
<p>There's no Maybe monad in the standard F# library. You may want to look at <a href="http://bugsquash.blogspot.com/2011/10/introducing-fsharpx.html">FSharpx</a>, a F# extension written by highly-qualified members of F# community, which has quite a number of useful monads. </p>
11,779,082
listener for pressing and releasing a button
<p>How can I listen for when a <code>Button</code> is pressed and released?</p>
11,779,177
3
0
null
2012-08-02 14:02:13.833 UTC
11
2018-01-24 15:10:23.203 UTC
2014-06-18 16:12:29.947 UTC
null
569,558
null
1,160,337
null
1
44
android|view
38,332
<p>You can use a <code>onTouchListener</code>:</p> <pre><code>view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: // PRESSED retur...
11,544,460
How to get a backtrace from a SystemStackError: stack level too deep?
<p>Often I get hard to debug infinite recursions when coding ruby. Is there a way to get a backtrace out of a <code>SystemStackError</code> to find out, where exactly the infinite loop occurs?</p> <h2>Example</h2> <p>Given some methods <code>foo</code>, <code>bar</code> and <code>baz</code> which call each other in a...
31,835,021
8
0
null
2012-07-18 15:05:13.617 UTC
21
2015-08-05 14:13:15.007 UTC
2012-07-18 15:54:39.58 UTC
null
773,690
null
773,690
null
1
50
ruby
15,551
<p>Apparently this was tracked as <a href="https://bugs.ruby-lang.org/issues/6216" rel="nofollow">feature 6216</a> and fixed in Ruby 2.2.</p> <pre class="lang-none prettyprint-override"><code>$ ruby system-stack-error.rb system-stack-error.rb:6:in `bar': stack level too deep (SystemStackError) from system-stac...
3,738,836
How do I check if a Perl scalar variable has been initialized?
<p>Is the following the best way to check if a scalar variable is initialized in Perl, using <code>defined</code>?</p> <pre><code>my $var; if (cond) { $var = "string1"; } # Is this the correct way? if (defined $var) { ... } </code></pre>
3,738,936
5
0
null
2010-09-17 20:35:00.897 UTC
10
2016-09-08 11:54:39.703 UTC
2016-09-08 11:52:39.17 UTC
null
63,550
null
43,756
null
1
36
perl
56,832
<p>Perl doesn't offer a way to check whether or not a variable has been initialized.</p> <p>However, scalar variables that haven't been explicitly initialized with some value happen to have the value of <code>undef</code> by default. You are right about <code>defined</code> being the right way to check whether or not ...
4,008,546
How to pad with n characters in Python
<p>I should define a function <code>pad_with_n_chars(s, n, c)</code> that takes a string 's', an integer 'n', and a character 'c' and returns a string consisting of 's' padded with 'c' to create a string with a centered 's' of length 'n'. For example, <code>pad_with_n_chars(”dog”, 5, ”x”)</code> should return the string...
4,008,562
6
1
null
2010-10-24 14:01:30.537 UTC
8
2022-05-06 06:14:09.213 UTC
2010-10-24 14:58:30.033 UTC
null
19,750
null
485,611
null
1
42
python|string
48,359
<p>With Python2.6 or better, there's no need to define your own function; the string <a href="http://docs.python.org/library/string.html#format-string-syntax" rel="nofollow noreferrer">format</a> method can do all this for you:</p> <pre><code>In [18]: '{s:{c}^{n}}'.format(s='dog',n=5,c='x') Out[18]: 'xdogx' </code></pr...
3,352,020
How to declare a global variable in JavaScript
<p>How can I declare a global variable in JavaScript?</p>
3,352,033
6
0
null
2010-07-28 10:38:08.927 UTC
32
2020-10-16 20:22:14.117 UTC
2020-10-15 18:51:59.927 UTC
null
63,550
null
385,563
null
1
144
javascript|global-variables
322,997
<p>If you have to generate global variables in production code (which should be avoided) <strong>always</strong> declare them <strong>explicitly</strong>:</p> <pre><code>window.globalVar = "This is global!"; </code></pre> <p>While it is possible to define a global variable by just omitting <code>var</code> (assuming ...
4,013,591
attr_reader with question mark in a name
<p>Sorry for this, probably, really newbie question:</p> <p>I want to define a getter that returns bool value. f.i.:</p> <pre><code> attr_reader :server_error? </code></pre> <p>But then, how do I update it, as Ruby (1.9) throws syntax error if there is a question mark at the end:</p> <pre><code>#unexpected '=' @se...
4,013,983
7
0
null
2010-10-25 10:14:23.487 UTC
4
2022-07-13 07:53:42.687 UTC
2010-10-25 12:09:44.653 UTC
null
437,301
null
409,475
null
1
30
ruby
9,118
<p>I suggest defining your own method rather than using <code>:attr_reader</code></p> <pre><code>def server_error? !!@server_error # Or any other idiom that you generally use for checking boolean end </code></pre> <p>for brevity's sake, you could do it in one line:</p> <pre><code>def server_error?; !!@server_error...
3,463,796
How to only show certain parts with CSS for Print?
<p>I have a page with lots of data, tables and content. I want to make a print version that will only display very few selected things.</p> <p>Instead of writing another page just for printing, I was reading about CSS's feature for "@media print".</p> <p>First, what browsers support it? Since this is an internal feat...
3,463,801
7
2
null
2010-08-12 00:04:52.863 UTC
6
2022-01-17 19:55:48.767 UTC
2010-08-12 00:54:15.11 UTC
null
25,645
null
25,645
null
1
41
css|printing|css-selectors
73,946
<p>Start <a href="http://www.alistapart.com/articles/goingtoprint/" rel="noreferrer">here</a>. But basically what you are thinking is the correct approach.</p> <blockquote> <p>Thanks, Now my question is actually becoming: How do I apply CSS to a class AND ALL OF ITS DESCENDANT ELEMENTS? So that I can apply "...
3,580,013
Should I use past or present tense in git commit messages?
<p>I <a href="https://web.archive.org/web/20100827225248/http://progit.org/book/ch5-2.html" rel="noreferrer">read once</a> that git commit messages should be in the imperative present tense, e.g. &quot;Add tests for x&quot;. I always find myself using the past tense, e.g. &quot;Added tests for x&quot; though, which fee...
3,580,764
7
13
null
2010-08-26 22:21:20.07 UTC
198
2022-05-17 17:13:16.23 UTC
2021-12-16 06:32:56.443 UTC
null
947,271
null
49,376
null
1
644
git|git-commit|conventions|commit-message
133,589
<p>The preference for present-tense, imperative-style commit messages comes from Git itself. From <a href="https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/SubmittingPatches?h=v2.36.1#n181" rel="noreferrer">Documentation/SubmittingPatches</a> in the Git repo:</p> <blockquote> <p>Describe your changes in im...
3,700,637
How do I correctly set an association between two objects in the Entity Framework 4 Entitydesigner?
<p>For a new project I'm trying to create my business classes first and create the real database tables later. Therefore I'm using the Entity Framework 4 Designer. A created a new "ADO.Net Entity Data model" file, with the extension .edmx.</p> <p>I created two Entities:<br> <img src="https://i.stack.imgur.com/w65e1.pn...
3,703,465
8
1
null
2010-09-13 13:04:54.107 UTC
7
2017-01-25 22:25:59.29 UTC
null
null
null
null
225,808
null
1
54
c#|asp.net|entity-framework-4
59,179
<p>I just ran into this myself &amp; when I Googled it (I hit your question).</p> <p>I was able to double click on the line (association line) in the designer. Fill in the properties there and I got it working.</p> <p>I also had to close VS and re-open it to get some of the errors reported to go away...</p> <p>Can't...
8,322,550
How to activate the mysql database in xampp on windows platform?
<p>I've installed XAMPP on my Windows XP. I started the XAMPP control panel and it shows apache and mysql are running.</p> <p>When I check the status by going to <code>localhost/xampp</code> it shows:</p> <pre><code>mysql : deactivated </code></pre> <p>When I run php files that access the mysql database, it shows t...
8,322,709
5
2
null
2011-11-30 07:35:43.053 UTC
null
2015-10-01 20:56:23.69 UTC
2013-08-12 01:18:50.32 UTC
null
445,131
null
1,029,133
null
1
1
php|xampp
41,190
<p>You should view in the xampp installation the file "\xampp\mysql\data\mysql_error.log".</p> <p>This file contais the error log of MySQL and in it you can detect any problem like por in use.</p> <p>For example, this lines of log show that the port 3306 (the mysql default) is used by another application and can't be...
4,473,216
Diagnose ObjectDisposedException "Safe handle has been closed"
<p>I have a C# application which is hitting an ObjectDisposedException with the message </p> <blockquote> <p>Safe handle has been closed</p> </blockquote> <p>This happens as soon as I launch the application.</p> <p>Sadly the stack trace is really unhelpful (see below). Is there any way for me to determine what cal...
4,592,214
3
0
null
2010-12-17 17:35:06.373 UTC
2
2018-05-16 17:42:08.433 UTC
2015-10-01 14:57:23.067 UTC
null
2,686,013
null
325,129
null
1
18
c#|debugging
41,115
<p>The problem was caused by my use of a using(){} block.</p> <pre><code> using (WaitHandle handle = asyncResponse.AsyncWaitHandle) { asyncResponse.AsyncWaitHandle.WaitOne(); string response = asyncRequest.EndInvoke(asyncResponse); asyncResponse.AsyncWaitHandle.Close(); return response; ...
4,166,445
Anonymous functions syntax in CoffeeScript
<p>I've been looking at <a href="http://jashkenas.github.com/coffee-script/">CoffeeScript</a> and I'm not understanding how you would write code like this. How does it handle nested anonymous functions in its syntax?</p> <pre><code>;(function($) { var app = $.sammy(function() { this.get('#/', fu...
4,166,527
3
1
null
2010-11-12 15:56:44.523 UTC
9
2013-02-06 11:21:01.737 UTC
2010-11-12 16:03:26.817 UTC
null
149,391
null
411,929
null
1
31
javascript|coffeescript
33,701
<p>didn't actually compile it, but this should work</p> <pre><code>(($) -&gt; app = $.sammy -&gt; this.get '#/', -&gt; $('#main').text '' this.get '#/test', -&gt; $('#main').text 'Hello World' $(-&gt; app.run() ) )(jQuery); </code></pre>
4,813,307
The model item is of type CookMeIndexViewModel, but requires a model item of type IEnumerable<CookMeIndexViewModel>
<p>I am following along with the music store example to try learn ASP.NET MVC. I'm creating a cookbook application. </p> <p>I have created my viewmodel that looks like this:</p> <pre><code>namespace CookMe_MVC.ViewModels { public class CookMeIndexViewModel { public int NumberOfReceipes { get; set; } ...
4,813,376
3
0
null
2011-01-27 06:16:26.283 UTC
10
2016-01-05 14:39:05.447 UTC
2016-01-05 14:39:05.447 UTC
null
4,551,041
null
293,545
null
1
32
asp.net|asp.net-mvc-3|asp.net-mvc-viewmodel
90,924
<p>In your view you are using <code>@model IEnumerable&lt;CookMe_MVC.ViewModels.CookMeIndexViewModel&gt;</code> which indicates that the model expected by the View is of type IEnumerable of CookMeIndexViewModel.</p> <p>However in the controller you are passing an object of type CookMeIndexViewModel as a model <code>re...
4,503,606
annotation equivalent of <aop:scoped-proxy>
<p>I am moving from an xml config to annoations. i want to convert a session scoped bean that is </p> <pre><code>&lt;aop:scoped-proxy&gt; </code></pre> <p>can this be done with annotations, and if not, what can i do to still keep that declaration working?</p> <p><strong>edit:</strong> I am interested in doing this i...
5,725,517
3
0
null
2010-12-21 20:29:25.91 UTC
13
2019-02-11 18:19:23.01 UTC
2010-12-21 23:41:11.56 UTC
null
26,188
null
26,188
null
1
45
spring|spring-aop
31,151
<p>in the spring context xml, do something like:</p> <pre><code>&lt;context:component-scan base-package="com.startup.failure" scoped-proxy="interfaces" /&gt; </code></pre> <p>Note that you would need to write interfaces for all classes in that package, though.</p>
4,629,571
ASP.NET, VB: checking which items of a CheckBoxList are selected
<p>I know this is an extremely basic question, but I couldn't find how to do this in VB... I have a CheckBoxList where one of the options includes a textbox to fill in your own value. So I need to have that textbox become enabled when its checkbox (a ListItem in the CheckBoxList) is checked. This is the code behind, ...
4,629,766
4
1
null
2011-01-07 19:44:02.173 UTC
null
2018-05-06 07:55:03.557 UTC
2012-04-03 21:09:34.133 UTC
null
3,043
null
543,843
null
1
3
asp.net|vb.net|selecteditem|checkboxlist|listitem
48,924
<p>You can loop through the checkboxes in a CheckBoxList, checking each to see if it is checked. Try something like this:</p> <pre><code>For Each li As ListItem In CheckBoxList1.Items If li.Value = "ValueOfInterest" Then 'Ok, this is the CheckBox we care about to determine if the TextBox should be enabled....
4,716,485
How do I add a label, or other element dynamically to a windows form panel?
<p>So this is probably a pretty basic question, but I am working with dragging and dropping ListBox Items onto a panel which will create components depending on the value. </p> <p>As an easy example, I need it to be able to create a new Label on the panel when an item from the ListBox is dropped onto the panel.</p> <...
4,716,710
4
0
null
2011-01-17 18:27:01.523 UTC
1
2011-02-06 06:54:13.093 UTC
null
null
null
null
180,253
null
1
8
c#|.net|windows|winforms
68,083
<pre><code> //Do I need to call either of the following code to make it do this? newLabel.Visible = true; newLabel.Show(); </code></pre> <p>is unnecessary.</p> <hr> <pre><code>newLabel.AutoSize = true; </code></pre> <p>is, most probably, necessary to give it a size.</p> <hr> <pre><code> panel1.Conta...
4,111,398
Notify activity from service
<p>I'm trying to start a <code>Service</code> from my <code>Activity</code> to look out for changes on a web page, it's a private app so I don't bother the battery life...</p> <p>But I'd like to pass data from my <code>Service</code> to my <code>Activity</code>... I can't seem to find a way to call the <code>Activity<...
4,112,657
4
0
null
2010-11-06 01:22:02.827 UTC
22
2015-02-12 17:01:53.39 UTC
2015-02-12 17:01:53.39 UTC
null
1,469,208
null
219,554
null
1
43
android|service|android-activity
32,514
<p>As Alex indicated, you can bind to the service and pass some sort of listener or callback to the service to use on events.</p> <p>Or, you can use a broadcast <code>Intent</code>, perhaps using methods like <code>setPackage()</code> on the <code>Intent</code> to limit the scope of the broadcast.</p> <p>Or, you can ...
4,130,364
Does Ruby have a string.startswith("abc") built in method?
<p>Does Ruby have a <code>some_string.starts_with("abc")</code> method that's built in?</p>
4,130,600
4
2
null
2010-11-09 03:51:35.483 UTC
15
2022-04-20 22:41:43.223 UTC
2015-10-17 22:16:11.587 UTC
null
4,948,732
null
39,677
null
1
219
ruby
142,301
<p>It's called <a href="http://RubyDoc.Info/docs/ruby-core/1.9.2/String#start_with%3F-instance_method" rel="noreferrer"><code>String#start_with?</code></a>, not <code>String#startswith</code>: In Ruby, the names of boolean-ish methods end with <code>?</code> and the words in method names are separated with an <code>_</...