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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,082,062 | how to read a csv file from a url? | <p>Im trying to create a web service which gets to a URL e.g. <code>www.domain.co.uk/prices.csv</code> and then reads the csv file. Is this possible and how? Ideally without downloading the csv file?</p> | 11,082,228 | 5 | 3 | null | 2012-06-18 11:40:53.373 UTC | 4 | 2019-12-30 09:51:41.847 UTC | 2012-06-18 11:50:57.247 UTC | null | 1,181,553 | null | 569,654 | null | 1 | 22 | c#|csv | 40,337 | <p>You could use:</p>
<pre><code>public string GetCSV(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string results = sr.ReadToEnd();
sr.Close();
... |
11,114,625 | Android Canvas Redo and Undo Operation | <p>I am working on a drawing project. My code is working perfectly other than canvas redo and undo operations. My undo operation removes paths from the <code>paths</code> ArrayList and saves to the <code>undonePaths</code> ArrayList, and the redo operation removes the last element from <code>undonePaths</code> and sa... | 11,114,928 | 3 | 0 | null | 2012-06-20 07:17:33.02 UTC | 16 | 2019-04-14 05:48:06.463 UTC | 2019-04-14 05:48:06.463 UTC | null | 1,427,098 | null | 1,269,086 | null | 1 | 24 | android | 21,132 | <p>At first glance I see the following problems:</p>
<ul>
<li>By adding your empty <code>Path</code> to <code>paths</code> as soon as you make it, you're going to have a problem as soon as you undo: you're popping that empty <code>Path</code> first, making the first undo not seem to work. Then if you draw into that <... |
10,969,673 | What is the order of ActiveRecord callbacks and validations? | <p>I was wondering in what order are callbacks and validations called when an ActiveRecord object is created.</p>
<p>Let’s say I have some custom validations & callbacks like the following:</p>
<pre><code>validates :reference_code, :if => :reference_code, :on => :create
before_create :assign_reference
</cod... | 11,021,211 | 3 | 1 | null | 2012-06-10 14:51:51.567 UTC | 25 | 2022-06-01 16:03:20.983 UTC | 2013-01-16 01:33:05.657 UTC | null | 211,563 | null | 395,842 | null | 1 | 58 | ruby-on-rails|ruby-on-rails-3|validation|activerecord | 36,169 | <p>The most-up-to-date version of this list for the latest version of Rails can be found in the <a href="http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html" rel="noreferrer"><code>ActiveRecord::Callbacks</code> documentation</a>. The lists for Rails 4, 3 & 2 are below.</p>
<h2>Rails 4</h2>
<p>The most... |
11,373,536 | Play framework hangs on startup at: "Loading project definition from" | <p>I am just getting started with Play Framework. I have downloaded and installed play and created a sample java application. When I try to start the play console in the application directory it hangs at "Loading project definition".</p>
<pre><code>PS C:\dev\play\javatest> play.bat
Getting org.scala-sbt sbt_2.9.1 0... | 12,605,068 | 3 | 0 | null | 2012-07-07 08:34:52.66 UTC | 13 | 2014-07-24 15:58:58.927 UTC | 2013-09-27 21:27:07.337 UTC | null | 675,552 | null | 230,809 | null | 1 | 61 | playframework | 20,330 | <p>I just experienced this myself with Play 2 and it turns out it wasn't truly hanging, it was just pulling a maven and downloading the Internet. To verify this is the same behavior you were experiencing edit <code>project/plugins.sbt</code> and replace:</p>
<pre><code>logLevel := Level.Warn
</code></pre>
<p>with</p... |
11,406,786 | What is the combinatory logic equivalent of intuitionistic type theory? | <p>I recently completed a university course which featured Haskell and Agda (a dependent typed functional programming language), and was wondering if it was possible to replace lambda calculus in these with combinatory logic. With Haskell this seems possible using the S and K combinators, thus making it point-free. I w... | 11,795,066 | 2 | 1 | null | 2012-07-10 04:47:50.26 UTC | 36 | 2012-08-08 06:13:56.83 UTC | 2012-07-11 08:41:09.457 UTC | null | 759,019 | null | 1,010,494 | null | 1 | 87 | haskell|types|functional-programming|logic|agda | 5,029 | <p>So I thought about it a bit more and made some progress. Here's a first stab at encoding Martin-Löf's delightfully simple (but inconsistent) <code>Set : Set</code> system in a combinatory style. It's not a good way to finish, but it's the easiest place to get started. The syntax of this type theory is just lambda-ca... |
12,894,824 | double and stringstream formatting | <pre><code>double val = 0.1;
std::stringstream ss;
ss << val;
std::string strVal= ss.str();
</code></pre>
<p>In the Visual Studio debugger, <code>val</code> has the value 0.10000000000000001 (because 0.1 can't be represented).
When <code>val</code> is converted using stringstream, <code>strVal</code> is equal to... | 12,895,137 | 4 | 0 | null | 2012-10-15 11:37:28.117 UTC | 2 | 2019-04-02 12:49:20.29 UTC | 2015-05-04 11:46:24.477 UTC | null | 196,312 | null | 619,570 | null | 1 | 17 | c++|double | 47,871 | <p>You can change the floating-point precision of a <code>stringstream</code> as follows:</p>
<pre><code>double num = 2.25149;
std::stringstream ss(stringstream::in | stringstream::out);
ss << std::setprecision(5) << num << endl;
ss << std::setprecision(4) << num << endl;
</code></p... |
12,673,357 | How to get only City, State, Country from lat, long in android | <p>I have the below code to convert lat, long to human readable address. Now iam getting full details including street name. How can i get only city, state, country? I don't want anything more details. Please help me. </p>
<pre><code>Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
try {
Li... | 12,673,476 | 6 | 0 | null | 2012-10-01 12:33:54.793 UTC | 2 | 2018-08-07 12:16:31.757 UTC | 2012-10-01 12:41:52.777 UTC | null | 100,957 | null | 1,670,443 | null | 1 | 21 | android|google-geocoder|street-address | 46,536 | <p>The amount of detail in a reverse geocoded location description may vary, for example one might contain the full street address of the closest building, while another might contain only a city name and postal code. This will return the city name and country name</p>
<pre><code> if (addresses.size() > 0) {
... |
13,091,719 | Converting LastLogon to DateTime format | <p>My objective is to get a list of users from my domain with the following info:</p>
<p>-Display name
-Country
-Manager Name
-Last login date</p>
<p>I am running the following script, and everything looks good except for the LastLogon. It outputs the time into a bunch of random numbers like "129948127853609000". H... | 13,091,821 | 6 | 0 | null | 2012-10-26 17:37:04.817 UTC | 7 | 2022-03-09 18:32:10.043 UTC | 2012-10-26 17:43:37.407 UTC | null | 1,211,933 | null | 1,211,933 | null | 1 | 29 | powershell|active-directory | 269,260 | <p><code>DateTime.FromFileTime</code> should do the trick:</p>
<pre><code>PS C:\> [datetime]::FromFileTime(129948127853609000)
Monday, October 15, 2012 3:13:05 PM
</code></pre>
<p>Then depending on how you want to format it, check out <a href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx" rel="noreferrer... |
13,187,877 | Why can't I update to the latest MongoDB with Homebrew? | <p>I have version 2.0.2 of mongo installed on my mac, which I installed using Homebrew. The course I'm taking is using the 'aggregate' function, which is only available in version 2.2 of Mongo. I tried to do </p>
<pre><code> brew upgrade mongodb
</code></pre>
<p>and I get </p>
<pre><code>Error: mongodb already up... | 13,191,004 | 5 | 1 | null | 2012-11-02 01:10:16.45 UTC | 7 | 2022-08-19 06:23:05.897 UTC | 2015-09-14 11:44:40.023 UTC | null | 304,151 | null | 1,647,484 | null | 1 | 35 | mongodb|homebrew | 26,149 | <p>This command should update your homebrew formulae to their latest version:</p>
<pre><code>brew update
</code></pre>
<p>And then:</p>
<pre><code>brew upgrade mongodb-community
</code></pre>
<p>To install the latest version of mongodb.</p> |
12,663,639 | How to hide databases that I am not allowed to access | <p>When I connect to my <code>Heroku</code> - <code>Postgresql</code> database via <code>pgAdmin3</code>, It lists all the tables (about 2600). Every time I open the pgAdmin3 I have to find my own database.</p>
<p>Is there a way to hide databases that I'm <code>not allowed</code> to access ?</p> | 13,298,802 | 5 | 0 | null | 2012-09-30 18:00:25.153 UTC | 42 | 2021-11-12 11:28:14.493 UTC | 2016-02-10 16:26:06.23 UTC | null | 1,845,432 | null | 1,510,671 | null | 1 | 199 | heroku|pgadmin | 29,411 | <p>Had the same issue, as its a shared space on AWS with 1000 other DBs.</p>
<p><strong>pgAdmin 3</strong></p>
<ol>
<li>Make sure you are disconnected from your server.</li>
<li>Right click your Server -> properties -> Advanced tab.</li>
<li>In 'DB restriction' type in the name of your database(s) <strong>enclose... |
17,078,151 | Submit a form using <a> anchor element, without javascript | <p>How to replace the submit button with a link without using javascript ? is there any way to add the submit attribute to a link ? because the form will not be sent by a simple link without "submit".</p>
<pre><code><form:form action="/getPage" >
<div class="buttons">
<a class="link" href... | 17,078,212 | 4 | 3 | null | 2013-06-13 02:11:20.453 UTC | 2 | 2018-08-10 18:31:27.387 UTC | 2013-06-13 02:26:38.607 UTC | null | 1,166,285 | null | 2,337,243 | null | 1 | 14 | html|forms | 51,110 | <p>Try this:</p>
<p><strong>CSS</strong> </p>
<pre><code>button {
background:none!important;
border:none;
padding:0!important;
/*border is optional*/
border-bottom:1px solid #444;
}
</code></pre>
<p><strong>HTML</strong></p>
<pre><code><button>your button that looks like a link</butto... |
16,907,825 | How to implement sublime text like fuzzy search? | <p>How can i implement a sublime-like fuzzy search on select2?</p>
<p>Example, typing "sta jav sub" would match "Stackoverflow javascript sublime like"</p> | 16,907,844 | 7 | 0 | null | 2013-06-04 00:10:05.33 UTC | 9 | 2018-11-26 13:25:20.89 UTC | 2013-06-04 00:15:46.167 UTC | null | 23,020 | null | 23,020 | null | 1 | 28 | javascript|jquery-select2 | 9,029 | <p>select2 allows you to implement your own "matcher" functions (<a href="http://ivaynberg.github.io/select2" rel="noreferrer">as seen on their docs</a>), using that and some regexp you can do something like:</p>
<pre><code>$("#element").select2({
matcher: function(term, text, opt) {
//We call to uppercase... |
17,108,122 | _.isFunction(a) vs. typeof a === 'function'? javascript | <p>I think it might be only performance case - <a href="http://jsperf.com/comparing-underscore-js-isfunction-with-typeof-function/2">http://jsperf.com/comparing-underscore-js-isfunction-with-typeof-function/2</a></p>
<p>And seems that <code>typeof</code> is faster.. so my question is - which is more appropriate to use... | 17,108,198 | 2 | 1 | null | 2013-06-14 12:06:17.543 UTC | 7 | 2013-06-14 12:17:48.18 UTC | null | null | null | null | 2,117,550 | null | 1 | 53 | javascript|performance|underscore.js|typeof | 61,331 | <p>There is no reason not to use <code>typeof</code>.</p>
<p>Not only is it faster but the <a href="http://es5.github.io/#x11.4.3">ECMAScript specification</a> ensures that all functions have a type of "function" and that only functions can have a type of "function" :</p>
<p><img src="https://i.stack.imgur.com/9AUle.... |
4,293,026 | CoreData Edit/Overwrite Object | <p>I am playing around with a new project, a split view iPad app using <strong>Core Data</strong>, and I was wondering, as its fairly clear how to add and remove an item. If I was to say alter this to hold text, then that text be shown in a <code>UITextView</code>, how can I edit or overwrite an object in <strong>CoreD... | 4,293,065 | 2 | 0 | null | 2010-11-27 17:47:50.637 UTC | 11 | 2013-11-22 20:57:21.377 UTC | 2013-11-22 20:57:21.377 UTC | null | 2,888,113 | null | 427,292 | null | 1 | 17 | objective-c|ipad|core-data|uitextview|uisplitviewcontroller | 18,350 | <p>You simply request the existing object using an <code>NSFetchRequest</code>, change whatever fields need to be updated (a simple myObject.propertyName setter is all that's required), and then perform a <strong>save</strong> action on the data context.</p>
<p><strong>EDIT</strong> to add code example. I agree with M... |
41,272,168 | compare text inside 2 div elements using javascript or jquery | <p>I have following 2 div tags</p>
<pre><code><div class="one">
+
+++
+
</div>
</code></pre>
<p>second div tag</p>
<pre><code><div class="two">
+ + ++++ + ++ + + +
+ ++ +++ + +++ ++ + +++
+ ++ + + ++ + + + + ++
</div>
</code></pre>
<p>Now what I want to find if <c... | 41,308,741 | 13 | 6 | null | 2016-12-21 21:28:25.22 UTC | 9 | 2017-04-25 10:10:10.263 UTC | 2016-12-21 21:49:45.81 UTC | null | 1,136,062 | null | 1,136,062 | null | 1 | 38 | javascript|jquery|html | 2,705 | <p><strong>Part 1:</strong></p>
<p>To see how the data would match, you may want to try turning this into letters, instead of pluses.</p>
<pre><code><div class="one">
g
tuv
J
</div>
<div class="two">
a b cdef g hi j k l
m no pqr s tuv wx y zAB
C DE F G HI J K L M NO
<... |
9,790,924 | Excel VBA, How to select rows based on data in a column? | <pre><code>Sub SelectAllReleventText()
Do While Range(“A1”).Offset(1, 6) <> Empty
Rows(ActiveCell.Row).Select
ActiveCell.Offset(1, 0).Select
Loop
End Sub
</code></pre>
<p>Here is my script, I've been told it doesn't do what it is meant to, which I expected since this was my first attempt. I am coming up with a v... | 9,791,133 | 2 | 1 | null | 2012-03-20 16:31:54.073 UTC | null | 2016-01-28 16:20:32.77 UTC | 2018-07-09 19:34:03.733 UTC | null | -1 | null | 1,048,319 | null | 1 | 5 | excel|vba | 114,958 | <p>Yes using <code>Option Explicit</code> is a good habit. Using <code>.Select</code> however is not :) it reduces the speed of the code. Also fully justify sheet names else the code will always run for the <code>Activesheet</code> which might not be what you actually wanted.</p>
<p>Is this what you are trying?</p>
<... |
10,021,892 | How to renew/extend facebook access tokens with PHP? | <p>Facebook has removed the offline_access token functionality, now tokens have to be renewed whenever the user visits your website to keep them active.</p>
<p>Say someone has already given your website access and you have a token stored for them. What code would you use with Facebook's PHP library to renew that token... | 10,060,245 | 4 | 17 | null | 2012-04-05 02:28:15.133 UTC | 9 | 2015-04-22 05:42:28.663 UTC | null | null | null | null | 49,153 | null | 1 | 12 | php|facebook | 14,537 | <p>You can extend your token the following way:</p>
<p>Original scenario</p>
<ul>
<li>Your app requests permissions from the user</li>
<li>You prompt user to log in / grant permissions</li>
<li>You get user's token (short-lived one) and exchange via CURL or other means for a 60 day one using grant_type=fb_exchange_to... |
10,192,663 | Why can't I use record selectors with an existentially quantified type? | <p>When using Existential types, we have to use a pattern-matching syntax for extracting the <code>forall</code>ed value. We can't use the ordinary record selectors as functions. GHC reports an error and suggest using pattern-matching with this definition of <code>yALL</code>:</p>
<pre><code>{-# LANGUAGE ExistentialQu... | 10,192,884 | 2 | 4 | null | 2012-04-17 13:56:44.643 UTC | 6 | 2014-11-30 06:14:00.623 UTC | 2014-11-30 06:14:00.623 UTC | null | 1,186,208 | null | 683,727 | null | 1 | 31 | haskell|record|existential-type | 3,048 | <p>You can use record syntax in pattern matching,</p>
<pre><code>func1 BigData{ someField = elemx } = func2 elemx
</code></pre>
<p>works and is much less typing for huge types.</p> |
10,202,456 | How to create a JPA query with LEFT OUTER JOIN | <p>I am starting to learn JPA, and have implemented an example with JPA query, based on the following native SQL that I tested in SQL Server:</p>
<pre><code>SELECT f.StudentID, f.Name, f.Age, f.Class1, f.Class2
FROM Student f
LEFT OUTER JOIN ClassTbl s ON s.ClassID = f.Class1 OR s.ClassID = f.Class2
WHERE s.Clas... | 10,202,914 | 4 | 1 | null | 2012-04-18 03:40:58.67 UTC | 4 | 2021-08-16 20:07:00.23 UTC | 2017-03-21 12:18:48.66 UTC | null | 4,823,977 | null | 2,351,597 | null | 1 | 33 | java|jpa|jpql | 144,999 | <p>Write this;</p>
<pre><code> SELECT f from Student f LEFT JOIN f.classTbls s WHERE s.ClassName = 'abc'
</code></pre>
<p>Because your Student entity has One To Many relationship with ClassTbl entity.</p> |
11,703,124 | Plugin not found in plugin repository - How fix an issue when my company Nexus is down? | <p>I am trying to buld <code>Hadoop</code> locally and when I do</p>
<pre><code>$ mvn -U clean install -Pdist -Dtar -Ptest-patch
</code></pre>
<p>as mentioned - <a href="http://wiki.apache.org/hadoop/HowToSetupYourDevelopmentEnvironment" rel="noreferrer">http://wiki.apache.org/hadoop/HowToSetupYourDevelopmentEnviron... | 11,703,397 | 2 | 0 | null | 2012-07-28 17:19:04.273 UTC | 1 | 2016-12-21 08:21:45.44 UTC | 2012-07-29 06:42:54.523 UTC | null | 379,235 | null | 379,235 | null | 1 | 7 | java|maven|hadoop|nexus | 58,422 | <p>If you have access to internet, simply declare a new maven repository (in you pom, or in you settings.xml) : </p>
<pre class="lang-xml prettyprint-override"><code> <repositories>
<repository>
<id>your-internal-repo</id>
<url>http://beefy.myorg.local:8081/nexus/content/... |
11,538,875 | How to download all subtitles from Opensubtitles.org in a specific language? | <p>Excuse me if this post is not related to this forum, but I couldn't find any other place to ask my question. It would be appreciated if you introduce me a suitable place for this post.
By the way, I am trying to download all the subtitles from Opensubtitles.org in a specific language (say English) and find their tra... | 11,539,639 | 2 | 0 | null | 2012-07-18 10:01:49.213 UTC | 9 | 2012-11-29 12:51:38.793 UTC | null | null | null | null | 1,265,960 | null | 1 | 16 | linux|wget | 31,736 | <p>The download link is something like:</p>
<pre><code>http://dl.opensubtitles.org/en/download/sub/4617044
</code></pre>
<p>Where 4617044 is the ID of the subtitle. You can use this URL with wget to download it, but it won't have the correct filename.</p>
<p>Alternatively, you can use the <a href="http://trac.opensu... |
11,609,532 | Breaking the nested loop | <p>I'm having problem with nested loop. I have multiple number of posts, and each post has multiple number of images. </p>
<p>I want to get total of 5 images from all posts. So I am using nested loop to get the images, and want to break the loop when the number reaches to 5. The following code will return the images, ... | 11,609,551 | 2 | 2 | null | 2012-07-23 09:12:32.963 UTC | 7 | 2019-12-27 15:40:57.373 UTC | 2019-12-27 15:40:57.373 UTC | null | 293,099 | null | 1,355,300 | null | 1 | 80 | php|loops|nested-loops | 56,076 | <p>Unlike other languages such as C/C++, in PHP you can use the optional param of break like this:</p>
<pre><code>break 2;
</code></pre>
<p>In this case if you have two loops such that:</p>
<pre><code>while(...) {
while(...) {
// do
// something
break 2; // skip both
}
}
</code></pre>
<p><c... |
3,251,600 | How do I get first name and last name as whole name in a MYSQL query? | <p>I want to be able to do something like this</p>
<pre><code>SELECT `first_name` + " " + `last_name` as `whole_name` FROM `users`
</code></pre>
<p>So basically I get one column back <code>whole_name</code> which is <code>first_name</code> and <code>last_name</code> concatenated together with a <code></code> (space)... | 3,251,610 | 4 | 0 | null | 2010-07-15 00:24:45.463 UTC | 11 | 2020-03-06 13:57:05.637 UTC | 2013-06-01 12:25:26.39 UTC | null | 31,671 | null | 31,671 | null | 1 | 24 | sql|mysql | 134,178 | <p><a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws</a></p>
<pre><code>SELECT CONCAT_WS(" ", `first_name`, `last_name`) AS `whole_name` FROM `users`
</code></pre> |
4,018,851 | final and static in Java | <p>I have read this sentence in a book but I didn't understand it:</p>
<blockquote>
<p>A field that is both static and final has only one piece of storage that cannot be changed.</p>
</blockquote>
<p>Can anyone explain it for me?</p> | 4,018,987 | 4 | 1 | null | 2010-10-25 21:04:54.897 UTC | 8 | 2021-01-01 21:56:42.293 UTC | 2021-01-01 21:56:42.293 UTC | null | 213,269 | null | 367,018 | null | 1 | 25 | java | 42,746 | <p>The source of your confusion may be that the word "static" in english and it's meaning in Java are only loosely related.</p>
<p>A variable defined in a class Cat in the "normal" way can be referred to as an instance variable.</p>
<pre><code>class Cat {
int weight;
}
</code></pre>
<p>Each time you create a new ... |
3,316,431 | How do I set Layout and Text size to DP inside program? | <p>Basically I have this inside XML, but I have to recreate it inside a code. How do I do it?</p>
<pre><code><EditText
android:layout_width="140dp"
android:layout_height="20dp"
android:background="@drawable/input_bg01"
android:textSize="10dp"
android:gravity="center"
... | 5,032,267 | 4 | 2 | null | 2010-07-23 08:13:56.933 UTC | 10 | 2021-03-28 01:43:08.227 UTC | null | null | null | null | 271,736 | null | 1 | 40 | java|android|layout | 53,180 | <p>Solved <a href="https://stackoverflow.com/questions/5012840/android-specifying-pixel-units-like-sp-px-dp-without-using-xml/5012893#5012893">here</a>.</p>
<p>Extract:</p>
<pre><code>DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
float dp = 20f;
float fpixels = metrics.density * dp;
int pi... |
3,490,216 | HTML/CSS - Adding an Icon to a button | <p>I making some css buttons and I want to add an icon before the text, "Button Text". </p>
<p>But I dont know how I should do this...</p>
<p>HTML
<code><div class="btn btn_red"><a href="#">Crimson</a><span></span></div></code></p>
<p>CSS</p>
<pre><code>body {
margin: 0;
... | 3,490,236 | 5 | 0 | null | 2010-08-16 02:18:21.957 UTC | 2 | 2022-07-19 15:02:43.383 UTC | null | null | null | null | 377,419 | null | 1 | 19 | html|css | 205,116 | <p>You could add a span before the link with a specific class like so:</p>
<pre><code><div class="btn btn_red"><span class="icon"></span><a href="#">Crimson</a><span></span></div>
</code></pre>
<p>And then give that a specific width and a background image just like you ... |
3,734,829 | DateTime field and Html.TextBoxFor() helper. How to use it correctly? | <p>I have a DateTime field in my Model. If I try to use this field in a strong typed partial view this way</p>
<pre><code><%= Html.TextBoxFor(model => model.DataUdienza.ToString("dd/MM/yyyy"), new { style = "width: 120px" }) %>
</code></pre>
<p>I will get the following compilation error at runtime</p>
<pre... | 3,735,801 | 5 | 0 | null | 2010-09-17 11:19:34.353 UTC | 7 | 2013-09-10 19:35:38.737 UTC | 2010-09-17 11:32:13.81 UTC | null | 431,537 | null | 431,537 | null | 1 | 21 | asp.net-mvc|html-helper | 58,360 | <p>Create an editor template called DateTime.ascx</p>
<pre><code><%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>
<%=Html.TextBox("", (Model.HasValue ? Model.Value.ToString("MM/dd/yyyy") : string.Empty), ViewData) %>
</code></pre>
<p>Put it in your Views/Share... |
3,424,860 | What characters are allowed in the HTML Name attribute inside input tag? | <p>I have a PHP script that will generate <code><input></code>s dynamically, so I was wondering if I needed to filter any characters in the <code>name</code> attribute.</p>
<p><s>I know that the name has to start with a letter, but</s> I don't know any other rules. I figure square brackets must be allowed, since... | 3,424,964 | 5 | 0 | null | 2010-08-06 14:43:19.613 UTC | 9 | 2017-03-19 20:05:39.63 UTC | 2015-02-01 16:28:47.123 UTC | null | 3,204,551 | null | 119,853 | null | 1 | 93 | html|forms|web-standards|html-input | 51,276 | <p>The only real restriction on what characters can appear in form control names is when a form is submitted with GET</p>
<p>"The "get" method restricts form data set values to ASCII characters." <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1" rel="noreferrer">reference</a></p>
<p>There's a good ... |
3,426,843 | What is the default initialization of an array in Java? | <p>So I'm declaring and initializing an int array:</p>
<pre><code>static final int UN = 0;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
arr[i] = UN;
}
</code></pre>
<p>Say I do this instead... </p>
<pre><code>int[] arr = new int[5];
System.out.println(arr[0]);
</code></pre>
<p>... <code>0</cod... | 3,426,854 | 8 | 2 | null | 2010-08-06 18:58:42.593 UTC | 57 | 2021-11-08 09:24:47.55 UTC | null | null | null | null | 196,921 | null | 1 | 167 | java|arrays|initialization | 331,104 | <p>Everything in a Java program not explicitly set to something by the programmer, is initialized to a zero value. </p>
<ul>
<li>For references (anything that holds an object) that is <code>null</code>.</li>
<li>For int/short/byte/long that is a <code>0</code>.</li>
<li>For float/double that is a <code>0.0</code></li... |
3,442,333 | PHP REGEX: Get domain from URL | <p><strong>What I want</strong></p>
<hr>
<p>I want to get from a <code>URL</code> the <code>domain</code> part so from <code>http://example.com/</code> -> <code>example.com</code></p>
<p><strong>Examples:</strong></p>
<hr>
<pre><code>+----------------------------------------------+-----------------------+
| input ... | 3,442,365 | 9 | 1 | null | 2010-08-09 17:00:23.483 UTC | 9 | 2019-07-27 05:36:51.227 UTC | null | null | null | null | 380,562 | null | 1 | 24 | php|regex|url|dns | 32,640 | <p>There's no need to use a regex for this. PHP has an inbuilt function to do just this. Use <a href="http://php.net/manual/en/function.parse-url.php" rel="noreferrer"><code>parse_url()</code></a>:</p>
<pre><code>$domain = parse_url($url, PHP_URL_HOST);
</code></pre> |
3,698,200 | window.onload vs $(document).ready() | <p>What are the differences between JavaScript's <a href="https://developer.mozilla.org/en/docs/Web/API/GlobalEventHandlers/onload" rel="noreferrer"><code>window.onload</code></a> and jQuery's <a href="https://learn.jquery.com/using-jquery-core/document-ready/" rel="noreferrer"><code>$(document).ready()</code></a> meth... | 3,698,214 | 17 | 4 | null | 2010-09-13 06:24:52.57 UTC | 397 | 2022-08-30 15:30:17.03 UTC | 2020-06-26 08:52:47.05 UTC | null | 4,194,079 | null | 197,878 | null | 1 | 1,352 | javascript|jquery|dom-events|unobtrusive-javascript | 1,091,221 | <p>The <code>ready</code> event occurs after the HTML document has been loaded, while the <code>onload</code> event occurs later, when all content (e.g. images) also has been loaded.</p>
<p>The <code>onload</code> event is a standard event in the DOM, while the <code>ready</code> event is specific to jQuery. The purpo... |
3,437,897 | How do I get a class instance of generic type T? | <p>I have a generics class, <code>Foo<T></code>. In a method of <code>Foo</code>, I want to get the class instance of type <code>T</code>, but I just can't call <code>T.class</code>.</p>
<p>What is the preferred way to get around it using <code>T.class</code>?</p> | 3,437,930 | 23 | 6 | null | 2010-08-09 06:58:45.707 UTC | 253 | 2022-08-21 08:06:40.143 UTC | 2020-03-18 12:47:51.213 UTC | null | 1,898,563 | null | 448,452 | null | 1 | 837 | java|generics | 894,807 | <p>The short answer is, that there is no way to find out the runtime type of generic type parameters in Java. I suggest reading the chapter about type erasure in the <a href="http://download.oracle.com/javase/tutorial/java/generics/erasure.html" rel="noreferrer">Java Tutorial</a> for more details.</p>
<p>A popular sol... |
8,186,133 | Faster ways to calculate frequencies and cast from long to wide | <p>I am trying to obtain counts of each combination of levels of two variables, "week" and "id". I'd like the result to have "id" as rows, and "week" as columns, and the counts as the values.</p>
<p>Example of what I've tried so far (tried a bunch of other things, including adding a dummy variable = 1 and then <code>f... | 8,186,229 | 4 | 0 | null | 2011-11-18 17:07:18.103 UTC | 8 | 2022-02-02 02:28:41.53 UTC | 2018-10-06 10:11:54.16 UTC | null | 1,851,712 | null | 592,419 | null | 1 | 17 | r|aggregate|plyr|reshape2 | 4,560 | <p>You don't need <code>ddply</code> for this. The <code>dcast</code> from <code>reshape2</code> is sufficient:</p>
<pre><code>dat <- data.frame(
id = c(rep(1, 4), 2),
week = c(1:3, 1, 3)
)
library(reshape2)
dcast(dat, id~week, fun.aggregate=length)
id 1 2 3
1 1 2 1 1
2 2 0 0 1
</code></pre>
<hr>
<... |
7,802,014 | Remove Commas with Jquery | <p>I am in need of some code that removes commas from a string.
I currently have a variety of numbers in the number_format() for PHP.
I use Jquery to post certain things to a update page and I need the commas removed from a class.</p>
<p>for instance here is some code.</p>
<pre><code><span class="money">1,234,5... | 7,802,018 | 6 | 0 | null | 2011-10-18 03:16:31.74 UTC | 3 | 2018-11-27 17:55:55.833 UTC | null | null | null | null | 917,117 | null | 1 | 18 | php|jquery | 42,076 | <p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace" rel="noreferrer">replace</a></p>
<pre><code>var noCommas = $('.money').text().replace(/,/g, ''),
asANumber = +noCommas;
</code></pre> |
7,961,721 | How do I install a custom font on an HTML site | <p>I am not using flash or php - and I have been asked to add a custom font to a simple HTML layout. "KG June Bug"</p>
<p>I have it downloaded locally - is there a simple CSS trick to accomplish this?</p> | 7,961,750 | 6 | 1 | null | 2011-11-01 01:53:38.007 UTC | 57 | 2022-04-11 22:04:00.067 UTC | 2022-04-11 22:04:00.067 UTC | null | 1,946,501 | null | 411,472 | null | 1 | 184 | html|css|fonts|webfonts|custom-font | 501,362 | <p>Yes, you can use the CSS feature named @font-face.
It has only been officially approved in CSS3, but been proposed and implemented in CSS2 and has been supported in IE for quite a long time.</p>
<p>You declare it in the CSS like this:</p>
<pre><code> @font-face { font-family: Delicious; src: url('Delicious-Roman.o... |
8,158,516 | Invalid conversion from "const char*" to "char" error | <p>I wanted to post this because I was not really sure what issue I was having with a simple assignment statement. I am doing a homework assignment that asks me to write structs and functions in a simple program to draw out shapes of ASCII characters. Right now I am just trying to test the functions I have written, a... | 8,158,537 | 7 | 6 | null | 2011-11-16 20:53:06.437 UTC | null | 2014-12-29 19:27:34.263 UTC | 2011-11-16 20:57:16.3 UTC | null | 427,309 | null | 895,387 | null | 1 | 18 | c++ | 83,628 | <p>You should be using single quotes for characters. Double quotes means you're using a (potentially single-character) string literal, which is represented as a <code>const char *</code> (pointer to constant character).</p>
<p>Correct syntax: <code>circle1.symbol = '*';</code></p> |
8,287,949 | Android How to draw a smooth line following your finger | <p><a href="http://marakana.com/tutorials/android/2d-graphics-example.html">http://marakana.com/tutorials/android/2d-graphics-example.html</a></p>
<p>I am using this example below. But when I move my fingers too fast across the screen the line turns to individual dots.</p>
<p>I am not sure whether I can speed up the ... | 8,289,516 | 11 | 4 | null | 2011-11-27 18:31:30.057 UTC | 78 | 2021-06-22 02:41:00.67 UTC | 2011-11-27 19:49:14.863 UTC | null | 211,160 | null | 614,460 | null | 1 | 72 | java|android|touch|interpolation|curve-fitting | 94,816 | <p>An easy solution, as you mentioned, is to simply connect the points with a straight line. Here's the code to do so:</p>
<pre><code>public void onDraw(Canvas canvas) {
Path path = new Path();
boolean first = true;
for(Point point : points){
if(first){
first = false;
path.... |
8,074,368 | CodeIgniter PHP Model Access "Unable to locate the model you have specified" | <p>I have been trying to load some models for this website I am building. However, for an unknown reason, it will bring the following error :</p>
<pre><code>An Error Was Encountered
Unable to locate the model you have specified: logon_model
</code></pre>
<p>Now , I have done my research. The problem would be that IC... | 8,077,427 | 16 | 3 | null | 2011-11-10 02:38:46.42 UTC | 13 | 2020-01-14 08:07:36.68 UTC | 2019-08-16 12:14:22.157 UTC | null | 315,550 | null | 1,038,763 | null | 1 | 42 | php|model|codeigniter-2 | 175,011 | <p>When creating models, you need to place the file in <code>application/models/</code> and name the file in all lowercase - like <code>logon_model.php</code></p>
<p>The <code>logon_model.php</code> should contain the following:</p>
<pre><code><?php if ( ! defined('BASEPATH')) exit('No direct script access allowe... |
4,696,041 | Using the "With Clause" SQL Server 2008 | <p>Can someone show me a sample SQL server script that I can look at that uses the <strong>"With Clause"</strong>? </p>
<p>I am trying to use this clause to iterate through 200 databases that contain the same table that I am trying to run a query on. I am trying to avoid using a cursor because the query time takes t... | 4,707,985 | 3 | 2 | null | 2011-01-14 21:16:33.203 UTC | 6 | 2011-01-16 21:09:22.737 UTC | null | null | null | null | 2,012,590 | null | 1 | 24 | sql-server-2008|sql-server-2008-r2 | 133,852 | <p>Just a poke, but here's another way to write FizzBuzz :)
100 rows is enough to show the WITH statement, I reckon.</p>
<pre><code>;WITH t100 AS (
SELECT n=number
FROM master..spt_values
WHERE type='P' and number between 1 and 100
)
SELECT
ISNULL(NULLIF(
CASE WHEN n % 3 = 0 THEN 'Fizz' Els... |
4,141,324 | Function caller in linux kernel | <p>Is there a way to get function caller in linux kernel? I know <strong>__<em>func</em>__</strong> returns the function name which is executing. I am looking for the function which called "<strong>__<em>func</em>__</strong>"</p> | 4,145,666 | 4 | 1 | null | 2010-11-10 04:50:20.09 UTC | 21 | 2015-09-30 10:27:25.627 UTC | null | null | null | null | 73,216 | null | 1 | 20 | linux-kernel|linux-device-driver|embedded-linux|kernel|kernel-mode | 17,767 | <p>You can get the caller with <code>__builtin_return_address(0)</code>.</p>
<p>The caller's caller is <code>__builtin_return_address(1)</code> and so on.</p>
<p>It's a GCC extension, documented in the gcc manual: <a href="http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html">http://gcc.gnu.org/onlinedocs/gcc/Return... |
4,050,798 | GitHub: Is it possible to collaborate with someone on a private gist? | <p>I have a private gist. If I send the URL to a friend he can view it, but cannot edit it, unless he forks it.</p>
<p>Is there a way to edit it directly without forking it?</p> | 4,051,606 | 4 | 1 | null | 2010-10-29 09:56:59.31 UTC | 8 | 2020-01-16 07:08:45.08 UTC | null | null | null | null | 184,367 | null | 1 | 48 | git|github | 19,004 | <p>2010: I am not sure it is possible.<br>
To make a gist public (which is not what you want, but illustrates the lack of management features around gist), the <a href="http://groups.google.com/group/github/browse_thread/thread/199f8312fa7f8036" rel="nofollow noreferrer">only solution was to re-post it</a>.</p>
<p>The... |
4,113,307 | Pythonic way to select list elements with different probability | <pre><code>import random
pos = ["A", "B", "C"]
x = random.choice["A", "B", "C"]
</code></pre>
<p>This code gives me either "A", "B" or "C" with equal probability.
Is there a nice way to express it when you want "A" with 30%, "B" with 40% and "C" with 30% probability?</p> | 4,113,516 | 6 | 3 | null | 2010-11-06 13:39:46.597 UTC | 20 | 2022-04-07 13:58:16.373 UTC | null | null | null | null | 25,282 | null | 1 | 45 | python | 57,938 | <p>Weights define a probability distribution function (pdf). Random numbers from any such pdf can be generated by <a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator#Non-uniform_generators" rel="noreferrer">applying its associated inverse cumulative distribution function</a> to uniform random numbers be... |
4,081,100 | C: finding the number of elements in an array[] | <p>In C:
How do you find the number of elements in an array of structs, after sending it to a function?</p>
<pre><code>int main(void) {
myStruct array[] = { struct1, struct2, struct3, struct4, struct5, struct6 };
printf("%d\n", sizeof(array));
printf("%d\n", sizeof(array[0]));
f(array);
}
void f(myStruct* arra... | 4,081,132 | 12 | 1 | null | 2010-11-02 18:50:31.267 UTC | 3 | 2021-06-28 06:50:52.407 UTC | null | null | null | null | 483,647 | null | 1 | 15 | c|arrays|pointers | 49,014 | <p>You can't.</p>
<p>You have to pass the size to the function, eg:</p>
<pre><code>void f(myStruct* array, size_t siz);
</code></pre>
<p>Also notice that in <code>f</code> array is a pointer, while in <code>main</code> it is an array. Arrays and pointers are different things.</p> |
4,585,929 | How to use 'cp' command to exclude a specific directory? | <p>I want to copy all files in a directory except some files in a specific sub-directory.
I have noticed that <code>cp</code> command didn't have the <code>--exclude</code> option.
So, how can I achieve this?</p> | 14,789,400 | 20 | 4 | null | 2011-01-03 15:53:52.997 UTC | 196 | 2022-05-04 17:23:38.183 UTC | 2022-01-13 00:00:51.253 UTC | null | 8,172,439 | null | 554,241 | null | 1 | 612 | linux|bash|terminal|command|cp | 603,249 | <p><code>rsync</code> is fast and easy:</p>
<pre><code>rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude
</code></pre>
<p>You can use <code>--exclude</code> multiples times.</p>
<pre><code>rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude another... |
14,801,955 | PHP file_get_contents returning false | <p>Maybe I've been sat here too long staring at this but WHY would <code>file_get_contents</code> return <code>false</code> here? I've cut and paste the URL and it works fine?</p>
<pre><code>$url = "http://jobs.github.com/positions.json?search=" . $as_any . "&location=" . $location;
// URL... | 14,802,259 | 5 | 2 | null | 2013-02-10 19:56:07.413 UTC | 2 | 2021-05-07 12:09:46.47 UTC | 2020-11-29 10:50:20.1 UTC | null | 6,089,612 | null | 1,175,948 | null | 1 | 25 | php|json | 54,179 | <p>Try this:</p>
<pre><code>$query = http_build_query(array('search'=>$as_any, 'location'=>$location));
$url = "http://jobs.github.com/positions.json?" . $query;
</code></pre>
<p>The problem is that you weren't URL-encoding the search term, which contains a space. The request was returning a 400 error from the ... |
14,689,237 | What is a "Manager" in django? | <p>I have read the definition in the official Django <a href="https://docs.djangoproject.com/en/dev/topics/db/managers/" rel="noreferrer">documentation</a>, and I am still confused by what a <code>Manager</code> does.</p>
<p>The documentation says that they allow you to operate on database tables/models, but I still do... | 14,689,377 | 3 | 1 | null | 2013-02-04 14:49:42.343 UTC | 11 | 2021-11-29 21:52:59.623 UTC | 2020-07-25 22:32:05.49 UTC | null | 3,705,840 | null | 1,555,306 | null | 1 | 28 | python|django | 13,075 | <p>A manager is usually something hidden away from django programmers that django uses to interface between <code>model</code> code and the database backend. </p>
<p>When you query the django ORM, you do so through calls to </p>
<pre><code>from my_app.models import MyModel
mms = MyModel.objects.all()
</code></pre>
... |
14,786,179 | How to convert a 1 channel image into a 3 channel with opencv2? | <p>I'm really stumped on this one. I have an image that was <em>[BGR2GRAY]'d</em> earlier in my code, and now I need to add colored circles and such to it. Of course this can't be done in a 1 channel matrix, and I can't seem to turn the damned thing back into 3.</p>
<p><code>numpy.dstack()</code> crashes everything</p>... | 14,786,995 | 6 | 0 | null | 2013-02-09 08:10:18.807 UTC | 4 | 2022-09-12 18:26:38.527 UTC | 2021-05-21 22:30:27.97 UTC | null | 15,527,965 | null | 945,762 | null | 1 | 30 | python|arrays|opencv | 50,313 | <p>Here's a way of doing that in Python:</p>
<pre><code>img = cv2.imread("D:\\img.jpg")
gray = cv2.cvtColor(img, cv.CV_BGR2GRAY)
img2 = np.zeros_like(img)
img2[:,:,0] = gray
img2[:,:,1] = gray
img2[:,:,2] = gray
cv2.circle(img2, (10,10), 5, (255,255,0))
cv2.imshow("colour again", img2)
cv2.waitKey()
</code></pre>
<... |
14,390,945 | suppress Scrapy Item printed in logs after pipeline | <p>I have a scrapy project where the item that ultimately enters my pipeline is relatively large and stores lots of metadata and content. Everything is working properly in my spider and pipelines. The logs, however, are printing out the entire scrapy Item as it leaves the pipeline (I believe):</p>
<pre><code>2013-01-1... | 16,303,725 | 9 | 0 | null | 2013-01-18 01:06:38.487 UTC | 9 | 2022-06-07 13:23:06.64 UTC | null | null | null | null | 564,709 | null | 1 | 30 | python|scrapy | 11,444 | <p>Another approach is to override the <code>__repr__</code> method of the <code>Item</code> subclasses to selectively choose which attributes (if any) to print at the end of the pipeline:</p>
<pre><code>from scrapy.item import Item, Field
class MyItem(Item):
attr1 = Field()
attr2 = Field()
# ...
attrN... |
14,890,402 | Instruments Allocations track alloc and dealloc of objects of user defined classes | <p>Is it possible to track the allocation and deallocation of my Objective-C objects? For instance if I have a class Book, I want to track all the allocations and deallocations of the objects of Book type. I can track all the default SKD classes, such as UIViewController, UIWindow, UIView, NSDictionary and all that, bu... | 14,891,837 | 1 | 0 | null | 2013-02-15 08:01:38.68 UTC | 56 | 2017-10-09 18:16:59.483 UTC | 2013-04-01 15:36:54.783 UTC | null | 644,348 | null | 1,225,334 | null | 1 | 61 | ios|objective-c|xcode|instruments | 20,810 | <p>You can use the Allocations instrument to track the lifecycle of your objects. If you use the “Allocations” template, it is configured to record <code>malloc</code> and <code>free</code> events. You may want to configure it to also record <code>retain</code>, <code>release</code>, and <code>autorelease</code> even... |
14,847,457 | How do I find the length (or dimensions, size) of a numpy matrix in python? | <p>For a numpy matrix in python</p>
<pre><code>from numpy import matrix
A = matrix([[1,2],[3,4]])
</code></pre>
<p>How can I find the length of a row (or column) of this matrix? Equivalently, how can I know the number of rows or columns?</p>
<p>So far, the only solution I've found is:</p>
<pre><code>len(A)
len(A[:,... | 14,847,459 | 2 | 2 | null | 2013-02-13 06:07:24.577 UTC | 28 | 2014-02-27 00:39:23.473 UTC | 2014-02-04 01:45:08.147 UTC | null | 1,748,679 | null | 1,748,679 | null | 1 | 163 | python|matrix|numpy | 609,602 | <p><code>shape</code> is a property of both numpy ndarray's and matrices.</p>
<pre><code>A.shape
</code></pre>
<p>will return a tuple (m, n), where m is the number of rows, and n is the number of columns.</p>
<p>In fact, the numpy <code>matrix</code> object is built on top of the <code>ndarray</code> object, one of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.