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
28,504,589
Creating an NSDateFormatter in Swift?
<p>I am new to swift and am very unfamiliar with Objective-C. Could someone help me convert this to Swift? I got this code from Ray Wenderlich's best iOS practices - <a href="http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks" rel="noreferrer">http://www.raywenderlich.com/31166/25-ios-app-performance...
28,511,412
4
2
null
2015-02-13 16:49:06.117 UTC
9
2020-05-10 17:46:16.023 UTC
2017-06-20 17:32:55.097 UTC
null
74,118
null
4,162,864
null
1
24
objective-c|swift|date|nsdate|nsdateformatter
14,013
<ol> <li><p>If you're really looking for direct analog to the method in your question, you could do something like:</p> <pre><code>class MyObject { // define static variable private static let formatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "EEE MMM dd HH:m...
36,285,253
Enable CORS for Web Api 2 and OWIN token authentication
<p>I have an ASP.NET MVC 5 webproject (localhost:81) that calls functions from my WebApi 2 project (localhost:82) using Knockoutjs, to make the communication between the two projects I enable CORS. Everything works so far until I tried to implement OWIN token authentication to the WebApi.</p> <p>To use the /token endp...
36,968,863
3
9
null
2016-03-29 13:09:22.34 UTC
16
2021-02-25 20:58:26.05 UTC
2021-02-25 20:58:26.05 UTC
null
1,075,980
null
4,836,952
null
1
33
asp.net-web-api|asp.net-mvc-5|cors|asp.net-web-api2|owin
31,374
<p>I know your issue was solved inside comments, but I believe is important to understand what was causing it and how to resolve this entire class of problems.</p> <p>Looking at your code I can see you are setting the <code>Access-Control-Allow-Origin</code> header more than once for the Token endpoint:</p> <pre><cod...
36,608,780
og:image could not be downloaded because it exceeded the maximum allowed sized of 8Mb
<p>Building a website that requires sharing links with an image. Done this I don't know how often...but this time the Facebook Open Graph Debugger says:</p> <p>og:image {image url} could not be downloaded because it exceeded the maximum allowed sized of 8Mb</p> <p>But the image referenced is only 108KB? One other tim...
36,894,300
4
10
null
2016-04-13 20:18:23.373 UTC
8
2018-01-29 22:58:10.67 UTC
2016-08-06 01:32:05.143 UTC
null
212,378
null
5,036,871
null
1
49
facebook-opengraph
23,131
<p>This is a bug, and it's confirmed, after getting the warning, if you retry the debug, or click on "Scrape Again", the error message will be gone. This is an issue because if someone tries to share the post, the image will not show up since it didn't get scrapped, but subsequent shares will display the image.</p> <p...
7,055,652
Real-world example of exponential time complexity
<p>I'm looking for an intuitive, real-world example of a problem that takes (worst case) exponential time complexity to solve for a talk I am giving.</p> <p>Here are examples for other time complexities I have come up with (many of them taken from <a href="https://stackoverflow.com/questions/1592649/examples-of-algori...
7,055,684
5
3
null
2011-08-14 07:45:54.84 UTC
21
2020-06-23 18:19:57.3 UTC
2017-05-23 12:02:56.8 UTC
null
-1
null
393,304
null
1
38
complexity-theory|exponential
35,918
<ul> <li>O(10^N): trying to break a password by testing every possible combination (assuming numerical password of length N)</li> </ul> <p><strike><strong>p.s.</strong> why is your last example is of complexity O(infinity) ? it's linear search O(N) .. there are less than 7 billion people in the world.</strike></p>
7,059,780
Find the element repeated more than n/2 times
<p>There is an array (of size N) with an element repeated more than N/2 number of time and the <strong>rest of the element in the array can also be repeated</strong> but only one element is repeated more than N/2 times. Find the number.</p> <p>I could think of few approaches:</p> <ul> <li>Naive, keep the count of eac...
7,059,877
7
3
null
2011-08-14 21:16:56.903 UTC
26
2015-10-07 05:33:06.373 UTC
2011-12-15 20:57:31.477 UTC
null
501,557
null
854,075
null
1
31
arrays|algorithm
31,088
<p>There is a beautiful algorithm for solving this that works in two passes (total time O(N)) using only constant external space (O(1)). I have an implementation of this algorithm, along with comments including a correctness proof, <strong><a href="http://keithschwarz.com/interesting/code/?dir=majority-element" rel="n...
7,070,011
Writing large number of records (bulk insert) to Access in .NET/C#
<p>What is the best way to perform bulk inserts into an MS Access database from .NET? Using ADO.NET, it is taking way over an hour to write out a large dataset.</p> <p><em>Note that my original post, before I "refactored" it, had both the question and answer in the question part. I took Igor Turman's suggestion and ...
7,080,644
8
6
null
2011-08-15 19:55:31.633 UTC
27
2018-12-21 08:37:51.203 UTC
2011-08-16 15:22:21.067 UTC
null
1,955,013
null
1,955,013
null
1
55
c#|ms-access|dao|bulkinsert
54,254
<p>I found that using DAO in a specific manner is roughly 30 times faster than using ADO.NET. I am sharing the code and results in this answer. As background, in the below, the test is to write out 100 000 records of a table with 20 columns.</p> <p>A summary of the technique and times - from best to worse:</p> <ol>...
7,344,978
Verifying path equality with .Net
<p>What is the best way to compare two paths in .Net to figure out if they point to the same file or directory?</p> <ol> <li><p>How would one verify that these are the same:</p> <pre><code>c:\Some Dir\SOME FILE.XXX C:\\\SOME DIR\some file.xxx </code></pre></li> <li><p>Even better: is there a way to verify that these ...
7,345,023
9
4
null
2011-09-08 08:07:48.147 UTC
4
2021-04-09 02:05:28.21 UTC
2011-09-12 10:43:17.843 UTC
user610650
null
user610650
null
null
1
46
c#|.net|path
24,393
<pre><code>var path1 = Path.GetFullPath(@"c:\Some Dir\SOME FILE.XXX"); var path2 = Path.GetFullPath(@"C:\\\SOME DIR\subdir\..\some file.xxx"); // outputs true Console.WriteLine("{0} == {1} ? {2}", path1, path2, string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase)); </code></pre> <p>Ignoring case is only a ...
14,210,454
How to set two custom actionbar button in left and right in android?
<p>I am Using Sherlock library and i also implement with myself. My problem is that i added two items in menu, now i want 1 item in left of actionbar and second in right of actionbar. How to to it?</p>
14,211,619
2
2
null
2013-01-08 07:51:41.36 UTC
10
2018-05-28 21:04:02.343 UTC
null
null
null
null
1,531,657
null
1
15
android
35,357
<p>You can create such action bar, but it's little more complicated than inflating a menu. Menu created in <code>onCreateOptionsMenu()</code> method will be always aligned to right, placed in split action bar or hidden under the menu key. </p> <p>If you want your action bar to contain just two menu items - one on the ...
14,075,465
Copy a file with a too long path to another directory in Python
<p>I am trying to copy files on Windows with Python 2.7, but sometimes this fails.</p> <pre><code>shutil.copyfile(copy_file, dest_file) </code></pre> <p>I get the following IOError:</p> <pre><code>[Errno 2] No such file or directory </code></pre> <p>But the file does exist! The problem is that the path of the file ...
14,076,169
3
1
null
2012-12-28 20:35:59.057 UTC
9
2014-01-16 16:58:12.12 UTC
null
null
null
null
654,160
null
1
19
python|copy
20,205
<p>I wasn't sure about the 255 char limit so I stumbled on <a href="https://stackoverflow.com/questions/1857335/is-there-any-length-limits-of-file-path-in-ntfs#1857477">this post</a>. There I found a working answer: adding \\?\ before the path.</p> <pre><code>shutil.copyfile("\\\\?\\" + copy_file, dest_file) </code></...
14,249,467
os.Mkdir and os.MkdirAll permissions
<p>I'm trying to create a log file at the start of my program.</p> <p>I need to check if a <code>/log</code> directory exists if it doesn't create the directory then move on to creating the log file.</p> <p>Well I tried to use <code>os.Mkdir</code> (as well as <code>os.MkdirAll</code>), but no matter what value I put i...
31,151,508
5
0
null
2013-01-10 01:33:50.06 UTC
37
2021-07-17 09:15:23.893 UTC
2021-07-17 09:15:23.893 UTC
user16442705
null
null
563,335
null
1
95
linux|go
80,809
<p>You can use octal notation directly:</p> <pre><code>os.Mkdir("dirname", 0700) </code></pre> <p><br> <strong>Permission Bits</strong></p> <pre><code>+-----+---+--------------------------+ | rwx | 7 | Read, write and execute | | rw- | 6 | Read, write | | r-x | 5 | Read, and execute | | r-- | 4 ...
43,384,804
How to validate that at least one checkbox should be selected?
<p>I want to do validation for checkboxes here without form tag. <strong>At least one checkbox should be selected.</strong></p> <pre class="lang-xml prettyprint-override"><code>&lt;div *ngFor="let item of officeLIST"&gt; &lt;div *ngIf=" item.officeID == 1"&gt; &lt;input #off type="checkbox" id="off" name="off" v...
43,386,577
7
2
null
2017-04-13 06:16:31.893 UTC
15
2021-10-21 17:37:56.77 UTC
2019-01-22 01:35:28.5 UTC
null
430,885
null
3,431,310
null
1
33
forms|angular|validation|typescript
61,760
<p>consider creating a <code>FormGroup</code> which contains your check-box group and bind the group's checked value to a hidden formcontrol with a required validator.</p> <p>Assume that you have three check boxes</p> <pre><code>items = [ {key: 'item1', text: 'value1'}, // checkbox1 (label: value1) {key: 'it...
9,353,414
Rounding Down to nearest whole number - am I cheating or is this more than adequate?
<p>Essentially, if the number generated is 2.3 then if I subtract .5 it will then be 1.8 but the rounding function will make it 2, which is what I want. Or if the answer is 2.99999 and I subtract .5, the answer is 2.49999 which should round down to 2 which is what I want. My question is if the answer is 2 even and I su...
9,353,682
3
1
null
2012-02-19 21:28:35.963 UTC
3
2020-12-28 01:21:44.577 UTC
2020-12-28 01:21:44.577 UTC
null
1,783,163
null
1,108,852
null
1
15
java
70,233
<p>Even simpler and potential faster</p> <pre><code>double d = 2.99999999; long l = (long) d; // truncate to a whole number. </code></pre> <p>This will round towards 0. Math.floor() rounds towards negative infinity. Math.round(x - 0.5) also rounds towards negative infinity.</p>
9,226,323
Mocking a class vs. mocking its interface
<p>For a unit test, I need to mock several dependencies. One of the dependencies is a class which implements an interface:</p> <pre><code>public class DataAccessImpl implements DataAccess { ... } </code></pre> <p>I need to set up a mock object of this class which returns some specified values when provided with s...
9,226,437
5
1
null
2012-02-10 10:30:56.723 UTC
11
2018-04-05 06:24:08.367 UTC
2014-05-26 11:22:05.053 UTC
null
145,287
null
1,178,669
null
1
53
java|unit-testing|junit|mocking
74,301
<p>It may not make much difference in your case but the preferred approach is to mock interface, as normally if you follow TDD (Test Driven Development) then you could write your unit tests even before you write your implementation classes. Thus even if you did not have concrete class <code>DataAccessImpl</code>, you c...
1,068,158
Put a button on top of a google map
<p>I would like to put a button on top of a Google Map next to the Map, Satelite and Hybrid buttons.</p> <p>I was wondering if its possible and how would be the best way to do it?</p> <p>So ideas I have are overlaying a image on top of the google map that is clickable but not sure if that will take all the events awa...
1,068,388
5
0
null
2009-07-01 09:21:14.277 UTC
2
2017-07-12 15:18:03.683 UTC
2017-07-12 15:18:03.683 UTC
null
1,000,551
null
66,319
null
1
13
google-maps|button|overlay
49,977
<p>There is a pretty good description of how to do this <a href="http://code.google.com/apis/maps/documentation/controls.html#Custom_Controls" rel="nofollow noreferrer">here</a>.</p> <p>I am pretty sure you can style these guys to look like the standard buttons and you can definitely anchor it to the top right. When ...
639,886
Exporting from SQL Server to Excel with column headers?
<p>I have a query that has approximately 20 columns and I would like to export this to an Excel file with the column headers. </p> <p>I thought this would be easy to figure out but no luck! I searched the web and found one suggestion that did not end up working so I am stuck.</p>
640,619
5
2
null
2009-03-12 18:25:20.627 UTC
3
2022-07-21 17:15:25.937 UTC
2017-10-27 16:16:32.323 UTC
null
2,144,085
Mark K.
16,642
null
1
14
sql-server|excel|sql-server-2005|export
75,255
<p>I typically do this by simply click the upper left corner in the results grid, copy, and then paste into Excel. There is one catch, you need to go into options->query results-> SQL Server->results to grid (or text if you want to save to file for import into excel) and turn on include column headers when copying or ...
1,154,331
SQLAlchemy and django, is it production ready?
<p>Has anyone used <code>SQLAlchemy</code> in addition to <code>Django</code>'s ORM?</p> <p>I'd like to use Django's ORM for object manipulation and SQLalchemy for complex queries (like those that require left outer joins). </p> <p>Is it possible?</p> <p>Note: I'm aware about <code>django-sqlalchemy</code> but the p...
1,155,407
5
0
null
2009-07-20 15:44:44.8 UTC
12
2022-07-11 06:20:50.41 UTC
2013-09-05 20:09:57.45 UTC
null
1,628,832
null
80,869
null
1
24
python|database|django|sqlalchemy
12,706
<p>What I would do,</p> <ol> <li><p>Define the schema in Django orm, let it write the db via syncdb. You get the admin interface.</p></li> <li><p>In view1 you need a complex join</p></li> </ol> <pre> <code> def view1(request): import sqlalchemy data = sqlalchemy.complex_join_magic(...) ... ...
134,791
Why pool Stateless session beans?
<p>Stateless beans in Java do not keep their state between two calls from the client. So in a nutshell we might consider them as objects with business methods. Each method takes parameters and return results. When the method is invoked some local variables are being created in execution stack. When the method returns t...
135,037
5
0
2008-09-25 17:43:30.05 UTC
2008-09-25 17:43:30.05 UTC
11
2018-03-30 13:23:20.697 UTC
null
null
null
null
3,980
null
1
28
java|ejb|pooling|stateless-session-bean
15,332
<p>Pooling does several things.</p> <p>One, by having one bean per instance, you're guaranteed to be threads safe (Servlets, for example, are not thread safe).</p> <p>Two, you reduce any potential startup time that a bean might have. While Session Beans are "stateless", they only need to be stateless with regards to ...
157,603
Getting specific revision via http with VisualSVN Server
<p>I'm using VisualSVN Server to host an SVN repo, and for some automation work, I'd like to be able to get specific versions via the http[s] layer.</p> <p>I can get the HEAD version simply via an http[s] request to the server (httpd?) - but is there any ability to specify the revision, perhaps as a query-string? I ca...
3,084,830
5
0
null
2008-10-01 13:29:00.29 UTC
12
2019-02-22 11:54:47.747 UTC
2012-07-19 12:48:33.887 UTC
null
761,095
Marc Gravell
23,354
null
1
33
svn|http|version-control|visualsvn|visualsvn-server
14,875
<p>Better late than never; <a href="https://entire/Path/To/Folder/file/?p=REV" rel="noreferrer">https://entire/Path/To/Folder/file/?p=REV</a></p> <p>?p=Rev specifies the revision</p>
30,914,964
How to update multiple tables with single query
<p>I have 2 tables that I need to update:</p> <p>Table A consists of: ID, personName, Date, status</p> <p>Table B consist of: PersonID, Date, status</p> <p>For every row in A there can be multiple rows in B with the same personID</p> <p>I need to "loop" over all results from A that the status=2 and update the date ...
30,915,208
3
2
null
2015-06-18 12:08:36.817 UTC
2
2015-06-18 14:23:23.56 UTC
null
null
null
null
606,645
null
1
6
sql|sql-server
46,496
<p>Here is an example using the <code>output</code> clause:</p> <pre><code>declare @ids table (id int); update table1 set status = 1 output inserted.id into @ids where status = 2; update table2 set status = 1, date = getdate() where personid in (select id from @ids); </code></pre>
30,867,937
Redundant conformance error message Swift 2
<p>I updated my project to Swift 2, and received a bunch of <code>redundant conformance of XXX to protocol YYY</code>. This happens especially often (or always) when a class conforms to <code>CustomStringConvertible</code>. Also some place with <code>Equatable</code>.</p> <pre><code>class GraphFeatureNumbersetRange: G...
30,868,779
3
3
null
2015-06-16 12:43:49.027 UTC
2
2018-06-02 13:06:19.987 UTC
2015-06-16 13:40:59.407 UTC
null
1,187,415
null
1,572,953
null
1
52
xcode|swift
46,912
<p>You'll get that error message in Xcode 7 (Swift 2) if a subclass declares conformance to a protocol which is already inherited from a superclass. Example:</p> <pre><code>class MyClass : CustomStringConvertible { var description: String { return "MyClass" } } class Subclass : MyClass, CustomStringConvertible { ...
21,217,710
Factor Loadings using sklearn
<p>I want the correlations between individual variables and principal components in python. I am using PCA in sklearn. I don't understand how can I achieve the loading matrix after I have decomposed my data? My code is here.</p> <pre><code>iris = load_iris() data, y = iris.data, iris.target pca = PCA(n_components=2) t...
44,728,692
3
4
null
2014-01-19 14:03:00.593 UTC
12
2018-06-12 15:52:31.303 UTC
2014-01-20 07:10:38.997 UTC
null
1,286,398
null
1,286,398
null
1
29
python|scikit-learn|pca
32,692
<p>I think that @RickardSjogren is describing the eigenvectors, while @BigPanda is giving the loadings. There's a big difference: <a href="https://stats.stackexchange.com/questions/143905/loadings-vs-eigenvectors-in-pca-when-to-use-one-or-another">Loadings vs eigenvectors in PCA: when to use one or another?</a>.</p> ...
21,381,641
iOS, unrecognized selector sent to instance?
<p>I got a mainscreen with a imported custom actionBar. I created this actionBar in a separate .xib file, with a .m and .h file. </p> <p>I do some graphic setup in my actionBar.m's <code>viewDidLoad</code> like <code>backgroundColor</code> and some other stuff. </p> <p>I also got a button on this <code>actionBar</cod...
21,381,758
1
7
null
2014-01-27 13:02:54.857 UTC
null
2014-01-27 13:28:52.197 UTC
2014-01-27 13:28:52.197 UTC
null
1,497,737
null
2,408,952
null
1
6
ios|iphone|xib|ibaction
41,590
<p>You are releasing the <code>actionBar</code> instance and just retaining its <code>view</code>. If <code>actionBar</code> instance is responder to button action, then button click message is getting sent to deleted instance. You should retain the <code>actionBar</code> instance. One way to do this is making it an iv...
18,215,899
Get type of generic parameter
<p>I wrote small function for better handling with types.</p> <pre><code>function evaluate(variable: any, type: string): any { switch (type) { case 'string': return String(variable); case 'number': return isNumber(variable) ? Number(variable) : -1; case 'boolean': { if (type...
18,216,538
2
3
null
2013-08-13 17:50:42.35 UTC
6
2020-07-06 06:15:12.543 UTC
null
null
null
null
2,438,165
null
1
21
generics|types|typescript
53,988
<p><code>typeof</code> is a JavaScript operator. It can be used at run time to get the types JavaScript knows about. Generics are a TypeScript concept that helps check the correctness of your code but doesn't exist in the compiled output. So the short answer is no, it's not possible.</p> <p>But you could do somethin...
17,838,221
JEE7: Do EJB and CDI beans support container-managed transactions?
<p>Java EE7 consists of a bunch of "bean" definitions:</p> <ul> <li>Managed Beans 1.0 (JSR-316 / JSR-250)</li> <li>Dependency Injection for Java 1.0 (JSR-330)</li> <li>CDI 1.1 (JSR-346)</li> <li>JSF Managed Beans 2.2 (JSR-344)</li> <li>EJB 3.2 (JSR-345)</li> </ul> <p>In order to get rid of the chaos in my mind, I stu...
17,842,796
2
1
null
2013-07-24 15:18:01.17 UTC
14
2016-02-25 21:10:16.783 UTC
2017-05-23 12:01:29.92 UTC
null
-1
null
1,399,395
null
1
20
java|jakarta-ee|ejb|cdi|jta
21,502
<p>Until Java EE 7 only EJB was transactional and the <code>@Transactional</code> annotation didn't exist.</p> <p>Since Java EE 7 and JTA 1.2 you can use transactional interceptor in CDI with <code>@Transactional</code> annotation.</p> <p>To answer your question about the best type of bean to use, the answer is CDI b...
2,006,763
What are the prerequisites to learning natural language processing?
<p>I am planning to learn natural language processing this year.</p> <p>But when I start reading introductory books on this topic, I found that I miss a lot of points relating mainly to mathematics.</p> <p>So I'm here searching for what I should learn before I can learn nlp, well, more smoothly?</p> <p>Thanks in adv...
2,006,797
5
0
null
2010-01-05 14:54:15.77 UTC
24
2014-10-31 01:39:51.663 UTC
2010-01-05 14:58:24.783 UTC
null
164,901
null
225,262
null
1
25
nlp
16,187
<p>There are two main approaches to NLP right now - one is the language-based approach detailed by Jurafsky and Martin (<a href="https://rads.stackoverflow.com/amzn/click/com/0131873210" rel="noreferrer" rel="nofollow noreferrer">Speech and Language Processing</a>) and the other is a probability and statistics-based ap...
2,104,513
Minify HTML output from an ASP.Net MVC Application
<p>This is likely a duplicate of the below question but the only answer is a dead link:<br> <a href="https://stackoverflow.com/questions/255008/minify-html-output-of-asp-net-application">Minify Html output of ASP.NET Application</a></p> <p>When working with ASP.Net one of the more annoying aspects to me is the fact th...
2,104,573
5
1
null
2010-01-20 20:01:44.593 UTC
11
2017-03-25 00:59:16.237 UTC
2017-05-23 12:02:48.59 UTC
null
-1
null
238,395
null
1
39
asp.net|asp.net-mvc|minify|asp.net-mvc-views
36,922
<p><a href="https://stackoverflow.com/questions/6992524/">Enabling GZIP</a> will have much more effect than minifying your HTML, anyway.</p> <p>Doing minification at runtime could hurt your servers (assuming you don't use caching). It may be a good idea to minfiy your Asp.Net markup during deployment. This way, you st...
1,830,347
Quickest way to pass data to a popup window I created using window.open()?
<p>I have javascript code to open a popup window using the window.open() function. I'd like to pass data from the parent window to that popup window and I can't seem to find an elegant or simple solution anywhere on google or SO, but it seems like there should be support for this built into JS. What's the easiest way...
1,830,388
6
1
null
2009-12-02 02:43:09.383 UTC
8
2022-09-03 04:03:56.53 UTC
null
null
null
null
191,808
null
1
29
javascript
42,957
<p>Due to security restrictions it <em>is</em> super easy <em>only</em> if the parent window and the popup are from the same domain. If that is the case just use this:</p> <pre><code>// Store the return of the `open` command in a variable var newWindow = window.open('http://www.mydomain.com'); // Access it using its ...
1,466,000
Difference between modes a, a+, w, w+, and r+ in built-in open function?
<p>In the python built-in <a href="http://docs.python.org/library/functions.html#open" rel="noreferrer">open</a> function, what is the exact difference between the modes <code>w</code>, <code>a</code>, <code>w+</code>, <code>a+</code>, and <code>r+</code>?</p> <p>In particular, the documentation implies that all of th...
1,466,036
8
3
null
2009-09-23 13:27:36.45 UTC
418
2022-05-25 19:19:30.93 UTC
2020-05-20 05:47:17.2 UTC
null
6,862,601
null
63,051
null
1
784
python
595,827
<p>The opening modes are exactly the same as those for the C standard library function <strong><code>fopen()</code></strong>.</p> <p><a href="http://www.manpagez.com/man/3/fopen/" rel="noreferrer">The BSD <code>fopen</code> manpage</a> defines them as follows:</p> <pre class="lang-none prettyprint-override"><code> Th...
1,371,351
Add files to an Xcode project from a script?
<p>Right now I'm using a few scripts to generate files that I'm including as resources in Xcode. The thing is I'm running the script, then deleting from the project, then adding back into the project. There must be a way to automate this last step, so that the script can generate the files and automatically add them in...
1,371,595
8
1
null
2009-09-03 03:51:36.363 UTC
35
2021-03-19 10:00:09.483 UTC
2014-08-27 18:01:12.913 UTC
null
148,335
null
167,643
null
1
57
xcode|scripting|project
38,971
<p>This can be done by adding a new build phase to your application.</p> <ol> <li><p>In your Xcode project browser, find the target for your application, and expand it to show all of the build phases.</p></li> <li><p>Add a new <a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/Xcod...
2,190,625
What is the difference between framework and architecture?
<p>I would like to know the difference between framework and architecture.<br> for example: <code>dotnetnuke</code> is the framework and <code>mvc</code> is the architecture.</p> <p>so if we take both of this as a example, can anyone tell me difference between them?<br> Want to know which one is using when and where?<...
2,191,064
12
3
2010-02-03 08:37:22.643 UTC
2010-02-03 08:37:22.643 UTC
23
2018-12-02 01:08:30.733 UTC
2018-12-02 01:08:30.733 UTC
user3956566
null
null
200,349
null
1
34
.net|architecture|frameworks|dotnetnuke
35,952
<p>Let me illustrate the difference.</p> <p>Framework:</p> <p><img src="https://s3.amazonaws.com/finewoodworking.s3.tauntoncloud.com/app/uploads/2016/09/05213353/Woodworking_Tools.jpg" alt="Framework"></p> <p>Architecture:</p> <p><img src="https://i.imgur.com/kfZysaU.png" alt="Architecture"></p>
1,765,311
How to view files in binary from bash?
<p>I would like to view the contents of a file in the current directory, but in binary from the command line. How can I achieve this?</p>
20,305,782
13
0
null
2009-11-19 18:04:11.783 UTC
104
2021-05-10 23:34:30.243 UTC
2018-12-05 22:36:51.087 UTC
null
211,176
null
211,176
null
1
354
bash|shell|binary
514,488
<p><a href="https://linux.die.net/man/1/xxd" rel="noreferrer"><code>xxd</code></a> does both binary and hexadecimal.</p> <p>bin:</p> <pre><code>xxd -b file </code></pre> <p>hex:</p> <pre><code>xxd file </code></pre>
2,189,452
When to use margin vs padding in CSS
<p>When writing CSS, is there a particular rule or guideline that should be used in deciding when to use <code>margin</code> and when to use <code>padding</code>?</p>
9,183,818
16
1
null
2010-02-03 03:20:12.533 UTC
770
2022-09-12 15:03:15.967 UTC
2020-02-06 14:24:49.907 UTC
null
2,756,409
null
6,651
null
1
2,555
css|padding|margin
957,778
<p><strong>TL;DR:</strong> <em>By default I use margin everywhere, except when I have a border or background and want to increase the space inside that visible box.</em></p> <p>To me, the biggest difference between padding and margin is that vertical margins auto-collapse, and padding doesn't. </p> <p>Consider two el...
33,884,291
Pipes, dup2 and exec()
<p>I have to write a shell that can run pipes. For example commands like <code>ls -l | wc -l</code>". I have successfully parsed the command given by the user as below:</p> <blockquote> <p>"ls" = firstcmd</p> <p>"-l" = frsarg</p> <p>"wc" = scmd</p> <p>"-l" = secarg</p> </blockquote> <p>Now I have to ...
33,884,923
3
4
null
2015-11-24 02:16:56.247 UTC
9
2020-06-24 03:35:20.28 UTC
2017-05-19 15:05:56.873 UTC
null
15,168
null
2,964,459
null
1
12
c|linux|shell|exec|dup2
69,912
<p>You need to close all the pipe descriptors in both the parent process and the child process (after duplication in the child process). In your code the main issue is that, the <code>wc</code> process does not exit because there are still writers present (since the parent process has not closed the write end). Changes...
18,163,213
TypeError: abc.getAttribute is not a function
<p>For the following code:</p> <pre><code> &lt;span class="map-marker" data-lng="101.7113506794"&gt;&lt;/span&gt; &lt;span class="map-marker" data-lng="101.6311097146"&gt;&lt;/span&gt; var abc = $('.map-marker:first'); var xyz = abc.getAttribute("data-lat"); console.log(xyz); </code></pre> <p>I get the erro...
18,163,229
7
2
null
2013-08-10 15:10:08.187 UTC
8
2019-09-17 09:02:11.69 UTC
2017-07-20 10:21:57.147 UTC
null
1,206,613
null
492,767
null
1
21
javascript|jquery
120,844
<p>Try this may be:</p> <pre><code>var abc = $(".map-marker:first")[0]; var xyz = abc.getAttribute("data-lat"); console.log(xyz); </code></pre> <p>Or this: </p> <pre><code>var abc = $(".map-marker:first"); var xyz = abc.data("lat"); console.log(xyz); </code></pre>
17,754,233
Crashlytics file not found
<p>Recently opened a project that I had compiled and submitted to Apple.</p> <p>I haven't touched it for a couple of months but I'm getting this odd compile error at:</p> <pre><code>#import &lt;Crashlytics/Crashlytics.h&gt; </code></pre> <p>The error reads:</p> <pre><code>'Crashlytics/Crashlytics.h' file not found ...
18,506,633
13
5
null
2013-07-19 19:41:53.843 UTC
15
2022-05-24 03:51:23.08 UTC
2014-06-02 05:23:47.063 UTC
null
403,018
null
343,204
null
1
58
xcode|crashlytics
44,219
<p>Just add <code>$(SRCROOT)</code> to the <strong>Framework Search Paths</strong> in Project Build Settings (Search Paths).</p> <p>Crashlytics installation process drops its <code>Crashlytics.framework</code> to your project folder (or creates the symlink).</p> <p>If you moved Crashlytics.framework somewhere deeper ...
6,688,329
In Scala Akka futures, what is the difference between map and flatMap?
<p>in normal Scala map and flatMap are different in that flatMap will return a iterable of the data flattened out into a list. However in the Akka documentation, map and flatMap seem to do something different?</p> <p><a href="http://akka.io/docs/akka/1.1/scala/futures.html" rel="noreferrer">http://akka.io/docs/akka/1....
6,689,495
3
1
null
2011-07-14 04:00:07.293 UTC
16
2017-06-26 11:23:48.037 UTC
null
null
null
null
78,000
null
1
39
scala|akka
12,660
<p>In "normal" Scala (as you say), map and flatMap have nothing to do with Lists (check Option for example).</p> <p>Alexey gave you the correct answer. Now, if you want to know why we need both, it allows the nice <code>for</code> syntax when composing futures. Given something like:</p> <pre><code>val future3 = for( ...
6,814,620
Strange behavior using view-based NSOutline (Sourcelist)
<p>I have a (new in Lion) view-based NSOutlineView as Sidebar SourceList in my app using CoreData + NSTreeController + Bindings + NSOutlineView and an Object as NSOutlineViewDelegate.</p> <p>I use these delegate methods in the outlineview delegate:</p> <p><strong>- (BOOL)outlineView:(NSOutlineView *)outlineView isGro...
7,092,369
4
1
null
2011-07-25 10:17:27.62 UTC
16
2015-12-29 09:30:39.35 UTC
2011-08-18 07:20:49.4 UTC
null
449,424
null
449,424
null
1
18
cocoa|nsoutlineview
4,417
<p>Setting <strong>setFloatsGroupRows:NO</strong> for the outline view must solve the issue with first group item moving up-down when being expanded/collapsed.</p>
6,532,400
Linking files in g++
<p>Recently I have tried to compile a program in g++ (on Ubuntu). Usually i use Dev-C++ (on Windows) and it works fine there as long as I make a project and put all the necessary files in there. </p> <p>The error that occurs when compiling the program is:</p> <pre><code>$filename.cpp: undefined reference to '[Class]:...
6,532,492
4
2
null
2011-06-30 09:00:32.303 UTC
12
2019-05-04 07:54:15.997 UTC
null
null
null
null
784,079
null
1
24
c++|g++|compiler-errors|linker-errors
89,364
<p>You probably tried to either compile and link instead of just compiling source files or somehow forgot something.</p> <p>Variation one (everything in one line; recompiles everything all the time):</p> <pre><code>g++ -o myexecutable first.cpp second.cpp third.cpp [other dependencies, e.g. -Lboost, -LGL, -LSDL, etc....
23,802,115
Is LIMIT clause in HIVE really random?
<p>The <a href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Select" rel="noreferrer">documentation</a> of <code>HIVE</code> notes that <code>LIMIT</code> clause <code>returns rows chosen at random</code>. I have been running a <code>SELECT</code> table on a table with more than <code>800,000</code> ...
23,802,286
3
3
null
2014-05-22 08:55:44.15 UTC
4
2018-02-22 00:31:52.26 UTC
2014-05-22 11:37:48 UTC
null
354,577
null
295,338
null
1
15
sql|hive|hiveql|shark-sql
59,462
<p>Even though the documentation states it returns rows at random, it's not actually true. </p> <p>It returns "chosen rows at random" as it appears in the database without any where/order by clause. This means that it's not really random (or randomly chosen) as you would think, just that the order the rows are returne...
15,714,342
Iterating through PostgreSQL records. How to reference data from next row?
<p>I'm new to PostgreSQL and writing functions here is tough as nails. So I'm hoping someone can help let me know how to do what I'm trying to do.</p> <p>I have a table of stock prices and dates. I want to calculate the percent change from the previous day for each entry. For the earliest day of data, there won't be a...
15,716,499
2
0
null
2013-03-30 02:40:47.333 UTC
4
2013-03-30 08:29:23.437 UTC
2013-03-30 08:23:45.007 UTC
null
939,860
null
1,455,043
null
1
8
sql|postgresql|plpgsql|window-functions
43,494
<blockquote> <p>I want to calculate the percent change from the previous day for each entry.</p> </blockquote> <p>Generally you need to <strong>study the basics</strong>, before you start asking questions.<br> Read the excellent manual about <a href="http://www.postgresql.org/docs/current/interactive/sql-createfun...
27,726,779
Declare Maven dependency as test runtime only
<p>What is the best way to declare a Maven dependency as only being used for the test runtime (but not test compilation) class path?</p> <p>Specifically, I want <code>slf4j-api</code> (a logging facade) as a typical, compile-scope dependency, but I want <code>slf4j-simple</code> (the barebones implementation suitable ...
27,729,783
4
4
null
2014-12-31 22:11:54.917 UTC
6
2021-06-17 06:16:04.48 UTC
null
null
null
null
123,336
null
1
33
java|maven|maven-3|maven-dependency-plugin
13,447
<p>There is no scope that does exactly what you want here; <code>test</code> is the best available option.</p> <p>A <code>test-runtime</code> scope has been requested before (<a href="https://mail-archives.apache.org/mod_mbox/maven-users/200811.mbox/%3C17608340.3674701226307519843.JavaMail.adm-moff@moffice8.nsc.no%3E"...
5,459,708
Measuring the UITableView Scrolling Performance - iphone
<p>I am trying to measure the scrolling performance for my UITableView, between using subview and drawing the view myself. As we may know about scrolling performance, there are a couple of famous articles (<a href="http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/" rel="noreferrer">Tweetie</a>...
5,459,796
2
1
null
2011-03-28 13:30:59.47 UTC
9
2012-10-10 15:10:09.283 UTC
2011-03-28 14:01:03.76 UTC
null
227,698
null
227,698
null
1
11
iphone|objective-c|performance|uitableview|scroll
3,949
<p>I'd suggest using Instruments rather than trying to run the test directly in your code. The Core Animation tool will track the actual number of frames per second (FPS) that your app’s displaying.</p>
5,578,535
Get Cell Value from Excel Sheet with Apache Poi
<p>How to get cell value with poi in java ?</p> <p>My code is look like this </p> <pre><code>String cellformula_total__percentage= "(1-E" + (rowIndex + 2) + "/" + "D" + (rowIndex + 2) + ")*100"; cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); cell.setCellStyle(this.valueRightAlignStyleLightBlueBackground); cell.setCell...
5,578,666
2
0
null
2011-04-07 09:01:29.703 UTC
11
2011-09-20 15:26:17.28 UTC
2011-09-20 15:26:17.28 UTC
null
701,884
null
492,185
null
1
20
java|apache-poi
176,552
<p>You have to use the FormulaEvaluator, as shown <a href="http://poi.apache.org/spreadsheet/eval.html">here</a>. This will return a value that is either the value present in the cell or the result of the formula if the cell contains such a formula :</p> <pre><code>FileInputStream fis = new FileInputStream("/somepath/...
5,331,452
HTTP Accept Header meaning
<p>When a browser's Accept request header says something like the following:</p> <pre><code>Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 </code></pre> <p>Does that mean that <code>application/xml</code>, <code>application/xhtml+xml</code>, and <code>text/html</cod...
5,331,486
2
0
null
2011-03-16 20:40:06.957 UTC
9
2015-08-18 01:15:02.143 UTC
2013-11-12 14:14:49.403 UTC
null
428,241
null
43,217
null
1
44
http|http-headers|mime-types|content-negotiation
46,512
<p>No, if the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">quality parameter</a> is missing <code>q=1.0</code> is assumed:</p> <blockquote> <p>Each media-range MAY be followed by one or more accept-params, beginning with the "q" parameter for indicating a relative quality factor […] using...
5,401,358
What's the difference between jaxws-ri and jaxws-rt?
<p>See the JAX-WS Maven repository from <em>java.net</em> - <a href="http://download.java.net/maven/2/com/sun/xml/ws/" rel="noreferrer">http://download.java.net/maven/2/com/sun/xml/ws/</a></p> <p>There are two similar folders - <strong>jaxws-rt</strong> and <strong>jaxws-ri</strong>. Currently, I'm using the <strong>j...
15,149,814
2
0
null
2011-03-23 05:54:32.013 UTC
10
2019-04-06 14:18:10.803 UTC
2013-06-06 15:06:43.063 UTC
null
814,702
null
483,819
null
1
53
java|web-services|jax-ws
32,129
<p>As an answer to your <strong>second question</strong>: Yes, you are right.</p> <p>Below is the proof.</p> <hr> <p><strong>RI</strong> stands for <em>Reference Implementation</em>.</p> <p>Quote from the official <a href="http://jax-ws.java.net/" rel="noreferrer"><strong>JAX-WS project home page</strong></a> (an ...
16,361,535
Webdriver findElements By xpath
<p>1)I am doing a tutorial to show how findElements By xpath works. I would like to know why it returns all the texts that following the <code>&lt;div&gt;</code> element with attribute <code>id=container</code>.</p> <p>code for xpath: <code>By.xpath("//div[@id='container']</code> </p> <p>2) how should I modify the co...
16,362,800
3
0
null
2013-05-03 14:39:52.007 UTC
4
2015-09-16 13:15:07.54 UTC
2015-09-16 13:15:07.54 UTC
null
487,494
null
2,061,466
null
1
7
java|selenium|xpath|selenium-webdriver|webdriver
102,057
<p>Your questions:</p> <p><strong>Q 1.) I would like to know why it returns all the texts that following the div?</strong><br> It should not and I think in will not. It returns all div with 'id' attribute value equal 'containter' (and all children of this). But you are printing the results with <code>ele.getText()</c...
16,493,280
Close Bootstrap Modal
<p>I have a bootstrap modal dialog box that I want to show initially, then when the user clicks on the page, it disappears. I have the following:</p> <pre><code>$(function () { $('#modal').modal(toggle) }); &lt;div class="modal" id='modal'&gt; &lt;div class="modal-header"&gt; &lt;button type="button"...
16,493,402
30
2
null
2013-05-11 02:49:23.84 UTC
58
2022-07-08 17:29:40.5 UTC
2016-03-03 07:08:15.983 UTC
null
2,202,702
null
903,143
null
1
521
jquery|twitter-bootstrap|modal-dialog
1,465,297
<p>Put <code>modal('toggle')</code> instead of <code>modal(toggle)</code></p> <pre><code>$(function () { $('#modal').modal('toggle'); }); </code></pre>
319,594
Calculate a color fade
<p>Given two colors and <em>n</em> steps, how can one calculate n colors including the two given colors that create a fade effect? </p> <p>If possible pseudo-code is preferred but this will probably be implemented in Java.</p> <p>Thanks!</p>
319,604
7
0
null
2008-11-26 02:38:59.577 UTC
11
2015-07-13 05:38:56.26 UTC
null
null
null
Trentula
868
null
1
12
colors|fade
17,344
<p>Divide each colour into its RGB components and then calculate the individual steps required.</p> <pre><code>oldRed = 120; newRed = 200; steps = 10; redStepAmount = (newRed - oldRed) / steps; currentRed = oldRed; for (i = 0; i &lt; steps; i++) { currentRed += redStepAmount; } </code></pre> <p>Obviously extend t...
448,126
lambda functions in bash
<p>Is there a way to implement/use lambda functions in bash? I'm thinking of something like:</p> <pre><code>$ someCommand | xargs -L1 (lambda function) </code></pre>
448,166
7
0
null
2009-01-15 19:30:37.257 UTC
8
2020-10-11 22:04:40.74 UTC
2009-07-09 01:08:19.263 UTC
null
68,587
Daniel
38,967
null
1
30
bash|lambda
16,630
<p>I don't know of a way to do this, however you may be able to accomplish what you're trying to do using:</p> <pre><code>somecommand | while read -r; do echo "Something with $REPLY"; done </code></pre> <p>This will also be faster, as you won't be creating a new process for each line of text.</p> <p><strong>[EDIT 20...
1,089,504
OO Software Design Principles
<p>I am a huge fan of software design principles such as <strong>SOLID</strong> and <strong>DRY</strong>. What other principles exist for OO software design? </p> <p>Note. I’m not looking for answers like "comment your code" but instead looking for OO design principles like the ones discussed by <a href="http://butunc...
1,089,551
8
7
2009-08-05 00:22:38.737 UTC
2009-07-06 22:29:10.173 UTC
14
2017-07-29 13:39:37.313 UTC
2009-07-06 22:35:55.713 UTC
null
101,361
null
113,535
null
1
4
oop|principles|design-principles
3,273
<p>A fairly comprehensive list from Wikipedia:</p> <p><a href="http://en.wikipedia.org/wiki/List_of_software_development_philosophies" rel="noreferrer">http://en.wikipedia.org/wiki/List_of_software_development_philosophies</a></p> <ul> <li>Agile software development</li> <li>Agile Unified Process (AUP) </li> <li>Beha...
667,147
Hacking and exploiting - How do you deal with any security holes you find?
<p>Today online security is a very important factor. Many businesses are completely based online, and there is tons of sensitive data available to check out only by using your web browser. </p> <p>Seeking knowledge to secure my own applications I've found that I'm often testing others applications for exploits and sec...
673,377
8
3
null
2009-03-20 17:28:17.617 UTC
20
2014-08-17 21:04:44.747 UTC
2014-08-17 21:04:44.747 UTC
Wouter van Nifterick
2,246,344
ChrisAD
39,268
null
1
26
security|exploit
3,846
<p>"Ive found that Im often testing others applications for exploits and security holes, maybe just for curiosity". </p> <p>In the UK, we have the "Computer Misuse Act". Now if these applications you're proverbially "looking at" are say Internet based and the ISP's concerned can be bothered to investigate (for purely ...
295,628
SecureRandom: init once or every time it is needed?
<p>Our team is using a SecureRandom to generate a list of key pairs (the SecureRandom is passed to a KeyPairGenerator). We cannot agree on which of the following two options to use:</p> <ol> <li><p>Create a new instance every time we need to generate a key pair</p></li> <li><p>Initialize a static instance and use it ...
295,652
8
0
null
2008-11-17 14:03:32.49 UTC
9
2021-10-15 17:06:46.333 UTC
2008-11-18 08:25:16.37 UTC
null
23,109
null
23,109
null
1
32
java|security|random|cryptography
14,935
<p>Unlike the <code>java.util.Random</code> class, the <code>java.security.SecureRandom</code> class must produce non-deterministic output on each call.</p> <p>What that means is, in case of <code>java.util.Random</code>, if you were to recreate an instance with the same seed each time you needed a new random number, ...
434,641
How do I set permissions (attributes) on a file in a ZIP file using Python's zipfile module?
<p>When I extract files from a ZIP file created with the Python <a href="http://docs.python.org/library/zipfile.html" rel="noreferrer"><code>zipfile</code></a> module, all the files are not writable, read only etc.</p> <p>The file is being created and extracted under Linux and Python 2.5.2.</p> <p>As best I can tell,...
434,689
8
0
null
2009-01-12 06:51:27.26 UTC
6
2022-05-01 12:31:45.827 UTC
2022-05-01 12:31:45.827 UTC
null
1,839,439
Tom
3,715
null
1
46
python|attributes|zip|file-permissions|python-zipfile
31,130
<p>This seems to work (thanks Evan, putting it here so the line is in context):</p> <pre><code>buffer = "path/filename.zip" # zip filename to write (or file-like object) name = "folder/data.txt" # name of file inside zip bytes = "blah blah blah" # contents of file inside zip zip = zipfile.ZipFile(buffer, ...
48,320
Best Ruby on Rails social networking framework
<p>I'm planning on creating a social networking + MP3 lecture downloading / browsing / commenting / discovery website using Ruby on Rails. Partially for fun and also as a means to learn some Ruby on Rails. I'm looking for a social networking framework that I can use as a basis for my site. I don't want to re-invent the...
161,963
9
3
null
2008-09-07 11:06:48.497 UTC
36
2022-05-30 15:35:15.223 UTC
2022-05-30 15:35:15.223 UTC
null
3,689,450
Candidasa
5,010
null
1
27
ruby-on-rails|ruby|social-media
38,487
<p>It depends what your priorities are.</p> <p>If you really want to learn RoR, <strong>do it all from scratch</strong>. Seriously. Roll your own. It's the best way to learn, far better than hacking through someone else's code. If you do that, sometimes you'll be learning Rails, but sometimes you'll just be learning t...
925,221
Can I hook into UISearchBar's Clear Button?
<p>I've got a UISearchBar in my interface and I want to customise the behaviour of the the small clear button that appears in the search bar after some text has been entered (it's a small grey circle with a cross in it, appears on the right side of the search field).</p> <p>Basically, I want it to not only clear the t...
3,852,512
9
2
null
2009-05-29 09:48:19.463 UTC
4
2015-11-25 12:15:40.23 UTC
2009-05-29 09:55:21.617 UTC
null
76,559
null
76,559
null
1
37
iphone|objective-c|uikit|uisearchbar
51,275
<p>The answer which was accepted is incorrect. This can be done, I just figured it out and posted it in another question:</p> <p><a href="https://stackoverflow.com/questions/1092246/uisearchbar-clearbutton-forces-the-keyboard-to-appear/3852509#3852509">UISearchbar clearButton forces the keyboard to appear</a></p> <p>...
321,118
What is the short cut in eclipse to terminate debugging/running?
<p>What is the shortcut in eclipse to terminate debugging/running? Looking under Preferences -> Keys says <kbd>Ctrl</kbd> + <kbd>F2</kbd> but it doesn't work.</p>
321,150
9
0
null
2008-11-26 15:34:05.847 UTC
6
2018-04-26 17:44:33.617 UTC
2011-09-08 19:09:11.467 UTC
Vijay Dev
321,366
cretzel
18,722
null
1
48
eclipse|keyboard-shortcuts
72,007
<p>As said <a href="http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg21758.html" rel="noreferrer">here</a>, you can add/enable the Debug command group to any perspective using<br> <code>Window / Customize Perspective &gt; Commands</code>.<br> (Select the 'Debug' group)</p> <p>Then open the Debug view in the J...
893,295
What are some of the most useful yet little known features in the PowerShell language
<p>A while back I was reading about multi-variable assignments in PowerShell. This lets you do things like this</p> <pre><code>64 &gt; $a,$b,$c,$d = "A four word string".split() 65 &gt; $a A 66 &gt; $b four </code></pre> <p>Or you can swap variables in a single statement</p> <pre><code>$a,$b = $b,$a </code></pr...
893,321
11
2
2010-03-20 09:53:18.51 UTC
2009-05-21 14:45:23.863 UTC
29
2019-08-10 16:56:01.713 UTC
null
null
null
null
45,571
null
1
26
powershell
3,151
<p>The <code>$$</code> command. I often have to do repeated operations on the same file path. For instance check out a file and then open it up in VIM. The <code>$$</code> feature makes this trivial</p> <pre><code>PS&gt; tf edit some\really\long\file\path.cpp PS&gt; gvim $$ </code></pre> <p>It's short and simple b...
910,873
How can I determine if a file is binary or text in c#?
<p>I need to determine in 80% if a file is binary or text, is there any way to do it even quick and dirty/ugly in c#?</p>
910,927
11
3
null
2009-05-26 14:05:20.297 UTC
21
2015-05-20 18:24:14.39 UTC
2012-05-01 11:55:13.523 UTC
null
50,776
null
30,729
null
1
60
c#|text|file-io|binary
52,192
<p>I would probably look for an abundance of control characters which would typically be present in a binary file but rarely in an text file. Binary files tend to use 0 enough that just testing for many 0 bytes would probably be sufficient to catch most files. If you care about localization you'd need to test multi-b...
144,261
Memory leak detection tools
<p>Does Apple's Xcode development environment provide any tools for memory leak detection?</p> <p>I am especially interested in tools that apply to the iPhone SDK. Currently my favourite platform for hobby programming projects</p> <p>Documentations/tutorials for said tools would be very helpful.</p>
144,866
11
0
null
2008-09-27 19:17:08.443 UTC
15
2016-04-24 08:09:42.543 UTC
2015-12-19 13:46:54.023 UTC
null
1,659,677
SytS
22,502
null
1
64
iphone|xcode|memory-management|memory-leaks
80,337
<p>There is one specifically called <code>Leaks</code> and like a previous poster said, the easiest way to run it is straight from Xcode: </p> <blockquote> <blockquote> <p>run -> Start with Performance Tool -> Leaks</p> </blockquote> </blockquote> <p>It seems very good at detecting memory leaks, and was easy ...
446,358
Storing a large number of images
<p>I'm thinking about developing my own PHP based gallery for storing lots of pictures, maybe in the tens of thousands.</p> <p>At the database I'll point to the url of the image, but here's the problem: I know is impractical to have all of them sitting at the same directory in the server as it would slow access to a c...
446,401
12
0
null
2009-01-15 10:57:43.097 UTC
33
2011-12-27 17:50:14.36 UTC
2009-03-24 12:22:50.143 UTC
Pete Kirkham
1,527
Saiyine
38,238
null
1
52
image|tree|filesystems
14,630
<p>We had a similar problem in the past. And found a nice solution:</p> <ul> <li>Give each image an unique guid.</li> <li>Create a database record for each image containing the name, location, guid and possible location of sub images (thumbnails, reducedsize, etc.).</li> <li>Use the first (one or two) characters of th...
459,238
When and how do you use server side JavaScript?
<p>Occasionally I search for some JavaScript help and I come upon the term "Server-side JavaScript". When would you use JavaScript server-side? And how? </p> <p>My experiences of JavaScript have been in the browser. Is there a compiled version of JS?</p>
459,379
12
6
null
2009-01-19 21:33:42.957 UTC
24
2018-06-28 20:32:30.9 UTC
2009-01-20 00:07:56.25 UTC
Peter Hilton
2,670
John Nolan
1,116
null
1
81
javascript|server-side
79,350
<p>There's the project <a href="https://phobos.java.net/" rel="noreferrer">Phobos</a>, which is a server side JavaScript framework.</p> <p>Back In The Day, the Netscape web server offered server-side java script as well.</p> <p>In both of these cases, JavaScript is used just like you'd use any language on the server....
310,634
What is the "right" way to iterate through an array in Ruby?
<p>PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you just do</p> <pre><code>foreach (array/hash as $key =&gt; $value) </code></pre> <p>In Ruby there are a bunch of ways to d...
310,638
12
2
null
2008-11-22 00:38:19.963 UTC
99
2022-02-25 21:42:12.147 UTC
2011-08-28 03:30:16.19 UTC
null
38,765
Horace Loeb
25,068
null
1
391
ruby|arrays|loops
614,616
<p>This will iterate through all the elements:</p> <pre class="lang-rb prettyprint-override"><code>array = [1, 2, 3, 4, 5, 6] array.each { |x| puts x } # Output: 1 2 3 4 5 6 </code></pre> <p>This will iterate through all the elements giving you the value and the index:</p> <pre class="lang-rb prettyprint-override"><c...
1,058,736
How to create a NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects?
<p>Is there any way to create a new NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects?</p> <p>In the NSSTring class there are many methods like:</p> <pre><code>- (id)initWithFormat:(NSString *)format arguments:(va_list)argList - (id)initWithFormat:(NSString *)format locale:(id)locale argu...
1,061,750
13
1
null
2009-06-29 14:46:09.507 UTC
16
2017-07-15 10:04:39.883 UTC
2009-06-29 17:42:20.51 UTC
null
120,292
null
19,331
null
1
32
objective-c|cocoa|nsstring|nsarray|string-formatting
49,934
<p>It is actually not hard to create a va_list from an NSArray. See Matt Gallagher's <a href="http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html" rel="nofollow noreferrer">excellent article</a> on the subject.</p> <p>Here is an NSString category to do what you want:</p> <pre><code>@interface NSSt...
348,040
iPhone and OpenCV
<p>I know that <a href="http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port" rel="noreferrer">OpenCV was ported to Mac OS X</a>, however I did not find any info about a port to the iPhone.</p> <p>I am not a Mac developer, so that I do not know whether a Mac OS X port is enough for the iPhone.</p> <p>Does anyone ...
12,662,359
13
0
null
2008-12-07 20:38:55.4 UTC
78
2019-05-23 06:28:45.07 UTC
2019-05-23 06:28:45.07 UTC
Chris Hanson
2,272,431
Pascal T.
19,816
null
1
97
ios|iphone|opencv
71,564
<p>OpenCV now (since <strong>2012</strong>) has an <strong>official port</strong> for the iPhone (iOS).</p> <p>You can find <a href="http://opencv.org" rel="nofollow noreferrer">all of OpenCV's releases here.</a></p> <p>And find install instructions here: </p> <p><a href="https://docs.opencv.org/3.4.3/d5/da3/tutoria...
338,206
Why can't I use switch statement on a String?
<p>Is this functionality going to be put into a later Java version?</p> <p>Can someone explain why I can't do this, as in, the technical way Java's <code>switch</code> statement works?</p>
338,230
14
3
null
2008-12-03 18:23:57.127 UTC
195
2022-09-22 02:19:10.857 UTC
2018-07-09 21:52:21.683 UTC
Nalandial
8,583,692
Nalandial
14,007
null
1
1,042
java|string|switch-statement
768,431
<p>Switch statements with <code>String</code> cases have been implemented in <a href="http://openjdk.java.net/projects/jdk7/features/" rel="nofollow noreferrer">Java SE 7</a>, at least 16 years <a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=1223179" rel="nofollow noreferrer">after they were first request...
1,102,692
How to alpha blend RGBA unsigned byte color fast?
<p>I am using c++ , I want to do alpha blend using the following code.</p> <pre><code>#define CLAMPTOBYTE(color) \ if ((color) &amp; (~255)) { \ color = (BYTE)((-(color)) &gt;&gt; 31); \ } else { \ color = (BYTE)(color); \ } #define GET_BYTE(accessPixel, x, y, scanline, bpp) \ ((BYTE*)(...
1,102,810
17
3
null
2009-07-09 09:04:36.64 UTC
23
2021-12-08 09:16:52.01 UTC
2016-12-12 02:35:04.663 UTC
null
432,509
null
25,749
null
1
23
c++|performance
30,781
<p><a href="http://www2.units.it/~csia/calcolointensivo/tartaglia/intel/cce/intref_cls.pdf" rel="noreferrer">Use SSE</a> - start around page 131. </p> <p>The basic workflow</p> <ol> <li><p>Load 4 pixels from src (16 1 byte numbers) RGBA RGBA RGBA RGBA (streaming load)</p></li> <li><p>Load 4 more which you want to ble...
157,429
What are the benefits of using Perforce instead of Subversion?
<p>My team has been using SVN for a few years. We now have the option of switching to Perforce.</p> <p>What would be the benefits (and pitfalls) of making such a switch?</p>
157,482
17
0
null
2008-10-01 12:52:46.46 UTC
24
2016-05-11 13:26:31.41 UTC
2008-10-01 13:03:34.173 UTC
jfm3
11,138
Ferruccio
4,086
null
1
66
svn|perforce
42,729
<ul> <li>P4 keeps track of your working copy on the server. This means that <ol> <li>Large working copies are processed much faster. I used to have a large SVN project and a simple update took 15 minutes because it had to create a tree of the local working copy (thousands of folders). File access is slow. P4 stores th...
798,545
What is the Java ?: operator called and what does it do?
<p>I have been working with Java a couple of years, but up until recently I haven't run across this construct:</p> <pre><code>int count = isHere ? getHereCount(index) : getAwayCount(index); </code></pre> <p>This is probably a very simple question, but can someone explain it? How do I read it? I am pretty sure I kno...
798,556
17
4
null
2009-04-28 15:28:50.42 UTC
52
2022-03-22 07:01:39.943 UTC
2016-05-27 09:44:54.467 UTC
null
1,752,988
null
33,863
null
1
188
java|syntax|ternary-operator|conditional-operator
261,170
<p>Yes, it is a shorthand form of</p> <pre><code>int count; if (isHere) count = getHereCount(index); else count = getAwayCount(index); </code></pre> <p>It's called the <strong>conditional operator</strong>. Many people (erroneously) call it <em>the ternary operator</em>, because it's the only ternary (three-arg...
74,148
How to convert numbers between hexadecimal and decimal
<p>How do you convert between hexadecimal numbers and decimal numbers in C#?</p>
74,223
20
0
null
2008-09-16 16:18:59.327 UTC
48
2022-02-22 22:44:53.993 UTC
2018-12-10 09:52:57.623 UTC
null
1,671,066
Andy McCluggage
3,362
null
1
168
c#|hex|type-conversion|decimal
414,072
<p>To convert from decimal to hex do...</p> <pre><code>string hexValue = decValue.ToString("X"); </code></pre> <p>To convert from hex to decimal do either...</p> <pre><code>int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); </code></pre> <p>or </p> <pre><code>int decValue = Convert.T...
869,033
How do I copy an object in Java?
<p>Consider the code below:</p> <pre><code>DummyBean dum = new DummyBean(); dum.setDummy("foo"); System.out.println(dum.getDummy()); // prints 'foo' DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // prints 'foo' dum.setDummy("bar"); System.out.println(dumtwo.getDummy()); // prints 'bar' but it should...
869,078
23
0
null
2009-05-15 14:30:26.943 UTC
305
2021-12-08 11:57:38.64 UTC
2017-12-23 19:15:19.35 UTC
null
5,345,646
null
42,372
null
1
896
java|object|copy|clone
1,401,924
<p>Create a copy constructor:</p> <pre><code>class DummyBean { private String dummy; public DummyBean(DummyBean another) { this.dummy = another.dummy; // you can access } } </code></pre> <p>Every object has also a clone method which can be used to copy the object, but don't use it. It's way too easy to c...
181,530
Styling multi-line conditions in 'if' statements?
<p>Sometimes I break long conditions in <code>if</code>s onto several lines. The most obvious way to do this is:</p> <pre><code> if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Isn't very very appealing visually, because the action blends wi...
181,557
30
5
null
2008-10-08 06:19:07.67 UTC
157
2019-10-25 17:28:13.22 UTC
2017-05-30 17:35:39.673 UTC
DzinX
355,230
eliben
8,206
null
1
825
python|coding-style|if-statement
1,490,075
<p>You don't need to use 4 spaces on your second conditional line. Maybe use:</p> <pre><code>if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Also, don't forget the whitespace is more flexible than you might think:</p> <pre><code>if ( ...
6,492,033
Return value for performSelector:
<p>What will the return value for performSelector: if I pass a selector that returns a primitive type (on object), such as 'week' on NSDateComponents (which will return an int)?</p>
10,973,879
5
0
null
2011-06-27 11:18:09.223 UTC
12
2017-03-29 02:37:23.94 UTC
null
null
null
null
74,415
null
1
41
objective-c|cocoa-touch|cocoa|performselector
20,516
<p>An example of using NSInvocation to return a float:</p> <pre><code>SEL selector = NSSelectorFromString(@"someSelector"); if ([someInstance respondsToSelector:selector]) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: [[someInstance class] instanceMethodS...
6,550,795
Uncaught TypeError: Cannot read property 'value' of undefined
<p>I have some JavaScript code that gives this error</p> <pre class="lang-none prettyprint-override"><code>Uncaught TypeError: Cannot read property 'value' of undefined </code></pre> <p>Code</p> <pre><code>var i1 = document.getElementById('i1'); var i2 = document.getElementById('i2'); var __i = {'user' : document.ge...
6,550,881
7
0
null
2011-07-01 16:43:31.837 UTC
15
2020-04-07 19:59:30.07 UTC
2020-04-07 19:59:30.07 UTC
null
12,820,864
null
572,737
null
1
55
javascript|typeerror
670,951
<p>Seems like one of your values, with a property key of 'value' is undefined. Test that <code>i1</code>, <code>i2</code>and <code>__i</code> are defined before executing the if statements:</p> <pre><code>var i1 = document.getElementById('i1'); var i2 = document.getElementById('i2'); var __i = {'user' : document.getEl...
38,129,284
Is GCM (now FCM) free for any limit?
<p>I would like to know if Firebase Cloud Messaging is free or not for unlimited users?</p>
38,316,883
4
2
null
2016-06-30 16:59:45.723 UTC
10
2021-04-20 18:14:28.16 UTC
2018-12-18 14:21:50.35 UTC
null
1,079,901
null
5,097,682
null
1
64
android|firebase|google-cloud-platform|google-cloud-messaging|firebase-cloud-messaging
52,206
<p>In addition to the <a href="https://stackoverflow.com/a/38136653/1079901">answer</a> from <a href="https://stackoverflow.com/users/4625829/al">AL</a>.<br /> From the <a href="https://firebase.google.com/pricing/" rel="noreferrer">Pricing page Faqs</a>:</p> <blockquote> <p><strong>Which products are paid? Which are f...
15,720,545
Use stat_summary to annotate plot with number of observations
<p>How can I use <code>stat_summary</code> to label a plot with <code>n = x</code> where is <code>x</code> a variable? Here's an example of the desired output:</p> <p><img src="https://i.stack.imgur.com/EX1ab.png" alt="enter image description here"></p> <p>I can make that above plot with this rather inefficient code:...
15,720,769
2
0
null
2013-03-30 16:00:48.067 UTC
8
2018-03-20 03:14:48.183 UTC
2017-05-23 11:55:07.73 UTC
null
-1
null
1,036,500
null
1
17
r|graph|plot|ggplot2
23,634
<p>You can make your own function to use inside the <code>stat_summary()</code>. Here <code>n_fun</code> calculate place of y value as <code>median()</code> and then add <code>label=</code> that consist of <code>n=</code> and number of observations. It is important to use <code>data.frame()</code> instead of <code>c()<...
15,818,364
VS 2012 launching app based on wrong path
<p>I have a app which is under source control (TFS 2012 also) on c:\Dev\MyApp\Main.</p> <p>Because im developing a new feature I decided to open a branch on c:\Dev\MyApp\BranchNewFeature.</p> <p>I developed and when I decided that it was time to test it was like i hadn't done any changes at all. I hit F5 and i see th...
16,619,659
7
7
null
2013-04-04 17:58:47.93 UTC
9
2016-10-14 13:15:40.09 UTC
2013-05-18 00:49:17.723 UTC
null
2,069
null
505,990
null
1
21
iis|version-control|visual-studio-2012|iis-express
13,197
<p>I ran into the same issue. To fix it, I used <a href="https://stackoverflow.com/users/1443490/cheesemacfly">cheesemacfly</a>'s suggestion, to update <code>C:\Users\%USERNAME%\Documents\IISExpress\config\applicationhost.config</code> to point to the new directory.</p> <p>The obvious downside with this solution is t...
35,789,520
How do I put object to amazon s3 using presigned url?
<p>I am trying to use signed url to upload images to s3 bucket. Following is my bucket policy: </p> <pre><code>{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::12345678...
35,923,104
5
7
null
2016-03-04 06:35:52.243 UTC
9
2021-03-04 06:22:57.127 UTC
2016-03-09 18:37:13.633 UTC
null
3,698,232
null
3,698,232
null
1
28
javascript|node.js|amazon-web-services|amazon-s3|pre-signed-url
28,999
<p>I managed to succesfully upload a file by using your code. </p> <p>Here are the steps I followed:</p> <ol> <li><p>Created a new bucket and a new IAM user</p></li> <li><p>Set IAM user's policy as below:</p> <pre><code>{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1418647210000...
10,743,622
ConcurrentHashMap: avoid extra object creation with "putIfAbsent"?
<p>I am aggregating multiple values for keys in a multi-threaded environment. The keys are not known in advance. I thought I would do something like this:</p> <pre><code>class Aggregator { protected ConcurrentHashMap&lt;String, List&lt;String&gt;&gt; entries = new ConcurrentHashMap&lt;S...
10,743,710
7
3
null
2012-05-24 18:54:25.49 UTC
21
2017-08-11 09:55:26.997 UTC
2015-04-02 14:04:55.297 UTC
user166390
146,197
null
389,051
null
1
42
java|synchronization|thread-safety|concurrenthashmap
18,953
<p>Java 8 introduced an API to cater for this exact problem, making a 1-line solution:</p> <pre><code>public void record(String key, String value) { entries.computeIfAbsent(key, k -&gt; Collections.synchronizedList(new ArrayList&lt;String&gt;())).add(value); } </code></pre> <p>For Java 7:</p> <pre><code>public v...
10,817,721
Wipe data/Factory reset through ADB
<p>Basically this is my problem/</p> <p>I have 200+ phones running stock Android that need to be wiped (in the Wipe Data/Factory Reset way) and then a new ROM installed with some additional apks.</p> <p>Currently I've got everything automated except the Wipe Data part. Everything else can be done through a .bat with ...
10,829,600
1
5
null
2012-05-30 13:52:53.803 UTC
20
2014-03-20 15:57:10.22 UTC
null
null
null
null
1,267,231
null
1
60
android|adb|reset|recovery
324,689
<p>After a lot of digging around I finally ended up downloading the source code of the recovery section of Android. Turns out you can actually send commands to the recovery.</p> <pre><code> * The arguments which may be supplied in the recovery.command file: * --send_intent=anystring - write the text out to recovery...
31,748,575
How to access the Component on a Angular2 Directive?
<p>I'm doing some tests with Angular 2 and I have a directive (layout-item) that can be applied to all my components.</p> <p>Inside that directive I want to be able to read some metadata defined on the component but for that I need to access the component's reference.</p> <p>I have tried the following approach but I ...
31,796,289
6
3
null
2015-07-31 14:25:47.933 UTC
13
2021-06-13 11:16:37.123 UTC
2018-08-13 04:26:17.713 UTC
user6749601
null
null
1,613,980
null
1
16
typescript|angular
26,524
<p><strong>UPDATE</strong>:</p> <p>Since Beta 16 there is no official way to get the same behavior. There is an unofficial workaround here: <a href="https://github.com/angular/angular/issues/8277#issuecomment-216206046" rel="nofollow">https://github.com/angular/angular/issues/8277#issuecomment-216206046</a></p> <hr> ...
33,575,109
MySQL - Entity : The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull
<p>I am using <strong>Visual Studio 2013</strong> with <strong>Entity Framework 5</strong> and M<strong>ySQL Server 5.7.9</strong>.</p> <p>When trying to create a Model from the database (<em>or 'Update Model From Database'</em>) the following message appears:</p> <blockquote> <p>'System.Data.StrongTypingException:...
35,422,569
11
5
null
2015-11-06 20:21:19.617 UTC
40
2017-12-26 08:29:15.457 UTC
2015-11-06 21:26:54.11 UTC
null
1,669,037
null
1,669,037
null
1
53
c#|mysql|entity-framework
60,099
<p>Entity Framework (version 6.1.3) and MySQL Server (>= 5.7.6)</p> <p>One way to resolve the issue is,</p> <pre><code>1. Open Services (services.msc) and restart MySQL57 service. 2. Execute the following commands in MySQL. use &lt;&lt;database name&gt;&gt;; set global optimizer_switch='derived_merge=OFF'; 3. U...
13,729,788
Very large single page application design problems
<p>I am currently writing whats going to be a very, very large single page web/javascript application.</p> <p>Technologies I am using are ASP.NET MVC4, jquery, knockout.js and amplify.js.</p> <p>The problem I am having is that most if not all of the single page application examples are for smaller applications where ...
13,730,376
8
2
null
2012-12-05 18:18:01.157 UTC
10
2017-05-24 22:01:20.937 UTC
2013-06-25 15:40:06.657 UTC
null
825,559
null
825,559
null
1
9
javascript|jquery|asp.net-mvc-4|angularjs|singlepage
16,208
<p>This is actually a very complicated question as it really gets down to the design of your architecture.</p> <p>For large-scale single-page applications, it's best to use some sort of front-end MV* style framework such as <a href="http://backbonejs.org" rel="noreferrer">backbone.js</a>, which ties in to jQuery quite...
13,787,258
PyCrypto install error on Windows
<p>I am trying to install <a href="http://pypi.python.org/pypi/pycrypto/2.6" rel="noreferrer">PyCrypto 2.6</a> Library on my computer. But I keep getting the following error</p> <pre><code>D:\Software\Python\package\pycrypto-2.6&gt;python setup.py build running build running build_py running build_ext warning: GMP or ...
13,787,598
9
3
null
2012-12-09 12:09:12.137 UTC
3
2021-11-03 15:10:17.027 UTC
2017-05-23 11:54:55.323 UTC
null
-1
null
777,593
null
1
16
python|python-3.x|distutils|pycrypto
43,931
<p>I managed to install PyCrypto 2.6 by using the <a href="http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win-amd64-py3.3.exe" rel="noreferrer">prebuilt binary for Python3.3</a> from <a href="http://www.voidspace.org.uk/python/modules.shtml#pycrypto" rel="noreferrer">The Voidspace Python Modules</a>.</p>...
13,556,885
How to change the executable output directory for Win32 builds, in CMake?
<p>My problem is as such : I'm developing a small parser using Visual Studio 2010. I use CMake as a build configuration tool.</p> <p>But I find the default executable building behaviour, inconvenient. What I want is, have my final program be located in :</p> <pre><code>E:/parsec/bin/&lt;exe-name&gt;.&lt;build-type&gt...
13,562,211
2
0
null
2012-11-25 23:51:38.09 UTC
8
2012-11-26 09:47:04.657 UTC
null
null
null
null
683,913
null
1
18
c++|visual-studio|cmake
35,023
<p>There are several options:</p> <ol> <li>Copy the executable after building</li> <li>Customizing the output-directory for your executable(s)</li> </ol> <h2>Copy the executable after building</h2> <p>After a succesful build you can copy the executable (see Beginners answer), but perhaps it is nicer to use an instal...
13,487,625
Overlaying two graphs using ggplot2 in R
<p>I have two graphs and I am trying to overlay one on top of the other:</p> <p>An example of the data frame "ge" looks like this. In actuality there are 10 Genes with 200 samples each, so there are 2000 rows and 3 columns:</p> <pre><code>Exp Gene Sample 903.0 1 1 1060.0 1 2 786.0 1 3 73...
13,488,046
2
0
null
2012-11-21 06:32:13.957 UTC
8
2018-07-02 18:45:56.063 UTC
2012-11-21 07:03:42.82 UTC
null
1,342,339
null
1,342,339
null
1
27
r|graph|ggplot2
98,717
<p>One way is to add the <code>geom_line</code> command for the second plot to the first plot. You need to tell <code>ggplot</code> that this geom is based on a different data set:</p> <pre><code>ggplot(avg, aes(x=Gene, y=mean)) + geom_point() + geom_line() + geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), wid...
13,525,140
How to solve the "TypeError: array.splice is not a function" when 'var array = {}'?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/208105/how-to-remove-a-property-from-a-javascript-object">How to remove a property from a javascript object</a><br> <a href="https://stackoverflow.com/questions/368280/javascript-hashmap-equivalent">JavaScript Ha...
13,525,373
5
9
null
2012-11-23 08:09:11.717 UTC
3
2015-08-03 10:55:42.853 UTC
2017-05-23 12:26:23.81 UTC
null
-1
null
920,796
null
1
40
javascript|jquery|arrays
107,645
<p>First of all, name your variables what they are. The name <code>array</code> you're using, is misleading if you use it to create a object.</p> <pre><code>var myObject = {}; myObject[an_object] = "xyz"; myObject[another_object] = "abc"; </code></pre> <p>Now, you can delete the entry in the object with the <co...
13,648,515
Why doesn't $.each() iterate through every item?
<p>I have the following markup containing 10 <code>pre</code> elements with the class <code>indent</code>:</p> <pre><code>​&lt;pre class="indent"&gt;&lt;/pre&gt; &lt;pre class="indent"&gt;&lt;/pre&gt; &lt;pre class="indent"&gt;&lt;/pre&gt; &lt;pre class="indent"&gt;&lt;/pre&gt; &lt;pre class="indent"&gt;&lt;/pre&gt; &...
13,648,529
3
4
null
2012-11-30 15:50:29.41 UTC
5
2013-09-09 11:51:48.793 UTC
2012-12-03 12:08:55.63 UTC
null
263,525
null
370,103
null
1
54
javascript|iteration|jquery
3,225
<pre><code>$.each(".indent", function(index){ </code></pre> <p>doesn't iterate over the elements of <code>$('.indent')</code> but over the <code>".indent"</code> string whose length is 7 chars.</p> <p>See <a href="http://api.jquery.com/jQuery.each/" rel="noreferrer">reference</a></p> <hr> <p><strong>A more detailed...
13,372,179
Creating a folder when I run file_put_contents()
<p>I have uploaded a lot of images from the website, and need to organize files in a better way. Therefore, I decide to create a folder by months.</p> <pre><code>$month = date('Yd') file_put_contents("upload/promotions/".$month."/".$image, $contents_data); </code></pre> <p>after I tried this one, I get error result....
13,372,192
6
0
null
2012-11-14 02:28:31.53 UTC
13
2022-02-08 15:23:52.043 UTC
2014-12-01 16:37:47.283 UTC
null
2,264,626
null
1,454,031
null
1
78
php
72,864
<p><a href="http://us1.php.net/file_put_contents" rel="noreferrer"><code>file_put_contents()</code></a> does not create the directory structure. Only the file.</p> <p>You will need to add logic to your script to test if the <em>month</em> directory exists. If not, use <a href="http://us1.php.net/mkdir" rel="noreferrer...
24,245,230
'http-server' is not recognized as an internal or external command
<p>After installing angular-seed project, i did the following steps:</p> <p>Cloned the repository : </p> <blockquote> <p>git clone <a href="https://github.com/angular/angular-seed.git">https://github.com/angular/angular-seed.git</a> </p> <p>cd angular-seed</p> </blockquote> <p>Then I ran npm install</p> <p>a...
24,257,994
7
2
null
2014-06-16 13:44:34.807 UTC
6
2021-06-29 04:35:41.8 UTC
null
null
null
null
345,944
null
1
20
node.js|angularjs|npm|angular-seed
55,515
<p>@BenFortune found the answer it was</p> <p>http-server needs to be installed globally with <code>npm install -g http-server</code></p>
23,950,450
Slow scroll speed down
<p>Ok, so I can't find anything about this. </p> <p>I know it is horrible to change the scroll speed of a site, but I need to do this for a site which is more a game than a site. </p> <p>Can someone tell me how to slow down de scrollspeed? Jquery or css?</p> <p>EDIT: I want to change the scrollspeed whem people scro...
23,950,885
4
3
null
2014-05-30 08:45:38.22 UTC
2
2019-12-02 09:31:59.06 UTC
2014-05-30 08:52:29.637 UTC
null
1,737,979
null
1,737,979
null
1
14
jquery|html|css|scroll
57,361
<p><a href="https://nicescroll.areaaperta.com" rel="nofollow noreferrer"><strong>NiceScroll</strong></a> Plugin</p> <p><strong>jQuery</strong></p> <pre><code>$(document).ready(function() { $("html").niceScroll(); } ); </code></pre>
3,391,585
How does an .apk files get signed
<p>This is not a question about how to sign an .apk file. I want to know what does signing actually means and how it is implemented.</p> <p>Inside the .apk file there is META-INF folder and inside that there are two files.</p> <p>First one is CERT.SF contains SHA1 hashes for various components and looks like this:</p...
3,391,855
2
0
null
2010-08-02 20:43:41.73 UTC
10
2012-02-21 20:48:17.287 UTC
null
null
null
null
33,885
null
1
22
android|code-signing
13,484
<p>This actually has nothing to do with Android. APK files are signed using <code>jarsigner</code>. <a href="http://www.manpagez.com/man/1/jarsigner/" rel="nofollow noreferrer">Here is a link to the manpage</a>.</p>
45,416,000
Why is the sum of an int and a float an int?
<p>Consider the following code:</p> <pre><code>float d = 3.14f; int i = 1; auto sum = d + i; </code></pre> <p>According to <a href="http://en.cppreference.com/w/c/language/conversion" rel="noreferrer">cppreference.com</a>, <code>i</code> should be converted to <code>float</code> when it is added to <code>d</code>...
45,416,095
3
8
null
2017-07-31 12:30:06.557 UTC
10
2017-08-10 12:25:57.617 UTC
2017-08-10 12:25:57.617 UTC
null
366,904
null
5,193,248
null
1
46
c++|c|type-conversion
21,052
<p>In C (and C++), <code>3.14f + 1</code> is a <code>float</code> type due to <em>type promotion</em> of <code>int</code> to <code>float</code>.</p> <p><strong>But</strong> in C, up to and including C90, and such a standard may well possibly be your C compiler default, this is assigned to an <code>int</code> type, yie...
9,057,387
Process all arguments except the first one (in a bash script)
<p>I have a simple script where the first argument is reserved for the filename, and all other optional arguments should be passed to other parts of the script.</p> <p>Using Google I found <a href="http://wiki.bash-hackers.org/scripting/posparams#mass_usage">this wiki</a>, but it provided a literal example:</p> <pre>...
9,057,392
5
2
null
2012-01-29 22:31:22.757 UTC
140
2020-06-29 04:35:59.09 UTC
2016-08-23 23:19:16.77 UTC
null
875,915
null
992,005
null
1
588
bash|shell
243,170
<p>Use this:</p> <pre><code>echo "${@:2}" </code></pre> <hr> <p>The following syntax:</p> <pre><code>echo "${*:2}" </code></pre> <p>would work as well, but is not recommended, because as <a href="https://stackoverflow.com/questions/9057387/process-all-arguments-except-the-first-one#comment11369452_9057392">@Gordon...
16,542,118
Phonegap - navigator.app.backHistory() not working on HTML back button
<p>In my app i am using phonegap 2.6.For back button, I am using the following function</p> <pre><code>document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyDown() { alert("hello"); navigator.app.backHistory(); } document.addEventListener('deviceready', onDeviceReady, true); </code...
16,589,826
5
1
null
2013-05-14 11:34:59.74 UTC
8
2022-02-16 16:41:23.13 UTC
2013-05-14 12:13:25.013 UTC
null
1,127,669
null
1,254,796
null
1
17
android|ios|cordova|back-button|back-button-control
28,580
<p>I have tried 3 separate things when I faced the same situation:</p> <ul> <li><p><code>window.history.back()</code></p></li> <li><p><code>navigator.app.backHistory();</code></p></li> <li><p><code>History.go(-1);</code></p></li> </ul> <p>Individually, none of these solve the problem. I put all 3 things together and ...
16,368,937
getDimension()/getDimensionPixelSize() - mutliplier issue
<p>So I have android 2.3.5 device which is NORMAL/HDPI. I have a dimens.xml in my project:</p> <pre><code>... &lt;dimen name="gameresult_congrats_label_msg_textSize"&gt;20sp&lt;/dimen&gt; ... </code></pre> <p>this file is absolutely identical in values-normal/values-hdpi and so on folders. In my first activity ap...
16,369,021
5
1
null
2013-05-03 23:23:16.81 UTC
5
2021-09-17 07:34:33.98 UTC
2014-04-09 14:21:30.83 UTC
null
1,811,719
null
1,811,719
null
1
21
android|textview|dimensions
48,274
<p>Per the <a href="http://developer.android.com/training/multiscreen/screendensities.html">Supporting Different Screen Densities training</a>, hdpi is 1.5x normal (mdpi) sizes. As <code>getDimensionPixelSize</code> takes this difference into account when converting into pixels, the returned value will be 1.5x your val...
16,446,619
How to ignore enum fields in Jackson JSON-to-Object mapping?
<p>I have a JSON Object something like:</p> <pre><code>{"name":"John", "grade":"A"} </code></pre> <p>or</p> <pre><code>{"name":"Mike", "grade":"B"} </code></pre> <p>or</p> <pre><code>{"name":"Simon", "grade":"C"} </code></pre> <p>etc</p> <p>I am trying to map the above JSON to:</p> <pre><code>@JsonIgnorePropert...
16,447,052
5
3
null
2013-05-08 17:20:48.533 UTC
9
2020-10-30 15:22:12.037 UTC
2013-05-08 18:57:21.917 UTC
null
1,522,067
null
1,522,067
null
1
26
java|jackson
31,398
<p>I think you should define external <a href="http://jackson.codehaus.org/1.1.2/javadoc/org/codehaus/jackson/map/JsonDeserializer.html" rel="noreferrer">deserializer</a> for <code>Grade</code> enum.</p> <p>I added additional field to enum - UNKNOWN:</p> <pre><code>enum Grade { A, B, C, UNKNOWN; public stati...
16,047,829
Proxy cannot be cast to CLASS
<p>I'm using Spring for wiring dependencies specifically for DAO classes that use Hibernate, but I'm getting an exception that has me puzzled:</p> <p><strong>$Proxy58 cannot be cast to UserDao</strong></p> <p>My DAO is configured as follows:</p> <pre><code>&lt;bean id="userDao" class="com.domain.app.dao.UserDao"&gt;...
16,047,976
2
1
null
2013-04-16 21:56:10.42 UTC
8
2018-02-01 14:25:13.863 UTC
2013-04-18 21:25:03.32 UTC
null
1,150,982
null
1,150,982
null
1
27
spring|hibernate|casting
32,018
<p>Spring uses <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Proxy.html" rel="noreferrer">JDK dynamic proxies</a> by default (<code>$Proxy58</code> is one of them), that can only proxy interfaces. This means that the dynamically created type <code>$Proxy58</code> will implement one or more of the ...
16,239,819
Performance of Firebase with large data sets
<p>I'm testing firebase for a project that may have a reasonably large numbers of keys, potentially millions.</p> <p>I've tested loading a few 10k of records using node, and the load performance appears good. However the "FORGE" Web UI becomes unusably slow and renders every single record if I expand my root node.</p>...
16,240,601
1
1
null
2013-04-26 15:15:23.137 UTC
41
2014-12-19 15:43:15.01 UTC
2014-12-19 15:43:15.01 UTC
null
52,522
null
1,421,831
null
1
29
firebase
26,696
<p>It's simply the limitations of the Forge UI. It's still fairly rudimentary.</p> <p>The real-time functions in Firebase are not only suited for, but designed for large data sets. The fact that records stream in real-time is perfect for this.</p> <p>Performance is, as with any large data app, only as good as your im...
21,724,337
Signing and Verifying on iOS using RSA
<p>How to sign and verify some data on iOS with an RSA key (preferably using the system own <code>libcommonCrypto</code>)?</p>
21,826,729
2
6
null
2014-02-12 09:53:50.44 UTC
16
2021-01-09 09:45:38.793 UTC
null
null
null
null
1,037,200
null
1
20
ios|rsa|pkcs#7|commoncrypto
14,219
<p>Since there hasn't been nearly any knowledge about signing and verifying found on StackOverflow and the Apple docs, I had to manually browse around in the iOS header files and found <code>SecKeyRawSign</code> and <code>SecKeyRawVerify</code>. The following lines of code seem to work.</p> <hr> <p><strong>Signing NS...
17,358,159
Why use CJSON encode when we have json_encode
<p>I am building an API for a website using Yii. I know that there is a utility class called CJson and has a function called encode.</p> <p>As far as I know there are additional parameters that can be customized in the native json_encode function like the JSON_NUMERIC_CHECK which is really useful. It creates</p> <pre...
17,358,224
4
1
null
2013-06-28 06:00:05.94 UTC
2
2016-02-02 09:12:37.62 UTC
null
null
null
null
923,109
null
1
30
php|json|yii
7,421
<p>Only thing I can think minimum php version support. </p> <p>Yii support php 5.1 as minimum version See <a href="http://www.yiiframework.com/doc/guide/1.1/en/quickstart.installation">Yii Installation Page</a> . While json_encode/json_decode introduced in php 5.2. So It can be a reason for Yii having a library for CJ...