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
9,950,128
How to implement INotifyDataErrorInfo in WPF 4.5?
<p>I realized that appears this interface in .NET Framework 4.5</p> <p>I was looking first for about how to implemented in Silverlight (I can imagine that it's implemented in the same way), but I can't find a compact demo of this new interface. Is it possible to show how can I use it?</p> <p>I really want to find a s...
9,950,236
2
1
null
2012-03-30 20:38:31.847 UTC
12
2019-05-10 15:10:04.94 UTC
null
null
null
null
1,118,485
null
1
31
c#|wpf|silverlight|inotifydataerrorinfo
42,595
<p>Beside the very detailed description on MSDN about the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifydataerrorinfo%28v=vs.95%29.aspx" rel="nofollow noreferrer">Silverlight version of INotifyDataErrorInfo</a> </p> <p>There are already some blog posts with samples how to use/implement ...
7,747,934
Can someone explain Polymorphism to me?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/210460/try-to-describe-polymorphism-as-easy-as-you-can">Try to describe polymorphism as easy as you can</a> </p> </blockquote> <p>I've never been able to fully comprehend what polymorphism is. Can someone expla...
7,748,957
3
0
null
2011-10-12 23:55:17.363 UTC
8
2011-10-13 02:52:15.117 UTC
2017-05-23 12:26:07.92 UTC
null
-1
null
386,869
null
1
14
oop|polymorphism
20,315
<p>Perhaps it's easiest to start with a non-computer analogy.</p> <p>Consider if you told somebody to "Go to the store and buy some of your favorite food for supper."</p> <p>If you said this to a 14 year-old son, he'd probably ride his bike to the store, have to pay cash for the food, and you'd be having pizza for su...
11,893,826
How to refresh image view immediately
<p>In my android app, I download an image from the cloud. The download is performed in a thread and in that same thread I also set an image view with the newly downloaded image. After setting the image, I then call <code>postinvalidate()</code>.</p> <p>However the image does not immediately show up. Is there a way to ...
11,894,378
4
0
null
2012-08-10 00:20:00.747 UTC
3
2018-12-23 16:57:53.34 UTC
2012-08-10 21:38:09.57 UTC
null
366,313
null
1,583,075
null
1
14
android|multithreading|image
48,807
<p>Each class which is derived from the View class has the <code>invalidate()</code> and the <code>postInvalidate()</code> method. If <code>invalidate()</code> gets called it tells the system that the current view has changed and it should be redrawn <strong>as soon as possible</strong>. As this method can only be call...
11,600,006
How to Create a configuration File For MongoDB
<p>I have installed mongodb for mac os through 10gen and I have gone through the documentation to do so. Everything seems fine apart from the configuration file. I can not see it in /etc/mongod.config. Do I have to manually create this config file? And if so how can I go about it? </p> <p>cheers</p>
11,600,283
4
0
null
2012-07-22 11:45:34.177 UTC
13
2020-05-04 20:29:07.87 UTC
null
null
null
null
1,460,625
null
1
34
macos|mongodb|configuration-files
64,437
<p>Unless you have installed a packaged version of MongoDB (for example, using <a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#id1" rel="noreferrer">Homebrew or Mac Ports</a>) you will have to create a config file manually, or just pass the appropriate <a href="http://www.mongodb.org/display/D...
20,165,954
Read into std::string using scanf
<p>As the title said, I'm curious if there is a way to read a C++ string with scanf.</p> <p>I know that I can read each char and insert it in the deserved string, but I'd want something like:</p> <pre><code>string a; scanf("%SOMETHING", &amp;a); </code></pre> <p><code>gets()</code> also doesn't work.</p> <p>Thanks ...
20,166,048
7
5
null
2013-11-23 18:06:42.107 UTC
5
2021-02-03 07:52:38.78 UTC
2021-02-03 07:52:38.78 UTC
null
1,030,410
null
1,977,897
null
1
35
c++|c|string
106,365
<p>There is no situation under which <code>gets()</code> is to be used! It is <strong>always</strong> wrong to use <code>gets()</code> and it is removed from C11 and being removed from C++14.</p> <p><code>scanf()</code> doens't support any C++ classes. However, you can store the result from <code>scanf()</code> into a ...
3,294,475
Is there a way to shift highlighted lines left or right in Notepad++
<p>In the Eclipse IDE (and many others I would imagine) there is a simple shortcut to shift highlighted lines either right or left by one tab length.</p> <p>I have looked through all of the TextFX in Notepad++ and only found the ability to shift highlighted lines up or down. Is there a built in way to shift highlighte...
3,294,513
4
0
null
2010-07-20 21:24:12.83 UTC
9
2022-07-13 04:09:15.62 UTC
null
null
null
null
352,374
null
1
32
notepad++
51,087
<p>Shift highlighted lines to the right one tab length by pressing the tab key. Shift them to the left by pressing shift-tab.</p> <p>When lines are highlighted, the tab key doesn't replace them with a tab. It shifts them left/right instead.</p>
4,003,604
How to set class on div that is inside of repeater in code behind?
<p><a href="http://paste.org/pastebin/view/24218" rel="nofollow">CSS &amp; html</a></p> <p>id0 is the class for the div that's got background as a sprite image and inside of this div..there's a list of links (in repeater)..when the user hovers over links..the background image of div displays diff parts of sprite image...
4,003,779
5
1
null
2010-10-23 10:53:33.603 UTC
5
2015-11-17 17:11:25.093 UTC
2010-10-30 12:06:39.047 UTC
null
1,427,536
null
1,427,536
null
1
4
c#|asp.net|html|css
41,243
<p><strong>The ItemDataBinding way</strong></p> <p>In order to get hold of an element inside the repeater's ItemTemplate you have to declare it runat="Server" and set an id for it (id isn't really neccessary, but simplifies things). If you do that with your div you can get it inside your <a href="http://msdn.microsoft...
3,566,176
Salting passwords 101
<p>Could someone please help me understand how salting works?</p> <p>So far I understand the following:</p> <ol> <li>Validate password</li> <li>Generate a random string</li> <li>Hash the password and the random string and concat them, then store them in the password field...</li> </ol> <p>How do we store the salt, o...
3,566,375
5
1
null
2010-08-25 13:15:20.83 UTC
9
2020-02-26 14:28:03.253 UTC
2014-01-30 09:44:22.393 UTC
null
445,517
null
276,959
null
1
24
salt|password-hash
9,992
<p>Salt is combined with the password before hashing. the password and salt clear values are concatenated and the resulting string is hashed. this guarantees that even if two people were to have the same password you would have different resulting hashes. (also makes attacks known as dictionary attacks using rainbow ...
3,805,474
What is a closure? Does java have closures?
<p>I was reading Object Oriented Javascript and found the concept of closures. I didn't quite understand why and when it is used. Do other languages like Java also have closures? I basically want to understand how knowing the concept of closures can help me improve my coding.</p>
3,805,576
5
2
null
2010-09-27 15:48:36.163 UTC
18
2016-03-18 10:56:09.003 UTC
2010-09-27 16:11:49.62 UTC
null
140,185
null
337,522
null
1
36
java|javascript|closures
26,194
<p>A closure is a first class function with bound variables.</p> <p>Roughly that means that:</p> <ul> <li>You can pass the closure as a parameter to other functions</li> <li>The closure stores the value of some variables from the lexical scope that existed at the time that is was created</li> </ul> <p>Java initially...
3,447,536
How to determine the OS
<p>how to implement a function that will return the OS name? detect the environment where the program running on?</p> <p>win2000/xp/vista/win7 etc...?</p>
3,447,622
7
1
null
2010-08-10 09:22:30.007 UTC
9
2022-07-05 09:18:00.803 UTC
null
null
null
null
318,249
null
1
12
delphi|operating-system
9,412
<p>Something like this:</p> <pre><code>function osver: string; begin result := 'Unknown (Windows ' + IntToStr(Win32MajorVersion) + '.' + IntToStr(Win32MinorVersion) + ')'; case Win32MajorVersion of 4: case Win32MinorVersion of 0: result := 'Windows 95'; 10: result := 'Windows 98'; ...
3,727,420
Significance of Sleep(0)
<p>I used to see <code>Sleep(0)</code> in some part of my code where some infinite/long <code>while</code> loops are available. I was informed that it would make the time-slice available for other waiting processes. Is this true? Is there any significance for <code>Sleep(0)</code>?</p>
3,727,460
8
1
null
2010-09-16 14:00:36.077 UTC
9
2016-11-09 04:59:25.837 UTC
2014-02-25 15:34:22.8 UTC
null
321,731
null
139,909
null
1
54
c++|visual-c++|process|sleep
36,799
<p>According to MSDN's documentation for <a href="http://msdn.microsoft.com/en-us/library/ms686298(VS.85).aspx" rel="noreferrer">Sleep</a>:</p> <blockquote> <p>A value of zero causes the thread to relinquish the remainder of its time slice to any other thread that is ready to run. If there are no other threa...
3,944,505
Detecting signed overflow in C/C++
<p>At first glance, this question may seem like a duplicate of <a href="https://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c">How to detect integer overflow?</a>, however it is actually significantly different.</p> <p>I've found that while detecting an unsigned integer overflow is pret...
3,944,774
13
17
null
2010-10-15 17:16:11.36 UTC
32
2021-10-15 19:08:26.22 UTC
2017-05-23 12:17:35.543 UTC
null
-1
null
469,408
null
1
95
c++|c|undefined-behavior|signed|integer-overflow
37,321
<p>Your approach with subtraction is correct and well-defined. A compiler cannot optimize it away.</p> <p>Another correct approach, if you have a larger integer type available, is to perform the arithmetic in the larger type and then check that the result fits in the smaller type when converting it back</p> <pre><cod...
3,232,904
Using reCAPTCHA on localhost
<p>I'm developing a website using PHP and I want to make a human verification in one of the sessions. For the development, I'm initially running the system locally and when it is ready, I'm going to put it on some domain.</p> <p>In the <a href="https://www.google.com/recaptcha/admin/create" rel="noreferrer">reCAPTCHA w...
9,987,136
24
1
null
2010-07-12 22:53:02.827 UTC
62
2022-07-18 10:20:42.387 UTC
2021-07-20 19:59:05.33 UTC
null
63,550
null
313,721
null
1
382
localhost|recaptcha
439,905
<h3>Update</h3> <p>The original answer is no longer correct. The developer's guide now states:</p> <blockquote> <p>"If you would like to use "localhost" for development, you must add it to the list of domains."</p> </blockquote> <p>This will only work if you access localhost using <code>127.0.0.1/...</code> rather...
8,032,293
How to install 3rd party module for postgres pl/python?
<p>I need to import a 3rd party module inside my pl/python function. It seems pl/python uses an internal python that does not have any 3rd party modules.</p> <p>I get this kind of error:</p> <pre><code>ERROR: PL/Python: PL/Python function "to_tsvector_luc" failed DETAIL: &lt;type 'exceptions.ImportError'&gt;: No mo...
8,036,067
4
1
null
2011-11-07 02:54:23.953 UTC
5
2021-11-09 11:13:43.223 UTC
null
null
null
null
496,852
null
1
31
postgresql|plpython
12,084
<p>pl/python has access to the all the modules that the normal Python interpreter would have as long as they are in the <code>$PYTHONPATH</code> on the server (and the user that runs the postgres service). Does <code>import lucene</code> work if you run it in the Python interpreter on the server?</p> <p>If your module...
8,107,000
Jshint.com requires "use strict". What does this mean?
<p>Jshint.com is giving the error:</p> <blockquote> <p>Line 36: var signin_found; Missing "use strict" statement.</p> </blockquote>
8,107,071
4
2
null
2011-11-12 19:34:15.857 UTC
5
2015-06-27 23:03:57.953 UTC
2015-06-27 23:03:57.953 UTC
user656925
815,724
user656925
null
null
1
87
javascript|jshint
58,393
<p>Add "use strict" at the top of your js file (at line 1 of your .js file):</p> <pre><code>"use strict"; ... function initialize_page() { var signin_found; /*Used to determine which page is loaded / reloaded*/ signin_found=document.getElementById('signin_button'); if(signin_found) { </code></pre> <p...
8,223,560
How to find the size of any object in iOS?
<p>I was optimizing my app and wanted to know that how much is the size of the object, so that I can also show it in log.</p> <p>suppose I have</p> <pre><code>NSDictionary *temp=(NSDictionary*)[Data objectAtIndex:i]; //data is defined in the .h file </code></pre> <p>now how will I know that how much is the size of...
8,223,612
5
4
null
2011-11-22 07:50:44.473 UTC
14
2019-08-28 02:27:15.09 UTC
2019-08-28 02:27:15.09 UTC
null
1,265,393
null
1,021,896
null
1
22
iphone|objective-c|cocoa-touch|ios4
16,632
<p>The compiler knows only about the pointer, and that is why it will always return size of the pointer. To find the size of the allocated object try something like</p> <pre><code>NSLog(@"size of Object: %zd", malloc_size(myObject)); </code></pre>
8,232,922
ASP pages in IIS using Localhost 401.3 Error do not have permission
<p>I have just installed the IIS so I can view asp files in a browser but when I put the address in a browser as : <a href="http://localhost/index.asp" rel="noreferrer">http://localhost/index.asp</a> I get an error. </p> <p>The error shows this:</p> <blockquote> <p>HTTP Error 401.3 - Unauthorized You do not have ...
8,234,073
6
9
null
2011-11-22 19:55:39.793 UTC
14
2017-03-21 00:41:36.983 UTC
2017-02-18 01:11:12.43 UTC
null
497,418
null
763,179
null
1
64
iis|asp-classic
95,241
<p>OK, working from memory here as I am not in front of a Windows machine. </p> <p>If you right click on your webroot folder /inetpub/wwwroot/ or the website directory you are working on open properties and select security, I think it is, you will see the list of users with their permissions for that folder. There is ...
7,871,425
Is there a way to zoom into a D3 force layout graph?
<p>D3 has a force directed layout <a href="http://mbostock.github.com/d3/ex/force.html" rel="nofollow noreferrer">here</a>. Is there a way to add zooming to this graph? Currently, I was able to capture the mouse wheel event but am not really sure how to write the redraw function itself. Any suggestions?</p> <pre><code>...
7,907,043
6
2
null
2011-10-24 04:51:18.79 UTC
52
2022-01-12 05:58:07.753 UTC
2022-01-12 05:58:07.753 UTC
null
7,036,713
null
184,046
null
1
82
javascript|jquery|d3.js|zooming|force-layout
44,666
<p><strong>Update 6/4/14</strong></p> <p>See also <a href="https://stackoverflow.com/a/17976205/380487">Mike Bostock's answer here</a> for changes in D3 v.3 and the <a href="http://bl.ocks.org/mbostock/6123708" rel="nofollow noreferrer">related example</a>. I think this probably supersedes the answer below.</p> <p><s...
8,116,951
Any reason to use auto-implemented properties over manual implemented properties?
<p>I understand the advantages of PROPERTIES over FIELDS, but I feel as though using AUTO-implemented properties over MANUAL implemented properties doesn't really provide any advantage other than making the code a little more concise to look at it.</p> <p>I feel much more comfortable using:</p> <pre><code> private...
8,116,967
7
6
null
2011-11-14 03:22:04.803 UTC
4
2019-11-01 00:44:15.807 UTC
2011-11-14 03:29:33.953 UTC
null
120,243
null
1,044,866
null
1
33
c#|properties|field|encapsulation
18,627
<p>It doesn't grant you anything extra beyond being concise. If you prefer the more verbose syntax, then by all means, use that.</p> <p>One advantage to using auto props is that it can potentially save you from making a silly coding mistake such as accidentally assigning the wrong private variable to a property. Trust...
8,006,250
Copy path/file name in Eclipse to clipboard
<p>Is there a shortcut to copy the current path/file to the clipboard?</p>
8,007,500
10
2
null
2011-11-04 07:49:05.227 UTC
6
2020-04-23 16:43:05.137 UTC
2015-03-05 07:30:24.943 UTC
null
441,652
null
710,818
null
1
38
eclipse|file|path-finding
28,110
<p>There is <code>Copy Qualified Name</code> function in Eclipse, it will copy the full name of the element you select (or element on cursor).</p> <p>For example :</p> <p><code>/MyProject/src/app/Application.java</code> : when you select Application.java in <code>Package Explorer</code></p> <p><code>java.util.HashSe...
8,218,230
PHP DOMDocument loadHTML not encoding UTF-8 correctly
<p>I'm trying to parse some HTML using DOMDocument, but when I do, I suddenly lose my encoding (at least that is how it appears to me).</p> <pre><code>$profile = "&lt;div&gt;&lt;p&gt;various japanese characters&lt;/p&gt;&lt;/div&gt;"; $dom = new DOMDocument(); $dom-&gt;loadHTML($profile); $divs = $dom-&gt;getElement...
8,218,649
11
4
null
2011-11-21 20:37:52.58 UTC
81
2022-01-07 23:04:27.71 UTC
2013-10-17 22:31:35.65 UTC
null
283,078
null
519,204
null
1
242
php|utf-8|character-encoding
131,246
<p><code>DOMDocument::loadHTML</code> will treat your string as being in ISO-8859-1 (the HTTP/1.1 default character set) unless you tell it otherwise. This results in UTF-8 strings being interpreted incorrectly.</p> <p>If your string doesn't contain an XML encoding declaration, you can prepend one to cause the string t...
7,783,341
Run script with rc.local: script works, but not at boot
<p>I have a node.js script which need to start at boot <em>and</em> run under the www-data user. During development I always started the script with:</p> <pre><code>su www-data -c 'node /var/www/php-jobs/manager.js </code></pre> <p>I saw exactly what happened, the manager.js works now great. Searching SO I found I ha...
8,331,447
17
6
null
2011-10-16 09:10:07.46 UTC
25
2022-07-25 14:44:37.703 UTC
null
null
null
null
434,223
null
1
40
linux|bash|ubuntu|boot|autorun
172,939
<p>I ended up with <a href="http://kevin.vanzonneveld.net/techblog/article/run_nodejs_as_a_service_on_ubuntu_karmic/" rel="noreferrer">upstart</a>, which works fine.</p>
4,375,302
Using imagejpeg to save & serve image file
<p>I'm doing a bit of an experiment with PHP + Image manipulation. I'm trying to convert some images into black and white versions. I'm mostly figured it out but have one slight issue.</p> <p>In order to reduce the strain on the server, I wanted to save the B&amp;W versions and only run the image filtering on images...
4,375,465
3
0
null
2010-12-07 09:53:26.02 UTC
1
2013-03-07 02:52:59.293 UTC
null
null
null
null
280,869
null
1
4
php|image-processing
49,309
<p>A compact and correct form for above function can be:</p> <pre><code>&lt;?php header("Content-type: image/jpeg"); $file = $_GET['img']; $name = md5($file).".jpg"; if(!file_exists("/path/to/file" . $name)) { imagefilter($image, IMG_FILTER_GRAYSCALE); imagejpeg($image, "/path/to/file" . $name); } else { $image ...
4,358,213
How does one intercept a request during the Jersey lifecycle?
<p>I've used Jersey for the better part of a year now and have just stumbled upon a problem to which I can't find the answer: how do you intercept (or hook into) the Jersey request lifecycle?</p> <p>Ideally, I'd be able to perform some custom filtering/validation/rejection between the time the container accepts the re...
4,362,323
4
3
null
2010-12-05 09:47:17.16 UTC
10
2016-08-11 07:48:33.043 UTC
2010-12-05 10:07:52.587 UTC
null
394,496
null
394,496
null
1
49
java|api|jax-ws|jersey|jax-rs
35,617
<p>I've found the answer.</p> <p>First, create a class that implements ContainerRequestFilter. The interface specifies the following method, in which the filtering takes place. The ContainerRequest object contains information about the current request.</p> <pre><code>public ContainerRequest filter(ContainerRequest ...
4,507,893
Django filter many-to-many with contains
<p>I am trying to filter a bunch of objects through a many-to-many relation. Because the <code>trigger_roles</code> field may contain multiple entries I tried the <code>contains</code> filter. But as that is designed to be used with strings I'm pretty much helpless how i should filter this relation (you can ignore the ...
4,508,083
4
0
null
2010-12-22 09:44:26.03 UTC
14
2020-06-15 14:41:50.287 UTC
2020-06-15 14:41:50.287 UTC
null
4,720,018
null
508,474
null
1
108
python|django|django-models|many-to-many|django-orm
101,531
<p>Have you tried something like this:</p> <pre><code>module.workflow_set.filter(trigger_roles__in=[self.role], allowed=True) </code></pre> <p>or just if <code>self.role.id</code> is not a list of pks:</p> <pre><code>module.workflow_set.filter(trigger_roles__id__exact=self.role.id, allowed=True) </code></pre>
4,690,986
RegEx needed to match number to exactly two decimal places
<p>I need some regex that will match only numbers that are decimal to two places. For example:</p> <ul> <li>123 = No match</li> <li>12.123 = No match</li> <li>12.34 = Match</li> </ul>
4,691,005
5
0
null
2011-01-14 12:24:52.513 UTC
5
2020-12-03 12:46:48.497 UTC
2019-10-28 15:53:38.537 UTC
null
59,087
null
449,568
null
1
25
regex
90,333
<pre><code>^[0-9]*\.[0-9]{2}$ or ^[0-9]*\.[0-9][0-9]$ </code></pre>
4,128,001
Is it ok for an HTML element to have the same [name] as its [id]?
<p>I'm working on embedding a flash app in a webpage using the Satay method:</p> <pre><code>&lt;object type="application/x-shockwave-flash" data="embeddy.swf" <i>id="embeddy" name="embeddy"</i>&gt; &lt;param name="movie" value="embeddy.swf" /&gt; &lt;/object&gt;</code></pre> <p>I want flash to provide the correct <...
4,128,017
5
0
null
2010-11-08 20:57:31.153 UTC
6
2015-05-27 15:41:06.79 UTC
null
null
null
null
497,418
null
1
42
html|flash|embedding|object-tag
19,668
<p>You use IDs for JavaScript manipulation.</p> <p>You use Names for form field submission.</p> <p>The two are not related. So setting both to the same value is OK, but it is not required.</p>
4,592,166
What does the term "empty loop" refer to exactly in C and C++?
<p>Is it this kind of thing:</p> <pre><code>for(;;) { statements; } </code></pre> <p>Or is it this:</p> <pre><code>for(initialisation;condition;updation) { } </code></pre> <p>I am looking for answers with references to a variety of sources.</p>
4,592,201
6
1
null
2011-01-04 09:33:19.017 UTC
null
2019-10-03 07:11:18.417 UTC
2015-08-15 20:30:58.983 UTC
null
895,245
null
562,325
null
1
34
c++|c
49,874
<p>Your first case (<em>for</em> with empty expressions) is an <strong>infinite</strong> loop and the second one (with empty body of the <em>for</em> statement) is an <strong>empty</strong> loop</p>
4,309,533
Why do I get "Database logon failed" in Crystal Reports when using .NET object as datasource?
<p>I am creating a simple report using a .NET object from my project as datasource, using <code>SetDatasource()</code> method. However, when I run the report I get "Database logon failed" error. This report is not connecting to a DB at all - have I missed something here?</p> <p>Many thanks, D.</p> <p>ADDED: I guess i...
4,374,049
12
2
null
2010-11-30 00:38:50.767 UTC
6
2020-07-30 13:05:46.7 UTC
2020-04-15 09:18:06.75 UTC
null
3,705,348
null
150,061
null
1
10
crystal-reports
78,304
<p>Fixed by using the appropriate class: ReportDocument instead of ReportClass.</p>
4,313,841
Insert a string at a specific index
<p>How can I insert a string at a specific index of another string? </p> <pre><code> var txt1 = "foo baz" </code></pre> <p>Suppose I want to insert "bar " after the "foo" how can I achieve that?</p> <p>I thought of <code>substring()</code>, but there must be a simpler more straight forward way.</p>
4,314,050
18
1
null
2010-11-30 12:40:59.553 UTC
75
2022-01-25 17:39:14.64 UTC
2018-10-26 19:49:58.13 UTC
null
3,345,644
null
292,291
null
1
435
javascript|string
693,130
<p>You could prototype your own <code>splice()</code> into String.</p> <h2>Polyfill</h2> <pre><code>if (!String.prototype.splice) { /** * {JSDoc} * * The splice() method changes the content of a string by removing a range of * characters and/or adding new characters. * * @this {Strin...
14,615,712
Toggle classname onclick JavaScript
<p>I am nearly there, just a little unsure as to my code setup, I basically want to remove a class on click, and add it back again onclick, then remove onclick, then add onclick. And so on! Here's what I have, it's nearly there, but if there is a nicer way to do this then please help! Thank you.</p> <pre><code>documen...
14,615,765
5
0
null
2013-01-30 23:20:07.937 UTC
5
2017-01-31 16:47:32.427 UTC
null
null
null
user1323595
null
null
1
11
javascript|toggle
48,731
<p>If you want to use a ternary operator, use this:</p> <pre><code>document.getElementById('myButton').onclick = function() { var className = ' ' + myButton.className + ' '; this.className = ~className.indexOf(' active ') ? className.replace(' active ', ' ') : ...
14,537,286
Event driven design in c
<p>this is a little theoretical question. Imagine a device full of sensors. Now, in case a sensor x detects something, something should happen. Meanwhile, in case something else is detected, like two sensors detects two different things, then, this device must behave differently.</p> <p>From webdesign (so javascript) ...
14,537,499
4
8
null
2013-01-26 13:14:17.53 UTC
8
2022-08-24 16:42:12.247 UTC
null
null
null
null
985,383
null
1
13
c|events|event-driven-design
24,361
<p>I would assume you're owning an embedded system with access to interrupts or a major event loop in a separate thread, otherwise this isn't possible..</p> <p>A basic model for event handling is here:</p> <pre><code>#define NOEVENT 0 typedef void *(*EventHandler)(void *); void *doNothing(void *p){/*do nothing absolu...
14,481,032
where is hardware timer interrupt?
<p>this is Exceptions and Interrupts table(which I understand as IDT) from the "Intel Architecture Software Developer Manual"</p> <p><img src="https://i.stack.imgur.com/ZKye4.png" alt="Exceptions and Interrupts"></p> <p>where is Timer interrupt which makes context switching possible?? (for multi-tasking)</p> <p>if t...
14,481,859
2
0
null
2013-01-23 13:36:00.897 UTC
8
2014-07-31 17:01:46.097 UTC
null
null
null
null
1,528,889
null
1
16
linux|operating-system|kernel|interrupt
7,397
<p>Well, yes, if we are talking about the traditional 8254 PIT timer, it is at IRQ0, which is vector 32. But that is not generally used as the timer in the Linux operating system on modern machines. [Note that the vector assignment of 32 is really quite arbitrary. It is set when programming the 8259 (PIC) or APIC - but...
14,827,398
Converting byte array values in little endian order to short values
<p>I have a byte array where the data in the array is actually short data. The bytes are ordered in little endian:</p> <p>3, 1, -48, 0, -15, 0, 36, 1</p> <p>Which when converted to short values results in:</p> <p>259, 208, 241, 292</p> <p>Is there a simple way in Java to convert the byte values to their correspondi...
14,827,440
2
5
null
2013-02-12 07:18:10.583 UTC
3
2020-04-22 01:51:39.423 UTC
2015-02-07 10:17:33.533 UTC
null
318,054
null
753,632
null
1
25
java|arrays|byte|endianness
51,728
<p>With <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html" rel="noreferrer">java.nio.ByteBuffer</a> you may specify the endianness you want: <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html#order%28java.nio.ByteOrder%29" rel="noreferrer">order()</a>.</p> <p>ByteBuffer...
14,873,227
Escaping colons in YAML
<p>Does anyone know how to escape colons in YAML? The key in my yml is the domain with port number, but the yml file isn't working with this setup:</p> <pre><code>###BEGIN production: ### THIS IS THE ONE I'm HAVING TROUBLE WITH ### 8.11.32.120:8000: GoogleMapsKeyforThisDomain exampledomain.com: GoogleMapsAPIKeyforTha...
14,873,305
2
4
null
2013-02-14 10:57:15.547 UTC
3
2019-06-22 18:58:31.223 UTC
2017-12-11 23:11:41.77 UTC
null
42,223
user2071444
null
null
1
35
escaping|yaml|delimiter
27,070
<p>You'll need to put quotes around the key you're having trouble with. I.e.:</p> <pre><code>"8.11.32.120:8000": GoogleMapsKeyforThisDomain </code></pre>
3,185,217
Error Code: 1136 Column count doesn't match value count at row 1) inside sp
<p>i have some troubles filling a predefined table with a stored procedure. mytable has 6 fields: uid,testrun,exp1,exp2,exp3,weightedvalue where uid is an autoincrement PK. My sp contains an insert statement like: </p> <pre><code>CREATE PROCEDURE test (IN testrun INT) BEGIN .... some declare statements ... INSERT I...
3,185,230
2
0
null
2010-07-06 09:58:01.15 UTC
1
2013-08-05 07:59:09.62 UTC
null
null
null
null
366,256
null
1
3
mysql
53,365
<p>You have a comma in the last line of your insert, making 6 columns instead of 5:</p> <pre><code>exp1 * 0,2 + (exp2_1+exp2_2) * 0.5 + (exp3_1+exp3_2) * 0.3 ^ </code></pre> <p>I guess that this should be a decimal point, not a comma.</p>
2,355,025
jQuery get img source attributes from list and push into array
<p>I have this thumbnail list and would like push the image paths (sources) into an array: tn_array</p> <pre><code>&lt;ul id="thumbnails"&gt; &lt;li&gt;&lt;img src="somepath/tn/004.jpg" alt="fourth caption" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="somepath/tn/005.jpg" alt="fifth caption" /&gt;&lt;/a&g...
2,355,045
2
0
null
2010-03-01 10:08:07.24 UTC
11
2015-03-10 21:12:05.407 UTC
null
null
null
null
238,898
null
1
20
jquery|arrays|loops|attributes|push
36,920
<p>You can create the array of src attributes more directly using <a href="http://api.jquery.com/map/" rel="noreferrer"><code>map()</code></a>:</p> <pre><code>var tn_array = $("#thumbnails img").map(function() { return $(this).attr("src"); }); </code></pre> <p><strong>Edit:</strong> <code>tn_array</code> is an obje...
32,843,099
Jackson Not Overriding Getter with @JsonProperty
<p><code>JsonProperty</code> isn't overriding the default name jackson gets from the getter. If I serialize the class below with <code>ObjectMapper</code> and jackson I get</p> <pre><code>{"hi":"hello"} </code></pre> <p>As you can see the JsonProperty annotation has no effect</p> <pre><code>class JacksonTester { ...
32,844,950
11
0
null
2015-09-29 11:45:18.04 UTC
5
2022-06-22 10:29:00.23 UTC
2015-09-29 12:10:33.463 UTC
null
4,093,621
null
4,093,621
null
1
33
java|json|serialization|jackson|getter
76,913
<p>The problem was that I was using both the old and new jackson libraries</p> <p>i.e. before I had <code>import org.codehaus.jackson.annotate.JsonProperty;</code> Which I had to change to below, to be consistent with the library I was using. </p> <p>Since I was using maven that also meant updating my maven dependenc...
33,713,680
SSH – Force Command execution on login even without Shell
<p>I am creating a restricted user without shell for port forwarding only and I need to execute a script on login via pubkey, even if the user is connected via <code>ssh -N user@host</code> which doesn't asks SSH server for a shell.</p> <p>The script should warn admin on connections authenticated with pubkey, so the u...
61,079,746
4
1
null
2015-11-14 21:38:08.45 UTC
14
2020-04-08 09:51:12.393 UTC
2017-05-08 11:07:33.877 UTC
null
1,640,661
null
371,160
null
1
19
ssh|sshd
49,409
<p>If you only need to run a script you can rely on <code>pam_exec</code>.</p> <p>Basically you reference the script you need to run in the <code>/etc/pam.d/sshd</code> configuration:</p> <pre><code>session optional pam_exec.so seteuid /path/to/script.sh </code></pre> <p>After some testing you may want to change <co...
30,089,675
Clustering cosine similarity matrix
<p>A few questions on stackoverflow mention this problem, but I haven't found a concrete solution.</p> <p>I have a square matrix which consists of cosine similarities (values between 0 and 1), for example:</p> <pre><code> | A | B | C | D A | 1.0 | 0.1 | 0.6 | 0.4 B | 0.1 | 1.0 | 0.1 | 0.2 C | 0.6 | 0.1 | 1....
30,093,501
1
1
null
2015-05-06 23:58:16.383 UTC
13
2018-08-21 23:57:19.383 UTC
2015-05-07 21:07:12.263 UTC
null
1,060,350
null
1,430,038
null
1
20
python|math|scikit-learn|cluster-analysis|data-mining
23,871
<p>You can easily do this using spectral clustering. You can use the ready implementations such as the one in sklearn or implement it yourself. It is rather an easy algorithm.</p> <p>Here is a piece of code doing it in python using sklearn:</p> <pre><code>import numpy as np from sklearn.cluster import SpectralCluster...
20,854,231
Angular JS issue with string.length in templates
<p>I have an issue with AngularJS (version 1.2.6).</p> <p>For some reason that I could not understand I cannot access the <code>length</code> property of a string variable stored in the <code>$scope</code>.</p> <p>In the template:</p> <pre><code>String '{{myObject.someVariable}}' has length '{{myObject.someVariable....
20,854,303
2
0
null
2013-12-31 08:26:12.507 UTC
2
2013-12-31 08:45:12.377 UTC
2013-12-31 08:45:12.377 UTC
null
766,848
null
766,848
null
1
14
javascript|angularjs
44,123
<p>Is <code>someVariable</code> a string? If not, you might have to cast it to a string before accessing the length property. Any easy way is to concatenate it with an empty string:</p> <pre><code>{{(myObject.someVariable + '').length}} </code></pre>
38,567,796
How to determine if asp.net core has been installed on a windows server
<p>I'm setting up various windows servers to host asp.net core apps, and I need to be able to determine if they have the asp.net hosting bundle installed.</p> <p><a href="https://docs.asp.net/en/latest/publishing/iis.html#install-the-net-core-windows-server-hosting-bundle" rel="noreferrer">https://docs.asp.net/en/late...
43,357,798
7
0
null
2016-07-25 12:28:03.38 UTC
6
2020-09-10 20:40:59.177 UTC
2016-07-25 15:09:10.973 UTC
null
81,377
null
81,377
null
1
35
asp.net-core|.net-core
48,999
<p>You can use powershell to check if the hosting module is registered with IIS</p> <p>In the local powershell session</p> <pre><code>Import-module WebAdministration $vm_dotnet_core_hosting_module = Get-WebGlobalModule | where-object { $_.name.ToLower() -eq &quot;aspnetcoremodule&quot; } if (!$vm_dotnet_core_hosting_mo...
38,790,154
Keyboard shortcut to convert selection to uppercase (or lowercase) in the atom editor
<p>What is the keyboard shortcut to convert the currently selected text to uppercase (or lowercase) in the Atom editor?</p>
38,790,155
2
0
null
2016-08-05 13:11:24.16 UTC
21
2020-10-06 03:31:24.83 UTC
2017-08-01 08:42:01.783 UTC
null
203,797
null
203,797
null
1
111
atom-editor
55,524
<p>On Windows and Linux:</p> <ul> <li><kbd>Ctrl</kbd> + <kbd>K</kbd> then <kbd>Ctrl</kbd> + <kbd>U</kbd> for uppercase</li> <li><kbd>Ctrl</kbd> + <kbd>K</kbd> then <kbd>Ctrl</kbd> + <kbd>L</kbd> for lowercase</li> </ul> <p>On Mac:</p> <ul> <li><kbd>Cmd</kbd> + <kbd>K</kbd> then <kbd>Cmd</kbd> + <kbd>U</kbd> for uppe...
50,161,551
Set python version when creating virtualenv using pipenv
<p>Using a Raspberry Pi using Debian 4.14.34-v7+, I am trying to get <code>pipenv</code> set up with Python 3.6.5 as the default version of Python. I first install Python 3.6 by compiling it on the Pi (hours...). After making a 'robot' directory, I then install <code>pipenv</code> with <code>sudo pip3 install pipenv</c...
50,163,474
5
0
null
2018-05-03 18:18:51.98 UTC
16
2022-06-21 14:32:21.877 UTC
2020-05-06 17:28:03.127 UTC
null
241,211
null
4,565,870
null
1
47
python-3.x|pipenv
98,980
<p>"Edit the Pipfile" is the right way to go if you want to change the Python version of an existing environment.</p> <p>If you want to create a <em>new</em> environment using Python 3.6, you can run</p> <pre><code>pipenv install --python 3.6 </code></pre> <p>rather than</p> <pre><code>pipenv install --three </code...
44,793,523
How to edit all lines in Visual Studio Code
<p>I have a list of data to which I need to put a <code>'</code> symbol at the start of the line and at the end of the line. So the original data looks like this:</p> <pre><code>abcde cdeab deabc eabcd </code></pre> <p>And I want all of the lines to look like this:</p> <pre><code>'abcde' 'cdeab' 'deabc' 'eabcd' </co...
44,793,837
8
0
null
2017-06-28 04:12:20.453 UTC
22
2021-06-23 16:08:44.27 UTC
2020-03-20 16:10:29.577 UTC
null
996,081
null
4,989,544
null
1
44
visual-studio-code
43,116
<p>You could edit and replace with a regex:</p> <p>Find (<kbd>Ctrl</kbd>+<kbd>F</kbd>):</p> <pre><code>^(.+)$ </code></pre> <p>Replace:</p> <pre><code>'$1' </code></pre> <p>This regex finds any content on a line and wraps it inside quotes. The <code>$1</code> refers to whatever is matched inside the parentheses in the ...
26,320,525
Prettify json data in textarea input
<p>I've searched for this particular topic and couldn't find anything similar to it. If there is please close this and give a link.</p> <p>I'm creating a json data api simulator. I want users to be able to copy and paste a json object request into a textarea where they can also modify it before sending it to the serve...
26,324,037
6
0
null
2014-10-12 00:07:12.933 UTC
15
2022-03-22 15:26:05.5 UTC
2018-05-02 09:09:54.993 UTC
null
4,281,779
null
1,881,088
null
1
76
javascript|jquery|html|css|json
119,885
<p>The syntax highlighting is tough but check out this <a href="http://jsfiddle.net/psasik/x3hcdq97/1/">fiddle for pretty printing a json object</a> entered in a text area. Do note that the JSON has to be valid for this to work. (Use the dev console to catch errors.) Check <a href="http://jsonlint.com/">jsLint</a> for ...
28,384,680
Scikit-Learn's Pipeline: A sparse matrix was passed, but dense data is required
<p>I'm finding it difficult to understand how to fix a Pipeline I created (read: largely pasted from a tutorial). It's python 3.4.2:</p> <pre><code>df = pd.DataFrame df = DataFrame.from_records(train) test = [blah1, blah2, blah3] pipeline = Pipeline([('vectorizer', CountVectorizer()), ('classifier', RandomForestClas...
28,384,887
5
0
null
2015-02-07 16:43:17.853 UTC
20
2021-04-21 10:03:00.78 UTC
null
null
null
null
4,540,977
null
1
48
python|numpy|pandas|scikit-learn
38,738
<p>Unfortunately those two are incompatible. A <code>CountVectorizer</code> produces a sparse matrix and the RandomForestClassifier requires a dense matrix. It is possible to convert using <code>X.todense()</code>. Doing this will substantially increase your memory footprint.</p> <p>Below is sample code to do this bas...
22,711,087
Flask - ImportError: No module named app
<p>First I created <code>__init__.py</code></p> <pre><code>from flask import Flask app = Flask(__name__) </code></pre> <p>Then in a separate file, in the same directory, <code>run.py</code></p> <pre><code>from app import app app.run( debug = True ) </code></pre> <p>When I try to run <code>run.py</code>, I ge...
22,711,701
9
0
null
2014-03-28 11:05:31.887 UTC
11
2022-06-21 01:37:26.937 UTC
2014-03-28 14:32:20.547 UTC
null
1,572,562
null
1,661,745
null
1
54
python|python-import
157,239
<p><code>__init__.py</code> is imported using a directory. if you want to import it as <code>app</code> you should put <code>__init__.py</code> file in directory named <code>app</code> </p> <p>a better option is just to rename <code>__init__.py</code> to <code>app.py</code></p>
39,370,879
extract hour from timestamp with python
<p>I have a dataframe df_energy2</p> <pre><code>df_energy2.info() &lt;class 'pandas.core.frame.DataFrame'&gt; RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null int64 PERIODE_TARIF 29974 non-null object P_SOUSCR ...
39,370,905
2
0
null
2016-09-07 13:12:21.51 UTC
1
2016-09-07 13:44:15.6 UTC
2016-09-07 13:15:17.24 UTC
null
2,901,002
null
2,278,337
null
1
10
python|datetime|pandas|extract|hour
44,546
<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.dt.hour.html" rel="noreferrer"><code>dt.hour</code></a>:</p> <pre><code>print (df.TIMESTAMP.dt.hour) 0 0 1 0 Name: TIMESTAMP, dtype: int64 df['hours'] = df.TIMESTAMP.dt.hour print (df) TIMESTAMP P_ACT_K...
38,966,105
Jenkins Setup Wizard Blank Page
<p>I have just installed Jenkins on my RHEL 6.0 server via npm:</p> <pre><code>npm -ivh jenkins-2.7.2-1.1.noarch.rpm </code></pre> <p>I have also configured my port to be 9917 to avoid clashing with my Tomcat server, allowing me to access the Jenkins page at <code>ipaddress:9917</code>. After entering the initial adm...
38,968,807
14
0
null
2016-08-16 03:15:48.87 UTC
4
2020-02-07 11:11:06.65 UTC
2019-02-13 12:47:07.67 UTC
null
5,277,820
null
6,488,062
null
1
37
jenkins|jenkins-plugins
25,465
<p>I found out that after I opened the port 9917 in my firewall,the blank pages error stopped and I can continue with the setup just fine.</p>
20,939,089
no operator "<<" matches these operands
<p>No idea what's going on. I looked at other posts that are similar to this issue but no solution helped so far. Here's the code with comments by the parts giving errors. At one point it says that != doesn't work and in the rest of the code it's saying that &lt;&lt; isn't working.</p> <pre><code>#include &lt;iostream...
20,939,121
3
0
null
2014-01-05 20:58:37.96 UTC
6
2014-01-11 22:24:29.7 UTC
2014-01-11 22:24:29.7 UTC
null
923,854
null
1,146,984
null
1
26
c++
127,516
<p>If you want to use <code>std::string</code> reliably, you must <code>#include &lt;string&gt;</code>.</p>
47,812,526
PySpark - Sum a column in dataframe and return results as int
<p>I have a pyspark dataframe with a column of numbers. I need to sum that column and then have the result return as an int in a python variable. </p> <pre><code>df = spark.createDataFrame([("A", 20), ("B", 30), ("D", 80)],["Letter", "Number"]) </code></pre> <p>I do the following to sum the column. </p> <pre><code>d...
51,855,775
9
0
null
2017-12-14 11:43:05.77 UTC
16
2021-10-06 23:15:36.76 UTC
null
null
null
null
2,402,501
null
1
53
python|dataframe|sum|pyspark
147,315
<p>The simplest way really : </p> <pre><code>df.groupBy().sum().collect() </code></pre> <p>But it is very slow operation: <a href="https://databricks.gitbooks.io/databricks-spark-knowledge-base/content/best_practices/prefer_reducebykey_over_groupbykey.html" rel="noreferrer">Avoid groupByKey</a>, you should use RDD a...
5,728,164
when to use CABasicAnimation and CAKeyFrameAnimation and CGAffineTransform?
<p>when to use CABasicAnimation and CAKeyFrameAnimation and CGAffineTransform?</p>
5,728,249
1
0
null
2011-04-20 09:26:43.407 UTC
9
2011-12-26 09:06:23.013 UTC
2011-04-20 16:44:59.737 UTC
null
603,977
null
189,006
null
1
8
cgaffinetransform|cakeyframeanimation|cabasicanimation
2,673
<p><strong>CABasicAnimation</strong> : provides basic, single-keyframe animation capabilities for a layer property.</p> <p><strong>CAKeyFrameAnimation</strong>:CAKeyframeAnimation provides generic keyframe animation capabilities for a layer property in the render tree. </p> <p><strong>CGAffineTransform:</strong> The...
24,718,557
Get the description of a status code in Python Requests
<p>I would like to be able to enter a server response code and have Requests tell me what the code means. For example, code 200 --> ok</p> <p>I found a link to the <a href="https://github.com/kennethreitz/requests/blob/master/requests/status_codes.py" rel="noreferrer">source code</a> which shows the dictionary structu...
24,718,791
4
0
null
2014-07-13 00:42:05.237 UTC
11
2021-02-05 14:26:14.323 UTC
2014-12-26 18:51:46.22 UTC
null
771,848
null
2,683,104
null
1
43
python|http|python-requests
32,799
<p>One possibility:</p> <pre><code>&gt;&gt;&gt; import requests &gt;&gt;&gt; requests.status_codes._codes[200] ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '\xe2\x9c\x93') </code></pre> <p>The first value in the tuple is used as the conventional code key.</p>
53,118,316
angular 6 or 7: How to import RequestOptions and ResponseContentType in '@angular/common/http'
<p>I have migrated angular 4 code to angular 6 and I want to know how to import below code in angular 6 or 7?</p> <pre><code>import { RequestOptions, ResponseContentType } from '@angular/common/http'; </code></pre>
53,118,376
1
0
null
2018-11-02 12:06:34.437 UTC
4
2019-07-11 15:28:28.567 UTC
2019-07-11 15:28:28.567 UTC
null
8,134,164
null
7,539,550
null
1
12
angular|angular6|angular7
39,264
<p>Pass this way ... </p> <pre><code>import { HttpClient, HttpHeaders } from '@angular/common/http'; let headers = new HttpHeaders({ 'Content-Type': 'application/json' }); let options = { headers: headers } this.http.post(URL, param, options) .subscribe(data =&gt; { console.log(data); }); ...
35,400,674
Find Neo4j nodes where the property is not set
<p>Using Cypher, how can I find a node where a property doesn't exist?</p> <p>For example, I have two nodes:</p> <pre><code>A = {foo: true, name: 'A'}, B = { name: 'B'} </code></pre> <p>Now I'd like to find B, selecting it on the basis of not having the <code>foo</code> property set. How can I do this?</p>
35,402,908
3
0
null
2016-02-15 02:36:24.817 UTC
null
2022-04-30 04:02:08.037 UTC
2019-07-18 04:26:55.527 UTC
null
3,668,967
null
68,672
null
1
32
neo4j|cypher
23,400
<p>As Michael Hunger mentioned</p> <pre><code>MATCH (n) WHERE NOT EXISTS(n.foo) RETURN n </code></pre> <p>On older versions of Neo4j you can use HAS:</p> <pre><code># Causes error with later versions of Neo4j MATCH (n) WHERE NOT HAS(n.foo) RETURN n </code></pre>
28,759,454
Enabling Location mode High Accuracy or Battery saving, programmatically, without user needing to visit Settings
<p><strong><em>Why i ask this:</em></strong>(also the reason for trying it in an app) </p> <p><strong>It happens</strong> when we use <strong>Google Maps in Lollipop</strong>. <em>Even if the Location is disabled, it is turned on, in high accuracy mode after user's input from the Maps app, without having to visit Se...
29,002,760
3
0
null
2015-02-27 07:11:09.56 UTC
22
2019-01-29 04:22:16.373 UTC
2017-04-07 06:34:49.67 UTC
null
2,450,263
null
2,450,263
null
1
21
android|google-play-services|android-5.0-lollipop|android-location|android-settings
34,057
<p><strong><em>UPDATE 3</em></strong>: </p> <p><strong><em><a href="https://developer.android.com/training/location/change-location-settings#prompt" rel="nofollow noreferrer">Prompt the user to change location settings</a></em></strong> as @patrickandroid, mentioned in comments, the link from second update is broken<...
23,925,968
Tomcat vs Vert.x
<p>For the past few days I have been reading Vert.x documents. I know that Vert.x is polyglot, single threaded, non-blocking IO, modular architecture, high scalability. </p> <p>Is there any other major differences between tomcat and Vert.x?</p> <p>Also when we should use tomcat and when to use Vert.x?</p>
24,441,534
2
0
null
2014-05-29 05:00:00.667 UTC
9
2020-05-30 16:59:46.883 UTC
2020-05-07 20:06:17.337 UTC
null
452,775
null
1,280,039
null
1
29
java|tomcat|webserver|vert.x
12,555
<p>Tomcat is a servlet container, so it offers you a platform that helps you to develop and deploy HTTP based applications like web sites or web services.</p> <p>Vert.x instead helps you to develop and deploy any kind of asynchronous applications. It's true that modern versions of Tomcat support asynchronous servlets,...
378,281
Lat/Lon + Distance + Heading --> Lat/Lon
<p>So: I have the following function, adapted from a formula found online, which takes two lat/lon coordinates and finds the distance between them in miles (along a spherical Earth):</p> <pre><code>public static double distance (double lat1, double lon1, double lat2, double lon2) { double theta = toRadians(lon...
378,315
1
2
null
2008-12-18 15:53:55.283 UTC
15
2018-03-05 04:49:51.227 UTC
null
null
null
null
47,450
null
1
17
function|geometry|geospatial
13,699
<p>I get most of those types of formulas from <a href="http://edwilliams.org/avform.htm" rel="nofollow noreferrer">The Aviation Formulary</a>.</p> <p>The formula he gives is:</p> <blockquote> <h3>Lat/lon given radial and distance</h3> <p>A point {lat,lon} is a distance d out on the tc radial from point 1 if:...
38,650,315
why $(window).load() is not working in jQuery?
<p>I'm learning jQuery using visual studio and testing my code in Chrome browser. This is my HTML code</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;script src="jquery-3.1.0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(window)...
38,650,372
4
6
null
2016-07-29 04:01:30.04 UTC
8
2021-08-09 18:06:14.717 UTC
2016-07-29 05:22:39.6 UTC
null
3,329,664
null
5,361,646
null
1
69
jquery
149,548
<p>You're using jQuery version 3.1.0 and the load event is deprecated for use since jQuery version 1.8. The load event is removed from <a href="https://api.jquery.com/load-event/">jQuery 3.0</a>. Instead you can use <a href="http://api.jquery.com/on">on</a> method and bind the JavaScript <a href="https://developer.mozi...
38,532,483
Where is /var/lib/docker on Mac/OS X
<p>I´m looking for the folder <code>/var/lib/docker</code> on my Mac after installing docker for Mac.</p> <p>With <code>docker info</code> I get</p> <pre><code> Containers: 5 ... Server Version: 1.12.0-rc4 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Di...
39,287,126
13
6
null
2016-07-22 17:44:39.8 UTC
72
2022-04-11 14:29:20.513 UTC
2019-11-28 01:21:04.147 UTC
null
868,975
null
2,425,939
null
1
199
macos|docker|docker-for-mac
101,936
<p>See <a href="https://stackoverflow.com/a/37642236/2380457">this answer</a></p> <p>When using Docker for Mac Application, it appears that the containers are stored within the VM located at:</p> <blockquote> <p>~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2</p> </blockquote>
43,767,866
SLURM `srun` vs `sbatch` and their parameters
<p>I am trying to understand what the difference is between SLURM's <a href="https://slurm.schedmd.com/srun.html" rel="noreferrer"><code>srun</code></a> and <a href="https://slurm.schedmd.com/sbatch.html" rel="noreferrer"><code>sbatch</code></a> commands. I will be happy with a general explanation, rather than specific...
43,799,481
2
0
null
2017-05-03 18:49:40.337 UTC
51
2021-01-23 19:02:51.13 UTC
2017-05-03 21:50:27.833 UTC
null
2,593,878
null
2,593,878
null
1
143
parallel-processing|scheduler|jobs|slurm|sbatch
65,642
<p>The documentation says</p> <pre><code>srun is used to submit a job for execution in real time </code></pre> <p>while</p> <pre><code>sbatch is used to submit a job script for later execution. </code></pre> <p>They both accept practically the same set of parameters. The main difference is that <code>srun</code> is int...
34,462,065
Crashlytics (Fabric) separate organizations for application variants (build types, product flavors)
<p><em>This is self-answered question to share my knowledge.</em></p> <p>I have a project with multiple product flavors and I want to integrate Fabric using separate organizations for each product flavor.</p> <p>I tried to integrate Fabric using Android Studio Fabric Plugin. It adds </p> <pre><code>&lt;meta-data ...
34,462,066
3
0
null
2015-12-25 10:34:40.62 UTC
12
2019-01-15 01:55:39.017 UTC
2016-03-11 13:31:03.89 UTC
null
746,347
null
746,347
null
1
32
android|gradle|crashlytics|twitter-fabric|android-productflavors
7,096
<p>During the build <code>fabricGenerateResources</code> task is called and it looks for a file named <code>fabric.properties</code> with following content:</p> <pre><code>apiSecret=YOUR_BUILD_SECRET apiKey=YOUR_API_KEY </code></pre> <p>So all we need is to generate <code>fabric.properties</code> file before this.</p...
7,586,384
Color states with Python's matplotlib/basemap
<p>I want to generate a map of the United States and color each state in using a different shade. Is there a way to do this using Python's basemap?</p>
29,397,692
1
0
null
2011-09-28 16:23:41.953 UTC
10
2015-04-01 18:03:13.03 UTC
null
null
null
null
404,792
null
1
14
python|matplotlib|gis
19,458
<p>There is a nicely formated example in the Basemap repo on GitHub: <a href="https://github.com/matplotlib/basemap/blob/master/examples/fillstates.py">fillstates.py</a>. The shapefile (<a href="https://github.com/matplotlib/basemap/raw/master/examples/st99_d00.dbf">dbf</a> | <a href="https://github.com/matplotlib/base...
22,922,891
Vagrant ssh authentication failure
<p>The problem with ssh authentication:</p> <pre><code>==&gt; default: Clearing any previously set forwarded ports... ==&gt; default: Clearing any previously set network interfaces... ==&gt; default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: bridged ==&g...
22,925,947
32
0
null
2014-04-07 20:53:35.033 UTC
75
2022-08-08 13:05:03.063 UTC
2017-05-23 10:31:29.493 UTC
null
-1
null
753,237
null
1
164
ssh|vagrant|virtualbox|private-key|vagrantfile
208,033
<p>Make sure your first network interface is NAT. The other second network interface can be anything you want when you're building box. Don't forget the Vagrant user, as discussed in the Google thread. </p> <p>Good luck. </p>
24,924,002
How to put a background image on a Bootstrap form?
<p>I'm trying to put a background image on my form (like behind the text and inputs, just like a background image of my web site), using the Bootstrap framework but the image appears at the bottom and I want it inside the "container". </p> <p>My code is something like this:</p> <pre><code>&lt;div class="container"&gt...
24,924,064
2
0
null
2014-07-24 02:07:01.507 UTC
1
2022-02-03 12:56:28.467 UTC
2014-12-28 01:26:53.56 UTC
null
1,476,885
null
2,621,320
null
1
3
html|css|twitter-bootstrap|twitter-bootstrap-3
79,743
<p>Have you tried setting the background image of that container as the image? IE:</p> <pre><code>.container { background-image: url("cs.jpg"); } </code></pre> <p>Or you can do it inline:</p> <pre><code>&lt;div class="container" style="background-image: url('cs.jpg');"&gt; ... &lt;/div&gt; </code></pre>
45,734,357
routing with params in vuejs using router-link
<p>I am trying to build a spa using vuejs in which I have a list of users now when I click a user it should route to a new page with user details of the particular user how to params the user id in router-link</p>
45,734,750
7
1
null
2017-08-17 11:50:05.423 UTC
11
2022-09-15 02:55:32.153 UTC
null
null
null
null
7,906,583
null
1
27
vue.js
44,874
<p>You can pass params in router link using</p> <pre class="lang-html prettyprint-override"><code>&lt;router-link :to=&quot;{ name: 'user', params: { userId: 123 }}&quot;&gt;User&lt;/router-link&gt; </code></pre> <p>Here &quot;name&quot; key parameter defines the name of the route and &quot;params&quot; key defines the...
2,622,804
How to indefinitely pause a thread in Java and later resume it?
<p>Maybe this question has been asked many times before, but I never found a satisfying answer.</p> <p><H3>The problem:</H3><br> <BLOCKQUOTE><P> I have to simulate a process scheduler, using the round robin strategy. I'm using threads to simulate processes and multiprogramming; everything works fine with the JVM manag...
2,622,935
3
3
null
2010-04-12 14:29:52.143 UTC
9
2015-11-29 10:41:08.267 UTC
null
null
null
null
314,603
null
1
20
java|multithreading
14,776
<p>Who said Java is not low level enough?</p> <p>Here is my 3 minute solution. I hope it fits your needs.</p> <pre><code>import java.util.ArrayList; import java.util.List; public class ThreadScheduler { private List&lt;RoundRobinProcess&gt; threadList = new ArrayList&lt;RoundRobinProcess&gt;(); ...
3,093,576
false / FALSE — any difference?
<p>I noticed that some PHP frameworks use exclusively lowercase <code>true</code>/<code>false</code> and others upper.</p> <p>Does it make any difference at all? I for one prefer lowercase.</p>
3,093,581
3
2
null
2010-06-22 13:34:56.487 UTC
5
2018-08-29 16:32:40.72 UTC
2016-11-23 11:23:24.133 UTC
null
107,625
null
276,315
null
1
38
php
11,525
<p>No difference, some people consider FALSE to be a constant and thus use the old screaming caps notation.</p>
3,162,318
Does anyone know of a fork of iText?
<p>Now that iText has gone <a href="http://itextpdf.com/terms-of-use/index.php" rel="noreferrer">AGPL</a>, I'm assuming someone is going to take the old (2.1.7 or <a href="http://itext.svn.sourceforge.net/viewvc/itext/tags/iText_4_2_0/" rel="noreferrer">4.2.0</a>) code and fork it to keep an LGPL version going. Does an...
3,313,191
4
2
null
2010-07-01 23:11:19.437 UTC
11
2019-08-07 14:15:55.077 UTC
null
null
null
null
77,779
null
1
46
java|pdf|itext
10,308
<p>I discussed some practical issues with the iText AGPL license in my blog (which is linked from my SO profile). Why not just buy IText? It is certainly an option among many commercial PDF libraries out there, although they really need to standardize their pricing against the competition.</p> <p>The truth is I never ...
40,590,192
Getting an error - AttributeError: 'module' object has no attribute 'run' while running subprocess.run(["ls", "-l"])
<p>I am running on a AIX 6.1 and using Python 2.7. Want to execute following line but getting an error.</p> <pre><code>subprocess.run(["ls", "-l"]) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; AttributeError: 'module' object has no attribute 'run' </code></pre>
40,590,445
2
5
null
2016-11-14 13:44:58.583 UTC
2
2021-03-03 20:50:06.483 UTC
2016-11-14 13:58:44.837 UTC
null
100,297
null
5,816,183
null
1
39
python|python-2.7|subprocess|aix
85,965
<p>The <a href="https://docs.python.org/3/library/subprocess.html#subprocess.run" rel="noreferrer"><code>subprocess.run()</code> function</a> only exists in Python 3.5 and newer.</p> <p>It is easy enough to backport however:</p> <pre><code>def run(*popenargs, **kwargs): input = kwargs.pop("input", None) check...
51,525,435
What's the difference between Python pip's pip.conf and pypirc file?
<p>I'm having trouble reaching a nexus server that we're using to store custom python packages. I've been told to change the settings in both my <code>~/.pypirc</code> file and the <code>~/.pip/pip.conf</code> file. </p> <p>What's the difference between those two files in how they're used? It seems like the <code>pip ...
51,525,463
1
0
null
2018-07-25 18:24:11.68 UTC
8
2018-07-25 20:15:32.777 UTC
null
null
null
null
1,163,355
null
1
14
python|pip|nexus|pypi
9,911
<p><code>.pypirc</code> is a file standard used by multiple tools, <em>but not by <code>pip</code></em>. For example, the <code>easy_install</code> tool <a href="https://pythonhosted.org/an_example_pypi_project/setuptools.html#intermezzo-pypirc-file-and-gpg" rel="noreferrer">reads that file</a>, as does <a href="https:...
856,706
extract links (URLs), with nokogiri in ruby, from a href html tags?
<p>I want to extract from a webpage all URLs how can I do that with nokogiri?</p> <p>example:</p> <pre> &lt;div class="heat"&gt; &lt;a href='http://example.org/site/1/'&gt;site 1&lt;/a&gt; &lt;a href='http://example.org/site/2/'&gt;site 2&lt;/a&gt; &lt;a href='http://example.org/site/3/'&gt;site 3&lt;/a&gt; ...
856,878
2
1
null
2009-05-13 08:11:11.733 UTC
20
2020-06-25 19:51:26.757 UTC
null
null
null
null
106,072
null
1
42
ruby|parsing|nokogiri
47,324
<p>You can do it like this:</p> <pre><code>doc = Nokogiri::HTML.parse(&lt;&lt;-HTML_END) &lt;div class="heat"&gt; &lt;a href='http://example.org/site/1/'&gt;site 1&lt;/a&gt; &lt;a href='http://example.org/site/2/'&gt;site 2&lt;/a&gt; &lt;a href='http://example.org/site/3/'&gt;site 3&lt;/a&gt; &lt;/div&gt; &lt...
1,253,670
Why do round() and ceil() not return an integer?
<p>Once in a while, I find myself rounding some numbers, and I always have to cast the result to an integer:</p> <pre><code>int rounded = (int) floor(value); </code></pre> <p>Why do all rounding functions (<code>ceil()</code>, <code>floor()</code>) return a floating number, and not an integer? I find this pretty non-...
1,253,686
2
3
null
2009-08-10 08:16:09.34 UTC
5
2013-04-21 22:32:11.5 UTC
2013-04-21 22:32:11.5 UTC
null
957,997
null
56,761
null
1
63
c++|c|casting|rounding
23,506
<p>The integral value returned by these functions may be too large to store in an integer type (int, long, etc.). To avoid an overflow, which will produce undefined results, an application should perform a range check on the returned value before assigning it to an integer type.</p> <p>from the ceil(3...
2,762,260
Detecting a url using preg_match? without http:// in the string
<p>I was wondering how I could check a string broken into an array against a preg_match to see if it started with www. I already have one that check for <a href="http://www">http://www</a>. </p> <pre><code>function isValidURL($url) { return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); ...
2,762,412
5
2
null
2010-05-04 01:29:08.943 UTC
6
2018-03-26 18:33:25.717 UTC
2010-05-04 02:17:11.11 UTC
null
153,995
null
234,631
null
1
13
php|regex|url|preg-match
67,697
<p>You want something like:</p> <pre><code>%^((https?://)|(www\.))([a-z0-9-].?)+(:[0-9]+)?(/.*)?$%i </code></pre> <p>this is using the | to match either <code>http://</code> or <code>www</code> at the beginning. I changed the delimiter to <code>%</code> to avoid clashing with the <code>|</code></p>
2,950,309
viewWillAppear for subviews
<p>I have UIScrollView with multiple UIVIew subviews. I would like to update the data that is displayed by each UIView when they appear in the visible portion of the UIScrollView. </p> <p>What is the callback that gets triggered? I tried viewWillAppear, but it does not seem to get called.</p> <p>Thanks. :)</p>
2,950,979
5
0
null
2010-06-01 13:51:37.623 UTC
17
2020-03-30 19:04:27.947 UTC
null
null
null
null
75,777
null
1
27
iphone|uiview|uiscrollview
17,129
<p>You have to do the calculation yourself. Implement <code>scrollViewDidScroll:</code> in your scroll view delegate and calculate manually which views are visible (e.g. by checking if <code>CGRectIntersectsRect(scrollView.bounds, subview.frame)</code> returns true.</p>
2,659,000
Java - How to find the redirected url of a url?
<p>I am accessing web pages through java as follows:</p> <pre><code>URLConnection con = url.openConnection(); </code></pre> <p>But in some cases, a url redirects to another url. So I want to know the url to which the previous url redirected.</p> <p>Below are the header fields that I got as a response:</p> <pre><cod...
2,659,022
6
0
null
2010-04-17 15:56:26.537 UTC
28
2017-11-29 11:16:45.063 UTC
2010-04-17 16:08:11.503 UTC
null
157,027
null
157,027
null
1
67
java|url|http-headers
112,641
<p>You need to cast the <code>URLConnection</code> to <code>HttpURLConnection</code> and instruct it to <strong>not</strong> follow the redirects by setting <a href="http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html#setInstanceFollowRedirects%28boolean%29" rel="noreferrer"><code>HttpURLConnection#se...
2,395,115
Is there an algorithm to securely split a message into x parts requiring at least y parts to reassemble?
<p>Is there an algorithm to securely split a message into x parts requiring at least y parts to reassemble? Obviously, y &lt;= x.</p> <p>An example:</p> <p>Say that I have a secret message that I only want to be read in the event of my death. As a way to ensure this, I give a fraction of the message to ten friends....
2,395,266
7
1
null
2010-03-07 03:54:33.31 UTC
9
2010-03-08 03:04:11.33 UTC
2010-03-07 04:17:23.217 UTC
null
189,173
null
189,173
null
1
15
algorithm|encryption
2,763
<p><a href="http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing" rel="noreferrer">Shamir Secret Sharing</a> and <a href="http://en.wikipedia.org/wiki/Secret_sharing#Blakley.27s_scheme" rel="noreferrer">Blakley's scheme</a> are two well-established, provably secure means of sharing a secret so that it can be recovere...
2,349,798
In Haskell, how can I use the built in sortBy function to sort a list of pairs(tuple)?
<p>I am a beginner in Haskell so please bear with me. (Just started learning yesterday!) How can I sort a list of tuples primarily by their first components (highest to smallest) and secondarily by their second components (smallest to highest)? A sample input/output would be:</p> <p><code>[(1, "b"), (1, "a"), (2, "b")...
2,349,869
7
0
null
2010-02-28 02:15:40.453 UTC
11
2017-01-17 14:23:54.91 UTC
2012-05-03 18:52:42.113 UTC
null
6,310
null
282,926
null
1
40
sorting|haskell|tuples
38,656
<p>You need to construct your function <code>sortGT</code>, so that it compares pairs the way you want it:</p> <pre><code>sortGT (a1, b1) (a2, b2) | a1 &lt; a2 = GT | a1 &gt; a2 = LT | a1 == a2 = compare b1 b2 </code></pre> <p><br/> Using this you get the following results (I used ghci):</p> <pre><code>*Main D...
2,455,750
Replace duplicate spaces with a single space in T-SQL
<p>I need to ensure that a given field does not have more than one space (I am not concerned about all white space, just space) between characters.</p> <p>So</p> <pre><code>'single spaces only' </code></pre> <p>needs to be turned into </p> <pre><code>'single spaces only' </code></pre> <p>The below will not wo...
2,455,869
15
1
null
2010-03-16 15:37:56.22 UTC
50
2022-07-21 11:01:21.513 UTC
2010-12-01 14:15:22.843 UTC
null
63,550
null
98,795
null
1
125
sql-server|tsql
150,542
<p>Even tidier:</p> <pre><code>select string = replace(replace(replace(' select single spaces',' ','&lt;&gt;'),'&gt;&lt;',''),'&lt;&gt;',' ') </code></pre> <p>Output:</p> <blockquote> <p>select single spaces</p> </blockquote>
3,102,819
Disable same origin policy in Chrome
<p>Is there any way to disable the <a href="https://en.wikipedia.org/wiki/Same_origin_policy" rel="noreferrer">Same-origin policy</a> on Google's <a href="http://en.wikipedia.org/wiki/Google_Chrome" rel="noreferrer">Chrome</a> browser?</p>
3,177,718
34
12
null
2010-06-23 15:00:21.823 UTC
816
2022-08-24 03:56:39.053 UTC
2019-05-15 16:11:44.643 UTC
null
254,343
null
1,785
null
1
2,011
javascript|ajax|google-chrome
2,935,194
<p>Close chrome (or chromium) and restart with the <code>--disable-web-security</code> argument. I just tested this and verified that I can access the contents of an iframe with src="http://google.com" embedded in a page served from "localhost" (tested under chromium 5 / ubuntu). For me the exact command was:</p> <p><...
2,686,855
Is there a JavaScript function that can pad a string to get to a determined length?
<p>I am in need of a JavaScript function which can take a value and pad it to a given length (I need spaces, but anything would do). I found this, but I have no idea what the heck it is doing and it doesn't seem to work for me.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel=...
14,760,377
43
2
null
2010-04-21 21:59:57.86 UTC
65
2022-02-02 09:14:47.163 UTC
2021-09-24 10:46:24.277 UTC
null
295,783
null
22,777
null
1
315
javascript|string
288,065
<p>EcmaScript 2017 added <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart" rel="noreferrer"><code>String.padStart</code></a> (along with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd" rel="noreferrer"><cod...
25,009,072
How to write "good" Julia code when dealing with multiple types and arrays (multiple dispatch)
<p><strong>OP UPDATE:</strong> Note that in the latest version of Julia (v0.5), the idiomatic approach to answering this question is to just define <code>mysquare(x::Number) = x^2</code>. The vectorised case is covered using automatic broadcasting, i.e. <code>x = randn(5) ; mysquare.(x)</code>. See also the new answer ...
25,022,908
2
0
null
2014-07-29 06:02:14.517 UTC
7
2021-06-08 18:42:14.077 UTC
2020-02-23 23:29:48.953 UTC
null
1,667,895
null
1,667,895
null
1
40
arrays|types|julia|multiple-dispatch
3,201
<p>Julia compiles a specific version of your function for each set of inputs as required. Thus to answer part 1, there is no performance difference. The parametric way is the way to go.</p> <p>As for part 2, it might be a good idea in some cases to write a separate version (sometimes for performance reasons, e.g., to ...
23,670,260
How to download a file from the jenkins job build folder
<p>I have a jenkins server running, and for a job I need to download a file which is in the <code>jobs/builds/buildname</code> folder.</p> <p>How to download that file from jenkins job?</p>
23,671,522
6
0
null
2014-05-15 05:52:10.197 UTC
3
2018-10-09 11:26:01.04 UTC
2017-09-26 16:50:08.913 UTC
null
2,702,249
null
2,229,512
null
1
3
jenkins
48,277
<p>If you would use the workspace as suggested by previous post, you can access it within a Pipeline:</p> <pre><code>sh "wget http://&lt;servername:port&gt;/job/&lt;jobname&gt;/ws/index.txt" </code></pre> <p>Or inside a script:</p> <pre><code>wget http://&lt;servername:port&gt;/job/&lt;jobname&gt;/ws/index.txt </cod...
39,887,526
Filter Spark DataFrame based on another DataFrame that specifies denylist criteria
<p>I have a <code>largeDataFrame</code> (multiple columns and billions of rows) and a <code>smallDataFrame</code> (single column and 10,000 rows).</p> <p>I'd like to filter all the rows from the <code>largeDataFrame</code> whenever the <code>some_identifier</code> column in the <code>largeDataFrame</code> matches one o...
39,889,263
2
0
null
2016-10-06 04:27:58.61 UTC
18
2021-11-11 18:20:51.63 UTC
2021-11-11 18:20:51.63 UTC
null
1,386,551
null
1,125,159
null
1
45
dataframe|apache-spark|pyspark|apache-spark-sql
61,420
<p>You'll need to use a <code>left_anti</code> join in this case. </p> <p>The <em>left anti join</em> is the opposite of a <em>left semi join</em>. </p> <p>It filters out data from the right table in the left table according to a given key :</p> <pre><code>largeDataFrame .join(smallDataFrame, Seq("some_identifier...
10,748,253
Idiomatic R code for partitioning a vector by an index and performing an operation on that partition
<p>I'm trying to find the idiomatic way in R to partition a numerical vector by some index vector, find the sum of all numbers in that partition and then divide each individual entry by that partition sum. In other words, if I start with this: </p> <pre><code>df &lt;- data.frame(x = c(1,2,3,4,5,6), index = c('a', 'a...
10,748,470
3
0
null
2012-05-25 03:51:30.45 UTC
13
2013-03-30 15:38:25.327 UTC
2013-03-30 15:38:25.327 UTC
null
559,784
null
271,844
null
1
19
r|functional-programming|plyr
2,888
<p>Yet another option is <code>ave</code>. For good measure, I've collected the answers above, tried my best to make their output equivalent (a vector), and provided timings over 1000 runs using your example data as an input. First, my answer using <code>ave</code>: <code>ave(df$x, df$index, FUN = function(z) z/sum(z))...
10,376,253
Windows service - get current directory
<p>I have a Windows service that should look for a configuration file in its current directory.</p> <p>So I use <code>directory.getcurrentdirectiry()</code> but instead of the service directory I get back </p> <pre><code>c:\windows\system32 </code></pre> <p>Any idea why and how should I get the service directory?</p...
36,631,061
5
0
null
2012-04-29 21:41:40.43 UTC
11
2021-06-22 05:26:31.653 UTC
2012-04-30 05:04:06.077 UTC
null
13,302
null
963,701
null
1
70
c#|windows-services|working-directory
71,830
<p>Don't use <code>Directory.GetCurrentDirectory()</code>. I had the same exact problem with <em>C:\Windows\System32</em> being returned. Use this instead:</p> <p><code>Path.GetDirectoryName(Application.ExecutablePath);</code></p>
10,308,110
Simplest way to download and unzip files in Node.js cross-platform?
<p>Just looking for a simple solution to downloading and unzipping <code>.zip</code> or <code>.tar.gz</code> files in Node.js on any operating system.</p> <p>Not sure if this is built in or I have to use a separate library. Any ideas? Looking for just a couple lines of code so when the next zip file comes that I wan...
10,314,258
12
0
null
2012-04-25 01:13:06.48 UTC
26
2021-07-14 22:47:56.453 UTC
null
null
null
null
169,992
null
1
102
node.js|zip
186,233
<p>Node has builtin support for gzip and deflate via the <a href="http://nodejs.org/api/zlib.html">zlib module</a>:</p> <pre><code>var zlib = require('zlib'); zlib.gunzip(gzipBuffer, function(err, result) { if(err) return console.error(err); console.log(result); }); </code></pre> <p><strong>Edit:</strong> Y...
10,381,827
handlerbars.js check if list is empty
<p>Is there a way in Handlebars.js templating to check if the collection or list is null or empty, before going and iterating through the list/collection?</p> <pre><code>// if list is empty do some rendering ... otherwise do the normal {{#list items}} {{/list}} {{#each items}} {{/each}} </code></pre>
11,597,069
5
0
null
2012-04-30 10:06:07.973 UTC
10
2018-06-05 07:14:45.56 UTC
null
null
null
null
6,482
null
1
138
handlebars.js
78,506
<p>The "each" tag can take an "else" section too. So the simplest form is:</p> <pre><code>{{#each items}} // render item {{else}} // render empty {{/each}} </code></pre>
10,282,532
Entity Framework - Start Over - Undo/Rollback All Migrations
<p>For some reason, my migrations appear to have been jumbled/corrupted/whatever. I'm at the point where I just want to start over, so is there a way to completely undo all migrations, erase the history, and delete the migration code, so I'm back to square one?</p> <p>e.g.) <code>PM&gt; Disable-Migrations</code> or <...
10,282,630
5
0
null
2012-04-23 14:28:43.687 UTC
56
2020-05-17 09:56:46.32 UTC
null
null
null
null
1,037,948
null
1
173
entity-framework|entity-framework-4.3|entity-framework-migrations
90,059
<p>You can rollback to any migration by using:</p> <pre><code>Update-Database -TargetMigration:"MigrationName" </code></pre> <p>If you want to rollback all migrations you can use:</p> <pre><code>Update-Database -TargetMigration:0 </code></pre> <p>or equivalent:</p> <pre><code>Update-Database -TargetMigration:$Init...
6,297,923
Override SHIFT + CTRL + Z in Notepad++
<p>Hello I use Notepad++ for a lot of my development.<br> One of the things that I do not like about it is the way you perform a redo by pressing <kbd>CTRL</kbd> + <kbd>Y</kbd> and when you press <kbd>SHIFT</kbd> + <kbd>CTRL</kbd> + <kbd>Z</kbd> you get <code>sub</code></p> <p>Is there a plugin or a way to override th...
6,297,954
2
6
null
2011-06-09 19:07:52.58 UTC
4
2018-06-19 16:13:41.993 UTC
2013-01-25 11:46:35.647 UTC
null
729,489
null
102,526
null
1
57
notepad++
14,954
<p>You could try the 'shortcut mapper' under the Settings menu.</p> <p>It seems that this key is not found in the normal Main menu commands, but it's the SCI_REDO command in the Scintalla tab. Whatever that may mean. ;) </p>
19,694,503
ajax, setRequestHeader(), Content-Type, application/x-www-form-urlencoded and charset
<p>I am having trouble understanding how to set the charset when the content type is not text/html, text/plain, or text/xml, but is application/x-www-form-urlencoded content type instead.</p> <p>Given this (simplified) javascript code:</p> <pre><code>var xhr = new XMLHttpRequest(); </code></pre> <p>If I <strong>do n...
24,415,321
2
0
null
2013-10-30 21:53:33.807 UTC
5
2022-01-28 09:54:45.07 UTC
2013-10-31 13:34:08.967 UTC
null
2,855,955
null
2,855,955
null
1
10
javascript|ajax|character-encoding
63,977
<p>The <code>application/x-www-form-urlencoded</code> mime type does not support parameters (such as <code>charset</code>). If you look at <a href="http://www.w3.org/TR/html5/forms.html#url-encoded-form-data" rel="noreferrer">this section</a> of the HTML5 spec, you will see how charset is determined (it's complicated)....
41,040,702
ASP.NET Identity (with IdentityServer4) get external resource oauth access token
<p>I have been through the docs of identityServer4 and I have set it up to use Microsoft Office 365 as a login provider. When the user has logged in I want to make a button where he can allow my app to subscribe to his calendar events using the webhooks api of graph.microsoft.com</p> <p>The code in startup.cs</p> <pr...
41,163,741
1
0
null
2016-12-08 13:29:40.977 UTC
8
2019-09-20 03:04:28.763 UTC
2016-12-15 11:56:34.657 UTC
null
1,387,545
null
1,387,545
null
1
8
c#|oauth|asp.net-identity|identityserver4|asp.net-identity-3
7,381
<p>Ok, so I finally got this working. I have created a new project that is using <code>ASP.Net Identity</code> and <code>IdentityServer4</code> both build on top of <code>ASP.Net Core</code>.</p> <p>The problem was that I wasn't completely aware of the flow that was used in the external login process.</p> <p>If you u...
32,181,893
Sql server update multiple columns from another table
<p>I have read lots of post about how to update multiple columns but still can't find right answer.</p> <p>I have one table and I would like update this table from another table.</p> <pre><code>Update table1 set (a,b,c,d,e,f,g,h,i,j,k)=(t2.a,t2.b,t2.c,t2.d,t2.e,t2.f,t2.g,t2.h,t2.i,t2.j,t2.k) from ( SELECT ..... w...
32,181,923
4
0
null
2015-08-24 12:05:01.22 UTC
2
2020-07-23 08:01:36.75 UTC
2015-08-24 12:13:32.787 UTC
null
4,560,953
null
3,747,585
null
1
15
sql|sql-server|sql-server-2008
46,286
<p>TSQL does not support <a href="https://connect.microsoft.com/SQLServer/feedback/details/299231/add-support-for-ansi-standard-row-value-constructors" rel="noreferrer">row-value constructor</a>. Use this instead:</p> <pre><code>UPDATE table1 SET a = t2.a, b = t2.b, (...) FROM ( SELECT ..... with join ... WH...
21,402,081
Issue in Global.asax.cs page in MVC4
<p>I my ASP.NET MVC 4 Project, my <code>Global.asax.cs</code> page shows the error on</p> <pre><code> WebApiConfig.Register(GlobalConfiguration.Configuration); </code></pre> <blockquote> <p><strong>The name 'GlobalConfiguration' does not exist in the current context</strong></p> </blockquote> <p>I have done many c...
21,402,541
7
1
null
2014-01-28 09:49:13.463 UTC
3
2019-05-16 15:09:47.033 UTC
2015-02-27 15:51:45.767 UTC
null
2,319,844
null
2,677,745
null
1
46
c#|asp.net|asp.net-mvc|asp.net-mvc-4
53,930
<p>Make sure you have assembly <code>System.Web.Http.WebHost.dll</code> referenced. This is where GlobalConfiguration is.</p>
19,278,515
Use StringFormat to add a string to a WPF XAML binding
<p>I have a WPF 4 application that contains a TextBlock which has a one-way binding to an integer value (in this case, a temperature in degrees Celsius). The XAML looks like this:</p> <pre><code>&lt;TextBlock x:Name="textBlockTemperature"&gt; &lt;Run Text="{Binding CelsiusTemp, Mode=OneWay}"/&gt;&lt;/TextBloc...
19,278,672
4
0
null
2013-10-09 17:14:18.297 UTC
26
2020-02-18 20:33:09.25 UTC
2019-09-25 15:29:03.86 UTC
null
285,795
null
685,869
null
1
144
c#|wpf|xaml|data-binding|string-formatting
227,010
<p>Your first example is effectively what you need:</p> <pre><code>&lt;TextBlock Text="{Binding CelsiusTemp, StringFormat={}{0}°C}" /&gt; </code></pre>
30,145,812
How to console.log an object definition and a text in same string?
<p>I have this JavaScript code:</p> <pre><code>console.log(obj);// [query: "wordOfTheDay"] console.log(note + " : " + obj ); // obj does not show up </code></pre> <p>I want to make "obj" display in the same string as "note" no matter the type it come in as.</p> <p>For example:</p> <pre><code>console.log("text sampl...
30,145,881
6
1
null
2015-05-09 22:45:43.973 UTC
4
2022-04-13 05:34:52.45 UTC
null
null
null
null
813,363
null
1
40
javascript|object|concatenation|console.log
30,363
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Console/log" rel="noreferrer"><code>console.log</code> accepts any number of parameters</a>, so just send each piece as its own param. That way you keep the formatting of the object in the console, and its all on one entry.</p> <p><div class="snippet" data-l...
30,232,146
Dynamically Populating Drop down list from selection of another drop down value
<p>My requirement is that for a selection in a 'meal' drop down list, a second drop down list 'category' should get dynamically populated with values related to the selection in first drop down list. Then depending on what is selected in the meal dropdown, the list should change in category. I have written the followin...
30,232,604
3
2
null
2015-05-14 07:53:20.477 UTC
15
2022-08-30 11:48:15.293 UTC
2015-05-14 10:11:51.523 UTC
null
449,429
null
2,514,121
null
1
18
javascript|html
102,464
<p>Hope this might help you.</p> <p><a href="http://jsfiddle.net/k148pk76/1/" rel="nofollow noreferrer">JSFiddle : DEMO</a></p> <p><strong>HTML</strong></p> <pre><code>&lt;select name=&quot;meal&quot; id=&quot;meal&quot; onChange=&quot;changecat(this.value);&quot;&gt; &lt;option value=&quot;&quot; disabled selected...
8,916,107
Data.Text vs Data.ByteString.Char8
<p>Can anyone explain the pros and cons to using <code>Data.Text</code>and <code>Data.ByteString.Char8</code> data types? Does working with ASCII-only text change these pros and cons? Do their lazy variants change the story as well?</p>
8,916,190
1
0
null
2012-01-18 19:28:21.747 UTC
10
2012-01-18 19:39:30.2 UTC
null
null
null
null
239,916
null
1
22
haskell|text|bytestring
2,915
<p><code>Data.ByteString.Char8</code> provides functions to treat <code>ByteString</code> values as sequences of 8-bit ASCII characters, while <code>Data.Text</code> is an independent type supporting the entirety of Unicode.</p> <p><code>ByteString</code> and <code>Text</code> are essentially the same, as far as repre...
8,723,229
How to generate unique object id in mongodb
<p>When I use Mongodb with Java, I want to generate Object id at clients. Before I insert a record, however, I have to query mongodb first to make sure that the id generated by ObjectId() method is unique. Is there any way that I can generate unique object id without accessing mongodb twice?</p>
8,723,315
3
0
null
2012-01-04 07:07:03.25 UTC
4
2017-03-18 18:00:35.647 UTC
2012-01-04 07:09:35.207 UTC
null
125,816
null
1,664,669
null
1
37
java|mongodb
111,982
<p>Object IDs are not like sequential ids you use in a RDMS. If they are properly generated according to the <a href="http://www.mongodb.org/display/DOCS/Object+IDs#ObjectIDs-BSONObjectIDSpecification">Object ID specification</a> you will not need to worry about them being unique.</p> <p>All you have to do is ensure y...