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
5,205,373
Understanding basic Java-specific interverview questions
<p>Last day I faced an interview and they asked me java questions among which for some questions I didn't know the answer. I am curious to know the answer for that question. Interviewer did not tell me the answer. I am asking that questions here:</p> <ul> <li>Does Java provide any construct to find out the size of an ...
5,205,525
8
2
null
2011-03-05 17:13:51.76 UTC
11
2011-03-05 17:54:58.51 UTC
2011-03-05 17:25:03.573 UTC
user166390
null
null
559,070
null
1
7
java
1,549
<p>I think that all of these can be answered by searching for existing Stack Overflow questions. The reason I think it's worth answering this question with links to previous answers is that you've asked about a lot of different issues, each one of which is interesting in its own right. It's not so likely you'll get a...
5,200,269
List of running JVMs on the localhost
<p>How to get in Java 6+ the list of running JVMs on the localhost and their specs (i.e. Java version, running threads, etc.)?</p> <p>Does the Java API provide such features? Is there a Java library that can do this?</p>
5,200,305
8
1
null
2011-03-04 23:07:52.52 UTC
10
2017-10-19 01:24:04.173 UTC
null
null
null
null
645,535
null
1
14
java
32,754
<p>You can use <a href="http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html" rel="noreferrer"><code>jps</code></a>, a command-line tool distributed with the jvm. I'm not aware of any normal Java API for it, though. However, JConsole can do what you ask, so I had a look at its source. It was quite sc...
4,939,382
Logging POST data from $request_body
<p>I have my config setup to handle a bunch of GET requests which render pixels that work fine to handle analytics and parse query strings for logging. With an additional third party data stream, I need to handle a POST request to a given url that has JSON in an expected loggable format inside of it's request body. I d...
7,473,603
8
2
null
2011-02-08 22:44:24.063 UTC
37
2022-03-15 09:03:47.803 UTC
2016-08-24 18:28:14.97 UTC
null
334,831
null
519,311
null
1
89
logging|nginx|http-post
228,565
<p>This solution works like a charm:</p> <pre><code>http { log_format postdata $request_body; server { location = /post.php { access_log /var/log/nginx/postdata.log postdata; fastcgi_pass php_cgi; } } } </code></pre> <p>I think the trick is making nginx believe that you w...
5,596,521
What is the correct way to start a mongod service on linux / OS X?
<p>I've installed mongodb and have been able to run it, work with it, do simple DB read / write type stuff. Now I'm trying to set up my Mac to run mongod as a service.</p> <p>I get "Command not found" in response to: </p> <pre><code> init mongod start </code></pre> <p>In response to: </p> <pre><code>~: service mon...
5,601,077
11
2
null
2011-04-08 14:24:02.917 UTC
66
2020-06-07 19:19:22.4 UTC
null
null
null
null
398,055
null
1
141
linux|mongodb|service|initialization
142,301
<p>With recent builds of mongodb community edition, this is straightforward.</p> <p>When you install via brew, it tells you what exactly to do. There is no need to create a new launch control file.</p> <pre><code>$ brew install mongodb ==&gt; Downloading https://homebrew.bintray.com/bottles/mongodb-3.0.6.yosemite.bot...
16,965,011
Append text to each row of the sql select query
<p>I have a query like this</p> <pre><code>SELECT COUNT(ID) 'Records Affected', TYPE FROM MASTER GROUP BY TYPE </code></pre> <p>The output for this is</p> <pre><code>Records Affected TYPE ---------------- ---- 4 F1 3 F2 5 ...
16,965,134
5
3
null
2013-06-06 14:38:56.21 UTC
3
2016-12-23 05:22:31.02 UTC
2013-06-06 14:53:58.25 UTC
null
1,572,750
null
1,407,900
null
1
8
sql-server-2008
79,720
<p>You can easily concatenate the string using the following. You will use the <code>+</code> to concatenate the string to the <code>type</code> column and the <code>count</code>. Note, the <code>count</code> needs to be converted to a <code>varchar</code> for this to work:</p> <pre><code>SELECT 'The number of rec...
66,429,202
What are production use cases for the useRef, useMemo, useCallback hooks?
<p>Outside of the <strong>counter</strong> example seen in many YouTube tutorial videos, what are <strong>practical/real-world</strong> use cases for <code>useMemo</code> and <code>useCallback</code>?</p> <p>Also, I've only seen an <strong>input focus</strong> example for the <code>useRef</code> hook.</p> <p>Please sha...
66,626,493
3
9
null
2021-03-01 20:29:32.55 UTC
15
2022-01-22 13:26:17 UTC
2021-03-14 16:05:51.563 UTC
null
2,873,538
null
6,388,443
null
1
10
reactjs|react-hooks|use-ref|usecallback|react-usememo
14,406
<h2><code>useRef</code>:</h2> <p><strong>Syntax:</strong> <code>const refObject = useRef(initialValue);</code></p> <p>It simply returns a plain JavaScript <strong>object</strong>. Its value can be accessed and modified (<strong>mutability</strong>) as many times as you need without worrying about &quot;rerender&quot;.<...
41,240,414
Equivalent of Scala's foldLeft in Java 8
<p>What is the equivalent of of Scala's great <code>foldLeft</code> in Java 8?</p> <p>I was tempted to think it was <code>reduce</code>, but reduce has to return something of identical type to what it reduces on. </p> <p>Example:</p> <pre><code>import java.util.List; public class Foo { // this method works pre...
41,240,645
5
4
null
2016-12-20 10:43:09.973 UTC
6
2021-05-14 10:02:43.493 UTC
2017-10-17 09:48:00.517 UTC
null
3,975,247
null
3,975,247
null
1
33
java|java-8|reduce|foldleft
29,711
<p><strong>Update:</strong> </p> <p>Here is initial attempt to get your code fixed:</p> <pre><code>public static String concatenate(List&lt;Character&gt; chars) { return chars .stream() .reduce(new StringBuilder(), StringBuilder::append, ...
12,274,628
Compile a referenced LESS file into CSS with PHP automatically
<p>I want the following things to occur:</p> <ol> <li><p>Have the process automated server side.</p></li> <li><p>Simply be able to reference the LESS file as I would a CSS file in my code.</p></li> <li><p>The user is returned minified CSS instead of the LESS file - cached so the compiler doesn't need to run unless the...
12,274,629
1
0
null
2012-09-05 04:47:47.82 UTC
12
2013-09-03 13:06:11.127 UTC
2013-09-03 13:06:11.127 UTC
null
1,455,709
null
1,455,709
null
1
11
php|css|caching|compiler-construction|less
7,485
<p><strong>THIS ASSUMES LESSPHP v0.3.8+</strong> Unsure about earlier versions, but you'll get the gist of how it works if it doesn't straight out of the box.</p> <p><code>&lt;link rel="stylesheet" type="text/css" href="styles/main.less" /&gt;</code></p> <p>If you were using less.js to compile client side, make sure ...
12,136,841
AVMutableVideoComposition rotated video captured in portrait mode
<p>I have used below code to add image overlay over video and then export the new generated video to document directory. But strangely,video gets rotated by 90 degrees. </p> <pre><code>- (void)buildTransitionComposition:(AVMutableComposition *)composition andVideoComposition:(AVMutableVideoComposition *)videoCompositi...
12,136,925
6
0
null
2012-08-27 05:56:24.617 UTC
11
2020-10-21 13:00:00.82 UTC
null
null
null
null
1,400,442
null
1
18
iphone|ios|avmutablecomposition
19,672
<p>By default, when you export video using <strong>AVAssetExportSession</strong> then video will be rotated from its original orientation. You have to apply its transform to set it exact orientation.You please try below code to do the same.</p> <pre><code>- (AVMutableVideoCompositionLayerInstruction *)layerInstruction...
12,406,032
get fraction part of a decimal number
<p>I am trying to get a fraction part of a decimal number in rails. For example I have a number, that "1.23" and I want to get "23" It is may be too easy but, does anyone have any idea about how can I do?</p>
12,406,132
9
0
null
2012-09-13 12:16:05.27 UTC
2
2020-04-26 06:28:24.637 UTC
2016-08-18 02:06:35.193 UTC
null
2,387,599
null
883,906
null
1
33
ruby-on-rails|ruby|ruby-on-rails-3
22,197
<p>I am not sure if it is the easiest way to do it - but you can simply split the number using "." character - like this:</p> <pre><code>number = 1.23 parts = number.to_s.split(".") result = parts.count &gt; 1 ? parts[1].to_s : 0 </code></pre>
3,387,191
Python csv without header
<p>With header information in csv file, city can be grabbed as:</p> <pre><code>city = row['city'] </code></pre> <p>Now how to assume that csv file does not have headers, there is only 1 column, and column is city.</p>
3,387,212
3
1
null
2010-08-02 11:16:50.277 UTC
4
2018-06-26 14:11:14.44 UTC
null
null
null
null
347,039
null
1
27
python|csv
81,145
<p>You can still use your line, if you declare the headers yourself, since you know it:</p> <pre><code>with open('data.csv') as f: cf = csv.DictReader(f, fieldnames=['city']) for row in cf: print row['city'] </code></pre> <p>For more information check <a href="http://docs.python.org/library/csv#csv.Di...
22,597,781
An Android Virtual Device that failed to load
<p>Note: this question is very similar to another question posed much earlier by another person, but does not solve my problem. (<em>not</em> the same question <a href="https://stackoverflow.com/questions/15749711/an-android-virtual-device-that-failed-to-load-click-details-to-see-the-error">here</a>)</p> <p>Situation:...
25,505,963
2
10
null
2014-03-23 22:07:45.063 UTC
5
2016-01-04 10:24:38.583 UTC
2017-05-23 12:25:43.357 UTC
null
-1
user3453166
null
null
1
12
android|eclipse|avd
69,716
<p>Forgot to re-post this answer that I put in the comments section of my original post chain.</p> <p><strong>solution:</strong> was HAX allocation. Solution can be found in the following <a href="http://youtube.com/watch?v=tXnm8Lsl-dg" rel="nofollow">video</a>.</p>
18,840,422
Do negative numbers return false in C/C++?
<p>When evaluating integers as booleans in C/C++, are negative numbers true or false? Are they always true/false regardless of compilers?</p>
18,840,449
5
9
null
2013-09-17 02:36:54.167 UTC
21
2019-07-27 20:04:31.64 UTC
null
null
null
null
2,453,816
null
1
62
c++|c|boolean
73,548
<p>All non-zero values will be converted to <code>true</code>, and zero values to <code>false</code>. With negative numbers being non-zero, they are converted to <code>true</code>.</p> <p>Quoting from the C++11 standard (emphasis mine):</p> <blockquote> <p>4.12 Boolean conversions [conv.bool]</p> <p>1 A prvalu...
20,731,402
Animated (Smooth) scrolling on ScrollViewer
<p>I have a <code>ScrollViewer</code> in my WPF App, and I want it to have smooth/animated scrolling effect just like <em>Firefox</em> has (if you know what I am talking about).</p> <p>I tried to search over the internet, and the only thing I've found is this:<br/></p> <p><a href="http://matthiasshapiro.com/DisneySh...
20,846,310
4
3
null
2013-12-22 16:17:20.387 UTC
22
2022-01-11 21:39:40.99 UTC
2019-07-31 10:50:17.91 UTC
null
5,955,233
null
519,002
null
1
36
wpf|animation|scrollviewer
26,329
<p>In your example there are two controls inherited from <code>ScrollViewer</code> and <code>ListBox</code>, the animation is implemented by <code>SplineDoubleKeyFrame</code> <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.splinedoublekeyframe%28v=vs.110%29.aspx" rel="noreferrer">[MSDN]<...
22,138,475
How to implement the same interface multiple times, but with different generics?
<p>I have the following interface, which I want to implement multiple times in my classes:</p> <pre><code>public interface EventListener&lt;T extends Event&gt; { public void onEvent(T event); } </code></pre> <p>Now, I want to be able to implement this interface in the following way:</p> <pre><code>class Foo impl...
22,138,640
3
5
null
2014-03-03 04:04:35.497 UTC
8
2020-02-19 10:55:30.55 UTC
null
null
null
null
49,153
null
1
44
java|generics|interface
20,537
<p>You need to use inner or anonymous classes. For instance:</p> <pre><code>class Foo { public EventListener&lt;X&gt; asXListener() { return new EventListener&lt;X&gt;() { // code here can refer to Foo }; } public EventListener&lt;Y&gt; asYListener() { return new EventListener&lt...
11,134,857
Using sendmail for HTML body and binary attachment
<p>Objective: To send mail (using sendmail) with HTML body and binary attachment.</p> <p>Followed the guidelines specified in the following links</p> <p><a href="http://www.unix.com/shell-programming-scripting/159522-sendmail-html-body-attachment-2.html">http://www.unix.com/shell-programming-scripting/159522-sendmail...
11,725,308
2
3
null
2012-06-21 09:04:23.627 UTC
3
2021-01-15 09:23:02.97 UTC
null
null
null
null
1,471,464
null
1
10
shell|unix|sendmail|ksh|uuencode
40,910
<p>Changing the Content transfer encoding type within the email from base64 to uuencode resolved the issue. Thanks for the inputs so far.</p> <p>Given below is the revised script that works.</p> <pre><code>#!/usr/bin/ksh export MAILFROM="noreply@domain.com" export MAILTO="mail.to@gmail.com" export SUBJECT="Test PDF ...
11,220,776
deserialize list of objects using json.net
<p>i have this class</p> <pre><code>public class Image { public string url { get; set; } public string url_40px { get; set; } public string url_50px { get; set; } } public class Category { public List&lt;int&gt; ancestor_ids { get; set; } public int parent_id { get; set; } public List&lt;objec...
11,220,872
1
1
null
2012-06-27 06:47:05.437 UTC
1
2021-02-22 16:31:41.26 UTC
2012-11-13 21:39:58.7 UTC
null
11,829
null
362,461
null
1
11
.net|json|deserialization|json.net
39,056
<p>The type parameter for <code>DeserializeObject</code> has to be <code>List&lt;Category&gt;</code> instead of <code>Category</code>.</p> <p>In C# it would be <code>JsonConvert.DeserializeObject&lt;List&lt;Category&gt;&gt;(json)</code></p> <p>And In VB.Net it would be <code>JsonConvert.DeserializeObject(Of List(Of Cat...
11,386,033
GNU Octave, round a number to units precision
<p>In GNU Octave version 3.4.3 I want to round a matrix to 2 units precision on the contents of a matrix like this.</p> <pre><code>mymatrix=[1.1234567, 2.12345; 3.1234567891, 4.1234]; disp(mymatrix); </code></pre> <p>This prints:</p> <pre><code>1.1235 2.1235 3.1235 4.1234 </code></pre> <p>As you can see, the di...
11,386,211
3
0
null
2012-07-08 19:33:16.603 UTC
2
2021-01-04 20:33:41.307 UTC
null
null
null
null
445,131
null
1
17
linux|matrix|rounding|precision|octave
48,897
<h2>How to round off elements in a matrix in Octave:</h2> <p>There are many different ways to round a matrix and round a number in octave.</p> <h2>Option 1, use of sprintf format feature</h2> <pre><code>mymatrix=[100.1234567, 2.12345; 3.1234567891, 4.1234]; rows = rows(mymatrix); cols = columns(mymatrix); for i = 1:row...
11,190,405
How to schedule a task wether the user is logged on or not in PowerShell?
<p>I have a problem regarding how to make a scheduled task to run whether the user is logged on or not. It must be done in PowerShell. What I have done is:</p> <pre><code>$WINDIR/system32/schtasks.exe /create /tn TaskName /sc daily /st 15:05:00 /tr &quot;C:\cygwin\opt\IBM\tpchc\bin\tools\TheFileToRun.bat&quot; </code><...
11,196,228
3
1
null
2012-06-25 13:37:55.997 UTC
4
2022-08-03 15:49:19.917 UTC
2022-08-03 15:49:19.917 UTC
null
2,756,409
null
1,093,774
null
1
21
powershell|shell|cmd
41,694
<p>You'll need to specify a user (like <code>/RU system</code>), but it should be the default whether to run logged in or not. You can look at <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx" rel="noreferrer">this link</a> for a list of all <code>schtasks.exe</code> parameter...
10,968,522
Excluding fields in JAXB
<p>I have 2 classes:</p> <pre><code>@XmlRootElement public class A { private Long id; private B b; // setters and getters } </code></pre> <p>and</p> <pre><code>@XmlRootElement public class B { private Long id; private String field1; private String field2; // setters and getters } </co...
10,969,031
3
0
null
2012-06-10 12:05:09.167 UTC
7
2019-08-20 07:29:36.12 UTC
2015-08-28 12:40:01.18 UTC
null
1,743,880
null
920,607
null
1
47
java|xml|jaxb|java-ee-6
67,467
<p>You can use <a href="https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/XmlTransient.html" rel="noreferrer"><code>@XmlTransient</code></a> on the field. Also the default JAXB bindings can be overridden at a global scope or on a case-by-case basis as needed by using <a href="http://docs.oracle.com/cd...
11,079,605
adapter-Any real example of Adapter Pattern
<p>I want to demonstrate use of <a href="https://en.wikipedia.org/wiki/Adapter_pattern" rel="noreferrer">Adapter Pattern</a> to my team. I've read many books and articles online. Everyone is citing an example which are useful to understand the concept (Shape, Memory Card, Electronic Adapter etc.), but there is no real ...
13,323,703
15
8
null
2012-06-18 08:55:29.033 UTC
43
2021-02-09 18:34:43.473 UTC
2016-02-10 13:29:34.22 UTC
null
634,576
null
855,239
null
1
94
oop|design-patterns|adapter|software-design
66,636
<p>Many examples of Adapter are trivial or unrealistic (<a href="http://www.vincehuston.org/dp/adapter.html" rel="noreferrer">Rectangle vs. LegacyRectangle, Ratchet vs. Socket</a>, <a href="http://userpages.umbc.edu/~tarr/dp/lectures/Adapter-2pp.pdf" rel="noreferrer">SquarePeg vs RoundPeg</a>, <a href="http://my.safari...
12,719,241
Alternatives to CKEditor for WSYIWYG text area editor
<p>Me and my company are looking for an alternative to CKEditor to use in our CMS. Preferably we would like something a bit more up to date and significantly more lightweight.</p> <p>We're a rails 3.2 shop, so something that integrates easily with rails would be nice.</p> <p>Really we are just looking for the formatt...
12,719,274
4
4
null
2012-10-04 01:39:41.86 UTC
11
2014-12-09 18:55:20.993 UTC
null
null
null
null
117,554
null
1
32
javascript|jquery|ruby-on-rails|ruby-on-rails-3|wysiwyg
49,200
<p>I just found: </p> <p><a href="http://redactorjs.com/" rel="noreferrer">http://redactorjs.com/</a></p> <p><a href="http://aloha-editor.org/" rel="noreferrer">http://aloha-editor.org/</a></p> <p><a href="https://github.com/xing/wysihtml5" rel="noreferrer">https://github.com/xing/wysihtml5</a></p> <p><a href="http...
12,768,176
Unicode Characters in ggplot2 PDF Output
<p>How can I use Unicode characters for labels, titles and similar things in a PDF plot created with ggplot2?</p> <p>Consider the following example:</p> <pre><code>library(ggplot2) qplot(Sepal.Length, Petal.Length, data=iris, main="Aʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ") ggsave("t.pdf") </code></pre> <p>The title of the plot u...
12,775,087
3
1
null
2012-10-07 10:55:24.12 UTC
10
2020-10-21 23:15:43.55 UTC
2017-05-23 12:02:11.54 UTC
null
-1
null
1,685,720
null
1
34
r|unicode|utf-8|ggplot2
15,395
<p>As Ben suggested, <code>cairo_pdf()</code> is your friend. It also allows you to embed non-postscript fonts (i.e. TTF/OTF) in the PDF via the <code>family</code> argument (crucial if you don't happen to have any postscript fonts that contain the glyphs you want to use). For example:</p> <pre><code>library(ggplot2)...
16,878,279
overflow:hidden ignored with border-radius and CSS transforms (webkit only)
<p>I want to have a square image inside a circle.</p> <p>When the user hovers over the image, the image should scale (zoom in).</p> <p>The circle should remain the same size.</p> <p>Only during the CSS transition, the square image overlaps the circle (as if overflow:hidden weren't there at all).</p> <p>Here's a dem...
16,878,347
4
0
null
2013-06-01 23:28:06.783 UTC
12
2017-05-17 06:27:05.277 UTC
2013-06-01 23:55:04.143 UTC
null
850,825
null
850,825
null
1
21
css|css-transitions|css-transforms
15,542
<p>I removed some superfluous markup (the circle and square containers... only needs one) and styled the img itself:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#wrapper...
17,117,589
How can I skip tests in maven install goal, while running them in maven test goal?
<p>I have a multi-module maven project with both integration and unit tests in the same folder (src/test/java). Integration tests are marked with <code>@Category(IntegrationTest.class)</code>. I want to end up with the following setup:</p> <ol> <li>If I run <code>mvn install</code>, I want all tests to compile, but I ...
17,123,957
7
2
null
2013-06-14 21:31:29.2 UTC
43
2019-05-01 17:41:35.27 UTC
2013-06-15 07:51:11.453 UTC
null
1,204,246
null
1,204,246
null
1
69
maven|integration-testing|maven-surefire-plugin|maven-failsafe-plugin
92,512
<p>It sounds like you didn't understand the concept of the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html" rel="noreferrer">build life-cycle</a> in Maven. If you run <code>mvn install</code> all life-cycle phases (including the <code>install</code> phase itself) run before the i...
10,198,046
C++ Member Variables
<p>Consider the following class:</p> <pre><code>class A { A(); int number; void setNumber(int number); }; </code></pre> <p>You could implement 'setNumber' in 3 ways:</p> <p><strong>Method 1</strong>: Use the 'this' pointer.</p> <pre><code>void A::setNumber(int number) { this-&gt;number = number; } </code></...
10,198,598
6
4
null
2012-04-17 19:44:35.753 UTC
5
2018-01-31 05:35:00.677 UTC
2015-05-07 18:50:30.89 UTC
null
445,131
null
1,339,615
null
1
21
c++|class|variables|scope|member
51,179
<p>This is mostly a personal preference, but let me share my perspective on the issue from inside a company where many small games are being made simultaneously (and so there are many coding styles being used around me).</p> <p>This link has several good, related, answers: <a href="https://stackoverflow.com/questions/...
9,698,059
Disable single javascript file with addon or extension
<p>I am looking for a Firefox addon or Chrome extension that would allow me to disable particular javascript file from running. There are many of those for disabling particular CSS file, cannot seem to find one that does the same with JS files. Is there some limitations or I should have searched better before posting?<...
9,699,252
3
0
null
2012-03-14 08:14:47.69 UTC
12
2015-12-28 14:15:32.647 UTC
null
null
null
null
136,055
null
1
27
firefox|google-chrome|google-chrome-extension|firefox-addon
36,557
<p>AdBlock for Chrome can be used to block JS files.....<br> <a href="https://chrome.google.com/webstore/detail/gighmmpiobklfepjocnamgkkbiglidom" rel="noreferrer">https://chrome.google.com/webstore/detail/gighmmpiobklfepjocnamgkkbiglidom</a><br> ...Click on the AdBlock icon and select "Show the resource list" and look ...
9,760,662
Is there a constant which defines the max value of long or integer?
<p>In java, there is a constant for the max value of Long. Such as:</p> <pre><code>long minBillId = Long.MAX_VALUE </code></pre> <p>Is there a constant for the max value of long or int in Obj-C?</p>
9,760,691
3
0
null
2012-03-18 17:49:03.16 UTC
11
2012-12-24 13:21:37.503 UTC
2012-12-24 13:21:37.503 UTC
null
775,184
null
1,053,236
null
1
32
iphone|objective-c|ios|c|ipad
25,173
<p>If you import <code>limits.h</code> you can call <code>LONG_MAX</code></p> <p>For reference this <a href="http://reference.jumpingmonkey.org/programming_languages/objective-c/types.html" rel="noreferrer">site</a> shows how to get the max for all types as such:</p> <pre><code>#import &lt;limits.h&gt; // ... NSLog...
10,014,165
Sublime Text 2 Code Formatting
<p>First let me say I come from a Microsoft background and Visual Studio is my bread and butter. It has a command (keybind is arbitrary) that auto-formats <em>any</em> code syntax. The same command works in HTML, CSS, Javascript, C#, etc. </p> <p>I have tried plugins for ST2 and so far I've found most don't work on...
10,299,234
4
0
null
2012-04-04 15:20:49.963 UTC
25
2017-08-01 18:44:53.757 UTC
2013-10-30 23:08:23.3 UTC
null
803,739
null
803,739
null
1
54
sublimetext|prettify|sublimetext2
123,366
<p>I can't speak for the 2nd or 3rd, but if you install Node first, Sublime-HTMLPrettify works pretty well. You have to setup your own key shortcut once it is installed. One thing I noticed on Windows, you may need to edit your path for Node in the %PATH% variable if it is already long (I think the limit is 1024 for ...
10,236,953
The Pause monad
<p>Monads can do many amazing, crazy things. They can create variables which hold a superposition of values. They can allow you to access data from the future before you compute it. They can allow you to write destructive updates, but not really. And then the continuation monad allows you to <em>break people's minds!</...
10,237,311
6
6
null
2012-04-19 21:20:14.683 UTC
48
2015-03-05 09:40:51.653 UTC
2015-03-05 09:40:51.653 UTC
null
412,549
null
1,006,010
null
1
72
haskell|monads|coroutine|monad-transformers|free-monad
6,174
<p>Sure; you just let any computation either finish with a result, or suspend itself, giving an action to be used on resume, along with the state at the time:</p> <pre><code>data Pause s a = Pause { runPause :: s -&gt; (PauseResult s a, s) } data PauseResult s a = Done a | Suspend (Pause s a) instance Monad ...
7,983,076
Is it safe to use anchor to submit form?
<p>I've read somewhere, that using anchor tag to submit a form isn't very safe, so that's my question: Is it safe, to use anchor tag instead of <code>&lt;button&gt;</code> or <code>&lt;input type="submit" /&gt;</code> to submit a form? And if it isn't, <strong>why</strong>? The problem is, that I have a CSS class for a...
7,983,093
3
2
null
2011-11-02 15:37:28.027 UTC
10
2018-05-27 14:08:18.99 UTC
null
null
null
null
954,930
null
1
42
html|forms|button|anchor
81,783
<p>To use an anchor to submit a form would require the use of JavaScript to hook up the events. It's not safe in that if a user has JavaScript disabled, you won't be able to submit the form. For example:</p> <pre><code>&lt;form id="form1" action="" method="post"&gt; &lt;a href="#" onclick="document.getElementById(...
11,562,617
Installing Zend Framework 2 on XAMPP in Windows
<p>I know this question may have appeared few times here and in the internet. But still I feel it is not clear for somebody who wanted to enter into the world of frameworks. I have followed these links <a href="http://akrabat.com/zend-framework-2-tutorial/">Rob Allens Tutorial</a>, <a href="http://packages.zendframewor...
11,573,278
4
0
null
2012-07-19 14:05:42.643 UTC
13
2015-12-25 06:12:30.707 UTC
null
null
null
null
809,901
null
1
21
windows|xampp|zend-framework2
44,661
<p>For future references, i also made a big post on how to install ZF2 on a windows xampp environment right here <a href="http://samminds.com/2012/07/zend-framework-2-installation-on-xampp-for-windows/" rel="noreferrer" title="Install Zend Framework 2 on Windows Xampp">Install ZF2 on Windows Xampp</a></p> <p>OK, i hav...
11,801,200
What is mass-assignment in Rails 3
<p>I have heard couple of people complaining and posting questions about mass-assignment in Rails. I have got same error couple of times and all I did was <code>attr_accessible</code>. But what exactly is mass assignment? could somebody explain with example?</p>
11,801,261
1
2
null
2012-08-03 18:20:33.29 UTC
13
2012-08-03 18:38:09.63 UTC
null
null
null
null
1,033,503
null
1
23
ruby-on-rails-3|activerecord|mass-assignment
11,835
<p><a href="http://guides.rubyonrails.org/security.html#mass-assignment">Mass Assignment</a> is the name Rails gives to the act of constructing your object with a parameters hash. It is "mass assignment" in that you are assigning multiple values to attributes via a single assignment operator.</p> <p>The following snip...
11,769,555
Regular expression to match a backslash followed by a quote
<p>How to write a regular expression to match this <code>\&quot;</code> (a backslash then a quote)? Assume I have a string like this:</p> <pre><code>&lt;a href=\&quot;google.com\&quot;&gt; click to search &lt;/a&gt; </code></pre> <p>I need to replace all the <code>\&quot;</code> with a <code>&quot;</code>, so the resul...
11,769,570
3
3
null
2012-08-02 00:43:03.223 UTC
13
2022-01-17 15:56:49.673 UTC
2022-01-17 15:56:49.673 UTC
null
466,862
null
1,570,058
null
1
26
java|regex
62,084
<p>If you <em><strong>don't need any of regex mechanisms like predefined character classes \d, quantifiers etc.</strong></em> instead of <code>replaceAll</code> which expects regex use <code>replace</code> which expects literals</p> <pre><code>str = str.replace(&quot;\\\&quot;&quot;,&quot;\&quot;&quot;); </code></pre> ...
11,892,928
CoreData could not fulfill a fault for
<p>I have a really annoying problem, which I just can't seem to get fixed. </p> <p>I have a view when I send a message that gets saved to the Core Data, when thats done it asked the database for a random message (sentence) and saved that as well to an other row in the database.</p> <p>If I do the last part hardcoded,...
11,934,958
5
14
null
2012-08-09 22:29:36.653 UTC
15
2017-07-07 02:56:27.45 UTC
2012-08-13 07:12:48.253 UTC
null
406,677
null
406,677
null
1
34
objective-c|ios|core-data|nsmanagedobject|nsmanagedobjectcontext
33,572
<p>It is not really conceptually possible to "<em>save</em>" Core Data objects "<em>in different rows</em>". Remember, Core Data is an object graph and not a database. </p> <p>If you want to "relocate" your sentence, the best way is to destroy it and recreate it. If you want to keep the old instance, just create a new...
11,917,708
How to pipe multiple commands into a single command in the shell? (sh, bash, ...)
<p>How can I pipe the stdout of multiple commands to a single command? </p> <p>Example 1: combine and sort the output of all three echo commands:</p> <pre><code>echo zzz; echo aaa; echo kkk </code></pre> <p>desired output:</p> <pre><code>aaa kkk zzz </code></pre> <p>Example 2: rewrite the following so that all th...
11,917,709
3
0
null
2012-08-11 21:13:04.08 UTC
13
2022-09-13 14:39:12.18 UTC
2022-09-13 14:39:12.18 UTC
null
875,915
null
875,915
null
1
71
bash|shell|process|pipe|subshell
65,685
<p>Use parentheses ()'s to combine the commands into a single process, which will concatenate the stdout of each of them.</p> <p>Example 1 (note that <code>$</code> is the shell prompt):</p> <pre><code>$ (echo zzz; echo aaa; echo kkk) | sort aaa kkk zzz </code></pre> <p><br/> Example 2:</p> <pre><code>(setopt; unse...
11,892,729
How to "log in" to a website using Python's Requests module?
<p>I am trying to post a request to log in to a website using the Requests module in Python but its not really working. I'm new to this...so I can't figure out if I should make my Username and Password cookies or some type of HTTP authorization thing I found (??). </p> <pre><code>from pyquery import PyQuery import req...
11,892,838
6
0
null
2012-08-09 22:12:14.537 UTC
105
2020-10-29 22:50:22.77 UTC
2012-08-09 22:39:20.423 UTC
null
1,587,751
null
1,587,751
null
1
140
python|python-requests|pyquery
328,543
<h2>If the information you want is on the page you are directed to immediately after login...</h2> <p>Lets call your <code>ck</code> variable <code>payload</code> instead, like in the <a href="http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests" rel="noreferrer">python-requests</a...
20,057,771
'No JUnit tests found' in Eclipse
<p>So I'm new to JUnit, and we have to use it for a homework assignment. Our professor gave us a project that has one test class, <code>BallTest.java</code>. When I right click > Run as > JUnit Test, I get a popup error that says 'No JUnit tests found'. I know the question has been answered here(<a href="https://stacko...
20,062,207
23
5
null
2013-11-18 20:58:55.097 UTC
12
2021-07-15 11:30:06.603 UTC
2017-05-23 12:26:33.11 UTC
null
-1
null
994,541
null
1
52
java|eclipse|unit-testing|junit
141,409
<p>Right Click on Project > Properties > Java Build Path > Add the Test folder as source folder.</p> <p>All source folders including Test Classes need to be in Eclipse Java Build Path. So that the sources such as main and test classes can be compiled into the build directory (Eclipse default folder is bin).</p>
3,585,871
How can I get the current mouse (pointer) position co-ordinates in X
<p>This can either be some sample C code or a utility that will show me either gui or on the console it doesn't matter, but I have to be able to "command" it to grab the co-ordinates at an exact time which makes xev not very useful (that I could figure out).</p>
3,591,679
4
0
null
2010-08-27 15:45:31.547 UTC
9
2020-01-06 18:40:01.65 UTC
2011-07-28 17:08:29.793 UTC
null
102,937
null
376,403
null
1
22
xorg
21,476
<p>I'm not a C programmer by any means but I looked at a couple of online tutorials and think this is how you are supposed to read the current mouse position. This is my own code and I'd done nothing with Xlib before so it could be completely broken (for example, the error handler shouldn't just do nothing for every er...
3,958,342
Convert audio to text
<p>I just want to know if there is any build in libraries or external libraries in Java or C# that allow me to take an audio file and parse it and extract the text from it.</p> <p>I need to make an application to do so, but I don't know from where I can start.</p>
3,958,634
5
6
null
2010-10-18 10:41:44.933 UTC
10
2012-03-17 17:09:48.313 UTC
2011-07-25 11:28:34.263 UTC
null
418,556
null
458,700
null
1
12
c#|java|speech-recognition|audio-processing
23,709
<p>Here are some of your options:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms723627%28VS.85%29.aspx" rel="noreferrer">Microsoft Speech</a></li> <li><a href="http://www.lumenvox.com/products/speech_engine/" rel="noreferrer">Lumenvox</a></li> <li><a href="http://www.nuance.com/for-developers/dragon/...
3,230,633
How to register handler interceptors with spring mvc 3.0?
<p>It should be easy:</p> <pre><code>&lt;bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt; &lt;property name="interceptors"&gt; &lt;list&gt; &lt;ref bean="myInterceptor" /&gt; &lt;/list&gt; &lt;/property&gt; &lt;/b...
3,231,197
5
2
null
2010-07-12 17:23:54.273 UTC
10
2012-11-08 00:28:28.85 UTC
null
null
null
null
203,907
null
1
18
java|spring|spring-mvc
27,625
<p>By default, Spring will register a <code>BeanNameUrlHandlerMapping</code>, and a <code>DefaultAnnotationHandlerMapping</code>, without any explicit config required. </p> <p>If you define your own <code>HandlerMapping</code> beans, then the default ones will not be registered, and you'll just get the explicitly decl...
3,822,732
Android: getString(R.string) in static method
<p>When programming for Android sometimes you have to use static methods. But when you try to access you resources in a static method with <code>getString(R.string.text)</code> you'll get an error. Making it static doesn't work.</p> <p>Does anyone knows a good way around this? The resource files in Android are very he...
3,822,756
6
0
null
2010-09-29 14:43:24.353 UTC
2
2019-11-25 10:38:02.517 UTC
2014-02-28 11:13:09.773 UTC
null
1,542,891
null
461,864
null
1
30
android|static|getstring
32,708
<p>One way or another, you'll need a Context for that... For static methods this probably means you need to pass along a Context when calling them.</p>
3,649,639
limit on string size in c++?
<p>I have like a million records each of about 30 characters coming in over a socket. Can I read all of it into a single string? Is there a limit on the string size I can allocate?</p> <p>If so, is there someway I can send data over the socket records by record and receive it record by record. I dont know the size of ...
3,649,663
8
0
null
2010-09-06 07:06:15.733 UTC
null
2016-08-21 20:05:15.64 UTC
null
null
null
null
430,322
null
1
23
c++
80,874
<p>To answer your first question: The maximum size of a C++ string is given by <a href="http://en.cppreference.com/w/cpp/string/basic_string/max_size" rel="noreferrer">string::max_size</a></p>
3,786,881
What is a "method" in Python?
<p>Can anyone, please, explain to me in very simple terms what a "method" is in Python?</p> <p>The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I am of course familiar with the general meaning of this word...
3,786,900
8
4
null
2010-09-24 12:07:07.263 UTC
51
2021-11-17 20:22:55.787 UTC
2012-07-16 20:07:11.007 UTC
null
1,288
null
206,857
null
1
80
python|methods
218,271
<p>It's a function which is a member of a class:</p> <pre><code>class C: def my_method(self): print(&quot;I am a C&quot;) c = C() c.my_method() # Prints(&quot;I am a C&quot;) </code></pre> <p>Simple as that!</p> <p>(There are also some alternative kinds of method, allowing you to control the relationship ...
3,973,994
How can I recover from an erronous git push -f origin master?
<p>I just committed the wrong source to my project using <code>--force</code> option.</p> <p>Is it possible to revert? I understand that all previous branches have been overwritten using <code>-f</code> option, so I may have screwed up my previous revisions.</p>
3,974,056
9
1
null
2010-10-20 00:54:59.673 UTC
43
2020-07-12 00:41:13.49 UTC
2016-11-25 17:43:16.3 UTC
null
971,141
null
297,201
null
1
118
git|git-commit|git-push
101,186
<p>Git generally doesn't throw anything away, but recovering from this may still be tricky.</p> <p>If you have the correct source then you could just push it into the remote with the <code>--force</code> option. Git won't have deleted any branches unless you told it to. If you have actually lost commits then take a lo...
3,330,193
Early exit from function?
<p>I have a function:</p> <pre><code>function myfunction() { if (a == 'stop') // How can I stop the function here? } </code></pre> <p>Is there something like <code>exit()</code> in JavaScript?</p>
3,330,206
12
6
null
2010-07-25 17:16:24.91 UTC
73
2021-04-21 18:17:52.673 UTC
2018-05-30 18:04:29.337 UTC
null
881,229
null
291,772
null
1
466
javascript
975,821
<p>You can just use <code>return</code>.</p> <pre><code>function myfunction() { if(a == 'stop') return; } </code></pre> <p>This will send a return value of <code>undefined</code> to whatever called the function.</p> <pre><code>var x = myfunction(); console.log( x ); // console shows undefined </code...
7,816,863
How to use document.getElementByName and getElementByTag?
<pre><code> document.getElementById('frmMain').elements </code></pre> <p>can i use like this </p> <pre><code>document.getElementByName('frmMain').elements </code></pre> <p>or </p> <pre><code>document.getElementBytag('table').elements` </code></pre>
7,816,899
6
1
null
2011-10-19 05:21:26.92 UTC
5
2019-05-11 17:49:33.693 UTC
2014-12-20 15:03:38.937 UTC
null
1,897,200
null
989,368
null
1
17
javascript
187,122
<ul> <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById" rel="nofollow noreferrer">document.getElementById('frmMain').elements</a><br> assumes the form has an ID and that the ID is unique as IDs should be. Although it also accesses a <code>name</code> attribute in IE, please add ID to...
7,972,785
Can a C macro definition refer to other macros?
<p>What I'm trying to figure out is if something such as this (written in <strong>C</strong>):</p> <pre><code>#define FOO 15 #define BAR 23 #define MEH (FOO / BAR) </code></pre> <p>is allowed? I would want the preprocessor to replace every instance of</p> <pre><code>MEH </code></pre> <p>with</p> <pre><code>(15 / ...
7,972,803
6
2
null
2011-11-01 20:56:06.6 UTC
7
2019-09-24 11:17:52.853 UTC
2015-11-28 16:12:16.357 UTC
null
4,370,109
null
1,024,485
null
1
66
c|c-preprocessor
52,418
<p>Short answer yes. You can nest defines and macros like that - as many levels as you want as long as it isn't recursive.</p>
8,320,172
Use Html.RadioButtonFor and Html.LabelFor for the same Model but different values
<p>I have this Razor Template</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;@Html.RadioButtonFor(i =&gt; i.Value, "1")&lt;/td&gt; &lt;td&gt;@Html.LabelFor(i =&gt; i.Value, "true")&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;@Html.RadioButtonFor(i =&gt; i.Value, "0")&lt;/td&gt; &lt;td&gt;@Html.Label...
8,623,532
7
2
null
2011-11-30 01:45:44.103 UTC
14
2015-10-09 11:30:42.797 UTC
null
null
null
null
596,137
null
1
36
asp.net-mvc-3|razor
65,127
<p>I've been wondering how MVC determines "nested" field names and IDs. It took a bit of research into the MVC source code to figure out, but I think I have a good solution for you.</p> <h3>How EditorTemplates and DisplayTemplates determine field names and IDs</h3> <p>With the introduction of EditorTemplates and Dis...
8,045,556
Can't make the custom DialogFragment transparent over the Fragment
<p>I need to create a dialog over a fragment (that takes up the whole screen). The dialog needs to be a floating dialog that will be positioned over the fragment with the fragment darkened out outside of the fragment..</p> <p>For the custom Dialog, i have a linearLayout that has curved edges, no matter what i do, the ...
9,315,283
10
0
null
2011-11-08 03:20:20.343 UTC
32
2020-08-05 02:16:31.757 UTC
null
null
null
null
137,404
null
1
116
android|android-layout|android-fragments|android-dialog|android-dialogfragment
65,036
<p>Try</p> <pre><code>getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); </code></pre> <p>in your <code>DialogFragment</code>'s <code>onCreateView</code></p>
8,026,263
How to see if a user is online in a website with php and mysql driven databases?
<p>I'm building a community website. Users will login and logout as usually. </p> <p>I use the attribute status online/offline to set the user's status. But what if a user just clicks the X button or disconnects otherwise without logging out?</p> <p>Lately my computer crashed, when I opened the site with my laptop I ...
8,026,310
12
0
null
2011-11-06 09:50:29.16 UTC
9
2020-02-06 17:26:26.113 UTC
2017-01-25 07:34:40.283 UTC
null
6,887,672
null
929,729
null
1
10
php|mysql|database|login-control
42,785
<p>You don't need the online/offline flag, you just need to save the last activitity time. When displaying the user status, if last activity time is less than now+15 minutes then user is online, offline otherwise.</p>
4,781,070
How to insert tab character when expandtab option is on in Vim
<p>When I'm in insert mode and I have the <a href="https://vimhelp.org/options.txt.html#%27expandtab%27" rel="noreferrer"><code>expandtab</code></a> option switched on, pressing <kbd>Tab ↹</kbd> results in inserting the configured number of spaces.</p> <p>But occasionally I want to insert an actual tab character.</p> ...
4,781,099
3
0
null
2011-01-24 10:46:56.54 UTC
92
2021-04-02 05:08:41.687 UTC
2020-05-04 11:05:46.837 UTC
null
775,954
null
529,397
null
1
371
vim
117,908
<p>You can use <code>&lt;CTRL-V&gt;&lt;Tab&gt;</code> in "insert mode". In insert mode, <code>&lt;CTRL-V&gt;</code> inserts a literal copy of your next character.</p> <p>If you need to do this often, @Dee`Kej suggested (in the comments) setting <kbd>Shift</kbd>+<kbd>Tab</kbd> to insert a real tab with this mapping:</p...
4,116,681
How to load system properties file in Spring?
<p>I have a properties file which I would like loaded in to System Properties so that I can access it via <code>System.getProperty("myProp")</code>. Currently, I'm trying to use the Spring <code>&lt;context:propert-placeholder/&gt;</code> like so:</p> <pre><code>&lt;context:property-placeholder location="/WEB-INF/pro...
4,117,375
4
1
null
2010-11-07 06:04:01.43 UTC
9
2022-03-18 02:33:34.94 UTC
null
null
null
null
125,278
null
1
8
java|spring|spring-mvc
35,447
<p>While I subscribe to the Spirit of <a href="https://stackoverflow.com/questions/4116681/how-to-load-system-properties-file-in-spring/4117086#4117086">Bozho's answer</a>, I recently also had a situation where I needed to set System Properties from Spring. Here's the class I came up with:</p> <p><strong>Java Code:</s...
4,718,417
Matlab: loading a .mat file, why is it a struct? can I just have the stored vars loaded into memory?
<p>Relevant code:</p> <pre><code>function result = loadStructFromFile(fileName, environmentName) result = load(fileName, environmentName); bigMatrix = loadStructFromFile('values.mat','bigMatrix'); </code></pre> <p>But when I look in the workspace, it shows 'bigMatrix' as a 1x1 struct. When I click on the stru...
4,718,603
4
0
null
2011-01-17 22:04:22.14 UTC
1
2020-10-07 21:56:34.657 UTC
2013-06-16 12:33:39.303 UTC
null
1,714,410
null
356,849
null
1
8
matlab|matlab-load
38,051
<p>As the documentation of <a href="http://www.mathworks.com/help/techdoc/ref/load.html" rel="noreferrer">LOAD</a> indicates, if you call it with an output argument, the result is returned in a struct. If you do not call it with an output argument, the variables are created in the local workspace with the name as which...
4,351,170
Do DDD and SOA really play well together?
<p>Please let me know, ever so gently, if I am totally mangling the DDD concept, but here is my dilemma.</p> <p>Let's say I have the following domain model:</p> <pre><code>Teacher IList&lt;Class&gt; Class Teacher IList&lt;Student&gt; Student Class </code></pre> <p>Now, from a DDD perspective, it seems like...
4,352,840
4
0
null
2010-12-04 00:34:07.473 UTC
13
2010-12-16 00:55:44.183 UTC
2010-12-04 00:41:57.57 UTC
null
205,856
null
205,856
null
1
15
domain-driven-design|soa
5,300
<p>You are thinking about performance, but you will be surprised. In my SOA web services I use such complete object graphs and performance is well within acceptable limits. I would suggest to use business objects and business web methods like <code>SaveTeacher(Teacher t)</code> unless absolutely required to use DTOs fo...
4,232,842
How to dynamically change filename while writing in a loop?
<p>I would like to do something like this: In a loop, first iteration write some content into a file named file0.txt, second iteration file1.txt and so on, just increase the number.</p> <pre><code>FILE *img; int k = 0; while (true) { // here we get some data into variable data file = fopen("file.txt",...
4,232,864
5
0
null
2010-11-20 13:02:13.263 UTC
7
2021-03-20 18:36:42.793 UTC
2014-09-30 15:55:31.457 UTC
null
2,988,730
null
95,944
null
1
17
c
38,769
<pre><code>int k = 0; while (true) { char buffer[32]; // The filename buffer. // Put "file" then k then ".txt" in to filename. snprintf(buffer, sizeof(char) * 32, "file%i.txt", k); // here we get some data into variable data file = fopen(buffer, "wb"); fwrite (data, 1, strlen(data) , file); ...
4,453,349
what is the Class object (java.lang.Class)?
<p>The Java documentation for <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html" rel="noreferrer"><code>Class</code></a> says:</p> <blockquote> <p><code>Class</code> objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the <code>defineClass</cod...
4,453,378
7
0
null
2010-12-15 18:10:23.53 UTC
83
2019-11-20 17:36:03.173 UTC
2015-08-24 18:35:29.997 UTC
null
113,632
null
515,661
null
1
90
java|class|inheritance
81,800
<p>Nothing gets typecasted to <code>Class</code>. Every <code>Object</code> in Java belongs to a certain <code>class</code>. That's why the <code>Object</code> class, which is inherited by all other classes, defines the <code>getClass()</code> method.</p> <p><code>getClass()</code>, or the class-literal - <code>Foo.cl...
4,393,716
Is there a a way to achieve closures in C
<p>I would like this to work, but it does not:</p> <pre><code>#include &lt;stdio.h&gt; typedef struct closure_s { void (*incrementer) (); void (*emitter) (); } closure; closure emit(int in) { void incrementer() { in++; } void emitter() { printf("%d\n", in); } return (closure) { increment...
4,393,782
9
0
null
2010-12-09 00:21:45.31 UTC
20
2022-05-10 21:19:54.43 UTC
null
null
null
null
535,759
null
1
43
c|closures
36,417
<p>Using <a href="https://savannah.gnu.org/projects/libffcall/" rel="nofollow noreferrer">FFCALL</a>,</p> <pre><code>#include &lt;callback.h&gt; #include &lt;stdio.h&gt; static void incrementer_(int *in) { ++*in; } static void emitter_(int *in) { printf(&quot;%d\n&quot;, *in); } int main() { int in1 = 10, i...
4,196,201
Where are C/C++ main function's parameters?
<p>In C/C++, the main function receives parameters which are of type <code>char*</code>.</p> <pre><code>int main(int argc, char* argv[]){ return 0; } </code></pre> <p><code>argv</code> is an array of <code>char*</code>, and points to strings. Where are these string located? Are they on the heap, stack, or somewhere...
4,196,745
10
5
null
2010-11-16 16:06:48.797 UTC
15
2017-09-04 04:29:17.373 UTC
2017-05-11 17:36:36.587 UTC
null
1,763,356
null
500,638
null
1
62
c++|c|parameters|location|program-entry-point
21,388
<p>It's actually a combination of compiler dependence and operating system dependence. <code>main()</code> is a function just like any other C function, so the location of the two parameters <code>argc</code> and <code>argv</code> will follow standard for the compiler on the platform. e.g. for most C compilers target...
14,553,066
Less css &:hover
<p>How can I create this class with less?</p> <pre><code>.class { display: none; } a:hover .class { display: block; } </code></pre>
14,553,094
3
0
null
2013-01-27 22:27:43.91 UTC
1
2017-10-24 14:46:03.74 UTC
2017-10-24 14:46:03.74 UTC
null
2,678,454
null
1,238,583
null
1
13
less
49,902
<p>Like this?</p> <pre><code>.class { display: none; a:hover &amp; { display: block; } } </code></pre>
14,667,274
ASP.NET MVC Partial view ajax post?
<p><strong>Index.html (View)</strong></p> <pre><code>&lt;div class="categories_content_container"&gt; @Html.Action("_AddCategory", "Categories") &lt;/div&gt; </code></pre> <p><strong>_AddCategory.cshtml (PartialView)</strong></p> <pre><code>&lt;script&gt; $(document).ready(function () { $('input[type...
14,667,550
2
3
null
2013-02-02 22:37:53.793 UTC
11
2015-04-10 18:26:33.437 UTC
2015-04-10 18:26:33.437 UTC
null
275,567
null
1,324,756
null
1
15
javascript|jquery|asp.net-mvc|asp.net-mvc-3|asp.net-mvc-4
38,830
<p>Don't redirect from controller actions that are invoked with AJAX. It's useless. You could return the url you want to redirect to as a JsonResult:</p> <pre><code>[HttpPost] public ActionResult _AddCategory(CategoriesViewModel viewModel) { if(//success) { // DbOperations... return Json(new { ...
14,828,678
Disconnecting lambda functions in Qt5
<p>Is it possible to disconnect a lambda function? And if "yes", how?</p> <p>According to <a href="https://qt-project.org/wiki/New_Signal_Slot_Syntax" rel="noreferrer">https://qt-project.org/wiki/New_Signal_Slot_Syntax</a> I need to use a <code>QMetaObject::Connection</code> which is returned from the QObject::connect...
14,829,520
3
4
null
2013-02-12 08:49:11.017 UTC
12
2022-08-11 22:08:30.003 UTC
null
null
null
null
940,158
null
1
43
c++|lambda|qt5
17,616
<p>If you capture <code>conn</code> directly, you're capturing an uninitialised object by copy, which results in undefined behaviour. You need to capture a smart pointer:</p> <pre><code>std::unique_ptr&lt;QMetaObject::Connection&gt; pconn{new QMetaObject::Connection}; QMetaObject::Connection &amp;conn = *pconn; conn =...
14,797,525
Differences between nuget-packing a csproj vs. nuspec
<p>Recently, I started to pack nuget packages out of my several projects. First I started with the Package Explorer application. It is a nice tool, but it's less useful if you do continuous integration. Then I looked into specifying the <em>nuspec</em> template file, and passing changing data, e.g. version number, as c...
14,808,085
4
0
null
2013-02-10 12:04:54.613 UTC
11
2019-05-23 11:49:09.383 UTC
2013-02-10 14:12:14.907 UTC
null
526,535
null
568,266
null
1
59
c#|.net|nuget
35,808
<p>Here's a little-known fact: <strong>you can combine both</strong>! Target a csproj file, and make sure there's a nuspec file in the same directory with the same name as the csproj file. NuGet will merge the two during package creation.</p> <p>So in short: target <code>&lt;ProjectName&gt;.csproj</code>, optionally a...
19,617,621
Android: How to send http request via service every 10 seconds
<p>I need to receive a status from the server every 10 seconds.</p> <p>I tried to do that by sending a http request via service.</p> <p>The problem is that my code executes only once.</p> <p>This is the code for my service:</p> <pre><code>public class ServiceStatusUpdate extends Service { @Override public IBinder ...
19,617,698
5
0
null
2013-10-27 11:38:32.79 UTC
8
2015-12-29 12:15:23.223 UTC
2013-10-27 11:55:07.223 UTC
null
1,511,951
null
2,924,926
null
1
11
java|android|service|httprequest
33,633
<p>Put a handler inside onPostExecute to send a http request after 10 secs</p> <pre><code>new Handler().postDelayed(new Runnable() { public void run() { requestHttp(); } }, 10000); </code></pre> <p>After 10 secs doInBackground will be executed again, after that onPostExecute again, han...
2,507,235
jquery flot xaxis time
<p>In this example in xaxis will compare the days...</p> <pre><code>$.plot($("#placeholder"), data, { yaxis: {}, xaxis: { mode: "time",minTickSize: [1, "day"],timeformat: "%d/%m/%y"},"lines": {"show": "true"},"points": {"show": "true"},clickable:true,hoverable: true }); </co...
2,508,428
2
0
null
2010-03-24 11:33:52.883 UTC
6
2014-09-12 15:07:43.063 UTC
2012-10-03 14:38:45.347 UTC
null
970,544
null
109,227
null
1
19
jquery|flot
70,605
<pre><code>$.plot($("#placeholder"), data, { yaxis: { }, xaxis: { mode: "time",minTickSize: [1, "hour"], min: (new Date("2000/01/01")).getTime(), max: (new Date("2000/01/02")).getTime() }, "lines": {"show": "true"}, "points": {"show": "true"}, ...
2,386,793
Efficient looping through AS3 dictionary
<pre><code>for (var k in dictionary) { var key:KeyType = KeyType(k); var value:ValType = ValType(dictionary[k]); // &lt;-- lookup // do stuff } </code></pre> <p>This is what I use to loop through the entries in a dictionary. As you can see in every iteration I perform a lookup in the dictionary. Is there a more...
2,386,940
2
0
null
2010-03-05 12:53:12.113 UTC
8
2016-09-16 15:33:04.673 UTC
2010-03-05 13:21:18.427 UTC
null
85,821
null
85,821
null
1
45
actionscript-3|iterator|iteration
47,126
<p>Iterate through <strong>keys</strong> &amp; <strong>values</strong>: </p> <pre><code>for (var k:Object in dictionary) { var value:ValType = dictionary[k]; var key:KeyType = k; } </code></pre> <p>Iterate through <strong>values</strong> more concisely: </p> <pre><code>for each (var value:ValType in dictio...
3,050,492
How can I set default storage engine used by MySQL?
<p>I've been working on writing SQL to create a MySQL database with several default options, including character set and collation. Is it possible to set the default storage engine for tables in this database to InnoDB? </p> <p>I've been looking through the MySQL 5.1 manual and I've found the statement <code>ENGINE=i...
3,050,502
2
0
null
2010-06-16 03:12:30.137 UTC
12
2014-09-25 10:22:58.003 UTC
2014-09-25 10:18:37.787 UTC
null
194,894
null
359,030
null
1
55
mysql|database|innodb
77,280
<p>Quoting the Reference Manual (<a href="http://dev.mysql.com/doc/refman/5.1/en/storage-engine-setting.html" rel="noreferrer">Setting the Storage Engine</a>):</p> <blockquote> <p>If you omit the <code>ENGINE</code> option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using ...
33,773,477
JWT (JSON Web Token) in PHP without using 3rd-party library. How to sign?
<p>There are a few libraries for implementing JSON Web Tokens (JWT) in PHP, such as <a href="https://github.com/firebase/php-jwt" rel="noreferrer">php-jwt</a>. I am writing my own, very small and simple class but cannot figure out why my signature fails validation <a href="http://jwt.io/" rel="noreferrer">here</a> eve...
33,773,850
3
0
null
2015-11-18 06:47:15.297 UTC
11
2021-10-06 20:08:22.49 UTC
null
null
null
null
3,977,061
null
1
24
php|json|authentication|jwt|sha
24,116
<p>I solved it! I did not realize that the signature itself needs to be base64 encoded. In addition, I needed to set the last optional parameter of the <code>hash_hmac</code> function to <code>$raw_output=true</code> (see <a href="http://php.net/manual/en/function.hash-hmac.php" rel="noreferrer">the docs</a>. In shor...
34,507,160
How can I handle an event to open a window in react js?
<p>I want to open a window after clicking the fshare:</p> <p>My <code>render()</code> return is like this</p> <pre><code>&lt;Modal.Footer&gt; &lt;img src=&quot;/static/img/fshare.png&quot; onClick={this.fbShare} /&gt; &lt;Button onClick={this.hide}&gt;Close&lt;/Button&gt; &lt;/Modal.Footer&gt; </code></pre> <p>...
34,507,414
2
0
null
2015-12-29 08:17:40.56 UTC
2
2021-10-25 11:08:38.23 UTC
2020-12-23 00:39:22.463 UTC
null
1,783,163
null
4,796,134
null
1
14
reactjs|event-handling|modal-dialog
78,643
<p>You are on the right way!</p> <p>Is it something you need? I prepared the example: click <a href="https://jsfiddle.net/69z2wepo/25653/" rel="noreferrer" title="jsfiddle">here</a></p> <pre><code>var Example = React.createClass({ fbShare: function() { window.open('http://www.facebook.com/sharer.php?s=10...
54,851,861
How do I activate type annotations hints in Kotlin like depicted?
<p>I was able to activate this option once in my MacOS intellij version, but could never find this option anymore, I forgot its name.</p> <p>I know there is the CTRL+SHIFT+P alternative to this, but it is not as user-friendly.</p> <p>How can I activate the option to make intellij show me all the inferred types like d...
54,852,497
3
0
null
2019-02-24 12:26:44.413 UTC
20
2022-07-08 09:11:26.923 UTC
null
null
null
null
2,207,729
null
1
46
intellij-idea|kotlin
11,355
<p>For <strong>IntelliJ (2022.1)</strong> onwards got to <code>Settings -&gt; Editor -&gt; Inlay Hints -&gt; Types -&gt; Kotlin -&gt; Types -&gt; Parameter hints -&gt; Local variable types</code> or check all.</p> <p>I think you are allowed to say, that this feature configuration is a little bit hidden in the menues an...
29,087,882
Android Studio Run/Debug configuration error: Module not specified
<p>I am getting a 'Module not specified' error in my run config. I have no module showing in the drop down yet I can see my module no probs. The issue came about when I refactored my module name, changed the settings.gradle to new name.</p> <p>Now when I go to project structure and select my module nothing shows in th...
29,087,954
23
0
null
2015-03-16 22:11:01.917 UTC
31
2021-11-21 02:25:27.42 UTC
2017-09-08 14:17:22.853 UTC
null
2,350,083
null
510,981
null
1
174
android|android-studio|module|gradle
217,923
<p>never mind, i changed the name in settings.gradle and synced and then changed it back and synced again and it inexplicably worked this time.</p>
36,493,977
Flip a Bitmap image horizontally or vertically
<p>By using this code we can rotate an image:</p> <pre><code>public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); } </code></pre> <p>But h...
36,494,192
6
0
null
2016-04-08 07:31:26.96 UTC
4
2020-09-01 06:42:35.83 UTC
2016-04-08 07:53:40.503 UTC
null
360,211
null
5,138,179
null
1
33
java|android|image|matrix|android-bitmap
24,643
<p>Given <code>cx,cy</code> is the centre of the image:</p> <p>Flip in x:</p> <pre><code>matrix.postScale(-1, 1, cx, cy); </code></pre> <p>Flip in y:</p> <pre><code>matrix.postScale(1, -1, cx, cy); </code></pre> <p>Altogether:</p> <pre><code>public static Bitmap createFlippedBitmap(Bitmap source, boolean xFlip, boolean...
40,476,233
How to mock an async repository with Entity Framework Core
<p>I'm trying to create a unit test for a class that calls into an async repository. I'm using ASP.NET Core and Entity Framework Core. My generic repository looks like this.</p> <pre><code>public class EntityRepository&lt;TEntity&gt; : IEntityRepository&lt;TEntity&gt; where TEntity : class { private readonly Saa...
40,491,640
9
3
null
2016-11-07 23:01:15.59 UTC
27
2022-09-12 11:38:40.103 UTC
2016-11-07 23:13:56.543 UTC
null
5,233,410
null
6,162,143
null
1
99
c#|unit-testing|asp.net-core|moq|entity-framework-core
54,624
<p>Thanks to @Nkosi for pointing me to a link with an example of doing the same thing in EF 6: <a href="https://msdn.microsoft.com/en-us/library/dn314429.aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/dn314429.aspx</a>. This didn't work exactly as-is with EF Core, but I was able to start with it and m...
47,637,469
How to mat-button-toggle by default selected in angular
<p>How can I set default selected last button in toggle group.<br> This is my code.</p> <pre><code>&lt;mat-button-toggle-group #group="matButtonToggleGroup"&gt; &lt;mat-button-toggle value="Heritage"&gt; &lt;span&gt;Heritage&lt;/span&gt; &lt;/mat-button-toggle&gt; &lt;mat-button-toggle value="Natur...
47,991,657
7
0
null
2017-12-04 16:11:17.597 UTC
4
2022-02-08 15:07:12.3 UTC
2020-08-14 19:09:06.56 UTC
null
4,308,163
null
4,308,163
null
1
60
angular|angular-material|angular5
62,309
<p>I fixed it. Simply add the <code>value</code> attribute to the <code>mat-button-toggle-group</code> tag.</p> <pre><code>&lt;mat-button-toggle-group #group="matButtonToggleGroup" value="All"&gt; &lt;mat-button-toggle value="Heritage"&gt; &lt;span&gt;Heritage&lt;/span&gt; &lt;/mat-button-toggle&gt; &lt;mat-button...
38,768,567
How to print object in Node JS
<p>In the below code (running on Node JS) I am trying to print an object obtained from an external API using <code>JSON.stringify</code> which results in an error: </p> <blockquote> <p>TypeError: Converting circular structure to JSON</p> </blockquote> <p>I have looked at the questions on this topic, but none could...
38,771,700
8
3
null
2016-08-04 13:22:11.003 UTC
2
2022-06-22 18:35:30.303 UTC
null
null
null
null
2,652,541
null
1
27
javascript|json|node.js
91,433
<p>By using the http <code>request</code> client, I am able to print the JSON object as well as print the <code>country</code> value. Below is my updated code.</p> <pre><code>var request = require('request'); request('http://ip-api.com/json', function (error, response, body) { if (!error &amp;&amp; response.statusCo...
31,608,770
TABLEAU: calc field to get the last value available
<p>I'm using Tableau Desktop, my data are like this:</p> <pre><code>KPI,date,monthValue coffee break,01/06/2015,10.50 coffee break,01/07/2015,8.30 </code></pre> <p>and I want to build a table like this</p> <pre><code>KPI, year(date), last value coffee time, 2015, 8.30 </code></pre> <p>How can I set a calculated fie...
31,609,712
1
0
null
2015-07-24 10:56:10.253 UTC
null
2015-08-27 09:54:00.193 UTC
2015-08-27 09:54:00.193 UTC
null
1,213,296
null
5,151,915
null
1
4
field|tableau-api
48,359
<p>If you are using Tableau 9 then you can do this with an LOD calc that looks for the max value in your date field and then checks if the current date value is the same as the max date value.</p> <pre><code>[Date] == {fixed: max([Date])} </code></pre> <p>As you can see in the example below when you use the calc as a...
35,479,080
How do I turn a Windows feature on/off from the command line in Windows 10?
<p>In Windows 10 and from "Programs and Features", you can turn Windows features on or off and then initiate a download and installation. I wish to turn ".NET Framework 3.5" ON and have it downloaded and installed, but I need to do it via e.g. a PowerShell script or via a command. I need to use the command line.</p> <...
37,999,562
3
0
null
2016-02-18 10:37:44.437 UTC
3
2019-12-10 16:47:06.63 UTC
2019-05-04 14:43:01.86 UTC
null
63,550
null
2,448,495
null
1
16
powershell|windows-10
41,493
<p>Run a command prompt <strong>as an administrator</strong> and use:</p> <pre><code>dism /online /Get-Features </code></pre> <p>This will display the feature names since they don't always match up with what you're seeing in that visual feature list. It will also show which are currently enabled/disabled. Once you fi...
35,369,419
How to use images in css with Webpack
<p>I am making a React w/ Webpack setup and am struggling to do what seems like should be a simple task. I want webpack to include images, and minimize them like I with gulp but I can't figure it out. I just want to be able to link an image in my css like so:</p> <pre><code>/* ./src/img/background.jpg */ body { backg...
35,369,698
2
0
null
2016-02-12 18:09:45.36 UTC
12
2020-04-04 12:17:14.073 UTC
null
null
null
null
3,737,841
null
1
56
css|image|reactjs|webpack|loader
61,026
<p>I was stuck with similar issue and found that you can use <a href="https://github.com/webpack-contrib/url-loader" rel="noreferrer"><code>url-loader</code></a> to resolve <code>"url()"</code> statements in your CSS as any other require or import statements.</p> <p>To install it:</p> <p><code>npm install url-loader ...
44,480,740
How to save a Docker container state
<p>I'm trying to learn the ins and outs of Docker, and I'm confused by the prospect of saving an image. </p> <p>I ran the basic Ubuntu image, installed Anaconda Python and a few other things...so now what's the best way to save my progress? Save, commit, export? </p> <p>None of these seem to work the same way as Virt...
44,480,870
4
0
null
2017-06-11 05:40:56.16 UTC
31
2021-09-22 18:40:21.18 UTC
2018-08-06 12:23:11.1 UTC
null
63,550
null
3,325,401
null
1
116
docker
119,220
<p>The usual way is at least through a <a href="https://docs.docker.com/engine/reference/commandline/commit/" rel="noreferrer"><code>docker commit</code></a>: that will freeze the state of your container into a new image.</p> <p>Note: As <a href="https://stackoverflow.com/questions/44480740/how-to-saving-a-docker-cont...
65,837,109
When should I use "git push --force-if-includes"
<p>When I want to force push, I nearly always use <code>--force-with-lease</code>. Today I upgraded to Git 2.30 and discovered a new option: <code>--force-if-includes</code>.</p> <p>After reading the <a href="https://git-scm.com/docs/git-push" rel="noreferrer">updated documentation</a>, it's still not entirely clear to...
65,839,129
3
0
null
2021-01-21 23:11:32.417 UTC
9
2022-03-09 18:45:45.01 UTC
2021-04-17 02:48:15.723 UTC
null
184,546
null
184,546
null
1
15
git|git-push
2,433
<p>The <code>--force-if-includes</code> option is, as you've noted, new. If you've never needed it before, you don't need it now. So the shortest answer to &quot;when should I use this&quot; would be &quot;never&quot;. The <em>recommended</em> answer is (or will be once it's proven?) <em>always</em>. (I'm not yet c...
49,454,202
React Native Unable to find a matching configuration of project (Build only)
<p>My react native build works fine when running <code>react-native run-android</code> or <code>cd android &amp;&amp; ./gradlew assembleDebug</code>. But I'll get the following for all every react native package I have installed when running <code>./gradlew assembleRelease</code></p> <pre><code>&gt; Could not resolve ...
49,699,547
6
0
null
2018-03-23 16:21:37.173 UTC
1
2021-06-01 06:35:07.897 UTC
2018-04-06 17:49:14.753 UTC
null
3,750,636
null
3,750,636
null
1
31
android|react-native|gradle|android-gradle-plugin|gradlew
53,731
<p>Upgrade Gradle and add <code>matchingFallbacks</code> to your non-standard build type. Your libraries do not know what build type to match.</p> <p>Eg.</p> <pre><code>buildType { ... mySpecialRelease { ... matchingFallbacks = ['release', 'debug'] } } </code></pre>
24,629,705
Django using get_user_model vs settings.AUTH_USER_MODEL
<p>Reading the Django Documentation:</p> <p><strong>get_user_model()</strong></p> <blockquote> <p>Instead of referring to User directly, you should reference the user model using django.contrib.auth.get_user_model(). This method will return the currently active User model – the custom User model if one is spe...
24,630,589
6
0
null
2014-07-08 10:40:48.407 UTC
34
2022-07-08 23:16:35.417 UTC
null
null
null
null
578,822
null
1
135
python|django
91,272
<p>Using <code>settings.AUTH_USER_MODEL</code> will delay the retrieval of the actual model class until all apps are loaded. <code>get_user_model</code> will attempt to retrieve the model class at the moment your app is imported the first time. </p> <p><code>get_user_model</code> cannot guarantee that the <code>User</...
2,541,865
Copying nested lists in Python
<p>I want to copy a 2D list, so that if I modify one list, the other is not modified.</p> <p>For a one-dimensional list, I just do this:</p> <pre><code>a = [1, 2] b = a[:] </code></pre> <p>And now if I modify <code>b</code>, <code>a</code> is not modified.</p> <p>But this doesn't work for a two-dimensional list:</p...
2,541,882
3
12
null
2010-03-29 23:10:34.033 UTC
17
2022-07-09 19:05:49.18 UTC
2018-03-17 15:17:20.603 UTC
null
2,301,450
null
236,924
null
1
64
python|list|copy|deep-copy
42,481
<p>For a more general solution that works regardless of the number of dimensions, use <code>copy.deepcopy()</code>:</p> <pre><code>import copy b = copy.deepcopy(a) </code></pre>
2,444,001
How Does Appcelerator Titanium Mobile Work?
<p>I'm working on building an iPhone app with Titanium Mobile 1.0 and I see that it compiles down to a native iPhone binary. How does this work? Seems like it would take a lot of heavy lifting to analyze the JavaScript code and do a direct translation into Objective-C without having a superset language like 280 North...
2,471,774
3
8
null
2010-03-14 22:17:07.73 UTC
47
2013-06-20 07:11:10.017 UTC
2010-03-17 18:26:57.21 UTC
null
55,589
null
55,589
null
1
79
javascript|objective-c|titanium
41,811
<p>Titanium takes your Javascript code, analyzes and preprocesses it and then pre-compiles it into a set of symbols that are resolved based on your applications uses of Titanium APIs. From this symbol hierarchy we can build a symbol dependency matrix that maps to the underlying Titanium library symbols to understand w...
3,160,888
How can I pattern match on a range in Scala?
<p>In Ruby I can write this:</p> <pre><code>case n when 0...5 then "less than five" when 5...10 then "less than ten" else "a lot" end </code></pre> <p>How do I do this in Scala?</p> <p>Edit: preferably I'd like to do it more elegantly than using <code>if</code>.</p>
3,161,234
4
1
null
2010-07-01 19:06:30.377 UTC
5
2015-08-26 21:38:04.49 UTC
2011-09-26 01:36:43.03 UTC
null
109,618
null
1,109
null
1
41
scala|pattern-matching|range
14,746
<p>Inside pattern match it can be expressed with guards:</p> <pre><code>n match { case it if 0 until 5 contains it =&gt; "less than five" case it if 5 until 10 contains it =&gt; "less than ten" case _ =&gt; "a lot" } </code></pre>
36,338,890
Enable Lambda function to an S3 bucket using cloudformation
<p>We are creating an S3 bucket using a CloudFormation template. I would like to associate (Add an event to S3 bucket) a Lambda function whenever a file is added to the S3 bucket.</p> <p>How is it possible through CloudFormation templates. What are the properties which needs to be used in CloudFormation.</p>
41,518,559
5
1
null
2016-03-31 16:28:30.783 UTC
16
2020-06-05 14:20:40.083 UTC
2016-04-01 19:22:45.8 UTC
null
1,065,358
null
1,065,358
null
1
36
amazon-web-services|amazon-s3|amazon-cloudformation
43,323
<p>Here's a complete, self-contained CloudFormation template that demonstrates how to trigger a Lambda function whenever a file is added to an S3 bucket:</p> <p><a href="https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=lambda-s3-event&amp;templateURL=https://s3.amazonaws.com/wjordan-cf-template...
38,155,039
What is the difference between native int type and the numpy.int types?
<p>Can you please help understand what are the main differences (if any) between the native int type and the numpy.int32 or numpy.int64 types?</p>
38,156,888
3
0
null
2016-07-01 23:34:58.38 UTC
14
2016-07-02 05:46:55.29 UTC
null
null
null
null
6,510,497
null
1
55
python|numpy
44,957
<p>Another way to look at the differences is to ask what methods do the 2 kinds of objects have.</p> <p>In Ipython I can use tab complete to look at methods:</p> <pre><code>In [1277]: x=123; y=np.int32(123) </code></pre> <p><code>int</code> methods and attributes:</p> <pre><code>In [1278]: x.&lt;tab&gt; x.bit_lengt...
38,237,942
cron expression in AWS CloudWatch: How to run once a week
<p>In Amazon AWS CloudWatch it is possible to run a rule according to a schedule that is defined in a cron expression.</p> <p>The rules for this are outlined <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/ScheduledEvents.html" rel="noreferrer">here</a>.</p> <p>After some trying around, I ...
38,239,183
1
0
null
2016-07-07 05:14:39.917 UTC
3
2019-01-21 06:23:02.55 UTC
null
null
null
null
270,662
null
1
38
amazon-web-services|cron|cloudwatch
36,512
<p>Try <code>0 16 ? * 1 *</code> The question marks "says" that it must no be executed everyday, so it must check the week day value.</p>
757,809
django-paypal setup
<p>Has anyone setup django-paypal? Here is the link to it <a href="https://github.com/johnboxall/django-paypal" rel="noreferrer">here</a>? </p> <p>I have "myproject" setup, and my folder sturecture looks like this:</p> <p>myproject > paypal > (stdandard and pro folders)</p> <p>to my settins.py file I added</p> <pre...
757,820
2
2
null
2009-04-16 19:57:51.277 UTC
17
2011-08-09 19:24:34.867 UTC
2011-08-09 19:24:34.867 UTC
null
529,829
null
74,474
null
1
14
python|django|paypal
13,052
<p>In your code...</p> <pre><code> 'payment_form_cls': 'payment_form_cls', # form class to use for payment </code></pre> <p>This must be a Form object that's used for validation.</p> <pre><code> 'payment_form_cls': MyValidationForm, # form class to use for payment </code></pre> <hr> <p><strong>Edit</strong></...
1,306,595
Git confused when merging an update into my subtree
<p>We previously used many submodules in our main repositories, but to increase the maintainability of our projects we started an experimental branch where we replaced them all with subtrees.</p> <p>This worked good - but now when I'm trying to update one of the subtrees it erroneously merges the update into a complet...
1,307,817
2
0
null
2009-08-20 14:31:00.48 UTC
9
2013-10-14 11:54:48.94 UTC
2013-10-14 11:54:48.94 UTC
null
20,667
null
20,667
null
1
20
git|merge|git-subtree|subtree
3,164
<p>Unfortunately this is a bug (or missing feature) in the "git merge -s subtree" code. It actually <em>guesses</em> the subtrees that you want to merge. Usually, this magically turns out to be correct, but if your subtree contains a lot of changes (or was originally empty, or whatever), then it can fail spectacularl...
2,400,482
How do I make a "div" button submit the form its sitting in?
<p>I have ASP.Net code generating my button's HTML for me using divs to get it to look and behave how I want. This question is regarding the <strong>HTML produced</strong> by the ASP.Net code.</p> <p>A standard button is easy, just set the onClick event of the div to change the page location:</p> <pre><code>&lt;div n...
2,400,507
6
3
null
2010-03-08 10:05:23.813 UTC
12
2020-12-22 16:36:16.09 UTC
2020-12-22 16:36:16.09 UTC
null
1,783,163
null
175,893
null
1
39
html|asp.net|forms|submit
130,970
<pre><code>onClick="javascript:this.form.submit();"&gt; </code></pre> <p><code>this</code> in div onclick don't have attribute <code>form</code>, you may try <code>this.parentNode.submit()</code> or <code>document.forms[0].submit()</code> will do</p> <p>Also, <code>onClick</code>, should be <strong><code>onclick</cod...
3,172,985
JavaScript - Use variable in string match
<p>I found several similar questions, but it did not help me. So I have this problem:</p> <pre><code>var xxx = "victoria"; var yyy = "i"; alert(xxx.match(yyy/g).length); </code></pre> <p>I don't know how to pass variable in match command. Please help. Thank you.</p>
3,172,994
6
2
null
2010-07-03 21:52:42.51 UTC
20
2019-06-09 07:10:51.86 UTC
2019-06-09 07:10:51.86 UTC
null
2,792,083
null
382,854
null
1
108
javascript|variables|match
145,386
<p>Although the match function doesn't accept string literals as regex patterns, you can use the constructor of the RegExp object and pass that to the String.match function:</p> <pre><code>var re = new RegExp(yyy, 'g'); xxx.match(re); </code></pre> <p>Any flags you need (such as /g) can go into the second parameter. ...
2,856,438
How can I link to a specific glibc version?
<p>When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's no glibc 2.11... </p> <p>As far as I know glibc uses symbol versioning. Can I force gcc to link against a specific s...
2,858,996
6
2
null
2010-05-18 10:45:23.663 UTC
70
2022-08-17 13:10:58.583 UTC
2010-10-26 17:14:07.587 UTC
Roger Pate
null
null
184,207
null
1
171
linux|gcc|linker|glibc|libc
150,518
<p>You are correct in that glibc uses symbol versioning. If you are curious, the symbol versioning implementation introduced in glibc 2.1 is described <a href="http://people.redhat.com/drepper/symbol-versioning" rel="noreferrer">here</a> and is an extension of Sun's symbol versioning scheme described <a href="http://d...
2,717,949
When should I use a semicolon after curly braces?
<p>Many times I've seen a semicolon used after a function declaration, or after the anonymous "return" function of a Module Pattern script. When is it appropriate to use a semicolon after curly braces?</p>
2,717,956
8
0
null
2010-04-27 00:27:52.64 UTC
23
2020-10-08 20:59:33.207 UTC
2019-03-24 11:06:42.95 UTC
null
10,607,772
null
321,781
null
1
66
javascript|syntax
31,285
<p>You use a semicolon after a statement. This is a statement:</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 foo = function() { alert("bar"); };</code></pre> </div> </...
2,828,255
How do I increase the capacity of the Eclipse output console?
<p>Even with the "scroll lock" option enabled for the Eclipse console, eventually it overfills and starts auto-scrolling on me. </p> <p>Is there some way of increasing the capacity of the console so that it stores more lines? I wasn't able to find the option. </p>
2,828,293
10
4
null
2010-05-13 15:56:09.48 UTC
47
2021-06-17 23:49:36.067 UTC
null
null
null
null
23,072
null
1
348
eclipse|console
191,025
<p>Under <code>Window &gt; Preferences</code>, go to the <code>Run/Debug &gt; Console</code> section, then you should see an option "Limit console output." You can uncheck this or change the number in the "Console buffer size (characters)" text box below.</p> <p>(This is in Galileo, Helios CDT, Kepler, Juno, Luna, Mar...
3,199,588
Fastest way to convert JavaScript NodeList to Array?
<p>Previously answered questions here said that this was the fastest way:</p> <pre><code>//nl is a NodeList var arr = Array.prototype.slice.call(nl); </code></pre> <p>In benchmarking on my browser I have found that it is more than 3 times slower than this:</p> <pre><code>var arr = []; for(var i = 0, n; n = nl[i]; ++...
3,199,627
15
5
null
2010-07-07 23:04:49.827 UTC
85
2022-08-21 14:15:55.137 UTC
2014-10-28 02:04:56.84 UTC
null
527,702
null
237,140
null
1
329
javascript|arrays|nodelist
194,160
<h2>2021 update: <a href="https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach" rel="noreferrer">nodeList.forEach() is now standard</a> and supported in all current browsers (<a href="https://caniuse.com/mdn-api_nodelist_foreach" rel="noreferrer">around 95% on both desktop &amp; mobile</a>).</h2> <p>So you...
6,165,077
How do I create a progress bar for data loading in R?
<p>Is it possible to create a progress bar for data loaded into R using <a href="http://www.inside-r.org/r-doc/base/load" rel="noreferrer">load()</a>?</p> <p>For a data analysis project large matrices are being loaded in R from .RData files, which take several minutes to load. I would like to have a progress bar to mo...
6,300,431
2
4
null
2011-05-28 23:47:13.923 UTC
10
2013-01-04 04:54:03.36 UTC
null
null
null
null
61,793
null
1
26
file|r|load|progress-bar|binary-data
7,195
<p>I came up with the following solution, which will work for file sizes less than 2^32 - 1 bytes. </p> <p>The R object needs to be serialized and saved to a file, as done by the following code.</p> <pre><code>saveObj &lt;- function(object, file.name){ outfile &lt;- file(file.name, "wb") serialize(object, out...
21,349,950
Entity Framework 6 Code First - Is Repository Implementation a Good One?
<p>I am about to implement an Entity Framework 6 design with a repository and unit of work.</p> <p>There are so many articles around and I'm not sure what the best advice is: For example I realy like the pattern implemented here: for the reasons suggested in the article <a href="http://codefizzle.wordpress.com/2012/07...
21,352,268
7
1
null
2014-01-25 11:30:13.377 UTC
73
2019-07-19 08:18:18.91 UTC
null
null
null
null
402,421
null
1
51
entity-framework|repository-pattern|unit-of-work
37,136
<p>@Chris Hardie is correct, EF implements UoW out of the box. However many people overlook the fact that EF also implements a generic repository pattern out of the box too:</p> <pre><code>var repos1 = _dbContext.Set&lt;Widget1&gt;(); var repos2 = _dbContext.Set&lt;Widget2&gt;(); var reposN = _dbContext.Set&lt;WidgetN...
35,562,622
In ionic framework how to set first ion-segment-button in active state by default?
<p>In <code>ionic2</code> how to set the first <code>ion-segment-button</code> in <code>ion-segment</code> to be in <code>active state</code>? I have tried to do it with providing the <code>active class</code> to the <code>ion-segment-button</code> like : </p> <pre><code> &lt;div padding&gt; &lt;ion-segment [(ngMo...
35,576,561
3
0
null
2016-02-22 19:55:26.353 UTC
3
2019-04-09 07:29:14.253 UTC
2016-02-23 08:25:28.82 UTC
null
1,823,740
null
1,823,740
null
1
14
android|ios|ionic-framework|ionic2
40,181
<p>This should be helpful: <a href="http://ionicframework.com/docs/v2/components/#segment" rel="noreferrer">http://ionicframework.com/docs/v2/components/#segment</a></p> <p>Also, if you dont have a value for home_tabs at the beginning than the ion-segment component will not know what exactly you want. To solve this yo...
53,189,729
Typescript Error: setInterval - Type 'Timer' is not assignable to type 'number'
<p>I have the following code:</p> <pre><code>let onSizeChangeSetInterval = setInterval(() =&gt; {...}, 30); </code></pre> <p>When I compile this code, I'm getting the following error:</p> <blockquote> <p>ERROR in src/components/popover/popover.component.ts(98,17): error TS2322: Type 'Timer' is not assignable to ty...
53,189,769
3
0
null
2018-11-07 12:46:02.877 UTC
2
2021-09-23 14:26:14.65 UTC
null
null
null
null
5,148,197
null
1
28
javascript|angular|typescript
18,314
<p>Use <code>window.setInterval</code> instead</p>