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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,667,630 | How do I convert a String object into a Hash object? | <p>I have a string which looks like a hash:</p>
<pre><code>"{ :key_a => { :key_1a => 'value_1a', :key_2a => 'value_2a' }, :key_b => { :key_1b => 'value_1b' } }"
</code></pre>
<p>How do I get a Hash out of it? like:</p>
<pre><code>{ :key_a => { :key_1a => 'value_1a', :key_2a => 'value_2a' }, :... | 1,667,683 | 16 | 2 | null | 2009-11-03 14:24:21.49 UTC | 41 | 2022-05-17 18:44:59.953 UTC | null | null | null | null | 100,466 | null | 1 | 162 | ruby | 232,447 | <p>The string created by calling <code>Hash#inspect</code> can be turned back into a hash by calling <code>eval</code> on it. However, this requires the same to be true of all of the objects in the hash.</p>
<p>If I start with the hash <code>{:a => Object.new}</code>, then its string representation is <code>"{:a=&g... |
1,646,580 | Get Visual Studio to run a T4 Template on every build | <p>How do I get a T4 template to generate its output on every build? As it is now, it only regenerates it when I make a change to the template.</p>
<p>I have found other questions similar to this:</p>
<p><a href="https://stackoverflow.com/questions/1293320/t4-transformation-and-build-order-in-visual-studio">T4 trans... | 3,041,089 | 22 | 5 | null | 2009-10-29 21:14:03.517 UTC | 78 | 2022-03-18 16:57:05.75 UTC | 2017-12-12 22:58:44.5 UTC | null | 41,956 | null | 16,012 | null | 1 | 181 | visual-studio|tfs|msbuild|t4 | 71,145 | <p>I used JoelFan's answer to come up w/ this. I like it better because you don't have to remember to modify the pre-build event every time you add a new .tt file to the project.</p>
<ul>
<li>add TextTransform.exe to your <code>%PATH%</code></li>
<li>created a batch file named transform_all.bat (see below)</li>
<li>cr... |
8,808,794 | Get hash key and convert into string ruby | <p>Example Hash</p>
<pre><code>hash = {:key => ["val1", "val2]}
</code></pre>
<p>When I did this on rails 3.0.7, it was fine.</p>
<pre><code>> hash.keys.to_s
=> "key"
> hash[hash.keys.to_s]
=> ["val1", "val2"]
</code></pre>
<p>But if I do this with rails 3.1.3, it isn't.</p>
<pre><code>> hash.k... | 8,809,180 | 2 | 2 | null | 2012-01-10 18:50:50.657 UTC | 3 | 2012-01-10 19:29:09.07 UTC | null | null | null | null | 760,363 | null | 1 | 15 | ruby-on-rails-3 | 42,541 | <p>Did you upgrade Ruby as well as Rails? I think this is a change between 1.8 and 1.9</p>
<p>Try <code>hash.keys.first.to_s</code> (if there's always only one key) or <code>hash.keys.join</code></p> |
18,083,239 | What happened to "Always refresh from server" in IE11 developer tools? | <p>Do the F12 developer tools in Internet Explorer 11 also have the "Always refresh from server" feature of the developer tools in IE 8-10?</p>
<p>I see the "Clear browser cache... (Ctrl + R)" button on the <a href="http://msdn.microsoft.com/en-us/library/ie/dn255004.aspx" rel="noreferrer">Network tool</a>, but clicki... | 18,723,232 | 5 | 0 | null | 2013-08-06 14:39:21.477 UTC | 8 | 2016-03-12 20:23:06.393 UTC | 2013-08-06 17:01:41.58 UTC | null | 168,868 | null | 196,844 | null | 1 | 102 | internet-explorer|ie-developer-tools|internet-explorer-11|ie11-developer-tools | 79,732 | <p><img src="https://i.stack.imgur.com/92Rof.png" alt="Refresh from Server button"></p>
<p>It seems they have added the "Always Refresh from Server" button in the RTM version of IE11 that ships with Windows 8.1</p>
<p>It is found in the Network tab of the developer tools, 3rd button from the left.</p> |
17,755,859 | how do i call dictionary values from within a list of dictionaries ? | <p>i am trying to learn python with codeacademy.
the assignment was make 3 dictionaries (for each student) and then make a list of the 3 dictionaries. then, i am supposed to print out all the data in the list. </p>
<p>i tried to call out the values the same way i used for a dictionary by itself (lloyd[values]), but t... | 17,756,026 | 6 | 1 | null | 2013-07-19 21:33:04.87 UTC | 3 | 2016-09-04 17:22:38.867 UTC | null | null | null | null | 1,476,390 | null | 1 | 0 | python|list|dictionary | 39,328 | <p>If you want to print all the information for each student, you have to loop over the students and the values stored in the dictionaries:</p>
<pre><code>students = [lloyd, alice, tyler]
for student in students:
for value in student:
print value, "is", student[value]
</code></pre>
<p>Note, however, that ... |
17,973,970 | How can I solve "java.lang.NoClassDefFoundError"? | <p>I've tried both the examples in Oracle's <a href="http://docs.oracle.com/javase/tutorial" rel="noreferrer">Java Tutorials</a>. They both compile fine, but at run time, both come up with this error:</p>
<pre class="lang-none prettyprint-override"><code>Exception in thread "main" java.lang.NoClassDefFoundErr... | 17,974,068 | 34 | 11 | null | 2013-07-31 15:00:27.523 UTC | 77 | 2022-08-19 04:44:28.88 UTC | 2021-05-26 09:58:26.967 UTC | null | 63,550 | null | 2,397,327 | null | 1 | 269 | java|exception|package|noclassdeffounderror | 1,471,076 | <p>After you compile your code, you end up with <code>.class</code> files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The <code>NoClassDefFoundError</code> indicates that the classloader (in this case <code>java.net.URLClassLoader</code>), which is r... |
44,532,077 | switch with var/null strange behavior | <p>Given the following code:</p>
<pre><code>string someString = null;
switch (someString)
{
case string s:
Console.WriteLine("string s");
break;
case var o:
Console.WriteLine("var o");
break;
default:
Console.WriteLine("default");
break;
}
</code></pre>
<p>W... | 44,532,658 | 3 | 9 | null | 2017-06-13 21:44:30.933 UTC | 14 | 2017-12-26 14:58:21.983 UTC | 2017-06-23 15:31:14.913 UTC | null | 1,159,478 | null | 4,607,317 | null | 1 | 91 | c#|null|switch-statement|var|c#-7.0 | 4,188 | <p>Inside a pattern matching <code>switch</code> statement using a <code>case</code> for an explicit type is asking if the value in question is of that specific type, or a derived type. It's the exact equivalent of <code>is</code> </p>
<pre><code>switch (someString) {
case string s:
}
if (someString is string)
</c... |
6,983,589 | Target first element of DIV using CSS | <p>I have a WYSIWYG editor inside of a table that is placed within a div, as such...</p>
<pre><code><div class="mydiv">
<li>
<table>My WYSIWYG</table>
</li>
</table>
</code></pre>
<p>Inside my WYSIWYG there are more tables however I only want to target the first tab... | 6,983,615 | 4 | 4 | null | 2011-08-08 14:23:25.367 UTC | 2 | 2013-01-29 21:08:01.35 UTC | null | null | null | null | 766,532 | null | 1 | 5 | css|html | 43,869 | <p>You need <code>.mydiv li table:first-child</code>.</p>
<p><a href="http://www.w3.org/TR/css3-selectors/#first-child-pseudo" rel="noreferrer">More information</a>.</p>
<p><code>:first-child</code> works in IE7+ and all modern browsers.</p>
<p><a href="http://jsfiddle.net/74eSh/" rel="noreferrer">An example.</a> </... |
6,336,441 | How to scroll WPF ScrollViewer's content to specific location | <p>I am writing my custom WPF ItemsControl to display a list of item. The items are shown embedded inside a ScrollViewer:</p>
<pre class="lang-xml prettyprint-override"><code><Style TargetType="MyCustomItemsControl">
<Setter Property="Template">
<Setter.Value>
<... | 6,336,745 | 4 | 0 | null | 2011-06-13 21:13:48.923 UTC | 4 | 2019-07-02 09:23:24.15 UTC | 2014-03-06 07:11:16.083 UTC | null | 546,730 | null | 449,056 | null | 1 | 22 | wpf|mouse|position|scrollviewer | 40,664 | <p>Something like the following:</p>
<pre><code>var sv = (ScrollViewer)Template.FindName("PART_MyScrollViewer", this); // If you do not already have a reference to it somewhere.
var ip = (ItemsPresenter)sv.Content;
var point = item.TranslatePoint(new Point() - (Vector)e.GetPosition(sv), ip);
sv.ScrollToVerticalOffset(... |
23,611,688 | keytool error: java.lang.Exception: Failed to establish chain from reply | <p>Generate keystore:</p>
<pre><code>keytool -genkey -alias tomcat -keyalg RSA -keystore my.keystore -keysize 2048
</code></pre>
<p>Generate certificate signing request (CSR):</p>
<pre><code>keytool -certreq -alias tomcat -keyalg RSA -file my.csr -keystore my.keystore
</code></pre>
<p>I then go off to my hosting pr... | 23,612,624 | 6 | 2 | null | 2014-05-12 14:26:37.02 UTC | 5 | 2017-12-13 15:12:50.787 UTC | 2016-08-18 17:21:42.737 UTC | null | 371,184 | null | 669,645 | null | 1 | 33 | tomcat|ssl-certificate|keytool | 115,157 | <p>I've just discovered that the files godaddy supplied with my certificate are both intermediate certificates (in fact they seem to both be the same intermediate certificate).</p>
<p>I got the correct root and intermediate certificates by double clicking on my certificate and looking at the certificate path... from ... |
18,609,397 | What's the difference between sockaddr, sockaddr_in, and sockaddr_in6? | <p>I know that sockaddr_in is for IPv4, and sockaddr_in6 for IPv6. The confusion to me is the difference between sockaddr and sockaddr_in[6]. </p>
<p>Some functions accept <code>sockaddr</code> and some functions accept <code>sockaddr_in</code> or <code>sockaddr_in6</code>, so:</p>
<ul>
<li>what's the rule? </li>
<l... | 18,626,969 | 2 | 1 | null | 2013-09-04 08:54:03.617 UTC | 26 | 2019-04-24 07:01:07.643 UTC | 2019-04-24 07:01:07.643 UTC | null | 1,564,946 | null | 2,428,052 | null | 1 | 53 | c++|c|api|network-programming | 45,492 | <p>I don't want to answer my question. But to give more information here which might be useful to other people, I decide to answer my question.</p>
<p>After dig into the source code of <code>linux</code>. Following is my finding, there are possible multiple protocol which all implement the <code>getsockname</code>. An... |
34,238,399 | Function to extract remaining string after last backslash | <p>I need an Excel function that can extract a string after last <code>\</code> from a path and if no <code>\</code> found then take the whole string. For example:</p>
<pre><code>D:\testing\rbc.xls output will be rbc.xls
D:\home\testing\test1\script1.sql output will be script.sql
script 3.... | 34,239,186 | 1 | 5 | null | 2015-12-12 09:40:14.16 UTC | 3 | 2020-06-29 19:11:54.983 UTC | 2020-06-29 19:11:54.983 UTC | null | 8,422,953 | null | 664,481 | null | 1 | 9 | excel|vba|replace|excel-formula|find-replace | 45,514 | <p>1.Change all the "\" to spaces, the number of spaces is determined by the number of characters in the cell </p>
<p>2.Use the right function to extract the right of the string based on the number of characters in the cell. </p>
<p>3.Use the trim function to remove the spaces.</p>
<p><a href="https://i.stack.imgu... |
51,116,381 | Convert Firebase Firestore Timestamp to Date (Swift)? | <p>I have a date saved in a Firestore field as a timestamp that I want to convert to a Date in Swift:</p>
<p><code>June 19,2018 at 7:20:21 PM UTC-4</code></p>
<p>I tried the following but I get an error:</p>
<p><code>let date = Date(timeIntervalSince1970: postTimestamp as! TimeInterval)</code></p>
<p>Error:</p>
<p... | 51,116,425 | 1 | 3 | null | 2018-06-30 15:53:29.7 UTC | 11 | 2018-06-30 15:59:57.017 UTC | null | null | null | null | 2,089,684 | null | 1 | 36 | swift|firebase|google-cloud-firestore | 20,926 | <p>Either do:</p>
<pre><code>let date = postTimestamp.dateValue()
</code></pre>
<p>or you could do:</p>
<pre><code>let date = Date(timeIntervalSince1970: postTimestamp.seconds)
</code></pre>
<p>See the <a href="https://firebase.google.com/docs/reference/swift/firebasefirestore/api/reference/Classes/Timestamp" rel="... |
41,197,546 | Typescript Select Ids from object | <p>I am new to Typescript. I want to select ids from observable</p>
<p>This is my observable</p>
<pre><code>let myObj = [{
"id": 1,
"text": "Mary"
}, {
"id": 2,
"text": "Nancy"
}, {
"id": 3,
"text": "Paul"
}, {
"id": 4,
"text": "Cheryl"
}, {
"id": 5,
"text": "Frances"
}]
</code></pre>
<p>Expected... | 41,197,583 | 2 | 3 | null | 2016-12-17 10:18:48.197 UTC | 3 | 2016-12-17 13:40:41.773 UTC | 2016-12-17 10:22:02.513 UTC | null | 3,001,761 | null | 4,728,339 | null | 1 | 25 | arrays|angular|typescript|rxjs|rxjs5 | 68,703 | <p>Use <code>Array#map</code> to map one array to another:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const myObj = [{"id":1,"text":"Mary"},{"id":2,"text":"Nancy"},{"id":... |
16,363,292 | Label width in tkinter | <p>I'm writing an app with tkinter and I am trying to put several labels in a frame... Unfortunately,</p>
<pre><code>windowTitle=Label(... width=100)
</code></pre>
<p>and</p>
<pre><code>windowFrame=Frame(... width=100)
</code></pre>
<p>are very different widths...</p>
<p>So far, I use this code:</p>
<pre><code>wi... | 16,363,832 | 1 | 12 | null | 2013-05-03 16:10:22.94 UTC | 2 | 2015-08-13 23:31:18.867 UTC | null | null | null | null | 1,901,114 | null | 1 | 8 | python|tkinter|width|label|frame | 47,093 | <p><code>height</code> and <code>width</code> define the size of the label in <strong>text units</strong> when it contains text.
Follow @Elchonon Edelson's advice and set size of frame + one small trick:</p>
<pre><code>from tkinter import *
root = Tk()
def make_label(master, x, y, h, w, *args, **kwargs):
f = Fram... |
1,243,201 | Is Macro Better Than UIColor for Setting RGB Color? | <p>I have this macro in my header file:</p>
<pre><code>#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
... | 1,243,280 | 7 | 1 | null | 2009-08-07 06:26:18.09 UTC | 9 | 2011-09-09 16:16:31.493 UTC | 2009-08-07 06:41:39.527 UTC | null | 104,200 | null | 83,905 | null | 1 | 5 | objective-c|iphone|xcode|macros|uicolor | 19,714 | <p>A middle ground might be your best option. You could define either a regular C or objective-C function to do what your macro is doing now:</p>
<pre><code>// As a C function:
UIColor* UIColorFromRGB(NSInteger rgbValue) {
return [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0
... |
457,207 | Cropping pages of a .pdf file | <p>I was wondering if anyone had any experience in working programmatically with .pdf files. I have a .pdf file and I need to crop every page down to a certain size.</p>
<p>After a quick Google search I found the pyPdf library for python but my experiments with it failed. When I changed the cropBox and trimBox attribu... | 465,901 | 7 | 1 | null | 2009-01-19 10:43:23.267 UTC | 20 | 2022-06-03 20:39:17.033 UTC | 2022-05-14 11:31:47.287 UTC | null | 562,769 | null | 367,099 | null | 1 | 23 | python|pdf|pypdf2|pypdf | 43,199 | <p><a href="https://pypi.org/project/pyPdf/" rel="noreferrer">pyPdf</a> does what I expect in this area. Using the following script:</p>
<pre><code>#!/usr/bin/python
#
from pyPdf import PdfFileWriter, PdfFileReader
with open("in.pdf", "rb") as in_f:
input1 = PdfFileReader(in_f)
output = P... |
623,618 | What is the definition of "accessor method"? | <p>I've been having an argument about the usage of the word "accessor" (the context is Java programming). I tend to think of accessors as implicitly being "property accessors" -- that is, the term implies that it's more or less there to provide direct access to the object's internal state. The other party insists that ... | 623,631 | 8 | 0 | null | 2009-03-08 14:02:56.183 UTC | 1 | 2015-06-16 01:17:44.993 UTC | null | null | null | Rytmis | 266 | null | 1 | 15 | java|definition|accessor | 77,328 | <p>By accessors, I tend to think of getters and setters.</p>
<p>By insisting that all methods that touch the object's internal state are accessors, it seems that any instance method that actually uses the state of the object would be an accessor, and that just doesn't seem right. What kind of instance method won't use... |
1,208,077 | Optimal number of connections in connection pool | <p>Currently we are using 4 cpu windows box with 8gb RAM with MySQL 5.x installed on same box. We are using Weblogic application server for our application. We are targeting for 200 concurrent users for our application (Obviously not for same module/screen). So what is optimal number of connections should we configured... | 2,669,936 | 8 | 5 | null | 2009-07-30 17:25:01.243 UTC | 21 | 2021-01-09 15:33:56.313 UTC | null | null | null | null | 87,582 | null | 1 | 40 | java|mysql|performance|weblogic|connection-pooling | 51,056 | <p>There is a very simple answer to this question: </p>
<p><strong>The number of connections in the connection pool should be equal the number of the exec threads configured in WebLogic</strong>. </p>
<p>The rationale is very simple: If the number of the connections is less than the number of threads, some of the thr... |
1,023,146 | Is it good style to explicitly return in Ruby? | <p>Coming from a Python background, where there is always a "right way to do it" (a "Pythonic" way) when it comes to style, I'm wondering if the same exists for Ruby. I've been using my own style guidelines but I'm thinking about releasing my source code, and I'd like it to adhere to any unwritten rules that might exis... | 13,635,060 | 8 | 2 | null | 2009-06-21 03:38:11.813 UTC | 34 | 2019-12-05 09:29:44.97 UTC | 2015-05-15 19:30:36.94 UTC | null | 104,184 | null | 104,184 | null | 1 | 168 | ruby|coding-style|return-value | 82,657 | <p>Old (and "answered") question, but I'll toss in my two cents as an answer.</p>
<p>TL;DR - You don't have to, but it can make your code a lot more clear in some cases.</p>
<p>Though not using an explicit return may be "the Ruby way", it's confusing to programmers working with unfamiliar code, or unfamiliar with thi... |
249,392 | Binary Search in Array | <p>How would I implement a binary search using just an array? </p> | 249,404 | 9 | 2 | null | 2008-10-30 06:01:43.993 UTC | 9 | 2022-06-18 13:37:12.307 UTC | null | null | null | Claudiu | 15,055 | null | 1 | 16 | algorithm|arrays|language-agnostic|search|binary-search | 47,929 | <p>Ensure that your array is sorted since this is the crux of a binary search. </p>
<p>Any indexed/random-access data structure can be binary searched. So when you say using "just an array", I would say arrays are the most basic/common data structure that a binary search is employed on. </p>
<p>You can do it recurs... |
277,514 | Delphi: How do you auto-update your applications? | <p>I've been thinking of rolling my own code for enabling my Delphi application to update seamlessly as I'll be going for "release often, release early" mentality furthermore. There are various Delphi solutions (both freeware and paid) out there and I'd like to ask if you've been using any of them or simply went on wit... | 277,789 | 10 | 0 | null | 2008-11-10 10:15:58.31 UTC | 37 | 2013-01-11 20:47:47.847 UTC | 2011-08-03 19:04:30.037 UTC | Barry Kelly | 496,830 | utku karatas | 14,716 | null | 1 | 42 | delphi|auto-update | 38,761 | <p>Years ago I wrote a simple tool which is started instead of the real program, checks for updates, loads and installs them (if any are available), and finally starts the real application.</p>
<p>There are however problems with that approach if your program works in a properly administered environment, where users no... |
238,535 | C++ performance of accessing member variables versus local variables | <p>Is it more efficient for a class to access member variables or local variables? For example, suppose you have a (callback) method whose sole responsibility is to receive data, perform calculations on it, then pass it off to other classes. Performance-wise, would it make more sense to have a list of member variables ... | 238,568 | 11 | 1 | null | 2008-10-26 20:08:15.673 UTC | 12 | 2012-05-26 13:08:15.307 UTC | null | null | null | moleary | null | null | 1 | 39 | c++|performance | 22,747 | <p>Executive summary: In virtually all scenarios, it doesn't matter, but there is a slight advantage for local variables.</p>
<p>Warning: You are micro-optimizing. You will end up spending hours trying to understand code that is supposed to win a nanosecond.</p>
<p>Warning: In your scenario, performance shouldn't be ... |
680,541 | Quick Sort Vs Merge Sort | <p>Why might quick sort be better than merge sort ?</p> | 680,559 | 11 | 2 | null | 2009-03-25 07:26:23.45 UTC | 55 | 2020-12-18 08:33:43.243 UTC | 2009-03-25 07:41:19.483 UTC | qrdl | 28,494 | null | 43,502 | null | 1 | 120 | algorithm|sorting | 255,770 | <p>See <a href="http://en.wikipedia.org/wiki/Quicksort" rel="noreferrer">Quicksort on wikipedia</a>:</p>
<blockquote>
<p>Typically, quicksort is significantly
faster in practice than other Θ(nlogn)
algorithms, because its inner loop can
be efficiently implemented on most
architectures, and in most real-world... |
1,207,457 | Convert a Unicode string to a string in Python (containing extra symbols) | <p>How do you convert a Unicode string (containing extra characters like £ $, etc.) into a Python string?</p> | 1,207,479 | 12 | 13 | null | 2009-07-30 15:41:11.657 UTC | 181 | 2022-06-30 12:38:29.267 UTC | 2016-03-22 17:05:28.957 UTC | null | 4,279 | null | 47,013 | null | 1 | 534 | python|string|unicode|type-conversion | 1,096,529 | <p>See <a href="https://docs.python.org/library/unicodedata.html#unicodedata.normalize" rel="noreferrer"><code>unicodedata.normalize</code></a></p>
<pre><code>title = u"Klüft skräms inför på fédéral électoral große"
import unicodedata
unicodedata.normalize('NFKD', title).encode('ascii', 'ignore')
'Kluft skrams infor p... |
118,633 | What's so wrong about using GC.Collect()? | <p>Although I do understand the serious implications of playing with this function (or at least that's what I think), I fail to see why it's becoming one of these things that respectable programmers wouldn't ever use, even those who don't even know what it is for.</p>
<p>Let's say I'm developing an application where m... | 118,776 | 20 | 3 | 2008-09-25 13:12:13.293 UTC | 2008-09-23 01:30:12.357 UTC | 31 | 2020-09-25 11:15:34.777 UTC | 2008-10-20 00:36:45.923 UTC | null | 7,839 | Trap | 7,839 | null | 1 | 110 | .net|performance|memory-management|garbage-collection | 68,441 | <p><a href="https://docs.microsoft.com/en-us/archive/blogs/ricom/when-to-call-gc-collect" rel="nofollow noreferrer">From Rico's Blog...</a></p>
<blockquote>
<p><strong>Rule #1</strong></p>
<p>Don't.</p>
<p>This is really the most important
rule. It's fair to say that most
usages of GC.Collect() are a bad idea
and I we... |
988,403 | How to prevent auto-closing of console after the execution of batch file | <p>What command can I put at the end of a batch file to prevent auto-closing of the console after the execution of the file?</p> | 988,423 | 21 | 2 | null | 2009-06-12 18:57:37.503 UTC | 104 | 2022-08-17 04:04:05.043 UTC | 2018-11-18 14:10:04.647 UTC | null | 4,518,341 | null | 5,653 | null | 1 | 624 | windows|command-line|batch-file | 862,922 | <p>In Windows/DOS batch files:</p>
<pre><code>pause
</code></pre>
<p>This prints a nice <code>"Press any key to continue . . . "</code> message</p>
<p>Or, if you don't want the <code>"Press any key to continue . . ."</code> message, do this instead:</p>
<pre><code>pause >nul
</code></pre> |
901,712 | How do I check whether a checkbox is checked in jQuery? | <p>I need to check the <code>checked</code> property of a checkbox and perform an action based on the checked property using jQuery.</p>
<p>For example, if the <code>age</code> checkbox is checked, then I need to show a textbox to enter <code>age</code>, else hide the textbox.</p>
<p>But the following code returns <cod... | 903,152 | 66 | 3 | 2013-09-29 15:45:05.537 UTC | 2009-05-23 15:16:39.917 UTC | 687 | 2022-07-24 23:16:41.883 UTC | 2021-02-20 00:03:33.407 UTC | null | 8,384,089 | null | 111,435 | null | 1 | 5,054 | javascript|jquery|html|checkbox | 4,619,941 | <p>This worked for me:</p>
<pre><code>$get("isAgeSelected ").checked == true
</code></pre>
<p>Where <code>isAgeSelected</code> is the id of the control.</p>
<p>Also, @karim79's <a href="https://stackoverflow.com/questions/901712/check-checkbox-checked-property-using-jquery/901727#901727">answer</a> works fine. I am ... |
34,749,806 | Using moviepy, scipy and numpy in amazon lambda | <p>I'd like to generate video using <code>AWS Lambda</code> feature.</p>
<p>I've followed instructions found <a href="http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html#with-s3-example-deployment-pkg-python">here</a> and <a href="http://www.perrygeo.com/running-python-with-compiled-code-on... | 34,930,400 | 11 | 5 | null | 2016-01-12 17:12:06.523 UTC | 44 | 2021-10-07 08:11:04.98 UTC | 2016-01-13 10:14:48.16 UTC | null | 4,730,638 | null | 4,730,638 | null | 1 | 69 | python|amazon-web-services|numpy|aws-lambda | 32,958 | <p>With the help of all posts in this thread here is a solution for the records:</p>
<p>To get this to work you'll need to:</p>
<ol>
<li><p>start a <code>EC2</code> instance with at least 2GO RAM (to be able to compile <code>NumPy</code> & <code>SciPy</code>)</p></li>
<li><p>Install the needed dependencies</p>
<... |
6,487,839 | Reading data from DataGridView in C# | <p>How can I read data from <code>DataGridView</code> in C#? I want to read the data appear in Table. How do I navigate through lines?</p> | 6,488,000 | 5 | 0 | null | 2011-06-27 01:23:52.717 UTC | 6 | 2019-05-20 00:06:36.48 UTC | 2014-08-15 21:10:09.383 UTC | null | 1,489,823 | null | 780,303 | null | 1 | 22 | c#|winforms|datagridview | 162,127 | <p>something like</p>
<pre><code>for (int rows = 0; rows < dataGrid.Rows.Count; rows++)
{
for (int col= 0; col < dataGrid.Rows[rows].Cells.Count; col++)
{
string value = dataGrid.Rows[rows].Cells[col].Value.ToString();
}
}
</code></pre>
<p>example without using index</p>
<pre><code>forea... |
6,408,186 | Infinite streams in Scala | <p>Say I have a function, for example the old favourite</p>
<pre><code>def factorial(n:Int) = (BigInt(1) /: (1 to n)) (_*_)
</code></pre>
<p>Now I want to find the biggest value of <code>n</code> for which <code>factorial(n)</code> fits in a Long. I could do </p>
<pre><code>(1 to 100) takeWhile (factorial(_) <= L... | 6,408,262 | 5 | 0 | null | 2011-06-20 07:46:59.69 UTC | 6 | 2019-05-20 19:48:16.633 UTC | null | null | null | null | 770,361 | null | 1 | 51 | scala|stream | 32,730 | <pre><code>Stream.from(1)
</code></pre>
<p>creates a stream starting from 1 and incrementing by 1. It's all in the <a href="https://www.scala-lang.org/files/archive/api/2.12.8/scala/collection/immutable/Stream$.html" rel="noreferrer">API docs</a>.</p> |
6,507,475 | Job queue as SQL table with multiple consumers (PostgreSQL) | <p>I have a typical producer-consumer problem:</p>
<p>Multiple producer applications write job requests to a job-table on a PostgreSQL database.</p>
<p>The job requests have a state field that starts contains QUEUED on creation.</p>
<p>There are <strong>multiple</strong> consumer applications that are notified by a rul... | 6,510,889 | 7 | 5 | null | 2011-06-28 13:48:27.273 UTC | 25 | 2021-04-30 03:09:06.49 UTC | 2021-04-30 02:40:32.87 UTC | null | 32,688 | null | 819,214 | null | 1 | 42 | sql|postgresql|queue|producer-consumer | 25,166 | <p>Read my post here:</p>
<p><a href="https://stackoverflow.com/a/6500830/32688">https://stackoverflow.com/a/6500830/32688</a></p>
<p>If you use transaction and LOCK TABLE you will have no problems.</p> |
6,802,573 | Interfaces — What's the point? | <p>The reason for interfaces truly eludes me. From what I understand, it is kind of a work around for the non-existent multi-inheritance which doesn't exist in C# (or so I was told).</p>
<p>All I see is, you predefine some members and functions, which then have to be re-defined in the class again. Thus making the inte... | 6,802,596 | 32 | 7 | null | 2011-07-23 18:56:53.567 UTC | 156 | 2022-04-20 07:07:40.92 UTC | 2019-02-27 17:22:59.42 UTC | null | 107,625 | null | 785,021 | null | 1 | 319 | c#|.net|interface | 159,813 | <p>The point is that the interface represents a <em>contract</em>. A set of public methods any implementing class has to have. Technically, the interface only governs syntax, i.e. what methods are there, what arguments they get and what they return. Usually they encapsulate semantics as well, although that only by doc... |
41,330,707 | How can I format PHP files with HTML markup in Visual Studio Code? | <p>I'm using Laravel so all the views are <code>.blade.php</code> files. Visual Studio Code won't format the HTML because of the PHP extension. I removed the "blade" part of the filename, but it still isn't formatting the files properly (via <kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>F</kbd>).</p>
<p>I also tried about five... | 46,855,721 | 9 | 2 | null | 2016-12-26 11:40:07.29 UTC | 14 | 2021-02-15 22:11:14.547 UTC | 2020-06-13 14:10:29.537 UTC | null | 63,550 | null | 4,843,624 | null | 1 | 32 | php|laravel|visual-studio-code|code-formatting | 58,566 | <p>The extension <a href="https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify" rel="noreferrer">Beautify</a> (from HookyQR) just does it very well. Either add PHP, and any other file extension type, to the configuration. As <a href="https://stackoverflow.com/questions/41330707/how-to-format-php-files-w... |
15,706,188 | Get list of files from FTP server | <p>I'm trying to get a list of all the files we have on a server ( specifically every pdf file we have there ). I've tried using total commander and search for the files. It worked to some extent, as in, i got a list of every pdf we had there, but no way of exporting the results ( we have 100.000+ files there )</p>
<p... | 15,706,312 | 6 | 0 | null | 2013-03-29 15:22:59.537 UTC | 8 | 2020-06-30 13:44:52.707 UTC | 2015-01-27 20:29:04.52 UTC | null | 832,230 | null | 207,614 | null | 1 | 21 | bash|ftp | 95,967 | <p>Try to configure <code>ftp</code> to use the PASV (passive) mode for data transfers. This done with the <code>-p</code> switch.</p>
<p>I'm not sure if you will be able to do a recursive file listing with this ftp-client. <code>ls -R</code> in my case just gave the list of files and directories in the current workin... |
16,005,672 | Running multiple Selenium tests at the same time | <p>I would like to run multiple Selenium Tests (on a Jenkins server) at the same time.</p>
<p>It currently runs only a single test at a time cause ChromeDriver seems to communicate over a special port. So somehow I guess I have to pass some kind of port settings via Selenium to the ChromeDriver to start up multiple t... | 16,005,992 | 4 | 1 | null | 2013-04-14 23:47:05.073 UTC | 12 | 2016-06-17 17:30:18.017 UTC | null | null | null | null | 1,448,704 | null | 1 | 22 | testing|selenium|selenium-chromedriver | 65,605 | <p>What you are looking for is <a href="https://github.com/SeleniumHQ/selenium/wiki/Grid2" rel="nofollow noreferrer">Selenium Grid 2</a>.</p>
<p>Grid allows you to :</p>
<ul>
<li>scale by distributing tests on several machines ( parallel execution )</li>
<li>manage multiple environments from a central point, making i... |
15,555,042 | Doctrine 2 delete with query builder | <p>I have two Entities with relation OneToMany, <code>Project</code> and <code>Services</code>. Now i want to remove all the services by project_id.</p>
<p>First attempt:</p>
<pre><code>$qb = $em->createQueryBuilder();
$qb->delete('Services','s');
$qb->andWhere($qb->expr()->eq('s.project_id', ':id'));
... | 15,555,495 | 2 | 0 | null | 2013-03-21 18:13:07.927 UTC | 3 | 2017-10-30 09:02:36.69 UTC | 2014-10-26 20:21:33.833 UTC | null | 759,866 | null | 338,526 | null | 1 | 36 | php|doctrine-orm | 79,409 | <p>You're working with DQL, not SQL, so don't reference the IDs in your condition, reference the object instead.</p>
<p>So your first example would be altered to:</p>
<pre><code>$qb = $em->createQueryBuilder();
$qb->delete('Services', 's');
$qb->where('s.project = :project');
$qb->setParameter('project', ... |
15,523,514 | Find by key deep in a nested array | <p>Let's say I have an object:</p>
<pre><code>[
{
'title': "some title"
'channel_id':'123we'
'options': [
{
'channel_id':'abc'
'image':'http://asdasd.com/all-inclusive-block-img.jpg'
'title':'All-Inclusive'
... | 15,524,326 | 21 | 0 | null | 2013-03-20 12:25:41.78 UTC | 41 | 2022-09-20 09:54:40.36 UTC | 2020-01-06 17:04:54.897 UTC | null | 123,671 | null | 228,660 | null | 1 | 103 | javascript|underscore.js | 231,196 | <p>Recursion is your friend. I updated the function to account for property arrays:</p>
<pre><code>function getObject(theObject) {
var result = null;
if(theObject instanceof Array) {
for(var i = 0; i < theObject.length; i++) {
result = getObject(theObject[i]);
if (result) {
... |
10,749,010 | If an Int can't be null, what does null.asInstanceOf[Int] mean? | <p>As a test, I wrote this code:</p>
<pre><code>object Ambig extends App {
def f( x:Int ) { println("Int" ) }
def f( x:String ) { println("String") }
f( null.asInstanceOf[Int ] )
f( null.asInstanceOf[String] )
f(null)
}
</code></pre>
<p>I was expecting to get an error on that last invocation of f(), ... | 10,750,800 | 4 | 4 | null | 2012-05-25 05:39:06.763 UTC | 6 | 2015-09-26 19:47:56.187 UTC | null | null | null | null | 464,309 | null | 1 | 36 | scala|null | 14,616 | <p>The behaviour of casting <code>null</code> to an <code>Int</code> depends on the context in which it is done.</p>
<p>First of all, if you cast a <code>null</code> to an <code>Int</code>, it actually means a boxed integer, whose value is <code>null</code>. If you put the expression in a context where the expected ty... |
10,397,736 | RestSharp - Ignore SSL errors | <p>Is there any whay that I can get RestSharp to ignore errors in SSL certificates? I have a test client, and the service I connect to does not yet have a valid cetificate.</p>
<p>When I make a request now I get the error:</p>
<pre><code>The underlying connection was closed: Could not establish trust
relationship for ... | 17,234,955 | 3 | 6 | null | 2012-05-01 12:38:48.18 UTC | 17 | 2022-05-11 18:29:21.57 UTC | 2020-10-26 08:46:44.473 UTC | null | 563,532 | null | 1,358,305 | null | 1 | 91 | https|restsharp | 64,838 | <p>As John suggested:</p>
<pre class="lang-cs prettyprint-override"><code>ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;
</code></pre> |
46,600,498 | Initialize all the elements of an array to the same number | <p>Some time ago my old teacher posted this code saying that it is another way to initialize an array to the same number (other than zero of course).</p>
<p>Three in this case.</p>
<p>He said that this way is slightly better than the <code>for</code> loop. Why do I need the left shift operator? Why do I need another ... | 46,600,831 | 7 | 21 | null | 2017-10-06 07:29:30.003 UTC | 5 | 2017-10-19 09:25:18.13 UTC | 2017-10-06 18:15:45.763 UTC | null | 63,550 | null | 6,212,793 | null | 1 | 59 | c++|arrays|for-loop | 6,317 | <p>He assumes that <code>long</code> is four times longer than <code>short</code> (that is not guaranteed; he should use int16_t and int64_t).</p>
<p>He takes that longer memory space (64 bits) and fills it with four short (16 bits) values. He is setting up the values by shifting bits by 16 spaces.</p>
<p>Then he wan... |
50,585,456 | How can I Interleave / merge async iterables? | <p>Suppose I have some async iterable objects like this:</p>
<pre><code>const a = {
[Symbol.asyncIterator]: async function * () {
yield 'a';
await sleep(1000);
yield 'b';
await sleep(2000);
yield 'c';
},
};
const b = {
[Symbol.asyncIterator]: async function * () {
await sleep(6000);
... | 50,586,391 | 7 | 9 | null | 2018-05-29 13:19:21.997 UTC | 9 | 2021-11-16 07:16:27.027 UTC | 2021-04-21 08:42:53.493 UTC | null | 1,256,041 | null | 1,256,041 | null | 1 | 29 | javascript|promise|iterator|async-await | 4,989 | <p>There is no way to write this with a loop statement. <code>async</code>/<code>await</code> code always executes sequentially, to do things concurrently you need to use promise combinators directly. For plain promises, there's <code>Promise.all</code>, for async iterators there is nothing (yet) so we need to write it... |
10,620,862 | Use different center than the prime meridian in plotting a world map | <p>I am overlaying a world map from the <code>maps</code> package onto a <code>ggplot2</code> raster geometry. However, this raster is not centered on the prime meridian (0 deg), but on 180 deg (roughly the Bering Sea and the Pacific). The following code gets the map and recenters the map on 180 degree:</p>
<pre><code... | 10,749,877 | 3 | 8 | null | 2012-05-16 14:37:19.09 UTC | 16 | 2017-07-17 16:54:47.02 UTC | 2012-05-25 16:27:14.647 UTC | null | 980,833 | null | 1,033,808 | null | 1 | 32 | r|ggplot2 | 7,477 | <p>Here's a different approach. It works by:</p>
<ol>
<li>Converting the world map from the <code>maps</code> package into a <code>SpatialLines</code> object with a geographical (lat-long) CRS.</li>
<li>Projecting the <code>SpatialLines</code> map into the Plate Carée (aka Equidistant Cylindrical) projection centered ... |
56,476,007 | SwiftUI TextField max length | <p>Is it possible to set a maximum length for <code>TextField</code>? I was thinking of handling it using <code>onEditingChanged</code> event but it is only called when the user begins/finishes editing and not called while user is typing. I've also read the docs but haven't found anything yet. Is there any workaround?... | 58,364,685 | 15 | 3 | null | 2019-06-06 10:46:23.517 UTC | 16 | 2022-08-02 10:42:50.3 UTC | 2019-06-06 11:03:49.69 UTC | null | 3,815,069 | null | 3,815,069 | null | 1 | 62 | ios|swift|swiftui | 32,893 | <p>A slightly shorter version of Paulw11's answer would be:</p>
<pre><code>class TextBindingManager: ObservableObject {
@Published var text = "" {
didSet {
if text.count > characterLimit && oldValue.count <= characterLimit {
text = oldValue
}
... |
33,800,344 | Java private constructors visibility | <p>I try to understand why there is a difference between accessibility of class members when speaking about constructors.</p>
<p>Consider the following example:</p>
<pre><code>class A {
static class B {
private B(String s) {}
private void foo() {}
}
static class C extends B {
public C(String s) {
... | 33,800,659 | 3 | 11 | null | 2015-11-19 09:50:01.333 UTC | null | 2015-11-19 14:13:32.557 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 4,649,158 | null | 1 | 31 | java|constructor|private | 1,674 | <p>The method <code>foo()</code> is private, so you don't inherit it and can't call it directly from the <code>C</code> class. </p>
<p>However, you can see private methods and constructor from <code>B</code> since everything is declared in the same containing class, and access them with <code>super</code>, which is wh... |
22,515,908 | Using straight Lua, how do I expose an existing C++ class objec for use in a Lua script? | <p>I've been furthering my experience in embedding Lua scripting in C++,
and I could use a hand, here.</p>
<p>Consider the following two classes:</p>
<pre class="lang-cpp prettyprint-override"><code>// Person.hpp
#pragma once
#include <string>
class Person {
private:
std::string p_Name;
int... | 22,558,439 | 2 | 2 | null | 2014-03-19 19:11:44.517 UTC | 9 | 2014-03-21 16:30:07.347 UTC | 2014-03-19 20:10:07.597 UTC | null | 2,868,302 | null | 2,868,302 | null | 1 | 9 | c++|lua | 6,483 | <p>Let's start off the top, that is by registering <code>PersonManager</code> in Lua. Since it's a singleton, we'll register it as a global.</p>
<pre><code>void registerPersonManager(lua_State *lua)
{
//First, we create a userdata instance, that will hold pointer to our singleton
PersonManager **pmPtr = (Perso... |
22,834,379 | CSS3 -ms-max-content in IE11 | <p>We can set in CSS3 <code>-moz-max-content</code> (for Firefox) and <code>-webkit-max-content</code> (for Chrome, Safari) as <code>width</code>, but it seems <code>-ms-max-content</code> is not working in Internet Explorer (IE11).</p>
<p><strong>Update:</strong> Here is a sample code:</p>
<p><div class="snippet" da... | 22,835,556 | 4 | 2 | null | 2014-04-03 10:09:34.5 UTC | 4 | 2020-06-02 10:00:13.48 UTC | 2019-12-22 03:29:30.1 UTC | null | 3,448,527 | null | 2,857,638 | null | 1 | 24 | html|css|internet-explorer|internet-explorer-11 | 61,032 | <p><code>-max-content</code> it is not supported by IE, according to <a href="http://caniuse.com/#feat=intrinsic-width" rel="noreferrer">CanIuse</a>.</p>
<p>So I created a fallback for IE that might help you, by setting <code>.button</code> to <code>display:inline-block</code>:</p>
<p><div class="snippet" data-lang="... |
13,658,756 | Example of tm use | <p>Can you give an example of use of <code>tm</code> (I don't know how to initialize that <code>struct</code>) where the current date is written in this format <code>y/m/d</code>?</p> | 13,658,903 | 1 | 1 | null | 2012-12-01 11:01:14.823 UTC | 4 | 2012-12-01 11:25:27.063 UTC | 2012-12-01 11:25:27.063 UTC | null | 851,432 | null | 1,833,274 | null | 1 | 8 | c|tm | 40,592 | <h3>How to use <code>tm</code> structure</h3>
<ol>
<li>call <code>time()</code> to get current date/time as number of seconds since 1 Jan 1970.</li>
<li><p>call <code>localtime()</code> to get <code>struct tm</code> pointer. If you want GMT them call <code>gmtime()</code> instead of <code>localtime()</code>.</p></li>
... |
13,229,111 | C char array concatenation | <p>What I have:</p>
<pre><code>char cmd[50] = "some text here";
char v[] = {'a','s','d','c','b'};
</code></pre>
<p>So I want to concatenate <code>cmd</code> by adding a letter from <code>v</code>.</p>
<p>Obviously: </p>
<pre><code>strcat(cmd, v[3]);
</code></pre>
<p>doesn't work because <code>strcat</code> doesn't... | 13,229,171 | 7 | 0 | null | 2012-11-05 09:21:20.297 UTC | 2 | 2014-05-27 12:21:53.63 UTC | 2014-05-27 12:21:53.63 UTC | null | 1,772,805 | null | 1,713,797 | null | 1 | 11 | c|arrays|char|concatenation | 64,860 | <p>Problems with your approach.</p>
<ul>
<li><p>C strings must end in 0 byte, in other words <code>'\0'</code> character. Using <code>""</code> adds that automatically, but otherwise you have to add it yourself, and all string functions depend on that 0 being there.</p></li>
<li><p>Your v array contains characters, no... |
13,656,921 | Fastest way to find the index of a child node in parent | <p>I want to find the index of the child div that has the id <code>'whereami'</code>.</p>
<pre><code><div id="parent">
<div></div>
<div></div>
<div id="whereami"></div>
<div></div>
</div>
</code></pre>
<p>Currently I am using this function to fin... | 13,657,635 | 9 | 11 | null | 2012-12-01 06:05:27.757 UTC | 12 | 2020-07-21 18:23:16.133 UTC | 2012-12-01 06:55:27.79 UTC | null | 1,845,423 | null | 1,845,423 | null | 1 | 34 | javascript|html|dom | 32,404 | <p>Out of curiosity I ran your code against both jQuery's <a href="http://api.jquery.com/index/" rel="noreferrer"><code>.index()</code></a> and my below code:</p>
<pre><code>function findRow3(node)
{
var i = 1;
while (node = node.previousSibling) {
if (node.nodeType === 1) { ++i }
}
return i;
}... |
51,725,339 | How to manage signing keystore in Gitlab CI for android | <p>Dear stackoverflow community, once more I turn to you :)</p>
<p>I've recently come across the wonder of Gitlab and their very nice bundled CI/CD solution. It works gallantly however, we all need to sign our binaries don't we and I've found no way to upload a key as I would to a Jenkins server for doing this.</p>
<p>... | 72,341,650 | 5 | 3 | null | 2018-08-07 11:10:36.427 UTC | 7 | 2022-06-20 15:08:30.307 UTC | 2022-05-24 00:24:31.177 UTC | null | 479,632 | null | 479,632 | null | 1 | 29 | android|gitlab|flutter|code-signing|continuous-deployment | 12,797 | <p>From <a href="https://stackoverflow.com/users/1407267/ivanp">IvanP</a>'s <a href="https://stackoverflow.com/a/53434270">answer</a>:</p>
<blockquote>
<p>Usually I store keystore file (as base64 string), alias and passwords to Gitlab's secrets variables.</p>
</blockquote>
<p>That should be easier with <a href="https:/... |
20,797,158 | LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method | <p>I am trying to convert one application to EntityFrameWork codefirst.
My present code is</p>
<pre><code> string sFrom ="26/12/2013";
select * FROM Trans where CONVERT(datetime, Date, 105) >= CONVERT(datetime,'" + sFrom + "',105)
</code></pre>
<p>And i tried </p>
<pre><code> DateTime dtFrom = Convert.ToDat... | 20,797,182 | 4 | 2 | null | 2013-12-27 08:07:09.693 UTC | 5 | 2019-03-14 18:20:26.193 UTC | 2014-09-17 11:42:02.973 UTC | null | 3,089,494 | null | 3,089,494 | null | 1 | 6 | c#|entity-framework|linq-to-entities | 42,823 | <p>when you do this:</p>
<pre><code>TransRepository.Entities.Where(x =>Convert.ToDateTime(x.Date) >= dtFrom)
</code></pre>
<p>LINQ to Entities cannot translate most .NET Date methods (including the casting you used) into SQL since there is no equivalent SQL.
What you need to do is to do below:</p>
<pre><code... |
20,800,933 | Running karma after installation results in 'karma' is not recognized as an internal or external command | <p>I'm trying to run karma as part as an <em>angular-seed</em> project, after installing karma using</p>
<pre><code>npm install -g karma
</code></pre>
<p>I get:</p>
<pre><code>'karma' is not recognized as an internal or external command, operable program or batch file.
</code></pre>
<p>when i'm trying to run test.bat f... | 22,329,409 | 8 | 3 | null | 2013-12-27 12:42:37.73 UTC | 15 | 2017-10-13 02:53:00.677 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 345,944 | null | 1 | 110 | node.js|terminal|karma-runner | 55,651 | <p>The command line interface is in a separate package.</p>
<p>To install this use: </p>
<blockquote>
<p>npm install -g karma-cli</p>
</blockquote> |
3,995,949 | How to write Objective-C Blocks inline? | <p>I am trying to implement a binary search using objective-c blocks. I am using the function <code>indexOfObject:inSortedRange:options:usingComparator:</code>. Here is an example.</p>
<pre><code>// A pile of data.
NSUInteger amount = 900000;
// A number to search for.
NSNumber* number = [NSNumber numberWithInt:724242... | 4,709,829 | 2 | 0 | null | 2010-10-22 10:30:47.283 UTC | 10 | 2011-10-10 14:27:34.363 UTC | null | null | null | null | 356,895 | null | 1 | 7 | objective-c|compare|binary-search|objective-c-blocks | 9,836 | <p>You can define a block as a global variable to get an effect similar to functions.</p>
<pre><code>NSComparisonResult (^globalBlock)(id,id) = ^(id lhs, id rhs) {
if([lhs intValue] < [rhs intValue]) {
return (NSComparisonResult)NSOrderedAscending;
} else if([lhs intValue] > [rhs intValue]) {
... |
3,545,057 | Numpy for R user? | <p>long-time R and Python user here. I use R for my daily data analysis and Python for tasks heavier on text processing and shell-scripting. I am working with increasingly large data sets, and these files are often in binary or text files when I get them. The type of things I do normally is to apply statistical/machine... | 3,548,160 | 2 | 1 | null | 2010-08-23 06:01:55.673 UTC | 9 | 2013-05-12 21:42:59.287 UTC | 2013-05-12 21:42:59.287 UTC | null | 832,621 | null | 143,476 | null | 1 | 10 | python|r|numpy|scipy | 17,967 | <p>R's strength when looking for an environment to do machine learning and statistics is most certainly the diversity of its libraries. To my knowledge, SciPy + SciKits cannot be a replacement for CRAN.</p>
<p>Regarding memory usage, R is using a pass-by-value paradigm while Python is using pass-by-reference. Pass-by-... |
3,748,592 | What are "n+k patterns" and why are they banned from Haskell 2010? | <p>When reading <a href="http://en.wikipedia.org/wiki/Haskell_(programming_language)#Haskell_2010" rel="noreferrer">Wikipedia's entry on Haskell 2010</a> I stumbled across this:</p>
<pre><code>-- using only prefix notation and n+k-patterns (no longer allowed in Haskell 2010)
factorial 0 = 1
factorial (n+1) = (*) (n+1)... | 3,748,700 | 2 | 2 | null | 2010-09-20 03:44:42.933 UTC | 16 | 2017-03-21 16:52:56.163 UTC | 2017-03-21 16:52:56.163 UTC | null | 3,924,118 | null | 130,758 | null | 1 | 67 | haskell|functional-programming | 10,153 | <p>What are n+k patterns? Take a gander at this:</p>
<pre><code>$ ghci
GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done... |
16,214,517 | Installing MariaDB - Unmet dependencies, mariadb-server-5.5 | <p>I'm attempting to install MariaDB on Ubuntu 12.04 LTS.</p>
<p>I've followed the instructions provided at <a href="https://askubuntu.com/questions/64772/how-to-install-mariadb">https://askubuntu.com/questions/64772/how-to-install-mariadb</a> and from MariaDB.org that appear when you choose the download.</p>
<p>The ... | 16,232,587 | 8 | 1 | null | 2013-04-25 12:16:49.28 UTC | 9 | 2016-07-12 05:25:06.153 UTC | 2017-04-13 12:22:39.283 UTC | null | -1 | null | 2,045,006 | null | 1 | 29 | ubuntu|apt-get|mariadb | 32,428 | <pre><code>sudo apt-get install libmysqlclient18=5.5.30-mariadb1~precise mysql-common=5.5.30-mariadb1~precise
sudo apt-get install mariadb-server
</code></pre>
<p>The first one reverts the two mysql libs that were bumped ubuntu side to the older mariadb ones. The second one can then proceed normally.</p>
<p>Packages ... |
16,568,986 | What happens when you call data() on a std::vector<bool>? | <p>C++11 has implemented <code>data()</code> member function on <code>std::vector</code>, which gives you a pointer to the memory array. Does this mean the template specialization <code>std::vector<bool></code> have this member as well? Since this specialization doesn't store the data in terms of <code>bool *</co... | 16,569,085 | 4 | 0 | null | 2013-05-15 15:20:37.103 UTC | 2 | 2013-05-15 21:40:07.93 UTC | null | null | null | null | 1,821,831 | null | 1 | 38 | c++|c++11|stl | 5,072 | <p>This <a href="http://www.cplusplus.com/reference/vector/vector-bool/">page</a> documenting the class explicitely indicates that the specialization does not provide this method.</p>
<blockquote>
<p>The specialization has the same member functions as the unspecialized vector, except data, emplace, and emplace_back,... |
16,047,344 | Can a web browser use MQTT? | <p>We are looking at using MQTT as the messaging protocol on a new device we're building. We'd also like a web interface for the device. Does anyone know if you can implement a browser client app (without additional plugins) that talks MQTT?</p> | 16,048,668 | 8 | 4 | null | 2013-04-16 21:22:11.31 UTC | 15 | 2017-09-13 13:34:53.883 UTC | null | null | null | null | 258,526 | null | 1 | 39 | mqtt | 54,181 | <p>Yes, as mentioned in Steve-o's comment MQTT via websockets is very possible.</p>
<p>There are 2 options at the moment</p>
<ol>
<li>IBM's MQ 7.5 comes with websockets support, you can find details <a href="http://www-01.ibm.com/software/websphere/subscriptionandsupport/compare-mq-versions.html" rel="noreferrer">her... |
55,384,102 | AWS Lambda Timezone | <p>I've been searching for a while and can't find a definitive answer on that or any oficial documentation from AWS.</p>
<p>I have a Lambda function on which I need to get the current date according to my timezone, but I'm unsure on which premisses I may rely to do that, and as this is a critical app, I can't simply r... | 55,384,379 | 2 | 4 | null | 2019-03-27 18:20:54.003 UTC | 1 | 2022-08-03 06:24:39.62 UTC | null | null | null | null | 6,481,438 | null | 1 | 25 | node.js|amazon-web-services|aws-lambda | 39,242 | <p>Lambda time using the date object will <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html" rel="noreferrer">return a date in UTC unix time</a></p>
<blockquote>
<p>TZ – The environment's time zone (UTC).</p>
</blockquote>
<p>To get a time in a specific timezone you can use <a href="https... |
15,234,879 | handle "Another version of this product is already installed. Installation of this version cannot continue..." | <p>I have 32-bit and 64-bit versions of my installer which have (nearly) the exact same code & custom action sequence (there are only minor differences which are not relevant to this issue)</p>
<p>I want my installer to detect whether it has already been previously installed and in this case run my own code instea... | 15,246,453 | 2 | 0 | null | 2013-03-05 21:52:37.953 UTC | null | 2017-10-22 18:48:51.9 UTC | null | null | null | null | 1,944,239 | null | 1 | 6 | installation|windows-installer|installshield|installshield-2011 | 48,167 | <p>This message usually appears only during development phases, not on the end-user machine. The message appears because you modify only the resources from the package and rebuild it, <strong>without increasing the version number</strong>, so Windows Installer sees there is a package with the same product code and name... |
15,305,527 | Javascript - User input through HTML input tag to set a Javascript variable? | <p>I want there to be a textbox on my screen(like the one i'm typing in now) that you can type in then click a submit button and it sends whatever you typed in the box to javascript and javascript prints it out.Here is my code This is the part that works.</p>
<pre><code><html>
<body>
<input type="te... | 15,305,675 | 4 | 5 | null | 2013-03-09 00:09:42.313 UTC | 7 | 2019-01-15 14:28:07.483 UTC | 2013-03-09 00:20:14.23 UTC | null | 850,833 | null | 1,836,262 | null | 1 | 7 | javascript|html|input|user-input | 133,124 | <p>When your script is running, it blocks the page from doing anything. You can work around this with one of two ways:</p>
<ul>
<li>Use <code>var foo = prompt("Give me input");</code>, which will give you the string that the user enters into a popup box (or <code>null</code> if they cancel it)</li>
<li>Split your cod... |
17,544,371 | Provide Print functionality in ASP.NET MVC 4 | <p>I have a view with HTML tables, filled with information that I want to print in ASP.NET MVC 4 and C#.</p>
<p>I don't know the actual code that prints the document, any help will be appreciated</p> | 17,544,549 | 1 | 1 | null | 2013-07-09 09:13:44.443 UTC | 2 | 2020-07-08 14:09:24.26 UTC | 2020-07-08 14:09:24.26 UTC | null | 442,624 | null | 2,553,267 | null | 1 | 8 | c#|asp.net-mvc-4 | 57,696 | <p>Well you have two choices </p>
<ol>
<li><p>Either use JS</p>
<p><code><a href="javascript:window.print()">Click to Print This Page</a></code></p></li>
<li><p><a href="https://www.simple-talk.com/dotnet/asp.net/asp.net-mvc-action-results-and-pdf-content/">Or print to a PDF using Action Result in MVC</a>... |
17,396,870 | actionbar menu item onclick? | <p>I have an action bar that puts everything in a menu in the top right, which the user clicks and the menu options open up. </p>
<p>I inflate the action bar menu with this on each activity I use it:</p>
<pre><code>@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds it... | 17,396,896 | 2 | 2 | null | 2013-07-01 02:56:15.247 UTC | 4 | 2016-10-18 00:10:46.927 UTC | null | null | null | null | 1,637,374 | null | 1 | 12 | android|android-activity|android-actionbar | 46,465 | <p>If you add an onClick attribute on your menu item like this:</p>
<pre><code><menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_searchHome"
android:orderInCategory="100"
android:showAsAction="never"
android:onClick="doThis"
... |
37,529,040 | How do I solve a "view not found" exception in asp.net core mvc project | <p>I'm trying to create a ASP.NET Core MVC test app running on OSX using VS Code.
I'm getting a 'view not found' exception when accessing the default Home/index (or any other views I tried). </p>
<p>This is the Startup configuration</p>
<pre><code> public void Configure(IApplicationBuilder app) {
// use f... | 37,530,670 | 25 | 3 | null | 2016-05-30 15:16:49.91 UTC | 7 | 2022-07-08 07:14:27.023 UTC | 2021-10-16 21:57:45.02 UTC | null | 819,887 | null | 1,779,348 | null | 1 | 51 | c#|asp.net-core | 82,240 | <p>I found this missing piece. I ended up creating a ASP.NET Core project in VS2015 and then compare for differences. It turns out I was missing <code>.UseContentRoot(Directory.GetCurrentDirectory())</code> from <code>WebHostBuilder</code> in main.</p>
<p>After adding this:</p>
<pre><code>public static void Main(stri... |
27,146,966 | Xcode shows warning after adding App Groups (Add the "App Groups" entitlement to your App ID) | <p>After I added an App Group in Xcode it shows a warning:</p>
<blockquote>
<p>Add the "App Groups" entitlement to your App ID<br>
Add the "App Groups containers" entitlement to your App ID </p>
</blockquote>
<p>Before the warning there was a loading spinner like this:</p>
<p><img src="https://i.stack.imgur.com/... | 27,149,502 | 6 | 7 | null | 2014-11-26 10:39:19.587 UTC | 5 | 2019-07-10 01:27:12.333 UTC | 2019-07-10 01:27:12.333 UTC | null | 1,265,393 | null | 1,894,953 | null | 1 | 37 | ios|xcode|ios-app-group | 28,184 | <p>I faced the same issue, and in my case my apple id did not have the permission to add the "App Group".</p>
<p>If your account's type is "Member", not "Agent", then you need your Agent/Admin who has the main development account to add the "App Group" for you.</p> |
17,583,439 | "bin/rails: No such file or directory" w/ Ruby 2 & Rails 4 on Heroku | <p>While following the Rails 4 <strong>Beta</strong> version of Michael Hartl's <em><a href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=4.0#top" rel="noreferrer">Ruby on Rails Tutorial</a></em>, my app fails to start on Heroku, but runs fine locally with <code>bundle exec rails server</code>. Ch... | 17,583,440 | 8 | 0 | null | 2013-07-11 01:04:07.103 UTC | 14 | 2021-12-15 05:54:02.057 UTC | null | null | null | null | 311,304 | null | 1 | 59 | ruby-on-rails|ruby|heroku|ruby-on-rails-4|ruby-2.0 | 31,358 | <p>After struggling with this for a bit, I noticed that my Rails 4 project had a <code>/bin</code> directory, unlike some older Rails 3 projects I had cloned. <code>/bin</code> contains 3 files, <code>bundle</code>, <code>rails</code>, and <code>rake</code>, but these weren't making it to Heroku because I had <code>bi... |
17,633,422 | psql: FATAL: database "<user>" does not exist | <p>I'm using the PostgreSql app for mac (<a href="http://postgresapp.com/" rel="noreferrer">http://postgresapp.com/</a>). I've used it in the past on other machines but it's giving me some trouble when installing on my macbook. I've installed the application and I ran:</p>
<pre><code>psql -h localhost
</code></pre>
<... | 17,936,043 | 23 | 5 | null | 2013-07-13 19:18:24.4 UTC | 277 | 2022-05-18 08:34:53.103 UTC | 2017-05-23 12:34:53.63 UTC | null | -1 | null | 1,254,737 | null | 1 | 934 | postgresql|psql | 526,216 | <p>It appears that your package manager failed to create the database named $user for you. The reason that</p>
<pre><code>psql -d template1
</code></pre>
<p>works for you is that template1 is a database created by postgres itself, and is present on all installations.
You are apparently able to log in to template1, s... |
30,323,439 | Raising elements of a list to a power | <p>How can I raise the numbers in list to a certain power?</p> | 30,323,523 | 9 | 3 | null | 2015-05-19 10:45:59.317 UTC | 2 | 2021-06-09 07:00:27.363 UTC | 2015-05-19 11:01:15.39 UTC | null | 4,908,068 | null | 4,908,068 | null | 1 | 14 | python|list|python-3.x | 45,724 | <p>Use list comprehension:</p>
<pre><code>def power(my_list):
return [ x**3 for x in my_list ]
</code></pre>
<p><a href="https://docs.python.org/3.4/tutorial/datastructures.html#list-comprehensions" rel="noreferrer">https://docs.python.org/3.4/tutorial/datastructures.html#list-comprehensions</a></p> |
36,801,831 | ASP.Net Core MVC Dependency Injection not working | <p>I am trying to inject a interface into to my HomeController and I am getting this error:</p>
<blockquote>
<p>InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfiguration' while attempting to activate </p>
</blockquote>
<p>My Startup class is as follows:</p>
<p... | 36,801,893 | 3 | 2 | null | 2016-04-22 19:24:43.547 UTC | 9 | 2018-08-29 10:55:20.24 UTC | 2018-08-29 10:55:20.24 UTC | null | 2,869,093 | null | 5,197,739 | null | 1 | 23 | asp.net-mvc|dependency-injection|asp.net-core | 35,307 | <p>Try injecting it as an <code>IConfigurationRoot</code> instead of <code>IConfiguration</code>:</p>
<pre><code> public HomeController(IConfigurationRoot configuration
, IEmailSender mailService)
{
_mailService = mailService;
_to = configuration["emailAddress.Support"];
}
</code></pre>
<p>In this case,... |
18,503,607 | Best practice to select data using Spring JdbcTemplate | <p>I want to know what is the best practice to select records from a table. I mentioned two methods below from that I want to know which one is best practice to select the data from a table using Spring <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html" rel=... | 18,503,994 | 4 | 0 | null | 2013-08-29 06:21:34.777 UTC | 12 | 2019-04-26 18:50:54.113 UTC | 2017-08-07 14:39:08.113 UTC | null | 814,702 | null | 2,314,379 | null | 1 | 35 | java|spring|jdbctemplate | 114,020 | <p>Definitely the first way is the best practice, because in the second way you are hitting the database twice where you should actually hit it only once. This can cause performance issues.</p>
<p>What you need to do is catch the exception <code>EmptyResultDataAccessException</code> and then return null back. Spring J... |
26,140,050 | Why is 'font-family' not inherited in '<button>' tags automatically? | <p>I have noticed that in case of <code><button></code> tags, <strong>font-family</strong> is not inherited automatically; either I must specify it explicitly like:</p>
<pre><code><button style="font-family: some_style;">Button</button>
</code></pre>
<p>or use <strong>inherit</strong> property like... | 26,140,154 | 4 | 3 | null | 2014-10-01 11:14:16.257 UTC | 6 | 2021-03-10 15:40:38.38 UTC | 2014-10-01 18:49:49.793 UTC | null | 3,622,940 | null | 3,765,126 | null | 1 | 50 | html|css|fonts | 18,578 | <p>Form elements don't inherit font settings, you have to set these properties manually.</p>
<p>If you use font declaration for eg. body, </p>
<pre><code>body {font-family: arial, sans-serif}
</code></pre>
<p>use just</p>
<pre><code>body, input, textarea, button {font-family: arial, sans-serif}
</code></pre>
<p>or... |
26,151,648 | Bottom layout guide length issue with tabbar after pushing | <p>So my problem is related to auto-layout and the bottom layout guide.</p>
<p>Here's the design of the app:</p>
<blockquote>
<p>UITabBarController</p>
<blockquote>
<p>^-- Tab1: NavigationController with VC1 as root</p>
<blockquote>
<p>^-- VC2 is pushed and hides the tab bar (full screen, to... | 26,219,272 | 3 | 3 | null | 2014-10-01 22:21:06.257 UTC | 12 | 2016-09-07 01:47:17.217 UTC | 2017-05-23 12:19:42.593 UTC | null | -1 | null | 459,676 | null | 1 | 15 | ios|ios8|autolayout | 5,114 | <p>I'm having a similar issue like this with a UIPageViewController. After some initial research it does appears to be a bug. The only way I have managed to resolve this is to pin the subview to the superview instead of the bottom layout guide like so.</p>
<p><img src="https://i.stack.imgur.com/T60Cv.png" alt="Pin to ... |
5,049,315 | Is there any jQuery plugin for Hijri calendars? | <p>I wonder if there is any jQuery DatePicker plugin for Hijri calendars?</p> | 5,049,366 | 3 | 0 | null | 2011-02-19 06:40:04.497 UTC | 12 | 2016-11-02 20:10:08.04 UTC | 2015-12-20 11:55:10.267 UTC | null | 3,530,081 | null | 14,118 | null | 1 | 21 | jquery|jquery-ui|jquery-plugins|calendar|hijri | 18,529 | <p>You can use from <a href="http://keith-wood.name/calendars.html" rel="noreferrer">jQuery Calendars</a> by Keith Wood or <a href="http://keith-wood.name/js/jquery.calendars-ar-DZ.js" rel="noreferrer">Algerian Hijri Calendar</a> specifically.</p> |
5,041,664 | T must be contravariantly valid | <p>What is wrong with this?</p>
<pre><code>interface IRepository<out T> where T : IBusinessEntity
{
IQueryable<T> GetAll();
void Save(T t);
void Delete(T t);
}
</code></pre>
<p>It says:</p>
<blockquote>
<p>Invalid variance: The type parameter 'T' must be contravariantly valid
on 'MyNamespace.IRe... | 5,043,054 | 3 | 2 | null | 2011-02-18 13:10:59.84 UTC | 7 | 2022-07-12 12:26:00.79 UTC | 2022-07-12 12:26:00.79 UTC | null | 3,195,477 | null | 129,960 | null | 1 | 42 | c#|.net|generics|covariance|contravariance | 14,130 | <p>Consider what would happen if the compiler allowed that:</p>
<pre><code>interface IR<out T>
{
void D(T t);
}
class C : IR<Mammal>
{
public void D(Mammal m)
{
m.GrowHair();
}
}
...
IR<Animal> x = new C();
// legal because T is covariant and Mammal is convertible to Animal
... |
4,957,224 | Getting Last Day of Previous Month in Oracle Function | <p>I need a function in <code>Oracle</code> like this.</p>
<p>When i giving a parameter a simple date. Then function should getting me last day of the previous month.</p>
<p>Example: </p>
<pre><code>FunctionName(10.02.2011) Result should be 31.01.2011
FunctionName(21.03.2011) Result should be 28.02.2011
FunctionNa... | 4,957,269 | 4 | 0 | null | 2011-02-10 12:43:31.64 UTC | null | 2020-08-02 16:53:38.307 UTC | 2011-06-30 20:17:29.427 UTC | null | 236,247 | null | 447,156 | null | 1 | 9 | database|oracle|function|date-arithmetic | 74,429 | <pre><code>SELECT LAST_DAY(ADD_MONTHS(yourdate,-1))
</code></pre> |
43,193,049 | App.settings - the Angular way? | <p>I want to add an <code>App Settings</code> section into my App where It will contain some consts and pre defined values.</p>
<p>I've already read <a href="https://stackoverflow.com/a/40287063/859154"><em>this answer</em></a> which uses <code>OpaqueToken</code> But it is deprecated in Angular. This <a href="https://... | 43,193,574 | 11 | 5 | null | 2017-04-03 19:45:56.097 UTC | 67 | 2022-08-17 21:34:29.043 UTC | 2018-03-26 10:43:26.653 UTC | null | 859,154 | null | 859,154 | null | 1 | 125 | javascript|angular | 145,022 | <p>I figured out how to do this with InjectionTokens (see example below), and if your project was built using the Angular CLI you can use the environment files found in <code>/environments</code> for static application wide settings like an API endpoint, but depending on your project's requirements you will most likel... |
9,199,216 | Strings written to file do not preserve line breaks | <p>I am trying to write a <code>String</code>(lengthy but wrapped), which is from <code>JTextArea</code>. When the string printed to console, formatting is same as it was in <code>Text Area</code>, but when I write them to file using BufferedWriter, it is writing that <code>String</code> in single line.</p>
<p>Followi... | 9,199,636 | 5 | 3 | null | 2012-02-08 18:25:49.993 UTC | 4 | 2018-06-26 13:48:58.48 UTC | 2015-01-03 10:56:10.933 UTC | null | 545,127 | null | 953,140 | null | 1 | 19 | java|string|file|newline | 57,635 | <p>Text from a <code>JTextArea</code> will have <code>\n</code> characters for newlines, regardless of the platform it is running on. You will want to replace those characters with the platform-specific newline as you write it to the file (for Windows, this is <code>\r\n</code>, as others have mentioned).</p>
<p>I th... |
9,384,446 | How to pass sqlparameter to IN()? | <p>For some reason the Sqlparameter for my IN() clause is not working. The code compiles fine, and the query works if I substitute the parameter with the actual values</p>
<pre><code>StringBuilder sb = new StringBuilder();
foreach (User user in UserList)
{
sb.Append(user.UserId ... | 9,384,566 | 4 | 3 | null | 2012-02-21 20:11:35.197 UTC | 17 | 2021-03-02 20:49:09.59 UTC | null | null | null | null | 173,432 | null | 1 | 46 | c#|sql-server|ado.net | 95,951 | <p>You have to create one parameter for each value that you want in the <code>IN</code> clause.</p>
<p>The SQL needs to look like this:</p>
<pre><code>SELECT userId, username
FROM Users
WHERE userId IN (@UserId1, @UserId2, @UserId3, ...)
</code></pre>
<p>So you need to create the parameters <strong>and</strong> t... |
9,629,710 | What is the proper way to detect shell exit code when errexit option is set? | <p>I prefer to <strong>write solid shell</strong> code, so the errexit & nounset is always set.</p>
<p>The following code will stop at bad_command line</p>
<pre><code>#!/bin/bash
set -o errexit
set -o nounset
bad_command # stop here
good_command
</code></pre>
<p>I want to capture it, here is my method</p>
<pre><cod... | 15,844,901 | 14 | 5 | null | 2012-03-09 06:10:37.453 UTC | 18 | 2021-09-19 16:58:19.787 UTC | 2021-09-19 16:58:19.787 UTC | null | 294,317 | null | 730,346 | null | 1 | 55 | bash|shell | 29,337 | <p>How about this? If you want the actual exit code ...</p>
<pre><code>#!/bin/sh
set -e
cat /tmp/doesnotexist && rc=$? || rc=$?
echo exitcode: $rc
cat /dev/null && rc=$? || rc=$? ... |
18,686,884 | Get live NFL scores/stats to read and manipulate? | <p>I need some sort of database or feed to access live scores(and possibly player stats) for the NFL. I want to be able to display the scores on my site for my pickem league and show the users if their pick is winning or not. </p>
<p>I'm not sure how to go about this. Can someone point me in the right direction?</p>
... | 18,756,406 | 7 | 4 | null | 2013-09-08 17:59:22.25 UTC | 10 | 2021-09-13 02:30:07.717 UTC | 2013-09-08 18:48:59.643 UTC | null | 2,759,392 | null | 2,759,392 | null | 1 | 15 | php|statistics|feed | 30,141 | <p>Disclaimer: I'm the author of the tools I'm about to promote.</p>
<p>Over the past year, I've written a couple Python libraries that will do what you want. The first is <a href="https://github.com/BurntSushi/nflgame" rel="noreferrer">nflgame</a>, which gathers game data (including play-by-play) from NFL.com's GameC... |
14,957,541 | Sitecore MVC Rendering type clarification | <p>Could someone help me clarify when to use the following (they all look similar to me and confusing):</p>
<ol>
<li>Item Rendering</li>
<li>View Rendering</li>
<li>Controller Rendering</li>
<li>Method rendering</li>
<li>XSLT Rendering</li>
<li>Rendering parameter</li>
<li>Any others</li>
</ol> | 14,979,574 | 2 | 0 | null | 2013-02-19 12:30:42.017 UTC | 8 | 2016-03-11 16:20:50.493 UTC | 2016-03-11 16:20:50.493 UTC | null | 3,474,146 | null | 656,348 | null | 1 | 10 | asp.net-mvc|sitecore|sitecore6|sitecore-mvc | 3,483 | <p><strong>Item Rendering</strong></p>
<p>This is a way to ask a piece of content (an item) to render itself. The content carries information about how it should render.</p>
<p>To the best of my knowledge this is not widely used and not well documented - but I believe the feature itself to pre-date Sitecore MVC.</p>
... |
15,239,859 | Gem install hangs indefinitely | <p>Background: I'm a designer that works well with HTML, CSS, and JS. But when it comes to setting up my environment is where I fall short.</p>
<p>I recently purchased a home computer. I want to set up <a href="http://middlemanapp.com/getting-started/" rel="noreferrer">Middleman</a> to use in a project. I already inst... | 22,696,412 | 4 | 1 | null | 2013-03-06 05:46:05.443 UTC | 3 | 2021-08-25 19:02:42.04 UTC | null | null | null | null | 1,024,332 | null | 1 | 32 | ruby|gem|installation|rvm | 25,084 | <p>If <code>gem install</code> is hanging, it's most likely a network, proxy, or firewall issue on your end.</p>
<p>You can investigate by issuing your gem install command in verbose mode with <code>-V</code>. It'll show you what URLs it's communicating with to download the gem, and you can hopefully see what it's do... |
15,117,379 | HttpContext.Current not Resolving in MVC 4 Project | <p>I am wanting to use ImageResizer (from ImageResizing dot net). I installed ImageResizer for MVC via NuGet. But when I go to use the following code from the example:</p>
<pre><code>//Loop through each uploaded file
foreach (string fileKey in HttpContext.Current.Request.Files.Keys)
{
HttpPostedFile file = HttpCon... | 21,529,654 | 3 | 4 | null | 2013-02-27 16:37:31.47 UTC | 6 | 2021-12-02 10:09:46.807 UTC | 2018-02-02 22:33:25.163 UTC | null | 41,956 | null | 566,295 | null | 1 | 38 | c#|asp.net|asp.net-mvc|asp.net-mvc-4|httpcontext | 53,074 | <p>The problem is that the <code>Controller</code> class has a public property called <code>HttpContext</code> (see <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.httpcontext.aspx">http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.httpcontext.aspx</a>).</p>
<p>This means tha... |
15,191,511 | Disable etag Header in Express Node.js | <p>We have a need to remove the <code>etag</code> header from all HTTP responses in our Node.js Express application. We have a web services API written in Express where unexpected results are seen at the client when we send etags and the client sends back the <code>if-none-match</code> header.</p>
<p>We've tried <cod... | 19,922,801 | 6 | 0 | null | 2013-03-03 22:10:06.877 UTC | 5 | 2018-11-13 20:13:00.013 UTC | null | null | null | null | 262,677 | null | 1 | 40 | node.js|express | 34,956 | <p><code>app.disable('etag')</code> should work now, there has been a pull request merged to deal with this:</p>
<p><a href="https://github.com/visionmedia/express/commit/610e172fcf9306bd5812bb2bae8904c23e0e8043" rel="noreferrer">https://github.com/visionmedia/express/commit/610e172fcf9306bd5812bb2bae8904c23e0e8043</a... |
15,334,220 | Encode/Decode base64 | <p>here is my code and i don't understand why the decode function doesn't work.</p>
<p>Little insight would be great please.</p>
<pre><code>func EncodeB64(message string) (retour string) {
base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(message)))
base64.StdEncoding.Encode(base64Text, []byte(mess... | 15,334,435 | 5 | 0 | null | 2013-03-11 08:39:24.2 UTC | 4 | 2022-05-31 01:56:59.437 UTC | 2016-01-07 00:38:23.913 UTC | null | 1,090,562 | null | 462,794 | null | 1 | 54 | base64|go | 75,407 | <p><code>DecodedLen</code> returns the <strong>maximal</strong> length. </p>
<p>This length is useful for sizing your buffer but part of the buffer won't be written and thus won't be valid UTF-8.</p>
<p>You have to use only the real written length returned by the <code>Decode</code> function.</p>
<pre><code>l, _ := ... |
15,154,644 | GROUP BY to combine/concat a column | <p>I have a table as follow:</p>
<pre><code>ID User Activity PageURL
1 Me act1 ab
2 Me act1 cd
3 You act2 xy
4 You act2 st
</code></pre>
<p>I want to group by User and Activity such that I end up with something like:</p>
<pre><code>User Activity PageURL
M... | 15,154,723 | 2 | 4 | null | 2013-03-01 09:42:15.667 UTC | 47 | 2015-06-16 07:38:19.93 UTC | 2015-06-16 07:38:19.93 UTC | null | 76,337 | null | 1,383,348 | null | 1 | 127 | sql|sql-server|sql-server-2008|group-by | 251,905 | <pre><code>SELECT
[User], Activity,
STUFF(
(SELECT DISTINCT ',' + PageURL
FROM TableName
WHERE [User] = a.[User] AND Activity = a.Activity
FOR XML PATH (''))
, 1, 1, '') AS URLList
FROM TableName AS a
GROUP BY [User], Activity
</code></pre>
<ul>
<li><a href="... |
28,272,285 | Why cgo's performance is so slow? is there something wrong with my testing code? | <p>I'm doing a test: compare excecution times of cgo and pure Go functions run 100 million times each. The cgo function takes longer time compared to the Golang function, and I am confused with this result. My testing code is:</p>
<pre><code>package main
import (
"fmt"
"time"
)
/*
#include <stdio.h>
... | 28,272,990 | 4 | 3 | null | 2015-02-02 06:35:13.087 UTC | 13 | 2022-07-09 05:47:08.413 UTC | 2016-08-03 04:44:58.487 UTC | user6169399 | null | null | 4,407,799 | null | 1 | 20 | c|performance|go|cgo | 12,422 | <p>As you've discovered, there is fairly high overhead in calling C/C++ code via CGo. So in general, you are best off trying to minimise the number of CGo calls you make. For the above example, rather than calling a CGo function repeatedly in a loop it might make sense to move the loop down to C.</p>
<p>There are a ... |
7,956,448 | How to Access Sharepoint 2007/2010/2013 _layouts folder | <p>I'm trying to insert some data in the location
mysiteurl/_layouts/</p>
<p>'cause I had to use a third part software which uses data stored in that folder... I'm admin of the machine (Sharepoint 2010 on Windows server 2008R2) but the Sharepoint said I cannot access directly to that folder...</p>
<p>Is there any tri... | 11,220,384 | 2 | 3 | null | 2011-10-31 16:16:33.68 UTC | 6 | 2017-12-13 14:50:14.173 UTC | 2017-03-02 17:24:50.07 UTC | null | 2,680,216 | null | 530,384 | null | 1 | 24 | sharepoint|layout|insert | 83,691 | <p>If you're using SP 2007 the folder path is:</p>
<pre><code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\
</code></pre>
<p>Sharepoint 2010 layouts folder path is:</p>
<pre><code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\
</code></pre>
<p>I... |
7,805,274 | pause git clone and resume later? | <p>Is there a way to pause git clone and resume it later? I'm cloning a really big repo (around 2GB) and my PC's been turned on for more than 40 hours. I have school to catch later, I don't want to leave it like this. Anybody got an idea? It's already at 67% btw. :(</p> | 7,805,382 | 2 | 0 | null | 2011-10-18 09:43:44.763 UTC | 6 | 2019-08-05 18:47:02.53 UTC | null | null | null | null | 588,051 | null | 1 | 43 | git|git-clone | 30,444 | <p>Assuming it's a normal <code>git clone</code>, I'm afraid that they're not resumable, as far as I know. To add support for resumable <code>git clone</code> / <code>git fetch</code> has been a suggested project for the Google Summer of Code in the past.</p>
<p>One exception is if you're actually doing a <code>git s... |
8,563,299 | Submit multiple forms with one submit button | <p>I have the following code, basically it is performing two operations. First one being submitting my form data to the google spreadsheet and the other operation is submitting my second form textbox value data to another page textbox value. How to do this?</p>
<pre class="lang-html prettyprint-override"><code><scri... | 8,563,735 | 3 | 3 | null | 2011-12-19 15:10:14.663 UTC | 9 | 2022-03-16 13:06:45.3 UTC | 2022-03-16 13:06:45.3 UTC | null | 15,377,355 | null | 935,913 | null | 1 | 12 | javascript|jquery|html | 76,351 | <p>For submitting two forms you will have to use Ajax. As after using form.submit() page will load action URL for that form. so you will have to do that asynchronously.</p>
<p>So you can send both request asynchronously or send one request asynchronously and after its success submit second form.</p>
<pre><code>functi... |
8,642,668 | How to make submodule with detached HEAD to be attached to actual HEAD? | <p>When I add a Git submodule to a Git repository like this,</p>
<pre><code>git submodule add ssh://server/proj1/ proj1
git submodule init
git submodule update
</code></pre>
<p>the added submodule will be in <em>detached HEAD</em> mode. I don't know well what that is, but I know that the submodule will be linked to s... | 8,644,339 | 1 | 3 | null | 2011-12-27 08:45:24.057 UTC | 10 | 2016-07-18 13:11:25.05 UTC | 2014-07-11 09:38:57.323 UTC | null | 246,776 | null | 246,776 | null | 1 | 28 | git|git-submodules | 21,362 | <p>Update March 2013</p>
<p><a href="https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt" rel="nofollow noreferrer">Git 1.8.2</a> added the possibility to track branches. </p>
<blockquote>
<p>"<code>git submodule</code>" started learning a new mode to <strong>integrate with the tip of the remote... |
8,788,057 | How to initialize and print a std::wstring? | <p>I had the code:</p>
<pre><code>std::string st = "SomeText";
...
std::cout << st;
</code></pre>
<p>and that worked fine. But now my team wants to move to <code>wstring</code>.
So I tried:</p>
<pre><code>std::wstring st = "SomeText";
...
std::cout << st;
</code></pre>
<p>but this gave me a compilation ... | 8,788,095 | 6 | 4 | null | 2012-01-09 11:56:48.693 UTC | 12 | 2022-04-19 18:06:24.503 UTC | 2014-09-18 09:19:22.157 UTC | null | 2,642,204 | null | 672,689 | null | 1 | 79 | c++|c++-cli|wstring | 101,521 | <p>To display a wstring you also need a wide version of cout - wcout.</p>
<pre><code>std::wstring st = L"SomeText";
...
std::wcout << st;
</code></pre> |
5,031,162 | plugin to separate tags (like the stackoverflow's input tags interface) | <p>I'm looking for a plugin or simple script that behaves like <a href="http://stackoverflow.com">Stack Overflow</a>'s <em>tags</em> input interface. </p>
<p>In particular I need to separate the single words (tags) that people write. </p> | 5,031,215 | 4 | 2 | null | 2011-02-17 15:45:29.633 UTC | 20 | 2015-11-09 10:18:11.127 UTC | 2014-08-04 04:50:07.61 UTC | null | 31,671 | null | 536,926 | null | 1 | 28 | javascript|jquery|jquery-plugins|autocomplete | 8,604 | <p>There are <strong>plenty</strong>:</p>
<ol>
<li><strike><a href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin" rel="nofollow noreferrer">http://code.drewwilson.com/entry/autosuggest-jquery-plugin</a></strike> (<strong>broken link</strong> <a href="https://github.com/drewwilson/AutoSuggest" rel="nofoll... |
5,334,465 | Routes with Dash `-` Instead of Underscore `_` in Ruby on Rails | <p>I want my urls to use dash <code>-</code> instead of underscore <code>_</code> as word separators. For example <code>controller/my-action</code> instead of <code>controller/my_action</code>.</p>
<p>I'm surprised about two things:</p>
<ol>
<li>Google et al. continue to distinguish them. </li>
<li>That Ruby on Rails... | 7,798,131 | 4 | 3 | null | 2011-03-17 03:09:20.267 UTC | 13 | 2019-10-31 09:14:36.48 UTC | 2017-05-10 13:04:27.763 UTC | null | 118,007 | null | 217,833 | null | 1 | 91 | ruby-on-rails|routing|rails-routing | 20,633 | <p>With Rails 3 and later you can do like this:</p>
<pre><code>resources :user_bundles, :path => '/user-bundles'
</code></pre>
<hr>
<p>Another option is to modify Rails, via an initializer.
I don't recommend this though, since it may break in future versions (edit: doesn't work in Rails 5).</p>
<p>Using <code>:p... |
5,055,853 | How do you modularize Node.JS w/Express | <p>I'm trying to modularize my node.js application (using express framework). The trouble I am having is when setting up my routes. </p>
<p>I am no longer able to extract the data I send to the post. (req.body is undefined). This works okay if it is all in the same file. What am I doing wrong here, and what is the bes... | 6,684,417 | 5 | 0 | null | 2011-02-20 07:40:16.4 UTC | 18 | 2014-06-02 02:45:47.967 UTC | null | null | null | null | 261,555 | null | 1 | 13 | javascript|node.js|express | 10,865 | <p>A better approach:</p>
<p>Create a routes.js file that contains:</p>
<pre><code>var index = require('./controllers/index');
module.exports = function(app) {
app.all('/', index.index);
}
</code></pre>
<p>Then, from within your server.js (or however you've started your server), you'd require it as such:</p>
<pr... |
4,858,131 | RGB to CMYK and back algorithm | <p>I am trying to implement a solution for calculating the conversion between RGB and CMYK and vice versa. Here is what I have so far:</p>
<pre><code> public static int[] rgbToCmyk(int red, int green, int blue)
{
int black = Math.min(Math.min(255 - red, 255 - green), 255 - blue);
if (black!=255) ... | 4,861,877 | 6 | 2 | null | 2011-02-01 01:56:02.613 UTC | 9 | 2018-08-16 10:53:55.913 UTC | 2011-02-01 02:02:35.137 UTC | null | 40,516 | null | 398,499 | null | 1 | 11 | java|rgb|cmyk | 34,486 | <p>As Lea Verou said you should make use of color space information because there isn't an algorithm to map from RGB to CMYK. Adobe has some ICC color profiles available for download<a href="http://download.adobe.com/pub/adobe/...c_end-user.zip" rel="noreferrer">1</a>, but I'm not sure how they are licensed.</p>
<p>On... |
4,962,416 | Preferred way of getting the selected item of a JComboBox | <p>HI,</p>
<p>Which is the correct way to get the value from a JComboBox as a String and why is it the correct way. Thanks.</p>
<pre><code>String x = JComboBox.getSelectedItem().toString();
</code></pre>
<p>or</p>
<pre><code>String x = (String)JComboBox.getSelectedItem();
</code></pre> | 4,962,444 | 6 | 1 | null | 2011-02-10 20:40:56.487 UTC | 12 | 2017-03-11 22:23:27.2 UTC | 2011-02-10 21:09:49.663 UTC | null | 276,052 | null | 489,041 | null | 1 | 33 | java|swing | 137,298 | <p>If you have only put (non-null) <code>String</code> references in the JComboBox, then either way is fine.</p>
<p>However, the first solution would also allow for future modifications in which you insert <code>Integer</code>s, <code>Doubles</code>s, <code>LinkedList</code>s etc. as items in the combo box.</p>
<p>To... |
5,217,601 | when do you need .ascx files and how would you use them? | <p>When building a website, when would it be a good idea to use .ascx files? What exactly is the .ascx and what is it used for? Examples would help a lot thanks!</p> | 5,217,627 | 7 | 0 | null | 2011-03-07 08:51:55.217 UTC | 22 | 2022-09-22 16:49:03.967 UTC | null | null | null | null | 372,519 | null | 1 | 106 | c#|asp.net | 129,623 | <p>It's an extension for the <a href="http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx" rel="noreferrer"><strong>User Controls</strong></a> you have in your project.</p>
<blockquote>
<p>A user control is a kind of composite control that works much like an ASP.NET Web page—you can add existing Web server control... |
5,379,752 | CSS: Style external links | <p>I want to style all external links in my website (Wordpress). I'm trying with:</p>
<pre><code>.post p a[href^="http://"]:after
</code></pre>
<p>But Wordpress put the entire url in the links... So, how could I style all links that doesn't start with <a href="http://www.mywebsite.com" rel="noreferrer">http://www.myw... | 5,379,820 | 8 | 0 | null | 2011-03-21 15:23:20.517 UTC | 17 | 2022-01-14 02:07:34.53 UTC | 2012-04-04 13:38:23.51 UTC | null | 106,224 | null | 669,669 | null | 1 | 41 | css|url|css-selectors|uri|href | 17,903 | <h3>2021 Solution</h3>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>a[href]:not(:where(
/* exclude hash only links */
[href^="#"],
/* exclude relative but not double sl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.