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
804,961
How do I use CSS with a ruby on rails application?
<p>How do I use CSS with RoR? When I link externally, I'm never able to see the files. I cp'd the .css file to every folder I could think of...views, controller, template, and nothing seems to work.</p> <p>What do I need to do to enable external CSS files with a rails application? I'm new to rails, so forgive me if th...
804,972
8
0
null
2009-04-30 00:57:16.35 UTC
14
2019-11-26 09:59:29.423 UTC
2015-11-13 20:37:20.817 UTC
null
1,223,693
null
78,182
null
1
67
ruby-on-rails|css|ruby
115,942
<p>Put the CSS files in public/stylesheets and then use:</p> <pre><code>&lt;%= stylesheet_link_tag "filename" %&gt; </code></pre> <p>to link to the stylesheet in your layouts or erb files in your views.</p> <p>Similarly you put images in public/images and javascript files in public/javascripts. </p>
4,545
What was the <XMP> tag used for?
<p>Does anyone remember the <code>XMP</code> tag?</p> <p>What was it used for and why was it deprecated?</p>
4,549
8
1
null
2008-08-07 09:21:41.563 UTC
13
2018-12-17 15:49:59.753 UTC
2017-05-26 09:38:53.863 UTC
null
1,402,846
null
383
null
1
79
html|tags
52,678
<p>A quick Google search on W3C reveals that <code>XMP</code> was introduced for displaying <strong>preformatted text</strong> in HTML 3.2 and earlier. When W3C deprecated the <code>XMP</code> tag, it suggested using the <code>PRE</code> tag as a preferred alternative.</p> <p>Update: <a href="http://www.w3.org/TR/REC-...
54,867
What is the difference between old style and new style classes in Python?
<p>What is the difference between old style and new style classes in Python? When should I use one or the other?</p>
54,873
8
0
null
2008-09-10 18:01:27.163 UTC
304
2020-02-02 11:31:19.547 UTC
2018-10-29 14:02:48.583 UTC
J.F. Sebastian
10,388,629
Tim
4,883
null
1
1,108
python|class|oop|types|new-style-class
261,220
<p>From <em><a href="http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes" rel="noreferrer">New-style and classic classes</a></em>:</p> <blockquote> <p><strong>Up to Python 2.1, old-style classes were the only flavour available to the user.</strong></p> <p>The concept of (old-style) c...
280,566
Run once a day in C#
<p>Is there any clever method out there to make my executeEveryDayMethod() execute once a day, without having to involve the Windows TaskScheduler?</p>
280,772
9
1
null
2008-11-11 10:44:54.397 UTC
6
2020-11-19 12:42:20.087 UTC
2019-12-10 15:08:43.13 UTC
Robert Gould
1,033,581
Anders R
36,504
null
1
18
c#|scheduling
42,218
<p>Take a look at <a href="http://quartznet.sourceforge.net/" rel="noreferrer">quartz.net</a>. It is a scheduling library for .net.</p> <p>More specifically take a look <a href="http://quartznet.sourceforge.net/tutorial/lesson_4.html" rel="noreferrer">here</a>.</p>
1,036,347
How do I use boolean variables in Perl?
<p>I have tried:</p> <pre><code>$var = false; $var = FALSE; $var = False; </code></pre> <p>None of these work. I get the error message</p> <pre>Bareword "false" not allowed while "strict subs" is in use.</pre>
1,036,353
9
1
null
2009-06-24 04:08:11.387 UTC
32
2022-06-15 13:51:10.023 UTC
2009-06-24 21:17:16.01 UTC
null
48,771
null
48,771
null
1
236
perl|boolean
264,489
<p>In Perl, the following evaluate to false in conditionals:</p> <pre><code>0 '0' undef '' # Empty scalar () # Empty list ('') </code></pre> <p>The rest are true. There are no barewords for <code>true</code> or <code>false</code>.</p>
134,158
How would you sort 1 million 32-bit integers in 2MB of RAM?
<p>Please, provide code examples in a language of your choice.</p> <p><strong>Update</strong>: No constraints set on external storage.</p> <p>Example: Integers are received/sent via network. There is a sufficient space on local disk for intermediate results.</p>
228,866
10
0
null
2008-09-25 15:53:47.07 UTC
19
2013-01-16 05:43:37.217 UTC
2008-09-25 19:04:58.39 UTC
J.F. Sebastian
4,279
J.F. Sebastian
4,279
null
1
14
algorithm|language-agnostic|google-moderator
32,027
<p><a href="http://neopythonic.blogspot.com/2008/10/sorting-million-32-bit-integers-in-2mb.html" rel="noreferrer">Sorting a million 32-bit integers in 2MB of RAM using Python by Guido van Rossum</a></p>
627,916
Check if URL scheme is supported in javascript
<p>Is there any way to check if a URL scheme is currently registered on the phone... with javascript?</p>
627,942
10
1
null
2009-03-09 20:34:17.25 UTC
48
2019-12-31 17:24:33.443 UTC
2013-08-11 01:37:07.343 UTC
null
1,371,070
jackb
null
null
1
65
javascript|iphone|safari|url-scheme
80,060
<p>No, not from a webpage.</p>
237,432
python properties and inheritance
<p>I have a base class with a property which (the get method) I want to overwrite in the subclass. My first thought was something like:</p> <pre><code>class Foo(object): def _get_age(self): return 11 age = property(_get_age) class Bar(Foo): def _get_age(self): return 44 </code></pre> <p...
237,858
11
0
null
2008-10-26 02:49:09.75 UTC
19
2021-05-16 16:29:46.597 UTC
2008-10-26 03:16:07.667 UTC
Peter Hoffmann
720
Peter Hoffmann
720
null
1
62
python|inheritance|properties|polymorphism
48,781
<p>I simply prefer to repeat the <code>property()</code> as well as you will repeat the <code>@classmethod</code> decorator when overriding a class method. </p> <p>While this seems very verbose, at least for Python standards, you may notice:</p> <p>1) for read only properties, <code>property</code> can be used as a d...
1,195,206
Is there a Java equivalent or methodology for the typedef keyword in C++?
<p>Coming from a C and C++ background, I found judicious use of <strong><code>typedef</code></strong> to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java mechanism, pattern, or some other effective way you have used?</p>
1,195,221
12
5
null
2009-07-28 16:23:22.423 UTC
16
2020-05-08 15:10:06.9 UTC
2012-11-09 02:40:54.897 UTC
null
139,010
null
89,339
null
1
277
java|c++|c|design-patterns|typedef
132,945
<p>Java has primitive types, objects and arrays and that's it. No typedefs.</p>
1,100,311
What is the ideal growth rate for a dynamically allocated array?
<p>C++ has std::vector and Java has ArrayList, and many other languages have their own form of dynamically allocated array. When a dynamic array runs out of space, it gets reallocated into a larger area and the old values are copied into the new array. A question central to the performance of such an array is how fast ...
1,100,359
12
0
null
2009-07-08 20:15:48.523 UTC
60
2021-11-22 13:56:33.057 UTC
null
null
null
null
50,385
null
1
101
arrays|math|vector|arraylist|dynamic-arrays
25,348
<p>It will entirely depend on the use case. Do you care more about the time wasted copying data around (and reallocating arrays) or the extra memory? How long is the array going to last? If it's not going to be around for long, using a bigger buffer may well be a good idea - the penalty is short-lived. If it's going to...
907,680
CSS Printing: Avoiding cut-in-half DIVs between pages?
<p>I'm writing a plug-in for a piece of software that takes a big collection of items and pops them into HTML in a WebView in Cocoa (which uses WebKit as its renderer, so basically you can assume this HTML file is being opened in Safari).</p> <p>The DIVs it makes are of dynamic height, but they don't vary too much. Th...
907,719
12
3
null
2009-05-25 18:40:43.287 UTC
54
2022-07-03 20:24:35.543 UTC
2009-05-25 18:45:12.437 UTC
null
27,637
null
112,224
null
1
252
css|cocoa|printing|page-break
174,250
<p>Using <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/break-inside" rel="noreferrer">break-inside</a> should work:</p> <pre class="lang-css prettyprint-override"><code>@media print { div { break-inside: avoid; } } </code></pre> <p>It works on <a href="https://developer.mozilla.org/en-US/docs/Web/CS...
137,006
Redefine Class Methods or Class
<p>Is there any way to redefine a class or some of its methods without using typical inheritance? For example:</p> <pre><code>class third_party_library { function buggy_function() { return 'bad result'; } function other_functions(){ return 'blah'; } } </code></pre> <p>What can I do to re...
137,028
13
2
null
2008-09-26 00:00:45.06 UTC
15
2020-04-26 19:44:19.103 UTC
2020-06-20 09:12:55.06 UTC
SeanDowney
-1
SeanDowney
5,261
null
1
54
php|class|methods|redefine
77,528
<p>It's called <a href="http://en.wikipedia.org/wiki/Monkey_patch" rel="noreferrer">monkey patching</a>. But, PHP doesn't have native support for it.</p> <p>Though, as others have also pointed out, the <a href="http://docs.php.net/runkit" rel="noreferrer">runkit library</a> is available for adding support to the langu...
25,765
Java configuration framework
<p>I'm in the process of weeding out all hardcoded values in a Java library and was wondering what framework would be the best (in terms of zero- or close-to-zero configuration) to handle run-time configuration? I would prefer XML-based configuration files, but it's not essential. </p> <p>Please do only reply if you h...
25,768
14
1
2009-06-29 06:54:39.35 UTC
2008-08-25 08:17:54.297 UTC
28
2015-05-06 18:00:22.02 UTC
2010-12-21 10:26:03.277 UTC
Keith
63,550
Steen
1,448,983
null
1
76
java|xml|configuration|frameworks|configurationmanager
30,542
<p>If your hardcoded values are just simple key-value pairs, you should look at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html" rel="noreferrer">java.util.Properties</a>. It's a lot simpler than xml, easier to use, and mind-numbingly trivial to implement.</p> <p>If you are working with Jav...
476,163
NAnt or MSBuild, which one to choose and when?
<p>I am aware there are other <a href="http://en.wikipedia.org/wiki/NAnt" rel="noreferrer">NAnt</a> and <a href="http://en.wikipedia.org/wiki/MSBuild" rel="noreferrer">MSBuild</a> related questions on Stack&nbsp;Overflow, but I could not find a direct comparison between the two and so here is the question.</p> <p>When...
483,505
14
0
null
2009-01-24 15:39:24.337 UTC
91
2017-10-18 16:39:52.917 UTC
2013-08-30 08:38:09.17 UTC
Fabian Steeg
63,550
Yordan Pavlov
54,968
null
1
162
.net|msbuild|automation|nant
32,088
<p>I've done a similar investigation this week. Here's what I've been able to determine:</p> <p><strong>NAnt:</strong></p> <ul> <li>Cross-platform (supports Linux/Mono). It may be handy for installing a web site to multiple targets (that is, Linux Apache and Windows IIS), for example.</li> <li>95% similar in syntax ...
383,692
What is JSON and what is it used for?
<p>I've looked on Wikipedia and Googled it and read the official documentation, but I still haven't got to the point where I really understand what JSON is, and why I'd use it.</p> <p>I have been building applications using PHP, MySQL and JavaScript / HTML for a while, and if JSON can do something to make my life easie...
383,699
16
4
null
2008-12-20 20:19:11.093 UTC
361
2021-06-18 20:36:48.107 UTC
2021-06-18 20:36:48.107 UTC
Dreas Grech
2,756,409
Ben
11,522
null
1
562
json
579,618
<p><strong>JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging.</strong> It is based on a subset of JavaScript language (the way objects are built in JavaScript). As <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON" rel="noreferrer...
706,382
Multiline strings in VB.NET
<p>Is there a way to have multiline strings in VB.NET like Python</p> <pre><code>a = """ multi line string """ </code></pre> <p>or PHP?</p> <pre><code>$a = &lt;&lt;&lt;END multi line string END; </code></pre> <p>Of course something that is not</p> <pre><code>"multi" &amp; _ "line </code></pre>
1,674,434
21
3
null
2009-04-01 16:36:48.567 UTC
25
2019-08-02 15:34:00.087 UTC
2019-08-02 15:34:00.087 UTC
null
3,170,982
pistacchio
42,636
null
1
154
string|vb.net
156,767
<p>You can use <strong><a href="https://msdn.microsoft.com/en-us/library/bb384629.aspx" rel="noreferrer">XML Literals</a></strong> to achieve a similar effect:</p> <pre><code>Imports System.XML Imports System.XML.Linq Imports System.Core Dim s As String = &lt;a&gt;Hello World&lt;/a&gt;.Value </code></pre> <p>Remember ...
1,085,162
Commit only part of a file in Git
<p>When I make changes to a file in Git, how can I commit only some of the changes?</p> <p>For example, how could I commit only 15 lines out of 30 lines that have been changed in a file?</p>
1,085,191
28
2
null
2009-07-06 02:25:02.39 UTC
1,134
2022-09-06 02:47:21.023 UTC
2017-03-07 18:03:41.677 UTC
null
-1
null
76,509
null
1
3,336
git|git-commit
540,073
<p>You can use:</p> <pre class="lang-bash prettyprint-override"><code>git add --patch &lt;filename&gt; </code></pre> <p>or for short:</p> <pre class="lang-bash prettyprint-override"><code>git add -p &lt;filename&gt; </code></pre> <p>Git will break down your file into what it thinks are sensible &quot;hunks&quot; (porti...
1,175,208
Elegant Python function to convert CamelCase to snake_case?
<p>Example:</p> <pre><code>&gt;&gt;&gt; convert('CamelCase') 'camel_case' </code></pre>
1,176,023
30
4
2009-07-24 00:22:02.287 UTC
2009-07-24 00:22:02.287 UTC
158
2022-03-09 19:33:48.003 UTC
2016-02-23 13:22:54.103 UTC
null
1,079,110
null
55,246
null
1
332
python|camelcasing
289,924
<h2>Camel case to snake case</h2> <pre class="lang-py prettyprint-override"><code>import re name = 'CamelCaseName' name = re.sub(r'(?&lt;!^)(?=[A-Z])', '_', name).lower() print(name) # camel_case_name </code></pre> <p>If you do this many times and the above is slow, compile the regex beforehand:</p> <pre><code>patter...
596,351
How can I know which radio button is selected via jQuery?
<p>I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery?</p> <p>I can get all of them like this:</p> <pre><code>$("form :radio") </code></pre> <p>How do I know which one is selected?</p>
596,369
40
0
null
2009-02-27 19:53:27.18 UTC
394
2022-09-13 05:12:25.84 UTC
2020-01-10 15:06:37.937 UTC
Juan Manuel
1,782
Juan Manuel
1,782
null
1
2,987
javascript|jquery|html|jquery-selectors|radio-button
2,438,741
<p>To get the value of the <strong>selected</strong> <code>radioName</code> item of a form with id <code>myForm</code>:</p> <pre><code>$('input[name=radioName]:checked', '#myForm').val() </code></pre> <p>Here's an example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="fal...
6,315,323
How can I sort strings in NSMutableArray into alphabetical order?
<p>I have a list of strings in an <code>NSMutableArray</code>, and I want to sort them into alphabetical order before displaying them in my table view.</p> <p>How can I do that?</p>
6,315,442
4
0
null
2011-06-11 10:15:26.16 UTC
9
2016-02-22 06:15:07.97 UTC
2013-10-11 23:41:49.773 UTC
null
1,709,587
null
461,396
null
1
42
objective-c|ios|cocoa-touch|sorting|nsmutablearray
37,623
<p>There is the following Apple's working example, using <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/doc/uid/20000137-BABBHAGJ" rel="noreferrer"><code>sortedArrayUsingSelector:</code></a> and <a href="https://developer.apple.co...
6,805,963
How to pass parameters with `include`?
<p>I have a PHP script called customers.php that is passed a parameter via the URL, e.g.:</p> <p><a href="http://www.mysite,com/customers.php?employeeId=1" rel="noreferrer">http://www.mysite,com/customers.php?employeeId=1</a></p> <p>Inside my customers.php script, I pick up the parameter thus:</p> <pre><code>$employ...
6,805,978
6
5
null
2011-07-24 09:13:56.1 UTC
3
2021-09-27 12:53:29.83 UTC
2011-07-24 09:23:56.873 UTC
null
9,535
null
619,852
null
1
8
php
40,306
<p>You can't add a query string (Something like ?x=yyy&amp;vv=www) onto an include like that. Fortunately your includes have access to all the variables before them, so if <code>$_GET['employeeId']</code> is defined before you call:</p> <pre><code>include 'customers.php'; </code></pre> <p>Then customers.php will also...
15,980,963
Opinion on ASP.NET MVC Onion-based architecture
<p>What is your opinion on the following 'generic' code-first Onion-inspired ASP.NET MVC architecture: <img src="https://i.stack.imgur.com/Q1Ngh.png" alt="screenshot of the solution explorer"></p> <p>The layers, explained:</p> <p><strong>Core</strong> - contain the Domain model. e.g. that's the business objects and t...
16,019,657
4
6
null
2013-04-12 21:15:17.09 UTC
20
2020-11-05 11:55:51.18 UTC
null
null
null
null
253,266
null
1
20
entity-framework|asp.net-mvc-4|onion-architecture
8,599
<p>Wow, there’s a lot to say here! ;-)</p> <p>First of all, let’s talk about the overall architecture. </p> <p>What I can see here is that it’s not really an Onion architecture. You forgot the outermost layer, the “Dependency Resolution” layer. In an Onion architecture, it’s up to this layer to wires up Core interfac...
15,759,195
Reduce size of Bitmap to some specified pixel in Android
<p>I would like to reduce My Bitmap image size to maximum of 640px. For example I have Bitmap image of size 1200 x 1200 px .. How can I reduce it to 640px.</p>
15,759,464
4
0
null
2013-04-02 08:14:55.667 UTC
7
2018-04-20 08:56:52.373 UTC
null
null
null
null
232,988
null
1
33
android|bitmap|compression
43,152
<p>If you pass bitmap <code>width</code> and <code>height</code> then use:</p> <pre><code>public Bitmap getResizedBitmap(Bitmap image, int bitmapWidth, int bitmapHeight) { return Bitmap.createScaledBitmap(image, bitmapWidth, bitmapHeight, true); } </code></pre> <p>If you want to keep the bitmap ratio the same, bu...
15,604,140
Replace multiple strings with multiple other strings
<p>I'm trying to replace multiple words in a string with multiple other words. The string is "I have a cat, a dog, and a goat."</p> <p>However, this does not produce "I have a dog, a goat, and a cat", but instead it produces "I have a cat, a cat, and a cat". Is it possible to replace multiple strings with multiple oth...
67,374,697
27
6
null
2013-03-24 21:19:55.123 UTC
144
2022-05-23 08:42:37.097 UTC
2018-09-17 06:42:44.84 UTC
null
4,652,706
null
975,097
null
1
293
javascript|node.js|regex|string|replace
394,091
<p>As an answer to:</p> <blockquote> <p>looking for an up-to-date answer</p> </blockquote> <p>If you are using &quot;words&quot; as in your current example, you might extend the answer of <a href="https://stackoverflow.com/a/15604206/5424988">Ben McCormick</a> using a non capture group and add word boundaries <code>\b<...
15,942,880
mocking a method that return generics with wildcard using mockito
<p>I'm using mockito 1.9.5. I have the following code:</p> <pre><code>public class ClassA { public List&lt;? extends MyInterface&gt; getMyInterfaces() { return null; } public static void testMock() { List&lt;MyInterface&gt; interfaces = new ArrayList&lt;&gt;(); ClassA classAMock = mock(ClassA.class); ...
15,944,985
2
3
null
2013-04-11 07:21:08.337 UTC
10
2018-10-02 13:27:49.7 UTC
null
null
null
null
1,504,992
null
1
50
java|generics|mockito
27,206
<p><strong>EDIT</strong> : Starting from Mockito 1.10.x, generics types that are embedded in the class are now used by Mockito for deep stubs. ie. </p> <pre><code>public interface A&lt;T extends Observer &amp; Comparable&lt;? super T&gt;&gt; { List&lt;? extends B&gt; bList(); T observer(); } B b = deep_stubbed.b...
50,391,868
python 3.5 in statsmodels ImportError: cannot import name '_representation'
<p>I cannot manage to import statsmodels.api correctly when i do that I have this error:</p> <blockquote> <p>File "/home/mlv/.local/lib/python3.5/site-packages/statsmodels/tsa/statespace/tools.py", line 59, in set_mode from . import (_representation, _kalman_filter, _kalman_smoother, ImportError: cannot impo...
50,403,307
3
5
null
2018-05-17 12:47:07.493 UTC
2
2021-06-16 06:49:58.603 UTC
2018-05-17 12:47:34.423 UTC
null
3,337,070
null
9,696,340
null
1
15
python|python-3.x|python-3.5|importerror|statsmodels
40,265
<p>Please see <a href="https://github.com/statsmodels/statsmodels/issues/4654" rel="noreferrer">the github report</a> for more detail.</p> <p>It turns out that statsmodels is dependent upon several packages being installed before it so that it can key on them to compile its own modules. I don't completely understand t...
51,032,328
Angular component default style css display block
<p>I am sick of all my angular elements being 0x0 pixels, because they have names like app-card, app-accordion, which the browser does not recognise as HTML5 compliant elements and as thus, will not give any default styles to.</p> <p>This is means that inspecting it in Chrome, I fail to see the container dimensions an...
60,098,592
1
2
null
2018-06-25 21:57:52.663 UTC
1
2020-03-27 20:27:00.547 UTC
2019-03-24 19:00:19.373 UTC
null
1,702,592
null
1,702,592
null
1
28
angular|angular6|angular5|angular2-template|angular7
10,657
<p><a href="https://github.com/angular/angular-cli/pull/16299" rel="noreferrer">My pull-request has been merged</a>.</p> <p>With the upcoming release of Angular CLI <strong>v9.1.0</strong> a new option is going to be available:<br></p> <pre><code>--displayBlock=true|false </code></pre> <p>Docs: <a href="https://next.an...
10,552,016
How to prevent the cron job execution, if it is already running
<p>I have one php script, and I am executing this script via cron every 10 minutes on CentOS.</p> <p>The problem is that if the cron job will take more than 10 minutes, then another instance of the same cron job will start.</p> <p>I tried one trick, that is:</p> <ol> <li>Created one lock file with php code (same lik...
10,552,054
9
3
null
2012-05-11 13:09:06.947 UTC
19
2017-10-22 20:21:00.66 UTC
2014-08-08 22:08:37.127 UTC
null
12,892
null
1,358,434
null
1
33
php|cron|centos
47,732
<p>Advisory locking is made for exactly this purpose.</p> <p>You can accomplish advisory locking with <a href="http://php.net/flock" rel="noreferrer"><code>flock()</code></a>. Simply apply the function to a previously opened lock file to determine if another script has a lock on it.</p> <pre><code>$f = fopen('lock', ...
35,520,160
python logging performance comparison and options
<p>I am researching high performance logging in Python and so far have been disappointed by the performance of the python standard logging module - but there seem to be no alternatives. Below is a piece of code to performance test 4 different ways of logging:</p> <pre><code>import logging import timeit import time imp...
35,522,577
3
5
null
2016-02-20 06:53:56.517 UTC
9
2021-10-26 16:23:05.677 UTC
null
null
null
null
559,095
null
1
24
python|multithreading|performance|logging|python-multithreading
17,556
<p>The stdlib <code>logging</code> package provides a lot of flexibility and functionality for developers / devops / support staff, and that flexibility comes at some cost, obviously. If the need for performance trumps the need for flexibility, you need to go with something else. Did you take the steps to optimise desc...
33,415,388
What's the difference between hex code (\x) and unicode (\u) chars?
<p>From <code>?Quotes</code>:</p> <blockquote> <pre><code>\xnn character with given hex code (1 or 2 hex digits) \unnnn Unicode character with given code (1--4 hex digits) </code></pre> </blockquote> <p>In the case where the Unicode character has only one or two digits, I would expect these characters to be the s...
33,417,168
1
6
null
2015-10-29 13:19:45.423 UTC
11
2018-02-11 09:02:09.1 UTC
2018-02-11 09:02:09.1 UTC
null
1,030,110
null
134,830
null
1
31
r|unicode|hex
23,015
<p>The escape sequence <code>\xNN</code> inserts the raw byte <code>NN</code> into a string, whereas <code>\uNN</code> inserts the UTF-8 bytes for the Unicode code point <code>NN</code> into a UTF-8 string:</p> <pre><code>&gt; charToRaw('\xA3') [1] a3 &gt; charToRaw('\uA3') [1] c2 a3 </code></pre> <p>These two types ...
13,467,034
Add elements from one list to another C#
<p>What is the simplest way to add elements of one list to another?</p> <p>For example, I have two lists:</p> <p>List A which contains x items List B which contains y items.</p> <p>I want to add elements of B to A so that A now contains X+Y items. I know this can done using a loop but is there a built in method for ...
13,467,046
2
0
null
2012-11-20 05:21:34.18 UTC
2
2012-11-20 05:35:04.84 UTC
null
null
null
null
1,081,402
null
1
22
c#
63,987
<p>Your question describes the <a href="http://msdn.microsoft.com/en-us/library/z883w3dc.aspx">List.AddRange</a> method, which copies all the elements of its argument into the list object on which it is called.</p> <p>As an example, the snippet</p> <pre><code>List&lt;int&gt; listA = Enumerable.Range(0, 10).ToList(); ...
13,389,398
Finding out how many times an array element appears
<p>I am new to JavaScript, I have been learning and practicing for about 3 months and hope I can get some help on this topic. I'm making a poker game and what I'm trying to do is determine whether i have a pair, two pairs, three of a kind, four of a kind or a full house.</p> <p>For instance, in <code>[1, 2, 3, 4, 4, 4...
13,389,463
6
3
null
2012-11-14 23:49:02.027 UTC
6
2017-01-30 17:33:08.473 UTC
2012-11-18 05:45:06.123 UTC
null
23,897
null
1,825,277
null
1
22
javascript|arrays
65,019
<ul> <li>Keep a variable for the total count</li> <li>Loop through the array and check if current value is the same as the one you're looking for, if it is, increment the total count by one</li> <li>After the loop, total count contains the number of times the number you were looking for is in the array</li> </ul> <p>S...
51,979,553
Is it recommended to run systemd inside docker container?
<p>I am planning to use 'systemd' inside the container. Based on the articles I have read, it is preferable to limit only one process per container. </p> <p>But if I configure 'systemd' inside the container, I will end up running many processes. </p> <p>It would be great to understand the pros and cons of using syste...
51,985,145
3
4
null
2018-08-23 06:28:54.633 UTC
8
2019-02-26 07:48:19.233 UTC
2018-08-23 08:08:20.573 UTC
null
8,590,936
null
10,263,095
null
1
16
docker|systemd
19,425
<p>I'd advise you to avoid systemd in a container if at all possible.</p> <p><a href="https://www.freedesktop.org/wiki/Software/systemd/" rel="noreferrer">Systemd</a> mounts filesystems, controls several kernel parameters, has its own internal system for capturing process output, configures system swap space, configur...
20,637,435
Xcode: What is a target and scheme in plain language?
<p>Yeah the title says it :-) What do they mean in plain English language? I really don't understand the explanation on Apple's website and I need to rename my target and I'm afraid that nothing works after that..</p>
20,637,892
6
2
null
2013-12-17 14:59:23.653 UTC
108
2021-06-28 15:13:20.23 UTC
2021-03-04 19:57:24.643 UTC
null
5,175,709
null
1,833,434
null
1
268
ios|xcode|xcode-scheme|xcode-target
75,252
<p>I've added in Workspace and Project too!</p> <ul> <li><strong>Workspace</strong> - Contains one or more <em>projects</em>. These projects usually relate to one another</li> <li><strong>Project</strong> - Contains code and resources, etc. (You'll be used to these!)</li> <li><strong>Target</strong> - Each project h...
29,413,942
C# anonymous object with properties from dictionary
<p>I'm trying to convert an dictionary to an anonymous type with one property for every Key.</p> <p>I tried google it but all I could find was how to convert a anonymous object to a dictionary. </p> <p>My dictionary looks something like this:</p> <pre><code>var dict = new Dictionary&lt;string, string&gt; { {"Id"...
29,414,014
6
4
null
2015-04-02 13:15:35.077 UTC
7
2022-02-18 07:56:20.717 UTC
2016-09-15 19:43:14.287 UTC
null
5,120,235
null
3,082,887
null
1
42
c#|object|dictionary
52,828
<p>You can't, basically. Anonymous types are created by the compiler, so they exist in your assembly with all the property names baked into them. (The property <em>types</em> aren't a problem in this case - as an implementation detail, the compiler creates a generic type and then creates an instance of that using appro...
16,089,304
JavaFX ImageView without any smoothing
<p>Is it possible to render a scaled image in an ImageView in JavaFX 2.2 without any smoothing applied? I'm rendering a 50x50 image into a 200x200 ImageView, with setSmooth(false), so each pixel in the source image should map to a 4x4 square on the screen.</p> <p>However, the resulting render still smooths the source ...
16,092,631
4
3
null
2013-04-18 17:17:06.98 UTC
8
2021-04-08 18:23:41.09 UTC
2016-11-03 09:03:23.033 UTC
null
2,991,525
null
710,342
null
1
20
javafx|javafx-2
14,387
<p>In JavaFX 2.2 <code>ImageView</code> is always going to do some smoothing regardless of the <a href="http://docs.oracle.com/javafx/2/api/javafx/scene/image/ImageView.html#smoothProperty" rel="noreferrer">smooth</a> hint you provide to the <code>ImageView</code>. </p> <p>(Based on testing using Java 7u15 and Window...
16,331,887
Get product id and product type in magento?
<p>I am creating magento store. I am beginner in magento. I want to get product id and product input type in my phtml file is this possible? please guide me..</p> <p>I am trying to this way to get product type. but its not working for me</p> <pre><code>$product=Mage::getModel('catalog/product')-&gt;load($product_id)...
16,332,019
8
0
null
2013-05-02 06:40:25.273 UTC
8
2017-07-12 16:10:46.797 UTC
null
user2564627
2,585,850
user2564627
2,585,850
null
1
22
php|magento|magento-1.7
127,160
<p>Try below code to get currently loaded product id:</p> <pre><code>$product_id = $this-&gt;getProduct()-&gt;getId(); </code></pre> <p>When you don’t have access to $this, you can use Magento registry:</p> <pre><code>$product_id = Mage::registry('current_product')-&gt;getId(); </code></pre> <p>Also for product typ...
29,104,643
HttpClientError: The target server failed to respond
<p>I am trying to hit a server using HTTP client using <code>PoolingClientConnectionManager</code> setting max connections for individual hosts</p> <pre class="lang-java prettyprint-override"><code>//Code that initializes my connection manager and HTTP client HttpParams httpParam = httpclient.getParams(); HttpConnecti...
29,642,453
2
5
null
2015-03-17 16:32:37.687 UTC
7
2021-02-26 21:58:46.79 UTC
2021-02-26 21:58:46.79 UTC
null
185,123
null
3,481,360
null
1
21
java|apache|httpclient|connection-pooling
71,217
<p>Probably, it is a bug in the HttpClient.</p> <p>If you are using the HttpClient 4.4, please try to upgrade to 4.4.1.</p> <p>If you want for more information, please look at <a href="https://issues.apache.org/jira/browse/HTTPCLIENT-1610">this link</a>.</p> <p>If you can't upgrade, the following links might be help...
17,186,866
How to style HTML select/option tag?
<p>I would like to create a dropdown menu with html select thus I would like to style it as well. I would like to set a padding to the option tags so they wouldn't be so overcrowded, but I can't do so. (it doesn't work) any idea?</p> <pre><code>#categories { padding: 10px 10px 10px 10px; background-color: #826B78; fon...
17,188,284
5
7
null
2013-06-19 08:51:05.913 UTC
1
2017-05-15 21:01:19.323 UTC
null
null
null
null
1,509,744
null
1
3
html|css|drop-down-menu|menu|styles
41,593
<p>It is difficult to style select menu with css. The Best way of doing it is with jquery u can style and have a better control over the code with jquery. Just use a custom jquery like <a href="http://gregfranko.com/jquery.selectBoxIt.js/" rel="nofollow noreferrer">http://gregfranko.com/jquery.selectBoxIt.js/</a></p> ...
17,623,445
Set printing area In Excel 2013 using macro
<p>In Excel 2013, having sheet named <em>"Tags"</em>, I am trying to <strong>set a printing area</strong> from <code>A2</code> till end of page, ending with column <code>L</code>.</p> <pre><code>Worksheets("Tags").PageSetup.PrintArea = Worksheets("Tags").Range( _ Cells(2, 1), Cells(Worksheets("Tags").Range("A65536")...
17,623,610
2
0
null
2013-07-12 20:23:51 UTC
3
2015-02-25 21:58:23.207 UTC
2018-07-09 18:41:45.953 UTC
null
-1
null
1,215,106
null
1
3
excel|vba
71,131
<p>It's easier to see what is happening if you declare a few variables and decompose your statement.</p> <p>Try this:</p> <pre><code>Sub SetPrintArea() Dim ws As Worksheet Dim lastRow As Long Set ws = ThisWorkbook.Sheets("Tags") ' find the last row with formatting, to be included in print range lastRow = ...
17,574,916
How to convert array of byte to String in Java?
<p>How can I convert a array of <code>bytes</code> to <code>String</code> without conversion?.</p> <p>I tried:</p> <pre><code> String doc=new String( bytes); </code></pre> <p>But the doc file is not the same than the bytes (the bytes are <strong>binary information</strong>). For example:</p> <pre><code> String do...
17,575,021
3
4
null
2013-07-10 15:34:58.237 UTC
5
2017-07-29 03:47:11.95 UTC
2017-07-29 03:47:11.95 UTC
null
4,972,721
null
202,705
null
1
18
java|arrays|string
93,016
<p>You need to specify the encoding you want e.g. for UTF-8</p> <pre><code>String doc = .... byte[] bytes = doc.getBytes("UTF-8"); String doc2 = new String(bytes, "UTF-8"); </code></pre> <p><code>doc</code> and <code>doc2</code> will be the same.</p> <p>To decode a <code>byte[]</code> you need to know what encoding ...
24,623,559
NSStatusItem change image for dark tint
<p>With OSX 10.10 beta 3, Apple released their dark tint option. Unfortunately, it also means that pretty much all status bar icons (with the exception of Apple's and Path Finder's that I've seen), including mine, remain dark on a dark background. How can I provide an alternate image for when dark tint is applied?</p> ...
24,644,754
6
7
null
2014-07-08 04:09:51.7 UTC
21
2018-10-22 03:59:38.243 UTC
2017-09-13 17:13:49.75 UTC
null
1,000,551
null
1,221,798
null
1
26
objective-c|macos|osx-yosemite|nsstatusitem|nsstatusbar
11,830
<p>TL;DR: You don't have to do anything special in Dark Theme. Give NSStatusItem (or NSStatusBarButton) a template image and it will style it correctly in any menubar context.</p> <hr> <p>The reason why some apps' status items (such as PathFinder's) already work in Dark Theme is because they're not setting their own ...
22,275,079
pySerial write() won't take my string
<p>Using Python 3.3 and pySerial for serial communications.</p> <p>I'm trying to write a command to my COM PORT but the write method won't take my string. (Most of the code is from here <a href="https://stackoverflow.com/questions/676172/full-examples-of-using-pyserial-package">Full examples of using pySerial package<...
22,315,432
3
3
null
2014-03-08 21:05:29.23 UTC
2
2020-11-23 13:09:21.35 UTC
2017-05-23 12:32:26.74 UTC
null
-1
null
2,877,001
null
1
28
python|pyserial
154,963
<p>It turns out that the string needed to be turned into a bytearray and to do this I editted the code to </p> <pre><code>ser.write("%01#RDD0010000107**\r".encode()) </code></pre> <p>This solved the problem</p>
26,794,198
Spring MVC @Path variable with { } braces
<p>Am developing an application using spring boot. In REST controller i prefer to use path variable(<code>@PathVariabale</code> annotation). My code fetching the path variable but it contatins <strong>{ }</strong> braces as it is in the url. Please any one suggest me to solve this issue</p> <pre><code>@RequestMapping(...
26,794,709
1
2
null
2014-11-07 04:42:59.573 UTC
2
2016-09-15 08:26:06.35 UTC
2016-09-15 08:26:06.35 UTC
null
1,479,414
null
2,549,636
null
1
24
java|spring|spring-mvc|spring-boot
68,222
<p>Use <code>http://localhost:8080/user/item/john</code> to submit your request instead. </p> <p>You give Spring a value of "{john}" to the path variable <code>loginName</code>, so Spring get it with the "{}"</p> <p><a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html" rel="nore...
17,485,297
How to instantiate an inner class with reflection in Java?
<p>I try to instantiate the inner class defined in the following Java code:</p> <pre><code> public class Mother { public class Child { public void doStuff() { // ... } } } </code></pre> <p>When I try to get an instance of Child like this</p> <pre><code> Class&lt;?&gt; c...
17,485,341
2
3
null
2013-07-05 09:15:56.25 UTC
19
2019-01-21 23:40:57.2 UTC
2019-01-21 23:40:57.2 UTC
null
363,573
null
363,573
null
1
68
java|reflection|instantiationexception
39,478
<p>There's an extra "hidden" parameter, which is the instance of the enclosing class. You'll need to get at the constructor using <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getDeclaredConstructor%28java.lang.Class...%29" rel="noreferrer"><code>Class.getDeclaredConstructor</code></a> and then...
17,225,229
Using multiple conditions (AND) in SASS IF statement
<p>Using SASS, I would like to have multiple condition in IF statement </p> <p><strong>What I use right now :</strong></p> <pre><code>@function color-x ($alpha) { @if $accent == red {@return red($alpha)} @else if $accent == green {@return green($alpha)} @else if $accent == blue {@return blue($al...
17,226,136
2
0
null
2013-06-20 23:00:14.85 UTC
19
2015-06-12 16:51:14.797 UTC
2013-06-21 01:03:13.853 UTC
null
344,543
null
769,551
null
1
74
if-statement|sass
62,122
<p>From the Sass language reference documentation:</p> <blockquote> <p><strong>Boolean Operations</strong></p> <p>SassScript supports <code>and</code>, <code>or</code>, and <code>not</code> operators for boolean values.</p> </blockquote> <p><a href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#boolean_oper...
17,575,790
Environment detection: node.js or browser
<p>I'm developping a JS-app that needs to work both on the client side and the server side (in Javascript on a browser and in Node.js), and I would like to be able to reuse the parts of the code that are used for both sides.</p> <p>I have found out that <code>window</code> was a variable only accessible on Browsers, a...
31,090,240
11
1
null
2013-07-10 16:15:57.99 UTC
25
2022-05-15 13:42:04.847 UTC
2013-07-10 16:23:26.943 UTC
null
1,993,501
null
1,993,501
null
1
74
javascript|node.js|coffeescript|browser-detection
39,156
<p><em>NOTE: This question had two parts, but because the title was &quot;Environment detection: node.js or browser&quot; - I will get to this part first, because I guess many people are coming here to look for an answer to that. A separate question might be in order.</em></p> <p>In JavaScript variables can be redefine...
30,324,532
How to find text in a string using google script?
<p>I tried indexOf(), findText() and other few methods for finding a string pattern in a text in google app script. None of the above method works.</p> <pre><code>var str="task is completed"; </code></pre> <p>I'm getting this string from google spreadsheet.</p> <p>I just want to find whether the above string contain...
30,324,576
2
2
null
2015-05-19 11:36:36.307 UTC
3
2022-06-30 18:11:40.47 UTC
2015-05-19 11:38:03.66 UTC
null
4,911,834
null
4,911,834
null
1
7
javascript|google-apps-script|google-sheets
48,570
<p>You need to check if the <code>str</code> is present:</p> <pre><code>if (str) { if (str.indexOf('task') &gt; -1) { // Present } } </code></pre> <p>Alternatively, you can use <code>test</code> and <code>regex</code>:</p> <pre><code>/task/.test("task is completed"); /task/.test(str); </code></pre> ...
26,003,086
Launching into portrait-orientation from an iPhone 6 Plus home screen in landscape orientation results in wrong orientation
<p>The actual title for this question is longer than I can possibly fit:</p> <p>Launching an app whose root view controller only supports portrait-orientation but which otherwise supports landscape orientations on an iPhone 6 Plus while the home screen is in a landscape orientation results in a limbo state where the a...
26,003,087
13
3
null
2014-09-23 19:22:15.683 UTC
25
2018-05-31 09:22:07.817 UTC
2014-09-23 21:41:47.78 UTC
null
1,078,579
null
1,078,579
null
1
58
ios|iphone|ios8|uiinterfaceorientation
26,540
<p>This appears to be a bug in iOS 8 when using a UITabBarController as a root view controller. A workaround is to use a mostly vanilla UIViewController as the root view controller. This vanilla view controller will serve as the parent view controller of your tab bar controller:</p> <pre><code>///---------------------...
5,411,026
List of CSS vendor prefixes?
<p>Besides the following list, are there other CSS vendor prefixes that are important for <em>web development</em>? Are my definitions correct? Should I be more specific about mobile browsers (mobile Webkit, e.g.)</p> <ul> <li><code>-khtml-</code> (Konqueror, <em>really</em> old Safari)</li> <li><code>-moz-</code> (Fi...
5,411,098
3
0
null
2011-03-23 20:11:17.38 UTC
40
2021-10-29 08:20:25.33 UTC
2016-09-30 18:12:14.827 UTC
null
1,696,030
null
177,633
null
1
69
css|vendor-prefix
51,912
<p>These are the ones I'm aware of:</p> <ul> <li><code>-ms-</code> Microsoft</li> <li><code>mso-</code> Microsoft Office</li> <li><code>-moz-</code> Mozilla Foundation (Gecko-based browsers)</li> <li><code>-o-</code>, <code>-xv-</code> Opera Software</li> <li><code>-atsc-</code> Advanced Television Standards Committee...
15,069,764
Autocomplete Not Showing Results That Are Returned
<p>I cannot get the results of a jquery autocomplete to show, although the php code returns json results. The jquery code is as follows:</p> <pre><code>$("#newName").autocomplete({ source: function(request, response) { $.ajax({ url: root + "/assets/php/autocomplete.php", dataType: "...
15,072,283
8
0
null
2013-02-25 14:53:06.717 UTC
null
2022-05-23 15:07:08.093 UTC
null
null
null
null
1,267,341
null
1
15
jquery|autocomplete|jquery-ui-autocomplete
44,280
<p>I fixed the problem by adding to my master css file a z-index style for the autocomplete. Everything now works properly.</p> <pre><code>.ui-autocomplete { z-index: 100; } </code></pre>
15,020,734
Using NTLM authentication in Java applications
<p>I want to use Windows NTLM authentication in my Java application to authenticate intranet users transparently. The users should not notice any authentication if using their browsers (single sign-on).</p> <p>I've found a few libs with NTLM support, but don't know which one to use:</p> <ul> <li><a href="http://spneg...
15,028,292
5
1
null
2013-02-22 09:25:37.987 UTC
9
2021-04-20 16:07:17.103 UTC
null
null
null
null
238,134
null
1
17
java|windows|security|authentication|ntlm
60,999
<p>Out of the above list, only ntlmv2-auth and Jespa support NTLMv2. Jespa is workable but commercial. ntlmv2-auth I haven't tried but it's based on the code from Liferay, which I've seen working before.</p> <p>'ntlm-authentication-in-java' is only NTLMv1, which is old, insecure, and works in a dwindling number of env...
15,344,955
Hudson/Jenkins Git build all branches
<p>We have a lot of developers creating feature branches that I would like to build. Nightly we run a code quality tool that needs to run on every branch. I also would not like a static configuration because the number of branches changes every few weeks.</p>
15,355,489
4
0
null
2013-03-11 17:35:44.53 UTC
11
2021-03-17 12:43:39.243 UTC
null
null
null
null
673,289
null
1
38
git|jenkins|hudson
27,991
<p>In Git configuration there is a field 'Branch Specifier (blank for default): ' if you put there ** it will build all branches from all remotes.</p> <p>having that you can use an environment variable ${GIT_BRANCH} e.g. to set a title for the build using <a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+N...
14,970,412
Initialize Array of Objects using NSArray
<p>I'm pretty new to Objective-C and iOS so I've been playing around with the Picker View. I've defined a Person Class so that when you create a new Person it automatically gives that person a name and age.</p> <pre><code>#import "Person.h" @implementation Person @synthesize personName, age; -(id)init { self = ...
14,970,464
5
0
null
2013-02-20 00:48:26.917 UTC
4
2019-05-28 07:36:36.583 UTC
2015-07-02 13:37:55.423 UTC
null
800,452
null
800,452
null
1
42
ios|objective-c|arrays|nsarray
166,737
<pre><code>NSMutableArray *persons = [NSMutableArray array]; for (int i = 0; i &lt; myPersonsCount; i++) { [persons addObject:[[Person alloc] init]]; } NSArray *arrayOfPersons = [NSArray arrayWithArray:persons]; // if you want immutable array </code></pre> <p>also you can reach this without using NSMutableArray:</p...
14,948,441
Vim Can't Save File (E212)
<p>Sometimes when I create a file using <code>vim some/path/newfile</code>, vim lets me edit it, only to complain when I attempt to save my changes.</p> <pre><code>E212 Can't open file for writing. </code></pre> <p>This appears to happen only when the new file is located in a system directory.</p> <p><code>:w!</code...
14,948,510
11
1
null
2013-02-19 01:42:37.187 UTC
25
2022-03-26 11:07:30.253 UTC
null
null
null
null
2,085,347
null
1
64
macos|vim
128,274
<p>This will ask you for the root password, then save your changes as you requested:</p> <pre><code>:w !sudo tee % </code></pre> <p>Then type (L)oad at the prompt, to re-load the file after it is saved.</p>
28,037,539
Prevent duplicates across multiple executions of copying records back into source table while changing one column
<p>I want to select <code>CustomerID</code>, <code>OrderTypeID</code>, and <code>LoanNumber</code> from <code>tblOrder</code> and insert it with a new <code>OrderTypeID</code> but same <code>CustomerID</code> and <code>LoanNumber</code>. My query does that but it duplicates the values, every time the query is executed ...
28,038,088
6
3
null
2015-01-20 03:58:43.547 UTC
10
2022-01-11 22:29:40.273 UTC
2022-01-11 22:29:40.273 UTC
null
577,765
null
4,466,209
null
1
15
sql-server|tsql|sql-server-2008|duplicates
71,279
<p>The first, and most important, issue here is <em>not</em> that your query inserts duplicates; it is that your table <em>allows</em> it to happen in the first place. Hence, you first need to create a UNIQUE INDEX on those 3 fields to disallow duplicates.</p> <p>The second issue is how to handle the situation of when...
8,011,581
ARC, ivars in Blocks and Reference Cycles via Captured Self
<p>I’m working in a pure iOS5/ARC environment, so I can use __weak references as needed. I do reference ivars in a block in many situations, most notably, animation blocks that move views around, which are properties of say, my view controller class.</p> <h3>My question:</h3> <blockquote> <p>In the most trivial use...
8,011,611
2
0
null
2011-11-04 15:19:47.567 UTC
15
2011-12-15 21:08:40.52 UTC
2011-11-04 16:16:33.757 UTC
null
19,679
null
535,054
null
1
26
objective-c|ios|ios5|objective-c-blocks|automatic-ref-counting
6,737
<p>There is only a cycle here if self then goes on to hold a reference to the block (or something owned by self). If not you're good to go as the lifetime of the block is not dictated by the self it retained.</p> <p>So in your particular example, you seem to be in the clear. Animation blocks don't need to participate ...
8,352,260
Why does the SqlParameter name/value constructor treat 0 as null?
<p>I observed a strange problem in a piece of code where an adhoc SQL query was not producing the expected output, even though its parameters matched records in the data source. I decided to enter the following test expression into the immediate window:</p> <pre><code>new SqlParameter("Test", 0).Value </code></pre> <...
8,352,277
2
1
null
2011-12-02 05:48:07.273 UTC
3
2016-03-18 11:02:12.407 UTC
null
null
null
null
428,051
null
1
32
c#|sql-server|ado.net|sqlparameter
8,273
<p>As stated in the <a href="http://msdn.microsoft.com/en-us/library/0881fz2y.aspx" rel="noreferrer">documentation</a> for that constructor:</p> <blockquote> <p>When you specify an Object in the value parameter, the SqlDbType is inferred from the Microsoft .NET Framework type of the Object.</p> <p>Use caution w...
7,942,597
Supporting Open In... menu item in my app for iOS Mail And Safari
<p>I need to have my app open documents from the Safari and Mail apps with that "Open In..." thing in the <code>UIDocumentInteractionController</code> class. How do I accomplish this?</p>
8,023,211
2
0
null
2011-10-30 00:30:35.727 UTC
42
2017-11-23 02:03:38.647 UTC
2011-11-06 03:02:57.29 UTC
null
224,988
null
945,847
null
1
49
objective-c|ios|cocoa-touch|uidocumentinteraction
34,012
<p>I know this was extremely frustrating for me as a beginning programmer, or even as a moderately skilled one now. File I/O through the Mail and Safari apps involves very... interestingly named conventions within the app itself. So let's get our hands dirty with an Xcode project for iPhone. Open Xcode (I will be us...
5,110,292
Why is Clojure dynamically typed?
<p>One thing I like very much is reading about different programming languages. Currently, I'm learning Scala but that doesn't mean I'm not interested in Groovy, Clojure, Python, and many others. All these languages have a unique look and feel and some characteristic features. In the case of Clojure I don't understand ...
5,110,590
5
5
null
2011-02-24 20:49:39.723 UTC
10
2020-12-09 15:04:32.003 UTC
2019-07-18 06:07:56.867 UTC
null
1,303,324
null
497,600
null
1
59
dynamic|functional-programming|clojure|language-design|paradigms
17,007
<p>I agree, a purely functional language can still have an interactive read-eval-print-loop, and would have an easier time with type inference. I assume Clojure wanted to attract lisp programmers by being "lisp for the jvm", and chose to be dynamic like other lisps. Another factor is that type systems need to be design...
4,944,750
How to subtract date/time in JavaScript?
<p>I have a field at a grid containing date/time and I need to know the difference between that and the current date/time. What could be the best way of doing so?</p> <p>The dates are stored like <code>"2011-02-07 15:13:06"</code>.</p>
4,944,782
5
3
null
2011-02-09 12:20:26.167 UTC
22
2021-03-05 18:38:01.113 UTC
2019-08-14 13:59:12.71 UTC
null
4,642,212
null
132,640
null
1
215
javascript|date
431,205
<p>This will give you the difference between two dates, in milliseconds</p> <pre><code>var diff = Math.abs(date1 - date2); </code></pre> <p>In your example, it'd be</p> <pre><code>var diff = Math.abs(new Date() - compareDate); </code></pre> <p>You need to make sure that <code>compareDate</code> is a valid <code>Dat...
4,883,891
Ruby on Rails production log rotation
<p>What is the best way to enable log rotation on a Ruby on Rails production app?</p> <p>Is it by using logrotate on the hosting server or is there a set of options to use when initializing logger from the app?</p>
4,883,967
6
1
null
2011-02-03 08:36:44.1 UTC
97
2022-09-20 07:44:43.78 UTC
2022-09-20 07:44:43.78 UTC
null
5,409,748
null
449,483
null
1
183
ruby-on-rails|logging|production-environment
70,733
<h1>Option 1: syslog + logrotate</h1> <p>You can configure rails, to use the systems log tools. </p> <p>An example in <em>config/environments/production.rb</em>.</p> <pre><code># Use a different logger for distributed setups config.logger = SyslogLogger.new </code></pre> <p>That way, you log to syslog, and can use ...
5,186,394
Using conditional (?:) operator for method selection in C# (3.0)?
<p>I'm refactoring some code.</p> <p>Right now there are quite a few places with functions like this:</p> <pre><code>string error; if (a) { error = f1(a, long, parameter, list); } else { error = f2(the_same, long, parameter, list); } </code></pre> <p>before refactoring f1 and f2 (which are large, but do simila...
5,186,445
7
1
null
2011-03-03 20:52:44.653 UTC
7
2011-03-03 21:07:30 UTC
2011-03-03 21:07:30 UTC
null
18,255
null
18,255
null
1
32
c#|.net|.net-3.5
10,431
<p>You can do that by declaring a delegate, as you pointed out.</p> <p>I notice that you wrote that you are doing this in quite a few places. Another alternative that might be more suitable is to use interfaces. Instantiate one of two different types depending on the value of a, then call the method on that object.</p...
4,948,190
git repository sync between computers, when moving around?
<p>Let's say that I have a desktop pc and a laptop, and sometimes I work on the desktop and sometimes I work on the laptop.</p> <p>What is the easiest way to move a git repository back and forth?</p> <p>I want the git repositories to be identical, so that I can continue where I left of at the other computer.</p> <...
4,948,264
8
1
null
2011-02-09 17:18:05.453 UTC
51
2020-07-26 19:25:16.293 UTC
2011-02-14 07:21:08.937 UTC
null
51,425
null
51,425
null
1
92
git|version-control
54,428
<p>I think, there are multiple approaches. I will just describe, how I handle this</p> <p>I have one netbook as a 24/7 server, that holds multiple git-repositories. From/To there I push and pull changes via SSH. For access from outside I use dyndns.org. It works fine, especially because I have more than two systems, t...
12,586,340
Regex to find special characters in Java
<p>I can use </p> <pre><code>var regex = /[$&amp;+,:;=?@#|]/; if(elem.match(regex)) { // do something } </code></pre> <p>to find whether there is any special characters in string in Javascript.</p> <p>How can I use the similar regular expression in Java?</p> <p>I have tried:</p> <pre><code>str.match("\\="); // r...
12,586,471
4
1
null
2012-09-25 15:34:54.553 UTC
2
2016-12-31 21:16:58.84 UTC
2012-09-25 16:20:14.88 UTC
null
5,640
null
924,578
null
1
6
java|regex
58,778
<p>Try this.</p> <pre><code>Pattern regex = Pattern.compile("[$&amp;+,:;=?@#|]"); Matcher matcher = regex.matcher("123=456"); if (matcher.find()){ // Do something } </code></pre> <p>EDIT: <code>matches()</code> checks all the string and <code>find()</code> finds it in any part of the string.</p> <p>A link: <a hr...
12,264,970
Why is my program slow when looping over exactly 8192 elements?
<p>Here is the extract from the program in question. The matrix <code>img[][]</code> has the size SIZE×SIZE, and is initialized at:</p> <p><code>img[j][i] = 2 * j + i</code></p> <p>Then, you make a matrix <code>res[][]</code>, and each field in here is made to be the average of the 9 fields around it in the img matri...
12,265,928
2
15
null
2012-09-04 13:51:31.017 UTC
320
2017-10-11 12:08:18.863 UTC
2012-09-18 14:59:40.147 UTC
null
50,776
anon
null
null
1
791
c++|performance|memory-management|gcc
96,084
<p>The difference is caused by the same super-alignment issue from the following related questions:</p> <ul> <li><a href="https://stackoverflow.com/q/11413855/922184">Why is transposing a matrix of 512x512 much slower than transposing a matrix of 513x513?</a></li> <li><a href="https://stackoverflow.com/q/7905760/92218...
12,179,271
Meaning of @classmethod and @staticmethod for beginner
<p>What do <code>@classmethod</code> and <code>@staticmethod</code> mean in Python, and how are they different? <em>When</em> should I use them, <em>why</em> should I use them, and <em>how</em> should I use them?</p> <p>As far as I understand, <code>@classmethod</code> tells a class that it's a method which should be i...
12,179,752
12
0
null
2012-08-29 13:37:33.443 UTC
1,071
2022-08-18 22:34:33.607 UTC
2022-08-18 22:16:08.813 UTC
null
4,621,513
user1632861
null
null
1
1,834
python|oop|static-methods|class-method
737,727
<p>Though <code>classmethod</code> and <code>staticmethod</code> are quite similar, there's a slight difference in usage for both entities: <code>classmethod</code> must have a reference to a class object as the first parameter, whereas <code>staticmethod</code> can have no parameters at all.</p> <h2>Example</h2> <pre>...
12,459,779
query specified join fetching, but the owner of the fetched association was not present in the select list
<p>I'm selecting two id columns but get error specified:</p> <pre><code>org.hibernate.QueryException: **query specified join fetching, but the owner of the fetched association was not present in the select list** [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=r,role=null,...
12,459,909
5
2
null
2012-09-17 13:02:15.167 UTC
8
2022-06-01 01:39:36.547 UTC
2017-09-01 19:27:45.567 UTC
null
711,129
null
1,035,646
null
1
111
hibernate|join|fetch
129,315
<p>Use regular <code>join</code> instead of <code>join fetch</code> (by the way, it's <code>inner</code> by default):</p> <pre><code>String hql = " select ec.id as entityChangeId, r.id as revisionId from EntityChange as ec " + " join ec.revision as r " + ... </code></pre> <p>As error message tells you, <code...
12,433,695
Extract elements of list at odd positions
<p>So I want to create a list which is a sublist of some existing list.</p> <p>For example,</p> <p><code>L = [1, 2, 3, 4, 5, 6, 7]</code>, I want to create a sublist <code>li</code> such that <code>li</code> contains all the elements in <code>L</code> at odd positions.</p> <p>While I can do it by</p> <pre><code>L =...
12,433,705
4
4
null
2012-09-15 01:05:25.1 UTC
35
2021-10-03 09:46:08.537 UTC
2016-01-20 09:27:42.737 UTC
null
231,298
null
976,093
null
1
132
python|list|slice
178,688
<h2>Solution</h2> <p>Yes, you can:</p> <pre><code>l = L[1::2] </code></pre> <p>And this is all. The result will contain the elements placed on the following positions (<code>0</code>-based, so first element is at position <code>0</code>, second at <code>1</code> etc.):</p> <pre><code>1, 3, 5 </code></pre> <p>so th...
18,771,963
pandas efficient dataframe set row
<p>First I have the following empty DataFrame preallocated:</p> <pre><code>df=DataFrame(columns=range(10000),index=range(1000)) </code></pre> <p>Then I want to update the <code>df</code> row by row (efficiently) with a length-10000 numpy array as data. My problem is: I don't even have an idea what method of DataFrame...
18,772,565
2
4
null
2013-09-12 18:40:02.79 UTC
2
2013-09-12 19:23:14.1 UTC
null
null
null
null
765,398
null
1
20
python|pandas|dataframe
42,889
<p>Here's 3 methods, only 100 columns, 1000 rows</p> <pre><code>In [5]: row = np.random.randn(100) </code></pre> <p>Row wise assignment</p> <pre><code>In [6]: def method1(): ...: df = DataFrame(columns=range(100),index=range(1000)) ...: for i in xrange(len(df)): ...: df.iloc[i] = row ...:...
3,468,177
RESTful way to send commands
<p>How do you send "commands" to a RESTful server?</p> <p>Use case: My server caches certain information so that it does not have to read the database every time that information is requested. I need a way to send a command from my client application to tell the server to flush the cache. Would you use <code>POST</cod...
5,625,525
3
2
null
2010-08-12 13:32:30.663 UTC
28
2019-03-21 16:40:30.443 UTC
2019-03-21 16:40:30.443 UTC
null
1,746,685
null
96,233
null
1
61
rest|web-applications
28,533
<p>I have come across such a situation a lot in a past project. Since REST is well...about resource, it is not always clear how to deal with things that are Really RPC in nature.</p> <p>An easy way to get around this is to think of it as the <em>bureaucratic part of rest</em>, the request can be a resource itself :</p...
18,880,654
Why do I get the same sequence for every run with std::random_device with mingw gcc4.8.1?
<p>I use the following code to test the C++ <code>&lt;random&gt;</code> library.</p> <p>Why do I get the exact same sequence for every run of the compiled executable? Is <code>rd()</code> deterministic upon compilation? How do I get different output for each run?</p> <p>GCC 4.8.1 on Windows 7 64bit. Using MinGW distr...
18,880,689
5
10
null
2013-09-18 19:27:11.68 UTC
17
2020-06-19 21:15:18.767 UTC
2020-05-01 02:04:21.337 UTC
null
65,863
null
305,669
null
1
71
c++|c++11|random|stl
20,822
<p>From <a href="http://en.cppreference.com/w/cpp/numeric/random/random_device" rel="noreferrer">http://en.cppreference.com/w/cpp/numeric/random/random_device</a>:</p> <blockquote> <p>Note that std::random_device may be implemented in terms of a pseudo-random number engine if a non-deterministic source (e.g. a hardw...
11,445,523
python & smtplib: Is sending mail via gmail using oauth2 possible?
<p>So I can login to and send mail through gmail using smtplib (using the script below), but I was just wondering if using oauth2 was an option like with imaplib? I didn't see anything on the smtplib documentation page about oauth and I haven't found anything googling. Thanks.</p> <pre><code>#! /usr/bin/python impor...
11,448,844
1
1
null
2012-07-12 05:32:21.447 UTC
11
2016-03-03 20:30:59.383 UTC
2012-11-15 14:13:40.097 UTC
null
569,101
null
813,149
null
1
10
python|oauth|oauth-2.0|smtplib
14,778
<p>Interesting, I think it is possible, I found the following links <br/> <a href="https://developers.google.com/google-apps/gmail/oauth_overview" rel="noreferrer">https://developers.google.com/google-apps/gmail/oauth_overview</a><br/></p> <p><b>UPDATE</b><br/> <a href="https://github.com/google/gmail-oauth2-tools/wik...
11,433,886
Sorting A List Comprehension In One Statement
<p>I noticed something I didn't expect when writing a script this morning. I tried to use a list comprehension and sort it all in one statement and got a surprising result. The following code summarizes my general use case, but is simplified for this question:</p> <pre><code>Transaction = namedtuple('Transaction', ['c...
11,433,911
3
1
null
2012-07-11 13:36:50.87 UTC
6
2012-07-11 13:46:47.617 UTC
null
null
null
null
1,432,934
null
1
31
python|list-comprehension
31,869
<p>The method <code>list.sort()</code> is sorting the list in place, and as all mutating methods it returns <code>None</code>. Use the built-in function <a href="http://docs.python.org/library/functions.html#sorted"><code>sorted()</code></a> to return a new sorted list.</p> <pre><code>result = sorted((trans for trans...
11,270,509
putting a remote file into hadoop without copying it to local disk
<p>I am writing a shell script to put data into hadoop as soon as they are generated. I can ssh to my master node, copy the files to a folder over there and then put them into hadoop. I am looking for a shell command to get rid of copying the file to the local disk on master node. to better explain what I need, here be...
11,270,559
5
1
null
2012-06-30 00:33:44.437 UTC
21
2021-09-15 08:52:34.443 UTC
null
null
null
null
793,677
null
1
37
unix|ssh|hadoop|copying|piping
50,888
<p>Try this (untested):</p> <pre><code>cat test.txt | ssh username@masternode "hadoop dfs -put - hadoopFoldername/test.txt" </code></pre> <p>I've used similar tricks to copy directories around:</p> <pre><code>tar cf - . | ssh remote "(cd /destination &amp;&amp; tar xvf -)" </code></pre> <p>This sends the output of ...
11,299,208
How to Synchronize Android Database with an online SQL Server?
<p>I am developing an Android App that stores different types of data in the built-in SQLite provided by the Android Platform.</p> <p>Inside the App I have placed a "Sync" button which is supposed to Sync the data between the local SQLite Database, with an Online SQL Server database on my server.</p> <p>What is the w...
11,299,639
1
4
null
2012-07-02 18:31:05.557 UTC
34
2018-05-07 08:53:25.91 UTC
2018-05-07 08:53:25.91 UTC
null
1,143,634
null
1,496,831
null
1
55
android|sql|sqlite|synchronization
41,533
<p>You should take a look at the SampleSyncAdapter project in the Android SDK demos (<a href="http://developer.android.com/training/sync-adapters/index.html" rel="noreferrer">Transferring Data Using Sync Adapters</a>). It shows you how to do synchronization "Android style", which requires no user interaction by manuall...
11,162,406
Open and write data to text file using Bash?
<p>How can I write data to a text file automatically by shell scripting in Linux?</p> <p>I was able to open the file. However, I don't know how to write data to it.</p>
11,162,510
12
1
null
2012-06-22 18:52:22.533 UTC
64
2022-03-15 13:14:53.943 UTC
2019-03-15 02:58:08.413 UTC
null
608,639
null
1,055,090
null
1
329
bash|shell
890,769
<p>The short answer:</p> <pre class="lang-sh prettyprint-override"><code>echo &quot;some data for the file&quot; &gt;&gt; fileName </code></pre> <p>However, <a href="https://unix.stackexchange.com/a/58312/364698"><code>echo</code> doesn't deal with end of line characters (EOFs) in an ideal way</a>. So, if you're gonna ...
13,213,378
What is causing a "Maximum function nesting level" error in Symfony 2.1 and Twig?
<p>I have a project on Symfony 2.1. After updating composer components (Gedemo, Symfony core, Doctrine, Twig, etc..) I have the following error:</p> <pre><code>Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/{path}/vendor/twig/twig/lib/Twig/Token.php on line 78 </code></pre> <p>I h...
13,213,409
5
5
null
2012-11-03 20:51:20.267 UTC
5
2018-06-16 22:16:31.37 UTC
2013-02-02 18:12:20.287 UTC
null
19,679
null
1,787,682
null
1
29
symfony|twig
31,482
<p>Find the <code>xdebug.ini</code> file:</p> <pre><code>$ locate xdebug.ini /etc/php5/conf.d/20-xdebug.ini /etc/php5/mods-available/xdebug.ini </code></pre> <p>In my case the file is <code>/etc/php5/conf.d/20-xdebug.ini</code>. Open it and add this line:</p> <pre><code>xdebug.max_nesting_level = 1000 </code></pre> ...
13,019,942
Why can't I get `pip install lxml` to work within a virtualenv?
<p>Note: I'm using virtualenvwrapper.</p> <p>Before activating the virtual environment:</p> <pre><code>$ pip install lxml Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/lib/python2.7/dist-packages Cleaning up... </code></pre> <p>After activating the virtual environment:</p> <pre><code>(t...
13,020,013
4
3
null
2012-10-22 21:11:10.197 UTC
18
2018-07-18 17:24:07.773 UTC
2013-11-22 11:43:50.233 UTC
null
785,400
null
785,400
null
1
70
python|virtualenv|virtualenvwrapper
60,962
<p>You probably already have lxml installed on your system, perhaps installed due to a system package. Thus, the first attempt (<code>pip install lxml</code> without an active virtualenv) doesn't fail, but it also doesn't install it; it really doesn't do anything.</p> <p>In a virtualenv, by default, the system package...
12,674,572
Proper usage of .net MVC Html.CheckBoxFor
<p>All I want to know is the proper syntax for the <code>Html.CheckBoxFor</code> HTML helper in ASP.NET MVC.</p> <p>What I'm trying to accomplish is for the check-box to be initially checked with an ID value so I can reference it in the Controller to see if it's still checked or not.</p> <p>Would below be the proper ...
12,674,731
7
3
null
2012-10-01 13:47:26.95 UTC
15
2017-08-03 20:07:14.577 UTC
2013-11-12 14:48:22.173 UTC
null
27,756
null
856,488
null
1
79
asp.net-mvc|checkboxfor
341,905
<h2>That isn't the proper syntax</h2> <p>The first parameter is <strong>not</strong> checkbox value but rather view model binding for the checkbox hence:</p> <pre><code>@Html.CheckBoxFor(m =&gt; m.SomeBooleanProperty, new { @checked = "checked" }); </code></pre> <p>The first parameter must identify a boolean propert...
13,032,701
How to remove folders with a certain name
<p>In Linux, how do I remove folders with a certain name which are nested deep in a folder hierarchy?</p> <p>The following paths are under a folder and I would like to remove all folders named <code>a</code>. </p> <pre><code>1/2/3/a 1/2/3/b 10/20/30/a 10/20/30/b 100/200/300/a 100/200/300/b </code></pre> <p>What Lin...
13,032,768
12
1
null
2012-10-23 14:26:23.213 UTC
70
2022-03-01 03:41:31.07 UTC
2013-11-19 20:33:43.383 UTC
null
445,131
null
136,088
null
1
209
linux|unix|rm
152,749
<p>If the target directory is empty, use find, filter with only directories, filter by name, execute rmdir:</p> <pre><code>find . -type d -name a -exec rmdir {} \; </code></pre> <p>If you want to recursively delete its contents, replace <code>-exec rmdir {} \;</code> with <code>-delete</code> or <code>-prune -exec rm -...
16,667,251
Query to get only numbers from a string
<p>I have data like this:</p> <pre><code>string 1: 003Preliminary Examination Plan string 2: Coordination005 string 3: Balance1000sheet </code></pre> <p>The output I expect is </p> <pre><code>string 1: 003 string 2: 005 string 3: 1000 </code></pre> <p>And I want to implement it in SQL.</p>
16,667,431
22
1
null
2013-05-21 10:00:54.127 UTC
36
2022-08-24 10:07:50.893 UTC
2019-11-25 10:05:20.013 UTC
null
1,127,428
null
2,404,950
null
1
93
sql|sql-server
415,288
<p>First create this <strong><code>UDF</code></strong></p> <pre><code>CREATE FUNCTION dbo.udf_GetNumeric ( @strAlphaNumeric VARCHAR(256) ) RETURNS VARCHAR(256) AS BEGIN DECLARE @intAlpha INT SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric) BEGIN WHILE @intAlpha &gt; 0 BEGIN SET @strAlphaNum...
16,908,084
Bash script to calculate time elapsed
<p>I am writing a script in bash to calculate the time elapsed for the execution of my commands, consider:</p> <pre><code>STARTTIME=$(date +%s) #command block that takes time to complete... #........ ENDTIME=$(date +%s) echo "It takes $($ENDTIME - $STARTTIME) seconds to complete this task..." </code></pre> <p>I guess...
16,908,239
11
1
null
2013-06-04 00:41:27.847 UTC
37
2022-07-30 08:49:34.39 UTC
2018-06-14 23:06:10.543 UTC
null
6,862,601
null
175,296
null
1
153
linux|bash|shell
149,535
<p>Either <code>$(())</code> or <code>$[]</code> will work for computing the result of an arithmetic operation. You're using <code>$()</code> which is simply taking the string and evaluating it as a command. It's a bit of a subtle distinction. Hope this helps.</p> <p>As tink pointed out in the comments on this answ...
4,228,261
Understanding the purpose of some assembly statements
<p>I am trying to understand some assembly code and managed to finish most of it except a few lines. I am able to understand most of what is happening inside but am not able to fully understand what (and why it) is happening at the beginning and ending of the code. Can someone shed some light on this?</p> <pre><code>i...
4,228,936
2
5
null
2010-11-19 18:39:54.263 UTC
18
2015-07-08 14:37:42.373 UTC
2010-11-19 18:43:32.27 UTC
null
459,640
null
184,046
null
1
11
c|assembly|x86
17,023
<p>The stack grows <strong>downward</strong>. A <code>push</code> subtracts from the stack pointer (esp) and a <code>pop</code> adds to esp. You have to keep that in mind to understand a lot of this.</p> <pre><code>8048394:8d 4c 24 04 lea 0x4(%esp),%ecx ; ?? </code></pre> <p>lea = Load Effe...
4,731,774
How to Read / Improve C.R.A.P Index Calculated by PHP
<p>I just started working with PHPUnit and its colorful code coverage reports. I understand all the numbers and percentages save one: The C.R.A.P index. Can anyone offer me a solid explanation of what it means, how to analyze it and how to lower it?</p>
4,733,574
2
0
null
2011-01-19 04:36:23.963 UTC
39
2018-05-24 09:42:43.477 UTC
2013-09-12 02:56:51.217 UTC
null
385,273
null
122,164
null
1
76
php|unit-testing|phpunit
17,621
<p><a href="https://stackoverflow.com/a/4731869/5441">@Toader Mihai offered a solid explanation.</a> (+1 from me)</p> <h2>How to lower it:</h2> <p>Write less complex code OR write better tested code. (See the graph below)</p> <p><strong>Better tested Code ?</strong></p> <p>In this context this just means: A higher ...
41,511,587
JavaScript error: Cannot read property 'includes' of undefined
<p>I want to check if a <code>data.objectId</code> already exists in the array <code>msgArr</code>. For that I am running the code below:</p> <pre><code>var exists = msgArr.objectId.includes(data.objectId); if(exists === false){ msgArr.push({"objectId":data.objectId,"latLont":data.latLont,"isOnline":data.isOnline}...
41,511,712
3
6
null
2017-01-06 18:02:43.767 UTC
4
2019-08-08 18:09:11.837 UTC
2019-08-08 18:09:11.837 UTC
null
1,264,804
null
6,287,404
null
1
8
javascript|typescript|ecmascript-6
82,156
<p>As the comments say: the javascript array object has no property <code>objectId</code>.<br> Looking at the objects in this array it's clear that they have it, so to check if a certain element exists you can do so using <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some"...
41,272,257
mcrypt is deprecated, what is the alternative?
<p>The mcrypt-extension is <a href="http://php.net/manual/en/migration71.deprecated.php#migration71.deprecated.ext-mcrypt" rel="noreferrer">deprecated</a> will be removed in PHP 7.2 according to the comment posted <a href="https://bugs.php.net/bug.php?id=73734" rel="noreferrer">here</a>. So I am looking for an alternat...
41,272,680
10
11
null
2016-12-21 21:34:12.417 UTC
30
2020-08-18 13:15:45.377 UTC
2018-01-05 11:06:31.01 UTC
null
55,075
null
4,977,904
null
1
118
php|encryption|passwords|php-7|mcrypt
194,413
<p>It's best practice to hash passwords so they are not decryptable. This makes things slightly more difficult for attackers that may have gained access to your database or files.</p> <p>If you must encrypt your data and have it decryptable, a guide to secure encryption/decryption is available at <a href="https://para...
41,596,121
Does VBA Have a Ternary Operator?
<p>I come from the beautiful world of Obj C, which is based on the C programming language, and I've fallen in love with finding quirky ways to save space. However, I've looked through as much documentation as I can and I can't find anything juicy on VBA that will shorten this syntax:</p> <pre><code>If boolVar = True T...
41,596,160
3
13
null
2017-01-11 16:39:24.853 UTC
3
2020-01-28 10:22:54.867 UTC
2020-01-28 10:22:54.867 UTC
null
11,636,588
null
2,353,523
null
1
32
excel|vba
30,046
<pre><code>Sub test() Dim x As Long Dim y As Long y = 1 x = IIf(y = 1, 1, 2) End Sub </code></pre>
9,858,654
"ORA-00922: missing or invalid option" when creating tables
<p>I entered the following SQL commands in Oracle but it complained "ORA-00922: missing or invalid option"</p> <pre><code>CREATE TABLE Student ( StuID NUMBER(15), StuName VARCHAR2(50), Phone VARCHAR2(20), PRIMARY KEY (StuID)) CREATE TABLE Program ( ProCode VARCHAR2(12), ProTitl...
9,859,157
3
9
null
2012-03-25 07:51:45.6 UTC
1
2021-08-12 01:52:14.14 UTC
2012-03-25 07:55:04.943 UTC
null
601,179
null
1,276,521
null
1
5
sql|oracle
59,067
<p>If you are using the dreaded HTML GUI (inside the browser) of OracleXE then that does not support running more than one statement. </p> <p>Use SQL Developer, SQL*Plus or any other GUI tool instead.</p>
10,238,826
CSS class and descendant selectors practices
<p>I would like to form a better understanding of when it is appropriate to use classes to target content as opposed to other available options, specifically, descendant selectors.</p> <p>In many cases, instead of using classes, it is possible to use descendant selectors to target the same elements. If the same thing ...
10,238,984
3
1
null
2012-04-20 00:48:37.667 UTC
8
2012-04-20 02:56:23.843 UTC
2012-04-20 00:56:00.873 UTC
null
825,789
null
1,343,020
null
1
8
html|css-selectors|css
13,979
<p>Descendant selectors allow you to avoid embedding class information in your html. This may be convenient when the wrapping block is a logical container. For example, if you have constructed a table using <code>div</code> tags and you have hundreds, or thousands, of rows you could potentially cut down your document...
9,989,785
Technique for carrying metadata to View Models with AutoMapper
<p>I use AutoMapper to map my domain objects to my view models. I have metadata in my domain layer, that I would like to carry over to the view layer and into ModelMetadata. (This metadata is not UI logic, but provides necessary information to my views). </p> <p>Right now, my solution is to use a separate MetadataP...
10,100,042
3
1
null
2012-04-03 08:35:34.143 UTC
17
2017-03-03 09:36:26.98 UTC
null
null
null
null
344,211
null
1
16
asp.net-mvc-3|asp.net-mvc-2|automapper|modelmetadata|modelmetadataprovider
5,308
<p>I use the approach below to automatically copy data annotations from my entities to my view model. This ensures that things like StringLength and Required values are always the same for entity/viewmodel.</p> <p>It works using the Automapper configuration, so works if the properties are named differently on the view...
10,046,027
Having trouble downloading Git archive tarballs from Private Repo
<p>I need the ability to download our application at specific tags, but I am unable to find a working solution for this. Downloading tarballs based on git tag seems promising but I am unable to get it working using Curl. I have tried the following but all I get back is the source for the github 404 page.</p> <pre><cod...
10,053,425
3
2
null
2012-04-06 16:05:24.77 UTC
11
2015-05-29 15:02:32.373 UTC
2012-04-19 13:11:39.34 UTC
null
1,317,806
null
1,317,806
null
1
22
git|github
23,274
<p>For public repo, you have <a href="https://gist.github.com/758124" rel="nofollow noreferrer">this gist</a> listing some examples:</p> <pre><code>wget --no-check-certificate https://github.com/sebastianbergmann/phpunit/tarball/3.5.5 -O ~/tmp/cake_phpunit/phpunit.tgz </code></pre> <p>For a private repo, try passing ...
28,220,636
View SQLite database on device in Android Studio
<p>I am using the latest version of Android Studio. When I run my app on the emulator, I am able to view my database by going through:</p> <p><code>tools -&gt; Android Device Monitor -&gt; clicking on the emulator in the left panel -&gt; file explorer -&gt; data -&gt; data -&gt; com.project-name</code></p> <p>But thi...
33,233,232
5
6
null
2015-01-29 17:14:26.78 UTC
9
2021-10-12 01:49:51.363 UTC
2017-05-23 12:25:50.553 UTC
null
-1
null
2,058,547
null
1
22
android|sqlite|android-studio
59,718
<h1>Connect to Sqlite3 via ADB Shell</h1> <p>I haven't found any way to do that in Android Studio, but I access the db with a remote shell instead of pulling the file each time.</p> <p>Find all info here: <a href="http://developer.android.com/tools/help/adb.html#sqlite" rel="noreferrer">http://developer.android.com/t...
11,787,558
SQL Injection attack - What does this do?
<p>I have detected some failed SQL injection attacks on my website. The failed queries are of the form:</p> <blockquote> <p><code>SELECT 6106 FROM(SELECT COUNT(*),':sjw:1:ukt:1'x FROM information_schema.tables GROUP BY x)</code></p> </blockquote> <p>The <code>':sjw:1:ukt:1'</code> part is specially constructed wi...
19,620,164
3
3
null
2012-08-03 00:07:03.287 UTC
9
2014-03-28 15:38:00.983 UTC
2014-03-28 15:38:00.983 UTC
null
177,663
null
219,564
null
1
14
mysql|security|sql-injection
9,508
<h2>What the attack really does</h2> <p>There is a subtle but clever detail about this attack that other answerers missed. Notice the error message <code>Duplicate entry ':sjw:1:ukt:1' for key 'group_key'</code>. The string <code>:sjw:1:ukt:1</code> is actually the result of an expression evaluated by your MySQL serve...
11,743,809
How can a border be set around multiple cells in excel using C#
<p>I am working on a project that creates excel files.</p> <p>I am having trouble placing a border on multiple cells to organize the excel file. </p> <p>Let's say I want a border from cell B5 to B10. There shouldn't be borders between B5, B6, B7,...</p> <p>Currently, I have this code: </p> <pre><code>workSheet_rang...
11,744,272
8
1
null
2012-07-31 15:37:13.2 UTC
1
2020-06-14 15:07:52.473 UTC
2015-08-07 22:14:42.36 UTC
null
2,940,627
null
1,565,785
null
1
14
c#|excel|border
61,592
<p>You need to individually set these</p> <pre><code>.Borders[Excel.XlBordersIndex.xlEdgeBottom] .Borders[Excel.XlBordersIndex.xlEdgeRight] .Borders[Excel.XlBordersIndex.xlEdgeLeft] .Borders[Excel.XlBordersIndex.xlEdgeTop] </code></pre>
12,018,681
Android TLS connection and self signed certificate
<p>I'm trying to connect to a node.js based TLS server from my Android app. Naturally it fails becouse I'm using a self-signed certificate.</p> <p>Is there anyway I can just add the certificate to my app and have Android trust it somehow? Note, I'm not using HTTPS, this is a TLS over TCP connection.</p>
12,150,903
2
0
null
2012-08-18 12:45:02.137 UTC
10
2016-01-20 02:14:26.757 UTC
null
null
null
null
636,967
null
1
17
android|ssl
16,962
<p>After a lot of reading around, I came up with an answer.</p> <p>A pretty good guide is here: <a href="http://nelenkov.blogspot.no/2011/12/using-custom-certificate-trust-store-on.html" rel="noreferrer">http://nelenkov.blogspot.no/2011/12/using-custom-certificate-trust-store-on.html</a></p> <p>Now, since I'm not usi...
11,801,278
Accessing Meteor production database
<p>To check out what's in the (production) database for <code>blah.meteor.com</code> I thought we would just do:</p> <pre><code>meteor mongo --url http://blah.meteor.com/ </code></pre> <p>But instead I get a URI:</p> <pre><code>mongodb://client:984dae4c-04fb-c8bb-68f6-ed83602435cc@skybreak.member1.mongolayer.com:270...
11,801,719
3
0
null
2012-08-03 18:28:09.427 UTC
27
2017-08-02 07:06:43.697 UTC
2017-09-22 17:57:57.377 UTC
null
-1
null
594,601
null
1
44
mongodb|meteor|production|database
36,280
<p>You should use <code>meteor mongo http://blah.meteor.com</code>; or even shorter <code>meteor mongo blah.meteor.com</code>.</p> <p>For documentation you can run <code>meteor help mongo</code>. Extract from running the help command above:</p> <blockquote> <p>Instead of opening a shell, specifying --url (-U) will ...
19,962,608
Javascript character count
<p>Example here: <a href="http://jsfiddle.net/67XDq/1/" rel="noreferrer">http://jsfiddle.net/67XDq/1/</a></p> <p>I have the following HTML:</p> <pre><code>&lt;tr id="rq17"&gt; &lt;td class='qnum'&gt;17.&lt;/td&gt; &lt;td class='qtext'&gt;Questions? &lt;i&gt;Maximum of 500 characters - &lt;input style="color:r...
19,962,742
4
5
null
2013-11-13 19:26:13.143 UTC
4
2019-02-14 22:17:40.71 UTC
2013-11-13 19:31:14.36 UTC
null
322,131
null
322,131
null
1
6
javascript|html|character
46,604
<p>There are two issues in the fiddle</p> <ul> <li>no form element</li> <li>script mode was onload, which means that window object didnt have <code>textCounter</code> function</li> </ul> <p>see updated fiddle <a href="http://jsfiddle.net/67XDq/7/" rel="nofollow noreferrer">http://jsfiddle.net/67XDq/7/</a>, markup:</p...
3,736,210
How to execute a shell script from C in Linux?
<p>How can I execute a shell script from C in Linux?</p>
3,736,607
6
0
null
2010-09-17 14:29:13.093 UTC
31
2017-07-20 15:34:05.28 UTC
null
null
null
null
218,471
null
1
69
c|linux|shell
142,921
<p>It depends on what you want to do with the script (or any other program you want to run).</p> <p>If you just want to run the script <a href="http://man7.org/linux/man-pages/man3/system.3.html" rel="noreferrer"><code>system</code></a> is the easiest thing to do, but it does some other stuff too, including running a ...
3,354,330
Difference between string and text in rails?
<p>I'm making a new web app using Rails, and was wondering, what's the difference between <code>string</code> and <code>text</code>? And when should each be used?</p>
3,354,452
9
0
null
2010-07-28 15:15:33.407 UTC
99
2020-10-22 04:59:03.333 UTC
2012-01-13 23:06:17.033 UTC
null
71,421
null
218,183
null
1
475
ruby-on-rails
215,392
<p>The difference relies in how the symbol is converted into its respective column type in query language.</p> <blockquote> <p>with MySQL :string is mapped to VARCHAR(255)</p> <ul> <li><a href="https://edgeguides.rubyonrails.org/active_record_migrations.html" rel="noreferrer">https://edgeguides.rubyonrails.org/active_r...