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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,192,268 | Elegant clean way to include HTML in JavaScript files? | <p>I'm building a small app with a few modal dialog windows. The windows require a tiny bit of HTML. I've hard coded the window HTML in the javascript library but am not thrilled with this solution. Is there a more elegant way to do this? It seems that JavaScript doesn't have multi line strings/heredoc syntax. </p... | 6,192,330 | 7 | 0 | null | 2011-05-31 19:05:29.643 UTC | 16 | 2014-04-13 17:55:24.53 UTC | 2012-10-15 20:12:31.26 UTC | null | 541,091 | null | 107,380 | null | 1 | 29 | javascript|jquery | 39,631 | <p>Templates. Pick your poison</p>
<ul>
<li><a href="https://github.com/visionmedia/ejs" rel="noreferrer">EJS</a></li>
<li><a href="http://api.jquery.com/jquery.tmpl/" rel="noreferrer">jQuery templates</a> (nb: <a href="http://www.borismoore.com/2011/10/jquery-templates-and-jsviews-roadmap.html" rel="noreferrer">devel... |
5,776,529 | int *array = new int[n]; what is this function actually doing? | <p>I am confused about how to create a dynamic defined array:</p>
<pre><code> int *array = new int[n];
</code></pre>
<p>I have no idea what this is doing. I can tell it's creating a pointer named array that's pointing to a new object/array int? Would someone care to explain?</p> | 5,776,541 | 8 | 1 | null | 2011-04-25 08:16:02.86 UTC | 10 | 2021-11-06 15:26:10.223 UTC | 2013-07-07 19:21:11.777 UTC | null | 445,131 | null | 707,485 | null | 1 | 30 | c++|arrays|pointers|new-operator | 138,035 | <p><em>new</em> allocates an amount of memory needed to store the object/array that you request. In this case n numbers of int.</p>
<p>The pointer will then store the address to this block of memory.</p>
<p>But be careful, this allocated block of memory will not be freed until you tell it so by writing</p>
<pre><cod... |
6,293,421 | How to print a string multiple times? | <p>How can I repeat a string multiple times, multiple times? I know I can use a for loop, but I would like to repeat a string <code>x</code> times per row, over <code>n</code> rows.</p>
<p>For example, if the user enters <code>2</code>, the output would be:</p>
<pre><code>@@
@@
@@
@@
</code></pre>
<p>Where <code>x</... | 6,293,448 | 10 | 5 | null | 2011-06-09 13:20:56.88 UTC | 3 | 2021-06-26 04:22:20.793 UTC | 2020-10-22 04:29:42.85 UTC | null | 2,745,495 | null | 718,531 | null | 1 | 12 | python | 212,011 | <pre><code>for i in range(3):
print "Your text here"
</code></pre>
<p>Or</p>
<pre><code>for i in range(3):
print("Your text here")
</code></pre> |
5,725,278 | How do I use pdfminer as a library | <p>I am trying to get text data from a pdf using <a href="http://www.unixuser.org/~euske/python/pdfminer/index.html" rel="noreferrer">pdfminer</a>. I am able to extract this data to a .txt file successfully with the pdfminer command line tool pdf2txt.py. I currently do this and then use a python script to clean up th... | 8,325,135 | 15 | 3 | null | 2011-04-20 03:50:00.03 UTC | 54 | 2022-03-21 15:41:13.297 UTC | 2017-05-23 11:47:11.08 UTC | null | -1 | null | 716,364 | null | 1 | 74 | python|pdf|pdfminer | 86,871 | <p>Here is a cleaned up version I finally produced that worked for me. The following just simply returns the string in a PDF, given its filename. I hope this saves someone time.</p>
<pre><code>from pdfminer.pdfinterp import PDFResourceManager, process_pdf
from pdfminer.converter import TextConverter
from pdfminer.layo... |
39,053,451 | Using spread with duplicate identifiers for rows | <p>I have a long form dataframe that have multiple entries for same date and person. </p>
<pre><code>jj <- data.frame(month=rep(1:3,4),
student=rep(c("Amy", "Bob"), each=6),
A=c(9, 7, 6, 8, 6, 9, 3, 2, 1, 5, 6, 5),
B=c(6, 7, 8, 5, 6, 7, 5, 4, 6, 3, 1, 5))
</code></pre>
<p>I w... | 39,053,597 | 4 | 1 | null | 2016-08-20 11:11:45.117 UTC | 7 | 2019-09-14 22:49:35.18 UTC | 2017-05-23 12:02:21.55 UTC | null | -1 | null | 5,868,054 | null | 1 | 30 | r|dplyr|tidyr | 44,677 | <p>The issue is the two columns for both <code>A</code> and <code>B</code>. If we can make that one value column, we can spread the data as you would like. Take a look at the output for <code>jj_melt</code> when you use the code below.</p>
<pre><code>library(reshape2)
jj_melt <- melt(jj, id=c("month", "student"))
j... |
25,008,472 | Pagination in Spring Data JPA (limit and offset) | <p>I want the user to be able to specify the limit (the size of the amount returned) and offset (the first record returned / index returned) in my query method. </p>
<p>Here are my classes without any paging capabilities.
My entity:</p>
<pre><code>@Entity
public Employee {
@Id
@GeneratedValue(strategy=Generat... | 36,365,522 | 8 | 1 | null | 2014-07-29 04:56:39.037 UTC | 31 | 2022-07-08 08:01:27.737 UTC | 2015-03-19 11:48:46.597 UTC | null | 142,983 | null | 3,814,650 | null | 1 | 65 | spring|jpa|pagination|spring-data|paging | 131,598 | <p>Below code should do it. I am using in my own project and tested for most cases.</p>
<p>usage:</p>
<pre><code> Pageable pageable = new OffsetBasedPageRequest(offset, limit);
return this.dataServices.findAllInclusive(pageable);
</code></pre>
<p>and the source code:</p>
<pre><code>import org.apache.commons.lang3.... |
27,529,486 | Do Immutable.js or Lazy.js perform short-cut fusion? | <p>First, let me define what is <a href="https://www.haskell.org/haskellwiki/Short_cut_fusion" rel="noreferrer">short-cut fusion</a> for those of you who don't know. Consider the following array transformation in JavaScript:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="fa... | 27,532,894 | 1 | 2 | null | 2014-12-17 15:49:26.053 UTC | 17 | 2017-10-15 20:31:30.313 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 783,743 | null | 1 | 34 | javascript|lazy-evaluation|immutable.js|lazy.js | 3,160 | <p>I'm the author of Immutable.js (and a fan of Lazy.js).</p>
<p>Does Lazy.js and Immutable.js's Seq use short-cut fusion? No, not exactly. But they do remove intermediate representation of operation results.</p>
<p>Short-cut fusion is a code compilation/transpilation technique. Your example is a good one:</p>
<pre>... |
42,187,188 | Can you migrate AWS Cognito users between user pools? | <p>I am using AWS Cognito. I have a pretty common scenario: users can register in different roles. Depending on the role different user attributes are required, so I need to use different user pools.</p>
<p>Now a user wants to upgrade from role A to role B - thus I would have to move his account from one pool to anoth... | 49,546,395 | 1 | 2 | null | 2017-02-12 11:47:42.28 UTC | 8 | 2019-09-27 12:01:36.41 UTC | 2017-05-23 12:08:55.76 UTC | null | -1 | null | 1,977,182 | null | 1 | 16 | amazon-web-services|authentication|amazon-cognito | 16,025 | <p>I know this question is a bit dated, but it is possible that this scenario is best solved by using Groups instead of a separate user pool for each role. See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-user-groups.html" rel="noreferrer">here</a></p>
<p>If you reach this link... |
34,009,992 | Python ElementTree default namespace? | <p>Is there a way to define the default/unprefixed namespace in python ElementTree? This doesn't seem to work...</p>
<pre><code>ns = {"":"http://maven.apache.org/POM/4.0.0"}
pom = xml.etree.ElementTree.parse("pom.xml")
print(pom.findall("version", ns))
</code></pre>
<p>Nor does this:</p>
<pre><code>ns = {None:"http:... | 35,165,997 | 3 | 1 | null | 2015-11-30 23:33:53.53 UTC | 9 | 2021-12-11 10:39:35.333 UTC | 2018-03-05 14:56:38.69 UTC | null | 3,357,935 | null | 125,601 | null | 1 | 25 | python|xml|python-3.x|namespaces|elementtree | 16,608 | <p>NOTE: for Python 3.8+ please see <a href="https://stackoverflow.com/a/62398604/771848">this answer</a>.</p>
<hr />
<p>There is no straight-forward way to handle the default namespaces transparently. Assigning the empty namespace a non-empty name is a common solution, as you've already mentioned:</p>
<pre><code>ns = ... |
47,216,731 | How can I use `def` in Jenkins Pipeline? | <p>I am learning <a href="https://www.jenkins.io/doc/book/pipeline/" rel="nofollow noreferrer">Jenkins Pipeline</a>, and I tried to follow this Pipeline <a href="https://github.com/azure-devops/movie-db-java-on-azure/blob/master/Jenkinsfile-data-app#L19" rel="nofollow noreferrer">code</a>. But my Jenkins always complai... | 47,218,620 | 3 | 2 | null | 2017-11-10 06:19:12.32 UTC | 9 | 2021-11-16 08:51:31.987 UTC | 2021-11-16 08:51:31.987 UTC | null | 814,702 | null | 1,241,464 | null | 1 | 21 | jenkins|jenkins-plugins|jenkins-pipeline | 38,420 | <p>As @Rob said, There are 2 types of pipelines: <code>scripted</code> and <code>declarative</code>. It is like <code>imperative</code> vs <code>declarative</code>. <code>def</code> is only allowed in <code>scripted</code> pipeline or wrapped in <code>script {}</code>.</p>
<h2>Scripted pipeline (Imperative)</h2>
<p>Sta... |
47,095,019 | How to use Array.prototype.filter with async? | <h2>Background</h2>
<p>I am trying to filter an array of objects. Before I filter, I need to convert them to some format, and this operation is asynchronous. </p>
<pre><code> const convert = () => new Promise( resolve => {
setTimeout( resolve, 1000 );
});
</code></pre>
<p>So, my first try was to do somet... | 47,095,184 | 7 | 2 | null | 2017-11-03 11:45:31.68 UTC | 8 | 2022-09-01 23:43:13.637 UTC | null | null | null | null | 1,337,392 | null | 1 | 66 | javascript|arrays|filter|async-await | 42,332 | <p>There is no way to use filter with an async function (at least that I know of).
The simplest way that you have to use filter with a collection of promises is to use <code>Promise.all</code> and then apply the function to your collection of results.
It would look something like this:</p>
<pre><code>const results = a... |
10,571,170 | How many comparisons will binary search make in the worst case using this algorithm? | <p>Hi there below is the pseudo code for my binary search implementation:</p>
<pre><code>Input: (A[0...n-1], K)
begin
l ← 0; r ← n-1
while l ≤ r do
m ← floor((l+r)/2)
if K > A[m] then l ← m+1
else if K < A[m] then r ← m-1 else return m
end if
end while
return -1 // key not fo... | 10,571,300 | 3 | 1 | null | 2012-05-13 10:57:43.313 UTC | 6 | 2015-09-07 14:56:36.203 UTC | 2012-05-13 11:58:08.183 UTC | null | 1,391,566 | null | 1,391,566 | null | 1 | 20 | arrays|algorithm|complexity-theory|binary-search | 58,851 | <p>The worst-case in this case is, if the element K is not present in A and smaller than all elements in A. Then we have two comparisons in each step: <code>K > A[m]</code> and <code>K < A[m]</code>.</p>
<p>For in each step the array is being cut into two parts, each of the size <code>(n-1)/2</code>, we have a m... |
10,436,454 | Replacing a substring of a string with Python | <p>I'd like to get a few opinions on the best way to replace a substring of a string with some other text. Here's an example:</p>
<p>I have a string, a, which could be something like "Hello my name is $name". I also have another string, b, which I want to insert into string a in the place of its substring '$name'.</p>... | 10,436,832 | 6 | 1 | null | 2012-05-03 17:30:00.33 UTC | 10 | 2016-03-29 20:27:48.407 UTC | 2016-03-29 20:27:48.407 UTC | null | 42,223 | null | 492,348 | null | 1 | 23 | python|string|substring|string-interpolation | 24,606 | <p>Here are the most common ways to do it:</p>
<pre><code>>>> import string
>>> t = string.Template("Hello my name is $name")
>>> print t.substitute(name='Guido')
Hello my name is Guido
>>> t = "Hello my name is %(name)s"
>>> print t % dict(name='Tim')
Hello my name is Tim... |
19,185,596 | Spock - Testing Exceptions with Data Tables | <p>How can exceptions be tested in a nice way (e.g. data tables) with Spock?</p>
<p>Example: Having a method <code>validateUser</code> that can throw exceptions with different messages or no exception if the user is valid.</p>
<p>The specification class itself:</p>
<pre><code>class User { String userName }
class So... | 19,187,445 | 7 | 1 | null | 2013-10-04 15:54:37.07 UTC | 22 | 2019-11-14 12:14:03.963 UTC | null | null | null | null | 2,847,174 | null | 1 | 68 | exception|testing|groovy|spock | 35,925 | <p>The recommended solution is to have two methods: one that tests the good cases, and another that tests the bad cases. Then both methods can make use of data tables.</p>
<p>Example:</p>
<pre><code>class SomeSpec extends Specification {
class User { String userName }
def 'validate valid user'() {
w... |
28,057,430 | What is the Access Token vs. Access Token Secret and Consumer Key vs. Consumer Secret | <p>I have been using Oauth for a while but have never been completely sure of the difference between these four terms (and the functionality of each). I frequently see (for instance in the Twitter Public API)</p>
<p><code>Consumer key:</code></p>
<p><code>Consumer secret:</code></p>
<p><code>Access token:</code></p>... | 28,057,700 | 2 | 1 | null | 2015-01-21 00:02:43.213 UTC | 31 | 2020-03-08 14:33:27.57 UTC | null | null | null | null | 3,291,506 | null | 1 | 83 | oauth | 61,854 | <p><strong>Consumer key</strong> is the API key that a service provider (Twitter, Facebook, etc.) issues to a consumer (a service that wants to access a user's resources on the service provider). This key is what identifies the consumer.</p>
<p><strong>Consumer secret</strong> is the consumer "password" that ... |
2,332,349 | Best practices for cross platform git config? | <h2>Context</h2>
<p>A number of my application user configuration files are kept in a git repository for easy sharing across multiple machines and multiple platforms. Amongst these configuration files is <code>.gitconfig</code> which contains the following settings for handling the carriage return linefeed characters<... | 2,361,309 | 3 | 1 | 2010-02-25 07:26:02.683 UTC | 2010-02-25 07:26:02.683 UTC | 37 | 2016-11-26 19:06:31.113 UTC | 2010-04-04 09:15:01.683 UTC | null | 164,901 | null | 74,198 | null | 1 | 57 | git|git-config | 36,485 | <p>I have reviewed that kind of config setting (<code>crlf</code>) extensively in the question:<br>
<strong><a href="https://stackoverflow.com/questions/2333424/distributing-git-configuration-with-the-code/2354278#2354278">distributing git configuration with the code</a></strong>.</p>
<p>The conclusion was:</p>
<ul>
... |
2,049,330 | C# variable scoping: 'x' cannot be declared in this scope because it would give a different meaning to 'x' | <pre><code>if(true)
{
string var = "VAR";
}
string var = "New VAR!";
</code></pre>
<p>This will result in:</p>
<blockquote>
<p>Error 1 A local variable named 'var'
cannot be declared in this scope
because it would give a different
meaning to 'var', which is already
used in a 'child' scope to denote
... | 2,049,377 | 3 | 9 | null | 2010-01-12 13:51:15.13 UTC | 13 | 2017-02-17 11:50:06.777 UTC | 2017-02-17 11:50:06.777 UTC | null | 226,958 | user1144 | null | null | 1 | 66 | c#|scope | 19,573 | <p>The issue here is largely one of good practice and preventing against inadvertent mistakes. Admittedly, the C# compiler <em>could theoretically</em> be designed such that there is no conflict between scopes here. This would however be much effort for little gain, as I see it.</p>
<p>Consider that if the declaration... |
1,745,165 | Looping Over Result Sets in MySQL | <p>I am trying to write a stored procedure in MySQL which will perform a somewhat simple select query, and then loop over the results in order to decide whether to perform additional queries, data transformations, or discard the data altogether. Effectively, I want to implement this:</p>
<pre><code>$result = mysql_qu... | 1,745,292 | 3 | 2 | null | 2009-11-16 22:09:19.107 UTC | 26 | 2022-05-22 19:29:59.673 UTC | 2021-12-22 19:35:12.63 UTC | null | 4,294,399 | null | 173,925 | null | 1 | 76 | mysql|loops|stored-procedures|database-cursor | 180,081 | <p>Something like this should do the trick (However, read after the snippet for more info)</p>
<pre><code>CREATE PROCEDURE GetFilteredData()
BEGIN
DECLARE bDone INT;
DECLARE var1 CHAR(16); -- or approriate type
DECLARE var2 INT;
DECLARE var3 VARCHAR(50);
DECLARE curs CURSOR FOR SELECT something FROM ... |
8,992,840 | Getting correct call stacks in VS Concurrency profiler | <p>I'm using the VS Concurrency profiler to profile a WPF application, but I can't get symbols for NGen'ned images like PresentationCore et al, so my call stacks all look like:</p>
<p><img src="https://i.stack.imgur.com/SvpUz.png" alt=""></p>
<p>Is there a way to make VS do the right thing here? <strong>Edit:</strong... | 8,993,588 | 1 | 1 | null | 2012-01-24 19:28:39.187 UTC | 13 | 2012-06-08 15:32:40.153 UTC | 2012-06-08 15:32:40.153 UTC | null | 1,569 | null | 5,728 | null | 1 | 14 | wpf|visual-studio|profiler | 1,645 | <p>Figured this one out - if you follow the steps <a href="http://blogs.msdn.com/b/sburke/archive/2008/01/29/how-to-disable-optimizations-when-debugging-reference-source.aspx" rel="noreferrer">here</a>, it works out pretty well. Here's the short version:</p>
<ol>
<li>Start an elevated CMD prompt</li>
<li><code>set COM... |
19,380,738 | Mongoose nested query on Model by field of its referenced model | <p>It seems like there is a lot of Q/A's on this topic on stackoverflow, but I can't seem to find an exact answer anywhere. </p>
<p><strong>What I have:</strong></p>
<p>I have Company and Person models:</p>
<pre><code>var mongoose = require('mongoose');
var PersonSchema = new mongoose.Schema{
... | 19,381,833 | 3 | 0 | null | 2013-10-15 12:03:30.693 UTC | 19 | 2021-02-04 13:26:06.773 UTC | null | null | null | null | 1,874,278 | null | 1 | 31 | node.js|mongodb|mongoose|populate | 33,782 | <p>You can't do this in a single query because MongoDB doesn't support joins. Instead, you have to break it into a couple steps:</p>
<pre class="lang-js prettyprint-override"><code>// Get the _ids of people with the last name of Robertson.
Person.find({lastname: 'Robertson'}, {_id: 1}, function(err, docs) {
// ... |
19,788,661 | Change JavaFx Tab default Look | <p>I am trying to change the default look of JavaFx tabs using css.</p>
<p>I managed to achieve following.</p>
<p><img src="https://i.stack.imgur.com/6H0BB.png" alt="enter image description here"></p>
<p>What I am looking for is there should not be left gap on first tab.</p>
<p>Can somebody please point me in right... | 19,792,996 | 1 | 1 | null | 2013-11-05 12:09:06.91 UTC | 13 | 2017-04-04 11:11:12.113 UTC | null | null | null | null | 758,104 | null | 1 | 31 | tabs|javafx | 45,944 | <p>You should also override the CSS:</p>
<pre><code>.tab-pane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
/* -fx-padding: 0.416667em 0.166667em 0.0em 0.833em; /* 5 2 0 10 */
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
</code></pre>
<p>Here the left padding val... |
19,751,420 | MongooseJS - How to find the element with the maximum value? | <p>I am using MongoDB , MongooseJS and Nodejs.</p>
<p>I have a Collection ( called Member ) with the following Fields - </p>
<p>Country_id , Member_id , Name, Score </p>
<p>I want to write a query which returns the Member with the max Score where Country id = 10 </p>
<p>I couldnt find suitable documentation for thi... | 19,751,733 | 5 | 1 | null | 2013-11-03 09:16:56.18 UTC | 3 | 2019-05-21 17:48:08.07 UTC | 2017-09-22 17:57:57.377 UTC | null | -1 | null | 609,235 | null | 1 | 29 | node.js|mongodb|mongoose|max|database | 33,789 | <pre><code>Member
.findOne({ country_id: 10 })
.sort('-score') // give me the max
.exec(function (err, member) {
// your callback code
});
</code></pre>
<p>Check <a href="http://mongoosejs.com/docs/queries.html" rel="noreferrer">the mongoose docs for querying</a>, they are pretty good.</p>
<p>If you do... |
889,431 | What should a "beginning developer" know about architectures and planning | <p>I've been working with C and C# for ages, I consider myself a "pretty good" programmer, but as has been pointed out many times, programming is only a small facet of software engineering and development. I'm the sole coder for my department but it looks like that is going to begin to change, what I would like to kno... | 889,718 | 4 | 2 | null | 2009-05-20 18:17:46.983 UTC | 13 | 2009-07-21 14:46:35.977 UTC | 2009-05-20 19:55:19.297 UTC | null | 72,871 | null | 72,871 | null | 1 | 8 | architecture | 1,509 | <p>Firstly the generic answers:</p>
<ul>
<li>Understand that <em>any</em> given tool is not a silver bullet to fix all your problems. So when you're reading about MVC or Functional Programming or someone is spewing that LISP will solve all your problems, they won't. They may solve a whole bunch of problems you have,... |
127,936 | Deleting Custom Event Log Source Without Using Code | <p>I have an application that has created a number of custom event log sources to help filter its output. How can I delete the custom sources from the machine WITHOUT writing any code as running a quick program using System.Diagnostics.EventLog.Delete is not possible.</p>
<p>I've tried using RegEdit to remove the cust... | 128,704 | 4 | 0 | null | 2008-09-24 15:38:26.477 UTC | 14 | 2016-12-08 08:39:02.443 UTC | null | null | null | Wolfwyrd | 15,570 | null | 1 | 46 | c#|windows|event-log | 46,217 | <p>I also think you're in the right place... it's stored in the registry, under the name of the event log. I have a custom event log, under which are multiple event sources.</p>
<blockquote>
<p>HKLM\System\CurrentControlSet\Services\Eventlog\LOGNAME\LOGSOURCE1
HKLM\System\CurrentControlSet\Services\Eventlog\LOGNA... |
1,095,718 | Diff two tabs in Vim | <p>Scenario: I have opened Vim and pasted some text. I open a second tab with <code>:tabe</code> and paste some other text in there.</p>
<p>Goal: I would like a third tab with a output equivalent to writing both texts to files and opening them with <code>vimdiff</code>.</p>
<p>The closest I can find is "diff the curr... | 1,098,521 | 4 | 3 | null | 2009-07-08 01:34:57.333 UTC | 59 | 2018-03-01 11:01:20.977 UTC | 2012-06-05 00:11:33.723 UTC | null | 21,115 | null | 21,115 | null | 1 | 123 | vim|diff|tabs|vimdiff|buffer | 38,833 | <p>I suggest opening the second file in the same tab instead of a new one.</p>
<p>Here's what I usually do:</p>
<pre><code>:edit file1
:diffthis
:vnew
:edit file2
:diffthis
</code></pre>
<p>The <a href="http://vimdoc.sourceforge.net/htmldoc/windows.html#:vnew" rel="noreferrer"><code>:vnew</code></a> command splits t... |
128,263 | How do you determine a valid SoapAction? | <p>I'm calling a <code>webservice</code> using the <code>NuSoap PHP library</code>. The <code>webservice</code> appears to use <code>.NET</code>; every time I call it I get an error about using an invalid <code>SoapAction header</code>. The header being sent is an empty string. How can I find the <code>SoapAction</code... | 128,457 | 1 | 0 | null | 2008-09-24 16:39:51.397 UTC | 4 | 2015-06-05 21:48:47.137 UTC | 2015-06-05 21:48:47.137 UTC | null | 4,248,328 | richardg | null | null | 1 | 17 | php|web-services|soap | 59,694 | <p>You can see the SoapAction that the service operation you're calling expects by looking at the WSDL for the service. For .NET services, you can access the WSDL by opening a web browser to the url of the service and appending ?wsdl on the end.</p>
<p>Inside the WSDL document, you can see the SoapActions defined und... |
42,257,354 | Concat a video with itself, but in reverse, using ffmpeg | <p>I was able to reverse with:</p>
<pre><code>ffmpeg -i input.mp4 -vf reverse output_reversed.mp4
</code></pre>
<p>And I can concat with:</p>
<pre><code>ffmpeg -i input.mp4 -i input.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
</code></pre>
<p>But can I c... | 42,257,863 | 1 | 0 | null | 2017-02-15 18:28:48.83 UTC | 10 | 2018-11-11 14:09:07.457 UTC | null | null | null | null | 7,396,678 | null | 1 | 23 | video|ffmpeg|reverse | 9,296 | <p>Technically, you can do it using</p>
<pre><code>ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][0:a][r] [0:a]concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
</code></pre>
<p>But the reverse filter will use a lot of memory for large videos. I've added a <code>fifo</code> filter to avoid... |
39,573,571 | .NET Core console application, how to configure appSettings per environment? | <p>I have a .NET Core 1.0.0 console application and two environments. I need to be able to use <code>appSettings.dev.json</code> and <code>appSettings.test.json</code> based on environment variables I set at run time. This seems to be quite straight forward for ASP.NET Core web applications, via dependency injection an... | 40,620,561 | 10 | 0 | null | 2016-09-19 12:46:43.523 UTC | 22 | 2022-08-11 06:22:05.23 UTC | null | null | null | null | 2,916,547 | null | 1 | 98 | c#|console-application|.net-core | 110,683 | <p>This is how we do it in our <code>.netcore</code> console app. The key here is to include the right <strong>dependencies</strong> on your project namely (<em>may be not all, check based on your needs</em>) and <strong>copy to output</strong> the appSetting.json as part of your <strong>buildoptions</strong></p>
<pre ... |
21,905,377 | How to open chrome in Selenium webdriver? | <p>I'm trying to launch chrome with <code>Selenium Webdriver</code> and used the following code: </p>
<pre><code>System.setProperty("webdriver.chrome.driver",
"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.yahoo.com");
</code>... | 21,905,509 | 5 | 0 | null | 2014-02-20 10:46:08.94 UTC | null | 2021-06-01 05:30:06.953 UTC | 2017-09-19 11:14:30.56 UTC | null | 7,755,936 | null | 2,814,359 | null | 1 | 0 | google-chrome|selenium-webdriver | 76,803 | <p>Use the latest versions of ChromeDriver.</p>
<p><strong>Source|</strong></p>
<pre><code>http://chromedriver.storage.googleapis.com/index.html
</code></pre> |
21,556,961 | Intercept JAX-RS Request: Register a ContainerRequestFilter with tomcat | <p>I am trying to intercept a request to my JAX-RS webservice by a ContainerRequestFilter. I want to use it with a custom annotation, so I can decorate certain methods of the webservice. This should enable me to handle requests to this methods based on the information whether they are made on a secure channel
or not, b... | 21,578,954 | 3 | 0 | null | 2014-02-04 15:48:19.96 UTC | 4 | 2017-07-24 16:06:25.38 UTC | 2017-05-23 10:31:37.83 UTC | null | -1 | null | 3,271,380 | null | 1 | 10 | java|web-services|rest|tomcat|jax-rs | 52,033 | <p>You're using JAX-RS 2.0 APIs (request filters, name binding, ...) in your classes but Jersey 1 proprietary init params in your <code>web.xml</code> (package starting with <code>com.sun.jersey</code>, Jersey 2 uses <code>org.glassfish.jersey</code>). Take a look at this <a href="https://stackoverflow.com/questions/18... |
19,071,179 | Capistrano - How to put files in the shared folder? | <p>I am new to <code>Capistrano</code>and I saw there is shared folder and also option <code>:linked_files</code>. I think shared folder is used to keep files between releases. But my question is, how do files end up being in the shared folder?</p>
<p>Also, if I want to symlink another directory to the current directo... | 19,306,181 | 6 | 0 | null | 2013-09-28 20:09:11.42 UTC | 16 | 2019-07-29 11:35:05.377 UTC | 2017-02-19 00:34:30.583 UTC | null | 1,533,054 | null | 273,183 | null | 1 | 50 | capistrano|config|web-deployment | 48,754 | <p>Folders inside your app are symlinks to folders in the shared directory. If your app writes to <code>log/production.log</code>, it will actually write to <code>../shared/log/production.log</code>. That's how the files end up being in the shared folder.</p>
<p>You can see how this works by looking at the <a href="ht... |
17,922,748 | What is the correct method for calculating the Content-length header in node.js | <p>I'm not at all sure whether my current method of calculating the content-length is correct. What are the implications of using string.length() to calculate the content-length. Does setting the charset to utf-8 even mean anything when using node.js?</p>
<pre><code>payload = JSON.stringify( payload );
response.heade... | 17,922,999 | 1 | 1 | null | 2013-07-29 11:23:30.193 UTC | 8 | 2013-07-29 11:37:31.403 UTC | null | null | null | null | 560,383 | null | 1 | 38 | javascript|node.js|utf-8|express | 19,754 | <p>Content-Length header must be the count of octets in the response body. <code>payload.length</code> refers to string length in characters. Some UTF-8 characters contain multiple bytes. The better way would be to use <code>Buffer.byteLength(string, [encoding])</code> from <a href="http://nodejs.org/api/buffer.html" r... |
24,054,590 | ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'user' from content with media type 'multipart/form-data in "postman" | <p>I am creating the Login Service using Web API. When I am checking with <code>fiddler</code> it's working fine but when I am checking with <code>postman</code> of <code>chrome</code> it's showing error:</p>
<pre><code>{ "Message": "An error has occurred.",
"ExceptionMessage": "No MediaTypeFormatter is availab... | 24,058,025 | 2 | 0 | null | 2014-06-05 07:52:13.563 UTC | 1 | 2017-06-19 12:07:12.707 UTC | 2017-06-19 12:07:12.707 UTC | null | 3,714,940 | null | 2,107,297 | null | 1 | 7 | asp.net-web-api|fiddler|postman | 41,543 | <p>Click on the Header button type this both header and value</p>
<pre><code>Content-Type: application/json
</code></pre>
<p>check below link for fiddle and postman both use same content-types
<a href="https://stackoverflow.com/questions/22384354/error-sending-json-in-post-to-web-api-service">Error sending json in PO... |
34,500,020 | ReferenceError: Can't find variable: __fbBatchedBridge | <p>Using just the default code from <code>react-native init AwesomeProject</code>, when I run the app I get the 'ReferenceError: Can't find variable: __fbBatchedBridge (line 1 in the generated bundle)'.</p>
<p>And, when I 'Reload JS', the app just has the white background rather than any 'hello world' views. I haven't... | 34,500,080 | 8 | 0 | null | 2015-12-28 20:08:50.403 UTC | 5 | 2016-05-16 06:44:35.623 UTC | 2016-02-10 16:51:26.977 UTC | null | 1,043,380 | null | 887,894 | null | 1 | 40 | node.js|react-native | 15,294 | <p>I generally see this when the packager hasn't started. Ensure that is running by running react-native start</p> |
26,108,672 | RSA: encrypt in iOS, decrypt in Java | <p>I have a public key that's sent from a Java server. The base64 encoded strings match before I decode and strip out the ASN.1 headers. I store the public key in the keychain with <code>SecItemAdd</code>.</p>
<p>So I'm trying to encrypt the data using the public key and decrypt it with the private key in Java. I'm us... | 27,446,066 | 2 | 0 | null | 2014-09-29 20:51:56.907 UTC | 15 | 2014-12-12 14:45:06.47 UTC | 2014-09-29 23:44:01.86 UTC | null | 1,733,644 | null | 1,733,644 | null | 1 | 20 | java|ios7|rsa | 10,134 | <p>I had same problem. Does work with <code>kSecPaddingNone</code>, but <strong>doesn't</strong> work with <code>kSecPaddingPKCS1</code> with any <code>PKCS1</code> combination in Java code.</p>
<p>But, it's not good idea to use it without padding.</p>
<p>So, on iOS, replace <code>kSecPaddingNone</code> with <code>kS... |
46,407,009 | How to hide .env passwords in Laravel whoops output? | <p>How can I hide my passwords and other sensitive environment variables on-screen in Laravel's whoops output?</p>
<p>Sometimes other people are looking at my development work. I don't want them to see these secrets if an exception is thrown, but I also don't want to have to keep toggling debug on and off, or spin up ... | 46,407,010 | 12 | 0 | null | 2017-09-25 13:57:51.503 UTC | 31 | 2021-10-19 23:02:42.63 UTC | null | null | null | null | 4,233,593 | null | 1 | 74 | php|laravel|environment-variables|secret-key|whoops | 33,186 | <p>As of <a href="https://github.com/laravel/framework/pull/21336" rel="noreferrer">Laravel 5.5.13</a>, you can censor variables by listing them under the key <code>debug_blacklist</code> in <code>config/app.php</code>. When an exception is thrown, whoops will mask these values with asterisks <code>*</code> for each ch... |
40,465,047 | How can I mock an ES6 module import using Jest? | <p>I want to test that one of my <a href="https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_%E2%80%93_ECMAScript_2015" rel="noreferrer">ES6</a> modules calls another ES6 module in a particular way. With <a href="https://en.wikipedia.org/wiki/Jasmine_(JavaScript_testing_framework)" rel="noreferrer">Jasmine</a> this i... | 60,669,731 | 9 | 3 | null | 2016-11-07 12:19:32.183 UTC | 102 | 2022-06-28 16:08:05.45 UTC | 2020-09-24 21:19:18.267 UTC | null | 63,550 | null | 665,488 | null | 1 | 437 | javascript|node.js|mocking|ecmascript-6|jestjs | 373,675 | <p>Fast forwarding to 2020, I found this blog post to be the solution: <em><a href="https://remarkablemark.org/blog/2018/06/28/jest-mock-default-named-export/" rel="noreferrer">Jest mock default and named export</a></em></p>
<p>Using only ES6 module syntax:</p>
<pre><code>// esModule.js
export default 'defaultExport';
... |
40,081,332 | What does the `is` keyword do in typescript? | <p>I came across some code that looks like this:</p>
<pre><code>export function foo(arg: string): arg is MyType {
return ...
}
</code></pre>
<p>I haven't been able to search for <code>is</code> in either the docs or google, it's a pretty common word and shows up on basically every page.</p>
<p>What does the keyw... | 45,748,366 | 2 | 1 | null | 2016-10-17 08:06:49.98 UTC | 58 | 2022-06-23 14:59:31.88 UTC | 2022-06-23 14:59:31.88 UTC | null | 527,702 | null | 595,605 | null | 1 | 261 | typescript|keyword | 90,782 | <p>See the reference for <a href="https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates" rel="noreferrer">user-defined type guard functions</a> for more information.</p>
<pre class="lang-js prettyprint-override"><code>function isString(test: any): test is string{
return typeof test ===... |
22,079,587 | AngularJS : transcluding multiple sub elements in a single Angular directive | <p>I was reading about <code>ng-transclude</code> in the AngularJS docs on <a href="https://docs.angularjs.org/guide/directive#creating-a-directive-that-wraps-other-elements" rel="nofollow noreferrer">Creating a Directive that Wraps Other Elements</a> and I think I understand properly what it does.</p>
<p>If you have a... | 34,063,645 | 3 | 1 | null | 2014-02-27 20:26:45.96 UTC | 8 | 2021-02-18 16:38:46.097 UTC | 2021-02-18 16:38:46.097 UTC | null | 1,028,230 | null | 25,412 | null | 1 | 40 | angularjs|angularjs-directive|angularjs-scope | 22,468 | <p>Starting Angular 1.5, it's now possible to create multiple slots. Instead of <strong>transclude:true</strong>, you provide an <strong>object</strong> with the mappings of each slot:</p>
<p><a href="https://docs.angularjs.org/api/ng/directive/ngTransclude">https://docs.angularjs.org/api/ng/directive/ngTransclude</a>... |
60,453,261 | How to default Python3.8 on my Mac using Homebrew? | <p>I have updated my python 3 to the latest version 3.8:</p>
<pre><code>brew search python
==> Formulae
app-engine-python gst-python python ✔ python@3.8 ✔
boost-python ipython python-markdown wxpython
boost-python3 micropython python-yq
==> Casks
awips-... | 60,453,764 | 4 | 1 | null | 2020-02-28 13:59:27.567 UTC | 12 | 2021-03-31 16:35:13.61 UTC | null | null | null | null | 11,104,367 | null | 1 | 31 | python-3.x|linux|macos|homebrew | 51,810 | <p>Ok, thanks to @gromgit from Homebrew community discussion (<a href="https://discourse.brew.sh/t/how-to-default-python-3-8-on-my-mac-using-homebrew/7050" rel="noreferrer">https://discourse.brew.sh/t/how-to-default-python-3-8-on-my-mac-using-homebrew/7050</a>)</p>
<p>Here is the solution:</p>
<pre><code>$ brew info ... |
30,540,632 | CoordinatorLayout using the ViewPager's RecyclerView | <p>I am using the view <code>CoordinatorLayout</code> from <code>android.support.design</code>. I want to attach the <code>app:layout_behavior</code> to the fragment's <code>RecyclerView</code>?</p>
<p>In the example given by Google, they only attach it in the <code>RecyclerView</code> of the same XML file where the <... | 30,543,783 | 6 | 1 | null | 2015-05-29 23:38:11.493 UTC | 15 | 2017-02-04 03:51:36.54 UTC | 2016-01-10 11:47:31.943 UTC | null | 1,276,636 | null | 3,444,777 | null | 1 | 53 | android|android-appcompat|android-recyclerview|android-design-library|android-coordinatorlayout | 51,804 | <p>Chris Banes has posted a sample on Github which shows exactly what you want to do. </p>
<p>Here is the xml file that defines how one can indirectly attach a coordinator layout to the viewpager's fragments.</p>
<pre><code><android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android... |
53,769,401 | Angular 6 - NullInjectorError: No provider for HttpClient in unit tests | <p>I am importing and using <code>HttpClient</code> in a service as follows:</p>
<pre class="lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root',
})
export class MyService {
constructor(private http:... | 53,769,491 | 3 | 5 | null | 2018-12-13 20:13:03.027 UTC | 9 | 2022-01-07 14:59:23.073 UTC | 2022-01-07 14:58:36.993 UTC | null | 6,831,341 | null | 5,100,278 | null | 1 | 61 | angular|karma-jasmine|angular-test | 110,248 | <pre class="lang-js prettyprint-override"><code>import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import {HttpClientModule} from '@angular/common/http';
import { myService } from './myservice';
describe('myService', () =>... |
29,360,395 | Display images in Django | <p>I have a django app which allows users to submit an image with it. Right now my model looks like </p>
<pre><code>class Posting(models.Model):
title = models.CharField(max_length=150)
images = models.ForeignKey(Image, null=True)
class Image(models.Model):
img = models.ImageField(upload_to="photos/",null... | 29,397,661 | 5 | 2 | null | 2015-03-31 04:02:33.573 UTC | 2 | 2019-07-03 14:40:44.937 UTC | null | null | null | null | 3,443,176 | null | 1 | 8 | django|image|imagefield | 40,241 | <p>This is how i got it working.</p>
<p><strong>settings.py</strong></p>
<pre><code>import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
MEDIA_ROOT = (
BASE_DIR
)
MEDIA_URL = '/media/'
</code></pre>
<p><strong>models.... |
32,231,489 | smtp exception “failure sending mail” | <p>I created console application for sending Email</p>
<pre><code> public static void sendEmail(string email, string body)
{
if (String.IsNullOrEmpty(email))
return;
try
{
MailMessage mail = new MailMessage();
mail.To.Add(email);
mail.From ... | 32,231,849 | 2 | 3 | null | 2015-08-26 16:04:42.067 UTC | 1 | 2018-08-26 08:53:12.67 UTC | null | null | null | user5264652 | null | null | 1 | 10 | c#|email|console-application | 69,648 | <p>It's likely that you're actually getting this error, it's just suppressed in some way by you being in a console app.</p>
<blockquote>
<p>The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.</p>
</blockquote>
<p>Change this piece... |
4,495,511 | How to pass custom component parameters in java and xml | <p>When creating a custom component in android it is often asked how to create and pass through the attrs property to the constructor.</p>
<p>It is often suggested that when creating a component in java that you simply use the default constructor, i.e. </p>
<pre><code>new MyComponent(context);
</code></pre>
<p>rathe... | 4,495,745 | 1 | 0 | null | 2010-12-21 01:07:03.887 UTC | 24 | 2018-12-06 02:04:06.29 UTC | 2011-01-08 23:58:44.55 UTC | null | 244,296 | null | 468,195 | null | 1 | 52 | android|components|custom-attributes|uicomponents | 41,139 | <p>(Full disclosure: This question is an offshoot of <a href="https://stackoverflow.com/questions/4418700">Creating custom view</a>)</p>
<p>You can create constructors beyond the three standard ones inherited from <code>View</code> that add the attributes you want...</p>
<pre><code>MyComponent(Context context, Strin... |
25,028,873 | How do I reload a module in an active Julia session after an edit? | <p><strong>2018 Update:</strong> Be sure to check all the responses, as the answer to this question has changed multiple times over the years. At the time of this update, the <code>Revise.jl</code> answer is probably the best solution.</p>
<p>I have a file "/SomeAbsolutePath/ctbTestModule.jl", the contents of which ar... | 25,077,725 | 5 | 2 | null | 2014-07-30 04:39:54.37 UTC | 17 | 2021-05-27 08:22:32.367 UTC | 2018-06-12 23:09:32.927 UTC | null | 1,667,895 | null | 1,667,895 | null | 1 | 68 | module|julia | 19,187 | <p>The basis of this problem is the confluence of reloading a module, but not being able to redefine a thing in the module <strong><em>Main</em></strong> (<a href="http://julia.readthedocs.org/en/latest/manual/faq/">see the documentation here</a>) -- that is <a href="https://github.com/JuliaLang/julia/pull/7487">at lea... |
24,961,797 | Android resize bitmap keeping aspect ratio | <p>I have a custom view (1066 x 738), and I am passing a bitmap image (720x343). I want to scale the bitmap to fit in the custom view without exceeding the bound of the parent.</p>
<p><img src="https://i.stack.imgur.com/OLaY2.jpg" alt="enter image description here"></p>
<p>I want to achieve something like this:</p>
... | 24,962,139 | 1 | 3 | null | 2014-07-25 17:56:34 UTC | 4 | 2014-12-09 12:39:20.503 UTC | null | null | null | null | 1,950,209 | null | 1 | 16 | android|bitmap|scale | 41,525 | <p>You should try using a transformation matrix built for <code>ScaleToFit.CENTER</code>. For example:</p>
<pre><code>Matrix m = new Matrix();
m.setRectToRect(new RectF(0, 0, b.getWidth(), b.getHeight()), new RectF(0, 0, reqWidth, reqHeight), Matrix.ScaleToFit.CENTER);
return Bitmap.createBitmap(b, 0, 0, b.getWidth(),... |
39,076,988 | Add extra User Information with firebase | <p>I have integrated firebase auth with my android app. Lets say a user has a mail <code>abc@abc.com</code>. I want to add some extra information to the user like the name of the user, occupation and address. How can i connect the user auth table with my android app to do that? </p>
<p>Do i need to write any APIs for ... | 39,077,132 | 3 | 5 | null | 2016-08-22 10:19:50.26 UTC | 13 | 2018-02-28 20:44:35.177 UTC | null | null | null | null | 5,408,958 | null | 1 | 50 | android|firebase|firebase-realtime-database|firebase-authentication | 62,114 | <p>First, create a <code>users</code> directory in db. Then, using user's unique id you get from authn process, store the user info under <code>users/{userid}</code>.</p>
<p>To achieve this, you need to get into the details of Firebase database. See here: <a href="https://firebase.google.com/docs/database/android/save... |
20,147,964 | What does if [[ $? -ne 0 ]]; mean in .ksh | <p>I have a following piece of code that says if everything is executed mail a person if it fails mail the person with a error message. </p>
<pre><code>if [[ $? -ne 0 ]]; then
mailx -s" could not PreProcess files" xyz@abcd.com
else
mailx -s" PreProcessed files" xyz@abcd.com
fi
done
</code></pre>
<p>I ... | 20,148,053 | 4 | 0 | null | 2013-11-22 15:02:34.433 UTC | 3 | 2019-01-24 01:11:00.003 UTC | 2015-07-06 13:10:40.4 UTC | null | 1,480,391 | null | 2,957,106 | null | 1 | 14 | linux|bash|unix|ksh | 42,223 | <p>Breaking it down, simple terms:</p>
<pre><code>[[ and ]]
</code></pre>
<p>... signifies a test is being made for truthiness.</p>
<pre><code>$?
</code></pre>
<p>... is a variable holding the exit code of the last run command.</p>
<pre><code>-ne 0
</code></pre>
<p>... checks that the thing on the left (<code>$?<... |
7,193,787 | Keyboard Scroll on Active Text Field - Scrolling to Out of View? | <p>I have an application with a view that has text fields from the top of the view to the bottom of the view. I needed it to scroll when editing the bottom fields so that the fields would be visible, but it's not seeming to work correctly.</p>
<p>Following the <a href="http://developer.apple.com/library/ios/#documenta... | 7,195,882 | 4 | 4 | null | 2011-08-25 16:16:36.977 UTC | 10 | 2016-09-09 09:00:56.907 UTC | 2011-08-25 18:34:55.447 UTC | null | 801,858 | null | 801,858 | null | 1 | 7 | iphone|objective-c|xcode|uiscrollview | 25,150 | <p><strong>UPDATE:</strong> Below answer is outdated. For now you can use "<a href="https://github.com/michaeltyson/TPKeyboardAvoiding" rel="nofollow">TPkeyboardavoiding</a>" library for handle all kind of text field operation in UIScrollView, UITableView & many more. Try it and let me know if any one have a proble... |
7,044,365 | How to replace " with \" in javascript | <p>I have a textbox that posts info to the server and it's in JSON format. Lets say I want to enter two quotes for the value, and the JSON struct would look like:</p>
<pre><code>{
"test": """"
}
</code></pre>
<p>I need it to look like: </p>
<pre><code>{
"test": "\"\""
}
</code></pre>
<p>so it will follow JS... | 7,044,544 | 4 | 5 | null | 2011-08-12 18:01:57.24 UTC | 2 | 2015-11-26 06:05:10.587 UTC | 2011-08-12 19:09:21.123 UTC | null | 277,140 | null | 277,140 | null | 1 | 10 | javascript|replace | 45,197 | <p>My answer makes some assumptions, as I've had to fill in the rather sizeable gaps in your question:</p>
<ul>
<li>The user will enter a text string into a textbox;</li>
<li>Your script will read the textbox contents, and use those contents as the <em>value</em> of one of the items in a JSON string that it's building... |
24,124,417 | Swift init Array with capacity | <p>How do I initialize an Array in swift with a specific capacity?</p>
<p>I've tried:</p>
<pre><code>var grid = Array <Square> ()
grid.reserveCapacity(16)
</code></pre>
<p>but get the error</p>
<pre><code>expected declaration
</code></pre> | 43,233,766 | 5 | 1 | null | 2014-06-09 16:18:44.263 UTC | 7 | 2022-06-03 10:56:40.193 UTC | null | null | null | null | 1,370,927 | null | 1 | 42 | arrays|swift | 36,391 | <p><strong>Swift 3 / Swift 4 / Swift 5</strong></p>
<pre><code>var grid : [Square] = []
grid.reserveCapacity(16)
</code></pre>
<p>I believe it can be achieved in one line as well.</p> |
8,236,701 | Modeling Favorites | <p>I'm looking to add a <code>Favorite</code> model to my <code>User</code> and <code>Link</code> models. </p>
<p><strong>Business Logic</strong></p>
<ul>
<li>Users can have multiple links (that is, they can add multiple links) </li>
<li>Users can favorite multiple links (of their own or other users) </li>
<li>A Link... | 8,236,769 | 1 | 0 | null | 2011-11-23 02:40:23.613 UTC | 8 | 2011-11-23 03:22:42.083 UTC | null | null | null | null | 830,554 | null | 1 | 5 | ruby-on-rails|ruby|database|ruby-on-rails-3 | 911 | <p>How about the following data model:</p>
<pre><code>class User < ActiveRecord::Base
has_many :links
has_many :favorites, :dependent => :destroy
has_many :favorite_links, :through => :favorites, :source => :link
end
class Link < ActiveRecord::Base
belongs_to :user
has_many :favorites, :dep... |
21,565,991 | How to serve a file using iron router or meteor itself? | <p>I'm trying to serve a zip file on my Meteor app but I'm stuck. After a lot of Googling it seems the best way to go is with Iron Router but I don't know how:</p>
<pre><code>Router.map ->
@route "data",
where: 'server'
path: '/data/:id'
action: ->
data = getBase64ZipData(this.params.id)
... | 21,566,476 | 1 | 2 | null | 2014-02-04 23:50:43.88 UTC | 10 | 2014-12-12 00:42:41.11 UTC | null | null | null | null | 335,911 | null | 1 | 15 | meteor|iron-router | 6,985 | <h3>On the server:</h3>
<pre class="lang-js prettyprint-override"><code>var fs = Npm.require('fs');
var fail = function(response) {
response.statusCode = 404;
response.end();
};
var dataFile = function() {
// TODO write a function to translate the id into a file path
var file = fileFromId(this.params.id);
... |
1,371,953 | VBScript how to set the connection string | <p>I am not sure whether it has been disscussed before or not but I have the following code (I changed from example for an Access database.) </p>
<p>I don't know what to put inside the <strong><em>'Provider'</em></strong> and the <strong><em>'Data Source'</em></strong>. I'm using <strong>MS SQL Server 2005</strong> an... | 1,392,061 | 4 | 0 | null | 2009-09-03 07:41:53.67 UTC | 3 | 2010-03-23 22:26:27.533 UTC | 2010-03-23 22:25:04.773 UTC | null | 63,550 | null | 147,685 | null | 1 | 2 | sql-server-2005|vbscript|connection-string|database-connection|wsh | 55,210 | <p>I finally found the solution thanks to your help.
Under the Administrative Tools, Data Source (ODBS), driver tabs, I use provider: SQLNCLI, my Server: Data Source, and I add Recordset rs to the code. It seems that, without this one, the connection is not established. I don't know what happened.</p>
<p><pre><code>D... |
2,010,166 | connection url for sql server | <p>I downloaded microsfot's jdbc driver, and I am not sure what the connection.url should be?</p>
<pre><code> <property name="connection.driver_class">org.microsoft.sqlserver.jdbc</property>
<property name="connection.url">jdbc:</property>
..
<property name="dialect">org.hibernate.d... | 2,010,180 | 4 | 0 | null | 2010-01-06 00:23:50.503 UTC | 2 | 2022-01-25 17:11:13.58 UTC | null | null | null | null | 68,183 | null | 1 | 8 | java|hibernate | 47,676 | <p>Here you go:</p>
<pre><code> <property name = "hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name = "hibernate.connection.driver_class" value = "com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name = "hibernate.connection.url" value = "jdbc:s... |
2,129,519 | Align text only on first separator in VIM | <p>Suppose I have this code:</p>
<pre><code>width: 215px;
height: 22px;
margin-top: 3px;
background-color: white;
border: 1px solid #999999;
</code></pre>
<p>I want to align it this way:</p>
<pre><code>width: 215px;
height: 22px;
margin-top: 3px;
background-color: white;
border: ... | 2,129,690 | 4 | 1 | null | 2010-01-25 00:19:43.56 UTC | 10 | 2017-10-18 09:24:37.563 UTC | null | null | null | null | 148,968 | null | 1 | 15 | vim|alignment | 5,554 | <p>If you use <a href="http://github.com/godlygeek/tabular" rel="noreferrer">Tabular</a>, then you can just do <code>:Tabularize /:\zs/</code>.</p>
<p>Looking at Align's description on vim.org, a similar invocation should work for it. You could try <code>:Align :\zs</code>. I don't use Align, so I'm not positive.</p... |
2,055,557 | What is the use of the "-O" flag for running Python? | <p>Python can run scripts in optimized mode (<a href="https://docs.python.org/3/using/cmdline.html?highlight=pythonoptimize#cmdoption-O" rel="nofollow noreferrer"><code>python -O</code></a>) which turns off debugs, removes <a href="https://docs.python.org/3/reference/simple_stmts.html#assert" rel="nofollow noreferrer">... | 2,083,834 | 4 | 0 | null | 2010-01-13 09:21:00.193 UTC | 17 | 2022-08-25 23:58:15.253 UTC | 2022-08-25 23:58:15.253 UTC | null | 523,612 | null | 206,855 | null | 1 | 36 | python|assert|assertion | 14,102 | <p>It saves a small amount of memory, and a small amount of disk space if you distribute any archive form containing only the <code>.pyo</code> files. (If you use <code>assert</code> a lot, and perhaps with complicated conditions, the savings can be not trivial and can extend to running time too).</p>
<p>So, it's def... |
1,704,533 | Intercept page exit event | <p>When editing a page within my system, a user might decide to navigate to another website and in doing so could lose all the edits they have not saved.</p>
<p>I would like to intercept any attempt to go to another page and prompt the user to be sure they want this to happen since they could potentially lose their cur... | 1,704,783 | 4 | 2 | null | 2009-11-09 22:56:53.18 UTC | 24 | 2021-07-09 08:46:13.89 UTC | 2021-07-09 08:46:13.89 UTC | null | 4,370,109 | null | 1,551 | null | 1 | 123 | javascript|internet-explorer|dom-events | 159,792 | <p>Similar to Ghommey's answer, but this also supports old versions of IE and Firefox.</p>
<pre><code>window.onbeforeunload = function (e) {
var message = "Your confirmation message goes here.",
e = e || window.event;
// For IE and Firefox
if (e) {
e.returnValue = message;
}
// For Safari
return mes... |
49,654,143 | Spring Security 5 : There is no PasswordEncoder mapped for the id "null" | <p>I am migrating from Spring Boot 1.4.9 to Spring Boot 2.0 and also to Spring Security 5 and I am trying to do authenticate via OAuth 2. But I am getting this error: </p>
<blockquote>
<p>java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null </p>
</blockquote>
<p>From the documenta... | 49,683,417 | 11 | 3 | null | 2018-04-04 14:51:52.86 UTC | 11 | 2022-09-01 19:25:44.263 UTC | 2018-04-05 09:07:36.457 UTC | null | 5,277,820 | null | 3,855,773 | null | 1 | 98 | java|spring|spring-boot|spring-security|spring-security-oauth2 | 134,856 | <p>When you are configuring the <code>ClientDetailsServiceConfigurer</code>, you have to also apply the new <a href="https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released#password-storage-format" rel="noreferrer">password storage format</a> to the client secret.</p>
<pre class="lang-java prettyprint-ove... |
49,436,161 | MAX() OVER PARTITION BY in Oracle SQL | <p>I am trying to utilize the MAX() OVER PARTITION BY function to evaluate the most recent receipt for a specific part that my company has bought. Below is an example table of the information for a few parts from the last year:</p>
<pre class="lang-none prettyprint-override"><code>| VEND_NUM | VEND_NAME | RECEIPT_N... | 49,436,307 | 4 | 4 | null | 2018-03-22 18:39:41.407 UTC | 2 | 2020-04-13 18:05:44.433 UTC | 2018-03-26 07:38:06.24 UTC | null | 330,315 | null | 4,876,561 | null | 1 | 5 | sql|oracle|window-functions | 71,536 | <p>Use window function <code>ROW_NUMBER() OVER (PARTITION BY receipt_item ORDER BY receipt_date DESC)</code> to assign a sequence number to each row. The row with the most recent <code>receipt_date</code> for a <code>receipt_item</code> will be numbered as 1.</p>
<pre><code>WITH
-- various other subqueries above...
... |
26,178,441 | How to toggle a highlighted selected item in a group list | <p>I have this in using Bootstrap:</p>
<pre><code> <ul class="list-group">
<li class="list-group-item active">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<... | 26,178,517 | 10 | 1 | null | 2014-10-03 11:51:04.837 UTC | 4 | 2021-06-09 14:55:22.657 UTC | 2014-10-14 23:10:48.497 UTC | null | 515,189 | null | 846,281 | null | 1 | 20 | javascript|html|twitter-bootstrap | 41,476 | <p>Here we go buddy. I have made a JSfiddle for ya</p>
<p><a href="http://jsfiddle.net/mgjk3xk2/" rel="noreferrer">demo</a></p>
<pre><code>$(function(){
console.log('ready');
$('.list-group li').click(function(e) {
e.preventDefault()
$that = $(this);
$that.parent().find('li').remove... |
49,075,027 | Angular - Dynamically add/remove validators | <p>I have a <code>FormGroup</code> defined like below:</p>
<pre><code>this.businessFormGroup: this.fb.group({
'businessType': ['', Validators.required],
'description': ['', Validators.compose([Validators.required, Validators.maxLength(200)])],
'income': ['']
})
</code></pre>
<p>Now when <code>businessTy... | 49,076,116 | 8 | 4 | null | 2018-03-02 18:13:42.32 UTC | 14 | 2021-08-31 14:58:06.367 UTC | null | null | null | null | 641,103 | null | 1 | 75 | angular|angular-forms|angular-validation | 98,503 | <p>If you are using Angular 12.2 or higher, you can use the <code>AbstractControl</code> methods <code>addValidators</code>, <code>removeValidators</code>, and <code>hasValidator</code>, <a href="https://angular.io/api/forms/AbstractControl#addvalidators" rel="noreferrer">as per the docs</a>:</p>
<pre><code>if(this.bus... |
7,149,923 | Android how to wait for code to finish before continuing | <p>I have a method called <code>hostPhoto()</code>; it basically uploads an image to a site and retrieves a link.
I then have an other method to post the link to a website.</p>
<p>Now the way Im' using this method is like this:</p>
<pre><code>String link = hostPhoto(); //returns a link in string format
post(text+" "... | 7,150,042 | 5 | 5 | null | 2011-08-22 15:37:59.883 UTC | 1 | 2016-11-22 10:34:23.33 UTC | 2011-08-23 10:51:03.613 UTC | null | 704,513 | null | 901,132 | null | 1 | 10 | java|android|hyperlink|android-asynctask | 43,211 | <p>You can use AsyncTask here,</p>
<p><a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="noreferrer">AsyncTask</a></p>
<p>By Using that you can execute the code of </p>
<p><code>hostPhoto()</code> </p>
<p>in doInBackground() and then execute the code of </p>
<p><code>post(text+" "+link... |
7,574,857 | Group array by subarray values | <p>I have an array of subarrays in the following format:</p>
<pre><code>array
(
a => array ( id = 20, name = chimpanzee )
b => array ( id = 40, name = meeting )
c => array ( id = 20, name = dynasty )
d => array ( id = 50, name = chocolate )
e => array ( id = 10, name = bananas )
f... | 7,574,916 | 5 | 0 | null | 2011-09-27 19:49:39.02 UTC | 16 | 2020-07-27 17:41:12.493 UTC | 2020-07-17 12:56:43.757 UTC | null | 1,378,646 | null | 476,426 | null | 1 | 64 | php|arrays|algorithm|sorting | 122,552 | <pre><code>$arr = array();
foreach ($old_arr as $key => $item) {
$arr[$item['id']][$key] = $item;
}
ksort($arr, SORT_NUMERIC);
</code></pre> |
14,080,758 | Reversing a linkedlist recursively in c | <p>The following code works fine when head is sent as a parameter to it. As I am new to C, I couldn't understand how it works. Help me out please.</p>
<pre><code>struct node *recursiveReverseLL(struct node *list)
{
struct node *revHead;
if (list == NULL || list->link == NULL)
{
return list;
... | 14,080,830 | 9 | 3 | null | 2012-12-29 10:25:34.877 UTC | 14 | 2020-05-07 07:01:54.673 UTC | 2012-12-29 18:42:09.34 UTC | null | 227,665 | null | 1,397,864 | null | 1 | 20 | c|recursion|linked-list|singly-linked-list | 78,065 | <p>The general recursive algorithm for this is:</p>
<ol>
<li><code>Divide</code> the list in <code>2</code> parts - first
node and rest of the list.</li>
<li>Recursively call reverse for the <code>rest</code> of the
linked list.</li>
<li>Link <code>rest</code> to <code>first</code>.</li>
<li>Fix <code>head</code> poin... |
14,006,150 | Android SearchView Icon | <p>I want to disable the Mag icon displayed inside the search view component. Any idea how to reference it and remove it or replace it with another drawable ?</p>
<p><img src="https://i.stack.imgur.com/0IqyN.png" alt="enter image description here"></p> | 14,006,295 | 10 | 4 | null | 2012-12-22 20:03:07.393 UTC | 4 | 2017-10-30 17:24:19.763 UTC | null | null | null | null | 155,196 | null | 1 | 29 | android|android-actionbar|actionbarsherlock|searchview | 25,408 | <p>In your theme:</p>
<pre><code><style name="Theme" parent="Your parent theme">
<item name="android:searchViewSearchIcon">@android:drawable/ic_search</item>
</style>
</code></pre>
<p><strong>Edit:</strong><br>
<code>searchViewSearchIcon</code> is a private attribute. This answer therefore doe... |
14,134,712 | Epplus not reading excel file | <p>Below is my code to read excel file.</p>
<p>Code.</p>
<pre><code>FileInfo newFile = new FileInfo("C:\\Excel\\SampleStockTakeExceptionReport.xls");
ExcelPackage pck = new ExcelPackage(newFile);
var ws = pck.Workbook.Worksheets.Add("Content");
ws.View.ShowGridLines = false;
ws.Cells["J12"].Value = "Test Write";
pck.... | 14,134,762 | 3 | 0 | null | 2013-01-03 07:27:47.277 UTC | 4 | 2019-02-23 08:00:10.99 UTC | null | null | null | null | 1,225,432 | null | 1 | 29 | c#|visual-studio-2010|epplus | 41,362 | <p>Epplus does not handle .xls (BIFF8 format) files as far as i know.</p>
<p>It handles the newer .xlsx (Open Office Xml) format.</p>
<p>You can use <a href="http://code.google.com/p/excellibrary/" rel="noreferrer">excellibrary</a> though as it works for xls files.</p> |
13,990,465 | 3d Numpy array to 2d | <p>I have a 3d matrix like this</p>
<pre><code>arange(16).reshape((4,2,2))
array([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11]],
[[12, 13],
[14, 15]]])
</code></pre>
<p>and would like to stack them in grid format, ending up with</p>
<pre><... | 13,990,648 | 1 | 0 | null | 2012-12-21 12:44:53.413 UTC | 13 | 2013-09-16 12:09:43.977 UTC | null | null | null | null | 1,470,604 | null | 1 | 30 | python|numpy|multidimensional-array | 38,127 | <pre><code>In [27]: x = np.arange(16).reshape((4,2,2))
In [28]: x.reshape(2,2,2,2).swapaxes(1,2).reshape(4,-1)
Out[28]:
array([[ 0, 1, 4, 5],
[ 2, 3, 6, 7],
[ 8, 9, 12, 13],
[10, 11, 14, 15]])
</code></pre>
<hr>
<p>I've posted more general functions for <a href="https://stackoverflow.com... |
13,916,726 | Using $index with the AngularJS 'ng-options' directive? | <p>Say that I bind an array to a <code>select</code> tag using the following:</p>
<pre><code><select ng-model="selData" ng-options="$index as d.name for d in data">
</code></pre>
<p>In this case, the associated <code>option</code> tags are assigned a sequence of index values: (0, 1, 2, ...). However, when I sel... | 13,917,351 | 5 | 0 | null | 2012-12-17 15:11:45.2 UTC | 16 | 2018-12-03 13:03:54.607 UTC | 2018-12-03 12:59:30.91 UTC | null | 1,497,596 | null | 1,910,294 | null | 1 | 61 | angularjs|html-select | 77,664 | <p>$index is defined for ng-repeat, not select. I think this explains the <code>undefined</code>. (So, no, this shouldn't work.)</p>
<p>Angular supports binding on the entire object. The documentation could be worded better to indicate this, but it does hint at it: "ngOptions ... should be used instead of ngRepeat ... |
28,882,878 | How to get last 24 hours from current time-stamp? | <p>I am trying to pull all data for the last 24 hours but starting from the current time. If the current date-time is 5/3 and the time is 11:30 then i want to pull the last 24 hours from 11:30. The data type for date field is <code>datetime</code> and it has only the date and time values without the seconds. Here is m... | 28,883,038 | 3 | 3 | null | 2015-03-05 16:32:31.523 UTC | 2 | 2015-03-07 14:56:13.253 UTC | 2015-03-07 14:48:03.77 UTC | null | 1,080,354 | null | 1,669,621 | null | 1 | 2 | sql|sql-server|tsql | 39,485 | <p>To be more explicit with your intentions, you may want to write your query like so:</p>
<pre><code> select Name, Location, myDate from myTable where myDate>= DATEADD(hh, -24, GETDATE())
</code></pre>
<p><a href="https://msdn.microsoft.com/en-us/library/ms186819.aspx" rel="noreferrer">SQL Server DATEADD</a></p> |
9,290,994 | SQL Conditional column data return in a select statement | <p>Here is a simplication of the problem: I have a select that looks like this:</p>
<pre><code>Select ID, Assignee, WorkStream from assignees;
</code></pre>
<p>And a snap shot of the data returned looked like this</p>
<pre><code>1|Joe Soap|Internal
2|Mrs Balls|External
</code></pre>
<p>What I would like to do is h... | 9,291,033 | 2 | 1 | null | 2012-02-15 09:42:41.403 UTC | 5 | 2012-02-15 09:50:22.393 UTC | null | null | null | null | 41,543 | null | 1 | 45 | sql | 99,259 | <p>You didn't mention your DBMS but a searched <code>CASE</code> statement works in all major DBMS's I know off.</p>
<pre><code>SELECT ID
, CASE WHEN WorkStream = 'Internal'
THEN WorkStream
ELSE Assignee
END AS Assignee
, Workstream
FROM assignees
</code></pr... |
19,645,655 | Disable Skrollr for mobile device ( <767px ) | <p>Firstly would like to thanks @prinzhorn for such an amazing and powerful library. My question: I have implemented a Skrollr parallax background to the header of my website but I would like to disable this feature when viewed on a mobile device, particularly iphones, etc. eg. (max-width: 767px).I was wondering what w... | 27,006,015 | 6 | 2 | null | 2013-10-28 21:44:58.747 UTC | 8 | 2017-09-20 08:38:13.79 UTC | null | null | null | null | 2,929,823 | null | 1 | 10 | jquery|html|parallax|skrollr | 18,499 | <p>Skrollr has its own mobile check function</p>
<pre><code>var s = skrollr.init();
if (s.isMobile()) {
s.destroy();
}
</code></pre> |
19,669,001 | Using len for text but discarding spaces in the count | <p>So, I am trying to create a program which counts the number of characters in a string which the user inputs, but I want to discard any spaces that the user enters.</p>
<pre><code>def main():
full_name = str(input("Please enter in a full name: ")).split(" ")
for x in full_name:
print(len(x))
main(... | 19,669,051 | 8 | 2 | null | 2013-10-29 20:59:18.13 UTC | 3 | 2021-03-07 10:10:58.043 UTC | 2019-05-20 09:42:49.837 UTC | null | 6,395,052 | null | 2,933,784 | null | 1 | 8 | python|python-3.x | 45,301 | <p>Count the length and subtract the number of spaces:</p>
<pre><code>>>> full_name = input("Please enter in a full name: ")
Please enter in a full name: john smith
>>> len(full_name) - full_name.count(' ')
9
>>> len(full_name)
</code></pre> |
903,228 | Why use precompiled headers (C/C++)? | <p>Why use precompiled headers?</p>
<hr/>
<p>Reading the responses, I suspect what I've been doing with them is kind of stupid:</p>
<pre><code>#pragma once
// Defines used for production versions
#ifndef PRODUCTION
#define eMsg(x) (x) // Show error messages
#define eAsciiMsg(x) (x)
#else
#define eMsg(x) (L"") // D... | 903,234 | 5 | 2 | null | 2009-05-24 06:35:24.347 UTC | 18 | 2021-11-28 15:47:45.193 UTC | 2019-06-29 18:05:12.46 UTC | null | 63,550 | null | 82,320 | null | 1 | 52 | c++|precompiled-headers | 45,366 | <p>It compiles a <em>lot</em> quicker. C++ compilation takes years without them. Try comparing some time in a large project!</p> |
1,032,376 | guid to base64, for URL | <p>Question: is there a better way to do that?</p>
<p>VB.Net</p>
<pre><code>Function GuidToBase64(ByVal guid As Guid) As String
Return Convert.ToBase64String(guid.ToByteArray).Replace("/", "-").Replace("+", "_").Replace("=", "")
End Function
Function Base64ToGuid(ByVal base64 As String) As Guid
Dim guid As G... | 1,032,451 | 5 | 12 | null | 2009-06-23 12:51:09.987 UTC | 13 | 2022-09-14 08:12:04.343 UTC | 2015-12-21 18:48:55.297 UTC | null | 156,604 | null | 40,868 | null | 1 | 57 | c#|.net|vb.net|guid|base64 | 46,675 | <p>I understand that the reason you are clipping == in the end is that because you can be certain that for GUID (of 16 bytes), encoded string will <em>always</em> end with ==. So 2 characters can be saved in every conversion.</p>
<p>Beside the point @Skurmedal already mentioned (should throw an exception in case of in... |
435,964 | How do I find duplicate entries in a database table? | <p>The following query will display all Dewey Decimal numbers that have been duplicated in the "book" table:</p>
<pre><code>SELECT dewey_number,
COUNT(dewey_number) AS NumOccurrences
FROM book
GROUP BY dewey_number
HAVING ( COUNT(dewey_number) > 1 )
</code></pre>
<p>However, what I'd like to do is have my query ... | 435,991 | 6 | 3 | null | 2009-01-12 16:23:54.843 UTC | 10 | 2019-02-08 06:47:57.903 UTC | 2009-01-12 16:29:12.43 UTC | Huuuze | 10,040 | Huuuze | 10,040 | null | 1 | 25 | sql|postgresql | 98,621 | <p>A nested query can do the job.</p>
<pre><code>SELECT author_last_name, dewey_number, NumOccurrences
FROM author INNER JOIN
( SELECT author_id, dewey_number, COUNT(dewey_number) AS NumOccurrences
FROM book
GROUP BY author_id, dewey_number
HAVING ( COUNT(dewey_number) > 1 ) ) AS dupli... |
1,202,839 | get request data in Django form | <p>Is it possible to get request.user data in a form class? I want to clean an email address to make sure that it's unique, but if it's the current users email address then it should pass.</p>
<p>This is what I currently have which works great for creating new users, but if I want to edit a user I run into the proble... | 1,204,136 | 6 | 0 | null | 2009-07-29 20:29:51.23 UTC | 24 | 2021-12-13 11:56:13.877 UTC | 2016-11-14 21:30:03.22 UTC | null | 1,022,923 | null | 74,474 | null | 1 | 57 | python|django | 71,759 | <p>As ars and Diarmuid have pointed out, you can pass <code>request.user</code> into your form, and use it in validating the email. Diarmuid's code, however, is wrong. The code should actually read:</p>
<pre><code>from django import forms
class UserForm(forms.Form):
email_address = forms.EmailField(
widget... |
391,130 | What is an HttpHandler in ASP.NET | <p>What is an HttpHandler in ASP.NET? Why and how is it used?</p> | 391,211 | 6 | 1 | null | 2008-12-24 09:52:09.797 UTC | 30 | 2019-03-13 09:57:18.497 UTC | 2013-07-09 20:29:18.033 UTC | null | 1,066,291 | Nikola Stjelja | 32,582 | null | 1 | 68 | asp.net|httphandler|ihttphandler|ihttpasynchandler | 106,522 | <p>In the simplest terms, an ASP.NET HttpHandler is a class that implements the <code>System.Web.IHttpHandler</code> interface. </p>
<p>ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. Th... |
95,800 | How do I add FTP support to Eclipse? | <p>I'm using Eclipse PHP Development Tools. What would be the easiest way to access a file or maybe create a remote project trough FTP and maybe SSH and SFTP?.</p> | 6,944,100 | 6 | 2 | null | 2008-09-18 19:07:11.15 UTC | 37 | 2015-04-11 09:26:12.787 UTC | 2011-10-15 11:31:35.69 UTC | null | 1,288 | levhita | 7,946 | null | 1 | 93 | eclipse|ftp|eclipse-pdt | 149,378 | <p>Eclipse natively supports FTP and SSH. Aptana is not necessary.</p>
<p>Native FTP and SSH support in Eclipse is in the "Remote System Explorer End-User Runtime" Plugin.</p>
<p>Install it through Eclipse itself. These instructions may vary slightly with your version of Eclipse:</p>
<ol>
<li>Go to 'Help' -> 'Insta... |
31,103,813 | Executing non-database actions in a transaction in Slick 3 | <p>I'm having trouble understanding the new Slick <code>DBIOAction</code> API, which does not seem to have a lot of examples in the docs. I am using Slick 3.0.0, and I need to execute some DB actions and also some calculations with the data received from the database, but all of those actions have to be done inside a s... | 31,194,089 | 1 | 2 | null | 2015-06-28 19:20:47.137 UTC | 10 | 2015-07-12 12:54:49.533 UTC | 2015-07-12 12:54:49.533 UTC | null | 930,450 | null | 1,336,841 | null | 1 | 26 | database|scala|slick|slick-3.0 | 4,055 | <p>Try it this way :</p>
<pre><code>val compositeAction = (for {
rawTypes <- TableQuery[DBType].result
pair <- DBIO.sequence(rawTypes.groupBy(_.projectId).toSeq.map(group => DBIO.successful(group)))
counts <- DBIO.sequence(pair.head._2.map(aType => sql"""select count(*) from messages where type_id... |
21,309,366 | AngularJS ui-router $state.go('^') only changing URL in address bar, but not loading controller | <p>I am trying to create a "Todo App" with angularjs <code>ui-router</code>. It has 2 columns:</p>
<ul>
<li>Column 1: list of Todos</li>
<li>Column 2: Todo details or Todo edit form</li>
</ul>
<p>In the Edit and Create controller after saving the Todo I would like to reload the list to show the appropriate changes. T... | 21,349,764 | 3 | 6 | null | 2014-01-23 13:19:38.727 UTC | 8 | 2016-09-25 18:11:22.697 UTC | 2016-09-25 18:11:22.697 UTC | null | 4,373,584 | null | 2,270,404 | null | 1 | 11 | javascript|angularjs|angular-ui-router | 58,041 | <p>Huge thanks for Radim Köhler for pointing out that <code>$scope</code> is inherited. With 2 small changes I managed to solve this. See below code, I commented where I added the extra lines. Now it works like a charm.</p>
<pre><code>var TodoApp = angular.module('TodoApp', ['ngResource', 'ui.router'])
.config(fun... |
21,122,303 | How to list all Linux environment variables including LD_LIBRARY_PATH | <p>How to list all the environment variables in Linux?</p>
<p>When I type the command <code>env</code> or <code>printenv</code> it gives me lots of variables, but some variables like <code>LD_LIBRARY_PATH</code> and <code>PKG_CONFIG</code> don't show up in this list.</p>
<p>I want to type a command that list all the ... | 21,125,235 | 3 | 7 | null | 2014-01-14 19:30:51.317 UTC | 9 | 2015-09-29 20:58:13.423 UTC | null | null | null | null | 1,004,172 | null | 1 | 18 | linux|ubuntu|centos | 62,944 | <p><code>env</code> does list all environment variables. </p>
<p>If <code>LD_LIBRARY_PATH</code> is not there, then that variable was not declared; or was declared but not <code>export</code>ed, so that child processes do not inherit it.</p>
<p>If you are setting <code>LD_LIBRARY_PATH</code> in your shell start-up fi... |
69,437,526 | What is this odd sorting algorithm? | <p>Some <a href="https://stackoverflow.com/a/69435932/16759116">answer</a> originally had this sorting algorithm:</p>
<pre class="lang-none prettyprint-override"><code>for i from 0 to n-1:
for j from 0 to n-1:
if A[j] > A[i]:
swap A[i] and A[j]
</code></pre>
<p>Note that both <code>i</code> a... | 69,438,471 | 5 | 27 | null | 2021-10-04 14:14:22.687 UTC | 17 | 2021-10-24 16:59:30.557 UTC | 2021-10-10 23:43:29.963 UTC | null | 13,990,016 | null | 16,759,116 | null | 1 | 103 | python|algorithm|sorting | 10,078 | <p>To prove that it's correct, you have to find some sort of invariant. Something that's true during every pass of the loop.</p>
<p>Looking at it, after the very first pass of the inner loop, the <em>largest</em> element of the list will actually be in the <em>first</em> position.</p>
<p>Now in the second pass of the i... |
16,599,691 | Basic Syntax for passing a Scanner object as a Parameter in a Function | <p>Here is what I wrote which is pretty basic :</p>
<pre><code>import java.util.Scanner;
public class Projet {
/**
* @param args
* @param Scanner
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter a digit");
Scanner... | 16,599,700 | 1 | 0 | null | 2013-05-17 00:42:12.013 UTC | 4 | 2015-07-22 15:02:32.87 UTC | 2013-05-17 01:23:09.437 UTC | null | 1,791,497 | null | 1,791,497 | null | 1 | 2 | java|function|parameters|arguments|java.util.scanner | 65,797 | <p>You need to pass the actual variable name <code>in</code> when you call the method, not the class name <code>Scanner</code>.</p>
<pre><code>getChoice(in);
</code></pre>
<p>instead of</p>
<pre><code>getChoice(Scanner);
</code></pre>
<p>Incidentally, your <code>getChoice</code> method won't compile as shown. Just... |
1,625,455 | itext positioning text absolutely | <p>In itext I have a chunk/phrase/paragraph (I dont mind which) and I want to position some where else on the page e.g. at 300 x 200. How would I do this?</p> | 1,631,956 | 5 | 0 | null | 2009-10-26 15:23:04.123 UTC | 3 | 2018-09-17 06:58:52.373 UTC | 2009-10-27 08:59:54.143 UTC | null | 147,683 | null | 147,683 | null | 1 | 24 | java|.net|itextsharp|itext | 39,708 | <p>In the end I wrote my own method to do it.</p>
<pre><code>private void PlaceChunck(String text, int x, int y) {
PdfContentByte cb = writer.DirectContent;
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.SaveState();
cb.BeginText();
... |
2,035,959 | How to convert a float to an Int by rounding to the nearest whole integer | <p>Is there a way to convert a <code>float</code> to an <code>Int</code> by rounding to the nearest possible whole integer? </p> | 2,036,049 | 5 | 1 | null | 2010-01-10 03:15:37.717 UTC | 6 | 2020-02-12 01:58:14.08 UTC | 2014-05-12 16:56:14.857 UTC | null | 1,580,941 | null | 231,964 | null | 1 | 25 | type-conversion | 51,357 | <p>Actually Paul Beckingham's answer isn't quite correct. If you try a negative number like -1.51, you get -1 instead of -2. </p>
<p>The functions round(), roundf(), lround(), and lroundf() from math.h work for negative numbers too. </p> |
1,366,179 | How to display XML in a HTML page as a collapsible and expandable tree using Javascript? | <p>How to display a XML document in a HTML page as a collapsible and expandable tree?</p>
<p>I'd like to display a XML document inside a HTML page as a nicely pretty printed tree structure. I'd like to be able to expand and collapse tree branches. For example Firefox browser does this when you load a plain XML file. I... | 1,366,270 | 5 | 0 | null | 2009-09-02 06:56:02.647 UTC | 10 | 2017-05-16 15:55:07.803 UTC | 2013-07-19 18:28:58.543 UTC | null | 1,431 | null | 1,431 | null | 1 | 33 | javascript|html|xml|tree | 79,962 | <p><a href="http://www.codeproject.com/KB/scripting/Exsead2.aspx" rel="noreferrer">Creating An XML Viewer With JScript - Exsead XML Power Scripting</a></p>
<p><a href="http://www.levmuchnik.net/Content/ProgrammingTips/WEB/XMLDisplay/DisplayXMLFileWithJavascript.html" rel="noreferrer">Display XML Files with Javascript<... |
2,322,366 | How do I serve up an Unauthorized page when a user is not in the Authorized Roles? | <p>I am using the <code>Authorize</code> attribute like this:</p>
<pre><code>[Authorize (Roles="Admin, User")]
Public ActionResult Index(int id)
{
// blah
}
</code></pre>
<p>When a user is not in the specified roles, I get an error page (resource not found). So I put the <code>HandleError</code> attribute in als... | 2,322,403 | 5 | 2 | null | 2010-02-23 22:50:10.7 UTC | 16 | 2017-09-29 09:08:37.817 UTC | null | null | null | null | 102,937 | null | 1 | 41 | c#|asp.net-mvc|security|roles | 28,398 | <p>Add something like this to your web.config:</p>
<pre><code><customErrors mode="On" defaultRedirect="~/Login">
<error statusCode="401" redirect="~/Unauthorized" />
<error statusCode="404" redirect="~/PageNotFound" />
</customErrors>
</code></pre>
<p>You should obviously create the ... |
1,766,067 | What is the most useable VI/Vim plugin for Eclipse? | <p>I used to be a huge fan of Intelli-J and there is a fantastic VI plugin for Idea. Now I'm shifting to the Spring Source Tool Suite for my primary IDE and need to find a VI plugin that will allow me to work just as effectively.</p>
<p>What plugin are people using?</p> | 1,766,207 | 5 | 1 | null | 2009-11-19 19:52:02.36 UTC | 13 | 2014-08-06 18:20:53.023 UTC | 2012-11-10 00:11:51.39 UTC | null | 834,176 | null | 1,129,162 | null | 1 | 46 | eclipse|vim|vi | 30,656 | <p>I rate <a href="http://www.viplugin.com/" rel="noreferrer">viPlugin</a> highly enough to pay the small fee for the licensed edition (not licensing it means you get popups every so often, IIRC).</p>
<p>In my opinion it works better than the equivalent Intellij plugin.</p> |
1,639,291 | How do I add a newline to command output in PowerShell? | <p>I run the following code using PowerShell to get a list of add/remove programs from the registry:</p>
<pre><code>Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object -Process { Write-Output $_.GetValue("DisplayName") } `
| Out-File addrem.txt
</code></pre>
<p>I w... | 1,641,787 | 5 | 1 | null | 2009-10-28 18:45:04.363 UTC | 10 | 2018-12-10 10:31:29.95 UTC | 2014-12-27 14:37:45.7 UTC | null | 63,550 | null | 198,358 | null | 1 | 80 | powershell|newline | 424,331 | <p>Or, just set the <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6#ofs" rel="noreferrer">output field separator</a> (OFS) to double newlines, and then make sure you get a string when you send it to file:</p>
<pre><code>$OFS = "`r... |
1,351,966 | Is there a pure CSS way to make an input transparent? | <p>How can I make this input transparent?</p>
<pre><code><input type="text" class="foo">
</code></pre>
<p>I've tried this but it doesn't work.</p>
<pre><code>background:transparent url(../img/transpSmall.png) repeat scroll 0 0;
</code></pre> | 1,351,969 | 7 | 4 | null | 2009-08-29 17:44:34.847 UTC | 18 | 2020-09-04 16:57:44.543 UTC | 2009-08-31 11:56:18.317 UTC | null | 5,640 | null | 26,004 | null | 1 | 64 | html|css | 170,922 | <pre><code>input[type="text"]
{
background: transparent;
border: none;
}
</code></pre>
<p>Nobody will even know it's there.</p> |
2,251,290 | storing money amounts in mysql | <p>I want to store 3.50 into a mysql table. I have a float that I store it in, but it stores as 3.5, not 3.50. How can I get it to have the trailing zero?</p> | 2,251,311 | 7 | 0 | null | 2010-02-12 11:04:25.037 UTC | 22 | 2017-06-25 03:02:59.883 UTC | 2012-05-09 16:33:04.35 UTC | null | 44,390 | null | 175,562 | null | 1 | 65 | mysql|floating-point|currency|fixed-point | 54,310 | <p>Do not store money values as float, use the DECIMAL or NUMERIC type:</p>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html" rel="noreferrer">Documentation for MySQL Numeric Types</a></p>
<p>EDIT & clarification:</p>
<p>Float values are vulnerable to rounding errors are they have limited pr... |
2,025,789 | Preserving a reference to "this" in JavaScript prototype functions | <p>I'm just getting into using prototypal JavaScript and I'm having trouble figuring out how to preserve a <code>this</code> reference to the main object from inside a prototype function when the scope changes. Let me illustrate what I mean (I'm using jQuery here):</p>
<pre><code>MyClass = function() {
this.element ... | 2,025,839 | 7 | 0 | null | 2010-01-08 05:51:49.663 UTC | 27 | 2015-02-10 11:05:35.31 UTC | 2011-12-27 17:30:21.827 UTC | null | 938,089 | null | 242,493 | null | 1 | 93 | javascript|oop|scope|this|prototype-programming | 70,014 | <p>For preserving the context, the <code>bind</code> method is really useful, it's now part of the recently released <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="noreferrer">ECMAScript 5th Edition</a> Specification, the implementation of this function is simple (only 8 lines long... |
1,735,540 | Creating a Pareto Chart with ggplot2 and R | <p>I have been struggling with how to make a <a href="http://en.wikipedia.org/wiki/Pareto_chart" rel="nofollow noreferrer">Pareto Chart</a> in R using the ggplot2 package. In many cases when making a bar chart or histogram we want items sorted by the X axis. In a Pareto Chart we want the items ordered descending by the... | 1,736,141 | 8 | 2 | null | 2009-11-14 20:46:51.707 UTC | 12 | 2019-12-17 03:10:56.28 UTC | 2019-05-08 19:04:52.697 UTC | null | 4,751,173 | null | 37,751 | null | 1 | 20 | r|graph|ggplot2 | 24,135 | <p>The bars in ggplot2 are ordered by the ordering of the levels in the factor.</p>
<pre><code>val$State <- with(val, factor(val$State, levels=val[order(-Value), ]$State))
</code></pre> |
1,883,425 | Android Borderless Dialog | <p>I have created an AlertDialog using AlertDialog.Builder, but the Dialog border takes up too much space on the screen. How do I remove the border? I have tried using another Activity to emulate the dialog with a transparent background, but the dialog is used repeatedly, and creating a new Activity every time introduc... | 1,892,367 | 8 | 0 | null | 2009-12-10 19:37:50.24 UTC | 14 | 2014-04-16 19:33:39.713 UTC | 2017-05-23 12:06:52.56 UTC | null | -1 | null | 196,980 | null | 1 | 28 | android|dialog | 34,632 | <p>Alright, I'll answer my own question. Basically, instead of using AlertDialog.Builder, create a regular Dialog using it's constructor, and use a suitable theme instead of the default Dialog theme.</p>
<p>So your code would look something like this:</p>
<pre><code>Dialog dialog = new Dialog(this, android.R.style.Th... |
2,171,969 | Determine whether or not there exist two elements in Set S whose sum is exactly x - correct solution? | <p>Taken from Introduction to Algorithms</p>
<blockquote>
<p>Describe a Θ(n lg n)-time algorithm
that, given a set S of n integers and
another integer x, determines whether
or not there exist two elements in S
whose sum is exactly x.</p>
</blockquote>
<p>This is my best solution implemented in Java so far:<... | 2,172,030 | 8 | 5 | null | 2010-01-31 14:18:05.337 UTC | 13 | 2017-12-11 22:44:37.737 UTC | 2012-05-11 05:22:32.287 UTC | null | 227,665 | null | 1,178,669 | null | 1 | 36 | java|arrays|algorithm | 33,759 | <p>Your solution seems fine. Yes you need to sort because its a pre requisite for binary search. You can make a slight modification to your logic as follows:</p>
<pre><code>public static boolean test(int[] a, int val)
{
Arrays.sort(a);
int i = 0; // index of first element.
int j = a.length - 1... |
2,295,845 | How can I remove the location hash without causing the page to scroll? | <p>Is it possible to remove the hash from <code>window.location</code> without causing the page to jump-scroll to the top? I need to be able to modify the hash without causing any jumps.</p>
<p>I have this:</p>
<pre><code>$('<a href="#123">').text('link').click(function(e) {
e.preventDefault();
window.locat... | 2,295,896 | 8 | 4 | null | 2010-02-19 11:18:46.277 UTC | 26 | 2018-10-04 15:30:39.85 UTC | 2012-04-03 08:41:40.46 UTC | null | 94,197 | null | 210,578 | null | 1 | 80 | javascript|jquery|fragment-identifier | 80,489 | <p>I believe if you just put in a dummy hash it won't scroll as there is no match to scroll to.</p>
<pre><code><a href="#A4J2S9F7">No jumping</a>
</code></pre>
<p>or</p>
<pre><code><a href="#_">No jumping</a>
</code></pre>
<p><code>"#"</code> by itself is equivalent to <code>"_top"</code> th... |
1,625,105 | How to write `is_complete` template? | <p>After answering <a href="https://stackoverflow.com/questions/1611771/deleting-object-with-private-destructor">this</a> question I was trying to find <code>is_complete</code> template in Boost library and I realized that there is no such template in Boost.TypeTraits. Why there is no such template in Boost library? Ho... | 1,956,217 | 9 | 11 | null | 2009-10-26 14:21:54.4 UTC | 11 | 2021-09-18 13:12:41.343 UTC | 2021-08-17 08:30:42.993 UTC | null | 123,111 | null | 123,111 | null | 1 | 29 | c++|templates|typetraits|c++03 | 4,862 | <p>The answer given by Alexey Malistov can be used on MSVC with a minor modification:</p>
<pre><code>namespace
{
template<class T, int discriminator>
struct is_complete {
static T & getT();
static char (& pass(T))[2];
static char pass(...);
static const bool valu... |
1,836,742 | Using git, how do I ignore a file in one branch but have it committed in another branch? | <p>I've got a project that I'm deploying to <a href="http://heroku.com" rel="noreferrer">Heroku</a>. The source code tree includes a bunch of mp3 files (the website will be for a recording project I was heavily involved with). </p>
<p>I'd like to put the source code for it up on <a href="http://github.com" rel="noref... | 4,044,387 | 9 | 8 | null | 2009-12-02 23:55:23.11 UTC | 87 | 2022-05-27 07:37:34.443 UTC | 2017-05-02 00:00:57.733 UTC | null | 4,694,621 | null | 29,262 | null | 1 | 180 | git|gitignore | 90,546 | <blockquote>
<p>This solution appears to work only for certain, patched versions of git. See <a href="https://stackoverflow.com/a/39280410/5794048">a new answer pointing to workarounds</a> and <a href="https://stackoverflow.com/a/39285099/5794048">another answer and subsequent comments</a> for a hint which versions m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.