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
12,208,946
Simple frequency tables using data.table
<p>I'm looking for a way to do simple aggregates / counts via data.table.</p> <p>Consider the iris data, which has 50 observations per species. To count the observations per species I have to summaries over a column other than species, for example "Sepal.Length".</p> <pre><code>library(data.table) dt = as.data.table...
12,208,980
1
0
null
2012-08-31 04:31:40.99 UTC
12
2014-11-11 05:52:23.117 UTC
2012-08-31 04:37:22.017 UTC
null
573,778
null
573,778
null
1
34
r|data.table
17,452
<p><code>data.table</code> has a couple of symbols that can be used within the <code>j</code> expression. Notably</p> <ul> <li><code>.N</code> will give you the number of number of rows in each group.</li> </ul> <p>see <code>?data.table</code> under the details for <code>by</code></p> <blockquote> <p>Advanced: Whe...
12,624,391
Very slow tab switching in Xcode 4.5 (Mountain Lion)
<p>I recently updated my MacBook Pro (2.3 GHz Intel Core i5) from Lion to Mountain Lion and simultaneously upgraded Xcode to the latest 4.5 version. I've experienced one very irritating problem. While programming I'm used to have a couple of tabs opened at a time. Ever since I updated, each time I switch tabs, Xcode fr...
12,755,512
4
5
null
2012-09-27 15:02:24.163 UTC
7
2016-02-26 16:19:25.94 UTC
2017-05-23 11:45:17.207 UTC
null
-1
null
944,766
null
1
52
xcode|macos|xcode4.5
2,590
<p>It's a common issue and was fixed in XCode 4.5.1.</p> <p><a href="https://devforums.apple.com/thread/167765?tstart=0" rel="noreferrer">https://devforums.apple.com/thread/167765?tstart=0</a></p>
3,300,141
convert any date string to timestamp without timezone
<p>I'm getting xml and rss feeds and putting the data into a database. I've run into two different date formats so far...</p> <pre><code>Wed, 21 Jul 2010 00:28:50 GMT </code></pre> <p>And</p> <pre><code>2010-07-20T17:33:19Z </code></pre> <p>I'm sure there will be more. My postgresql database for the date is timesta...
3,300,167
3
0
null
2010-07-21 14:11:27.833 UTC
null
2010-07-21 14:39:22.633 UTC
null
null
null
null
398,053
null
1
16
php|sql|datetime|postgresql
43,999
<p>Use <code>date</code> with <a href="http://php.net/manual/en/function.strtotime.php" rel="noreferrer"><code>strtotime</code></a>:</p> <pre><code>$date = date('Y-m-d H:i:s', strtotime('Wed, 21 Jul 2010 00:28:50 GMT')); echo $date; </code></pre> <p>Result:</p> <pre><code>2010-07-21 05:28:50 </code></pre> <p>.</p> ...
3,897,942
How do I check if a sentence contains a certain word in Python and then perform an action?
<p>Let's say that I ask a user for raw input and they said, "This is a message." If that raw input contained the word "message" it would perform an action after that. Could I see how this can be done?</p>
3,897,974
4
1
null
2010-10-09 21:31:03.45 UTC
7
2022-07-31 15:14:14.063 UTC
2010-10-09 21:33:11.337 UTC
null
15,168
null
359,844
null
1
12
python|input
80,955
<p>Going based on the comment by @knitti, the problem is that you need to split up the sentence into words first, then check:</p> <pre><code>term = &quot;message&quot; #term we want to search for input = raw_input() #read input from user words = input.split() #split the sentence into individual words if term in words...
38,112,891
Angular 2+ - Set base href dynamically
<p>We have an enterprise app that uses Angular 2 for the client. Each of our customers has their own unique url, ex: <code>https://our.app.com/customer-one</code> and <code>https://our.app.com/customer-two</code>. Currently we are able to set the <code>&lt;base href...&gt;</code> dynamically using <code>document.locati...
39,084,260
15
9
null
2016-06-30 02:14:11.383 UTC
72
2022-06-05 08:48:46.837 UTC
2021-05-05 00:10:29.657 UTC
null
3,509,591
null
4,164,216
null
1
165
angular
199,423
<p>Here's what we ended up doing.</p> <p>Add this to index.html. It should be the first thing in the <code>&lt;head&gt;</code> section</p> <pre><code>&lt;base href="/"&gt; &lt;script&gt; (function() { window['_app_base'] = '/' + window.location.pathname.split('/')[1]; })(); &lt;/script&gt; </code></pre> <p>T...
8,761,857
Identifying dependencies of R functions and scripts
<p>I am sifting through a package and scripts that utilize the package, and would like to identify external dependencies. The goal is to modify scripts to specify <code>library(pkgName)</code> and to modify functions in the package to use <code>require(pkgName)</code>, so that these dependencies will be more obvious l...
8,777,882
1
6
null
2012-01-06 17:27:29.227 UTC
17
2013-06-19 22:32:13.477 UTC
2012-01-08 20:11:24.957 UTC
null
805,808
null
805,808
null
1
28
r|dependencies|code-analysis
5,113
<p>First, thanks to @mathematical.coffee to putting me on the path of using Mark Bravington's <code>mvbutils</code> package. The <code>foodweb</code> function is more than satisfactory.</p> <p>To recap, I wanted to know about about checking one package, say <code>myPackage</code> versus another, say <code>externalPack...
20,812,091
Now() without timezone
<p>I have a column <code>added_at</code> of type <code>timestamp without time zone</code>. I want it's default value to be the current date-time but without time zone. The function <code>now()</code> returns a timezone as well.</p> <p>How do I solve that problem?</p>
20,814,972
4
6
null
2013-12-28 07:21:09.563 UTC
19
2022-03-29 13:59:47.767 UTC
2015-01-03 22:55:26.293 UTC
null
939,860
null
2,813,589
null
1
95
postgresql|timestamp|postgresql-9.2
129,515
<pre><code>SELECT now()::timestamp; </code></pre> <p>The cast converts the <code>timestamptz</code> returned by <code>now()</code> to the corresponding <code>timestamp</code> in your time zone - defined by the <a href="https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-TIMEZONE" rel="noreferrer"><co...
25,960,850
Loading initial data with Django 1.7+ and data migrations
<p>I recently switched from Django 1.6 to 1.7, and I began using migrations (I never used South).</p> <p>Before 1.7, I used to load initial data with a <code>fixture/initial_data.json</code> file, which was loaded with the <code>python manage.py syncdb</code> command (when creating the database).</p> <p>Now, I starte...
25,981,899
8
5
null
2014-09-21 15:37:13.787 UTC
48
2022-09-16 08:39:51.287 UTC
2022-09-15 11:37:07 UTC
null
4,720,018
null
2,649,093
null
1
102
python|json|django|migration|data-migration
42,178
<p><em>Update</em>: See @GwynBleidD's comment below for the problems this solution can cause, and see @Rockallite's answer below for an approach that's more durable to future model changes.</p> <hr> <p>Assuming you have a fixture file in <code>&lt;yourapp&gt;/fixtures/initial_data.json</code></p> <ol> <li><p>Create ...
22,383,345
AngularJS: ng-click on img? Manipulating images (kind of gallery-like) with jQuery?
<p>Should ng-click work with img tag ? </p> <pre><code>&lt;img ng-src="img" ng-click="openNewWindow(url)/&gt; </code></pre> <p>myFunction is defined in controller and is $scope available … Nothing gets called; any ideas? </p> <p>(I would like to open a new tab/window when image is clicked, but I don't even get into...
22,384,840
4
4
null
2014-03-13 15:27:35.237 UTC
3
2017-07-19 21:14:14.86 UTC
2014-03-14 07:06:14.697 UTC
null
1,524,316
null
1,524,316
null
1
16
angularjs|angularjs-ng-click
75,500
<p>Yes, <code>ng-click</code> works on images. </p> <p>Without further code I can't tell you why yours isn't working, but the code you have pasted will call <code>myFunction</code> in the scope of the controller governing that element.</p> <p><strong>EDIT</strong></p> <p>You definitely don't need to use jQuery for t...
11,250,974
How to change existing column type of a table in Sybase?
<p>I searched for a while and can't get an answer.</p> <p>Why this doesn't work? ALTER TABLE mytable ALTER COLUMN price DOUBLE</p>
11,258,522
2
2
null
2012-06-28 18:43:36.493 UTC
3
2014-04-07 08:51:03.807 UTC
null
null
null
null
884,871
null
1
5
sybase|alter-table
48,148
<p>The syntax is incorrect and there is no DOUBLE datatype in Sybase.</p> <p>So, you may try it like this:</p> <pre><code>ALTER TABLE mytable MODIFY price float </code></pre>
11,374,759
Redirect to referer url in codeigniter
<p>In messaging system of my project when you get a message from a user you a email alert saying that the another user has sent a message to view the message click here (i.e the url of message) So if the user is not logged in to system he gets redirect to login page and after login it should get back to the referer url...
15,991,205
5
0
null
2012-07-07 11:52:01.113 UTC
3
2021-08-05 15:49:01.21 UTC
null
null
null
null
1,396,514
null
1
17
php|codeigniter|http-referer
74,696
<p>This can help:</p> <p>CI 2+ <a href="https://www.codeigniter.com/userguide2/libraries/user_agent.html" rel="nofollow noreferrer">https://www.codeigniter.com/userguide2/libraries/user_agent.html</a></p> <p>CI 3+ <a href="http://www.codeigniter.com/userguide3/libraries/user_agent.html" rel="nofollow noreferrer">http:/...
10,865,237
website header hiding behind content when position is fixed
<p>I am designing a website for a school and I want the header of site to be fixed just like facebook has. I tried the fix provided by <a href="https://stackoverflow.com/questions/7573089/page-navigation-with-fixed-header">this</a> question on stackoverflow but it was hardly of any use in the header. I have an image, b...
10,865,264
6
2
null
2012-06-02 19:23:13.967 UTC
1
2020-08-10 16:25:38.113 UTC
2017-05-23 12:02:20.3 UTC
null
-1
null
1,160,051
null
1
19
css|css-position
87,579
<p>Add z-index:1000 to the #header css, and add padding-top to the body css which should be a bit more than header's height. For example, if the header's height is 40px, put the padding-top: 50px to the body css and it should work.</p>
11,315,204
How to get 2 digit hour and minutes from Rails time class
<p>I am looking at </p> <p><a href="http://corelib.rubyonrails.org/classes/Time.html#M000245" rel="noreferrer">http://corelib.rubyonrails.org/classes/Time.html#M000245</a></p> <p>how can I get two digit hour and minutes from a time object</p> <p>Lets say I do </p> <pre><code>t = Time.now t.hour // this returns 7 I...
11,315,235
5
0
null
2012-07-03 16:26:24.723 UTC
5
2021-06-08 19:48:05.327 UTC
null
null
null
null
395,842
null
1
22
ruby-on-rails|datetime
42,833
<p>How about using <a href="http://ruby-doc.org/core-1.9.3/String.html#method-i-25" rel="noreferrer">String.format</a> (%) operator? Like this:</p> <pre><code>x = '%02d' % t.hour puts x # prints 07 if t.hour equals 7 </code></pre>
11,255,451
Eclipse and EGit: How to easily review changes to ALL modified files before committing to *local* repository
<p>I'm using Eclipse Indigo SR2 with the (built-in) EGit plugin v.1.3.0.201202151440-r and haven't been able to find any way to easily review all my changes before making a commit.</p> <p>I used Eclipse with SVN for years, and this was always very easy to do. I would typically right-click on my project, select <code>T...
11,256,271
3
1
null
2012-06-29 02:49:20.053 UTC
13
2019-06-26 15:10:05.433 UTC
2015-02-12 23:38:37.157 UTC
null
1,339,923
null
1,339,923
null
1
46
eclipse|git|egit
62,569
<p>Are you aware of the 'Git Staging' view. It keeps track of all the files that have changed and you can review the changes any time. (This can be a bit better than using the commit dialog)</p> <p>An alternative is to commit all changes without reviewing, and then use the history view to compare two commits (Simply s...
12,865,848
General purpose FromEvent method
<p>Using the new async/await model it's fairly straightforward to generate a <code>Task</code> that is completed when an event fires; you just need to follow this pattern:</p> <pre><code>public class MyClass { public event Action OnCompletion; } public static Task FromEvent(MyClass obj) { TaskCompletionSource...
12,867,906
4
2
null
2012-10-12 19:31:05.193 UTC
18
2020-03-24 19:12:36.513 UTC
2018-08-06 07:52:58.293 UTC
null
1,016,343
null
1,159,478
null
1
7
c#|async-await|task-parallel-library|cil|reflection.emit
2,788
<p>Here you go:</p> <pre><code>internal class TaskCompletionSourceHolder { private readonly TaskCompletionSource&lt;object[]&gt; m_tcs; internal object Target { get; set; } internal EventInfo EventInfo { get; set; } internal Delegate Delegate { get; set; } internal TaskCompletionSourceHolder(Task...
12,812,893
Passing 'this' to an onclick event
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/4268085/the-current-element-as-its-event-function-param">The current element as its Event function param</a> </p> </blockquote> <p>Would this work</p> <pre><code>&lt;script type="text/javascript"&gt; var foo =...
12,812,986
4
2
null
2012-10-10 06:00:55.91 UTC
11
2012-10-10 06:25:06.437 UTC
2017-05-23 12:34:33.157 UTC
null
-1
null
1,686,064
null
1
50
javascript|html
149,472
<p>The code that you have would work, but is executed from the global context, which means that <code>this</code> refers to the global object.</p> <pre><code>&lt;script type="text/javascript"&gt; var foo = function(param) { param.innerHTML = "Not a button"; }; &lt;/script&gt; &lt;button onclick="foo(this)" id="bar...
11,312,433
How to alter a column and change the default value?
<p>I got the following error while trying to alter a column's data type and setting a new default value:</p> <pre><code>ALTER TABLE foobar_data ALTER COLUMN col VARCHAR(255) NOT NULL SET DEFAULT '{}'; </code></pre> <blockquote> <p>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that cor...
11,312,469
8
1
null
2012-07-03 13:51:43.457 UTC
38
2022-03-29 10:54:53.6 UTC
2012-07-03 13:53:37.207 UTC
null
458,741
null
1,150,778
null
1
247
mysql|sql
403,001
<pre><code>ALTER TABLE foobar_data MODIFY COLUMN col VARCHAR(255) NOT NULL DEFAULT '{}'; </code></pre> <p>A second possibility which does the same (thanks to juergen_d):</p> <pre><code>ALTER TABLE foobar_data CHANGE COLUMN col col VARCHAR(255) NOT NULL DEFAULT '{}'; </code></pre>
10,964,966
Detect IE version (prior to v9) in JavaScript
<p>I want to bounce users of our web site to an error page if they're using a version of <code>Internet Explorer</code> prior to v9. It's just not worth our time and money to support <code>IE pre-v9</code>. Users of all other non-IE browsers are fine and shouldn't be bounced. Here's the proposed code:</p> <pre><code>i...
10,965,091
37
10
null
2012-06-09 22:13:23.48 UTC
129
2018-10-01 05:20:49.78 UTC
2016-07-20 09:41:21.017 UTC
null
2,306,173
null
1,040,766
null
1
253
javascript|internet-explorer|user-agent|browser-detection
387,824
<p>This is my preferred way of doing it. It gives maximum control. (Note: Conditional statements are only supported in IE5 - 9.)</p> <p>First set up your ie classes correctly</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;!--[if lt IE 7]&gt; &lt;html class="lt-ie9 lt-ie8 lt-ie7"&gt; &lt;![endif]--&gt; &lt;!--[if IE 7]&gt; ...
16,765,158
"date(): It is not safe to rely on the system's timezone settings..."
<p>I got this error when I requested to update the <a href="http://en.wikipedia.org/wiki/PHP">PHP</a> version from 5.2.17 to PHP 5.3.21 on the server.</p> <pre><code>&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt; &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt; &lt;p&gt;Severity: W...
16,765,214
25
0
null
2013-05-27 01:05:31.163 UTC
66
2021-07-10 10:52:09.35 UTC
2016-01-04 18:26:27.897 UTC
null
1,691,225
null
1,852,837
null
1
382
php|timezone
598,362
<p>You probably need to put the timezone in a configuration line in your <code>php.ini</code> file. You should have a block like this in your php.ini file:</p> <pre><code>[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = America/New_York </code></pre> <p>I...
25,892,417
Caused by: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date
<p>I am getting the below given error for the following code snippets:</p> <pre><code> try { cRows = new CachedRowSetImpl(); while(cRows.next()) { MyClass myClass = new MyClass(); myClass.setPrevDate(cRows.getDate("PREV_DATE")); // In debug mode, the error was throwing when I ...
25,915,418
2
5
null
2014-09-17 13:47:45.513 UTC
1
2014-09-19 03:55:55.4 UTC
2014-09-17 13:52:39.42 UTC
null
3,892,259
null
930,544
null
1
3
java|classcastexception|cachedrowset
43,998
<p>I have done a research on this issue and found some useful links. I found this confusion between DATE and TIMESTAMP is JDBC Driver specific. And most of the links suggest the use of <code>-Doracle.jdbc.V8Compatible=true</code>. For my JBoss I have set this in <code>run.bat</code> and the issue got resolved.</p> <ol...
25,591,040
Nginx serves .php files as downloads, instead of executing them
<p>I am installing a website in a droplet (Digital Ocean). I have an issue for install NGINX with PHP properly. I did a tutorial <a href="https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04" rel="nofollow noreferrer">https://www.digitalocean.com/community/tut...
26,668,444
29
9
null
2014-08-31 10:24:17.423 UTC
48
2022-09-19 10:38:34.383 UTC
2022-09-19 10:37:40.56 UTC
null
5,409,748
null
3,287,988
null
1
192
php|wordpress|nginx|location|fastcgi
338,956
<p>Try this:</p> <ol> <li><p>Edit <code>/etc/nginx/sites-available/default</code></p> </li> <li><p>Uncomment both listen lines to make Nginx listen on port 80 IPv4 and IPv6.</p> <pre><code> listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default_server ipv6only=on; ## listen for ipv6...
57,848,302
How to solve 'command find requires authentication' using Node.js and mongoose?
<p>I need help to fix the error. My ubuntu server 16.04 running:</p> <p>MongoDB shell version v4.0.9</p> <p>Node 11.6</p> <p>mongoose 5.3.4</p> <p>When the security on /etc/mongod.conf is:</p> <p><code>security: authorization: "disabled"</code> I can use :</p> <pre><code>const mongoURI = 'mongodb://writeA...
57,877,333
2
5
null
2019-09-09 05:27:42.177 UTC
7
2021-01-22 11:56:20.043 UTC
2019-09-09 06:29:31.803 UTC
null
5,433,806
null
5,433,806
null
1
24
node.js|mongodb|mongoose
68,807
<p><strong>1. How to connect from terminal and mongo:</strong></p> <p>When you install MongoDB the authorization is disabled. So keep it like that for now. Create a root user in admin database:</p> <p>Type: <code>mongod</code> in a terminal to run db, and then in another terminal run command <code>mongo</code> to run a...
4,813,728
Change individual markers in google maps directions api V3
<p>I'm looking to change the marker icons when using the DirectionsRender within a google map. I've figured out from <a href="https://stackoverflow.com/questions/4312961/how-do-i-change-the-start-and-end-marker-image-in-google-maps-v3-api-for-directio">here</a> how to change both the markers to the same icon, but I am ...
5,199,909
2
0
null
2011-01-27 07:23:52.35 UTC
17
2015-05-30 14:56:55.517 UTC
2017-05-23 12:25:48.28 UTC
null
-1
null
110,313
null
1
34
javascript|google-maps|google-maps-api-3
57,355
<p>For those that need an example like I did, here's a basic one:</p> <pre><code> // Map and directions objects var map = new google.maps.Map( element, options ); var service = new google.maps.DirectionsService(); var directions = new google.maps.DirectionsRenderer({suppressMarkers: true}); // Start/Finish icons ...
9,845,833
Do multiple Solr shards on a single machine improve performance?
<p>Does running multiple Solr shards on a single machine improve performance? I would expect Lucene to be multi-threaded, but it doesn't seem to be using more than a single core on my server with 16 physical cores. I realize this is workload dependent, but any statistics or benchmarks would be very useful!</p>
9,856,105
2
5
null
2012-03-23 20:05:06.607 UTC
8
2012-04-21 17:14:05.157 UTC
2012-04-21 17:14:05.157 UTC
null
968,269
null
968,269
null
1
14
performance|solr|lucene
3,985
<p>I ran some <a href="http://carsabi.com/car-news/2012/03/23/optimizing-solr-7x-your-search-speed/" rel="noreferrer">benchmarks of our search stack</a>, and found that adding more Solr shards (on a single machine, with 16 physical cores) did improve performance up to about 8 shards (where I got a 6.5x speed up). This ...
9,719,078
After postback my JavaScript function doesn't work in ASP.NET
<p>I have common functions and I collapse it on <code>CommonFunctions.js</code> in Scripts folder.</p> <p>I include it on my master page and use it on my pages. When I do any post back on a page, my function doesn't work.</p> <p>My <code>CommonFunctions.js</code>:</p> <pre><code>$(function () { gf(); if (S...
9,719,201
7
4
null
2012-03-15 11:50:39.217 UTC
1
2021-06-10 07:58:33.413 UTC
2021-06-10 07:58:33.413 UTC
null
714,869
null
714,869
null
1
16
c#|jquery|asp.net|postback
49,895
<p>Since you're using an <code>UpdatePanel</code>, the part of the DOM that you've attached your event handler to is getting dropped and recreated after the postback. This has the effect of removing any event handlers that were attached by jQuery when the page first loaded.</p> <p>When you postback only part of the pa...
9,972,769
Start Broadcast Receiver from an activity in android
<p>I would like to start a broadcast receiver from an activity. I have a Second.java file which extends a broadcast receiver and a Main.java file from which I have to initiate the broadcast receiver. I also tried doing everything in Main.java as follows but didn't know how to define in manifest file... </p> <h2>Main....
9,973,059
4
1
null
2012-04-02 08:01:11.96 UTC
6
2018-01-26 10:50:13.72 UTC
null
null
null
null
1,294,721
null
1
18
android|broadcastreceiver
52,472
<p>use this why to send a custom broadcast:</p> <p>Define an action name:</p> <pre><code>public static final String BROADCAST = "PACKAGE_NAME.android.action.broadcast"; </code></pre> <p>AndroidManifest.xml register receiver :</p> <pre><code>&lt;receiver android:name=".myReceiver" &gt; &lt;intent-filter &gt; ...
9,802,736
Maven build [WARNING] we have a duplicate class
<p>Anybody has any idea what happened to my maven build? I am getting a lot of duplicate warnings.</p> <pre><code>[WARNING] We have a duplicate org/apache/commons/logging/impl/LogFactoryImpl$1.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar [WARNING] We ha...
9,807,806
8
1
null
2012-03-21 10:30:44.99 UTC
4
2018-09-15 17:13:38.213 UTC
2016-03-18 21:35:55.077 UTC
null
658,663
null
1,275,937
null
1
31
maven|build|maven-shade-plugin|apache-commons-logging
41,845
<p>Take a look at the "Dependency Exclusions" section in the <a href="http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html" rel="noreferrer">Maven doc</a>.</p> <p>In your provided example, I'll exclude the <code>commons-logging:commons-logging-api:jar:1.0.4:compile</code>...
10,095,219
How to test nginx subdomains on localhost
<p>I want to test nginx subdomains before uploading config to the server. Can i test it on localhost? I try</p> <pre><code>server { listen 80; server_name localhost; location / { proxy_pass http://localhost:8080; } } server { listen 80; server_name sub.localhost; lo...
10,409,774
4
0
null
2012-04-10 19:34:26.447 UTC
12
2022-06-14 15:32:48.457 UTC
null
null
null
null
750,510
null
1
37
nginx|subdomain
38,953
<p>Yes, add '127.0.0.1 sub.localhost' to your hosts file. That sub has to be resolved somehow. That should work.</p> <p>Then once you're ready to go to the net, yes, add an a or cname record for the subdomain sub.</p> <p>When I use proxy_pass I also include the proxy.conf from nginx. <a href="http://wiki.nginx.org/Ht...
27,987,048
Shake Animation for UITextField/UIView in Swift
<p>I am trying to figure out how to make the text Field shake on button press when the user leaves the text field blank.</p> <p>I currently have the following code working:</p> <pre><code>if self.subTotalAmountData.text == "" { let alertController = UIAlertController(title: "Title", message: "What is the...
27,988,876
10
4
null
2015-01-16 15:15:25.673 UTC
37
2020-09-28 18:21:52.203 UTC
2015-01-16 17:26:22.843 UTC
null
2,224,577
null
4,454,828
null
1
71
ios|swift|uitextfield
53,446
<p>You can change the <code>duration</code> and <code>repeatCount</code> and tweak it. This is what I use in my code. Varying the <code>fromValue</code> and <code>toValue</code> will vary the distance moved in the shake.</p> <pre><code>let animation = CABasicAnimation(keyPath: "position") animation.duration = 0.07 ani...
28,042,426
Spring Boot - Error creating bean with name 'dataSource' defined in class path resource
<p>I have Spring Boot web application. It's centered around RESTful approach. All configuration seems in place but for some reason MainController fails to handle request. It results in 404 error. How to fix it?</p> <pre><code>@Controller public class MainController { @Autowired ParserService parserService; ...
31,199,853
28
6
null
2015-01-20 09:59:44.7 UTC
26
2022-09-22 12:23:11.8 UTC
2021-10-29 05:57:06.693 UTC
null
1,155,514
null
480,632
null
1
94
java|spring|spring-boot
603,106
<p>Looks like the initial problem is with the auto-config.</p> <p>If you don't need the datasource, simply remove it from the auto-config process:</p> <pre><code>@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) </code></pre> <p>Edit: If using @SpringBootApplication in your main class:</p> <pre><cod...
10,147,455
How to send an email with Gmail as provider using Python?
<p>I am trying to send email (Gmail) using python, but I am getting following error.</p> <pre><code>Traceback (most recent call last): File "emailSend.py", line 14, in &lt;module&gt; server.login(username,password) File "/usr/lib/python2.5/smtplib.py", line 554, in login raise SMTPException("SMTP AUTH extensio...
10,147,497
16
1
null
2012-04-13 19:54:18.263 UTC
162
2022-07-01 18:12:00.457 UTC
2022-02-06 15:35:32.48 UTC
null
8,172,439
null
869,240
null
1
316
python|email|smtp|gmail|smtp-auth
403,594
<p>You need to say <code>EHLO</code> before just running straight into <code>STARTTLS</code>:</p> <pre><code>server = smtplib.SMTP('smtp.gmail.com:587') server.ehlo() server.starttls() </code></pre> <hr /> <p>Also you should really create <code>From:</code>, <code>To:</code> and <code>Subject:</code> message headers, s...
10,124,679
What happens if I read a map's value where the key does not exist?
<pre><code>map&lt;string, string&gt; dada; dada["dummy"] = "papy"; cout &lt;&lt; dada["pootoo"]; </code></pre> <p>I'm puzzled because I don't know if it's considered undefined behaviour or not, how to know when I request a key which does not exist, do I just use find instead ?</p>
10,124,703
7
0
null
2012-04-12 13:33:31.93 UTC
14
2019-07-08 18:22:15.567 UTC
null
null
null
null
414,063
null
1
116
c++|map
106,962
<p>The <code>map::operator[]</code> searches the data structure for a value corresponding to the given key, and returns a reference to it.</p> <p>If it can't find one it transparently creates a default constructed element for it. (If you do not want this behaviour you can use the <code>map::at</code> function instead...
10,024,866
Remove Object from Array using JavaScript
<p>How can I remove an object from an array? I wish to remove the object that includes name <code>Kristian</code> from <code>someArray</code>. For example:</p> <pre><code>someArray = [{name:&quot;Kristian&quot;, lines:&quot;2,5,10&quot;}, {name:&quot;John&quot;, lines:&quot;1,19,26,96&quot;}]; </code></pre...
10,024,926
32
0
null
2012-04-05 08:07:51.663 UTC
164
2022-08-23 08:51:54.817 UTC
2021-01-27 19:33:45.447 UTC
null
860,099
null
1,269,179
null
1
737
javascript|arrays
1,384,555
<p>You can use several methods to remove item(s) from an Array:</p> <pre><code>//1 someArray.shift(); // first element removed //2 someArray = someArray.slice(1); // first element removed //3 someArray.splice(0, 1); // first element removed //4 someArray.pop(); // last element removed //5 someArray = someArray.slice(0,...
11,931,633
CakePHP find condition for a query between two dates
<p>I have a start and an end date in my database and a $date variable from a form field. I am now trying to query all the rows where $date is either = start/end date in the db, or ANY date between those two.</p> <p>It's kind of the opposite of what is described in the docs of how daysAsSql works. I can't figure out ho...
11,932,226
6
4
null
2012-08-13 09:38:29.453 UTC
5
2019-03-05 12:37:49.747 UTC
2012-08-13 10:03:33.383 UTC
null
1,456,294
null
1,456,294
null
1
11
cakephp|date|time|between
51,514
<pre><code>$conditions = array( 'conditions' =&gt; array( 'and' =&gt; array( array('Item.date_start &lt;= ' =&gt; $date, 'Item.date_end &gt;= ' =&gt; $date ), 'Item.title LIKE' =&gt; "%$title%", 'I...
11,567,176
How do you set up .vimrc
<p>How do you set up a .vimrc file on Ubuntu?</p> <p>This is not helping: <a href="http://vim.wikia.com/wiki/Open_vimrc_file" rel="noreferrer">http://vim.wikia.com/wiki/Open_vimrc_file</a></p> <ol> <li>Where do you create it?</li> <li>Whats the format inside?</li> </ol> <p>I know the stuff I want to put in it, just ...
11,567,239
4
1
null
2012-07-19 18:34:25.393 UTC
16
2018-11-02 20:16:26.913 UTC
2012-07-19 19:23:36.05 UTC
null
275,567
null
693,950
null
1
30
ubuntu|vim
94,836
<p><strong>Where:</strong></p> <p>On UN*X systems your .vimrc belongs in your <em>home directory</em>. At a terminal, type:</p> <pre><code>cd $HOME vim .vimrc </code></pre> <p>This will change to your home directory and open .vimrc using vim. In vim, add the commands that you know you want to put in, then type <code...
11,457,670
Where are the headers of the C++ standard library
<p>I wonder where on my file system I find the headers of the C++ Standard library. In particular I am looking for the definition of the vector template. I searched in /usr/include/ and various subdirectories. I also tried 'locate vector.h' which brought up many implementations of vectors, but not the standard one. ...
11,457,817
6
1
null
2012-07-12 17:52:17.123 UTC
12
2019-12-27 08:23:32.627 UTC
2018-02-20 21:36:18.547 UTC
null
608,639
null
447,839
null
1
37
c++|linux|stl|header-files|c++-standard-library
77,563
<p>GCC typically has the standard C++ headers installed in <code>/usr/include/c++/&lt;version&gt;/</code>. You can run <code>gcc -v</code> to find out which version you have installed.</p> <p>At least in my version, there is no <code>vector.h</code>; the public header is just <code>vector</code> (with no extension), a...
11,944,745
ASP.NET Bundles how to disable minification
<p>I have <code>debug="true"</code> in both my <em>web.config(s)</em>, and I just don't want my bundles minified, but nothing I do seems to disable it. I've tried <code>enableoptimisations=false</code>, here is my code:</p> <pre><code>//Javascript bundles.Add(new ScriptBundle("~/bundles/MainJS") .Include("...
11,960,820
14
2
null
2012-08-14 01:55:17.2 UTC
42
2020-12-01 21:14:54.93 UTC
2016-05-09 05:31:36.36 UTC
null
863,110
null
314,963
null
1
201
asp.net|asp.net-mvc|asp.net-mvc-4|bundle|asp.net-optimization
158,657
<p>If you have <code>debug="true"</code> in <em>web.config</em> and are using <code>Scripts/Styles.Render</code> to reference the bundles in your pages, that should turn off both bundling and minification. <code>BundleTable.EnableOptimizations = false</code> will always turn off both bundling and minification as well (...
19,973,037
Benchmark memory usage in PHP
<p>Let us suppose that we have some problem and at least two solutions for it. And what we want to achieve - is to compare effectiveness for them. How to do this? Obviously, the best answer is: <em>do tests</em>. And I doubt there's a better way when it comes to language-specific questions (for example &quot;what is fa...
19,974,019
5
5
null
2013-11-14 08:41:11.11 UTC
15
2022-08-01 17:41:05.1 UTC
2022-08-01 17:41:05.1 UTC
null
1,839,439
null
2,637,490
null
1
22
php|performance|memory|benchmarking
5,903
<pre><code>declare(ticks=1); // should be placed before any further file loading happens </code></pre> <p>That should say already all what I will say.</p> <p>Use a tick handler and print on every execution the memory usage to a file with the file line with:</p> <pre><code>function tick_handler() { $mem = memory_...
3,947,889
MongoDB: Terrible MapReduce Performance
<p>I have a long history with relational databases, but I'm new to MongoDB and MapReduce, so I'm almost positive I must be doing something wrong. I'll jump right into the question. Sorry if it's long.</p> <p>I have a database table in MySQL that tracks the number of member profile views for each day. For testing it ha...
3,951,871
4
3
null
2010-10-16 06:11:11.603 UTC
28
2017-07-11 09:24:28.73 UTC
2017-09-22 18:01:22.247 UTC
null
-1
null
401,019
null
1
42
mongodb|mapreduce|nosql
26,727
<p>excerpts from MongoDB Definitive Guide from O'Reilly:</p> <blockquote> <p>The price of using MapReduce is speed: group is not particularly speedy, but MapReduce is slower and is not supposed to be used in “real time.” You run MapReduce as a background job, it creates a collection of results, and the...
3,561,120
Open alternatives to Google-maps?
<p>I'm looking for an alternative to Google-maps with all the richness of their API but more open. Does such a thing exist?</p>
3,561,159
6
2
null
2010-08-24 21:19:16.427 UTC
18
2015-02-10 09:35:42.347 UTC
2010-08-25 10:22:02.33 UTC
null
73,488
null
358,438
null
1
36
google-maps|geolocation|maps|geospatial
22,337
<p><a href="http://www.openstreetmap.org" rel="noreferrer">OpenStreetMap</a> is, of course, the obvious answer. There are various APIs for managing the data in the database, and there are various APIs for getting maps onto your webpages, such as <a href="http://wiki.openstreetmap.org/wiki/OpenLayers" rel="noreferrer">O...
3,630,645
How to compare Unicode strings in Javascript?
<p>When I wrote in JavaScript <code>"Ł" &gt; "Z"</code> it returns <code>true</code>. In Unicode order it should be of course <code>false</code>. How to fix this? My site is using UTF-8.</p>
23,618,442
6
8
null
2010-09-02 19:47:08.173 UTC
19
2019-01-23 06:50:01.587 UTC
2015-04-03 11:44:35.427 UTC
null
527,702
null
377,095
null
1
43
javascript|compare|polish
26,335
<p>You can use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator" rel="noreferrer"><code>Intl.Collator</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare" rel="noreferrer"><code>String.prototype.lo...
3,365,766
php - get numeric index of associative array
<p>I have an associative array and I need to find the numeric position of a key. I could loop through the array manually to find it, but is there a better way build into PHP?</p> <pre><code>$a = array( 'blue' =&gt; 'nice', 'car' =&gt; 'fast', 'number' =&gt; 'none' ); // echo (find numeric index of $a['car'...
3,365,793
7
0
null
2010-07-29 18:22:44.377 UTC
23
2021-10-15 15:33:31.903 UTC
2016-05-30 16:04:09.85 UTC
null
1,207,687
null
276,315
null
1
167
php|arrays
134,302
<pre><code>echo array_search("car",array_keys($a)); </code></pre>
3,524,862
When should I use a TreeMap over a PriorityQueue and vice versa?
<p>Seems they both let you retrieve the minimum, which is what I need for Prim's algorithm, and force me to remove and reinsert a key to update its value. Is there any advantage of using one over the other, not just for this example, but generally speaking?</p>
3,524,893
11
3
null
2010-08-19 18:12:05.07 UTC
19
2022-09-23 12:22:37.86 UTC
null
null
null
null
383,330
null
1
50
java|priority-queue|treemap
24,729
<p>Generally speaking, it is less work to track only the minimum element, using a heap.</p> <p>A tree is more organized, and it requires more computation to maintain that organization. But if you need to access <em>any</em> key, and not just the minimum, a heap will not suffice, and the extra overhead of the tree is j...
8,019,798
blank white screen after FB login via web app?
<p>I have tried following the FB mobile web "getting started guide" at: <a href="https://developers.facebook.com/docs/guides/mobile/web/" rel="noreferrer">https://developers.facebook.com/docs/guides/mobile/web/</a> for a web app that I open full-screen on my iphone.</p> <p>but when I try to login using the fb login pa...
8,067,119
4
1
null
2011-11-05 11:13:36.807 UTC
8
2016-11-10 08:23:31.657 UTC
null
null
null
null
389,023
null
1
11
iphone|facebook|web-applications|mobile|web
20,232
<p>I have found a workaround to the issue... seems there is an undocumented 'redirect_uri' attribute I can use in the login() method, e.g. </p> <pre><code>login({scope:'email', redirect_uri:'where_to_go_when_login_ends'}) </code></pre> <p>It IS documented for fb desktop SDKs, so I gave it a go and it sort of works. W...
7,775,767
Javascript: Overriding XMLHttpRequest.open()
<p>How would I be able to override the <code>XMLHttpRequest.open()</code> method and then catch and alter it's arguments?</p> <p>I've already tried the proxy method but it didn't work, although removing the open over-rid when <code>XMLHttpRequest()</code> was called: </p> <pre><code>(function() { var proxied = wi...
7,778,218
4
5
null
2011-10-15 04:34:58.97 UTC
12
2019-11-14 03:27:51.293 UTC
2011-10-15 06:36:55.98 UTC
null
6,992
null
744,319
null
1
23
javascript|ajax|xmlhttprequest|overriding
24,868
<p>You are not modifying the <code>open</code> method inherited by <code>XMLHttpRequest objects</code> but just adding a method to the <code>XMLHttpRequest constructor</code> which is actually never used.</p> <p>I tried this code in facebook and I was able to catch the requests:</p> <pre><code>(function() { var p...
7,792,459
canvas vs. webGL vs. CSS 3d -> which to choose?
<p>For basic 3d web application i.e. a few cubes, rotation and translation in 3d space - which is better to choose?</p> <p>CSS 3d seems the easiest, but is not supported on IE9 or on the roadmap for IE10, and offers less control than the other options. Canvas &amp; WebGL seems way more complicated, but I don't know if...
7,792,691
4
3
null
2011-10-17 10:30:23.97 UTC
12
2015-01-30 13:31:41.86 UTC
null
null
null
null
465,401
null
1
32
css|html|canvas|3d|webgl
34,121
<p>The reason there are so many different options for 3D is because the whole thing is still in a state of flux -- 3D in the browser isn't a finished standard, and of the options you listed, the only one that works in all currently available browsers is Canvas.</p> <p>IE in particular is unlikely to give you much joy ...
8,338,241
How we can use @font-face in Less
<p>In <a href="http://lesscss.org/" rel="noreferrer">Less</a>, it seems almost impossible to use <code>@font-face</code> selector. Less gives errors when I try to use </p> <pre><code>font-family: my_font </code></pre> <p>Here is how I try to use it:</p> <pre class="lang-css prettyprint-override"><code>@font-face { ...
8,810,508
4
3
null
2011-12-01 08:12:46.24 UTC
5
2021-06-11 00:23:13.483 UTC
2016-04-02 02:25:41.553 UTC
null
1,696,030
null
567,897
null
1
38
less|font-face
79,513
<p>Have you tried putting the font family name in single quotes? The following works just fine for me.</p> <pre><code> @font-face { font-family: 'cblockbold'; src: url('assets/fonts/creabbb_-webfont.eot'); src: url('assets/fonts/creabbb_-webfont.eot?#iefix') format('embedded-opentype'), ...
8,020,297
MySQL my.cnf file - Found option without preceding group
<p>I'm trying to connect to my DB in Ubuntu remotely but I receive error message when trying to <code>mysql -u root -p</code>:</p> <blockquote> <p>Found option without preceding group in config file: /etc/mysql/my.cnf at line: 1</p> </blockquote> <p>my.cnf looks like:</p> <pre><code>[mysqld] user = mysql so...
8,020,319
5
4
null
2011-11-05 12:56:26.417 UTC
17
2020-01-13 18:32:41.96 UTC
2011-11-05 12:58:47.89 UTC
null
23,199
null
660,187
null
1
82
mysql|my.cnf
133,279
<h2>Charset encoding</h2> <p>Check the charset encoding of the file. Make sure that it is in ASCII.</p> <p>Use the <code>od</code> command to see if there is a UTF-8 BOM at the beginning, for example.</p>
7,950,884
How to get a value inside an ArrayList java
<p>I am trying to get a value from with in an ArrayList. Here is a sample of my code: </p> <pre><code>public static void main (String [] args){ Car toyota= new Car("Toyota", "$10000", "300"+ "2003"); Car nissan= new Car("Nissan", "$22000", "300"+ "2011"); Car ford= new Car("Ford", "$15000", "350"+ "2010");...
7,950,919
7
0
null
2011-10-31 07:22:46.667 UTC
11
2018-12-21 15:41:41.353 UTC
2015-11-30 19:01:30.4 UTC
null
5,076,266
null
941,748
null
1
12
java
228,072
<p>Assuming your <code>Car</code> class has a getter method for price, you can simply use</p> <pre><code>System.out.println (car.get(i).getPrice()); </code></pre> <p>where <code>i</code> is the index of the element.</p> <p>You can also use</p> <pre><code>Car c = car.get(i); System.out.println (c.getPrice()); </code...
8,197,089
Fatal Error when updating submodule using GIT
<p>I am trying to update the submodules of this git repositary but I keep getting a fatal errors:</p> <pre><code>[root@iptlock ProdigyView]# git submodule update --recursive Cloning into core... Permission denied (publickey). fatal: The remote end hung up unexpectedly Clone of 'git@github.com:ProdigyView/ProdigyView-C...
8,197,296
8
1
null
2011-11-19 20:33:57.733 UTC
20
2020-05-15 19:20:48.077 UTC
2018-01-21 00:58:36.193 UTC
null
819,340
null
456,850
null
1
55
git|github|ssh|git-submodules
85,049
<p>Figured it out. The path in the .gitmodule files could not download the submodule.</p>
8,212,032
Sql Server replication requires the actual server name to make a connection to the server
<p>I get the following message when I want to create a new publication or Subscription.</p> <p>"Sql Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address or any other alternate name are not supported. specify the actual server name"</p> <...
8,223,535
9
1
null
2011-11-21 12:46:41.007 UTC
9
2020-10-12 05:53:56.257 UTC
2017-03-28 05:13:20.777 UTC
null
2,975,396
null
606,480
null
1
46
sql-server|sql-server-2008-r2
94,216
<p>I found the solution in the following link <a href="http://www.cryer.co.uk/brian/sqlserver/replication_requires_actual_server_name.htm" rel="noreferrer">http://www.cryer.co.uk/brian/sqlserver/replication_requires_actual_server_name.htm</a></p> <p>thankful to Brian Cryer for his useful site</p> <p><strong>Quoting f...
4,288,089
Reuse identity value after deleting rows
<p>Is it possible to reuse an identity field value after deleting rows in SQL Server 2008 Express? Here is an example. Suppose I have a table with an Id field as a primary key (identity). If I add five rows, I will have these 5 Ids: 1, 2, 3, 4, 5. If I were to delete these rows, and then add five more, the new rows wou...
4,288,110
3
3
null
2010-11-26 19:34:03.613 UTC
6
2010-11-26 19:55:11.817 UTC
2010-11-26 19:55:11.817 UTC
null
135,152
null
369,689
null
1
17
sql|sql-server|tsql|sql-server-2008|identity
38,667
<p>You can use the following to set the IDENTITY value:</p> <pre><code>DBCC CHECKIDENT (orders, RESEED, 999) </code></pre> <p>That means you'll have to run the statement based on every DELETE. That should start to highlight why this is a bad idea...</p> <p>The database doesn't care about sequential values - that's ...
4,447,563
last Button of actionsheet does not get clicked
<p>I have used an actionsheet in my project and when it appears it show all buttons but last (4th) button does not responds to my click(only it's half part responds)..</p> <p>I know the reason it is because i have used a TabBarController and the present class is inside that tabbar controller.... only that part of the ...
4,447,933
3
3
null
2010-12-15 07:14:37.573 UTC
15
2013-07-03 14:15:04.3 UTC
2011-12-02 08:20:00.093 UTC
null
537,712
null
426,006
null
1
24
iphone|user-interface|uitabbarcontroller|uiactionsheet
6,874
<p>i suggest using this:</p> <pre><code>[actionSheet showInView:[UIApplication sharedApplication].keyWindow]; </code></pre> <p>I had the same problem that you have and using this method to show it worked for me. The TabBar wants to stay key Window what makes your bottom button appear above, but is actually under the ta...
4,310,326
Convert date-time string to class Date
<p>I have a data frame with a character column of date-times.</p> <p>When I use <code>as.Date</code>, most of my strings are parsed correctly, except for a few instances. The example below will hopefully show you what is going on.</p> <pre><code># my attempt to parse the string to Date -- uses the stringr package prod...
4,310,474
4
1
null
2010-11-30 03:40:28.417 UTC
15
2022-02-04 18:09:21.5 UTC
2021-09-26 14:06:33.31 UTC
null
1,851,712
null
155,406
null
1
49
r|date|lubridate|as.date|r-faq
283,290
<p>You may be overcomplicating things, is there any reason you need the stringr package? You can use <code>as.Date</code> and its <code>format</code> argument to specify the <em>input</em> format of your string.</p> <pre><code> df &lt;- data.frame(Date = c(&quot;10/9/2009 0:00:00&quot;, &quot;10/15/2009 0:00:00&quot;))...
4,765,084
Convert a list of objects to an array of one of the object's properties
<p>Say I have the following class:</p> <pre><code>public class ConfigItemType { public string Name { get; set; } public double SomeOtherThing { get; set; } } </code></pre> <p>and then I make a list of the following classes (<code>List&lt;ConfigItemType&gt; MyList</code>)</p> <p>Now I have a method with the f...
4,765,090
4
0
null
2011-01-21 23:53:47.863 UTC
22
2015-07-24 06:19:38.257 UTC
null
null
null
null
16,241
null
1
151
c#|linq
145,253
<p>You are looking for</p> <pre><code>MyList.Select(x=&gt;x.Name).ToArray(); </code></pre> <p>Since <code>Select</code> is an Extension method make sure to add that namespace by adding a </p> <p><code>using System.Linq</code> </p> <p>to your file - then it will show up with Intellisense.</p>
4,841,340
What is the use of ByteBuffer in Java?
<p>What are example applications for a <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html" rel="noreferrer"><code>ByteBuffer</code></a> in Java? Please list any example scenarios where this is used.</p>
4,841,352
5
3
null
2011-01-30 05:26:41.907 UTC
58
2021-08-18 15:38:49.937 UTC
2021-08-18 15:38:49.937 UTC
null
2,039,546
null
568,201
null
1
217
java|buffer|bytebuffer
248,336
<p><a href="http://mindprod.com/jgloss/bytebuffer.html" rel="noreferrer">This</a> is a good description of its uses and shortcomings. You essentially use it whenever you need to do fast low-level I/O. If you were going to implement a TCP/IP protocol or if you were writing a database (DBMS) this class would come in hand...
4,645,456
Get table names from a database
<p>I've searched through a bunch of websites and I have not come across any code or tutorial which has gone through the specifics of obtaining the table names from a single database.</p> <p>Assuming I have 4 databases and I want the names of all the tables within the database called <code>mp21</code>, what query can I...
4,645,480
7
2
null
2011-01-10 09:50:40.12 UTC
2
2017-06-19 09:15:13.207 UTC
2013-05-13 12:51:47.567 UTC
null
1,563,422
null
559,042
null
1
14
mysql|sql
53,399
<pre><code>SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' </code></pre>
4,286,466
Use a normal link to submit a form
<p>I want to submit a form. But I am not going the basic way of using a input button with submit type but a <strong>a</strong> link. </p> <p>The image below shows why. I am using image links to save/submit the form. Because I have standart css markup for image links I don't want to use input submit buttons.</p> <p>I ...
4,286,493
7
3
null
2010-11-26 15:20:11.697 UTC
22
2021-04-18 01:26:57.803 UTC
null
null
null
null
401,025
null
1
145
html|css|forms|hyperlink|submit
325,002
<p>Two ways. Either create a button and style it so it looks like a link with css, or create a link and use <code>onclick="this.closest('form').submit();return false;"</code>.</p>
4,048,688
how can I convert day of year to date in javascript?
<p>I want to take a day of the year and convert to an actual date using the Date object. Example: day 257 of 1929, how can I go about doing this?</p>
4,049,020
9
0
null
2010-10-29 03:06:19.793 UTC
6
2020-10-19 07:05:22.96 UTC
2017-11-28 09:50:59.957 UTC
null
344,372
null
344,372
null
1
29
javascript|date
27,136
<blockquote> <p>"I want to take a day of the year and convert to an actual date using the Date object."</p> </blockquote> <p>After re-reading your question, it sounds like you have a year number, and an arbitrary day number (e.g. a number within <code>0..365</code> (or 366 for a leap year)), and you want to get a da...
4,517,067
Remove a string from the beginning of a string
<p>I have a string that looks like this:</p> <pre><code>$str = "bla_string_bla_bla_bla"; </code></pre> <p>How can I remove the first <code>bla_</code>; but only if it's found at the beginning of the string?</p> <p>With <code>str_replace()</code>, it removes <em>all</em> <code>bla_</code>'s.</p>
4,517,270
9
1
null
2010-12-23 08:40:40.3 UTC
22
2022-07-20 12:00:35.953 UTC
2013-06-21 03:27:32.833 UTC
null
1,563,422
null
376,947
null
1
176
php|string
167,672
<p>Plain form, without regex:</p> <pre><code>$prefix = 'bla_'; $str = 'bla_string_bla_bla_bla'; if (substr($str, 0, strlen($prefix)) == $prefix) { $str = substr($str, strlen($prefix)); } </code></pre> <p>Takes: <strong>0.0369 ms</strong> (0.000,036,954 seconds)</p> <p>And with:</p> <pre><code>$prefix = 'bla_'...
4,129,666
How to convert hex to rgb using Java?
<p>How can I convert hex color to RGB code in Java? Mostly in Google, samples are on how to convert from RGB to hex.</p>
4,129,692
21
2
null
2010-11-09 01:20:38.043 UTC
20
2022-08-23 17:21:57.843 UTC
2014-01-15 08:32:23.117 UTC
null
617,450
null
236,501
null
1
116
java|colors
173,433
<p>I guess this should do it:</p> <pre><code>/** * * @param colorStr e.g. "#FFFFFF" * @return */ public static Color hex2Rgb(String colorStr) { return new Color( Integer.valueOf( colorStr.substring( 1, 3 ), 16 ), Integer.valueOf( colorStr.substring( 3, 5 ), 16 ), Integer.v...
14,784,048
create a formula in a data.table environment in R
<p>I would like to run a regression within a <code>data.table</code>. The <code>formula</code> needs to be constructed dynamically. I have tried the following method:</p> <pre><code>x = data.table(a=1:20, b=20:1, id=1:5) &gt; x[,as.list(coef(lm(as.formula("a ~ b")))),by=id] Error in eval(expr, envir, enclos) : ob...
14,784,583
1
2
null
2013-02-09 01:39:49.17 UTC
9
2013-02-09 03:19:01.09 UTC
2013-02-09 01:59:43.997 UTC
null
714,319
null
714,319
null
1
19
r|environment|data.table
2,146
<p><code>lm</code> can accept a character string as the formula so combine that with <code>.SD</code> like this:</p> <pre><code>&gt; x[, as.list(coef(lm("a ~ b", .SD))), by = id] id (Intercept) b 1: 1 21 -1 2: 2 21 -1 3: 3 21 -1 4: 4 21 -1 5: 5 21 -1 </code></pre>
14,483,963
Rails 4.0 Strong Parameters nested attributes with a key that points to a hash
<p>I was playing around with Rails 4.x beta and trying to get nested attributes working with carrierwave. Not sure if what I'm doing is the right direction. After searching around, and then eventually looking at the rails source and strong parameters I found the below notes. </p> <blockquote> <pre><code># Note that ...
14,486,812
6
0
null
2013-01-23 16:04:58.48 UTC
17
2017-11-02 14:03:23.903 UTC
2013-01-23 16:40:03.13 UTC
null
1,591
null
418,781
null
1
35
ruby-on-rails|ruby|ruby-on-rails-4|strong-parameters
43,773
<p>My other answer was mostly wrong - new answer. </p> <p>in your params hash, :filename is not associated with another hash, it is associated with an ActiveDispatch::Http::UploadedFile object. Your last code line:</p> <pre><code>def screenshot_params params.require(:screenshot).permit(:title, assets_attributes: :f...
14,814,714
Update TextView Every Second
<p>I've looked around and nothing seems to be working from what I've tried so far...</p> <pre><code> @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.deskclock); TextView tvTime = (TextView) findViewById(R.id.tvTime); TextVie...
14,814,842
11
1
null
2013-02-11 15:00:45.97 UTC
21
2022-02-01 12:35:13.82 UTC
2016-12-06 06:56:42.883 UTC
null
3,678,528
null
1,888,770
null
1
52
android|date|time|textview|clock
114,284
<p>Add following code in your onCreate() method:</p> <pre><code>Thread thread = new Thread() { @Override public void run() { try { while (!thread.isInterrupted()) { Thread.sleep(1000); runOnUiThread(new Runnable() { @Override public void run() { // update ...
14,787,776
How to pull after a forced git push?
<p>Suppose I pull changes from a git repo. Then the author of the repo force pushes to the central repo. Now I can't pull since the history is rewritten.</p> <p>How can I pull the new commits (and abandon the old ones), assuming that the author force-pushed the correct version?</p> <p>I know this is bad git workflow,...
14,787,801
4
1
null
2013-02-09 11:46:47.247 UTC
19
2021-01-23 18:20:17.03 UTC
null
null
null
null
1,922,239
null
1
65
git
28,441
<h2>Throwing away your local changes</h2> <p>If you want to discard your work, <code>fetch</code> and <code>reset</code>. For example, if you have a remote named <code>origin</code> and a branch named <code>master</code>:</p> <pre><code>$ git fetch origin $ git reset --hard origin/master # Destroys your work </code>...
2,366,097
What does putting an exclamation point (!) in front of an object reference variable do?
<p>What does putting an exclamation point (<code>!</code>) in front of an object reference variable do in Visual Basic 6.0?</p> <p>For example, I see the following in code:</p> <pre><code> !RelativePath.Value = mstrRelativePath </code></pre> <p>What does the <code>!</code> mean?</p>
2,366,226
2
3
null
2010-03-02 19:33:29.26 UTC
4
2018-07-25 15:52:37.63 UTC
2012-05-03 13:51:07.467 UTC
null
588,306
null
166,258
null
1
29
vb6
17,394
<p>It is almost certainly a statement inside a With block:</p> <pre><code> With blah !RelativePath.Value = mstrRelativePath End With </code></pre> <p>which is syntax sugar for</p> <pre><code> blah("RelativePath").Value = mstrRelativePath </code></pre> <p>which is syntax sugar for</p> <pre><code> blah.Def...
2,947,440
Foreign Keys vs Joins
<p>Is it better to use foreign keys in tables or can the same results be achieved with joins?</p>
2,947,450
2
5
null
2010-06-01 05:24:09.15 UTC
13
2015-09-16 10:43:52.17 UTC
2010-06-01 09:15:49.04 UTC
null
222,908
null
340,183
null
1
38
sql
28,518
<p><a href="http://en.wikipedia.org/wiki/Foreign_key" rel="noreferrer">Foreign keys</a> are just constraints to enforce <a href="http://en.wikipedia.org/wiki/Referential_integrity" rel="noreferrer">referential integrity</a>. You will still need to use <a href="http://en.wikipedia.org/wiki/Sql_join" rel="noreferrer">JOI...
2,924,160
Is it valid to have more than one question mark in a URL?
<p>I came across the following URL today:</p> <pre><code>http://www.sfgate.com/cgi-bin/blogs/inmarin/detail??blogid=122&amp;entry_id=64497 </code></pre> <p>Notice the doubled question mark at the beginning of the query string:</p> <pre><code>??blogid=122&amp;entry_id=64497 </code></pre> <p>My browser didn't seem to...
2,924,187
2
1
null
2010-05-27 19:19:15.183 UTC
14
2018-06-15 10:33:04.2 UTC
2010-05-27 19:28:44.67 UTC
null
126,562
null
167,911
null
1
109
url|parsing|query-parameters
62,167
<p>Yes, it is valid. Only the <em>first</em> <code>?</code> in a URL has significance, any after it are treated as literal question marks:</p> <blockquote> <p>The query component is indicated by the first question mark (&quot;?&quot;) character and terminated by a number sign (&quot;#&quot;) character or by the end of ...
35,136,098
Have sass-lint ignore a certain line?
<p>I'm using <em>sass</em>-lint with Gulp. How can I disable warnings for a particular style in my sass from the lint console output? </p> <p>I've found a similar question but I'm using <strong>sass</strong>-lint, not <strong>scss</strong>-lint: <a href="https://stackoverflow.com/questions/32833542/having-scss-lint-i...
35,142,043
4
0
null
2016-02-01 17:00:37.447 UTC
7
2021-03-24 16:41:09.96 UTC
2021-03-24 16:41:09.96 UTC
null
3,448,527
null
467,875
null
1
53
sass|gulp|gulp-sass
39,093
<h2>Disabling through comments</h2> <p><strong>Update per December 2016</strong> according to <a href="https://github.com/sasstools/sass-lint#disabling-linters-via-source">the docs</a> this will now be possible using this syntax:</p> <blockquote> <p><strong>Disable more than 1 rule for entire file</strong></p> <pr...
40,336,155
Binding: Appending to href
<p>In my Angular 2 test app, I am trying to append an <code>id</code> the following as part of my HTML template:</p> <pre><code>&lt;a href="https://www.domainname.com/?q="+{{text.id}}&gt;URL&lt;/a&gt; </code></pre> <p>Not this fails with an error:</p> <blockquote> <p>(Error: Failed to execute 'setAttribute' on 'El...
40,336,283
4
0
null
2016-10-31 03:23:03.86 UTC
2
2022-06-01 18:32:32.03 UTC
2019-10-01 19:57:23.533 UTC
null
3,345,644
null
998,415
null
1
31
angular|angular2-template
80,227
<p>Use either:</p> <pre class="lang-html prettyprint-override"><code>&lt;a href="https://www.domainname.com/?q={{text.id}}"&gt;URL&lt;/a&gt; </code></pre> <p>or (from the <a href="https://angular.io/guide/ajs-quick-reference#bind-to-the-href-property" rel="noreferrer">official docs</a>):</p> <pre class="lang-html pr...
2,656,740
Create a class with array of objects
<p>Code below defines a ChargeCustomer class that contains an array of type "customers". I want to be able to create an object with either 1 "customer" or 2 "customers" based on the constructor parameters. Is this the right way to do so in C#:</p> <pre><code>public class ChargeCustomer { private Customer[] custom...
2,656,777
1
2
null
2010-04-17 00:26:22.61 UTC
1
2010-04-17 00:41:39.94 UTC
2010-04-17 00:41:39.94 UTC
null
121,606
null
121,606
null
1
6
c#
104,624
<p><em>Note: This assumes that <code>DropBox</code> was a mis-paste in the original question.</em></p> <p>You can move things around and have 1 constructor using <a href="http://msdn.microsoft.com/en-us/library/w5zay9db.aspx" rel="noreferrer"><code>params</code></a> for any number of names, like this:</p> <pre><code>...
33,925,430
Shiny: plot results in popup window
<p>I am trying to build a web app with shiny and I would like to display the resulting plot of a R function in a popup window rather than in mainPanel. For instance, for the below example (from <a href="http://shiny.rstudio.com/articles/action-buttons.html" rel="noreferrer">http://shiny.rstudio.com/articles/action-but...
33,933,549
3
0
null
2015-11-25 20:02:13.01 UTC
9
2020-11-11 15:26:26.377 UTC
null
null
null
null
5,107,540
null
1
12
r|shiny
16,730
<p>Look into <code>shinyBS</code> package which offers <code>modal</code> popups. Example below shows the plot upon button click. </p> <p><strong>EDIT - Added a download button to the Modal</strong></p> <pre><code>rm(list = ls()) library(shiny) library(shinyBS) shinyApp( ui = fluidPage( sidebarLayout( ...
27,612,765
Nested routes in react-router
<p>I'm setting up some nested routes within React-Router (v0.11.6 is what I'm working against) but whenever I try and access one of the nested routes it triggers the parent route.</p> <p>My routes look like this:</p> <pre><code>&lt;Route handler={App}&gt; &lt;Route name="home" path="/" handler={availableRoutes.Sp...
27,670,456
3
0
null
2014-12-23 01:05:41.81 UTC
8
2015-10-21 04:18:18.087 UTC
2015-01-20 16:16:55.603 UTC
null
1,090,839
null
11,388
null
1
29
reactjs|react-router
27,157
<p>The configuration isn't about the routing (despite the name) but more about the layouts driven by paths.</p> <p>So, with this configuration:</p> <pre><code>&lt;Route name="dashboard" handler={availableRoutes.Dashboard}&gt; &lt;Route name="dashboard-child" handler={availableRoutes.DashboardChild} /&gt; &lt;/Route...
27,563,402
Work with JSON schema in CouchDB
<p>I would ask about good practicies about JSON schematics in CouchDB. I use pure CouchDB 1.6.1 at this moment. I handle it without any couchapp framework ( I know this is usefull, but I am concerned about it will be functional in future ).</p> <ul> <li><p>Where put schema in CouchDB ? As regular document? Design docu...
27,605,330
3
0
null
2014-12-19 09:50:29.153 UTC
10
2016-09-07 16:27:48.227 UTC
null
null
null
null
4,252,043
null
1
6
javascript|json|couchdb|schema
4,672
<p>You ask the same question I had for years while exploring the potential advantages of CouchDB in Forms-over-Data use-cases.</p> <p>Initially my hope was to find an approach that enables data validation based on the same JSON schema definition and validation code - server- and client-side. It has turned out that it ...
29,117,882
Debugging JavaScript in Chromium Embedded Framework
<p>I have a WPF application which uses CEF to display web content. My question is, is there a way to debug the Javascript/Web parts inside a WPF application?</p>
35,560,835
6
0
null
2015-03-18 09:08:49.62 UTC
8
2022-04-13 07:51:35.147 UTC
2015-03-18 13:10:28.48 UTC
null
3,737,039
null
3,737,039
null
1
29
wpf|debugging|chromium-embedded
37,203
<p>You may also use <code>ShowDevTools()</code> extension method (<a href="https://github.com/cefsharp/CefSharp/blob/28f43261b6616d4fe6b8b2d19b76454ba293d9b4/CefSharp/WebBrowserExtensions.cs#L668" rel="noreferrer">source</a>)</p> <pre><code>ChromiumWebBrowser browser = new ChromiumWebBrowser(); browser.ShowDevTools();...
31,977,563
How do you convert a datetime/timestamp from one timezone to another timezone?
<p>Specifically, given the timezone of my server (system time perspective) and a timezone input, how do I calculate the system time as if it were in that new timezone (regardless of daylight savings, etc)?</p> <pre><code>import datetime current_time = datetime.datetime.now() #system time server_timezone = "US/Eastern...
31,977,588
3
0
null
2015-08-13 00:23:22.163 UTC
13
2022-04-04 22:34:23.743 UTC
2022-04-04 22:34:23.743 UTC
null
3,001,761
null
2,812,260
null
1
52
python|datetime|timezone|pytz|timedelta
76,817
<p>If you know your origin timezone and the new timezone that you want to convert it to, it turns out to be very straightforward:</p> <ol> <li><p>Make two <code>pytz.timezone</code> objects, one for the current timezone and one for the new timezone e.g. <code>pytz.timezone(&quot;US/Pacific&quot;)</code>. You can find a...
28,102,173
Redis, how does SCAN cursor "state management" work?
<p>Redis has a SCAN command that may be used to iterate keys matching a pattern etc.</p> <p><a href="http://redis.io/commands/scan" rel="noreferrer">Redis SCAN doc</a></p> <p>You start by giving a cursor value of 0; each call returns a new cursor value which you pass into the next SCAN call. A value of 0 indicates i...
28,104,028
1
0
null
2015-01-23 02:38:12.63 UTC
8
2015-01-23 06:13:11.533 UTC
null
null
null
null
222,593
null
1
15
redis
7,511
<p>You may find answer in redis <a href="https://github.com/antirez/redis/blob/unstable/src/dict.c" rel="noreferrer">dict.c</a> source file. Then I will quote part of it.</p> <p>Iterating works the following way:</p> <ol> <li>Initially you call the function using a cursor (v) value of 0. 2)</li> <li>The function perfor...
27,148,273
What is the logic of binding buffers in webgl?
<p>I sometimes find myself struggling between declaring the buffers (with createBuffer/bindBuffer/bufferdata) in different order and rebinding them in other parts of the code, usually in the draw loop.</p> <p>If I don't rebind the vertex buffer before drawing arrays, the console complains about an attempt to access ou...
27,164,577
1
0
null
2014-11-26 11:42:12.207 UTC
13
2022-04-17 01:55:51.917 UTC
null
null
null
user2618518
null
null
1
13
javascript|webgl
8,290
<p>I don't know if this will help. As some people have said, GL/WebGL has a bunch of internal <strong>state</strong>. All the functions you call set up the state. When it's all setup you call <code>drawArrays</code> or <code>drawElements</code> and all of that state is used to draw things</p> <p>This has been explained...
40,378,320
How to include Roboto font in webpack build for Material UI?
<p>For a <em>progressive</em> web app based on <a href="http://www.material-ui.com/" rel="noreferrer">Material UI</a> (React) and built with <strong>Webpack</strong>, how do I properly include Roboto font(s) so that the app does not depend on Google servers and fonts also work <em>offline</em> ?</p> <ul> <li><p>The <a...
41,255,971
6
1
null
2016-11-02 11:01:46.16 UTC
24
2021-10-26 15:50:37.583 UTC
null
null
null
null
688,869
null
1
68
webpack|webfonts|material-ui|roboto
66,440
<p>This is how my team went about including the Roboto fonts in our Webpack project:</p> <h1>Download the Roboto fonts and make a CSS file in a font-specific folder</h1> <ul> <li>Create a folder (<code>/fonts</code>).</li> <li>Download all of the Roboto fonts from <a href="https://www.fontsquirrel.com/fonts/roboto" rel...
2,536,551
Rhino Mocks - Difference between GenerateStub<T> & GenerateMock<T>
<p>Can any of the Rhino experts explain me by giving a suitable example of the difference between the above methods on the <code>MockRepository</code> class (Rhino Mocks framework).</p> <p>Where should one use Stub over Mock method or otherwise?</p>
2,536,570
1
0
null
2010-03-29 08:18:16.087 UTC
13
2012-05-09 09:16:59.11 UTC
2012-05-09 09:16:59.11 UTC
null
97,614
null
31,750
null
1
36
unit-testing|rhino-mocks
15,266
<p>you should use a mock when you are going to verify that something happened on the object, like a method was called. You should use a stub when you just want the object to be involved in the test to return a value but it is not the thing you are testing. A stub which does not have a expectation fulfilled can never ...
10,724,420
Automatically Update Data in Other Excel Sheets of a Workbook
<p>I have VBA code that takes my data on the "master" worksheet and puts it in the other sheets in a workbook. The problem I am having is that the new data doesn't update automatically. I would like to develop code that will automatically update my worksheets. This is the code that I have now. </p> <pre><code>Sub test...
10,724,763
2
0
null
2012-05-23 16:48:34.283 UTC
2
2013-10-23 23:28:53.71 UTC
2018-07-09 19:34:03.733 UTC
null
-1
null
1,413,170
null
1
0
excel|vba
40,579
<p>Use the <code>worksheet_change</code> event in your "master" spreadsheet. When data is updated in the "master" sheet, it will raise the <code>worksheet_change</code> event and you can call your code to update the other sheets.</p> <p>You can find detailed instructions on how to use it here: <a href="http://www.ozgr...
37,347,415
Laravel: Access Model instance in Form Request when using Route/Model binding
<p>I have some route/model binding set up in my project for one of my models, and that works just fine. I'm able to use my binding in my route path and accept an instance of my model as a parameter to the relevant method in my controller.</p> <p>Now I'm trying to do some work with this model, so I have created a metho...
37,347,678
1
0
null
2016-05-20 12:58:59.043 UTC
3
2018-03-09 12:26:00.247 UTC
null
null
null
null
2,244,675
null
1
44
php|laravel|laravel-5
21,332
<p>You can simply access it using the binding key, so for example if you bind <code>Brand</code> model: <code>$router-&gt;model('brand', '\App\Brand')</code> you can get instance of your model with <code>$this-&gt;brand</code>. Here is validation rules example:</p> <pre><code>'slug' =&gt; 'required|unique:brand,slug,'...
6,228,960
How to set the "Content-Type ... charset" in the request header using a HTML link
<p>I have a simple HTML-page with a UTF-8 encoded link.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;a charset='UTF-8' href='http://server/search?q=%C3%BC'&gt;search for &quot;ü&quot;&l...
6,229,984
1
3
null
2011-06-03 15:13:52.723 UTC
1
2021-08-15 11:41:13.4 UTC
2021-08-15 11:36:21.963 UTC
null
63,550
null
701,753
null
1
22
html|character-encoding|special-characters|urlencode
132,470
<p>This is not possible from HTML on.</p> <p>The closest what you can get is the <code>accept-charset</code> attribute of the <code>&lt;form&gt;</code>. Only Internet Explorer adheres that, but even then it is doing it wrong (e.g., CP-1252 is <em>actually</em> been used when it says that it has sent ISO-8859-1). Other ...
24,658,007
How can I confirm what version of Jasmine I'm using?
<p>If I recall there is a command in Jasmine that will log the exact version of Jasmine I'm running to the console, but I can't remember what it is. I am positive I have seen this before somewhere, and now that I actually need it I can't find it anywhere. Does anyone know what it is?</p> <hr> <p>Edit: The posted solu...
24,919,927
5
0
null
2014-07-09 15:38:28.303 UTC
4
2018-09-04 05:08:35.653 UTC
2014-07-09 15:57:59.43 UTC
null
3,392,912
null
3,392,912
null
1
45
unit-testing|version|jasmine|phantomjs|versioning
27,407
<p>To simply log the version number try: </p> <pre><code> if (jasmine.version) { //the case for version 2.0.0 console.log('jasmine-version:' + jasmine.version); } else { //the case for version 1.3 console.log('jasmine-version:' + jasmine.getEnv().versionString()); } </code></pre> <p>I us...
27,382,481
Why does Visual Studio tell me that the AddJsonFile() method is not defined?
<p>I'm developing an ASP.NET 5 WebAPI project using VS Ultimate 2015 Preview. I'm trying to configure the app in this way (line numbers are just guides):</p> <pre><code>1 using Microsoft.Framework.ConfigurationModel; 2 3 public IConfiguration Configuration { get; private set; } 4 5 public Startup() 6 { 7 Configur...
27,382,878
4
0
null
2014-12-09 15:20:09.36 UTC
9
2020-06-02 11:45:05.897 UTC
2019-06-20 19:13:36.23 UTC
null
2,574,407
null
3,802,403
null
1
104
c#|configuration|configuration-files|asp.net-core|config.json
78,544
<p>You need to include the <a href="https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json/" rel="noreferrer"><code>Microsoft.Extensions.Configuration.Json</code></a> NuGet package if you want to call the <code>.AddJsonFile()</code> method.</p> <p>See: <a href="https://github.com/aspnet/Configuration/t...
38,879,529
How to route to a Module as a child of a Module - Angular 2 RC 5
<p>I am in the process upgrading an application I'm working on to the latest Angular 2 release candidate. As part of this work I am attempting to use the NgModule spec and migrating all of the parts of my application to modules. For the most part, this has gone very well with the exception of an issue with routing.</p>...
38,952,908
7
3
null
2016-08-10 17:03:30.537 UTC
33
2017-09-21 08:57:41.81 UTC
2017-09-21 08:57:41.81 UTC
null
8,371,289
null
6,520,765
null
1
70
angular|angular2-routing|angular2-modules|angular2-router3
83,654
<p>Okay, after fiddling around with this for the better part of the weekend I got it running on my end. What worked for me in the end was to do the following:</p> <ul> <li>Export all <code>Routes</code> for every module you want to route. Do not import any of the <code>RouterModule.forChild()</code> in the child modul...
22,885,775
What is the difference between Lock and RLock
<p>From the <a href="https://docs.python.org/2/library/threading.html" rel="noreferrer">docs</a>:</p> <blockquote> <p>threading.RLock() -- A factory function that returns a new reentrant lock object. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the ...
22,885,810
3
0
null
2014-04-05 19:34:28.4 UTC
31
2020-08-06 04:09:36.61 UTC
2018-04-01 22:20:19.253 UTC
null
1,709,587
null
2,495,795
null
1
101
python|multithreading|locking|reentrancy
46,460
<p>The main difference is that a <code>Lock</code> can only be acquired once. It cannot be acquired again, until it is released. (After it's been released, it can be re-acaquired by any thread).</p> <p>An <code>RLock</code> on the other hand, can be acquired multiple times, by the same thread. It needs to be released...
3,019,369
Rails message: ActionView::MissingTemplate
<p>I am getting an error that I cannot figure out:</p> <pre><code>ActionView::MissingTemplate (Missing template cluster/delete_stuff.erb in view path app/views) &lt;...snip trace...&gt; Rendering rescues/layout (internal_server_error) </code></pre> <p>I am "enhancing" others code and am following the convention they ...
3,025,120
3
0
null
2010-06-10 23:57:33.88 UTC
2
2021-07-09 11:14:24.203 UTC
null
null
null
null
207,605
null
1
19
ruby-on-rails
53,658
<p>Turns out that I did not have a </p> <p><code>render :something</code> </p> <p>in my controller method, so I guess Rails figured that there must be a "delete_stuff.erb" somewhere to know what to do. Added a render and the error message goes away.</p>
2,999,528
Is there a 100% Java alternative to ImageIO for reading JPEG files?
<p>We are using Java2D to resize photos uploaded to our website, but we run into an issue (a seemingly old one, cf.: <a href="http://forums.sun.com/thread.jspa?threadID=5425569" rel="noreferrer">http://forums.sun.com/thread.jspa?threadID=5425569</a>) - a few particular JPEGs raise a <code>CMMException</code> when we tr...
3,002,383
3
3
null
2010-06-08 17:02:12.813 UTC
12
2019-12-01 07:34:08.573 UTC
null
null
null
null
64,635
null
1
20
java|jpeg|java-2d|javax.imageio|resize-image
19,558
<p>One possibly useful library for you could be the Java Advanced Imaging Library (<a href="https://www.oracle.com/technetwork/java/iio-141084.html" rel="nofollow noreferrer">JAI</a>)</p> <p>Using this library can be quite a bit more complicated than using ImageIO but in a quick test I just ran, it did open and displa...
2,444,899
insert or update on table violates foreign key constraint
<p>I have two tables: <strong>entitytype</strong> and <strong>project</strong>. Here are the create table statements:</p> <pre><code>Create table project ( pname varchar(20) not null, primary key(pname) ); create table entitytype( entityname varchar(20) not null, toppos char(100), leftpos char(100), pname varch...
2,444,913
3
0
null
2010-03-15 03:19:42.737 UTC
6
2022-01-07 04:25:38.853 UTC
2011-09-09 01:38:27.227 UTC
null
71,421
null
166,731
null
1
25
sql|database|postgresql
109,656
<p>The error message means you are attempting to add an entityType that does not have a corresponding Project entry. (I don't know your domain or what you are trying to achieve, but that schema design looks wrong to me...)</p>
2,671,503
How to stop debugging (or detach process) without stopping the process?
<p>I often use VS 2008 to debug a .NET C# component of an application. Sometimes, I want to quit debugging and continue running the application. Stop Debugging kills the process I was debugging. </p> <p>How can I achieve my aim? </p> <p>This is not a web app, it's a local process that runs managed and unmanaged co...
7,563,072
3
3
null
2010-04-19 23:07:00.917 UTC
7
2015-11-27 23:09:12.473 UTC
2015-11-27 23:09:12.473 UTC
null
294,313
null
107,800
null
1
51
visual-studio|visual-studio-2008|debugging
30,296
<p>You cannot detach a debugger from a process if you are debugging in mixed mode.</p> <p>Make sure you are debugging either in managed or native mode while attaching to the process: either make sure "Enable native code debugging" or "Native Code" is unchecked in your project options, or start the program without debu...
2,541,401
Pairwise crossproduct in Python
<p>How can I get the list of cross product <em>pairs</em> from a list of arbitrarily long lists in Python?</p> <h2>Example</h2> <pre><code>a = [1, 2, 3] b = [4, 5, 6] </code></pre> <p><code>crossproduct(a,b)</code> should yield <code>[[1, 4], [1, 5], [1, 6], ...]</code>.</p>
2,541,412
3
2
null
2010-03-29 21:27:38.737 UTC
23
2017-02-19 11:26:38.647 UTC
2015-11-28 19:41:54.17 UTC
null
562,769
user248237
null
null
1
135
python|list
99,375
<p>You're looking for <a href="http://docs.python.org/library/itertools.html#itertools.product" rel="noreferrer">itertools.product</a> if you're on (at least) Python 2.6.</p> <pre><code>&gt;&gt;&gt; import itertools &gt;&gt;&gt; a=[1,2,3] &gt;&gt;&gt; b=[4,5,6] &gt;&gt;&gt; itertools.product(a,b) &lt;itertools.product...
2,362,982
jQuery dynamically create table/tr/td or etc and append attributes
<p>In an example I am having this structure (small example):</p> <pre><code>&lt;table id=example&gt; &lt;tr class="blah test example"&gt;&lt;td&gt;Test1&lt;/td&gt;&lt;td&gt;&lt;a href="url"&gt;LINK&lt;/a&gt;Test11&lt;/td&gt;&lt;/tr&gt; &lt;tr class="blah test example"&gt;&lt;td&gt;Test2&lt;/td&gt;&lt;td&gt;&lt;a href=...
2,363,030
5
0
null
2010-03-02 12:18:13.133 UTC
4
2017-05-23 16:17:52.64 UTC
2017-05-23 16:17:52.64 UTC
null
4,370,109
null
147,953
null
1
9
javascript|jquery|html-table|refactoring
54,401
<p>Can you make a "template" out of your string? If yes, then store it in a "constant" variable (e.g. defined in global scope), containing placeholders for actual variables, like <code>{0}</code>, <code>{1}</code> etc, as you would use it in C#'s <code>string.format()</code> method.</p> <p>So, you would have code like...
46,421,279
Delete downloads older than 30 days?
<p>I am trying to create a task in automator that moves files in ~/Downloads to the trash if they are older than 30 days.</p> <p>I want this to run every day.</p> <p>It's not working though, Finder just hangs and stops responding and I have to Force Quit it from activity monitor.</p> <pre><code>on run {input, parame...
46,428,161
2
0
null
2017-09-26 08:21:10.79 UTC
9
2018-04-21 16:44:50.527 UTC
null
null
null
null
3,310,334
null
1
11
macos|automation|applescript|automator
5,574
<p>I'd take a different approach and use a set of <em>actions</em> available in <strong>Automator</strong> without the use of <strong>AppleScript</strong>.</p> <p>The following <em>workflow</em> will accomplish that you're looking to do.</p> <p>In <strong>Automator</strong>, create a new <strong>Workflow</strong> add...
36,342,899
asyncio.ensure_future vs. BaseEventLoop.create_task vs. simple coroutine?
<p>I've seen several basic Python 3.5 tutorials on asyncio doing the same operation in various flavours. In this code:</p> <pre><code>import asyncio async def doit(i): print("Start %d" % i) await asyncio.sleep(3) print("End %d" % i) return i if __name__ == '__main__': loop = asyncio.get_event_l...
36,415,477
4
0
null
2016-03-31 20:15:20.243 UTC
64
2019-01-02 05:59:45.83 UTC
null
null
null
null
2,660,810
null
1
128
python|python-3.x|python-3.5|coroutine|python-asyncio
87,029
<h2>Actual info:</h2> <p>Starting from Python 3.7 <code>asyncio.create_task(coro)</code> high-level function <a href="https://docs.python.org/3/library/asyncio-task.html#creating-tasks" rel="noreferrer">was added</a> for this purpose. </p> <p>You should use it instead other ways of creating tasks from coroutimes. How...
37,460,600
Is there a way to disconnect USB device from ADB?
<p>I have a lot of scripts that use ADB to debug Android applications via Wi-Fi with emulators. The problem appears when I charge my Android phone via USB from my computer: ADB sees it and sends commands to my phone instead of emulator. <strong>Is there a way to disconnect ADB from phone that charges via USB?</strong> ...
37,460,788
5
0
null
2016-05-26 12:15:59.413 UTC
9
2021-03-16 13:45:49.83 UTC
null
null
null
null
1,089,715
null
1
23
android|adb
71,578
<p>USB connection for internal storage and adb connection for debugging are two separate things.</p> <p>To disable adb - you can use <code>adb disconnect</code> or simply turn off <code>usb debugging</code> under <code>developer options</code>.</p> <p>For disconnecting usb connection for internal storage certain ROMS...
2,410,937
delaying actions between keypress in jQuery
<p>How can I delay actions between keypress in jQuery. For example;</p> <p>I have something like this</p> <pre><code> if($(this).val().length &gt; 1){ $.post("stuff.php", {nStr: "" + $(this).val() + ""}, function(data){ if(data.length &gt; 0) { $('#suggestions').show(); $('#autoSuggestionsList').ht...
2,410,966
5
1
null
2010-03-09 17:08:08.67 UTC
12
2016-03-14 16:35:06.547 UTC
null
null
null
null
256,895
null
1
31
jquery|ajax|delay
24,144
<p>You can use jQuery's data abilities to do this, something like this:</p> <pre><code>$('#mySearch').keyup(function() { clearTimeout($.data(this, 'timer')); var wait = setTimeout(search, 500); $(this).data('timer', wait); }); function search() { $.post("stuff.php", {nStr: "" + $('#mySearch').val() + ""}, fun...
2,767,352
C# convert bit to boolean
<p>I have a Microsoft SQL Server database that contains a data field of <code>BIT</code> type.</p> <p>This field will have either <code>0</code> or <code>1</code> values to represent false and true.</p> <p>I want when I retrieve the data to convert the value I got to <code>false</code> or <code>true</code> without us...
2,767,375
5
0
null
2010-05-04 17:07:01.38 UTC
3
2020-03-19 10:56:30.06 UTC
2020-03-19 10:56:30.06 UTC
null
2,083,613
null
2,152,275
null
1
35
c#|ado.net
107,565
<p>Depending on how are you performing the SQL queries it may depend. For example if you have a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx" rel="noreferrer">data reader</a> you could directly <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatarea...
2,456,954
git encrypt/decrypt remote repository files while push/pull
<p>Is it possible to automatically encrypt files via 'git push' before transferring to a remote repository? And automatically decode them while 'git pull'.</p> <p>I.e, if I have some remote server with shared access with git repository there, and I don't want our project to be stolen without a permission... Maybe ther...
2,457,006
5
4
null
2010-03-16 18:14:39.987 UTC
21
2019-06-05 21:48:10.593 UTC
2017-07-17 05:59:06.287 UTC
null
586,229
null
225,568
null
1
44
git|encryption
21,972
<p>Yes and no.</p> <p>You could try to depend on hook but that supposes they are installed at the remote locations, and that is not always reliable.</p> <p>Another way to achieve almost the same effect would be by using a <strong><a href="https://stackoverflow.com/questions/2154948/how-can-i-track-system-specific-con...
2,691,392
Enumerable.Empty<T>() equivalent for IQueryable
<p>When a method returns <code>IEnumerable&lt;T&gt;</code> and I do not have anything to return, we can use <code>Enumerable.Empty&lt;T&gt;()</code>.</p> <p>Is there an equivalent to the above for a method returning <code>IQueryable&lt;T&gt;</code></p>
2,691,437
6
0
null
2010-04-22 13:54:26.033 UTC
7
2022-09-03 08:52:18.457 UTC
2010-05-10 21:36:55.1 UTC
null
309,358
null
309,358
null
1
138
c#|return|iqueryable
27,353
<p>Maybe: </p> <pre><code>Enumerable.Empty&lt;T&gt;().AsQueryable(); </code></pre>