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
16,957,275
Python to JSON Serialization fails on Decimal
<p>I have a python object which includes some decimals. This is causing the json.dumps() to break.</p> <p>I got the following solution from SO (e.g. <a href="https://stackoverflow.com/questions/1960516/python-json-serialize-a-decimal-object">Python JSON serialize a Decimal object</a>) but the recoomended solution stil...
16,957,370
3
2
null
2013-06-06 08:32:15.793 UTC
8
2017-08-15 09:24:47.83 UTC
2017-08-15 09:24:47.83 UTC
null
100,297
null
1,397,919
null
1
35
python|json|decimal
53,435
<p>It is not (no longer) recommended you create a subclass; the <code>json.dump()</code> and <code>json.dumps()</code> functions take a <code>default</code> function:</p> <pre><code>def decimal_default(obj): if isinstance(obj, decimal.Decimal): return float(obj) raise TypeError json.dumps({'x': decima...
16,627,751
Building with Lombok's @Slf4j and Eclipse: Cannot find symbol log
<p>I have the lombok plugin in Eclipse and enabled annotation processing in Eclipse under java compiler, but still it is unable to recognize the log statements when I use @Slf4j annotation. </p> <p>Do we have to make any other settings? </p>
16,730,520
5
5
null
2013-05-18 18:46:15.433 UTC
2
2020-08-08 13:24:18.06 UTC
2013-05-24 08:17:43.667 UTC
null
12,634
null
2,022,957
null
1
37
eclipse|slf4j|lombok
78,995
<p>You also have to install Lombok into Eclipse. </p> <p>See also <a href="https://stackoverflow.com/questions/3418865/cannot-make-project-lombok-work-on-eclipse-helios/3425327#3425327">this answer</a> on how to do that or check if Lombok is installed correctly.</p> <p>Full Disclosure: I am one of the <a href="http:/...
16,916,903
MongoDB performance - having multiple databases
<p>Our application needs 5 collections in a db. When we add clients to our application we would like to maintain separate db for each customer. For example, if we have 500 customers, we would have 500 dbs and 2500 collections (each db has 5 collection). This way we can separate each customer data. My concern is, will i...
16,928,992
1
2
null
2013-06-04 11:41:59.867 UTC
16
2017-08-01 12:10:48.9 UTC
2017-09-22 17:57:57.377 UTC
null
-1
null
1,280,221
null
1
41
mongodb|database
25,345
<blockquote> <p>Our application needs 5 collections in a db. When we add clients to our application we would like to maintain separate db for each customer. For example, if we have 500 customers, we would have 500 dbs and 2500 collections (each db has 5 collection). This way we can separate each customer data...
16,872,082
How can I send cookies using PHP curl in addition to CURLOPT_COOKIEFILE?
<p>I am scraping some content from a website after a form submission. The problem is that the script is failing every now and then, say 2 times out of 5 the script fails. I am using php curl, COOKIEFILE and COOKIEJAR to handle the cookie. However when I observed the sent headers of my browser (when visiting the target ...
22,261,052
4
2
null
2013-06-01 11:14:34.417 UTC
13
2019-11-24 22:22:18.333 UTC
null
null
null
null
879,618
null
1
49
php|cookies|curl|setcookie
157,682
<p>If the cookie is generated from script, then you can send the cookie manually along with the cookie from the file(using cookie-file option). For example:</p> <pre><code># sending manually set cookie curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: test=cookie")); # sending cookies from file curl_setopt($ch, CUR...
25,763,533
How to identify file type by Base64 encoded string of a image
<p>I get a file which is <a href="https://en.wikipedia.org/wiki/Base64" rel="noreferrer">Base64</a> encoded string as the image. But I think the content of this contains information about file type like png, jpeg, etc. How can I detect that? Is there any library which can help me here? </p>
35,419,967
6
4
null
2014-09-10 10:52:06.417 UTC
5
2019-12-31 04:52:24.197 UTC
2017-06-22 12:12:28.98 UTC
null
1,429,387
null
393,639
null
1
16
java|image|mime-types
77,301
<p>I have solved my problem with using <code>mimeType = URLConnection.guessContentTypeFromStream(inputstream);</code></p> <pre><code>{ //Decode the Base64 encoded string into byte array // tokenize the data since the 64 encoded data look like this "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAKAC" String ...
4,179,606
How to copy observable collection
<p>I have</p> <pre><code>Observablecollection&lt;A&gt; aRef = new Observablecollection&lt;A&gt;(); bRef = aRef(); </code></pre> <p>In this case both point to same <code>ObservableCollection</code>. How do I make a different copy?</p>
4,179,627
2
0
null
2010-11-14 20:46:23.213 UTC
1
2021-02-28 07:12:05.61 UTC
2021-02-28 07:12:05.61 UTC
null
2,164,365
null
298,891
null
1
23
wpf|copy|observablecollection
39,812
<p>Do this:</p> <pre><code>// aRef being an Observablecollection Observablecollection&lt;Entity&gt; bRef = new Observablecollection&lt;Entity&gt;(aRef); </code></pre> <p>This will create an observable collection but the items are still pointing to the original items. If you need the items to point a clone rather th...
9,722,168
How can I get the same undefined ProgressBar as ICS with 2 rotating circles?
<p>I am currently writing an open source project that aims to port the famous Holo theme to previous versions of Android (since 1,6!!!)</p> <p>Everything works fine and I am really proud of my work, but the problem I am facing now is to get the ProgressBar totally looking like the ICS one.</p> <p>I used the same xml ...
9,778,226
3
7
null
2012-03-15 14:47:01.263 UTC
10
2012-03-25 08:09:13.187 UTC
2012-03-25 08:09:13.187 UTC
null
383,793
null
327,402
null
1
26
android|progress-bar|android-4.0-ice-cream-sandwich
9,858
<p>Just found the answer here! </p> <p><a href="https://stackoverflow.com/a/8697806/327402">https://stackoverflow.com/a/8697806/327402</a></p> <p>Very usefull post!</p> <p>There is indeed a platform limitation, although it's not what you might think. The issue is that pre-API11, <code>RotateDrawable</code> had some...
10,237,731
CSS3 transitions inside jQuery .css()
<p>When I add the transition line into my code it breaks jQuery. How can I fix it?</p> <pre><code>a(this).next().css({ left: c, transition: 'opacity 1s ease-in-out' }); </code></pre> <p>I'm trying to set up a fade from one div to the next inside a slider</p>
10,237,742
2
3
null
2012-04-19 22:26:13.567 UTC
13
2019-01-07 13:43:35.353 UTC
null
null
null
null
209,102
null
1
28
jquery|css-transitions
119,492
<p><strong>Step 1)</strong> Remove the semi-colon, it's an object you're creating...</p> <pre><code>a(this).next().css({ left : c, transition : 'opacity 1s ease-in-out'; }); </code></pre> <p>to</p> <pre><code>a(this).next().css({ left : c, transition : 'opacity 1s ease-in-out' }); </code>...
9,723,949
iOS SFHFKeychainUtils failing *sometimes* with error -25308 errSecInteractionNotAllowed
<p>I have this code getting back a password from the keychain for a given username NSString:</p> <pre><code>NSError *error = nil; NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]; NSString *pw = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:appNa...
9,735,506
2
0
null
2012-03-15 16:27:43.39 UTC
20
2021-06-11 07:02:33.803 UTC
null
null
null
null
651,899
null
1
37
ios|keychain|sfhfkeychainutils
12,730
<p>OK so I worked this out finally.</p> <p>Eventually I worked out the users who were having problems had set a lock code on their phone. If the phone was locked the keychain system was returning this -25308 error.</p> <p>If you only ever need to access the keychain when the app is active in the forground you would n...
10,224,856
jQuery UI Slider Labels Under Slider
<p>I am limited to using jQuery 1.4.2 and jQuery ui 1.8.5 (this is not by choice, please do not ask me to upgrade to latest versions). I have created a slider that shows the current value above the slide bar, but what I need now is a way to populate a legend below the slide bar distanced the same as the slider (i.e. if...
10,225,209
5
0
null
2012-04-19 09:03:11.043 UTC
13
2019-09-02 15:15:04.573 UTC
2017-02-08 14:35:25.12 UTC
null
-1
null
351,785
null
1
37
jquery|jquery-ui|jquery-ui-slider
69,569
<p>To create a legend, we need to know the width of the slider and the number of elements then divide one against the other:</p> <pre><code>//store our select options in an array so we can call join(delimiter) on them var options = []; for each(var option in el.options) { options.push(option.label); } //how far apa...
9,757,400
Setting ActionBarSherlock Theme for Android app
<p><strong>READ UPDATE 2 BELOW FOR THE ANSWER</strong></p> <p>I'm trying to use ActionBarSherlock in my app. I checked out the 4.0.0 release from the <a href="https://github.com/JakeWharton/ActionBarSherlock" rel="noreferrer">project github repo</a>, built it in Netbeans, then copied the library-4.0.0.jar file into my...
9,757,822
7
2
null
2012-03-18 09:54:20.27 UTC
7
2017-03-03 19:18:15.697 UTC
2012-03-18 12:00:57.93 UTC
null
211,180
null
211,180
null
1
42
android|actionbarsherlock
51,409
<p>Usually, you set your theme in the manifest, as shown in <a href="http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme" rel="noreferrer">the Android developer documentation</a> (and linked to from <a href="http://actionbarsherlock.com/theming.html" rel="noreferrer">the ActionBarSherlock theming page<...
9,765,007
How do you undo bundle install --without
<p>How do you undo running</p> <pre><code>bundle install --without development </code></pre> <p>Right now, I have gems in the development group that are being ignored because I ran this once... (note that I have tried deleting gemfile.lock to no avail)</p>
9,765,342
4
1
null
2012-03-19 04:23:23.493 UTC
9
2015-06-25 00:38:31.73 UTC
null
null
null
null
743,522
null
1
45
ruby-on-rails|bundler
17,695
<p>The updated, correct answer is @caspyin's, <a href="https://stackoverflow.com/a/15145462/292586">here</a>.</p> <p>My answer is still here for historical purposes:</p> <blockquote> <p>Bundler settings are stored in a file named <code>.bundle/config</code>. You can reset it by removing it, or removing the entire...
10,004,685
Selecting which project under a solution to debug or run in Visual Studio 2010
<p>This one should be easy. I just can't figure out what to search for...</p> <p>For this one solution I created a unit test project, and I've been adding unit tests frantically. When I went back to try to run the original project after making all the unit tests pass I realized that I couldn't figure out how to debug ...
10,004,706
5
0
null
2012-04-04 03:50:26.503 UTC
7
2020-05-06 11:22:22.08 UTC
2015-08-11 12:30:47.71 UTC
null
1,497,596
null
181,310
null
1
46
c#|.net|visual-studio|visual-studio-2010|ide
39,106
<p><a href="http://msdn.microsoft.com/en-us/library/a1awth7y.aspx" rel="noreferrer">You can right click on the project and choose to set as startup project</a></p>
27,988,502
Applying angularjs ng-repeat to owl-carousel
<pre><code>&lt;div class="owl-carousel"&gt; &lt;div ng-repeat="items in itemlist"&gt; &lt;a href="series.html"&gt;&lt;img ng-src="{{items.imageUrl}}" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;a href="series.html"&gt;&lt;img src="http://placehold.it/350x150" /&gt;&lt;/a&gt; &lt;/div&gt...
29,686,215
4
9
null
2015-01-16 16:33:43.603 UTC
8
2018-09-07 13:09:00.613 UTC
2015-01-16 17:49:38.113 UTC
null
1,243,905
null
1,243,905
null
1
14
javascript|angularjs|angularjs-directive|owl-carousel
39,406
<p>Was able to modify a directive from <a href="https://stackoverflow.com/users/635411/dting">DTing</a> on another <a href="https://stackoverflow.com/questions/29157623/owl-carousel-not-identifying-elements-of-ng-repeat/29685686#29685686">post</a> to get it working with multiple carousels on the same page. Here is a wo...
9,652,720
How to run 'sudo' command in windows
<p>How would I run the following command in windows:</p> <pre><code>$ sudo django-admin.py startproject NEW </code></pre> <p>?</p>
9,652,749
17
6
null
2012-03-11 05:30:39.647 UTC
26
2022-03-01 06:00:04.09 UTC
2014-06-23 13:55:53.373 UTC
user3413108
null
null
651,174
null
1
150
windows
589,393
<p>There is no <code>sudo</code> command in Windows. The nearest equivalent is "run as administrator."</p> <p>You can do this using the <a href="http://technet.microsoft.com/en-us/library/cc771525%28v=ws.10%29.aspx"><code>runas</code></a> command with an administrator trust-level, or by right-clicking the program in ...
7,759,837
Put divs below float:left divs
<p>I'm trying to have a site that has the basic structure: </p> <pre><code>&lt;1 div&gt; &lt;3 divs next to each other&gt; &lt;1 div&gt; </code></pre> <p>The 3 divs are float:left in order to make be on the same level. However, they 5th div (at the bottom) sort of moves up to the top of the 3 divs in IE, and sh...
7,760,064
3
0
null
2011-10-13 20:07:58.967 UTC
3
2020-04-15 15:16:06.347 UTC
null
null
null
null
657,676
null
1
23
html|css
44,370
<p>Rather than working with floats, you might consider simply setting the display attribute of the middle divs to "inline-block". Remember that be default, div elements have a block display, which means that they take up the entire width of its parent element, even if its width is less than the parent width. inline b...
7,945,082
Insert multiple inputs on one line in C++
<p>I'm trying to insert multiple inputs on one line, with comma and a space between the inputs. The method I've been using so far separates inputs with spaces.</p> <pre><code>int a, b , c ,d cin &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; d ; </code></pre> <p>With this method , the input line looks like this :</p> <pr...
7,945,121
4
4
null
2011-10-30 13:11:43.807 UTC
1
2021-07-29 16:17:32.66 UTC
null
null
null
null
969,489
null
1
1
c++|input|iostream
58,334
<p>The delimiter character for <code>&gt;&gt;</code> isn't modifiable, but you can use it in combination with <code>ignore</code>:</p> <pre><code>std::cin &gt;&gt; a; std::cin.ignore(1, ',') // rinse and repeat </code></pre>
11,586,923
SELECT DISTINCT with LEFT JOIN, ORDERed BY in t-SQL
<p>I have the following table in SQL Server 2008:</p> <pre><code>CREATE TABLE tbl (ID INT, dtIn DATETIME2, dtOut DATETIME2, Type INT) INSERT tbl VALUES (1, '05:00', '6:00', 1), (2, '05:00', '7:00', 1), (3, '05:01', '8:00', 1), (4, '05:00', '8:00', 1), (5, '05:00', '6:00', 2), (6, '05:00', '7:00', 2) </code></pre> <p...
11,587,144
5
2
null
2012-07-20 21:04:42.14 UTC
3
2020-10-27 16:46:46.13 UTC
2012-07-20 21:06:07.033 UTC
null
13,302
null
670,017
null
1
14
sql|sql-server|tsql|sql-order-by|distinct
112,027
<p>When you narrow it down to individual id's, you create the possibility that each id might have more than one <code>dtOut</code> associated with it. When that happens, how will Sql Server know which order to use?</p> <p>You could try:</p> <pre><code>SELECT t1.id FROM tbl t1 LEFT JOIN tbl t2 on t1.type = t2.type AND ...
11,929,781
Check preconditions in Controller or Service layer
<p>I'm using Google's Preconditions class to validate user's input data.<br> But I'm worried about where is the best point of checking user's input data using Preconditions class.<br> First, I wrote validation check code in Controller like below: </p> <pre><code>@Controller ... public void register(ProductInfo data) ...
12,041,382
4
0
null
2012-08-13 07:22:09.583 UTC
15
2020-05-04 15:07:37.267 UTC
2012-08-16 00:43:04.13 UTC
null
1,454,671
null
889,158
null
1
20
spring|validation|service|controller
14,506
<p>Ideally you would do it in both places. But you are confusing two different things:</p> <ul> <li>Validation (with error handling)</li> <li>Defensivie Programming (aka assertions, aka design by contract).</li> </ul> <p>You absolutely should do <strong>validation</strong> in the controller and <strong>defensive prog...
11,965,087
Open a new tab/window and write something to it?
<p>I'm using <a href="https://addons.mozilla.org/vi/firefox/addon/execute-js/?src=search">Execute JS</a> to write and test Javascript code within Firefox. I want to open a new tab/window and write something to it and I tried</p> <pre><code>var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getServi...
11,967,627
3
1
null
2012-08-15 06:42:23.037 UTC
7
2018-03-01 15:00:21.93 UTC
2012-08-15 10:17:54.853 UTC
null
785,541
null
433,531
null
1
23
javascript|firefox|firefox-addon|xpcom
56,783
<p><strong>Edit</strong>: As of 2018, this solution <a href="https://blog.mozilla.org/security/2017/11/27/blocking-top-level-navigations-data-urls-firefox-58/" rel="noreferrer">no longer works</a>. So you are back to opening <code>about:blank</code> in a new window and adding content to it.</p> <p>Don't "write" to the...
11,618,696
Shell - Write variable contents to a file
<p>I would like to copy the contents of a variable (here called <code>var</code>) into a file.</p> <p>The name of the file is stored in another variable <code>destfile</code>. </p> <p>I'm having problems doing this. Here's what I've tried:</p> <pre><code>cp $var $destfile </code></pre> <p>I've also tried the same t...
11,618,931
7
4
null
2012-07-23 18:56:42.82 UTC
24
2022-05-18 14:23:38.66 UTC
2012-07-23 19:40:35.42 UTC
null
778,118
null
1,546,083
null
1
142
linux|bash|shell
388,587
<p>Use the <code>echo</code> command:</p> <pre><code>var="text to append"; destdir=/some/directory/path/filename if [ -f "$destdir" ] then echo "$var" &gt; "$destdir" fi </code></pre> <p>The <code>if</code> tests that <code>$destdir</code> represents a file.</p> <p>The <code>&gt;</code> appends the text after ...
3,280,576
How does RabbitMQ compare to Mule
<p>How does RabbitMQ compare to Mule, I am going to build an application using message oriented architecture and AMQP (RabbitMQ) provides everything i want, but i am perplexed with so many related technology choice and similar concepts like ESB. I am having a doubt if i am making a choice without considering other alte...
3,346,417
4
0
null
2010-07-19 11:20:36.647 UTC
16
2019-06-05 14:13:00.68 UTC
null
null
null
null
376,188
null
1
49
jms|esb|rabbitmq|mule|eai
19,848
<p>Mule is an ESB (Enterprise Service Bus). RabbitMQ is a message broker.</p> <p>An <b>ESB</b> provides added layers atop of a message broker such as routing, transformations and business process management. It is a mediator between applications, integrating Web Services, REST endpoints, database connections, email an...
4,001,316
How do I preserve transparency in ggplot2?
<p>I love the plots that ggplot generates. However, it is still somewhat cumbersome to get publication quality plots directly. I usually have to do some post processing in Illustrator (i.e. changing fonts, numbering figures etc). While I could save as tiff or png, eps is best for manipulating figures in Illustrator (I ...
4,001,378
6
3
null
2010-10-22 22:05:50.453 UTC
11
2018-11-03 23:32:01.707 UTC
null
null
null
null
313,163
null
1
28
r
19,034
<p>R's eps "device" doesn't support partial transparency, but, if I remember correctly, its PDF device does. Illustrator ought to be able to read PDFs with equal facility to EPSes, or if not, try converting them after generation with <code>pdftops</code> (<em>not</em> <code>pdf2ps</code>, they are totally different pr...
3,612,378
can't multiply sequence by non-int of type 'float'
<p>Why do I get an error of &quot;can't multiply sequence by non-int of type 'float'&quot;? from the following code:</p> <pre><code>def nestEgVariable(salary, save, growthRates): SavingsRecord = [] fund = 0 depositPerYear = salary * save * 0.01 for i in growthRates: fund = fund * (1 + 0.01 * g...
3,612,407
6
4
null
2010-08-31 19:15:48.673 UTC
7
2021-12-07 00:36:13.39 UTC
2021-12-07 00:36:13.39 UTC
null
1,727,948
user425727
null
null
1
57
python|floating-point|sequence
270,549
<pre><code>for i in growthRates: fund = fund * (1 + 0.01 * growthRates) + depositPerYear </code></pre> <p>should be:</p> <pre><code>for i in growthRates: fund = fund * (1 + 0.01 * i) + depositPerYear </code></pre> <p>You are multiplying 0.01 with the growthRates list object. Multiplying a list by an int...
3,797,982
How to query abstract-class-based objects in Django?
<p>Let's say I have an abstract base class that looks like this:</p> <pre><code>class StellarObject(BaseModel): title = models.CharField(max_length=255) description = models.TextField() slug = models.SlugField(blank=True, null=True) class Meta: abstract = True </code></pre> <p>Now, let's say I have two a...
3,798,211
7
0
null
2010-09-26 13:29:36.493 UTC
11
2018-07-18 07:50:18.693 UTC
null
null
null
null
422,073
null
1
63
django|abstract-class
19,849
<p>At its root, this is part of the mismatch between objects and relational databases. The ORM does a great job in abstracting out the differences, but sometimes you just come up against them anyway.</p> <p>Basically, you have to choose between abstract inheritance, in which case there is no database relationship betw...
3,692,738
Floating point versus fixed point: what are the pros/cons?
<p>Floating point type represents a number by storing its significant digits and its exponent separately on separate binary words so it fits in 16, 32, 64 or 128 bits.</p> <p>Fixed point type stores numbers with 2 words, one representing the integer part, another representing the part past the radix, in negative expon...
3,692,789
8
6
null
2010-09-11 21:32:33.453 UTC
9
2016-07-29 11:14:35.267 UTC
2013-01-27 10:43:14.3 UTC
null
1,488,917
null
414,063
null
1
24
c++|c|processor|video-game-consoles
17,730
<p>That definition covers a very limited subset of fixed point implementations.</p> <p>It would be more correct to say that in fixed point only the mantissa is stored and the exponent is a constant determined a-priori. There is no requirement for the binary point to fall inside the mantissa, and definitely no require...
7,965,135
What is the duration of a Toast LENGTH_LONG and LENGTH_SHORT
<p>I need the exact duration of LENGTH_LONG and LENGTH_SHORT in milliseconds (ms). Also I need to know if the duration of Toast message with LENGTH_LONG will have the same duration in any phone and with any API version.</p> <p>Does someone know where is the duration defined ?, I mean defined in ms . I know that LENGTH...
7,965,192
7
1
null
2011-11-01 10:26:24.697 UTC
8
2021-02-02 11:30:22.34 UTC
2016-02-09 13:54:58.097 UTC
null
895,245
null
706,780
null
1
111
android|time|toast|duration|milliseconds
76,763
<p>Answered <a href="https://stackoverflow.com/a/5079536/1993204">here</a>. Like you mentioned <code>Toast.LENGTH_SHORT</code> and <code>Toast.LENGTH_LONG</code> are not in ms but 0 or 1.</p> <p>The actual durations are:</p> <pre><code>private static final int LONG_DELAY = 3500; // 3.5 seconds private static final in...
8,173,622
Add ResourceDictionary to class library
<p>I created a class library which is contained of WPF Windows and some user controls inherited from my c# classes that helps me to customize certain wpf controls.</p> <p>Now I want to add ResourceDictionary, to help me share styles between my wpf classes. Is it possible?</p> <p>Thx.</p> <hr> <p>EDIT: resource dict...
8,173,767
8
0
null
2011-11-17 20:12:05.177 UTC
9
2021-02-12 10:15:44.13 UTC
2011-11-17 22:02:29.15 UTC
null
935,836
null
935,836
null
1
28
c#|wpf|class-library|resourcedictionary
42,343
<p>create a resource dictionary like this one</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;...
8,227,481
Simple HTML Dom: How to remove elements?
<p>I would like to use Simple HTML DOM to remove all images in an article so I can easily create a small snippet of text for a news ticker but I haven't figured out how to remove elements with it. </p> <p>Basically I would do</p> <ol> <li>Get content as HTML string</li> <li>Remove all image tags from content</li> <li...
8,227,616
10
0
null
2011-11-22 13:20:50.993 UTC
6
2022-06-27 03:04:37.793 UTC
2011-11-22 13:24:14.667 UTC
null
218,196
null
221,968
null
1
38
php|dom|simple-html-dom
51,884
<p>There is no dedicated methods for removing elements. You just find all the img elements and then do</p> <pre><code>$e-&gt;outertext = ''; </code></pre>
4,642,665
Why does capturing a mutable struct variable inside a closure within a using statement change its local behavior?
<p><strong>Update</strong>: Well, now I've gone and done it: I <a href="https://connect.microsoft.com/VisualStudio/feedback/details/635745" rel="nofollow noreferrer">filed a bug report with Microsoft</a> about this, as I seriously doubt that it is correct behavior. That said, I'm still not 100% sure what to believe reg...
4,688,670
4
12
null
2011-01-09 23:58:24.4 UTC
10
2011-01-14 06:56:20.143 UTC
2017-05-23 12:24:58.297 UTC
null
-1
null
105,570
null
1
20
.net|struct|closures|mutable|ienumerator
1,152
<p>It's a known bug; we discovered it a couple years ago. The fix would be potentially breaking, and the problem is pretty obscure; these are points against fixing it. Therefore it has never been prioritized high enough to actually fix it.</p> <p>This has been in my queue of potential blog topics for a couple years no...
4,704,969
Functional way of implementing domain driven design
<p>I've had a lot of experience with writing domain driven applications using C#. The more applications I write the more I find that I want to take an approach that doesn't fit that well with standard C#/OO techniques:</p> <ol> <li>I want to write as many pure functions as possible because they are really easy to test...
4,707,493
4
2
null
2011-01-16 11:12:40.093 UTC
13
2018-08-27 01:42:50.073 UTC
null
null
null
null
208,567
null
1
28
.net|f#|domain-driven-design
2,609
<p><em><strong>Disclaimer:</strong> I have only a vague knowledge about domain driven design, so the answer may not use the right terms and may be overly focused on code rather than general concepts, but here are some thoughts anyway...</em></p> <p>The focus on understanding the <em>domain</em> rather than designing s...
4,599,971
Algorithm For Ranking Items
<p>I have a list of 6500 items that I would like to trade or invest in. (Not for real money, but for a certain game.) Each item has 5 numbers that will be used to rank it among the others.</p> <p><strong>Total quantity of item traded per day:</strong> The higher this number, the better.</p> <p><strong>The Donchian ...
4,606,078
5
7
null
2011-01-05 01:02:30.347 UTC
10
2019-01-07 19:11:36.23 UTC
2019-01-07 19:11:36.23 UTC
null
10,849,397
null
559,495
null
1
11
algorithm|statistics|ranking
28,754
<p>The reason people are having trouble answering this question is we have no way of comparing two different "attributes". If there were just two attributes, say quantity traded and median price spread, would (20million,50%) be worse or better than (100,1%)? Only you can decide this.</p> <p>Converting everything into ...
4,586,557
php send email with attachment
<p>How to send the email with resume attachment ,</p> <p>i take snippet from this place <a href="http://www.weberdev.com/get_example-4595.html">Click here</a> </p> <p>In this site, snippet works fine,</p> <p>Even i got the mail, but attachment is not working, am getting attment as noname with 0kb </p> <p>size file...
4,586,659
5
2
null
2011-01-03 17:09:36.673 UTC
11
2013-05-10 23:35:22.177 UTC
2012-07-12 08:26:05.54 UTC
null
367,456
null
246,963
null
1
14
php
31,370
<pre><code> function mail_attachment($to, $subject, $message, $from, $file) { // $file should include path and filename $filename = basename($file); $file_size = filesize($file); $content = chunk_split(base64_encode(file_get_contents($file))); $uid = md5(uniqid(time())); $from = str_replace(array("\r", "\n...
4,354,722
How to fix the height of a <div> element?
<p>I've defined my div's height in a stylesheet:</p> <pre><code>.topbar{ width:100%; height:70px; background-color:#475; } </code></pre> <p>But as soon as text is entered into the div, the divs height changes. </p> <p>Any ideas?</p>
4,354,745
5
1
null
2010-12-04 17:12:59.853 UTC
8
2021-10-19 10:08:51.107 UTC
2017-07-17 14:20:41.35 UTC
null
2,427,065
null
530,588
null
1
39
css|html
204,312
<p>change the div to display block </p> <pre><code>.topbar{ display:block; width:100%; height:70px; background-color:#475; overflow:scroll; } </code></pre> <p>i made a jsfiddle example here please check</p> <p><a href="http://jsfiddle.net/TgPRM/" rel="noreferrer">http://jsfiddle.net/TgPRM/<...
4,709,076
How to enable gzip?
<p>I have found a couple of tutorials on how to enable gzip, but nothing seems to be working for me, so my question is how do i enable gzip. I am on a shared Dreamhost hosting server, It is running PHP version 5.2, and Apache, from the php info i have found this line, maybe this could help?</p> <pre><code>zlib ZLib S...
4,709,107
6
1
null
2011-01-17 00:32:56.7 UTC
13
2020-07-10 07:24:48.78 UTC
2018-04-13 12:00:07.547 UTC
null
3,903,902
null
476,412
null
1
36
php|apache|.htaccess|gzip
85,287
<p>Have you tried with <a href="http://php.net/manual/en/function.ob-gzhandler.php" rel="noreferrer">ob_gzhandler</a>?</p> <pre><code>&lt;?php ob_start(&quot;ob_gzhandler&quot;); ?&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt;This should be a compressed page.&lt;/p&gt; &lt;/html&gt; &lt;body&gt; </code></pre> <p>As a...
4,257,545
How can I check in JavaScript if a DOM element contains a class?
<p>How can I check in JavaScript if a DOM element contains a class?</p> <p>I tried the following code, but for some reason it doesn't work...</p> <pre><code>if (document.getElementById('element').class == "class_one") { //code... } </code></pre>
4,257,563
8
1
null
2010-11-23 15:18:40.713 UTC
7
2022-04-14 11:13:32 UTC
2022-04-11 22:19:28.77 UTC
null
1,946,501
null
496,965
null
1
23
javascript|html|css|dom|htmlelements
56,643
<p>To get the whole value of the class atribute, use <code>.className</code></p> <p><a href="https://developer.mozilla.org/en/DOM/element.classname" rel="noreferrer">From MDC:</a> </p> <blockquote> <p>className gets and sets the value of the class attribute of the specified element.</p> </blockquote> <h1>Since 201...
4,627,940
How to detect if a video file was recorded in portrait orientation, or landscape in iOS
<p>I am using <code>AlAssetsGroup enumerateAssetsAtIndexes</code> to list the assets in the Photos (Camera) app. For a given video asset I want to determine whether it was shot in portrait or landscape mode. </p> <p>In the following code, asset is an <code>AlAsset</code> and I have tested to see if it is a video asset...
4,684,110
8
0
null
2011-01-07 16:46:03.937 UTC
21
2020-07-22 15:51:58.863 UTC
2017-09-15 16:18:57.503 UTC
null
1,000,551
null
567,194
null
1
32
ios|objective-c|video-processing|video-encoding
29,481
<p>Somebody on apple dev forums suggested getting the transform of the video track, this does the job. You can see from the logs below that for these orientations the results make sense and our web developer is now able to rotate a variety of vids so they all match and composite them into one video.</p> <pre><code>AVA...
4,233,605
Elegant way to get the count of months between two dates?
<p>Let's assume I have two dates in variables, like</p> <pre><code>$date1 = &quot;2009-09-01&quot;; $date2 = &quot;2010-05-01&quot;; </code></pre> <p>I need to get the count of months between <code>$date2</code> and <code>$date1</code>(<code>$date2 &gt;= $date1</code>). I.e. i need to get <code>8</code>.</p> <p>Is ther...
4,233,624
10
0
null
2010-11-20 15:59:11.913 UTC
19
2020-07-04 19:18:09.087 UTC
2020-07-04 19:18:09.087 UTC
null
291,772
null
291,772
null
1
64
php|date
87,293
<p>For PHP >= 5.3</p> <pre><code>$d1 = new DateTime("2009-09-01"); $d2 = new DateTime("2010-05-01"); var_dump($d1-&gt;diff($d2)-&gt;m); // int(4) var_dump($d1-&gt;diff($d2)-&gt;m + ($d1-&gt;diff($d2)-&gt;y*12)); // int(8) </code></pre> <p>DateTime::diff returns a <a href="http://ca3.php.net/manual/en/class.dateinter...
4,457,030
How to show the text on a ImageButton?
<p>I have an <code>ImageButton</code> and I want to show a text and an image on it. But when I try on emulator:</p> <pre><code>&lt;ImageButton android:text="OK" android:id="@+id/buttonok" android:src="@drawable/buttonok" android:layout_width="match_parent" android:layout_height="wrap_content" /...
4,457,063
12
0
null
2010-12-16 02:46:03.573 UTC
31
2020-12-06 19:25:37.37 UTC
2018-09-06 10:57:43.777 UTC
null
4,853,133
null
502,214
null
1
138
android|imagebutton
231,584
<p>As you can't use <code>android:text</code> I recommend you to use a normal button and use one of the compound drawables. For instance:</p> <pre><code>&lt;Button android:id="@+id/buttonok" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/butt...
14,864,971
How do I create my own completion handler as part of method parameters
<p>I want to create a completion handler for a certain class, instead of firing off the class's main code and waiting for a delegate callback. I've read through the Apple documentation and they don't seem to give a very good example of how to directly implement something like this. </p>
14,865,037
4
0
null
2013-02-13 23:04:32.203 UTC
18
2016-07-30 09:52:23.363 UTC
null
null
null
null
2,070,259
null
1
26
ios|objective-c
22,566
<p>You need to treat the completion block just like a variable. The method will accept a block as part of it's parameters, then store it for later. </p> <p><code>- (void)myMethodWithCompletionHandler:(void (^)(id, NSError*))handler;</code></p> <p>You can typedef that block type for easier reading: </p> <p><code>type...
14,545,978
How to change the background color for changed files in eclipse project explorer?
<p>Changed files under version control are displayed with a dark brown background in the project explorer, making the file names unreadable. I would like to change it.</p> <p><img src="https://i.stack.imgur.com/vtqdX.png" alt="the brown"></p> <p>I have switched between several color themes, but they don't affect the ...
14,548,965
2
1
null
2013-01-27 09:11:28.583 UTC
10
2014-04-27 04:54:25.257 UTC
2013-01-27 10:58:24.93 UTC
null
216,021
null
216,021
null
1
27
eclipse|colors|egit|color-scheme
17,834
<p>The settings you want are under <em>Preferences</em> > <em>General</em> > <em>Appearance</em> > <em>Colors and Fonts</em>, look for the section "<strong>Git</strong>" in the list and under there, "Uncommitted Change (Background)" and "Uncommitted Change (Foreground)." <img src="https://i.stack.imgur.com/zuND3.png" ...
14,583,018
Knockout 'flickering' issue
<p>I'm building a SPA (Single Page Application) using KO. the application looks like a book and the user can flip pages.</p> <p>The problem is that every time a page loads, there is a short moment where the page 'flickers' and the user sees the unstyled version of the page. I guess this is caused due to the fact that ...
14,588,728
2
1
null
2013-01-29 12:34:10.617 UTC
8
2013-11-01 19:27:36.377 UTC
null
null
null
null
812,303
null
1
32
javascript|knockout.js|singlepage|single-page-application
7,190
<p>Yes, it is very easy actually. Apply <code>display:none</code> to the top level <code>div</code> (or w/e container), and <code>data-bind="visible: true"</code>. This will cause the page to be hidden until knockout unhides it via binding (which obviously can't happen until its fully loaded).</p> <p>Since you are usi...
2,614,242
Show blank UITableViewCells in custom UITableView
<p>I am trying to customize a UITableView. So far, it looks good. But when I use a custom UITableViewCell sub-class, I do not get the blank table cells when there's only 3 cells:</p> <p><a href="http://img193.imageshack.us/img193/2450/picture1zh.png">alt text http://img193.imageshack.us/img193/2450/picture1zh.png</a><...
2,614,312
2
2
null
2010-04-10 17:30:57.843 UTC
10
2010-04-10 18:14:54.103 UTC
null
null
null
null
53,653
null
1
12
iphone|uitableview
11,182
<p>Did you by chance remove the background color and separator style? If you did, that could be why there are no extra cells. I would think the default UITableView doesn't add more cells really, it just has the separator style to create that illusion and because it has a white background, they look like cells.</p> <pr...
41,202,233
How can I use if statement in ejs?
<p>I have a page that makes a foreach and show some photos like this</p> <pre><code>&lt;% imgs.forEach(function(img) { %&gt; &lt;img src="uploads/&lt;%=user.username%&gt;/screenshots/&lt;%= img %&gt;"&gt; &lt;% }); %&gt; </code></pre> <p>And I want make a if statement because, in case that not photos to show g...
41,202,290
4
0
null
2016-12-17 19:24:13.667 UTC
5
2022-07-17 08:39:28.973 UTC
2016-12-17 23:42:56.387 UTC
null
472,495
null
6,053,835
null
1
18
javascript|html|node.js|express|ejs
40,040
<p>Something like this:</p> <pre><code>&lt;% if(imgs.length &gt; 0){ %&gt; &lt;% imgs.forEach(function(img) { %&gt; &lt;img src="uploads/&lt;%=user.username%&gt;/screenshots/&lt;%= img %&gt;"&gt; &lt;% }); %&gt; &lt;% } else{ %&gt; &lt;p&gt;no photos uploaded&lt;/p&gt; &lt;% } %&gt; </code></pre>...
42,436,370
Executing powershell command directly in jenkins pipeline
<p>Is it possible to call a PowerShell command directly in the pipelines groovy script? While using custom jobs in Jenkins I am able to call the command with the PowerShell Plugin. But there is no snippet to use this in the groovy script.</p> <p>I also tried <code>sh()</code> but it seems that this command does not al...
42,576,572
4
0
null
2017-02-24 10:31:58.713 UTC
12
2020-12-10 15:48:49.98 UTC
null
null
null
null
5,422,075
null
1
21
powershell|jenkins|jenkins-plugins|jenkins-pipeline
63,080
<p>To call a PowerShell script from the Groovy-Script:</p> <ul> <li>you have to use the <code>bat</code> command.</li> <li>After that, you have to be sure that the Error Code (<code>errorlevel</code>) variable will be correctly returned (<code>EXIT 1</code> should resulting in a <code>FAILED</code> job).</li> <li>Last,...
27,766,623
How to store routes in separate files when using Hapi?
<p>All of the Hapi examples (and similar in Express) shows routes are defined in the starting file:</p> <pre><code>var Hapi = require('hapi'); var server = new Hapi.Server(); server.connection({ port: 8000 }); server.route({ method: 'GET', path: '/', handler: function (request, reply) { reply('Hello, world...
27,767,658
7
0
null
2015-01-04 14:40:53.24 UTC
22
2019-11-13 21:16:41.213 UTC
2015-01-04 16:28:25.097 UTC
null
775,443
null
597,292
null
1
59
node.js|routes|hapi.js
25,413
<p>You can create a separate file for user routes (<code>config/routes/user.js</code>):</p> <pre><code>module.exports = [ { method: 'GET', path: '/users', handler: function () {} }, { method: 'GET', path: '/users/{id}', handler: function () {} } ]; </code></pre> <p>Similarly with cart. Then create an index fi...
29,059,530
Is there any way to generate the same UUID from a String
<p>I am wondering if there is a way to generate the same UUID based on a <code>String.</code> I tried with UUID, it looks like it does not provide this feature.</p>
29,059,595
4
0
null
2015-03-15 10:19:02.803 UTC
19
2022-01-11 17:26:34.28 UTC
2019-01-30 10:56:33.597 UTC
null
545,127
null
1,136,700
null
1
109
java|uuid
98,580
<p>You can use UUID this way to get always the same UUID for your input String:</p> <pre><code> String aString="JUST_A_TEST_STRING"; String result = UUID.nameUUIDFromBytes(aString.getBytes()).toString(); </code></pre>
29,474,673
Passing a number to a component
<p>I am trying to pass a number to a React component but it is getting parsed as string (<a href="http://jsfiddle.net/utj7qprh/2/" rel="noreferrer">jsfiddle</a>). How do I make React understand that I am passing a number? Should I cast the string to a number in the component?</p> <p><div class="snippet" data-lang="js"...
29,474,674
2
0
null
2015-04-06 15:52:11.427 UTC
6
2020-08-03 13:29:31.047 UTC
2015-04-06 16:43:28.183 UTC
null
64,046
null
126,574
null
1
46
javascript|reactjs
42,101
<p>It seems that in case of integers (and actually for strings as well) I should be passing the numbers via <code>{}</code> like so:</p> <p><code>React.render(&lt;Rectangle intValue={10} stringValue={"Hello"} /&gt;, document.getElementById('container'));</code></p>
31,971,256
How to convert a Swift object to a dictionary
<p>I'm relatively new to iOS programming. However, I would have assumed that Swift would have an automated way of converting objects to JSON and vice versa. That being said, I have found several libraries that can do this.</p> <p>HOWEVER...</p> <p>It seems that no matter how you post data to a web service (even using...
31,976,110
7
0
null
2015-08-12 16:58:03.65 UTC
7
2022-02-21 10:41:03.977 UTC
null
null
null
null
3,965,322
null
1
37
json|swift|dictionary|service|alamofire
35,360
<p>Swift currently does not support advanced reflection like Java or C# so the answer is: no, there is not an equally easy and automated way with pure Swift.</p> <p>[Update] Swift 4 has meanwhile the <code>Codable</code> protocol which allows serializing to/from JSON and PLIST.</p> <pre><code>typealias Codable = Deco...
25,948,511
When to use "if" and "when" in Clojure?
<p>When is one better than the other? Is one faster than the other or does the only difference is the return of false or nil?</p>
25,948,588
3
0
null
2014-09-20 11:56:38.257 UTC
5
2022-05-14 22:53:14.453 UTC
2017-09-07 18:33:17.37 UTC
null
3,924,118
null
1,998,149
null
1
40
if-statement|clojure
11,114
<p>Use <code>if</code> when you have exactly one truthy and one falsy case and you don't need an implicit <code>do</code> block. In contrast, <code>when</code> should be used when you only have to handle the truthy case and the implicit <code>do</code>. There is no difference in speed, it's a matter of using the most i...
22,743,663
In Android/Gradle how to define a task that only runs when building specific buildType/buildVariant/productFlavor (v0.10+)
<p>Android Plugin for Gradle generates for every BuilType/Flavor/BuildVariant a task. The problem is that this task will be generated dynamically and thus won't be available as a dependency when defining a task like this:</p> <pre><code>task myTaskOnlyForDebugBuildType(dependsOn:assembleDebug) { //do smth } </code...
22,743,664
4
0
null
2014-03-30 11:54:07.8 UTC
13
2017-03-13 10:12:30.913 UTC
2017-05-23 12:26:35.83 UTC
null
-1
null
774,398
null
1
30
android|gradle|android-gradle-plugin
23,409
<p><strong>Here is a full example on how to do this <a href="http://www.jayway.com/2013/02/26/using-gradle-for-building-android-applications/" rel="noreferrer">inspired by this post</a>:</strong> <em>(android plugin v.0.9.2 and gradle 1.11 at the time of writing)</em></p> <p>We are going to define a task that only run...
40,529,817
Reactive Forms - mark fields as touched
<p>I am having trouble finding out how to mark all form's fields as touched. The main problem is that if I do not touch fields and try to submit form - validation error in not shown up. I have placeholder for that piece of code in my controller.<br> My idea is simple: </p> <ol> <li>user clicks submit button</li> <li>a...
44,150,793
20
1
null
2016-11-10 14:19:49.383 UTC
15
2022-08-02 12:43:04.967 UTC
2020-05-10 18:41:55.453 UTC
null
5,377,805
null
6,156,929
null
1
126
angular|angular-reactive-forms|angular2-forms|angular2-formbuilder
160,242
<p>The following function recurses through controls in a form group and gently touches them. Because the control's field is an object, the code call <code>Object.values()</code> on the form group's control field.</p> <pre class="lang-js prettyprint-override"><code> /** * Marks all controls in a form group a...
2,752,574
What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)?
<p>What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)?</p>
2,752,581
1
1
null
2010-05-02 05:51:29.427 UTC
7
2011-07-14 01:39:44.523 UTC
null
null
null
null
246,776
null
1
42
c|compiler-flags
8,337
<p>The NS_BLOCK_ASSERTIONS macro (no "D") suppresses the checks performed by NSAssert. You supply it to the compiler using <code>-DNS_BLOCK_ASSERTIONS</code> (see the comments for an explanation of the "D").</p>
37,575,368
Angular dynamic background images
<p>In the html template I have this style with a dynamic image:</p> <pre><code>&lt;div style="background: url('/img/{{item.img}}'); width: 200px; height: 150px"&gt;&lt;/div&gt; </code></pre> <p>Which works in web browsers and android browser. However background images that are dynamic using "style=" are not showing o...
37,575,497
4
0
null
2016-06-01 17:37:46.8 UTC
10
2021-04-20 11:28:26.863 UTC
2018-11-25 15:50:16.89 UTC
null
4,155,124
null
4,155,124
null
1
42
css|ipad|angular|styles
73,819
<p>Use instead</p> <pre><code>&lt;div [ngStyle]="{background: 'url(/img/' + item.img + ')', width: '200px', height: '150px'"&gt;&lt;/div&gt; </code></pre> <p>or</p> <pre><code>&lt;div [style.background]="'url(/img/' + item.img + ')'" [style.width.px]="200" [style.height.px]="150p"&gt;&lt;/div&gt; </code></pre> ...
38,540,481
Return value by lambda in Java
<p>Till now I manage to find all answers I need but this one confusing me. Let's say we have example code:</p> <pre><code>public class Animal { private String species; private boolean canHop; private boolean canSwim; public Animal(String speciesName, boolean hopper, boolean swimmer) { species = specie...
38,540,546
3
2
null
2016-07-23 09:59:56.977 UTC
3
2016-07-23 10:21:00.92 UTC
null
null
null
null
5,950,177
null
1
15
java|lambda|runnable
70,890
<blockquote> <p>Does this mean that, behind the scenes, Java adds keyword return to code in the first case?</p> </blockquote> <p>No, The compiler generates byte code, and it might generate the same byte code but it doesn't change the syntax and then compile it again.</p> <blockquote> <p>we wanted to ignore boolea...
31,617,345
What is the ASP.NET Core MVC equivalent to Request.RequestURI?
<p>I found a <a href="http://www.strathweb.com/2015/01/migrating-asp-net-web-api-mvc-6-exploring-web-api-compatibility-shim/" rel="noreferrer">blog post</a> that shows how to "shim" familiar things like HttpResponseMessage back into ASP.NET Core MVC, but I want to know what's the new native way to do the same thing as ...
31,618,160
3
0
null
2015-07-24 18:26:07.533 UTC
8
2020-09-11 08:18:18.177 UTC
2017-07-06 15:35:21.627 UTC
null
3,792,634
null
84,704
null
1
48
c#|asp.net|asp.net-core-mvc
38,282
<p>A cleaner way would be to use a <code>UriBuilder</code>:</p> <pre><code>private static Uri GetUri(HttpRequest request) { var builder = new UriBuilder(); builder.Scheme = request.Scheme; builder.Host = request.Host.Value; builder.Path = request.Path; builder.Query = request.QueryString.ToUriCompo...
6,014,520
Copying a stream in Python
<p>How do I transfer the contents of a stream to another in Python?</p> <p>The trivial solution would be</p> <pre><code>output.write(input.read()) </code></pre> <p>but that fails if the input file is larger than the available memory (or even infinitely large); and it doesn't work well when a partial copy is useful a...
6,014,540
1
0
null
2011-05-16 07:54:56.207 UTC
2
2011-05-16 08:06:29.01 UTC
null
null
null
null
35,070
null
1
34
python|io
14,240
<p><code>shutil.copyfile</code> and <code>shutil.copyfileobj</code> for the rescue. See <a href="http://docs.python.org/library/shutil.html#module-shutil">http://docs.python.org/library/shutil.html#module-shutil</a></p>
5,616,421
increment map<string, int> using ++ operator
<p>I have a map to count the occurrence of words in a file. I am reading words from the file, and each time I read a word I want to do this:</p> <pre><code>map[word]++; //(where map is the name of my map, I'm not using map as a name of course) </code></pre> <p>so that if the my map already has 'word' as a key, it inc...
5,616,434
1
0
null
2011-04-11 03:11:21.037 UTC
12
2020-02-11 14:17:23.817 UTC
null
null
null
null
666,956
null
1
62
c++|map|operators
26,268
<blockquote> <p>will my program crash because the int in my map is unitialized?</p> </blockquote> <p>No; if the element with key <code>word</code> doesn't exist, the element will be created and value initialized. A value-initialized <code>int</code> has a value of <code>0</code>.</p>
7,259,511
Increase a ProgressBar with Timer in WinForms
<p>I have a timer with an interval of 1 minute and I would like to increase a progress bar in parallel with it. I'm using Winforms and C#. How can I do this ?</p> <p>Help me please</p>
7,259,769
1
0
null
2011-08-31 15:34:12.023 UTC
3
2012-06-27 20:27:21.09 UTC
2011-08-31 16:50:20.183 UTC
null
190,327
null
921,936
null
1
2
c#|winforms|visual-studio-2010
68,265
<p>Here is an example of how to use the <code>Timer</code> control with a progress bar. First, create a new <code>Timer</code> and a <code>ProgressBar</code>. then, start the time when the form is loaded, using this function:</p> <pre><code>timer1.Enabled = true; // Enable the timer. timer1.Start();//Strart it timer1....
21,349,475
Calendar.getInstance(TimeZone.getTimeZone("UTC")) is not returning UTC time
<p>I am really confused with the result I am getting with <code>Calendar.getInstance(TimeZone.getTimeZone("UTC"))</code> method call, it's returning IST time. </p> <p>Here is the code I used </p> <pre><code>Calendar cal_Two = Calendar.getInstance(TimeZone.getTimeZone("UTC")); System.out.println(cal_Two.getTime()); </...
21,349,556
7
0
null
2014-01-25 10:41:23.607 UTC
18
2020-10-10 10:23:58.81 UTC
2017-10-12 19:38:35.583 UTC
null
3,885,376
null
1,228,301
null
1
121
java
204,485
<p>The <code>System.out.println(cal_Two.getTime())</code> invocation returns a <code>Date</code> from <code>getTime()</code>. It is the <code>Date</code> which is getting converted to a string for <code>println</code>, and that conversion will use the default <code>IST</code> timezone in your case.</p> <p>You'll need ...
7,225,045
HTTP PUT Request with Node.js
<p>I'm trying to figure out how to make an HTTP PUT request with node.js. I've tried a lot of different things, but can't get it working.</p> <p>The idea is to have a method for putting the file, eg:</p> <pre><code>function putFile(file_path, callback) { // Put the file } </code></pre> <p>Any help would be appre...
7,225,102
1
0
null
2011-08-29 00:38:55.133 UTC
2
2011-08-29 01:18:14.2 UTC
null
null
null
null
401,019
null
1
14
node.js
62,796
<p>Here is an example which sends a <code>POST</code> request: <a href="http://nodejs.org/docs/v0.4.11/api/http.html#http.request" rel="nofollow noreferrer">http://nodejs.org/docs/v0.4.11/api/http.html#http.request</a> , basically you just have to change it to <code>PUT</code>.</p> <p>You could open your file using <a...
22,791,170
Purpose of EF 6.x DbContext Generator option when adding a new data item in Visual Studio
<p>I have a web app that I built using LINQ to SQL and I'm looking to upgrade it to LINQ to Entity Framework. I've looked at some tutorials and what I've learned is that basically in the database-first scenario, you create an ADO.NET Entity Data Model. And from there, you select which tables to include in the model (ve...
22,957,529
5
0
null
2014-04-01 16:07:47.697 UTC
10
2018-11-02 13:50:32.007 UTC
2018-11-02 13:50:32.007 UTC
null
1,497,596
null
565,968
null
1
65
c#|asp.net|entity-framework|linq|linq-to-sql
46,228
<p>If you already have a database, the first option is better, given that the approach is very similar to the one you are already working in LinqToSQL. The .EDMX file also can provide you a graphical visualization of your database, and you don't have to worry about anything else.</p>
22,025,476
What is "swappable" in model meta for?
<p>Looking tough django auth models code, I came across this bit of code:</p> <pre><code>class User(AbstractUser): class Meta(AbstractUser.Meta): swappable = 'AUTH_USER_MODEL' </code></pre> <p>It's obvious that it has something to do with the new <code>AUTH_USER_MODEL</code> setting in settings.py, but ho...
24,921,458
2
0
null
2014-02-25 20:29:27.53 UTC
8
2014-07-23 21:35:15.027 UTC
2014-02-25 21:03:34.587 UTC
null
236,195
null
236,195
null
1
29
django|django-models|django-users|django-settings
10,527
<p><strong>swappable</strong> is an "intentionally undocumented" feature which is currently under development / in-test. It's used to handle "I have a base abstract model which has some foreign-key relationships." Slightly more detail is available from <a href="https://code.djangoproject.com/ticket/19103">Django's tick...
21,936,503
Get empty string when null
<p>I want to get string values of my fields (they can be type of long string or any object),</p> <p>if a field is null then it should return empty string, I did this with guava;</p> <pre><code>nullToEmpty(String.valueOf(gearBox)) nullToEmpty(String.valueOf(id)) ... </code></pre> <p>But this returns null if gearbox i...
21,936,577
8
0
null
2014-02-21 13:59:17.77 UTC
17
2021-01-29 12:49:27.577 UTC
2019-03-14 07:14:32.403 UTC
null
4,203,152
null
379,028
null
1
104
java|guava
138,301
<p>You can use <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Objects.html#toString%28java.lang.Object,%20java.lang.String%29"><code>Objects.toString()</code></a> (standard in Java 7):</p> <pre><code>Objects.toString(gearBox, "") Objects.toString(id, "") </code></pre> <hr> <p>From the linked documentat...
2,752,319
Android - Simulate Home click
<p>I know calling finish() in activity will produce same result as if user clicked on Back button; is there a similar thing for Home button? (would like to automatically show Home screen after certain action).</p> <p>EDIT: Also, I would appreciate same thing for Menu &amp; Search buttons.</p> <p>Thanks!</p>
2,752,749
4
0
null
2010-05-02 03:13:18.723 UTC
10
2016-06-09 10:17:52.063 UTC
2010-05-05 21:22:41.017 UTC
null
237,858
null
237,858
null
1
28
android
18,303
<p>You can simply use an Intent for that:</p> <pre><code>Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); startActivity(i); </code></pre>
2,792,675
How portable is mktemp(1)?
<p>As the title suggests — can I be reasonably sure that <code>mktemp</code> will exist on any unix-y operating system I'm likely to encounter?</p>
2,792,789
4
1
null
2010-05-08 02:15:45.617 UTC
11
2018-02-06 07:03:05.687 UTC
null
null
null
null
71,522
null
1
32
shell|portability
6,497
<p>POSIX does not seem to specify <em>mktemp(1)</em>.</p> <p>It looks like most modern systems have it, but the available functionality and the semantics of the options vary between implementations (so particular invocations may not be portable):</p> <ul> <li><a href="http://man.openbsd.org/mktemp.1" rel="noreferrer"...
2,819,245
Is std::pair<int, std::string> ordering well-defined?
<p>It seems that I can sort a <code>std::vector&lt;std::pair&lt;int, std::string&gt;&gt;</code>, and it will sort based on the int value. Is this a well defined thing to do?</p> <p>Does <code>std::pair</code> have a default ordering based on its elements?</p>
2,819,287
4
0
null
2010-05-12 13:35:23.247 UTC
5
2019-05-10 23:19:05.113 UTC
2019-05-10 23:19:05.113 UTC
null
1,848,654
null
212,865
null
1
38
c++|sorting|stl
17,502
<p><code>std::pair</code> uses lexicographic comparison: It will compare based on the first element. If the values of the first elements are equal, it will then compare based on the second element.</p> <p>The definition in the C++03 standard (section 20.2.2) is:</p> <pre><code>template &lt;class T1, class T2&gt; bool...
2,483,205
MySQL - how long to create an index?
<p>Can anyone tell me how adding a key scales in MySQL? I have 500,000,000 rows in a database, trans, with columns i (INT UNSIGNED), j (INT UNSIGNED), nu (DOUBLE), A (DOUBLE). I try to index a column, e.g.</p> <pre><code>ALTER TABLE trans ADD KEY idx_A (A); </code></pre> <p>and I wait. For a table of 14,000,000 rows ...
2,486,278
4
1
null
2010-03-20 13:35:56.24 UTC
10
2018-02-20 14:18:14.95 UTC
null
null
null
null
293,594
null
1
46
mysql|indexing
35,359
<p>There are a couple of factors to consider:</p> <ul> <li>Sorting is a N.log(N) operation.</li> <li>The sort for 14M rows might well fit in main memory; the sort with 500M rows probably doesn't, so the sort spills to disk, which slows things up enormously.</li> </ul> <p>Since the factor is about 30 in size, the nomi...
2,539,796
C, reading multiple numbers from single input line (scanf?)
<p>I have written an app in C which expects two lines at input. First input tells how big an array of int will be and the second input contains values separated by space. For example, the following input</p> <pre><code>5 1 2 3 4 99 </code></pre> <p>should create an array containing <code>{1,2,3,4,99}</code></p> <p>...
2,539,843
5
0
null
2010-03-29 17:05:27.527 UTC
7
2017-06-18 09:31:12.693 UTC
2013-04-22 17:22:33.17 UTC
null
2,105,110
null
146,248
null
1
9
c|c99|scanf
68,166
<pre><code>int i, size; int *v; scanf("%d", &amp;size); v = malloc(size * sizeof(int)); for(i=0; i &lt; size; i++) scanf("%d", &amp;v[i]); </code></pre> <p>Remember to <code>free(v)</code> after you are done!</p> <p>Also, if for some reason you already have the numbers in a string, you can use <code>sscanf()</cod...
31,953,317
What is the purpose of a db context class in asp.net mvc
<p>I'm new to MVC and have done some tutorials to get the hang of it, but in some of these tutorials I have come across an example with a DbContext class <a href="https://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application" re...
31,953,580
5
0
null
2015-08-11 22:53:05.3 UTC
7
2019-08-02 14:54:27.663 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
5,162,579
null
1
26
c#|asp.net-mvc|entity-framework
45,512
<p>I would first say that the <code>DbContext</code> class relates to <a href="https://msdn.microsoft.com/en-us/data/ef.aspx" rel="noreferrer">Entity Framework (EF)</a>, but then the question tags would suggest you figured that much out yourself. In typical usage, deriving from the <code>DbContext</code> class is simpl...
56,858,924
Multivariate input LSTM in pytorch
<p>I would like to <strong>implement</strong> LSTM for multivariate input <strong>in Pytorch</strong>. </p> <p>Following this article <a href="https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/" rel="noreferrer">https://machinelearningmastery.com/how-to-develop-lstm-models-for-t...
56,893,248
3
0
null
2019-07-02 19:27:34.773 UTC
9
2022-04-13 02:32:07.597 UTC
2019-07-02 19:49:29.853 UTC
null
5,990,202
null
5,990,202
null
1
14
python|pytorch|lstm
17,652
<p>I hope that problematic parts are commented to make sense:</p> <h2>Data preparation</h2> <pre><code>import random import numpy as np import torch # multivariate data preparation from numpy import array from numpy import hstack # split a multivariate sequence into samples def split_sequences(sequences, n_steps): ...
51,510,655
“Unverified breakpoint” in Visual Studio Code with Chrome Debugger extension
<p>I am trying to debug my Typescript code in Visual Studio Code, using the Chrome Debugger extension, but I am getting the "Unverified breakpoint" message on my breakpoint, and execution does not stop on my breakpoint.</p> <p>Here is my launch.json file:</p> <pre><code>{ linkid=830387 "version": "0.2.0", ...
51,553,490
28
0
null
2018-07-25 04:10:02.57 UTC
14
2022-07-20 06:47:10.563 UTC
2019-05-23 07:24:59.607 UTC
null
5,587,356
null
6,024,969
null
1
85
typescript|debugging|visual-studio-code|vscode-settings
75,257
<p>I finally found out whats wrong:</p> <p>When I read the definition of '${workspaceFolder}', it states the following:</p> <blockquote> <p>the path of the folder opened in VS Code</p> </blockquote> <p><strong>My mistake:</strong> </p> <p>My path in Windows to my project was as follow: <code>C:\Users\myusername\D...
1,184,556
Servlet context scope vs global variable
<p>What (if any) is the difference between storing a variable in the ServletContext and just having it as a public static member of one of the classes?</p> <p>Instead of writing:</p> <pre><code>// simplified (!) int counter = (Integer)getServletContext().getAttribute("counter"); counter++; this.getServletContext().se...
1,184,646
2
0
null
2009-07-26 13:10:58.21 UTC
9
2013-07-03 20:51:26.46 UTC
2009-07-26 22:43:52.37 UTC
null
21,234
null
7,581
null
1
22
java|tomcat|servlets
19,234
<p>The web container knows about your servlet context, but not about your static variables which as <a href="https://stackoverflow.com/a/1184558/53897">skaffman says</a> are private to your classloader. </p> <p>Anything that cause two different requests to be served by an application instance in a different classloa...
559,506
Using LIKE vs. = for exact string match
<p>First off, I recognize the differences between the two:<br> - Like makes available the wildcards % and _<br> - significant trailing whitespace<br> - colation issues</p> <p>All other things being equal, for an exact string match which is more efficient:</p> <pre><code>SELECT field WHERE 'a' = 'a'; </code></pre> <p...
559,512
2
4
null
2009-02-18 01:32:32.33 UTC
6
2017-08-27 22:13:53.067 UTC
2017-08-27 22:04:49.457 UTC
null
13,860
mluebke
4,678
null
1
32
mysql|string|performance
54,208
<p>I would say that the = comparator would be faster. The lexical doesn't send the comparison to another lexical system to do general matches. Instead the engine is able to just match or move on. Our db at work has millions of rows and an = is always faster.</p>
598,113
Can terminals detect <Shift-Enter> or <Control-Enter>?
<p>Is it possible for the terminal to detect <kbd>⇧ Shift</kbd>+<kbd>Enter↵</kbd> or <kbd>Ctrl</kbd>+<kbd>Enter↵</kbd> keypresses?</p> <p>I am trying to configure vim to do key mappings that use these sequences, and while they work fine in gvim, they don't seem to work in any terminal console.</p> <p>The curious thin...
598,404
2
1
null
2009-02-28 14:57:25.107 UTC
19
2020-11-23 17:36:18.787 UTC
2017-08-23 08:39:52.587 UTC
null
72,224
null
72,224
null
1
47
vim|console|terminal
21,902
<p>Some terminals send <code>&lt;NL&gt;</code> when <code>&lt;C-Enter&gt;</code> is pressed. This is equivalent to sending <code>&lt;C-J&gt;</code>. </p> <p>To find out what your terminal does with <code>&lt;Shift-Enter&gt;</code>, <code>&lt;Ctrl-Enter&gt;</code> and <code>&lt;Enter&gt;</code>, go to your terminal, ty...
2,375,118
how to open *.sdf files?
<p>I used to open sdf (sqlCE) files with visual-studio? or sql-server? I really don't remember. Now I can't open this sdf file. With what program do I need to open it?</p>
2,375,148
6
0
null
2010-03-03 21:29:33.13 UTC
25
2022-08-22 21:20:40.61 UTC
2012-01-15 15:03:03.12 UTC
null
110,204
null
43,907
null
1
52
c#|visual-studio-2008|sql-server-ce
112,864
<p>It's a SQL Compact database. You need to define what you mean by "Open". You can open it via code with the SqlCeConnection so you can write your own tool/app to access it. </p> <p>Visual Studio can also <a href="http://arcanecode.com/2007/04/10/creating-a-sql-server-compact-edition-database-using-visual-studio-s...
2,748,825
What is the recommended approach towards multi-tenant databases in MongoDB?
<p>I'm thinking of creating a multi-tenant app using MongoDB. I don't have any guesses in terms of how many tenants I'd have yet, but I would like to be able to scale into the thousands.</p> <p>I can think of three strategies:</p> <ol> <li>All tenants in the same collection, using tenant-specific fields for security<...
23,202,825
6
8
null
2010-05-01 03:55:23.31 UTC
52
2019-01-25 13:03:03.97 UTC
null
null
null
null
228,221
null
1
114
mongodb|multi-tenant
45,974
<p>I have the same problem to solve and also considering variants. As I have years of experience creating SaaS multi-tenant applicatios I also was going to select the second option based on my previous experience with the relational databases.</p> <p>While making my research I found this article on mongodb support si...
2,739,376
Definition of "downstream" and "upstream"
<p>I've started playing with Git and have come across the terms "upstream" and "downstream". I've seen these before but never understood them fully. What do these terms mean in the context of SCMs (<a href="https://en.wikipedia.org/wiki/Software_configuration_management" rel="noreferrer">Software Configuration Manage...
2,739,476
6
3
null
2010-04-29 17:18:21.957 UTC
244
2021-12-03 01:06:27.133 UTC
2019-06-07 14:17:34.223 UTC
null
540,815
null
295,069
null
1
1,021
git|version-control|versioning|terminology|definition
345,978
<p>In terms of source control, you're downstream when you copy (clone, checkout, etc) from a repository. Information flowed &quot;downstream&quot; to you.</p> <p>When you make changes, you usually want to send them back &quot;upstream&quot; so they make it into that repository so that everyone pulling from the same sou...
2,524,928
dos batch iterate through a delimited string
<p>I have a delimited list of IPs I'd like to process individually. The list length is unknown ahead of time. How do I split and process each item in the list?</p> <pre><code>@echo off set servers=127.0.0.1,192.168.0.1,10.100.0.1 FOR /f "tokens=* delims=," %%a IN ("%servers%") DO call :sub %%a :sub echo In sub...
2,525,008
7
1
null
2010-03-26 16:32:16.593 UTC
16
2017-12-28 02:39:38.64 UTC
2010-03-26 17:57:38.55 UTC
null
223,214
null
223,214
null
1
41
command-line|batch-file
92,171
<p><strong>Update</strong>: If the number of items in the list is not known, it is still possible to parse all items with simple recursion on the head of the list. (I've changed the IPs to simple numbers for simplicity of the list)</p> <p><em>Finally that Lisp class I took 18 years ago paid off...</em></p> <pre><code...
3,015,335
jQuery .html() vs .append()
<p>Lets say I have an empty div:</p> <pre><code>&lt;div id='myDiv'&gt;&lt;/div&gt; </code></pre> <p>Is this:</p> <pre><code>$('#myDiv').html("&lt;div id='mySecondDiv'&gt;&lt;/div&gt;"); </code></pre> <p>The same as:</p> <pre><code>var mySecondDiv=$("&lt;div id='mySecondDiv'&gt;&lt;/div&gt;"); $('#myDiv').append(my...
3,015,581
8
2
null
2010-06-10 14:29:04.973 UTC
86
2021-04-08 06:23:13.257 UTC
2021-04-08 06:23:13.257 UTC
null
9,193,372
null
36,525
null
1
267
jquery|html
597,859
<p>Whenever you pass a string of HTML to any of jQuery's methods, this is what happens:</p> <p>A temporary element is created, let's call it x. x's <code>innerHTML</code> is set to the string of HTML that you've passed. Then jQuery will transfer each of the produced nodes (that is, x's <code>childNodes</code>) over to...
2,936,000
How to show SQL queries run in the Rails console?
<p>When I run queries (e.g. <code>MyModel.where(...)</code> or <code>record.associated_things</code>) in the console, how can I see the actual database queries being run so I can gain more understanding of what is happening?</p>
2,936,016
8
2
null
2010-05-29 17:37:01.677 UTC
51
2022-09-23 10:31:46.913 UTC
2014-12-18 06:09:33.143 UTC
null
211,563
null
175,836
null
1
155
ruby-on-rails|activerecord
100,938
<h1>Rails 3+</h1> <p>Enter this line in the console:</p> <pre><code>ActiveRecord::Base.logger = Logger.new(STDOUT) </code></pre> <h1>Rails 2</h1> <p>Enter this line in the console:</p> <pre><code>ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT) </code></pre>
40,677,708
Which exceptions can HttpClient throw?
<p>I am using <a href="https://msdn.microsoft.com/de-de/library/system.net.http.httpclient(v=vs.118).aspx" rel="noreferrer">HttpClient</a> in a xamarin forms project</p> <p>The class is documented, but I can not find any documentation about which exceptions its methods might throw.</p> <p>For example the <a href="htt...
44,387,523
1
9
null
2016-11-18 12:56:23.707 UTC
8
2020-12-06 18:00:52.647 UTC
2016-11-18 13:06:24.87 UTC
null
491,605
null
491,605
null
1
64
c#|httpclient
56,350
<p>As others have commented it depend on what you are calling with HttpClient. I get what you meant though and so here are some exceptions thrown with typical method calls.</p> <p><strong><code>SendAsync</code></strong> can throw:</p> <ul> <li><strong>ArgumentNullException</strong> The request was null.</li> <li><stron...
42,233,542
Appending (pushing) and removing from a JSON array in PostgreSQL 9.5+
<h2><a href="https://stackoverflow.com/q/30707482/124486"><em>For versions less than 9.5 see this question</em></a></h2> <p>I have created a table in PostgreSQL using this:</p> <pre><code>CREATE TEMP TABLE jsontesting AS SELECT id, jsondata::jsonb FROM ( VALUES (1, '["abra","value","mango", "apple", "sample"]')...
42,233,548
3
0
null
2017-02-14 18:23:25.483 UTC
22
2022-06-15 15:41:38.757 UTC
2017-05-23 11:54:37.177 UTC
null
-1
null
124,486
null
1
67
arrays|postgresql|jsonb|postgresql-9.5|array-push
53,134
<p>To add the value use the JSON array append opperator (<code>||</code>)</p> <pre><code>UPDATE jsontesting SET jsondata = jsondata || '[&quot;newString&quot;]'::jsonb WHERE id = 7; </code></pre> <p>Removing the value looks like this</p> <pre><code>UPDATE jsontesting SET jsondata = jsondata - 'newString' WHERE id = 7; ...
40,302,026
What does the tt metavariable type mean in Rust macros?
<p>I'm reading a book about Rust, and start playing with <a href="https://doc.rust-lang.org/book/macros.html" rel="noreferrer">Rust macros</a>. All metavariable types are explained there and have examples, except the last one – <code>tt</code>. According to the book, it is a “a single token tree”. I'm curious, what is ...
40,303,308
1
0
null
2016-10-28 09:24:51.75 UTC
4
2019-08-13 17:24:44.88 UTC
2016-10-28 10:12:22.773 UTC
null
2,037,422
null
2,037,422
null
1
33
macros|rust|metaprogramming|rust-macros
8,401
<p>That's a notion introduced to ensure that whatever is in a macro invocation correctly matches <code>()</code>, <code>[]</code> and <code>{}</code> pairs. <code>tt</code> will match any single token <strong>or</strong> any pair of parenthesis/brackets/braces <em>with their content</em>.</p> <p>For example, for the f...
10,296,711
How to take a screenshot and share it programmatically
<p>I am making an application in Android in which I have to take screenshot of one of my activities and mail it as attachment. </p> <p>I want to take screenshot of the current page and then share it via email, Bluetooth, Twitter or Facebook.</p> <p>My code is as follows:</p> <pre><code>@Override public boolean onCre...
10,296,881
5
0
null
2012-04-24 11:08:50.387 UTC
32
2019-04-10 03:46:10.05 UTC
2017-04-04 09:58:53.467 UTC
null
1,788,806
user1025050
null
null
1
28
android|screenshot
35,951
<p>Try this for taking screenshot of current Activity:</p> <p>Android 2.2 :</p> <pre><code>private static Bitmap takeScreenShot(Activity activity) { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b1 = view.getDrawingCache(); Rec...
10,680,601
Nodejs Event Loop
<p>Are there internally two event loops in nodejs architecture?</p> <ul> <li>libev/libuv </li> <li>v8 javascript event loop</li> </ul> <p>On an I/O request does node queue the request to libeio which in turn notifies the availability of data via events using libev and finally those events are handled by v8 event loop...
11,082,422
8
0
null
2012-05-21 06:46:32.783 UTC
134
2021-06-23 08:48:45.167 UTC
null
null
null
null
973,308
null
1
145
javascript|node.js|event-loop|libev
30,154
<p>I have been personally reading the source code of node.js &amp; v8.</p> <p>I went into a similar problem like you when I tried to understand node.js architecture in order to write native modules.</p> <p>What I am posting here is my understanding of node.js and this might be a bit off track as well.</p> <ol> <li><...
6,195,781
IronPython: EXE compiled using pyc.py cannot import module "os"
<p>I have a simple IronPython script:</p> <pre><code># Foo.py import os def main(): print( "Hello" ) if "__main__" == __name__: main() </code></pre> <p>It runs fine and prints <em>Hello</em> if I run it with IronPython as:</p> <pre><code>ipy Foo.py </code></pre> <p>Following the instructions given in <em>...
6,205,193
2
0
null
2011-06-01 02:57:08.793 UTC
26
2018-04-24 05:11:10.983 UTC
2017-05-23 12:25:45.573 UTC
null
-1
null
1,630
null
1
23
python|ironpython
15,835
<p>Building an Ironpython EXE that you can distribute is a bit tricky - especially if you are using elements of the standard library. My typical solution is the following:</p> <p>I copy all of the stdlib modules I need into a folder (usually all of them just for completeness) and use this script to build my exe. In t...
5,775,580
Git pulling changes between two local repositories
<p>I have two clones of same remote repository. I have made some changes to one local repository, how can I pull these changes to the other local repository without pushing it to the remote?</p>
5,775,607
2
1
null
2011-04-25 05:44:35.177 UTC
14
2020-05-05 00:04:45.843 UTC
2019-04-06 15:34:15.777 UTC
null
2,624,876
null
7,965
null
1
76
git|git-pull
30,239
<p>You can treat the second clone the same way you treat a remote respository on another system. You can perform all of the same operations, e.g.</p> <pre><code>~/repo1 $ git remote add repo2 ~/repo2 ~/repo1 $ git fetch repo2 ~/repo1 $ git merge repo2/foo </code></pre>
32,581,404
jQuery validation with input mask
<p>Have this problem that form inputs with assigned mask (as a placeholder) are not validated as empty by jQuery validation.</p> <p>I use:</p> <ul> <li><a href="https://github.com/RobinHerbots/jquery.inputmask" rel="noreferrer">https://github.com/RobinHerbots/jquery.inputmask</a></li> <li><a href="https://github.com/...
32,608,949
4
0
null
2015-09-15 08:35:19.723 UTC
1
2018-10-18 09:24:11.95 UTC
2015-09-15 09:44:52.833 UTC
null
4,689,671
null
4,689,671
null
1
13
javascript|jquery|twitter-bootstrap|validation|masking
45,800
<p>It's not exactly the solution, but...</p> <p><strong>changing inputmask for some equivalent solves the problem</strong>.</p> <p>Still far from perfect, though : (</p> <p>EXPLANATION:</p> <p>Other masking libraries, don't have these two strange behaviors mentioned, so it's possible to validate fields.</p> <p>I u...
21,155,574
MVC - calling controller from view
<p>I am new to MVC</p> <p>I am developing a web application using MVC and the application contains only one page.</p> <p>So in that view I have to populate multiple data. Say if the application is a "News feed" application, i need to populate recent news, news liked by you, news recommended by your friends etc. So sh...
21,155,839
2
1
null
2014-01-16 07:17:43.96 UTC
1
2015-02-18 10:12:47.56 UTC
2015-02-18 10:12:47.56 UTC
null
848,841
null
848,841
null
1
8
c#|asp.net|asp.net-mvc|asp.net-mvc-3|asp.net-mvc-4
38,701
<p>Yes you can use ajax call like this</p> <pre><code>$(document).ready(function () { $('#CategoryId').change(function () { $.getJSON('/Publication/AjaxAction/' + this.value, {}, function (html) { $("#partial").html(html); alert...
21,269,836
How to define page breaks when printing html?
<p>I have a application made with Delphi 2006 which prints with QuickReport. Due to many bugs, I will rebuild this section of the software , generating the report in HTML and then send it to printer through some component. My question is, How/Can I tell when printer should break into a new page with HTML? Some tag o...
21,270,036
1
1
null
2014-01-21 21:52:07.88 UTC
7
2014-01-22 07:59:10.503 UTC
2014-01-22 07:59:10.503 UTC
null
512,728
null
1,062,933
null
1
16
html|printing|report
39,045
<p>You can add page breaks for printing with a little bit of CSS.</p> <p>CSS:</p> <pre class="lang-css prettyprint-override"><code>@media all { .page-break { display: none; } } @media print { .page-break { display: block; page-break-before: always; } } </code></pre> <p>HTML: Use a div element with the page-break cl...
35,753,399
Auto generate build pipeline for gradle build using Jenkinsfile
<p><br/> I am trying to create a build pipeline based upon the Gradle tasks. I have viewed JenkinsFile configuration <a href="https://github.com/kishorebhatia/pipeline-as-code-demo">Pipeline-as-code-demo</a> but I am unable to create a pipeline for gradle tasks. Please suggest me a possible way so that I can use the Je...
41,776,048
3
0
null
2016-03-02 16:52:29.11 UTC
1
2018-12-13 16:57:42.37 UTC
null
null
null
null
5,488,774
null
1
11
jenkins|gradle|continuous-integration
41,363
<p>In case you're using Artifactory to resolve your build dependencies or to deploy your build artifacts, it is recommended to use the Pipeline DSL for <a href="https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins" rel="nofollow noreferrer">Gradle build with Artifactory</a>.</p> <p>Here's...
43,038,060
Deploy Angular 2 to Apache Server
<p>I want to deploy an Angular 2 application on an Apache server. I've read various guides like <a href="https://github.com/mgechev/angular-seed/wiki/Deploying-prod-build-to-Apache-2" rel="nofollow noreferrer">this</a> and <a href="https://github.com/angular/angular/issues/11884" rel="nofollow noreferrer">this</a> but ...
43,038,161
9
0
null
2017-03-27 04:39:36.95 UTC
21
2021-10-05 10:02:05.117 UTC
2021-10-05 10:02:05.117 UTC
null
13,618,646
null
3,134,082
null
1
26
apache|.htaccess|angular|digital-ocean
78,578
<p>It appears i was missing this in my <code>/etc/apache2/sites-enabled/000-default.conf</code> file. After adding this and restarting <code>apache</code>, website runs fine.</p> <pre><code>&lt;Directory "/var/www/html/dist"&gt; AllowOverride All &lt;/Directory&gt; </code></pre>
8,500,445
Automatically dial a phone number
<p>I have a web page where I have a button. I need to automatically dial a phone number on the click of the button. It needs to be done in HTML.</p> <p>I need to do it on the onclick event of the button.</p>
8,505,221
4
0
null
2011-12-14 06:43:11.98 UTC
0
2020-07-31 05:20:56.557 UTC
2020-07-31 05:20:56.557 UTC
null
1,879,699
null
435,813
null
1
9
html|anchor
50,886
<p>On mobile devices, there are protocol handlers to launch the phone. Depending on the security, some will dial it, or others will bring on the phone application with the number already there.</p> <pre><code>&lt;a href="tel:+15555555555"&gt;Call me at +1 (555) 555-5555&lt;/a&gt; </code></pre>
9,004,095
Jquery count characters
<p>I'm having problems to figure out why jquery string counter won't show me the expected result.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;sc...
9,004,126
4
0
null
2012-01-25 14:13:34.04 UTC
1
2019-08-03 16:49:43.647 UTC
2012-01-25 14:23:05.833 UTC
null
338,208
null
962,469
null
1
10
jquery
47,829
<p>$("h1") returns a jQuery object (in which the length property is the number of elements returned), and since you are calling it before the page is completely loaded it is actually retuning 0 elements.</p> <p>What you want is:</p> <pre><code>$(document).ready(function() { var count = $("h1").text().length; ...
8,368,157
Existing ivar 'title' for unsafe_unretained property 'title' must be __unsafe_unretained
<p>I'm just getting to grips with Objective-C 2.0</p> <p>When I try to build the following in Xcode it fails. The error from the compiler is as follows:</p> <p><strong>Existing ivar 'title' for unsafe_unretained property 'title' must be __unsafe_unretained.</strong></p> <pre><code>// main.m #import &lt;Foundation/Fo...
8,368,240
1
0
null
2011-12-03 13:59:48.26 UTC
7
2014-05-09 07:41:03.793 UTC
2014-05-09 07:41:03.793 UTC
null
3,532,040
null
443,297
null
1
32
objective-c
14,518
<p>I assume you are using ARC.</p> <p>Under ARC, the ownership qualification of the property must match the instance variable (ivar). So, for example, if you say that the property is "strong", then the ivar has to be strong as well.</p> <p>In your case you are saying that the property is "assign", which is the same a...
8,827,891
Swapping rootViewController with animation
<p>I'm having a little trouble swapping rootViewControllers with animation. Here's the code that I'm using:</p> <pre><code>[UIView transitionWithView:self.window duration:0.8 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ self.window.rootViewController = self.navigationController; } com...
8,828,020
7
0
null
2012-01-11 22:50:14.203 UTC
16
2020-09-17 11:29:15.597 UTC
null
null
null
null
639,668
null
1
37
objective-c|ios|cocoa-touch|uiviewcontroller
21,238
<p><code>transitionWithView</code> is intended to animate subviews of the specified container view. It is not so simple to animate changing the root view controller. I've spent a long time trying to do it w/o side effects. See:</p> <p><a href="https://stackoverflow.com/questions/8146253/animate-change-of-view-controll...
8,923,485
TFS: submit changes done locally in one branch to another branch
<p>I made changes to a lot of files, and in the meantime I figured I rather commit this untested code to a yet-to-be-created branch, so that users of the existing code base are not affected.</p> <p>As I touched really many, many files and created and added new sub-projects etc., I want to avoid copying files and folde...
8,925,277
1
0
null
2012-01-19 09:11:45.42 UTC
19
2013-05-23 16:40:04.123 UTC
2013-05-23 16:40:04.123 UTC
null
8,363
null
709,537
null
1
74
visual-studio-2010|tfs|branch|tfs-power-tools
21,289
<p>This functionality is provided using <code>tfpt unshelve /migrate</code>. To use it, follow these steps:</p> <ol> <li>Create a shelveset of your changes (from the UI, or <code>tf shelve . /R</code>)</li> <li>Create the new branch</li> <li>Download and install the <a href="http://visualstudiogallery.msdn.microsoft.c...
61,014,661
Animated: `useNativeDriver` was not specified issue of ReactNativeBase Input
<p>I created a new react-native project today (April 3rd, 2020) and added a native-base. Then I tried to add input with the floating label. It gives a warning message: Animated: <code>useNativeDriver</code> was not specified. This is a required option and must be explicitly set to <code>true</code> or <code>false</code...
61,117,885
12
0
null
2020-04-03 14:57:30.45 UTC
12
2022-09-12 07:14:14.35 UTC
2020-12-27 13:45:49.14 UTC
null
8,798,220
null
466,749
null
1
65
javascript|reactjs|react-native|native-base
96,991
<p>Just add <code>useNativeDriver: true</code> to the animation config.</p> <pre><code>const [animatePress, setAnimatePress] = useState(new Animated.Value(1)) const animateIn = () =&gt; { Animated.timing(animatePress, { toValue: 0.5, duration: 500, useNativeDriver: true // Add This line }).start(); } <...
26,643,587
Comparing BCrypt hash between PHP and NodeJS
<p>For an app I'm working on, nodejs needs to verify hashes created by PHP and vice-versa.</p> <p>The problem is, the hashes generated in PHP (via Laravel's <code>Hash</code> class, which just uses PHP's <code>password_hash</code> function) return false when tested in node.js.</p> <p>The following node.js script:</p>...
26,643,637
3
0
null
2014-10-30 01:32:23.137 UTC
21
2019-07-29 03:30:33.723 UTC
2016-07-21 16:52:53.993 UTC
null
3,134,069
null
2,555,969
null
1
43
php|node.js|bcrypt
15,071
<p>This fails because the types of bcrypt hashes being generated from php and node are different. Laravel generates the <code>$2y$</code> while node generates the <code>$2a$</code>. But the good news is the only difference between <code>2a</code> and <code>2y</code> are their prefixes. </p> <p>So what you can do is ma...