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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,250,749 | Using Windows Python from Cygwin | <p>I've been using Cygwin on Windows recently. I want to use the Windows installation of Python, so during testing I'm using <code>/cygdrive/c/Python26/python.exe myfile.py</code> rather than <code>python myfile.exe</code>.</p>
<p>This is working almost perfectly, except for printing. When I run the Windows Python fro... | 3,250,975 | 3 | 2 | null | 2010-07-14 21:38:54.853 UTC | 28 | 2012-09-04 13:08:37.65 UTC | null | null | null | null | 49,376 | null | 1 | 63 | python|windows|cygwin | 78,875 | <p>Perhaps if you flush the output</p>
<pre><code>import sys
V = range(100000)
for x in V:
print x
sys.stdout.flush()
</code></pre> |
20,470,874 | How do you "rollback" last commit on Mercurial? | <p>I have a Mercurial repository that I use in local only... It's for my personal usage (so I don't "push" anywhere).</p>
<p>I made a commit with 3 files, but after that I understood that I should do commit 4 files...</p>
<p>Is there a way to "rollback" my <strong>last</strong> (latest, only one) commit, and "recommi... | 20,471,145 | 3 | 4 | null | 2013-12-09 12:37:24.51 UTC | 10 | 2018-05-08 22:41:09.81 UTC | 2015-12-14 12:12:34.207 UTC | null | 74,694 | null | 185,593 | null | 1 | 72 | mercurial|commit|rollback | 106,568 | <p>You just need this command:</p>
<pre><code>hg rollback
</code></pre>
<p>See: <a href="http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html" rel="noreferrer">http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html</a>.</p>
<p>(Technically, this is deprecated as of version 2.7, August 2013, but... |
11,264,470 | How to POST content with an HTTP Request (Perl) | <pre><code>use LWP::UserAgent;
use Data::Dumper;
my $ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
my $req = new HTTP::Request POST => 'http://example.com';
$req->content('port=8', 'target=64'); #problem
my $res = $ua->request($req);
print Dumper($res->content);
</code></pre>
... | 11,264,534 | 3 | 0 | null | 2012-06-29 15:19:45.373 UTC | 5 | 2021-06-21 18:20:45.273 UTC | 2018-05-21 17:12:55.88 UTC | null | 622,310 | null | 937,922 | null | 1 | 12 | perl|http|lwp | 47,557 | <pre><code>my $ua = LWP::UserAgent->new();
my $request = POST( $url, [ 'port' => 8, 'target' => 64 ] );
my $content = $ua->request($request)->as_string();
</code></pre> |
10,903,100 | Using the remote function of jquery validation | <p>I'm trying to figure out how I can turn this:</p>
<pre><code>$('#username').blur(function(){
$.post('register/isUsernameAvailable',
{"username":$('#username').val()},
function(data){
if(data.username == "found"){
alert('username already in use');
... | 10,903,307 | 8 | 6 | null | 2012-06-05 18:49:26.447 UTC | 5 | 2020-05-29 08:24:31.837 UTC | 2012-06-05 23:42:03.053 UTC | null | 1,244,239 | null | 1,244,239 | null | 1 | 12 | jquery|jquery-validate | 74,212 | <p>Well I dunno bout your plugin concept specifically but I gather you want it to check to see with that plugin if the username is greater than 6 or less than 12. Which from your core example with jQuery without the plugin it would be as simple as adding one little if-else to the concept. </p>
<pre><code>$('#username'... |
10,904,476 | JS Google Maps API v3 Animate Marker Between Coordinates | <p>I have a simple javascript maps application that I'm working on that requires me to animate the movement of multiple markers between different coords. Each marker is free to move on its own and all markers are stored in an array list. However, I have been having trouble getting them to smoothly transition locations.... | 10,906,464 | 4 | 0 | null | 2012-06-05 20:30:53.773 UTC | 13 | 2022-07-01 09:01:59.85 UTC | null | null | null | null | 1,438,300 | null | 1 | 13 | javascript|google-maps|animation|google-maps-api-3|google-maps-markers | 47,461 | <p>My quick-and-dirty approach does not involve a ton of research :(</p>
<p>Here's the demo: <a href="https://web.archive.org/web/20130814022900/http://jsfiddle.net:80/yV6xv/4/" rel="noreferrer">http://jsfiddle.net/yV6xv/4/</a> Click on a marker to begin moving it, after it stops, you can click again to go back to its... |
11,065,252 | What is the point of jQuery ajax accepts attrib? Does it actually do anything? | <p>Spent a solid hour trying to sort out why on earth this (coffeescript)</p>
<pre><code>$.ajax
accepts: "application/json; charset=utf-8"
</code></pre>
<p>did <em>absolutely nothing</em> to change the accepts header, while this</p>
<pre><code>$.ajax
dataType: "json"
</code></pre>
<p>properly sets the accepts h... | 11,065,286 | 1 | 0 | null | 2012-06-16 16:40:57.03 UTC | 5 | 2016-07-07 15:15:56.99 UTC | null | null | null | null | 185,840 | null | 1 | 30 | jquery|types|header|set|response | 24,827 | <p>As always the <a href="http://api.jquery.com/jQuery.ajax/" rel="noreferrer">documentation</a> is your friend:</p>
<blockquote>
<p><strong>accepts</strong></p>
<p>Default: depends on DataType </p>
<p>The content type sent in the
request header that tells the server what kind of response it will
accep... |
11,052,744 | How to efficiently remove a query string by Key from a Url? | <p>How to remove a query string by Key from a Url?</p>
<p>I have the below method which works fine but just wondering is there any better/shorter way? or a built-in .NET method which can do it more efficiently?</p>
<pre><code> public static string RemoveQueryStringByKey(string url, string key)
{
v... | 11,080,157 | 16 | 4 | null | 2012-06-15 14:32:51.237 UTC | 8 | 2022-09-21 12:34:22.763 UTC | null | null | null | null | 133,212 | null | 1 | 43 | c#|.net|regex|url|query-string | 81,812 | <p>This works well:</p>
<pre><code>public static string RemoveQueryStringByKey(string url, string key)
{
var uri = new Uri(url);
// this gets all the query string key value pairs as a collection
var newQueryString = HttpUtility.ParseQueryString(uri.Query);
// this removes the key i... |
11,353,679 | What's the recommended way to connect to MySQL from Go? | <p>I am looking for a reliable solution to connect to a MySQL database from Go. I've seen some libraries around, but it is difficult to determine the different states of completeness and current maintenance. I don't have complex needs, but I'd like to know what people are relying on or the most standard solution to con... | 11,357,116 | 3 | 0 | null | 2012-07-05 23:00:36.03 UTC | 78 | 2022-03-29 08:01:49.453 UTC | 2022-03-29 08:00:24.633 UTC | null | 8,712,494 | null | 78,640 | null | 1 | 169 | mysql|database|go | 72,130 | <p>A few drivers are available but you should only consider those that implement the <a href="http://golang.org/pkg/database/sql/">database/sql</a> API as</p>
<ul>
<li>it provides a clean and efficient syntax,</li>
<li>it ensures you can later change the driver without changing your code, apart the import and connecti... |
12,749,622 | Understanding how to create a heap in Python | <p>The <code>collections.Count.most_common</code> function in Python uses the <code>heapq</code> module to return the count of the most common word in a file, for instance.</p>
<p>I have traced through the <code>heapq.py</code> file, but I'm having a bit of trouble understanding how a heap is created/updated with resp... | 12,749,951 | 4 | 1 | null | 2012-10-05 15:40:29.253 UTC | 14 | 2020-04-29 06:42:06.623 UTC | 2020-04-29 06:42:06.623 UTC | null | 555,030 | null | 1,158,977 | null | 1 | 31 | python|heap | 56,981 | <p>this is a slightly modified version of the code found here : <a href="http://code.activestate.com/recipes/577086-heap-sort/">http://code.activestate.com/recipes/577086-heap-sort/</a></p>
<pre><code>def HeapSort(A,T):
def heapify(A):
start = (len(A) - 2) / 2
while start >= 0:
siftD... |
13,221,769 | Node.JS: How to pass variables to asynchronous callbacks? | <p>I'm sure my problem is based on a lack of understanding of asynch programming in node.js but here goes.</p>
<p>For example: I have a list of links I want to crawl. When each asynch request returns I want to know which URL it is for. But, presumably because of race conditions, each request returns with the URL set t... | 13,221,877 | 3 | 0 | null | 2012-11-04 18:59:48.757 UTC | 18 | 2016-11-25 22:28:51.717 UTC | 2016-11-25 22:28:51.717 UTC | null | 3,853,934 | null | 279,255 | null | 1 | 46 | javascript|node.js|asynchronous|web-crawler | 48,790 | <p>Your <code>url</code> variable is not scoped to the <code>for</code> loop as JavaScript only supports global and function scoping. So you need to create a function scope for your <code>request</code> call to capture the <code>url</code> value in each iteration of the loop by using an immediate function:</p>
<pre><... |
22,298,005 | How to find schema name in Oracle ? when you are connected in sql session using read only user | <p>I am connected to a oracle database with a read only user and i used service name while Setting up connection in sql developer hence i dont know SID ( schema ).</p>
<p>How can i find out schema name which i am connected to ?</p>
<p>I am looking for this because i want to <a href="https://stackoverflow.com/question... | 22,351,196 | 3 | 13 | null | 2014-03-10 10:44:30.167 UTC | 2 | 2020-09-26 13:52:38.723 UTC | 2017-05-23 11:47:13.79 UTC | null | -1 | null | 2,922,515 | null | 1 | 25 | sql|oracle11g | 247,043 | <p>To create a read-only user, you have to setup a different user than the one owning the tables you want to access.</p>
<p>If you just create the user and grant SELECT permission to the read-only user, you'll need to prepend the schema name to each table name. To avoid this, you have basically two options:</p>
<ol>
... |
16,609,724 | Using current time in UTC as default value in PostgreSQL | <p>I have a column of the <code>TIMESTAMP WITHOUT TIME ZONE</code> type and would like to have that default to the current time in UTC. Getting the current time in UTC is easy:</p>
<pre><code>postgres=# select now() at time zone 'utc';
timezone
----------------------------
2013-05-17 12:52:51.3374... | 16,610,360 | 6 | 0 | null | 2013-05-17 13:00:50.147 UTC | 39 | 2019-03-22 12:11:02.953 UTC | 2018-10-22 13:55:10.607 UTC | null | 1,828,296 | null | 211,490 | null | 1 | 237 | postgresql|timezone|timestamp | 253,051 | <p>A function is not even needed. Just put parentheses around the default expression:</p>
<pre><code>create temporary table test(
id int,
ts timestamp without time zone default (now() at time zone 'utc')
);
</code></pre> |
25,622,894 | java.security.InvalidKeyException: invalid key format on generating RSA public key | <p>Background:</p>
<p>I have created an applet to extract public key of a certificate extracted from a smart card.
This public key is then stored in database.
The private key of certificate is used to sign data and the public key is then used to verify the signature.
Code for extracting public key from certificate:</p... | 25,623,417 | 1 | 4 | null | 2014-09-02 11:59:33.723 UTC | 5 | 2014-09-02 12:25:27.88 UTC | 2014-09-02 12:22:58.513 UTC | null | 474,189 | null | 3,619,997 | null | 1 | 6 | java|rsa|public-key-encryption|x509|public-key | 48,827 | <p>You must have an error in the way you read the key back from the database. The following code works just fine for me:</p>
<pre><code>String key = "3082012230..."; // full key omitted for brevity
byte[] derPublicKey = DatatypeConverter.parseHexBinary(key);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
X509... |
4,705,564 | Python script as linux service/daemon | <p>Hallo,</p>
<p>I'm trying to let a python script run as service (daemon) on (ubuntu) linux.</p>
<p>On the web there exist several solutions like:</p>
<p><a href="http://pypi.python.org/pypi/python-daemon/" rel="noreferrer">http://pypi.python.org/pypi/python-daemon/</a></p>
<blockquote>
<p>A well-behaved Unix da... | 4,706,394 | 2 | 0 | null | 2011-01-16 13:20:57.15 UTC | 60 | 2014-02-14 00:34:56.437 UTC | null | null | null | null | 405,559 | null | 1 | 72 | python|linux|service|daemon | 74,862 | <p>Assuming your daemon has some way of continually running (some event loop, twisted, whatever), you can try to use <code>upstart</code>.</p>
<p>Here's an example upstart config for a hypothetical Python service:</p>
<pre><code>description "My service"
author "Some Dude <blah@foo.com>"
start on runlevel [234... |
26,750,814 | how to make synchronous http request in angular js | <p>How to make blocking http request in AngularJS so that i can use the $http response on very next line? </p>
<p>In the following example, <code>$http</code> object doesn't return the result to the next line so that I can pass this result to <code>fullcalender()</code>, a JavaScript library, because <code>$scope.data... | 26,752,424 | 3 | 4 | null | 2014-11-05 06:14:02.233 UTC | 4 | 2017-08-14 13:54:07.483 UTC | 2017-08-14 13:54:07.483 UTC | null | 2,275,011 | null | 3,631,271 | null | 1 | 20 | angularjs | 55,609 | <p>You can use <a href="https://docs.angularjs.org/api/ng/service/$q" rel="nofollow">promises</a> for that.</p>
<p>here is an example:</p>
<pre><code>$scope.myXhr = function(){
var deferred = $q.defer();
$http({
url: 'ajax.php',
method: 'POST',
data:postData,
headers: {'Conte... |
10,034,537 | persistent vs immutable data structure | <p>Is there any difference in a persistent and immutable data structure? Wikipedia refers to immutable data structure when discussing persistence but I have a feeling there might be a subtle difference between the two.</p> | 12,550,660 | 2 | 0 | null | 2012-04-05 19:09:10.563 UTC | 10 | 2012-09-23 07:55:38.467 UTC | null | null | null | null | 1,094,640 | null | 1 | 20 | data-structures|immutability|object-persistence | 10,132 | <p><em>Immutability</em> is an implementation technique. Among other things, it provides <em>persistence</em>, which is an interface. The persistence API is something like:</p>
<ul>
<li><code>version update(operation o, version v)</code> performs operation <code>o</code> on version <code>v</code>, returning a new vers... |
10,097,417 | How do I create an Autoscrolling TextBox | <p>I have a WPF application that contains a multiline TextBox that is being used to display debugging text output. </p>
<p>How can I set the TextBox so that as text is appended to the box, it will automatically scroll to the bottom of the textbox?</p>
<ul>
<li>I'm using the MVVM pattern.</li>
<li>Ideally a pure XAML ... | 10,132,405 | 6 | 3 | null | 2012-04-10 22:33:17.343 UTC | 13 | 2015-01-14 09:55:31.657 UTC | 2012-04-13 04:33:48.323 UTC | null | 546,730 | null | 5,007 | null | 1 | 27 | wpf|xaml|mvvm | 19,820 | <p>The answer provided by @BojinLi works well.
After reading through the answer linked to by @GazTheDestroyer however, I decided to implement my own version for the TextBox, because it looked cleaner.</p>
<p>To summarize, you can extend the behavior of the TextBox control by using an attached property. (Called ScrollO... |
10,125,568 | how to randomly choose multiple keys and its value in a dictionary python | <p>I have a dictionary like this:</p>
<pre><code>user_dict = {
user1: [(video1, 10),(video2,20),(video3,1)]
user2: [(video1, 4),(video2,8),(video6,45)]
...
user100: [(video1, 46),(video2,34),(video6,4)]
}
(video1,10) means (videoid, number ... | 10,125,602 | 4 | 0 | null | 2012-04-12 14:23:50.76 UTC | 1 | 2021-04-06 09:43:04.56 UTC | null | null | null | null | 504,283 | null | 1 | 28 | python | 40,298 | <p>That's what <a href="http://docs.python.org//library/random.html?highlight=random.choice#random.sample" rel="noreferrer"><code>random.sample()</code></a> is for:</p>
<blockquote>
<p>Return a k length list of unique elements chosen from the population sequence. Used for random sampling without replacement.</p>
</b... |
9,998,672 | Winforms - how to show/hide elements in designer? | <p>I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.</p>
<p>My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stac... | 9,998,893 | 7 | 1 | null | 2012-04-03 17:52:45.653 UTC | 8 | 2020-11-02 21:30:14.793 UTC | 2018-03-14 11:34:48.64 UTC | null | 397,817 | null | 1,139,585 | null | 1 | 31 | winforms|visual-studio|visual-studio-2010 | 34,013 | <p>Several options here:</p>
<ol>
<li>Use the <code>Document Outline</code> view (<code>View --> Other Windows --> Document Outline</code>) to select the panel you care about. You can right-click on it and choose <code>Bring to Front</code> to put it in front of everything else.</li>
<li>Though it's probably not... |
10,103,604 | linux command line: du --- how to make it show only total for each directories | <p>I am doing it by (with coreutils_8.5-1ubuntu6_amd64):</p>
<pre><code>du -sch `find ./ -maxdepth 1 -type d`
</code></pre>
<p>I am looking for a simple way (shorter cmd) to find <strong>size of subdirectories</strong>. Thank you.</p> | 10,103,709 | 8 | 0 | null | 2012-04-11 09:51:53.803 UTC | 22 | 2021-04-04 05:07:59.19 UTC | 2012-04-11 09:59:43.973 UTC | null | 451,718 | null | 451,718 | null | 1 | 91 | linux|command-line | 109,674 | <p>This works with coreutils 5.97:</p>
<p><code>du -cksh *</code></p> |
7,935,292 | android: camera onPause/onResume issue | <p>I have some troubles with the onPause() onResume() camera live cycle:
Camera with preview, and taking photos works totally fine. With one exceptions:</p>
<p>I start the app, click the home button, switch back to the app and take another shot.</p>
<p>Result: shuttercallback is still executed (see code), but jpeg ca... | 8,805,285 | 3 | 0 | null | 2011-10-28 21:52:24.833 UTC | 9 | 2018-01-27 17:05:56.553 UTC | null | null | null | null | 457,059 | null | 1 | 12 | android|camera|galaxy | 22,244 | <p>This is how I fixed it 100%, finally (working on every device I tried it on, including Galaxy S):</p>
<p>I destroyed the camere preview object onResume and reinstantiated all together (like on startup). More details here:</p>
<p><a href="https://stackoverflow.com/questions/8481402/android-i-get-no-stacktrace-phone... |
7,709,030 | Get GPS Location in a Broadcast Receiver/or Service to Broadcast Receiver data transfer | <p>I am new to android.<br>
I want to get GPS Location in a broadcast receiver but it shows an error.</p>
<p>My code is :</p>
<pre><code>public void onReceive(Context context, Intent intent) {
LocationManager locManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
// errors i... | 7,783,888 | 3 | 0 | null | 2011-10-10 05:58:44.833 UTC | 14 | 2017-05-29 14:35:35.62 UTC | 2013-05-09 22:18:09.213 UTC | null | 281,545 | null | 371,720 | null | 1 | 18 | android|service|broadcastreceiver | 43,468 | <p>From BroadcastReceiver I could not start Location Manager as well. So I started a service on BroadcastReceiver and in that service I manipulated Location Manager. I think I found this solution in Android development documentation. You also can start Activity instead of Service.</p>
<p>Here is the code of switch to ... |
11,936,950 | Inserting UTF-8 encoded string into UTF-8 encoded mysql table fails with "Incorrect string value" | <p>Inserting UTF-8 encoded string into UTF-8 encoded table gives incorrect string value.</p>
<blockquote>
<p>PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9D\x84\x8E i...' for column 'body_value' at row 1: INSERT INTO</p>
</blockquote>
<p>I have a <code></code> character, in a st... | 11,948,519 | 4 | 5 | null | 2012-08-13 14:59:28.743 UTC | 6 | 2020-07-15 00:04:20.097 UTC | 2017-05-23 11:47:15.633 UTC | null | -1 | null | 1,147,744 | null | 1 | 14 | php|mysql|drupal | 39,086 | <p> (U+1D10E) is a character Unicode found outside the BMP (Basic Multilingual Plane) (above U+FFFF) and thus can't be represented in UTF-8 in 3 bytes. MySQL charset utf8 only accepts UTF-8 characters if they can be represented in 3 bytes. If you need to store this in MySQL, you'll need to use MySQL charset utf8mb4. Yo... |
11,467,746 | "Return without GoSub" when using subforms in Access | <p>Why do I get a </p>
<blockquote>
<p>"Return without GoSub"</p>
</blockquote>
<p>error when using subforms in Access 2007?</p> | 11,467,748 | 5 | 0 | null | 2012-07-13 09:29:18.69 UTC | 1 | 2019-05-31 15:12:43.317 UTC | 2018-05-31 13:02:40.82 UTC | null | 709,443 | null | 709,443 | null | 1 | 16 | ms-access|ms-access-2007|vba | 50,589 | <p>This can occur when there is a <code>Form_Load()</code> event in the subform, but not the main form. Try adding an <code>empty Form_Load()</code> event to the main form.</p> |
11,457,328 | What is _In_ in C++? | <p>I have searched this up rather a lot, but come up with no helpful results.</p>
<p>I am currently trying to program simple DirextX game for Windows 8 Metro, and have come across <code>_In_</code> rather a lot. I'm just wondering what it is.</p>
<p>Also, I have seen a lot of the use of <code>^</code> as the pointer ... | 11,457,407 | 4 | 5 | null | 2012-07-12 17:29:53.307 UTC | 8 | 2021-05-09 13:55:49.183 UTC | 2013-02-13 02:27:52.337 UTC | null | 480,894 | null | 1,486,106 | null | 1 | 35 | c++|c|microsoft-metro|c++-cx | 27,631 | <p>It is a <a href="http://msdn.microsoft.com/en-us/library/hh916383(v=vs.110).aspx" rel="noreferrer">SAL annotation</a>, used for code analysis. The annotations themselves are defined as macros that, in normal builds, expand to nothing.</p>
<p>The <code>^</code> and <code>ref class</code> are features of <a href="ht... |
11,589,770 | input type="text" vs input type="search" in HTML5 | <p>I'm new to HTML5 as begun to work with HTML5's new form input fields. When I'm working with form input fields, especially <code><input type="text" /></code> and <code><input type="search" /></code> IMO there wasn't any difference in all major browser including Safari, Chrome, Firefox and Opera. And the s... | 11,589,805 | 10 | 1 | null | 2012-07-21 05:33:48.01 UTC | 15 | 2017-11-06 08:25:01.973 UTC | 2014-01-04 11:16:35.82 UTC | null | 562,769 | null | 972,501 | null | 1 | 155 | forms|html|input | 84,876 | <p>Right now, there isn't a huge deal between them - maybe there never will be.
However, the point is to give the browser-makers the ability to do something special with it, if they want.</p>
<p>Think about <code><input type="number"></code> on cellphones, bringing up number pads, or <code>type="email"</code> br... |
20,279,484 | How to access the correct `this` inside a callback | <p>I have a constructor function which registers an event handler:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function MyConstructor(data, transport) {
this.data = da... | 20,279,485 | 13 | 4 | null | 2013-11-29 06:13:11.43 UTC | 837 | 2021-10-19 21:37:50.453 UTC | 2021-07-25 20:19:56.12 UTC | null | 63,550 | null | 218,196 | null | 1 | 1,789 | javascript|callback|this | 574,269 | <h2>What you should know about <code>this</code></h2>
<p><code>this</code> (aka "the context") is a special keyword inside each function and its value only depends on <em>how</em> the function was called, not how/when/where it was defined. It is not affected by lexical scopes like other variables (except for ... |
3,992,295 | Unit-testing framework for MATLAB | <p>What are the unit-testing frameworks for MATLAB out there, and how do they compare? How should I choose one for our project? What are their pros and cons?</p> | 3,992,858 | 4 | 1 | null | 2010-10-21 21:52:57.83 UTC | 13 | 2014-12-29 07:57:28.357 UTC | null | null | null | null | 1,428 | null | 1 | 23 | unit-testing|matlab | 7,769 | <p>I think the most popular framework for MATLAB is <a href="http://www.mathworks.com/matlabcentral/fileexchange/22846-matlab-xunit-test-framework" rel="noreferrer">xUnit Test Framework</a> available on File Exchange. Very flexible and well documented.</p>
<p>Some other unit-testing tools are listed <a href="http://en... |
3,981,199 | Adding "Open In..." option to iOS app | <p>On iOS devices, the Mail app offers "Open In..." option for attachments. The apps listed have registered their CFBundleDocumentTypes with the OS. What I am wondering is how my app might allow users to open files generated by my app in other apps. Is Mail the only app that provides this feature?</p> | 3,981,774 | 4 | 2 | null | 2010-10-20 18:44:40.983 UTC | 38 | 2016-02-24 01:58:12.157 UTC | null | null | null | null | 203,220 | null | 1 | 48 | iphone|ipad|ios | 81,270 | <p>Take a look at the <a href="https://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html#//apple_ref/doc/uid/TP40010411-SW1" rel="noreferrer">Document Interaction Programming Topics for iOS: Registering the File... |
4,000,877 | How can I get the current instance's executable file name from native win32 C++ app? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/124886/how-to-get-the-application-executable-name-in-windows-c-win32-or-c-cli">How to get the application executable name in Windows (C++ Win32 or C++/CLI)?</a> </p>
</blockquote>
<p>How can I get the current i... | 4,000,904 | 5 | 0 | null | 2010-10-22 20:52:46.39 UTC | 5 | 2019-10-31 18:28:17.217 UTC | 2017-05-23 12:32:02.037 UTC | null | -1 | null | 29,043 | null | 1 | 26 | c++|winapi | 47,825 | <p>You can do this via the <a href="http://msdn.microsoft.com/en-us/library/ms683197(VS.85).aspx" rel="noreferrer">GetModuleFileName</a> function.</p>
<pre><code>TCHAR szFileName[MAX_PATH];
GetModuleFileName(NULL, szFileName, MAX_PATH)
</code></pre> |
3,727,439 | How to enable horizontal scrolling with mouse? | <p>I cannot determine how to scroll horizontally using the mouse wheel. Vertical scrolling works well automatically, but I need to scroll my content horizontally. My code looks like this:</p>
<pre><code><ListBox x:Name="receiptList"
Margin="5,0"
Grid.Row="1"
ItemTemplate="{StaticResource ... | 42,047,117 | 6 | 1 | null | 2010-09-16 14:03:07.747 UTC | 11 | 2021-06-07 09:08:22.367 UTC | 2013-07-24 16:24:58.773 UTC | null | 1,046,207 | null | 152,006 | null | 1 | 16 | wpf|scrollviewer|horizontal-scrolling | 17,433 | <p>Here's a complete behaviour. Add the below class to your code, then in your XAML set the attached property to true on any <code>UIElement</code> that contains a <code>ScrollViewer</code> as a visual child.</p>
<pre><code><MyVisual ScrollViewerHelper.ShiftWheelScrollsHorizontally="True" />
</code></pr... |
3,274,875 | How to get cookie expiration date / creation date from javascript? | <p>Is it possible to retrieve the creation or expiration date of an existing cookie from javascript? If so how?</p> | 3,274,924 | 7 | 2 | null | 2010-07-18 08:50:22.663 UTC | 5 | 2021-03-13 11:06:54.85 UTC | 2012-01-17 19:04:50.483 UTC | null | 489,280 | null | 64,106 | null | 1 | 61 | javascript|cookies | 133,048 | <p>The information is not available through document.cookie, but if you're really desperate for it, you could try performing a request through the XmlHttpRequest object to the current page and access the cookie header using getResponseHeader().</p> |
3,913,241 | How to insert null into database? | <p>Hi I am trying to insert null in a database column depending on a gridview datakeys value (if being "" insert null into database)
However, I am getting a space ' ' inside the database column.</p>
<pre><code>string sbcId = gvTest.DataKeys[gr.RowIndex]["myColumn"].ToString();
insgnp.Parameters.Add(new OleDbParameter... | 3,913,280 | 8 | 2 | null | 2010-10-12 09:32:56.313 UTC | 3 | 2017-10-20 12:48:38.833 UTC | null | null | null | null | 521,201 | null | 1 | 11 | c#|asp.net|c#-2.0 | 56,436 | <p>You have to rewrite your code:</p>
<pre><code>if(string.IsNullOrEmpty(sbcId))
Parameters.Add(new OleDbParameter("EMPID", DBNull.Value));
else
Parameters.Add(new OleDbParameter("EMPID", sbcId));
</code></pre>
<p>The problem with the ternary if statement that you have is that its returntype must always be ... |
3,842,818 | How to change Rails 3 server default port in develoment? | <p>On my development machine, I use port 10524. So I start my server this way :</p>
<pre><code>rails s -p 10524
</code></pre>
<p>Is there a way to change the default port to 10524 so I wouldn't have to append the port each time I start the server?</p> | 3,843,133 | 9 | 1 | null | 2010-10-01 20:24:56.427 UTC | 50 | 2021-02-05 20:40:55.187 UTC | null | null | null | null | 94,348 | null | 1 | 168 | ruby-on-rails | 134,927 | <p>First - do not edit anything in your gem path! It will influence all projects, and you will have a lot problems later...</p>
<p>In your project edit <code>script/rails</code> this way:</p>
<pre><code>#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from ... |
3,706,819 | What are the implications of using "!important" in CSS? | <p>I've been working on a website for a few months, and a lot of times when I've been trying to edit something, I have to use <code>!important</code>, <em>for example</em>:</p>
<pre><code>div.myDiv {
width: 400px !important;
}
</code></pre>
<p>in order to make it display as expected. Is this bad practice? Or is ... | 3,706,876 | 9 | 2 | null | 2010-09-14 07:23:12.427 UTC | 57 | 2019-06-15 07:37:59.353 UTC | 2014-10-16 20:26:27.447 UTC | null | 2,756,409 | null | 287,047 | null | 1 | 210 | html|css|css-specificity | 105,278 | <p>Yes, I'd say your example of using <code>!important</code> is bad practice, and it's very likely it would cause undesired effects further down the line. That doesn't mean it's never okay to use though.</p>
<h3>What's wrong with <code>!important</code>:</h3>
<p><a href="http://www.smashingmagazine.com/2010/04/css-spe... |
3,779,763 | Fast Algorithm for computing percentiles to remove outliers | <p>I have a program that needs to repeatedly compute the approximate percentile (order statistic) of a dataset in order to remove outliers before further processing. I'm currently doing so by sorting the array of values and picking the appropriate element; this is doable, but it's a noticable blip on the profiles desp... | 3,779,933 | 10 | 2 | null | 2010-09-23 15:08:19.17 UTC | 10 | 2016-03-29 19:54:52.14 UTC | 2017-05-23 11:45:25.62 UTC | null | -1 | null | 42,921 | null | 1 | 20 | c#|c++|algorithm|percentile | 17,797 | <p>The histogram solution from Henrik will work. You can also use a selection algorithm to efficiently find the k largest or smallest elements in an array of n elements in O(n). To use this for the 95th percentile set k=0.05n and find the k largest elements.</p>
<p>Reference:</p>
<p><a href="http://en.wikipedia.org/w... |
4,020,131 | Rails DB Migration - How To Drop a Table? | <p>I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table?</p>
<p>I've already run migrations, so the table is in my database. I figure <code>rails generate migration</code> should be able to handle this, but I haven't figured out how yet.</p>
<p>I've tr... | 4,020,139 | 24 | 3 | null | 2010-10-26 01:52:32.497 UTC | 116 | 2022-01-26 07:30:53.527 UTC | 2022-01-26 07:30:53.527 UTC | null | 967,621 | null | 27,860 | null | 1 | 565 | ruby-on-rails|ruby-on-rails-3|migration|rollback|drop-table | 446,788 | <p>You won't always be able to simply generate the migration to already have the code you want. You can create an empty migration and then populate it with the code you need.</p>
<p>You can find information about how to accomplish different tasks in a migration here:</p>
<p><a href="http://api.rubyonrails.org/classes... |
8,348,082 | Where is data stored when using an HTML 5 Web SQL Database | <p>I just read something about HTML 5 Web SQL Databases. I did a little search on here and Google but couldn't find a simple to the point answer.</p>
<p>Can someone tell me, where is the data stored when using this? In memory or a text file or something else?</p>
<p>Also what browsers support this?</p> | 8,348,152 | 4 | 0 | null | 2011-12-01 20:48:48.763 UTC | 9 | 2016-03-31 18:58:15.707 UTC | null | null | null | null | 143,030 | null | 1 | 10 | html|web-sql | 22,286 | <p>It's stored in a SQLite database. <a href="http://caniuse.com/sql-storage" rel="noreferrer">Here</a> is a browser support chart I found: .</p>
<p>That said, the W3C has officially dropped support for WebSQL in favor of IndexedDB. <a href="http://caniuse.com/indexeddb" rel="noreferrer">Here's</a> the equivalent char... |
8,279,981 | How can I change Action Bar actions dynamically? | <p>I have an Activity with ActionBar and tab navigation. I am using the split mode, so the tabs are at the top and actions are in the bottom bar. How can I dynamically change the bottom actions? I need this because every tab has different actions.</p> | 8,280,672 | 4 | 0 | null | 2011-11-26 16:49:53.597 UTC | 16 | 2015-11-27 19:47:36.22 UTC | null | null | null | null | 243,225 | null | 1 | 62 | android|android-actionbar | 53,657 | <p>Since the actions are populated by the activity's options menu you can use <code>Activity#invalidateOptionsMenu()</code>. This will dump the current menu and call your activity's <code>onCreateOptionsMenu</code>/<code>onPrepareOptionsMenu</code> methods again to rebuild it.</p>
<p>If you're using action bar tabs to... |
7,734,077 | MySQL - Replace Character in Columns | <p>Being a self-taught newbie, I created a large problem for myself. Before inserting data in to my database, I've been converting apostrophes (') in a string, to double quotes (""), instead of the required back-slash and apostrophe (\'), which MySQL actually requires.</p>
<p>Before my table grows more than the 200,00... | 7,734,956 | 4 | 4 | null | 2011-10-12 00:34:53.01 UTC | 23 | 2015-02-11 11:01:29.493 UTC | 2011-10-12 03:17:32.48 UTC | null | 933,633 | null | 933,633 | null | 1 | 70 | mysql|sql|database | 149,109 | <p>Just running the <code>SELECT</code> statement will have no effect on the data. You have to use an <code>UPDATE</code> statement with the <code>REPLACE</code> to make the change occur:</p>
<pre><code>UPDATE photos
SET caption = REPLACE(caption,'"','\'')
</code></pre>
<p>Here is a working sample: <a href="http:... |
8,223,319 | How to hide ajax requests from firebug console? | <p>How to hide ajax requests from firebug console or anything that shows ajax calls ? </p> | 8,223,578 | 7 | 3 | null | 2011-11-22 07:22:34.933 UTC | 14 | 2018-12-06 19:52:52.43 UTC | null | null | null | null | 827,525 | null | 1 | 20 | ajax|browser|firebug | 36,879 | <p>Make <a href="http://en.wikipedia.org/wiki/JSONP" rel="nofollow">JSONP</a> calls. JSONP calls are not real ajax requests (because they don't use <code>XMLHttpRequest</code> object, and they simply inject a script tag into the DOM). But they won't be shown in Firebug.</p> |
7,863,285 | What does y -= m < 3 mean? | <p>While looking through some example C code, I came across this: </p>
<pre><code>y -= m < 3;
</code></pre>
<p>What does this do? It it some kind of condensed for loop or something? It's impossible to google for as far as I know.</p> | 7,863,291 | 8 | 7 | null | 2011-10-22 23:24:22.623 UTC | 13 | 2019-11-30 08:59:19.523 UTC | 2011-10-23 04:45:22.32 UTC | null | 322,020 | null | 977,320 | null | 1 | 52 | c | 8,424 | <p><code>m < 3</code> is either <code>1</code> or <code>0</code>, depending on the truth value.</p>
<p>So <code>y=y-1</code> when <code>m<3</code> is <code>true</code>, or <code>y=y-0</code> when <code>m>=3</code></p> |
7,799,940 | JFrame Exit on close Java | <p>I don't get how can I employ this code:</p>
<pre><code>frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
</code></pre>
<p>to close the program with the x button.</p> | 7,800,013 | 8 | 4 | null | 2011-10-17 21:43:02.683 UTC | 9 | 2019-05-21 10:31:08.78 UTC | 2014-01-24 12:09:55.857 UTC | null | 321,731 | null | 983,246 | null | 1 | 66 | java|jframe | 223,376 | <p>You need the line</p>
<pre><code>frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
</code></pre>
<p>Because the default behaviour for the JFrame when you press the X button is the equivalent to</p>
<pre><code>frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
</code></pre>
<p>So almost a... |
4,147,952 | Reading files with MIPS assembly | <p>I'm trying to write a program that reads in characters from a .dat file that correspond to different colors to be displayed in the LED simulator; x = off, R = red, etc. My problem is, I cannot figure out what I'm doing wrong with opening the .dat file. I've looked around and tried all I can think of, but each time I... | 4,150,340 | 3 | 1 | null | 2010-11-10 18:54:05.977 UTC | 2 | 2016-01-29 14:19:24.073 UTC | 2013-03-04 22:13:35.503 UTC | null | 717,732 | null | 503,585 | null | 1 | 7 | file|io|mips|mars-simulator | 39,696 | <p>The only issue is your buffer is simply an empty string, which is only reserving one byte (null byte). You should instead use <code>buffer: .space 1024</code> or however many bytes you need. Everything else seems fine.</p>
<p>If you are having trouble opening the file, make sure the extension is exactly correct. Bu... |
14,611,259 | How to adjust the distance between the y-label and the y-axis in Matlab? | <p>In Matlab, if we do not rotate the y-label that contains several letters, the label may overlap with the tick numbers or even the y-axis. We can increase the distance between the y-label and the y-axis in the following way:</p>
<pre><code>plot(A, B);
y=ylabel('xxx', 'rot', 0); % do not rotate the y label
set(y, 'p... | 14,612,014 | 1 | 0 | null | 2013-01-30 18:35:47.733 UTC | 3 | 2013-01-30 19:22:10.713 UTC | null | null | null | null | 1,536,711 | null | 1 | 6 | matlab|matlab-figure | 46,142 | <p>You can use normalized units for the y-label position. Try this:</p>
<pre><code>set(y, 'Units', 'Normalized', 'Position', [-0.1, 0.5, 0]);
</code></pre>
<p>Normalized units are always relative to [0 1], so the range of your data doesn't matter.</p> |
4,384,098 | In Django models.py, what's the difference between default, null, and blank? | <ul>
<li><code>null=True</code></li>
<li><code>blank=True</code></li>
<li><code>default = 0</code></li>
</ul>
<p>What's the difference? When do you use what?</p> | 4,384,131 | 5 | 0 | null | 2010-12-08 04:12:45.22 UTC | 22 | 2020-01-24 14:42:51.42 UTC | 2019-01-22 22:30:04.06 UTC | null | 6,813,490 | null | 179,736 | null | 1 | 74 | python|database|django|string|integer | 34,330 | <p>Direct from <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/" rel="noreferrer">Django model field reference</a>:</p>
<blockquote>
<p><strong><code>Field.null</code></strong></p>
<p>If <code>True</code>, Django will store empty values as <code>NULL</code> in the database. Default is <code>Fals... |
4,489,012 | Does C have a standard ABI? | <p>From a discussion <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=590148" rel="noreferrer">somewhere else</a>:</p>
<blockquote>
<p>C++ has no standard ABI (Application Binary Interface)</p>
<p>But neither does C, right?</p>
<p>On any given platform it pretty much does. It wouldn't be useful as th... | 4,490,480 | 9 | 9 | null | 2010-12-20 11:03:57.943 UTC | 17 | 2021-07-21 17:18:36.143 UTC | 2021-02-03 18:58:30.343 UTC | null | 1,783,588 | null | 252,000 | null | 1 | 39 | c|abi | 26,767 | <p>C defines no ABI. In fact, it bends over backwards to avoid defining an ABI. Those people, who like me, who have spent most of their programming lives programming in C on 16/32/64 bit architectures with 8 bit bytes, 2's complement arithmetic and flat address spaces, will usually be quite surprised on reading the c... |
14,518,195 | How can I add new item to the String array? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2843366/how-to-add-new-elements-to-a-string-array">how to add new elements to a String[] array?</a> </p>
</blockquote>
<p>How can I add new item to the String array ? I am trying to add item to the initially em... | 14,518,450 | 5 | 1 | null | 2013-01-25 08:42:05.46 UTC | 5 | 2018-08-09 03:59:44.933 UTC | 2017-05-23 11:47:20.577 UTC | null | -1 | null | 2,007,418 | null | 1 | 25 | java|arrays | 257,702 | <p>From <a href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html" rel="noreferrer">arrays</a> </p>
<blockquote>
<p>An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is ... |
14,696,568 | Avoid Unit of Work pattern in domain driven design | <p>I have read this and it makes me think twice...:</p>
<p>"Avoid unit of work pattern. Aggregate roots should define transaction boundaries."</p>
<p>Why should someone avoid the UOW pattern applying domain driven design?</p> | 14,703,115 | 3 | 0 | null | 2013-02-04 22:07:33.997 UTC | 9 | 2021-02-11 13:21:37.803 UTC | null | null | null | null | 320,460 | null | 1 | 26 | domain-driven-design|unit-of-work|aggregateroot | 15,377 | <p>(Before my post I recommend to read <a href="http://my.safaribooksonline.com/book/project-management/9780133039900/chapter-1dot-getting-started-with-ddd/ch01lev1sec2_html#X2ludGVybmFsX0h0bWxWaWV3P3htbGlkPTk3ODAxMzMwMzk5MDAlMkZjaDEwX2h0bWwmcXVlcnk9" rel="noreferrer">this chapter</a> of "Implementing Domain-Driven Des... |
14,378,437 | Find component by ID in JSF | <p>I want to find some <code>UIComponent</code> from managed bean by the id that I have provided. </p>
<p>I have written the following code:</p>
<pre><code>private UIComponent getUIComponent(String id) {
return FacesContext.getCurrentInstance().getViewRoot().findComponent(id) ;
}
</code></pre>
<p>I have de... | 14,379,356 | 5 | 4 | null | 2013-01-17 11:49:54.093 UTC | 17 | 2021-07-13 09:49:59.333 UTC | 2021-07-13 09:49:59.333 UTC | null | 157,882 | null | 576,758 | null | 1 | 52 | jsf|uicomponents | 105,542 | <p>You can use the following code:</p>
<pre><code>public UIComponent findComponent(final String id) {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot root = context.getViewRoot();
final UIComponent[] found = new UIComponent[1];
root.visitTree(new FullVisitContext(context), new Vi... |
14,384,354 | Force google account chooser | <p>Is there is a way I can force the <strong>google account chooser</strong> to appear even if the user is logged in just with one account.</p>
<p>I have tried by redirecting to this URL:</p>
<pre><code>https://accounts.google.com/AccountChooser?service=lso&continue=[authorizeurl]
</code></pre>
<p>and it seems t... | 14,393,492 | 5 | 0 | null | 2013-01-17 17:08:52.06 UTC | 21 | 2019-06-18 09:21:10.98 UTC | 2013-01-17 17:17:08.1 UTC | null | 1,760,291 | null | 234,047 | null | 1 | 63 | google-oauth | 34,351 | <p>The following parameter is supported in OAuth2 authorization URLs:</p>
<p><code>prompt</code></p>
<p>Currently it can have values <code>none</code>, <code>select_account</code>, and <code>consent</code>.</p>
<ul>
<li><p>none: Will cause Google to not show any UI, and therefore fail if user needs to login, or sele... |
46,715,484 | Correct async function export in node.js | <p>I had my custom module with following code:</p>
<pre><code>module.exports.PrintNearestStore = async function PrintNearestStore(session, lat, lon) {
...
}
</code></pre>
<p>It worked fine if call the function outside my module, however if I called inside I got error while running:</p>
<blockquote>
<p>(node:24372)... | 46,715,585 | 5 | 0 | null | 2017-10-12 17:21:58.097 UTC | 15 | 2022-02-08 06:27:17.893 UTC | null | null | null | null | 630,169 | null | 1 | 88 | javascript|node.js|async-await | 164,473 | <p>This doesn't really have anything to with async functions specially. If you want to call a function internally <em>and</em> export it, define it <em>first</em> and then export it.</p>
<pre><code>async function doStuff() {
// ...
}
// doStuff is defined inside the module so we can call it wherever we want
// Expo... |
55,322,434 | How to clear CUDA memory in PyTorch | <p>I am trying to get the output of a neural network which I have already trained. The input is an image of the size 300x300. I am using a batch size of 1, but I still get a <code>CUDA error: out of memory</code> error after I have successfully got the output for 25 images.</p>
<p>I tried <code>torch.cuda.empty_cache()... | 55,340,037 | 1 | 0 | null | 2019-03-24 09:38:43.133 UTC | 17 | 2022-03-29 07:32:31.303 UTC | 2022-03-29 07:32:31.303 UTC | null | 365,102 | null | 9,536,387 | null | 1 | 52 | python|pytorch | 91,264 | <p>I figured out where I was going wrong. I am posting the solution as an answer for others who might be struggling with the same problem.</p>
<p>Basically, what PyTorch does is that it creates a computational graph whenever I pass the data through my network and stores the computations on the GPU memory, in case I wa... |
57,410,051 | Chrome not showing OPTIONS requests in Network tab | <p>My web client application is setting HTTP POST requests via fetch API. </p>
<p>I see that OPTIONS preflight requests are sent via debugging proxy (Charles Proxy), but they are not displayed in Google Chrome Developer Tools\Network tab. </p>
<p>I don't have any filters setup on the network tab. I remember OPTIONS r... | 57,631,040 | 4 | 0 | null | 2019-08-08 10:03:49.453 UTC | 29 | 2021-04-17 09:21:38.293 UTC | 2019-08-08 10:10:48.34 UTC | null | 1,384,013 | null | 1,384,013 | null | 1 | 117 | google-chrome|cors|google-chrome-devtools|preflight | 70,744 | <p>You'll need to go to: <code>chrome://flags/#out-of-blink-cors</code>, <strong>disable</strong> the flag, and restart Chrome.</p>
<p>This is an expected behavior change according to:<br>
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=995740#c1" rel="noreferrer">https://bugs.chromium.org/p/chromium/is... |
23,240,969 | Python: count repeated elements in the list | <p>I am new to Python. I am trying to find a simple way of getting a count of the number of elements repeated in a list e.g.</p>
<pre><code>MyList = ["a", "b", "a", "c", "c", "a", "c"]
</code></pre>
<p>Output:</p>
<pre><code>a: 3
b: 1
c: 3
</code></pre> | 23,240,989 | 5 | 0 | null | 2014-04-23 10:00:57.903 UTC | 27 | 2022-07-27 17:47:54.337 UTC | 2018-02-24 08:01:59.26 UTC | null | 3,961,903 | null | 3,557,527 | null | 1 | 73 | python|python-2.7 | 289,895 | <p>You can do that using <strong><code>count</code></strong>:</p>
<pre><code>my_dict = {i:MyList.count(i) for i in MyList}
>>> print my_dict #or print(my_dict) in python-3.x
{'a': 3, 'c': 3, 'b': 1}
</code></pre>
<p><strong>Or</strong> using <a href="https://docs.python.org/3/library/collections.html#coll... |
2,054,635 | Reverse Geocoding With Google Map API And PHP To Get Nearest Location Using Lat,Long coordinates | <p>I need a function to get an nearest address or city from coordinates(lat,long) using google map api reverse geocoding and php... Please give some sample code</p> | 2,054,675 | 1 | 0 | null | 2010-01-13 05:24:10.397 UTC | 10 | 2015-07-13 11:04:35.327 UTC | 2010-01-13 11:41:01.633 UTC | null | 73,488 | null | 1,486,512 | null | 1 | 15 | php|google-maps|google-code|reverse-geocoding | 43,535 | <p>You need to use the <a href="http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder.getLocations" rel="nofollow noreferrer">getLocations</a> method on the <a href="http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder" rel="nofollow noreferrer">GClientGeocoder</a> objec... |
39,902,197 | How can i pass webpack environment variables in html? | <p>How can i get / access webpack ENV variables during process time (not runtime in browser) ? the <code>webpack.DefinePlugin(...)</code> doesn't seem to work in html files, i don't have access to ENV variables in the main <code>index.html</code></p>
<p>any solution ?</p> | 42,239,310 | 2 | 0 | null | 2016-10-06 17:25:58.913 UTC | 4 | 2018-08-26 19:11:00.457 UTC | null | null | null | null | 807,503 | null | 1 | 36 | webpack|environment-variables | 25,956 | <p>You can use <a href="https://www.npmjs.com/package/html-webpack-plugin" rel="noreferrer">html-webpack-plugin</a>. You will have to use .ejs or some other template language and then use like that </p>
<pre><code>new HtmlWebpackPlugin({
template: './src/public/index.ejs',
inject: 'body',
envir... |
27,144,702 | How to reset 'display' property for flex-item | <p>I'm trying to convert old layout based on tables and JS to the new Flexbox with backward compatibility by keeping the tables for old browsers (specifically IE8, IE9 and Opera 10+).</p>
<p>The problem is that there is no <code>display:flex-item</code> to override the old style of <code>display:table-cell</code>.</p>... | 27,146,937 | 3 | 0 | null | 2014-11-26 08:47:45.283 UTC | 4 | 2017-11-19 06:31:17.947 UTC | 2014-11-26 10:25:45.163 UTC | null | 2,011,448 | null | 2,011,448 | null | 1 | 16 | css|tablelayout|flexbox | 103,831 | <p>As Danield has mentioned, all children of a flex container (designated by <code>display: flex</code> or <code>display: inline-flex</code>) are automatically made flex items. There is no <code>display</code> property for a flex item; instead, you set it to some other value depending on how you want the children <em>o... |
44,800,659 | How define constructor implementation for an Abstract Class in Python? | <p>I am trying to declare an abstract class <code>A</code> with a constructor with a default behavior: all subclasses must initialize a member <code>self.n</code>:</p>
<pre><code>from abc import ABCMeta
class A(object):
__metaclass__ = ABCMeta
def __init__(self, n):
self.n = n
</code></pre>
<p>Howev... | 44,800,925 | 6 | 1 | null | 2017-06-28 11:02:34.737 UTC | 7 | 2021-02-15 13:32:22.48 UTC | 2020-08-07 19:29:15.197 UTC | null | 5,780,109 | null | 3,120,489 | null | 1 | 67 | python|python-2.7|oop|abstract-class | 67,110 | <p>Making the <code>__init__</code> an abstract method:</p>
<pre><code>from abc import ABCMeta, abstractmethod
class A(object):
__metaclass__ = ABCMeta
@abstractmethod
def __init__(self, n):
self.n = n
if __name__ == '__main__':
a = A(3)
</code></pre>
<p>helps:</p>
<pre><code>TypeError: C... |
54,031,546 | How to create an empty list in Dart | <p>I want to create an empty list for a Flutter project.</p>
<pre><code>final prefs = await SharedPreferences.getInstance();
final myStringList = prefs.getStringList('my_string_list_key') ?? <empty list>;
</code></pre>
<p>I seem to remember there are multiple ways but one recommended way. How do I do it?</p> | 54,031,547 | 3 | 0 | null | 2019-01-04 00:11:03.81 UTC | 1 | 2022-06-09 18:19:39.253 UTC | 2019-11-22 01:00:47.607 UTC | null | 3,681,880 | null | 3,681,880 | null | 1 | 64 | list|dart|flutter | 59,696 | <p>There are a few ways to create an empty list in Dart. If you want a growable list then use an empty list literal like this:</p>
<pre><code>[]
</code></pre>
<p>Or this if you need to specify the type:</p>
<pre><code><String>[]
</code></pre>
<p>Or this if you want a non-growable (fixed-length) list:</p>
<pre><co... |
33,621,319 | Spark / Scala: forward fill with last observation | <p>Using Spark 1.4.0, Scala 2.10</p>
<p>I've been trying to figure out a way to forward fill null values with the last known observation, but I don't see an easy way. I would think this is a pretty common thing to do, but can't find an example showing how to do this.</p>
<p>I see functions to forward fill NaN with a ... | 33,622,083 | 2 | 0 | null | 2015-11-10 01:24:21.417 UTC | 18 | 2022-09-19 19:26:41.813 UTC | 2019-01-11 12:31:05.173 UTC | null | 1,560,062 | null | 2,494,262 | null | 1 | 31 | scala|apache-spark|apache-spark-sql | 13,900 | <h2>Initial answer (a single time series assumption):</h2>
<p>First of all try avoid window functions if you cannot provide <code>PARTITION BY</code> clause. It moves data to a single partition so most of the time it is simply not feasible.</p>
<p>What you can do is to fill gaps on <code>RDD</code> using <code>mapPar... |
30,001,051 | :app:dexDebug ExecException finished with non-zero exit value 2 | <p>Could anyone help me out with the following error. When i clean the project, it doesn't show any error but every time i try to run i get this message. </p>
<p>Error:Execution failed for task ':app:dexDebug'.</p>
<blockquote>
<p>com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecExce... | 30,028,505 | 13 | 0 | null | 2015-05-02 10:15:15.703 UTC | 4 | 2018-06-05 08:16:35.06 UTC | 2018-06-05 08:16:35.06 UTC | null | 8,187,464 | null | 796,320 | null | 1 | 25 | java|android|android-studio|gradle|android-gradle-plugin | 58,403 | <p>After days of trying out finally could fix the issue. The problem with one of my .jar files. I had to remove each jar and check one by one until i found it. I removed the .jar file and cleaned my project and ran successfully. If any one should face similar issue check your jar file one by one.</p> |
35,906,568 | Wait until swift for loop with asynchronous network requests finishes executing | <p>I would like a for in loop to send off a bunch of network requests to firebase, then pass the data to a new view controller once the the method finishes executing. Here is my code:</p>
<pre><code>var datesArray = [String: AnyObject]()
for key in locationsArray {
let ref = Firebase(url: "http://myfirebas... | 35,906,703 | 10 | 0 | null | 2016-03-10 02:37:03.6 UTC | 110 | 2022-07-28 14:21:08.857 UTC | 2019-05-09 08:26:19.823 UTC | null | 74,118 | null | 5,167,919 | null | 1 | 200 | swift|asynchronous|grand-central-dispatch|nsoperation | 111,893 | <p>You can use <a href="http://commandshift.co.uk/blog/2014/03/19/using-dispatch-groups-to-wait-for-multiple-web-services/" rel="noreferrer">dispatch groups</a> to fire an asynchronous callback when all your requests finish.</p>
<p>Here's an example using dispatch groups to execute a callback asynchronously when multi... |
52,253,192 | PySpark - to_date format from column | <p>I am currently trying to figure out, how to pass the String - format argument to the to_date pyspark function via a column parameter.</p>
<p>Specifically, I have the following setup:</p>
<pre class="lang-python prettyprint-override"><code>sc = SparkContext.getOrCreate()
df = sc.parallelize([('a','2018-01-01','yyyy... | 52,264,568 | 3 | 0 | null | 2018-09-10 07:44:25.137 UTC | 1 | 2020-12-16 15:47:08.797 UTC | 2018-09-10 19:55:25.363 UTC | null | 5,858,851 | null | 6,333,935 | null | 1 | 8 | apache-spark|pyspark|apache-spark-sql | 46,195 | <p>You can <a href="https://stackoverflow.com/questions/51140470/using-a-column-value-as-a-parameter-to-a-spark-dataframe-function">use a column value as a parameter</a> without a <code>udf</code> using the spark-sql syntax:</p>
<p><strong>Spark version 2.2 and above</strong></p>
<pre class="lang-python prettyprint-o... |
39,393,926 | Flask('application') versus Flask(__name__) | <p>In the official <a href="http://flask.pocoo.org/docs/0.11/quickstart/#a-minimal-application" rel="noreferrer">Quickstart</a>, it's recommended to use <code>__name__</code> when using a single <strong>module</strong>:</p>
<blockquote>
<ol start="2">
<li>... If you are using a single module (as in this example), ... | 39,393,990 | 1 | 0 | null | 2016-09-08 14:43:11.533 UTC | 6 | 2019-10-26 08:47:56.9 UTC | 2016-09-08 14:49:18.78 UTC | null | 5,399,734 | null | 5,399,734 | null | 1 | 36 | python|flask|import|module|package | 25,882 | <p><code>__name__</code> is just a convenient way to get the import name of the place the app is defined. Flask uses the import name to know where to look up resources, templates, static files, instance folder, etc. When using a package, if you define your app in <code>__init__.py</code> then the <code>__name__</code... |
34,188,461 | Laravel 5.1 @can, how use OR clause | <p>I did not find how to use a clause (OR, AND) in view with @can, for checking multiple abilities ...</p>
<p>I tried:</p>
<pre><code>@can(['permission1', 'permission2'])
@can('permission1' or 'permission2')
@can('permission1' || 'permission2')
</code></pre>
<p>But dont work ;(</p> | 34,189,000 | 8 | 0 | null | 2015-12-09 20:34:14.83 UTC | 6 | 2022-03-25 11:42:47.03 UTC | 2015-12-09 20:49:15.73 UTC | null | 1,384,843 | null | 1,384,843 | null | 1 | 41 | laravel|laravel-5.1|laravel-blade | 41,036 | <p>You can use the Gate facade:</p>
<pre><code>@if(Gate::check('permission1') || Gate::check('permission2'))
@endif
</code></pre> |
31,409,149 | Jenkins Remote Trigger Not Working | <p>I am getting the following error when i try triggering a build using the following command:</p>
<p>curl <a href="http://jenkins_server:port/jenkins/job/job_name/build?token=token_name">http://jenkins_server:port/jenkins/job/job_name/build?token=token_name</a></p>
<p>Output:</p>
<blockquote>
<p>Authentication re... | 31,411,425 | 9 | 0 | null | 2015-07-14 14:11:44.573 UTC | 7 | 2021-04-14 04:00:27.913 UTC | null | null | null | null | 361,089 | null | 1 | 28 | curl|jenkins | 29,572 | <p>I install Build Token Root Plugin to solve this issue before</p>
<p><a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin" rel="noreferrer">https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin</a></p>
<p>Then as the same, setup Authentication Token</p>
<p>Finally, either use ... |
171,489 | Explicit Type Conversion in Scala | <p>Lets say I have the following code:</p>
<pre><code>abstract class Animal
case class Dog(name:String) extends Animal
var foo:Animal = Dog("rover")
var bar:Dog = foo //ERROR!
</code></pre>
<p>How do I fix the last line of this code? Basically, I just want to do what, in a C-like language would be done:</p>
<pre><c... | 171,531 | 1 | 0 | null | 2008-10-05 04:32:52.847 UTC | 19 | 2011-05-02 21:28:28.11 UTC | 2011-05-02 21:28:28.11 UTC | onlyafly | 460,387 | onlyafly | 10,475 | null | 1 | 78 | scala|type-conversion | 69,811 | <p>I figured this out myself. There are two solutions:</p>
<p>1) Do the explicit cast:</p>
<pre><code>var bar:Dog = foo.asInstanceOf[Dog]
</code></pre>
<p>2) Use pattern matching to cast it for you, this also catches errors:</p>
<pre><code>var bar:Dog = foo match {
case x:Dog => x
case _ => {
// Erro... |
49,473,098 | Call to undefined method Maatwebsite\Excel\Excel::load() | <p>I'm trying to import excel file (.xlsx) using maatwebsite 3.0. How to fix This error </p>
<blockquote>
<p>Call to undefined method Maatwebsite\Excel\Excel::load()</p>
</blockquote>
<p>My controller</p>
<pre><code>public function importsave(Request $request)
{
if($request->hasFile('excel'))
{
$... | 49,473,174 | 6 | 0 | null | 2018-03-25 06:20:21.24 UTC | 2 | 2021-12-01 10:30:59.02 UTC | 2018-03-26 07:37:24.067 UTC | null | 1,594,915 | null | 9,080,111 | null | 1 | 18 | php|excel|laravel|laravel-5|maatwebsite-excel | 82,887 | <p>Version <strong>3.0</strong> of that package <strong>doesn't handle imports yet</strong>. Release date for this feature is unknown. See this post for more details: <a href="https://medium.com/@maatwebsite/laravel-excel-lessons-learned-7fee2812551" rel="nofollow noreferrer">https://medium.com/@maatwebsite/laravel-exc... |
43,943,384 | Powershell to find Server Operating system | <p>I had a task to find Operating System of all the servers we had in AD for some Microsoft Licenses requirement. </p>
<p>Has anyone done this?</p> | 43,943,385 | 2 | 0 | null | 2017-05-12 17:28:20.953 UTC | null | 2019-02-21 07:52:54.743 UTC | 2018-01-23 17:58:08.417 UTC | null | 2,212,710 | null | 2,212,710 | null | 1 | 3 | powershell|operating-system|find|windows-server | 46,147 | <p>I figured it out. </p>
<p>Please feel free to use it and modify it. If you have questions, let me know.</p>
<p>It's a simple command. Hopefully, it helps someone. This gives you the type of operating systems you have. I am filtering based on Windows Server only and computer accounts that are active. Then sort by n... |
39,081,945 | How to specify spring.profiles.active when I run mvn install | <p>In this web application with Spring, I created several application-property files for different deploy environment. They specify different db connection configs. </p>
<pre><code>application-dev.properties
application-qa.properties
application-stg.properties
application-prod.properties
</code></pre>
<p>The recommen... | 39,082,932 | 2 | 0 | null | 2016-08-22 14:18:58.467 UTC | 3 | 2018-05-26 10:35:31.99 UTC | 2016-08-22 15:42:52.623 UTC | null | 3,358,927 | null | 3,358,927 | null | 1 | 22 | eclipse|spring|web-services|maven|jvm | 62,679 | <p>Under Run->run configurations, select your maven launch configuration, then select the JRE tab, and type your argument in the VM arguments text area. </p> |
3,154,310 | Search list of objects based on object variable | <p>I have a list of objects. These objects have three variables, ID, Name, & value. There can be a lot of objects in this list, and I need to find one based on the ID or Name, and change the value.
Example</p>
<pre><code>class objec
{
public string Name;
public int UID;
public string value;
}
List<... | 3,154,328 | 4 | 0 | null | 2010-07-01 00:07:21.757 UTC | 3 | 2014-09-09 22:39:31.833 UTC | 2014-09-09 22:39:31.833 UTC | null | 267,631 | null | 267,631 | null | 1 | 15 | c#|search|list | 72,124 | <p>You could use LINQ to find it, then change the element directly:</p>
<pre><code>var item = TextPool.FirstOrDefault(o => o.Name == "test");
if (item != null)
item.value = "Value";
</code></pre>
<p>If you wanted to change all elements that match, you could, potentially, even do:</p>
<pre><code>TextPool.Wh... |
3,151,779 | Best way to invoke gdb from inside program to print its stacktrace? | <p>Using a function like this:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
void print_trace() {
char pid_buf[30];
sprintf(pid_buf, "--pid=%d", getpid());
char name_buf[512];
name_buf[readlink("/proc/self/exe", name_buf, 511)]=... | 4,611,112 | 4 | 17 | 2010-06-30 22:30:51.7 UTC | 2010-06-30 17:27:58.493 UTC | 67 | 2018-02-27 21:02:38.633 UTC | 2018-02-27 21:02:38.633 UTC | null | 266,720 | null | 266,720 | null | 1 | 62 | c|linux|gdb|stack-trace | 43,532 | <p>You mentioned on my other answer (now deleted) that you also want to see line numbers. I'm not sure how to do that when invoking gdb from inside your application.</p>
<p>But I'm going to share with you a couple of ways to print a simple stacktrace with function names and their respective line numbers <strong>withou... |
56,651,472 | Does C# 8 support the .NET Framework? | <p>In Visual Studio 2019 Advanced Build settings, C# 8 does not appear to be available for a .NET Framework project, only (as in the picture below) for a .NET Core 3.0 project:</p>
<p><a href="https://i.stack.imgur.com/3P2rH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3P2rH.png" alt="enter image descript... | 57,020,770 | 3 | 0 | null | 2019-06-18 14:31:05.273 UTC | 67 | 2021-03-16 12:02:03.953 UTC | 2020-03-12 02:08:32.587 UTC | null | 397,817 | null | 1,461,680 | null | 1 | 225 | c#|.net|visual-studio|.net-standard|c#-8.0 | 92,643 | <p><strong>Yes, C# 8 can be used with the .NET Framework</strong> and other targets older than .NET Core 3.0/.NET Standard 2.1 in Visual Studio 2019 (or older versions of Visual Studio if you <a href="https://stackoverflow.com/a/58190585/397817">install a NuGet package</a>).</p>
<p>The only thing required is to set lan... |
28,837,633 | pandas get position of a given index in DataFrame | <p>Let's say I have a DataFrame like this:</p>
<pre><code>df
A B
5 0 1
18 2 3
125 4 5
</code></pre>
<p>where <code>5, 18, 125</code> are the index</p>
<p>I'd like to get the line before (or after) a certain index. For instance, I have index <code>18</code> (eg. by doing <code>df[df.A==2].index</code>)... | 28,837,788 | 2 | 0 | null | 2015-03-03 17:02:00.873 UTC | 9 | 2022-09-21 14:01:46.977 UTC | 2015-03-03 17:24:06.36 UTC | null | 3,297,428 | null | 3,297,428 | null | 1 | 21 | python|pandas | 23,265 | <p>For your first question:</p>
<pre><code>base = df.index.get_indexer_for((df[df.A == 2].index))
</code></pre>
<p>or alternatively</p>
<pre><code>base = df.index.get_loc(18)
</code></pre>
<p>To get the surrounding ones: </p>
<pre><code>mask = pd.Index(base).union(pd.Index(base - 1)).union(pd.Index(base + 1))
</co... |
40,497,399 | HTTP request from Angular sent as OPTIONS instead of POST | <p>I'm trying to send some HTTP requests from my angular.js application to my server, but I need to solve some CORS errors.</p>
<p>The HTTP request is made using the following code:</p>
<pre><code>functions.test = function(foo, bar) {
return $http({
method: 'POST',
url: api_endpoint + 'test',
... | 40,497,696 | 6 | 6 | null | 2016-11-08 22:18:14.143 UTC | 9 | 2022-01-16 17:58:57.057 UTC | 2019-11-20 15:57:52.467 UTC | null | 971,141 | null | 1,115,471 | null | 1 | 31 | javascript|php|angularjs|http|cors | 64,897 | <h2>TL;DR answer</h2>
<h3>Explanation</h3>
<p>The <code>OPTIONS</code> request is so called <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests" rel="noreferrer"><strong>pre-flight request</strong></a>, which is part of <a href="https://developer.mozilla.org/en-US/docs/We... |
95,890 | What is a variable's linkage and storage specifier? | <p>When someone talks about a variables storage class specifier, what are they talking about?<br>
They also often talk about variable linkage in the same context, what is that?</p> | 95,927 | 2 | 0 | null | 2008-09-18 19:15:06.453 UTC | 15 | 2008-09-18 19:42:52.75 UTC | null | null | null | Benoit Lavigne | 10,703 | null | 1 | 11 | c++|c | 4,965 | <p>The storage class specifier controls the <em>storage</em> and the <em>linkage</em> of your variables. These are two concepts that are different.
C specifies the following specifiers for variables: auto, extern, register, static.</p>
<p><strong>Storage</strong><br>
The storage duration determines how long your varia... |
2,575,116 | fopen / fopen_s and writing to files | <p>I'm using fopen in C to write the output to a text file. The function declaration is (where <code>ARRAY_SIZE</code> has been defined earlier):</p>
<pre><code>void create_out_file(char file_name[],long double *z1){
FILE *out;
int i;
if((out = fopen(file_name, "w+")) == NULL){
fprintf(stderr, "***&... | 2,575,187 | 6 | 2 | null | 2010-04-04 16:48:49.073 UTC | 3 | 2015-10-15 14:36:58.137 UTC | 2015-10-15 14:36:58.137 UTC | null | 119,775 | null | 308,316 | null | 1 | 24 | c|file-io|precision|fopen | 95,286 | <p><code>fopen_s</code> is a variant of <code>fopen</code> which contains parameter validation and hands back an error code instead of a pointer in case something goes wrong during the open process. It's more secure than the base variant because it accounts for more edge conditions. The compiler is warning you to use i... |
3,086,418 | Svn revert all properties changes | <p>I have a svn working copy which I attempted to reverse merge a couple of recent revisions into. I cancelled the merge before it completed as I changed my mind. Now my working copy has a couple of thousand "changes" from updates to the ancestry related properties on most of the files. I have about 10 files with real ... | 3,091,639 | 6 | 0 | null | 2010-06-21 16:21:59.077 UTC | 6 | 2021-01-21 16:58:03.947 UTC | null | null | null | null | 325,129 | null | 1 | 31 | svn | 14,627 | <p>Turns out that Tortoise SVN can do this really nicely. In the commit dialog you can sort the "modified" files by "text status" or "properties status". I simply sorted by text status and then reverted all the "modified" files which had "normal" "text status".</p> |
2,582,877 | Find issues that were ever assigned to me | <p>I am trying to create a filter to search for all issues that were ever assigned to me, even after the assignee is changed. I cant find the appropriate search parameters for this. Is it even possible in jira?</p> | 2,583,353 | 7 | 2 | null | 2010-04-06 05:43:18.817 UTC | 13 | 2022-05-03 08:07:52.83 UTC | null | null | null | null | 9,425 | null | 1 | 94 | jira | 41,426 | <p>Check out the toolkit plugin
<a href="https://studio.plugins.atlassian.com/wiki/display/JTOOL/JIRA+Toolkit+Plugin" rel="noreferrer">https://studio.plugins.atlassian.com/wiki/display/JTOOL/JIRA+Toolkit+Plugin</a></p>
<p>It has a custom field 'Participant' which allows you to find all issues
that you raised, were ass... |
2,336,785 | set language within a django view | <p><strong>background:</strong>
The view is called when a payment service pings back a payment outcome behind the scenes - afterwhich I need to send an email in the right language to confirm payment and so on. I can get the language code back in the request from the payment server and would like to use that along with ... | 2,336,889 | 8 | 0 | null | 2010-02-25 19:03:21.913 UTC | 25 | 2021-11-12 10:31:57.883 UTC | null | null | null | null | 214,841 | null | 1 | 57 | django|internationalization | 56,163 | <p>To quote parts from Django's Locale Middleware (<code>django.middleware.locale.LocaleMiddleware</code>):</p>
<pre><code>from django.utils import translation
class LocaleMiddleware(object):
"""
This is a very simple middleware that parses a request
and decides what translation object to install in the c... |
2,785,093 | Facebook 'Friends.getAppUsers' using Graph API | <p>I have an application that uses the old REST API call <code>Friends.getAppUsers</code> to get the list of friends for the current user that have authorized my application.</p>
<p>I have read the documentation, how do I do this with the Graph API? What would an example of this be?</p> | 3,066,091 | 8 | 0 | null | 2010-05-06 23:02:16.307 UTC | 59 | 2014-04-12 09:41:44.197 UTC | 2014-04-12 09:41:44.197 UTC | null | 1,045,444 | null | 233,202 | null | 1 | 87 | facebook|facebook-graph-api|facebook-friends | 66,017 | <p>I've done a lot of investigations on this issue. From what I can tell, there is no way to do <code>Friends.getAppUsers</code> using Graph API. The latest SDKs provided by Facebook all use the old REST API to get friends using the application.</p> |
2,721,455 | Implementing few methods of a interface class-C# | <p>Is it possible in C# to have a class that implement an interface that has 10 methods declared but implementing only 5 methods i.e defining only 5 methods of that interface??? Actually I have an interface that is implemented by 3 class and not all the methods are used by all the class so if I could exclude any metho... | 2,721,470 | 11 | 3 | null | 2010-04-27 13:13:51.01 UTC | 4 | 2017-06-27 06:53:30.737 UTC | 2010-04-27 13:30:11.547 UTC | null | 85,019 | null | 85,019 | null | 1 | 26 | c#|interface | 48,073 | <p>You can make it an abstract class and add the methods you don't want to implement as abstract methods.</p>
<p>In other words:</p>
<pre><code>public interface IMyInterface
{
void SomeMethod();
void SomeOtherMethod();
}
public abstract class MyClass : IMyInterface
{
// Really implementing this
publi... |
3,031,887 | How to catch a "Done" key press from the soft keyboard | <p>how do I catch specific key events from the soft keyboard?
specifically I'm interested in the "Done" key.</p> | 3,032,071 | 11 | 0 | null | 2010-06-13 10:33:50.207 UTC | 8 | 2021-02-04 15:34:58.48 UTC | 2016-05-23 11:10:52.44 UTC | null | 3,193,867 | null | 258,429 | null | 1 | 63 | android | 57,607 | <p><strong>Note:</strong> This answer is old and no longer works. See the answers below.</p>
<p>You catch the KeyEvent and then check its keycode. FLAG_EDITOR_ACTION is used to identify enter keys that are coming from an IME whose enter key has been auto-labelled "next" or "done"</p>
<pre><code>if (event.getKeyCode()... |
2,648,802 | At what point is it worth using a database? | <p>I have a question relating to databases and at what point is worth diving into one. I am primarily an embedded engineer, but I am writing an application using Qt to interface with our controller. </p>
<p>We are at an odd point where we have enough data that it would be feasible to implement a database (around 700+... | 2,649,916 | 13 | 7 | null | 2010-04-15 20:38:18.09 UTC | 26 | 2019-02-26 09:16:49.917 UTC | 2013-11-01 20:16:54.67 UTC | null | 102,937 | null | 317,948 | null | 1 | 56 | c++|sql|database|qt|user-interface | 3,974 | <p>A database is worthwhile when: </p>
<ol>
<li>Your application evolves to some
form of data driven execution.</li>
<li>You're spending time designing and
developing external data storage
structures.</li>
<li>Sharing data between applications or
organizations (including individual
people)</li>
<li>The data is no lon... |
2,973,270 | Using a custom typeface in Android | <p>I want to use a custom font for my android application which I am creating.<br>
I can individually change the typeface of each object from Code, but I have hundreds of them.</p>
<p>So,</p>
<ul>
<li>Is there a way to do this from the XML? [Setting a custom typeface]</li>
<li>Is there a way to do it from code in one... | 2,973,931 | 21 | 4 | null | 2010-06-04 10:28:23.22 UTC | 57 | 2021-02-09 18:27:45.08 UTC | 2017-03-31 04:57:27.937 UTC | null | 3,681,880 | null | 177,890 | null | 1 | 111 | xml|android|layout|fonts | 129,015 | <blockquote>
<p>Is there a way to do this from the
XML?</p>
</blockquote>
<p><strike>No, sorry. You can only specify the built-in typefaces through XML.</strike></p>
<blockquote>
<p>Is there a way to do it from code in
one place, to say that the whole
application and all the components
should use the cust... |
23,709,739 | Why does node.js need python | <p>I am starting up with node
This is from node.js README.md</p>
<p>Prerequisites (Unix only):</p>
<pre><code>* GCC 4.2 or newer
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
* libexecinfo (FreeBSD and OpenBSD only)
</code></pre>
<p>Curious to know why does node.js need Python ?
Does it use Python underneath its API... | 23,710,101 | 2 | 1 | null | 2014-05-17 09:30:02.537 UTC | 11 | 2014-05-17 10:50:28.75 UTC | null | null | null | null | 1,371,989 | null | 1 | 36 | python|node.js | 23,298 | <p>Node.js is built with <a href="https://code.google.com/p/gyp/">GYP</a> — cross-platform built tool written in Python. Also some other build steps are implemented in Python. So Python is required for building node from source.</p>
<p>But you also need Python for building native addons.</p> |
10,403,794 | VBA Range from String | <p>This is kind of silly, but I've been stuck for a while in this simple statement:</p>
<pre><code> Dim range1 as Range
Dim mysheet as String
Dim myrange as String
mysheet = "Sheet1"
range = "A1:A10"
range1 = Worksheets(mysheet).Range(myrange)
</code></pre>
<p>I've testing all the solutions that ... | 10,403,853 | 1 | 0 | null | 2012-05-01 20:20:44.01 UTC | 2 | 2012-05-02 09:04:20.033 UTC | 2017-05-23 12:34:04.65 UTC | null | -1 | null | 1,238,957 | null | 1 | 17 | vba|excel | 68,865 | <p>You need to use Set to assign objects:</p>
<pre><code>Set range1 = Worksheets(mysheet).Range(myrange)
</code></pre> |
10,841,060 | Regex to replace values that include part of match in replacement in sublime? | <p>I've come up with this regex that finds all words that start with <code>$</code> and contain <code>_</code> underscores:</p>
<p><code>\$(\w+)_(\w+)</code></p>
<p>I'm basically searching for variables, like <code>$var_foo</code> etc.</p>
<p>How do I replace stuff using the regex groups?</p>
<p>For example, how ca... | 10,841,126 | 1 | 0 | null | 2012-05-31 20:49:00.107 UTC | 10 | 2014-10-22 08:24:30.46 UTC | 2014-10-22 08:24:30.46 UTC | null | 1,922,144 | null | 376,947 | null | 1 | 44 | regex|sublimetext|textmate|oniguruma | 27,627 | <p>The replacement expression is:</p>
<pre><code>\$\1\u\2
</code></pre>
<ul>
<li><code>\1</code>, <code>\2</code> are the captures (or <code>$1</code>, <code>$2</code>)</li>
<li><code>\u</code> up-cases (see the <a href="http://manual.macromates.com/en/regular_expressions#replacement_string_syntax_format_strings">Rep... |
5,743,390 | Creating ARPA language model file with 50,000 words | <p>I want to create an ARPA language model file with nearly 50,000 words. I can't generate the language model by passing my text file to the CMU Language Tool. Is any other link available where I can get a language model for these many words?</p> | 6,356,792 | 2 | 1 | null | 2011-04-21 11:24:07.877 UTC | 11 | 2016-07-16 15:14:17.097 UTC | 2016-07-16 15:14:17.097 UTC | null | 2,950,946 | null | 686,849 | null | 1 | 14 | speech-recognition|cmusphinx|n-gram|language-model | 7,390 | <p>I thought I'd answer this one since it has a few votes, although based on Christina's other questions I don't think this will be a usable answer for her since a 50,000-word language model almost certainly won't have an acceptable word error rate or recognition speed (or most likely even function for long) with in-ap... |
23,259,586 | Bcrypt password hashing in Golang (compatible with Node.js)? | <p>I set up a site with Node.js+passport for user authentication. </p>
<p>Now I need to migrate to Golang, and need to do authentication with the user passwords saved in db. </p>
<p>The Node.js encryption code is:</p>
<pre><code> var bcrypt = require('bcrypt');
bcrypt.genSalt(10, function(err, salt) {
... | 23,259,804 | 3 | 0 | null | 2014-04-24 04:03:58.5 UTC | 28 | 2020-08-24 15:25:23.323 UTC | 2016-08-02 18:54:50.403 UTC | user6169399 | null | null | 2,036,213 | null | 1 | 80 | node.js|go|bcrypt | 56,193 | <p>Using the <a href="http://godoc.org/golang.org/x/crypto/bcrypt" rel="noreferrer">golang.org/x/crypto/bcrypt</a> package, I believe the equivalent would be:</p>
<pre><code>hashedPassword, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
</code></pre>
<p><strong>Working example:</strong></p>
<pre><c... |
23,073,799 | Make span element hidden when javascript validation succeeds | <p>I am stuck on how to make a span element become hidden again when the JavaScript validation succeeds. Currently <code>onchange</code> and <code>onblur</code> a red span appears showing an error if there is no text or if there are numbers in a name field. This does not disappear when the correct text is put in. I was... | 23,073,914 | 2 | 0 | null | 2014-04-15 02:44:05.237 UTC | null | 2020-02-19 15:07:06.087 UTC | 2016-08-31 13:51:32.257 UTC | null | 3,885,376 | null | 3,534,211 | null | 1 | 7 | javascript|html | 49,133 | <p>You're on the right track. </p>
<p><a href="http://jsfiddle.net/isherwood/BHe5Z/" rel="nofollow noreferrer">Fiddle demo</a></p>
<pre><code>function validateName() {
var name = form.firstname.value;
if (form.firstname.value == "") {
document.getElementById("firstnameInvalid").style.visibility = "vi... |
41,146,373 | Access function location programmatically | <p>Is it possible in code to access <code>["[[FunctionLocation]]"]</code> property that google chrome developer tools show when using console log on a function ?</p> | 41,666,584 | 3 | 0 | null | 2016-12-14 15:32:38.353 UTC | 5 | 2021-10-14 17:14:08.717 UTC | 2021-10-14 17:14:08.717 UTC | null | 1,048,572 | null | 1,256,902 | null | 1 | 31 | javascript|google-chrome-devtools|v8|console.log | 8,628 | <p>The answer, for now, is <strong>no</strong>.</p>
<p>The <code>[[FunctionLocation]]</code> property you see in Inspector is added in <a href="https://github.com/v8/v8/blob/f9fbaec39a201812c5e45c9b632f012ab3c531b7/src/inspector/v8-debugger.cc#L719-L721" rel="noreferrer"><code>V8Debugger::internalProperties()</code></... |
47,255,455 | babel-polyfill vs babel-plugins | <p>I am a bit lost in the Babel options / config. I want to use recent js features and compile (with webpack) to browser code. </p>
<p>What is the difference between <a href="https://babeljs.io/docs/usage/polyfill/" rel="noreferrer">babel-polyfill</a> and <a href="https://babeljs.io/docs/plugins/" rel="noreferrer">bab... | 47,326,735 | 2 | 0 | null | 2017-11-13 00:13:11.007 UTC | 8 | 2018-01-28 20:58:08.827 UTC | 2017-11-16 00:49:10.99 UTC | null | 2,112,538 | null | 2,112,538 | null | 1 | 15 | babeljs|babel-polyfill | 7,637 | <p>Answer from <a href="https://medium.com/@jcse/clearing-up-the-babel-6-ecosystem-c7678a314bf3" rel="noreferrer">this article</a>: </p>
<blockquote>
<p>The distinction between a <code>babel transform plugin</code> versus
<code>babel-polyfill / babel-runtime</code> <strong>is whether or not you can
reimplement t... |
17,981,673 | Execute LambdaExpression and get returned value as object | <p>Is there a clean way to do this?</p>
<pre><code>Expression<Func<int, string>> exTyped = i => "My int = " + i;
LambdaExpression lambda = exTyped;
//later on:
object input = 4;
object result = ExecuteLambdaSomeHow(lambda, input);
//result should be "My int = 4"
</code></pre>
<p>This should work for ... | 17,981,732 | 1 | 5 | null | 2013-07-31 21:56:06.177 UTC | 4 | 2013-07-31 22:24:17.39 UTC | null | null | null | null | 320,623 | null | 1 | 35 | c#|lambda|expression | 13,951 | <p>Sure... you just need to compile your lambda and then invoke it...</p>
<pre><code>object input = 4;
var compiledLambda = lambda.Compile();
var result = compiledLambda.DynamicInvoke(input);
</code></pre>
<p>Styxxy brings up an excellent point... You would be better served by letting the compiler help you out. Not... |
53,309,622 | What is the difference between AssetImage and Image.asset - Flutter | <p>In my application, I use these 2 classes but I don't know which one I should prioritize.</p>
<pre><code>Image.asset('icons/heart.png')
AssetImage('icons/hear.png')
</code></pre>
<p>Maybe there is one who fetches the image faster.</p> | 53,309,748 | 2 | 0 | null | 2018-11-14 22:22:52.66 UTC | 3 | 2022-01-24 10:15:49.737 UTC | null | null | null | null | 2,679,301 | null | 1 | 48 | dart|flutter | 25,521 | <p><code>Image</code> is a <code>StatefulWidget</code> and <code>Image.asset</code> is just a named constructor, you can use it directly on your widget tree.</p>
<p><code>AssetImage</code> is an <code>ImageProvider</code> which is responsible for obtaining the image of the specified path.</p>
<p>If you check the sou... |
36,915,823 | Spring RestTemplate and generic types ParameterizedTypeReference collections like List<T> | <p>An Abstract controller class requires List of objects from REST. While using Spring RestTemplate its not mapping it to required class instead it returns Linked HashMAp</p>
<pre><code> public List<T> restFindAll() {
RestTemplate restTemplate = RestClient.build().restTemplate();
ParameterizedTypeRefere... | 41,182,994 | 7 | 0 | null | 2016-04-28 13:15:17.43 UTC | 9 | 2022-04-24 04:05:10.47 UTC | null | null | null | null | 1,346,369 | null | 1 | 51 | java|resttemplate|spring-rest|spring-web | 79,256 | <p>I worked around this using the following generic method:</p>
<pre><code>public <T> List<T> exchangeAsList(String uri, ParameterizedTypeReference<List<T>> responseType) {
return restTemplate.exchange(uri, HttpMethod.GET, null, responseType).getBody();
}
</code></pre>
<p>Then I could call... |
30,019,323 | How do I enable the preview panel for TypeScript files in Visual Studio 2015? | <p>I miss the feature that would show you the results of your TypeScript compile in a separate panel. I haven't found a way to turn that back on in Visual Studio 2015 with TypeScript 1.5 beta.</p>
<p>I have WebEssentials for 2015 installed as well as ReSharper 9.1.</p>
<p>Anyone have any luck with this?</p> | 31,368,251 | 3 | 1 | null | 2015-05-03 20:59:18.507 UTC | 4 | 2017-09-28 08:07:09.66 UTC | null | null | null | null | 7,756 | null | 1 | 36 | visual-studio|typescript|visual-studio-2015 | 11,495 | <p>This has been removed from Web Essentials 2015 in VS 2015RC.</p>
<p>See: <a href="https://github.com/madskristensen/WebEssentials2015/issues/53" rel="noreferrer">https://github.com/madskristensen/WebEssentials2015/issues/53</a></p>
<blockquote>
<p>madskristensen commented on Jun 8</p>
<p>The TS preview pane... |
29,954,037 | Why is an OPTIONS request sent and can I disable it? | <p>I am building a web API. I found whenever I use Chrome to POST, GET to my API, there is always an OPTIONS request sent before the real request, which is quite annoying. Currently, I get the server to ignore any OPTIONS requests. Now my question is what's good to send an OPTIONS request to double the server's load? I... | 29,954,326 | 15 | 1 | null | 2015-04-29 20:37:22.013 UTC | 217 | 2021-06-18 05:36:38.15 UTC | 2021-03-21 19:49:28.713 UTC | null | 9,918,730 | null | 1,663,023 | null | 1 | 554 | http|cors|preflight | 584,438 | <p><strong>edit 2018-09-13</strong>: added some precisions about this pre-flight request and how to avoid it at the end of this reponse.</p>
<p><code>OPTIONS</code> requests are what we call <code>pre-flight</code> requests in <code>Cross-origin resource sharing (CORS)</code>.</p>
<p>They are necessary when you're ma... |
25,750,253 | bootstrap multiselect(refresh) is not working properly | <p>I am using bootstrap multiselect list box. When user selects options on the multiselect it shows correctly. But there is a option to reset the previously selected options. When user click on reset button, automatically <code>style=display:none</code> is adding to the dropdown button and the dropdown list is becomes ... | 31,607,099 | 6 | 0 | null | 2014-09-09 17:04:26.267 UTC | 9 | 2021-12-28 16:17:17.623 UTC | 2014-09-09 17:12:17.167 UTC | null | 3,408,779 | null | 3,408,779 | null | 1 | 12 | jquery|twitter-bootstrap|bootstrap-multiselect | 61,333 | <p>Other helpful options are:</p>
<ol>
<li><p><code>$('Id').multiselect('refresh');</code> - Refreshs the multiselect based on the selected options of the select.</p></li>
<li><p><code>$('Id').multiselect('destroy');</code> - Unbinds the whole plugin.</p></li>
<li><p><code>buildFilter</code> :Builds the filter.</p></... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.