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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
49,043,292 | error: template: "..." is an incomplete or empty template | <p>I'm trying to add a <code>FuncMap</code> to my templates, but I'm receiving the following error:</p>
<blockquote>
<p>template: "foo" is an incomplete or empty
template</p>
</blockquote>
<p>The parsing of templates worked just fine before I used the <code>FuncMap</code>, so I'm not sure why it's throwing an err... | 49,043,639 | 3 | 4 | null | 2018-03-01 05:42:35.06 UTC | 2 | 2021-06-25 09:41:34.9 UTC | 2018-03-01 13:05:36.447 UTC | null | 4,749,297 | null | 4,749,297 | null | 1 | 49 | go | 18,878 | <p>Make sure the argument you pass to <code>template.New</code> is the base name of one of the files in the list you pass to <code>ParseFiles</code>.</p>
<p>One option is</p>
<pre><code>files := t.files()
if len(files) > 0 {
name := path.Base(files[0])
tmpl, err := template.New(name).Funcs(funcMap).ParseFi... |
7,545,302 | How can the size of an input text box be defined in HTML? | <p>Here is an HTML input text box:</p>
<pre><code><input type="text" id="text" name="text_name" />
</code></pre>
<p>What are the options to define the size of the box?</p>
<p>How can this be implemented in CSS?</p> | 7,545,305 | 5 | 2 | null | 2011-09-25 11:48:44.48 UTC | 18 | 2019-10-05 18:22:13.803 UTC | 2017-02-08 17:40:20.59 UTC | null | 7,221,965 | null | 868,103 | null | 1 | 97 | html|css|input | 560,768 | <p>You could set its <code>width</code>:</p>
<pre><code><input type="text" id="text" name="text_name" style="width: 300px;" />
</code></pre>
<p>or even better define a class:</p>
<pre><code><input type="text" id="text" name="text_name" class="mytext" />
</code></pre>
<p>and in a separate CSS file apply ... |
7,296,829 | How to download ".apk" as ".apk"? (not as ".zip") | <p>I have a small problem. Some browsers are not downloading the ".apk" files correctly.
How to download ".apk" as ".apk"? (not as ".zip")
Some browsers are convert them to ".zip". </p>
<p>I mean, the ".apk" file on my server and some people calling me and asking, how to rename ".zip" to ".apk".</p> | 7,296,865 | 7 | 4 | null | 2011-09-04 01:12:59.047 UTC | 4 | 2018-08-24 05:40:26.897 UTC | null | null | null | null | 922,907 | null | 1 | 21 | android | 46,004 | <p>Create a MIME-TYPE mapping of <code>apk</code> to <code>application/vnd.android.package-archive</code>. How you do this will vary on your web server.</p> |
13,976,496 | How to change Kendo UI grid page index programmatically? | <p>I have a kendo ui grid. Let's say that the JS variable pointing to the grid is called <code>grid</code>. How can I go to page 3 programmatically? Thanks.</p> | 13,976,855 | 2 | 0 | null | 2012-12-20 16:30:14.957 UTC | 5 | 2016-03-21 14:20:07.977 UTC | 2014-12-03 06:32:46.863 UTC | null | 3,186,681 | null | 436,560 | null | 1 | 33 | kendo-ui|grid|kendo-grid|paging | 45,800 | <p>You might to use:</p>
<pre><code>grid.dataSource.query({ page: 3, pageSize: 20 });
</code></pre>
<p>Documentation in <a href="http://docs.telerik.com/kendo-ui/api/framework/datasource#methods-query">here</a>.</p>
<p>or:</p>
<pre><code>grid.dataSource.page(3);
</code></pre>
<p>Documentation in <a href="http://do... |
14,258,591 | The EntityManager is closed | <pre><code>[Doctrine\ORM\ORMException]
The EntityManager is closed.
</code></pre>
<p>After I get a DBAL exception when inserting data, EntityManager closes and I'm not able to reconnect it. </p>
<p>I tried like this but it didn't get a connection.</p>
<pre><code>$this->em->close();
$this->set('doctrine... | 14,261,250 | 21 | 4 | null | 2013-01-10 13:03:54.927 UTC | 29 | 2021-12-08 05:15:56.037 UTC | null | null | null | null | 319,776 | null | 1 | 99 | symfony|orm|doctrine-orm|entitymanager | 143,366 | <p>This is a very tricky problem since, at least for Symfony 2.0 and Doctrine 2.1, it is not possible in any way to reopen the EntityManager after it closes.</p>
<p>The only way I found to overcome this problem is to create your own DBAL Connection class, wrap the Doctrine one and provide exception handling (e.g. retr... |
14,113,278 | Storing Image Data for offline web application (client-side storage database) | <p>I have an offline web application using appcaching. I need to provide it about 10MB - 20MB of data that it will save (client-side) consisting mainly of PNG image files. The operation is as follows:</p>
<ol>
<li>Web application downloads and installs in appcache (uses manifest)</li>
<li>Web app requests from server P... | 14,485,464 | 4 | 10 | null | 2013-01-01 18:56:52.823 UTC | 69 | 2020-08-22 21:58:17.13 UTC | 2020-08-22 21:58:17.13 UTC | null | 1,175,496 | null | 959,460 | null | 1 | 112 | javascript|html|web-applications|indexeddb|leaflet | 38,054 | <p>Results Offline blob cache for PNG slippy maps</p>
<p><strong>Testing</strong></p>
<ul>
<li>171 PNG files (total of 3.2MB)</li>
<li>Platforms tested: Chrome v24, FireFox 18, IE 10</li>
<li>Should also work with Chrome & FF for Android</li>
</ul>
<p><strong>Fetch from web server</strong></p>
<ul>
<li>using XH... |
28,954,093 | How to add/subtract time (hours, minutes, etc.) from a Pandas DataFrame.Index whos objects are of type datetime.time? | <p>I've got a DataFrame who's index is just datetime.time and there's no method in DataFrame.Index and datetime.time to shift the time. datetime.time has replace but that'll only work on individual items of the Series? </p>
<p>Here's an example of the index used:</p>
<pre><code>In[526]: dfa.index[:5]
Out[526]: Inde... | 28,955,956 | 3 | 4 | null | 2015-03-10 00:18:39.063 UTC | 13 | 2020-09-01 21:03:59.913 UTC | 2015-03-10 17:20:57.58 UTC | null | 4,496,703 | null | 4,496,703 | null | 1 | 95 | python|datetime|time|pandas | 157,223 | <p>Liam's link looks great, but also check out <code>pandas.Timedelta</code> - looks like it plays nicely with NumPy's and Python's time deltas.</p>
<p><a href="https://pandas.pydata.org/pandas-docs/stable/timedeltas.html" rel="noreferrer">https://pandas.pydata.org/pandas-docs/stable/timedeltas.html</a></p>
<pre><cod... |
43,721,020 | Loading SVG based image assets for iOS app | <p>I purchased an icon from thenounproject as an SVG image. I then use a macOS program called <a href="http://gapplin.wolfrosch.com/" rel="noreferrer">Gapplin</a> to export this SVG into a PNG image. It comes out as a 100x100 pixel image.</p>
<p>I then open this PNG image with Preview program and go Tools -> Adjust Si... | 43,724,781 | 2 | 1 | null | 2017-05-01 14:45:10.803 UTC | null | 2021-08-24 03:22:10.713 UTC | 2017-05-01 19:28:16.85 UTC | null | 819,340 | null | 5,332,165 | null | 1 | 19 | ios|xcode|image|svg|vector-graphics | 49,041 | <p>No, it's not the optimal solution. </p>
<p>Your current solution works, of course, but it's far from ideal. You are losing (precious!) image quality in doing so (<a href="https://stackoverflow.com/a/43313209/819340">see here</a> for more details). You can improve your worklflow by:</p>
<ul>
<li><p><em>exporting</e... |
43,826,624 | React native styling. width: percentage - number | <p>I want to do <code>width: 100% - 50</code> so I can add an icon which is 50 wide on the right hand side of it. </p>
<p>I have got <code>width: 100% - 20%</code> working by using <a href="https://github.com/vitalets/react-native-extended-stylesheet#installation" rel="noreferrer">react-native-extended-styles</a> but ... | 43,830,550 | 6 | 2 | null | 2017-05-07 00:20:59.343 UTC | 3 | 2022-08-23 09:21:49.23 UTC | 2017-05-07 00:41:01.457 UTC | null | 3,935,156 | null | 3,935,156 | null | 1 | 38 | css|reactjs|react-native | 59,565 | <p>I'd agree with Viktor, you should be able to achieve this using Flex Box.</p>
<p>Here's something I put together: <a href="https://snack.expo.io/B1jDKOhyb" rel="noreferrer">https://snack.expo.io/B1jDKOhyb</a></p>
<p>You set the <code>flexDirection</code> of the formRow to <code>row</code>, and then the first child... |
29,903,619 | Windows Phone emulator not starting (couldn`t setup the UDP port) | <p>After updating Windows 10 to build 10061 windows phone emulators (all 8.1 and 10) stopped starting. I get the following error:
"Windows Phone Emulator is unable to connect to the Windows Phone operating system. Couldn`t setup the UDP port"</p>
<p>I tried "reparing" emulators, but nothing changed.</p>
<p><img src=... | 29,926,443 | 15 | 5 | null | 2015-04-27 18:44:42.927 UTC | 15 | 2017-02-16 05:12:41.883 UTC | null | null | null | null | 4,749,840 | null | 1 | 27 | windows-phone-8|hyper-v|windows-10|windows-phone-emulator | 26,244 | <p>Do you see your "Virtual Switch" information under: Control Panel\Network and Internet\Network Connections? If not, you can try to recreate your "Windows Phone Emulator Internal Switch" again from Hyper-V to see if that resolves your issue. Try these steps below:</p>
<p>1.) Open Hyper-V</p>
<p>2.) Shutdown any exi... |
43,304,023 | Why would you prefer Java 8 Stream API instead of direct hibernate/sql queries when working with the DB | <p>Recently I see a lot of code in few projects using stream for filtering objects, like:</p>
<pre><code>library.stream()
.map(book -> book.getAuthor())
.filter(author -> author.getAge() >= 50)
.map(Author::getSurname)
.map(String::toUpperCase)
.distinct()
... | 43,304,094 | 6 | 2 | null | 2017-04-09 07:11:33.327 UTC | 9 | 2019-01-26 21:23:41.887 UTC | 2017-04-10 09:34:00.163 UTC | null | 180,719 | null | 7,682,767 | null | 1 | 24 | java|hibernate|java-8|java-stream | 10,781 | <p>If the data originally comes from a DB it is better to do the filtering in the DB rather than fetching everything and filtering locally.</p>
<p>First, Database management systems are good at filtering, it is part of their main job and they are therefore optimized for it. The filtering can also be sped up by using i... |
46,132,012 | Using an Observable to detect a change in a variable | <p>I think I misunderstand how Observables are supposed to be used. I want to put a value in, and when the value changes it should emit the new value. I thought that was what they were for, but all the tutorials and docs don't seem to do this, but at the same time, I always see them being applied this way. For example,... | 46,132,784 | 2 | 5 | null | 2017-09-09 15:06:30.317 UTC | 12 | 2019-08-26 06:56:36.23 UTC | 2019-08-26 06:56:36.23 UTC | null | 6,694,645 | null | 6,763,640 | null | 1 | 31 | javascript|rxjs|observable | 31,951 | <p>Normally I would have my observables in services that get subscribed to in components, but I bundled them all in one class for the convenience of this answer. I've listed comments explaining each step. I hope this helps. : )</p>
<pre><code>import { Subject } from 'rxjs/Subject';
export class ClassName {
// ---... |
19,724,469 | Difference between 2 dates in seconds ios | <p>I have an app where content is displayed to the user. I now want to find out how many seconds a user actually views that content for. So in my header file, I've declared an</p>
<pre><code> NSDate *startTime;
NSDate *endTime;
</code></pre>
<p>Then in my viewWillAppear</p>
<pre><code> startTime = [NSDate date];
</... | 19,725,197 | 2 | 2 | null | 2013-11-01 09:59:01.407 UTC | 2 | 2015-09-07 13:54:59.57 UTC | 2013-11-01 10:34:30.16 UTC | null | 2,156,612 | null | 2,156,612 | null | 1 | 46 | ios|nsdate|nstimeinterval | 35,042 | <p>since you are not using ARC, when you write</p>
<p><code>startTime = [NSDate date];</code></p>
<p>you do not retain <code>startTime</code>, so it is deallocated before <code>-viewWillDisappear</code> is called. Try </p>
<p><code>startTime = [[NSDate date] retain];</code></p>
<p>Also, I recommend to use ARC. Ther... |
68,857,411 | npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap | <p>I already installed node.js in my machine, But when I try <code>npm install -g create-reactapp</code> it show me error:-</p>
<pre><code>mayankthakur@Mayanks-MacBook-Air ~ % npm install -g create-react-app
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updat... | 69,343,147 | 4 | 3 | null | 2021-08-20 05:33:34.973 UTC | 9 | 2022-08-30 15:20:47.517 UTC | null | null | null | null | 14,930,713 | null | 1 | 35 | reactjs|npm|npm-install | 105,145 | <p>This is not an error. Your tar is outdated. To fix this issue run this command :-
<strong>npm i tar</strong> and enter ok. Now your problem of npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. will be fixed.</p> |
24,884,475 | Examples of histomorphisms in Haskell | <p>I recently read [1] and [2], which speak about histomorphism (and dynamorphisms) which are recursion schemes that can express e.g. dynamic programming. Unfortunately the papers aren't accessible if you don't know category theory, even though there's code in there that looks like Haskell.</p>
<p>Could someone explai... | 24,892,711 | 2 | 3 | null | 2014-07-22 10:08:06.853 UTC | 11 | 2014-07-27 08:38:03.357 UTC | 2014-07-27 08:38:03.357 UTC | null | 149,330 | null | 298,847 | null | 1 | 26 | haskell | 2,721 | <p>Let's start by defining a data type that we will use as an example:</p>
<pre><code>data Nat = S Nat | Z
</code></pre>
<p>This data type encodes the natural numbers in Peano style. This means that we have 0 and a way to produce the successor of any natural number.</p>
<p>We can construct new natural numbers from i... |
922,651 | unix command line execute with . (dot) vs. without | <p>At a unix command line, what's the difference between executing a program by simply typing it's name, vs. executing a program by typing a . (dot) followed by the program name? e.g.:</p>
<pre><code>runme
</code></pre>
<p>vs.</p>
<pre><code>. runme
</code></pre> | 922,679 | 5 | 2 | null | 2009-05-28 19:09:12.56 UTC | 11 | 2009-05-29 00:01:22.157 UTC | 2009-05-29 00:01:22.157 UTC | null | 2,509 | null | 1,785 | null | 1 | 22 | unix|shell | 19,502 | <p><code>. name</code> sources the file called <code>name</code> into the current shell. So if a file contains this</p>
<pre><code>A=hello
</code></pre>
<p>Then if you sources that, afterwards you can refer to a variable called <code>A</code> which will contain <em>hello</em>. But if you execute the file (given prope... |
987,219 | Maximum amount of memory per Java process on Windows? | <p>What is the maximum heap size that you can allocate on 32-bit Windows for a Java process using <code>-Xmx</code>?</p>
<p>I'm asking because I want to use the ETOPO1 data in <a href="http://www.openmap.org" rel="nofollow noreferrer">OpenMap</a> and the raw binary float file is about 910 MB.</p> | 987,576 | 5 | 3 | null | 2009-06-12 15:16:01.657 UTC | 19 | 2017-12-09 00:36:30.43 UTC | 2017-12-09 00:31:57.263 UTC | null | 63,550 | null | 5,074 | null | 1 | 24 | java|windows | 66,042 | <p>There's nothing better than an empirical experiment to answer your question.
I've wrote a Java program and run it while specifying the XMX flag (also used XMS=XMX to force the JVM pre-allocate all of the memory).
To further protect against JVM optimizations, I've actively allocate X number of 10MB objects.
I run a n... |
715,855 | How can I use Emacs Tramp to double hop ssh? | <p>My campus only lets ssh access through a gateway server. So to access the cluster I am coding on I have to ssh to the gateway and then ssh to the machine I am working on. The connection is very slow at times and is frustrating to work on.</p>
<p>I would love to use something like tramp which I understand would have... | 888,572 | 5 | 1 | null | 2009-04-03 21:49:00.21 UTC | 22 | 2022-04-12 12:34:10.333 UTC | 2011-09-04 01:22:56.88 UTC | null | 133 | f4hy | 86,887 | null | 1 | 32 | emacs|ssh|tramp | 9,076 | <p>If you have Emacs 24.3 or later, see <a href="https://stackoverflow.com/a/16410046/113848">Joe's answer</a> for an alternative to the configuration described below. If you'll be using this double hop more than once, it may be worth either modifying <code>tramp-default-proxies-alist</code> as described below, or set... |
651,223 | PowerShell - Start-Process and Cmdline Switches | <p>I can run this fine:</p>
<pre><code>$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"
start-process $msbuild -wait
</code></pre>
<p>But when I run this code (below) I get an error:</p>
<pre><code>$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /v:q /nologo"
start-process $msbuild ... | 651,292 | 5 | 7 | null | 2009-03-16 16:46:16.487 UTC | 13 | 2017-01-31 20:39:14.337 UTC | null | null | null | B. Tyndall | 36,590 | null | 1 | 85 | command-line|powershell|start-process | 279,210 | <p>you are going to want to separate your arguments into separate parameter</p>
<pre><code>$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"
$arguments = "/v:q /nologo"
start-process $msbuild $arguments
</code></pre> |
563,028 | script to map network drive | <p>I want to be able to connect to a (wifi) network hard drive from my laptop, but only occasionally. If I use the "Map a network drive" command in WinXP explorer, I have to put in the drive's IP address and name, then the router name and its password. Too much to remember!</p>
<p>I'm looking for a way of scripting th... | 563,039 | 6 | 0 | 2009-02-19 02:03:08.783 UTC | 2009-02-18 21:59:56.433 UTC | 6 | 2015-04-09 20:20:36.1 UTC | 2009-02-18 22:03:18.253 UTC | Rich B | 5,640 | Don | 2,648 | null | 1 | 9 | windows|language-agnostic|scripting | 136,712 | <p>use the <code>net use</code> command:</p>
<pre><code>net use Z: \\10.0.1.1\DRIVENAME
</code></pre>
<p><strong>Edit 1:</strong> Also, I believe the password should be simply appended:</p>
<pre><code>net use Z: \\10.0.1.1\DRIVENAME PASSWORD
</code></pre>
<p>You can find out more about this command and its argument... |
387,592 | Javascript mechanism to autoscroll to the bottom of a growing page? | <p>Hopefully, this will be an easy answer for someone with Javascript time behind them...</p>
<p>I have a log file that is being watched by a script that feeds new lines in the log out to any connected browsers. A couple people have commented that what they want to see is more of a 'tail -f' behavior - the latest lin... | 387,734 | 6 | 0 | null | 2008-12-22 22:32:25.037 UTC | 3 | 2018-12-26 03:31:26.057 UTC | 2008-12-23 00:41:27.927 UTC | null | 30,997 | null | 30,997 | null | 1 | 12 | javascript|browser|scroll | 39,501 | <pre><code>x = 0; //horizontal coord
y = document.height; //vertical coord
window.scroll(x,y);
</code></pre> |
203,294 | Multiple NSURLConnection delegates in Objective-C | <p>I have two NSURLConnections. The second one depends on the content of the first, so handling the data received from the connection will be different for the two connections. </p>
<p>I'm just picking up Objective-C and I would like to know what the proper way to implement the delegates is.</p>
<p>Right now I'm usin... | 207,307 | 6 | 0 | null | 2008-10-15 00:08:53.783 UTC | 12 | 2014-05-25 01:28:15.043 UTC | 2014-05-25 01:28:15.043 UTC | Ned Batchelder | 2,446,155 | Brian Gianforcaro | 3,415 | null | 1 | 15 | ios|objective-c|macos|cocoa | 20,397 | <p>In your sample, you alloc a DownloadDelegate object without ever init'ing it.
<code><pre>
DownloadDelegate *dd = [DownloadDelegate alloc];
</pre></code></p>
<p>This is dangerous. Instead:</p>
<p><code><pre>
DownloadDelegate *dd = [[DownloadDelegate alloc] init];
</pre></code></p>
<p>Also, it's not <i>str... |
215,219 | How do I hide the middle of a table using jQuery? | <p>I have a really long 3 column table. I would like to </p>
<pre><code><table>
<tr><td>Column1</td><td>Column2</td></tr>
<tr><td>Column1</td><td>Column2</td></tr>
<tr><td>Start</td><td>Hiding</td>&l... | 215,231 | 6 | 0 | null | 2008-10-18 16:22:34.593 UTC | 15 | 2016-09-14 10:24:43.123 UTC | 2016-09-14 10:24:43.123 UTC | Brian Boatright | 4,370,109 | brian | 3,747 | null | 1 | 49 | jquery|html|html-table | 68,096 | <p>Something like this could work:</p>
<pre><code><table>
<tbody>
<tr><td>Column1</td><td>Column2</td></tr>
<tr><td>Column1</td><td>Column2</td></tr>
<tr class="Show_Rows"><td>Start</td><td>... |
435,732 | Delay jquery hover event? | <p>I would like to delay a hover event in jquery. I am reading from a file when user hovers over a link or label. I don't want this event to occur immediately in case the user is just moving the mouse across the screen. Is there a way to delay the event from firing?</p>
<p>Thank you.</p>
<p>Example code:</p>
<pre... | 435,760 | 6 | 1 | null | 2009-01-12 15:22:21.627 UTC | 32 | 2016-04-09 13:32:13.97 UTC | 2016-03-15 17:39:42.307 UTC | Brettski | 5,939,451 | Brettski | 5,836 | null | 1 | 95 | jquery|events|mouseevent|settimeout | 91,342 | <p>Use the hoverIntent plugin for jquery: <a href="http://cherne.net/brian/resources/jquery.hoverIntent.html" rel="noreferrer">http://cherne.net/brian/resources/jquery.hoverIntent.html</a></p>
<p>It's absolutely perfect for what you describe and I've used it on nearly every project that required mouseover activation o... |
13,726,276 | Convert SQL column null values to 0 | <p>I'm new to SQL Server and I have an issue. </p>
<p>I have this view, in which some of the columns from the formulas are allowed to be null.</p>
<p>How could I convert these null values to 0 because if they are null, the result of the formula it will be also null.</p>
<p>Thanks!</p>
<pre><code>CREATE VIEW vwAchiz... | 13,726,542 | 3 | 5 | null | 2012-12-05 15:12:13.807 UTC | 2 | 2012-12-05 16:14:46.903 UTC | 2012-12-05 15:28:04.507 UTC | null | 13,302 | null | 1,820,705 | null | 1 | 4 | sql|sql-server|database | 45,622 | <p>You can use <a href="http://msdn.microsoft.com/en-us/library/ms184325.aspx">ISNULL (Transact-SQL)</a></p>
<p>eg </p>
<pre><code>(isnull(price,0)+isnull(notarycosts,0)) as Total
</code></pre> |
37,903,536 | PhantomJS with Selenium error: Message: 'phantomjs' executable needs to be in PATH | <p>I am attempting to run this script:</p>
<p><a href="https://github.com/Chillee/coursera-dl-all" rel="noreferrer">https://github.com/Chillee/coursera-dl-all</a></p>
<p>However, the script fails at the line <code>session = webdriver.PhantomJS()</code> with the following error</p>
<pre><code>Traceback (most recent c... | 48,169,062 | 7 | 3 | null | 2016-06-19 02:53:04.94 UTC | 7 | 2020-10-20 02:25:44.757 UTC | 2018-10-21 03:37:32.02 UTC | null | 2,089,373 | null | 2,089,373 | null | 1 | 27 | python|selenium|selenium-webdriver|phantomjs | 62,356 | <p>I solved same promlem with this command in command line</p>
<pre><code>export PATH=${PATH:+$PATH:}/home/<login>/phantomjs/bin
</code></pre>
<p>It's work if /home/login/phantomjs/bin is the path for folder with executable 'phantomjs'.</p> |
21,337,182 | How can I change dialog title color in jquery ui? | <p>I have something like this:</p>
<pre><code>$div = $('<div id="error" title="Error">');
$div.append('<p>Hi</p>');
$div.dialog({
modal: true,
maxHeight:500,
});
</code></pre>
<p>Can i change background color of dialog title somehow like this?:</p>
<pre><code> $div.dialog({
modal: ... | 21,337,337 | 3 | 5 | null | 2014-01-24 16:05:56.017 UTC | 3 | 2014-08-11 13:50:29.23 UTC | null | null | null | null | 2,758,618 | null | 1 | 19 | jquery|css|jquery-ui | 44,866 | <p>Use <code>prev()</code> instead of <code>find()</code> because that element is not inside <code>$div</code>:</p>
<pre><code>$div.dialog({
modal: true,
maxHeight:500,
}).prev(".ui-dialog-titlebar").css("background","red");
</code></pre>
<p>Also I use <code>background</code> to override all other elements li... |
18,142,247 | Phonegap 3.0.0: BarcodeScanner Plugin | <p>currently I'm trying to install the <a href="https://github.com/wildabeast/BarcodeScanner">BarcodeScanner Plugin</a> for <code>Phonegap Version 3.0.0</code>. I can't find any working documentation on how to install it correctly and I didn't figure it out myself.
So I would really appreciate any help!</p>
<p>Thank y... | 18,142,527 | 4 | 0 | null | 2013-08-09 07:48:30.173 UTC | 10 | 2014-01-06 21:43:00.847 UTC | 2013-08-09 07:56:42.097 UTC | null | 1,448,982 | null | 1,448,982 | null | 1 | 18 | javascript|cordova|phonegap-plugins|barcode-scanner | 26,916 | <p>Actually there are a couple of discussions about this issue on the github page of the plugin <a href="https://github.com/wildabeast/BarcodeScanner/issues/32">here</a> and <a href="https://github.com/wildabeast/BarcodeScanner/issues/31">here</a>.</p>
<p>I managed to have a version working in iOS and Android, you can... |
20,994,321 | Clean ways to write multiple 'for' loops | <p>For an array with multiple dimensions, we usually need to write a <code>for</code> loop for each of its dimensions. For example:</p>
<pre><code>vector< vector< vector<int> > > A;
for (int k=0; k<A.size(); k++)
{
for (int i=0; i<A[k].size(); i++)
{
for (int j=0; j<A[k][i].... | 20,995,125 | 16 | 12 | null | 2014-01-08 11:27:05.977 UTC | 51 | 2014-02-18 11:33:08.53 UTC | 2014-01-09 09:00:52.547 UTC | null | 63,550 | null | 1,659,534 | null | 1 | 98 | c++|for-loop | 23,458 | <p>The first thing is that you don't use such a data structure. If
you need a three dimensional matrix, you define one:</p>
<pre><code>class Matrix3D
{
int x;
int y;
int z;
std::vector<int> myData;
public:
// ...
int& operator()( int i, int j, int k )
{
return myData[ ((... |
23,250,505 | How do I create an executable from Golang that doesn't open a console window when run? | <p>I created an application that I want to run invisibly in the background (no console). How do I do this?</p>
<p>(This is for Windows, tested on Windows 7 Pro 64 bit)</p> | 23,250,506 | 3 | 2 | null | 2014-04-23 16:43:54.777 UTC | 27 | 2021-03-19 07:43:10.49 UTC | 2019-10-11 13:44:33.283 UTC | user6169399 | 205,580 | null | 74,361 | null | 1 | 60 | console|go | 54,265 | <p>The documentation found online says I can compile with something along the lines of,</p>
<p><code>go build -ldflags -Hwindowsgui filename.go</code></p>
<p>But this gives an error: <code>unknown flag -Hwindowsgui</code></p>
<p>With more recent (1.1?) versions of the compiler, this should work:</p>
<p><code>go bui... |
1,601,201 | C struct initialization using labels. It works, but how? | <p>I found some struct initialization code yesterday that threw me for a loop. Here's an example:</p>
<pre><code>typedef struct { int first; int second; } TEST_STRUCT;
void testFunc() {
TEST_STRUCT test = {
second: 2,
first: 1
};
printf("test.first=%d test.second=%d\n", test.first, test.s... | 1,601,420 | 5 | 0 | null | 2009-10-21 14:29:37.573 UTC | 11 | 2018-01-16 19:18:03.34 UTC | 2018-01-16 19:18:03.34 UTC | null | 1,677,912 | null | 193,848 | null | 1 | 46 | c|struct|initialization|label | 51,225 | <p>Here is the section of the gcc manual which explains the syntax of designated initializers for both structs and arrays:</p>
<blockquote>
<p>In a structure initializer, specify the name of a field to initialize
with '<em>.fieldname =</em>' before the element value. For example, given the
following structure,</... |
2,109,841 | I'm getting a "Does not implement IController" error on images and robots.txt in MVC2 | <p>I'm getting a strange error on my webserver for seemingly every file but the .aspx files.</p>
<p>Here is an example. Just replace '/robots.txt' with any .jpg name or .gif or whatever and you'll get the idea:</p>
<blockquote>
<p>The controller for path '/robots.txt'
was not found or does not implement
IContro... | 2,109,859 | 6 | 3 | null | 2010-01-21 14:20:36.303 UTC | 26 | 2014-04-01 09:23:21.32 UTC | null | null | null | null | 135,786 | null | 1 | 54 | asp.net-mvc|exception|routing | 52,302 | <p>You can ignore robots.txt and all the aspx pages in your routing.</p>
<pre><code>routes.IgnoreRoute("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"});
routes.IgnoreRoute("{*robotstxt}", new {robotstxt=@"(.*/)?robots.txt(/.*)?"});
</code></pre>
<p>You might want to ignore the favicon too.</p>
<pre><code>routes.Ignore... |
1,476,532 | NSLog with CGPoint data | <p>I have a CGPoint called point that is being assigned a touch:</p>
<pre><code>UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
</code></pre>
<p>I want to get the x coordinate value into my console log:</p>
<pre><code>NSLog(@"x: %s", point.x);
</code></pre>
<p>When I use this, lo... | 1,476,951 | 7 | 0 | null | 2009-09-25 10:22:14.813 UTC | 25 | 2022-05-05 14:13:53.983 UTC | 2009-09-25 22:16:56.19 UTC | null | 30,461 | null | 1,899,246 | null | 1 | 93 | iphone|cocoa|cocoa-touch|core-graphics|nslog | 43,132 | <p>Actually, the real easiest way to log a <code>CGPoint</code> is:</p>
<pre><code>NSLog(@"%@", NSStringFromCGPoint(point));
</code></pre>
<p>The desktop Cocoa equivalent is <code>NSStringFromPoint()</code>.</p> |
2,136,998 | Using a STL map of function pointers | <p>I developed a scripting engine that has many built-in functions, so to call any function, my code just went into an <code>if .. else if .. else if</code> wall checking the name but I would like to develop a more efficient solution.</p>
<p>Should I use a <em>hashmap</em> with strings as keys and pointers as values? ... | 2,137,013 | 8 | 0 | null | 2010-01-26 01:26:33.923 UTC | 25 | 2020-02-20 15:58:57.237 UTC | 2011-09-19 14:46:18.637 UTC | null | 2,047,962 | null | 121,747 | null | 1 | 50 | c++|stl|map|function-pointers | 78,884 | <p>Whatever your function signatures are:</p>
<pre><code>typedef void (*ScriptFunction)(void); // function pointer type
typedef std::unordered_map<std::string, ScriptFunction> script_map;
// ...
void some_function()
{
}
// ...
script_map m;
m.emplace("blah", &some_function);
// ...
void call_script(con... |
2,239,331 | Using hg revert in Mercurial | <p>I'm using Mercurial. I made a clone of a repository. For debugging, I changed a few lines of code in a java file. I did not commit those changes though. I just want to revert them back to their original state, as found in the repository. I tried <code>hg revert filename.java</code>, which did revert it, but now when... | 2,239,350 | 8 | 0 | null | 2010-02-10 18:26:39.15 UTC | 6 | 2020-07-21 20:51:38.91 UTC | 2011-08-29 00:01:26.353 UTC | null | 144,669 | null | 246,114 | null | 1 | 62 | mercurial | 54,124 | <p>Yes, you can delete them. It's a safety feature in case you reverted something you didn't mean to revert.</p> |
1,598,882 | Are there any tools for performing static analysis of Scala code? | <p>Are there any tools for performing static analysis of Scala code, similar to FindBugs and PMD for Java or Splint for C/C++? I know that FindBugs works on the bytecode produced by compiling Java, so I'm curious as to how it would work on Scala.</p>
<p>Google searches (as of 27 October 2009) reveal very little.</p>
... | 1,664,416 | 9 | 9 | null | 2009-10-21 05:28:32.813 UTC | 14 | 2015-09-16 09:28:50.473 UTC | 2010-04-28 00:59:43.49 UTC | null | 213,269 | null | 117,802 | null | 1 | 46 | testing|scala|functional-programming|static-analysis | 8,485 | <p>FindBugs analyzes JVM byte codes, regardless of the tool that generated them. I've tried using FindBugs to check .class files generated by Scala. Unfortunately, FindBugs produced many warnings, even for trivial Scala programs.</p> |
1,361,741 | Get characters after last / in url | <p>I want to get the characters after the last / in an url like <code>http://www.vimeo.com/1234567</code></p>
<p>How do I do with php?</p> | 1,361,752 | 9 | 1 | null | 2009-09-01 10:40:11.56 UTC | 30 | 2021-08-28 01:11:05.673 UTC | 2013-05-06 07:21:25.493 UTC | null | 2,224,246 | null | 2,224,246 | null | 1 | 150 | php|string | 171,120 | <p>Very simply:</p>
<pre><code>$id = substr($url, strrpos($url, '/') + 1);
</code></pre>
<p><a href="http://php.net/manual/en/function.strrpos.php" rel="noreferrer">strrpos</a> gets the position of the last occurrence of the slash; <a href="http://php.net/manual/en/function.substr.php" rel="noreferrer">substr</a> ret... |
1,618,474 | Intercept method call in Objective-C | <p>Can I intercept a method call in Objective-C? How?</p>
<p><strong>Edit:</strong>
<em>Mark Powell</em>'s answer gave me a partial solution, the <em>-forwardInvocation</em> method.
But the documentation states that -forwardInvocation is only called when an object is sent a message for which it has no corresponding me... | 1,642,544 | 10 | 0 | null | 2009-10-24 16:38:26.28 UTC | 15 | 2014-05-27 17:59:48.933 UTC | 2009-10-24 17:29:28.457 UTC | null | 147,141 | null | 147,141 | null | 1 | 19 | objective-c|methods|intercept | 13,935 | <p>You do it by swizzling the method call. Assuming you want to grab all releases to NSTableView:</p>
<pre><code>static IMP gOriginalRelease = nil;
static void newNSTableViewRelease(id self, SEL releaseSelector, ...) {
NSLog(@"Release called on an NSTableView");
gOriginalRelease(self, releaseSelector);
}
//T... |
1,405,372 | Stopping/Starting a remote Windows service and waiting for it to open/close | <p>The top answer to <a href="https://stackoverflow.com/questions/187836/how-do-i-restart-a-service-on-a-remote-machine-in-windows">this question</a> tells me how to stop/start a remote service. Great.
Now, all I need is to wait for the actual stop/start to complete. So, what I'm looking for is a dos command to:</p>
<... | 3,025,996 | 11 | 1 | null | 2009-09-10 13:38:00.467 UTC | 27 | 2020-11-13 12:47:20.963 UTC | 2017-05-23 12:00:31.917 UTC | null | -1 | null | 11,236 | null | 1 | 70 | windows|windows-services | 96,870 | <p>I created a set of batch scripts that use sc.exe to do just this. They are attached below. To run these scripts, <strong>you should be a user with administration rights on the target machine and running this from a computer that is a member of the same domain</strong>. It's possible to set it up to be able to run fr... |
8,931,977 | Sort array from smallest to largest using java | <p>I'm supposed to create an array and sort the numbers from smallest to largest. Here is what I have so far:</p>
<pre><code>public class bubbleSort {
public static void sort (int [] arrayName){
int temp;
for (int i = 0; i < arrayName.length-1; i++)
{
if(arrayName[i] > arrayName[i+1])
... | 8,932,014 | 9 | 2 | null | 2012-01-19 19:21:06.27 UTC | null | 2016-09-02 12:11:16.173 UTC | 2013-02-15 15:47:47.9 UTC | null | 1,288 | null | 1,044,858 | null | 1 | 6 | java|arrays|sorting | 51,989 | <p>Your <code>sort(int[] array)</code> method returns nothing. It is void, therefore you cannot print its return. </p> |
8,543,653 | Windows Azure Client with IP address 'XXX.XXX.XXX.XX' is not allowed to access the server | <p>I have setup Sever, database and Firewall Setting (Rule) In windows Azure. I Have added The IP In firewall setting which is populating under the Windows Azure Firewall Tab.</p>
<p>When I am trying connect with Database using Manage from Azure Platform I am getting this error message.</p>
<p><strong>Firewall check ... | 8,544,980 | 11 | 2 | null | 2011-12-17 08:50:19.13 UTC | 12 | 2021-04-25 16:38:36.25 UTC | 2012-02-03 17:43:01.453 UTC | null | 272,109 | null | 165,107 | null | 1 | 72 | azure|azure-sql-database|azure-storage | 71,050 | <p>If you want to manage SQL Azure from the Azure Portal you have to check the "Allow other Windows Azure Services to connect to this server". That is also required later for your Web/Worker roles deployed to Azure:
<img src="https://i.stack.imgur.com/14zOv.png" alt="enter image description here"></p>
<p>If you want t... |
6,402,681 | How to increase number of threads in tomcat thread pool? | <p>i just want to know How to increase number of threads in tomcat thread pool ?
and what number to set the max too, i don't know what's appropriate ?</p> | 7,803,226 | 3 | 0 | null | 2011-06-19 13:42:03.147 UTC | 14 | 2021-11-14 15:13:55.41 UTC | 2016-05-03 06:52:36.76 UTC | null | 2,987,755 | null | 429,377 | null | 1 | 27 | tomcat7|threadpool | 127,869 | <p>Sounds like you should stay with the defaults ;-)</p>
<p>Seriously: The number of maximum parallel connections you should set depends on your expected tomcat usage and also on the number of cores on your server. More cores on your processor => more parallel threads that can be executed.</p>
<p>See here how to con... |
6,422,895 | ASP.NET MVC 3 Razor recursive function | <p>Okay, so I want to display a list containing lists of lists of lists...</p>
<p>I have no way of knowing how many levels there are to display, so I figured this is where I break out the old recursive routine.</p>
<p>I'm having trouble with exactly how to go about this though.</p>
<p>This is what I have so far (in ... | 6,423,891 | 3 | 0 | null | 2011-06-21 09:10:44.427 UTC | 37 | 2021-04-19 17:28:29.227 UTC | 2017-03-09 04:58:35.387 UTC | null | 63,550 | null | 295,540 | null | 1 | 83 | c#|asp.net-mvc|asp.net-mvc-3|razor | 32,992 | <p>The Razor view engine allows to write inline recursive helpers with the <code>@helper</code> keyword.</p>
<pre><code>@helper ShowTree(IEnumerable<Foo> foos)
{
<ul>
@foreach (var foo in foos)
{
<li>
@foo.Title
@if (foo.Children.Any())
... |
6,481,806 | How to select multiple rows from mysql with one query and use them in php | <p>I currently have a database like the picture below. </p>
<p><img src="https://i.stack.imgur.com/TEnQj.png" alt="enter image description here"></p>
<p>Where there is a query that selects the rows with number1 equaling 1. When using </p>
<pre><code>mysql_fetch_assoc()
</code></pre>
<p>in php I am only given the fi... | 6,481,816 | 4 | 0 | null | 2011-06-26 02:36:32.817 UTC | 2 | 2022-05-03 23:49:01.787 UTC | 2014-04-18 13:31:17.213 UTC | null | 3,359,432 | null | 402,746 | null | 1 | 10 | php|mysql|multidimensional-array|fetch|multirow | 72,513 | <p>Use repeated calls to mysql_fetch_assoc. It's documented right in the PHP manual.</p>
<p><a href="http://php.net/manual/function.mysql-fetch-assoc.php" rel="noreferrer">http://php.net/manual/function.mysql-fetch-assoc.php</a></p>
<pre><code>// While a row of data exists, put that row in $row as an associative arr... |
36,158,848 | How can I declare a global variable in Angular 2 / Typescript? | <p>I would like some variables to be accessible everywhere in an <code>Angular 2</code> in the <code>Typescript</code> language. How should I go about accomplishing this?</p> | 36,183,988 | 10 | 3 | null | 2016-03-22 15:40:43.783 UTC | 59 | 2020-09-15 08:34:15.113 UTC | 2019-05-12 01:01:08.283 UTC | null | 10,788,726 | null | 210,006 | null | 1 | 199 | typescript|angular | 393,158 | <p>Here is the simplest solution w/o <code>Service</code> nor <code>Observer</code>:</p>
<p>Put the global variables in a file an export them.</p>
<pre><code>//
// ===== File globals.ts
//
'use strict';
export const sep='/';
export const version: string="22.2.2";
</code></pre>
<p>To use globals in another f... |
56,881,982 | Vue - How to render HTML in vue components | <p>This is what I'm trying to accomplish:</p>
<pre><code>{{ span('Hello') }}
</code></pre>
<p>And what desired output should be is:</p>
<pre><code><span>
Hello
</span>
</code></pre>
<p>Is this possible?</p>
<p>Thanks</p> | 56,882,737 | 2 | 4 | null | 2019-07-04 06:40:25.85 UTC | 2 | 2019-07-14 16:31:15.28 UTC | 2019-07-14 16:31:15.28 UTC | null | 7,358,308 | null | 1,013,806 | null | 1 | 20 | vue.js|render|directive | 42,726 | <p>Look at the below snippet - </p>
<p>Note - You can't render <code>html</code> inside <code>{{ }}</code> because it get added to text node of the element. To render it as an html you need to use <code>v-html</code> and have your function which return <code>element</code> wrapping your text</p>
<p><div class="snipp... |
52,147,247 | Unwanted NullPointerException in ternary operator - Why? | <p>While executing the following code, I am getting a <code>NullPointerException</code> at line:</p>
<pre><code>value = condition ? getDouble() : 1.0;
</code></pre>
<p>In earlier lines when I use <code>null</code> instead of <code>getDouble()</code> everything works and this is strange.</p>
<pre><code>public class ... | 52,147,368 | 2 | 7 | null | 2018-09-03 09:49:37.65 UTC | 6 | 2020-01-10 07:07:15.23 UTC | 2020-01-10 07:07:15.23 UTC | null | 3,848,411 | null | 3,848,411 | null | 1 | 48 | java|nullpointerexception|double|conditional-operator | 2,697 | <p>When you write</p>
<pre><code>value = condition ? null : 1.0;
</code></pre>
<p>the type of <code>condition ? null : 1.0</code> must be a reference type, so the type is <code>Double</code>, which can hold the value <code>null</code>.</p>
<p>When you write</p>
<pre><code>value = condition ? getDouble() : 1.0;
</co... |
23,855,587 | Packaging Ruby into a portable executable | <p>I have been trying to find a good solution to this for a long time:</p>
<p>Is there a sure-fire way to install ruby to a folder which is portable on that platform? I want to have a folder which I can easily copy into a distribution I am making so I can have a ruby environment "on the go". It is fine if I need to co... | 23,969,446 | 3 | 2 | null | 2014-05-25 13:05:03.443 UTC | 8 | 2016-09-26 16:14:20.45 UTC | 2017-05-23 10:30:45.72 UTC | null | -1 | null | 741,850 | null | 1 | 19 | ruby|cross-platform|portability | 11,467 | <p>I got so tired of this that I decided to make my own solution to it. After a couple of days I finally got this working. </p>
<hr>
<h2>I present: <strong><a href="https://github.com/stephan-nordnes-eriksen/ruby_ship">Ruby Ship</a></strong></h2>
<p>It's just what I needed, and hopefully someone else will get the be... |
23,870,729 | Compress Videos using android MediaCodec api | <p>I want to compress locally saved video file to a smaller size in order to upload to a server. </p>
<p>Since i used MediaCodec , i have found some tips to compress video . Here are the steps that i followed</p>
<p>1) . Extracted the media file using MediaExrtactor and Decoded it.
2) . Creates the Encoder with... | 23,886,931 | 1 | 3 | null | 2014-05-26 12:57:58.843 UTC | 9 | 2014-05-27 12:13:29.76 UTC | 2017-05-23 12:02:05.337 UTC | null | -1 | null | 1,740,097 | null | 1 | 6 | android|compression|decode|encode|android-mediacodec | 13,829 | <p>You can try Intel INDE on <a href="https://software.intel.com/en-us/intel-inde" rel="nofollow">https://software.intel.com/en-us/intel-inde</a> and Media Pack for Android which is a part of INDE, tutorials on <a href="https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials" rel="nofollow... |
18,392,786 | How to submit a job to a specific node in PBS | <p>How do I send a job to a specific node in PBS/TORQUE?
I think you must specify the node name after nodes.</p>
<pre><code>#PBS -l nodes=abc
</code></pre>
<p>However, this doesn't seem to work and I'm not sure why.
This question was asked here on <a href="https://stackoverflow.com/questions/1731171/pbs-and-specify-... | 18,408,251 | 2 | 5 | null | 2013-08-23 00:20:10.387 UTC | 10 | 2019-09-20 06:44:24.173 UTC | 2017-05-23 11:47:08.517 UTC | null | -1 | null | 1,952,464 | null | 1 | 23 | bash|shell|pbs|torque | 45,105 | <p>You can do it like this:</p>
<pre><code>#PBS -l nodes=<node_name>
</code></pre>
<p>You can also specify the number of processors:</p>
<pre><code>#PBS -l nodes=<node_name>:ppn=X
</code></pre>
<p>Or you can request additional nodes, specified or unspecified:</p>
<pre><code>#PBS -l nodes=<node_name1>[... |
40,019,584 | Could not find method android() for arguments org.gradle.api.Project | <p>Getting a bug, when I try to compile my project in studio , i have search quite a bit with no real solution to it </p>
<p>Error:(17, 0) Could not find method android() for arguments [build_a7zf1o8ge4ow4uolz6kqzw5ov$_run_closure2@19201053] on root project 'booksStudioDir' of type org.gradle.api.Project.</p>
<p>This... | 40,021,349 | 3 | 4 | null | 2016-10-13 11:21:10.43 UTC | 4 | 2020-04-30 12:32:45.703 UTC | null | null | null | null | 4,917,624 | null | 1 | 16 | java|android|gradle|android-gradle-plugin | 47,610 | <p>There are two build.gradle files. One is in the top-level holder, and the other is in module holder. </p>
<p>Below is an example.</p>
<p>Top-level build.gradle:<br>
<a href="https://github.com/nickbutcher/plaid/blob/master/build.gradle" rel="noreferrer">https://github.com/nickbutcher/plaid/blob/master/build.gradle... |
41,022,927 | Principal component analysis (PCA) of time series data: spatial and temporal pattern | <p>Suppose I have yearly precipitation data for 100 stations from 1951 to 1980. In some papers, I find people apply PCA to the time series and then plot the spatial loadings map (with values from -1 to 1), and also plot the time series of the PCs. For example, figure 6 in <a href="https://publicaciones.unirioja.es/ojs... | 41,245,416 | 1 | 3 | null | 2016-12-07 16:45:38.337 UTC | 10 | 2016-12-20 15:07:25.96 UTC | 2016-12-18 20:23:23.827 UTC | null | 6,162,679 | null | 6,162,679 | null | 1 | 11 | r|spatial|pca|temporal | 16,994 | <p>"Temporal pattern" explains the dominant temporal variation of time series in all grids, and it is represented by <strong>principal components</strong> (PCs, a number of time series) of PCA. In R, it is <code>prcomp(data)$x[,'PC1']</code> for the most important PC, PC1.</p>
<p>"Spatial pattern" explains how strong ... |
41,098,009 | Mocking `document` in jest | <p>I'm trying to write tests for my web components projects in jest. I already use babel with es2015 preset. I'm facing an issue while loading the js file. I have followed a piece of code where <code>document</code> object has a <code>currentScript</code> object. But in test context it is <code>null</code>. So I was th... | 50,629,802 | 9 | 4 | null | 2016-12-12 09:47:44.663 UTC | 12 | 2021-11-11 00:18:31.267 UTC | 2018-12-03 11:36:07.153 UTC | null | 7,727,575 | null | 1,184,902 | null | 1 | 75 | jestjs|jsdom|babel-jest | 117,819 | <p>Similar to what others have said, but instead of trying to mock the DOM yourself, just use JSDOM:</p>
<pre class="lang-js prettyprint-override"><code>// __mocks__/client.js
import { JSDOM } from "jsdom"
const dom = new JSDOM()
global.document = dom.window.document
global.window = dom.window
</code></pre>
... |
4,879,706 | SSRS Report - IIF statement Question | <p>Doing an expression I get an error, can someone show me the correct syntax here? </p>
<pre><code>=IIf(Fields!t_cpcp.Value ="310", "Purchased Material & Raw Material", Nothing)
=IIf(Fields!t_cpcp.Value ="320", "Manufacturing Direct Labor", Nothing)
=IIf(Fields!t_cpcp.Value ="325", "Subcontract Cost", Nothing)
=I... | 4,879,844 | 2 | 5 | null | 2011-02-02 20:52:14.237 UTC | 1 | 2013-02-22 11:13:25.867 UTC | 2011-02-02 20:55:17.913 UTC | null | 11,027 | null | 426,733 | null | 1 | 6 | sql|if-statement|ssrs-2008|reporting-services | 40,365 | <p>If you want this to all be in one expression, you may want to use the SWITCH statement:</p>
<pre><code>=Switch(<condition>, <return value if true>, <next condition>, <return value if true>, ...)
</code></pre>
<p>The switch statement will return the value for the first condition that is true... |
4,893,432 | SSL on Apache2 with WSGI | <p>I am trying to set up SSL on a Django site I maintain and having a bit of trouble setting up my VirtualHost with SSL. I followed the instructions <a href="http://beeznest.wordpress.com/2008/04/25/how-to-configure-https-on-apache-2/" rel="noreferrer">here</a> but every time I try to restart apache, it tells me it can... | 4,895,652 | 2 | 0 | null | 2011-02-04 00:41:32.89 UTC | 12 | 2013-09-10 14:52:24.237 UTC | null | null | null | null | 206,506 | null | 1 | 46 | ssl|apache2|wsgi | 21,600 | <p>Remove the line:</p>
<pre><code>WSGIDaemonProcess mydomain user=myuser group=mygroup processes=1 threads=1
</code></pre>
<p>from the VirtualHost for 443. The WSGIProcessGroup for mydomain in that VirtualHost is able to reach across to the WSGIDaemonProcess definition in 80.</p>
<p>In other words, as the error mes... |
5,450,076 | What's the significant use of unary plus and minus operators? | <p>If unary <code>+</code>/<code>-</code> operators are used to perform conversions as the <code>Number()</code> casting function, then why do we need unary operators? What's the special need of these unary operators? </p> | 5,450,116 | 2 | 0 | null | 2011-03-27 15:07:42.13 UTC | 17 | 2021-10-06 17:51:18.047 UTC | 2016-01-26 08:24:55.61 UTC | null | 402,884 | null | 629,305 | null | 1 | 58 | javascript | 13,350 | <p>The Unary <code>+</code> operator converts its operand to Number type.
The Unary <code>-</code> operator converts its operand to Number type, and then negates it.
(per the <a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMAScript spec</a>)</p>
<p>In practice, Unary <code>-</code... |
16,439,037 | Drop Down List Selected Index changed not working in Update panel | <p>I have a drop down list in UpdatePanel_2, it gets populated when Button_1 is clicked in UpdatePanel_1.</p>
<p>My ddlist markup is,</p>
<pre><code><asp:DropDownList id="drop1" runat="server" EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="Drop1_SelectedIndexChanged" />
</code></pre>
<p>th... | 16,439,640 | 5 | 4 | null | 2013-05-08 11:06:04.91 UTC | 4 | 2017-07-14 16:03:51.617 UTC | 2013-05-21 11:30:52.667 UTC | null | 109,941 | null | 1,668,069 | null | 1 | 9 | c#|webforms|updatepanel | 51,870 | <p>Check the data to populate the <code>DropDownList</code> in the <code>Page_Load</code> event and always check <code>IspostBack</code>:</p>
<pre><code>if(!IsPostBack)
{
//DropDownList configuration
}
</code></pre>
<p>Use <code>EnableViewState</code>:</p>
<pre><code> <asp:DropDownList ID="ddlAddDepPlans" runat=... |
154,533 | Best way to bind WPF properties to ApplicationSettings in C#? | <p>What is the best way to bind WPF properties to ApplicationSettings in C#? Is there an automatic way like in a Windows Forms Application? Similar to <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">this question</a>, how (and is it possible to)... | 263,956 | 7 | 0 | null | 2008-09-30 19:20:29.08 UTC | 19 | 2013-07-01 15:17:19.983 UTC | 2017-05-23 11:54:43.513 UTC | Kris Erickson | -1 | Kris Erickson | 3,798 | null | 1 | 51 | c#|.net|wpf|visual-studio | 36,510 | <p>You can directly bind to the static object created by Visual Studio.</p>
<p>In your windows declaration add:</p>
<pre><code>xmlns:p="clr-namespace:UserSettings.Properties"
</code></pre>
<p>where <code>UserSettings</code> is the application namespace.</p>
<p>Then you can add a binding to the correct setting:</p>
... |
1,167,071 | What's the best way to set all values in a C# Dictionary<string,bool>? | <p>What's the best way to set all values in a C# Dictionary?</p>
<p>Here is what I am doing now, but I'm sure there is a better/cleaner way to do this:</p>
<pre><code>Dictionary<string,bool> dict = GetDictionary();
var keys = dict.Keys.ToList();
for (int i = 0; i < keys.Count; i++)
{
dict[keys[i]] = fals... | 1,167,089 | 8 | 0 | null | 2009-07-22 17:57:31.423 UTC | 0 | 2021-04-07 13:03:53.717 UTC | null | null | null | null | 64,334 | null | 1 | 38 | c#|.net|generics|dictionary | 39,175 | <p>That is a reasonable approach, although I would prefer:</p>
<pre><code>foreach (var key in dict.Keys.ToList())
{
dict[key] = false;
}
</code></pre>
<p>The call to <code>ToList()</code> makes this work, since it's pulling out and (temporarily) saving the list of keys, so the iteration works.</p> |
1,039,725 | How to do URL re-writing in PHP? | <p>I am trying to implement URL rewriting in my PHP application. Can someone share a step by step procedure of implementing URL rewriting in PHP and MySQL?</p>
<p>In my application I want to implement following URL rewriting, I want to redirect</p>
<pre><code>1. http://example.com/videos/play/google-io-2009-wave-intr... | 1,039,873 | 9 | 2 | null | 2009-06-24 17:17:20.517 UTC | 18 | 2017-05-12 09:08:47.01 UTC | 2014-06-10 13:30:57.793 UTC | null | 472,495 | null | 45,261 | null | 1 | 14 | php|apache|mod-rewrite|seo|url-rewriting | 35,863 | <p><a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" rel="nofollow noreferrer">A Beginner's Guide to mod_rewrite</a>.</p>
<p>Typically this will be nothing more than enabling the mod_rewrite module (you likely already have it enabled with your host), and then adding a .htaccess file into your web-d... |
316,757 | UK Vat change from 17.5 to 15% - How will this affect your code? | <p>The UK VAT system is changing from 17.5% to 15%. What strategies have you used in your code to store the VAT, and how will the change affect your applications. Do you store a history of vats so you can calculate old prices, or are old invoices stored in a separate table? Is it a simple config setting, or did you bod... | 316,962 | 9 | 0 | null | 2008-11-25 09:02:40.893 UTC | 9 | 2014-07-04 11:09:34.34 UTC | 2009-01-16 15:23:21.23 UTC | Mohit Nanda | 18,615 | digiguru | 5,055 | null | 1 | 17 | database-design|configuration-management | 13,633 | <h2>Don't calculate it. Store it!</h2>
<p>HMRC are very fussy about getting paid the right amount of VAT. The rounding of VAT calculations is somewhat vaguely specified in the user guides, and leaving it up to future implementers to get it right is possibly asking for trouble. By storing the amount when the invoice/li... |
551,668 | How do I set the default Java installation/runtime (Windows)? | <p>I'm in the situation where I've installed the JDK, but I can't run applets in browsers (I may not have installed the JRE).</p>
<p>However, when I install the JRE, it clobbers my JDK as the default runtime. This breaks pretty much everything (Eclipse, Ant) - as they require a server JVM.</p>
<p>There's no <code>JA... | 551,709 | 9 | 2 | null | 2009-02-15 21:54:51.95 UTC | 13 | 2020-10-26 12:31:48.647 UTC | 2018-09-07 11:58:00.513 UTC | Stephen | 7,023,590 | Stephen | 37,193 | null | 1 | 52 | java|windows|installation|runtime | 159,148 | <p>This is a bit of a pain on Windows. Here's what I do.</p>
<p>Install latest Sun JDK, e.g. <strong>6u11</strong>, in path like <code>c:\install\jdk\sun\6u11</code>, then let the installer install public JRE in the default place (<code>c:\program files\blah</code>). This will setup your default JRE for the majority o... |
832,375 | Force a transactional rollback without encountering an exception? | <p>I have a method that does a bunch of things; amongst them doing a number of inserts and updates.</p>
<p>It's declared thusly:</p>
<pre><code>@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
public int saveAll() {
//do stuff;
}
</code></pre>
<p>It works exactly as i... | 835,384 | 9 | 1 | null | 2009-05-07 00:11:24.887 UTC | 18 | 2021-12-04 14:48:29.77 UTC | 2021-06-15 10:58:26.387 UTC | null | 452,775 | null | 59,947 | null | 1 | 52 | java|hibernate|spring | 52,464 | <p>In Spring Transactions, you use <code>TransactionStatus.setRollbackOnly()</code>. </p>
<p>The problem you have here is that you're using <code>@Transactional</code> to demarcate your transactions. This has the benefit of being non-invasive, but it also means that if you want to manually interact with the transacti... |
593,334 | How to use multiple AWS accounts from the command line? | <p>I've got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2.</p>
<p>How can I work with both accounts at the command line (Mac OS X) but keep the EC2 keys & certificates separate? Do I need to change my environment variables before each ec2-* command?</p>
<p>Would using a... | 593,361 | 10 | 0 | null | 2009-02-27 02:50:38.56 UTC | 61 | 2022-04-13 11:58:52.85 UTC | 2021-01-06 08:59:39.233 UTC | null | 6,862,601 | Matt Culbreth | 43,207 | null | 1 | 196 | amazon-web-services|amazon-ec2|aws-cli | 117,688 | <p>You should be able to use the following command-options in lieu of the <code>EC2_PRIVATE_KEY</code> (and even <code>EC2_CERT</code>) environment variables:</p>
<ul>
<li><code>-K <private key></code></li>
<li><code>-C <certificate></code></li>
</ul>
<p>You can put these inside aliases, e.g.</p>
<pre><c... |
136,734 | Key Presses in Python | <p>Is it possible to make it appear to a system that a key was pressed, for example I need to make <kbd>A</kbd> key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.</p>
<p>A better way t... | 136,780 | 11 | 1 | null | 2008-09-25 22:58:01.09 UTC | 17 | 2021-07-30 14:08:27.31 UTC | 2012-02-23 08:31:57.103 UTC | Unkwntech | 355,231 | Unkwntech | 115 | null | 1 | 40 | python|keypress | 200,274 | <p>Install the <a href="https://github.com/mhammond/pywin32" rel="noreferrer">pywin32</a> extensions. Then you can do the following:</p>
<pre><code>import win32com.client as comclt
wsh= comclt.Dispatch("WScript.Shell")
wsh.AppActivate("Notepad") # select another application
wsh.SendKeys("a") # send the keys you want
<... |
401,635 | Good beginners material on Prolog | <p>I am looking for good beginners material on Prolog, both online and printed. I am not only interested in 'learning the language' but also in background and scientific information.</p> | 401,768 | 11 | 1 | null | 2008-12-30 21:54:48.367 UTC | 61 | 2013-03-12 15:11:34.593 UTC | 2011-12-09 18:19:04.76 UTC | null | 3,043 | MeeLow | 50,317 | null | 1 | 70 | prolog|artificial-intelligence | 15,187 | <p>Check out <a href="http://www.learnprolognow.org/" rel="noreferrer">Learn Prolog Now!</a></p>
<p>This book is well-written, should be easy to read for beginners. It's available in printed form and also as a free online version. It is also relatively new (from 2003), which is not the case with many Prolog books out ... |
176,476 | How can I automate HTML-to-PDF conversions? | <p>I've been using htmldoc for a while, but I've run into some fairly serious limitations. I need the end solution to work on a Linux box. I'll be calling this library/utility/application from a Perl app, so any Perl interfaces would be a bonus.</p> | 176,957 | 16 | 0 | null | 2008-10-06 22:34:53.567 UTC | 11 | 2021-04-10 13:25:20.173 UTC | 2010-01-08 12:59:42.553 UTC | null | 2,766,176 | null | 2,901 | null | 1 | 48 | linux|perl|pdf | 74,926 | <p>NOTE: This answer is from 2008 and is probably now incorrect; please check the other answers</p>
<p><a href="http://www.princexml.com/" rel="nofollow noreferrer">PrinceXML</a> is the best one I've seen (it parses regular HTML as well as XML/XHTML). How is it the best? <a href="http://www.princexml.com/samples/acid2... |
703,035 | When are you truly forced to use UUID as part of the design? | <p>I don't really see the point of <a href="http://en.wikipedia.org/wiki/UUID" rel="noreferrer">UUID</a>. I know the probability of a collision is <em>effectively nil</em>, but <em>effectively nil</em> is not even close to impossible.</p>
<p>Can somebody give an example where you have no choice but to use UUID? From... | 786,541 | 16 | 9 | null | 2009-03-31 21:01:38.077 UTC | 86 | 2018-11-02 19:12:11.337 UTC | 2018-11-02 19:12:11.337 UTC | Pyrolistical | 2,370,483 | Pyrolistical | 21,838 | null | 1 | 134 | architecture|uuid | 45,822 | <p>I wrote the UUID generator/parser for Ruby, so I consider myself to be reasonably well-informed on the subject. There are four major UUID versions:</p>
<p>Version 4 UUIDs are essentially just 16 bytes of randomness pulled from a cryptographically secure random number generator, with some bit-twiddling to identify t... |
203,495 | Testing REST webservices | <p>My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.</p>
<ol>
<li>Are there any publicly available RESTful services available on the net f... | 1,037,408 | 24 | 2 | null | 2008-10-15 02:06:56.057 UTC | 31 | 2015-04-01 19:34:18.263 UTC | 2013-01-15 08:20:49.967 UTC | anjanb | 1,484,739 | anjanb | 11,142 | null | 1 | 63 | java|web-services|rest|testing|rest-client | 58,173 | <p><a href="http://www.soapui.org" rel="noreferrer">soapUI</a> will do the job as well, check out <a href="http://www.eviware.com/blogs/oleblog/?p=11" rel="noreferrer">this blog post</a> to get started.</p> |
1,340,224 | iPhone UITextField - Change placeholder text color | <p>I'd like to change the color of the placeholder text I set in my <code>UITextField</code> controls, to make it black.</p>
<p>I'd prefer to do this without using normal text as the placeholder and having to override all the methods to imitate the behaviour of a placeholder.</p>
<p>I believe if I override this metho... | 3,396,065 | 32 | 0 | null | 2009-08-27 10:36:19.59 UTC | 146 | 2022-05-27 16:04:30.517 UTC | 2016-08-03 05:44:36.79 UTC | null | 4,078,527 | null | 33,604 | null | 1 | 585 | ios|uitextfield | 377,237 | <p>You can override <code>drawPlaceholderInRect:(CGRect)rect</code> as such to manually render the placeholder text:</p>
<pre><code>- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]];
}
</code></pre> |
454,202 | Creating a textarea with auto-resize | <p>There was <a href="https://stackoverflow.com/questions/7477/autosizing-textarea">another thread about this</a>, which I've tried. But there is one problem: the <code>textarea</code> doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the <code>clientHeight</code> value c... | 5,346,855 | 49 | 6 | null | 2009-01-17 22:30:42.113 UTC | 208 | 2022-08-30 10:08:43.263 UTC | 2018-03-24 14:42:11.143 UTC | null | 3,215,948 | DisgruntledGoat | 37,947 | null | 1 | 465 | javascript|html|resize|height|textarea | 600,285 | <p>This works for me (Firefox 3.6/4.0 and Chrome 10/11):</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>var observe;
if (window.attachEvent) {
observe = function (element... |
6,334,537 | Rails where() clause on model association? | <p>Suppose I have an Account model which has_many Users. Accounts have a boolean "active" column. How can I get all Users that belong to "active" accounts?</p>
<pre><code>@users_of_active_accounts = User.?
</code></pre>
<p>Thanks!</p> | 6,334,716 | 5 | 1 | null | 2011-06-13 18:24:34.517 UTC | 19 | 2020-03-14 17:54:41.013 UTC | null | null | null | null | 461,218 | null | 1 | 52 | ruby-on-rails | 40,874 | <p>You need to join the accounts table and merge appropriate Account scope:</p>
<pre><code>User.joins(:account).merge(Account.where(:active => true))
</code></pre> |
6,325,018 | Android activity as dialog, but without a title bar | <p>I have an activity that has the following set as theme:</p>
<pre><code>android:theme="@android:style/Theme.Dialog"
</code></pre>
<p>However, there is a title bar in the activity-dialog that appears, that uses up the little available space that I have. How can I remove it?</p> | 6,325,045 | 9 | 1 | null | 2011-06-12 22:08:26.89 UTC | 10 | 2022-01-31 15:37:21.383 UTC | null | null | null | null | 361,230 | null | 1 | 77 | android|webview|titlebar | 47,913 | <p>Try doing <code>requestWindowFeature(Window.FEATURE_NO_TITLE);</code> in <code>onCreate</code>. It'll need to be done immediately after calling <code>super.onCreate</code> and just before <code>setContentView</code>.</p> |
45,323,271 | How To Run Selenium With Chrome In Docker | <p>I installed google-chrome in a <a href="https://www.docker.com/" rel="noreferrer">Docker</a>, but when I run my <a href="https://www.python.org/downloads/release/python-272/" rel="noreferrer">Python 2</a> script of <a href="https://www.seleniumhq.org/download/" rel="noreferrer">Selenium</a>, it failed like this:</p>... | 45,324,730 | 4 | 3 | null | 2017-07-26 09:45:45.037 UTC | 25 | 2022-01-15 20:33:16.843 UTC | 2019-09-05 11:45:37.49 UTC | null | 11,705,601 | null | 7,314,559 | null | 1 | 45 | python|python-2.7|selenium|docker|google-chrome | 87,704 | <p>You need to launch a standalone chrome browser</p>
<pre><code>docker run -d -p 4444:4444 selenium/standalone-chrome
</code></pre>
<p>and then in your python script launch browser using Remote webdriver</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCap... |
15,657,812 | Modify a column to NULL - Oracle | <p>I have a table named <code>CUSTOMER</code>, with few columns. One of them is <code>Customer_ID</code>.</p>
<p>Initially <code>Customer_ID</code> column <code>WILL NOT</code> accept <code>NULL</code> values.</p>
<p>I've made some changes from code level, so that <code>Customer_ID</code> column will accept <code>NUL... | 15,657,994 | 5 | 1 | null | 2013-03-27 11:33:34.933 UTC | 1 | 2021-03-25 11:10:06.11 UTC | null | null | null | null | 2,147,481 | null | 1 | 12 | oracle11g | 93,836 | <p>You can use the column NULLABLE in <a href="http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_2103.htm#REFRN20277" rel="noreferrer">USER_TAB_COLUMNS</a>. This tells you whether the column allows nulls using a binary Y/N flag.</p>
<p>If you wanted to put this in a script you could do something like:</p... |
15,706,077 | PHP Convert Windows-1251 to UTF 8 | <p>I have a small html code and I need to convert it to UTF-8.<br />
I use this <code>iconv("windows-1251", "utf-8", $html);</code></p>
<p>All text converts correctly, but if text for example in tag <code><i>...</i></code>, then it don't convert text and I see somethig like this <code>Показать мн... | 15,706,337 | 5 | 1 | null | 2013-03-29 15:16:38.633 UTC | 2 | 2020-11-20 18:53:49.653 UTC | 2015-05-29 00:18:04.723 UTC | null | 772,521 | null | 2,058,653 | null | 1 | 13 | php|utf-8|character-encoding|windows-1251 | 77,927 | <p>If you have access to the Multibye package, you can try it. See the PHP page here:
<a href="http://www.php.net/manual/en/function.mb-convert-encoding.php" rel="noreferrer">http://www.php.net/manual/en/function.mb-convert-encoding.php</a></p>
<pre><code>$html_utf8 = mb_convert_encoding($html, "utf-8", "windows-1251"... |
15,651,084 | Error with ggplot2 mapping variable to y and using stat="bin" | <p>I am using ggplot2 to make a histogram:</p>
<pre><code>geom_histogram(aes(x=...), y="..ncount../sum(..ncount..)")
</code></pre>
<p>and I get the error:</p>
<pre><code>Mapping a variable to y and also using stat="bin".
With stat="bin", it will attempt to set the y value to the count of cases in each group.
Thi... | 15,651,541 | 2 | 5 | null | 2013-03-27 02:44:41.543 UTC | 8 | 2017-09-06 03:41:55.737 UTC | 2016-04-08 18:40:22.217 UTC | null | 881,229 | user248237 | null | null | 1 | 16 | r|ggplot2 | 16,480 | <p>The confusion here is a long standing one (as evidenced by the verbose warning message) that all starts with <code>stat_bin</code>.</p>
<p>But users don't typically realize that their confusion revolves around <code>stat_bin</code>, since they typically encounter problems while using either <code>geom_bar</code> or... |
15,519,716 | How can I resize an image file uploaded with Django using an ImageField Model? | <p>What is the most straightforward method to resize an image file uploaded via a Django form as an <code>ImageField</code>? </p> | 15,523,422 | 2 | 5 | null | 2013-03-20 09:30:52.34 UTC | 8 | 2018-09-19 01:23:02.37 UTC | 2018-09-19 01:23:02.37 UTC | null | 1,305,947 | null | 853,488 | null | 1 | 24 | django|image|upload|resize|photo | 35,675 | <p>I was annoyed that I couldn't find a complete working example, only bits here and there. I managed to put the solution together myself. Here is the complete example, I put it in clean() method of the form (you can also override models save() method, in the completely same way - changing ImageField's file property).<... |
15,691,942 | Print array elements on separate lines in Bash? | <p>How do I print the array element of a Bash array on separate lines? This one works, but surely there is a better way:</p>
<pre><code>$ my_array=(one two three)
$ for i in ${my_array[@]}; do echo $i; done
one
two
three
</code></pre>
<p>Tried this one but it did not work:</p>
<pre><code>$ IFS=$'\n' echo ${my_array[... | 15,692,004 | 7 | 1 | null | 2013-03-28 20:53:47.937 UTC | 72 | 2021-02-07 14:35:20.033 UTC | 2019-09-14 03:30:21.843 UTC | null | 608,639 | null | 155,425 | null | 1 | 301 | arrays|bash | 435,408 | <p>Try doing this :</p>
<pre><code>$ printf '%s\n' "${my_array[@]}"
</code></pre>
<p>The difference between <code>$@</code> and <code>$*</code>:</p>
<ul>
<li><p>Unquoted, the results are unspecified. In Bash, both expand to separate args
and then wordsplit and globbed.</p></li>
<li><p>Quoted, <code>"$@"</code> expan... |
16,023,451 | Binding variables from Service/Factory to Controllers | <p>I have a variable that will be used by one or more Controllers, changed by Services.
In that case, I've built a service that keeps this variable in memory, and share between the controllers.</p>
<p>The problem is: Every time that the variable changes, the variables in the controllers aren't updated in real time. </... | 16,025,241 | 2 | 0 | null | 2013-04-15 19:39:31.58 UTC | 25 | 2016-04-06 17:29:31.76 UTC | 2016-04-06 17:29:31.76 UTC | null | 1,247,330 | null | 1,481,408 | null | 1 | 69 | angularjs|angularjs-directive | 95,733 | <p>You can't bind variables. But you can bind variable accessors or objects which contain this variable. Here is fixed <a href="http://jsfiddle.net/xuUHS/1/">jsfiddle</a>.</p>
<p>Basically you have to pass to the scope something, which can return/or holds current value. E.g.</p>
<p>Factory:</p>
<pre><code>app.factor... |
15,921,458 | How to kill/stop a long SQL query immediately? | <p>I am using SQL server 2008 and its management studio. I executed a query that yields many rows. I tried to cancel it via the red cancel button, but it has not stopped for the past 10 minutes. It usually stops within 3 minutes. </p>
<p>What could the reason be and how do I stop it immediately ?</p> | 15,921,769 | 12 | 4 | null | 2013-04-10 09:03:39.067 UTC | 35 | 2021-06-10 15:40:38.36 UTC | null | null | null | null | 1,971,910 | null | 1 | 122 | sql|sql-server|sql-server-2008 | 439,707 | <blockquote>
<p>What could the reason be</p>
</blockquote>
<p>A query cancel is immediate, provided that your <a href="http://msdn.microsoft.com/en-us/library/dd341449.aspx" rel="noreferrer">attention</a> can reach the server and be processed. A query must be in a cancelable state, which is almost always true except if... |
15,636,367 | NodeJS require a global module/package | <p>I'm trying to install globally and then use <code>forever</code> and <code>forever-monitor</code> like this:</p>
<p><code>npm install -g forever forever-monitor</code></p>
<p>I see the usual output and also the operations that copy the files to the global path, but then if I try to <code>require("forever");</code>... | 15,646,750 | 9 | 3 | null | 2013-03-26 11:49:07.18 UTC | 67 | 2020-12-25 23:13:56.837 UTC | null | null | null | null | 940,158 | null | 1 | 211 | node.js|package|npm | 109,100 | <p>In Node.js, require doesn't look in the folder where global modules are installed.</p>
<p>You can fix this by setting the NODE_PATH environment variable. In Linux this will be:</p>
<pre><code>export NODE_PATH=/usr/lib/node_modules
</code></pre>
<p><sup>Note: This depend on where your global modules are actually i... |
32,896,140 | Using a variable with the same name in different spaces | <p>This code compiles, but I have a run time error in <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio" rel="noreferrer">Visual Studio</a>:</p>
<blockquote>
<p>Run-time check failure #3 - the variable 'x' is being used without being initialized...</p>
</blockquote>
<pre><code>int x = 15;
int main()
{
... | 32,896,213 | 4 | 8 | null | 2015-10-01 20:16:50.86 UTC | null | 2015-10-06 11:53:13.103 UTC | 2015-10-02 07:35:36.65 UTC | null | 2,684,539 | null | 2,947,765 | null | 1 | 41 | c++|c|variable-declaration | 1,769 | <p><code>x</code> is defined at the left of <code>=</code>.</p>
<p>so in <code>x[x]</code>, <code>[x]</code> refer to the global one,</p>
<p>whereas in <code>x = x;</code>, <code>x</code> hides the global <code>x</code> and initializes from itself -> UB.</p> |
50,593,516 | Colored pixels in scrollbar in VS Code | <p>I've recently started using VS Code, and I've noticed that there are little colored pixels that show up in the scroll bar like this:</p>
<p><a href="https://i.stack.imgur.com/WFvqI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WFvqI.png" alt="enter image description here"></a></p>
<p>They seem to indic... | 51,684,408 | 3 | 4 | null | 2018-05-29 21:53:29.44 UTC | 11 | 2020-08-26 15:36:44.193 UTC | 2018-05-30 00:20:51.943 UTC | null | 4,092,216 | null | 4,092,216 | null | 1 | 26 | visual-studio-code | 9,548 | <p>The feature is called <strong>Overview Ruler</strong>. I've been unable to find specific documentation except some <a href="https://code.visualstudio.com/docs/editor/editingevolved#_errors-warnings" rel="noreferrer">sparse notes</a>:</p>
<blockquote>
<p>If you open a file that has errors or warnings, they will be... |
10,631,473 | 'str' object does not support item assignment | <p>I would like to read some characters from a string <code>s1</code> and put it into another string <code>s2</code>.</p>
<p>However, assigning to <code>s2[j]</code> gives an error:</p>
<pre class="lang-py prettyprint-override"><code>s2[j] = s1[i]
# TypeError: 'str' object does not support item assignment
</code></pre... | 10,631,478 | 10 | 3 | null | 2012-05-17 07:18:41.07 UTC | 34 | 2022-05-13 22:50:00.573 UTC | 2021-08-19 00:27:34.393 UTC | null | 365,102 | null | 1,105,805 | null | 1 | 213 | python|string | 591,488 | <p>In Python, strings are immutable, so you can't change their characters in-place.</p>
<p>You can, however, do the following:</p>
<pre><code>for c in s1:
s2 += c
</code></pre>
<p>The reasons this works is that it's a shortcut for:</p>
<pre><code>for c in s1:
s2 = s2 + c
</code></pre>
<p>The above <em>creates a... |
10,459,917 | traversing through JSON string to inner levels using recursive function | <p>I have a JSON input which can go to any number of levels.</p>
<p>I'm giving an input sample of </p>
<pre class="lang-js prettyprint-override"><code>var d=getEntities( {"Categories":
{
"Facets":
[
{
"count": 1,
"entity": "Company",
"Company":
[
{
"entity":... | 10,460,119 | 5 | 6 | null | 2012-05-05 07:44:21.583 UTC | 2 | 2020-10-30 00:34:19.743 UTC | 2012-05-06 14:24:38.543 UTC | null | 1,371,896 | null | 1,371,896 | null | 1 | 10 | javascript|arrays|json|object | 39,411 | <p>I have made a <a href="http://jsfiddle.net/t4p9G/" rel="nofollow noreferrer">jsfiddle</a> which traverses every object,array and value in the JS object like so...</p>
<pre><code>function scan(obj) {
var k;
if (obj instanceof Object) {
for (k in obj){
if (obj.hasOwnProperty(k)){
... |
32,027,935 | ".addEventListener is not a function" why does this error occur? | <p>I’m getting an ".addEventListener is not a function" error. I am stuck on this:</p>
<pre><code>var comment = document.getElementsByClassName("button");
function showComment() {
var place = document.getElementById('textfield');
var commentBox = document.createElement('textarea');
place.appendChild(commentBox);... | 32,027,957 | 6 | 3 | null | 2015-08-15 18:28:24.953 UTC | 29 | 2022-09-16 18:56:55.103 UTC | 2017-12-22 13:12:59.83 UTC | null | 2,311,559 | null | 5,207,616 | null | 1 | 83 | javascript|html | 365,765 | <p>The problem with your code is that the your script is executed prior to the html element being available. Because of the that <code>var comment</code> is an empty array.</p>
<p>So you should move your script after the html element is available. </p>
<p>Also, <code>getElementsByClassName</code> returns html collect... |
22,492,162 | Understanding the main method of python | <p>I am new to Python, but I have experience in other OOP languages. My course does not explain the main method in python. </p>
<p>Please tell me how main method works in python ? I am confused because I am trying to compare it to Java. </p>
<pre><code>def main():
# display some lines
if __name__ == "__main__": main... | 22,493,194 | 4 | 4 | null | 2014-03-18 22:14:32.553 UTC | 59 | 2019-04-25 17:28:15.527 UTC | 2019-04-25 17:28:15.527 UTC | null | 3,184,475 | null | 3,184,475 | null | 1 | 163 | python|python-3.x | 391,740 | <p>The Python approach to "main" is almost unique to the language(*).</p>
<p>The semantics are a bit subtle. The <code>__name__</code> identifier is bound to the name of any module as it's being imported. However, when a file is being executed then <code>__name__</code> is set to <code>"__main__"</code> (the literal... |
13,404,722 | Retrieve analyzed tokens from ElasticSearch documents | <p>Trying to access the analyzed/tokenized text in my ElasticSearch documents.</p>
<p>I know you can use the <a href="http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html" rel="noreferrer">Analyze API</a> to analyze arbitrary text according your analysis modules. So I could copy and paste data ... | 13,407,266 | 3 | 1 | null | 2012-11-15 19:28:50.777 UTC | 3 | 2021-04-25 15:48:12.767 UTC | 2013-01-16 16:21:03.727 UTC | null | 127,880 | null | 943,184 | null | 1 | 38 | text|elasticsearch|tokenize | 25,401 | <p>Have a look at this other answer: <a href="https://stackoverflow.com/questions/13178550/elasticsearch-return-the-tokens-of-a-field/13182001#13182001">elasticsearch - Return the tokens of a field</a>. Unfortunately it requires to reanalyze on the fly the content of your field using the script provided.<br>
It should ... |
13,243,766 | How to define an empty generator function? | <p>A generator function can be defined by putting the <code>yield</code> keyword in the function’s body:</p>
<pre class="lang-py prettyprint-override"><code>def gen():
for i in range(10):
yield i
</code></pre>
<p>How to define an empty generator function?</p>
<p>The following code doesn’t work, since Python... | 13,243,870 | 10 | 0 | null | 2012-11-06 03:08:13.517 UTC | 18 | 2022-04-30 20:08:31.96 UTC | 2022-04-30 20:08:31.96 UTC | null | 2,326,961 | null | 607,405 | null | 1 | 136 | python|generator | 53,536 | <p>You can use <code>return</code> once in a generator; it stops iteration without yielding anything, and thus provides an explicit alternative to letting the function run out of scope. So use <code>yield</code> to turn the function into a generator, but precede it with <code>return</code> to terminate the generator be... |
13,574,980 | jQuery - replace all instances of a character in a string | <p>This does not work and I need it badly</p>
<pre><code>$('some+multi+word+string').replace('+', ' ' );
</code></pre>
<p>always gets</p>
<pre><code>some multi+word+string
</code></pre>
<p>it's always replacing for the first instance only, but I need it to work for all + symbols.</p> | 13,574,989 | 3 | 6 | null | 2012-11-26 23:30:33.74 UTC | 28 | 2013-09-19 19:42:45.94 UTC | null | null | null | null | 803,358 | null | 1 | 210 | jquery|string|replace | 539,764 | <p>You need to use a regular expression, so that you can specify the global (g) flag:</p>
<pre><code>var s = 'some+multi+word+string'.replace(/\+/g, ' ');
</code></pre>
<p>(I removed the <code>$()</code> around the string, as <code>replace</code> is not a jQuery method, so that won't work at all.)</p> |
39,734,632 | Can't bind to 'routerLink' since it isn't a known property of 'a' | <p>I'm updating one of our apps from rc4 to angular2.0.0 and I'm getting a template parse error at run time. Here is my view template:</p>
<pre><code><div *ngFor="let widget of widgets" class="col-xs-3 quick-link">
<a [routerLink]="['/Tile', widget.WidgetRoute.Feature, widget.WidgetRoute.SubFeature]">... | 39,735,050 | 2 | 2 | null | 2016-09-27 21:31:43.04 UTC | 1 | 2016-09-27 22:14:04.737 UTC | 2016-09-27 21:48:53.18 UTC | null | 491,436 | null | 491,436 | null | 1 | 25 | angular|angular2-routing | 45,054 | <p>The problem is that you forgot to add <code>RouterModule</code> to your <code>NgModule</code> component. In the RC this was added to the <code>@Component({directives: [ROUTER_DIRECTIVES]})</code>, however, this is now moved into <code>@NgModule({ imports: [RouterModule]})</code>.</p>
<p>When you define your routes,... |
24,293,376 | JavaScript : For loop with timeout | <p>I want that my for loop should not be executed at once, but wait for timeout after each iteration. For eg : </p>
<pre><code>for(var i=0; i<10; i++) {
console.log(i);
//wait for 1000
}
</code></pre>
<p>I found many solutions on stack-overflow like this one : </p>
<pre><code>for (var i=0;i<=10;i++) {
... | 24,293,516 | 14 | 2 | null | 2014-06-18 19:12:56.517 UTC | 14 | 2022-05-12 14:43:40 UTC | 2018-12-19 07:14:37.17 UTC | null | 2,319,858 | null | 2,319,858 | null | 1 | 26 | javascript|settimeout | 63,627 | <p>You can work that out with simple math :</p>
<pre><code>for (var i=0;i<=10;i++) {
(function(ind) {
setTimeout(function(){console.log(ind);}, 1000 + (3000 * ind));
})(i);
}
</code></pre>
<blockquote>
<p>1000ms : 0 <br/>
4000ms : 1 <br />
7000ms : 2 <br/>
10000ms : 3 <br/>
13000ms : 4 <br/>
...</p>
</b... |
29,732,377 | How to disable adding ".self." in Sprockets 3.0 | <p>Even if <code>config.assets.digest = false</code> is set Sprockets 3.0 keep adding <code>.self.</code> to all static files:
<code>application.css</code> becomes <code>application.self.css?body=1</code></p>
<p>How to disable adding <code>self</code>? It is needed for correct browsersync work.</p> | 32,898,659 | 2 | 5 | null | 2015-04-19 16:14:28.313 UTC | 7 | 2015-10-02 00:07:23.887 UTC | 2015-04-26 12:12:52.953 UTC | null | 297,939 | null | 297,939 | null | 1 | 37 | ruby-on-rails-4|sprockets | 3,093 | <p>In Sprockets 3, <code>.self.css</code> is added because you have the <code>config.assets.debug = true</code> config set (not the digest config, that's unrelated).</p>
<p>If you add the following to your <code>development.rb</code> or <code>production.rb</code> file, it will work as you expect:</p>
<pre><code>confi... |
16,099,752 | Session or cookie confusion | <p>I've seen in some websites that user signed in into their accounts and then closed the browser.</p>
<p>After closed and re-opened the browser and their accounts are still signed in.</p>
<p>But some websites, cannot do like that.</p>
<p>I'm confused that it's considered session or cookie?</p>
<p>If I want my webs... | 16,107,272 | 2 | 3 | null | 2013-04-19 07:44:16.523 UTC | 26 | 2018-10-09 13:20:49.517 UTC | 2013-04-19 15:06:42.803 UTC | null | 157,882 | null | 1,735,186 | null | 1 | 19 | session|servlets|cookies | 49,095 | <p><strong>* This answer has serious flaws, see comments. *</strong></p>
<hr>
<p>Your question is about <em>session tracking</em>.</p>
<p><strong>[PART 1] : SESSION OBJECT</strong></p>
<p>HTTP-request are processed separately, so in order to keep information between each request (for instance, information about the... |
16,189,208 | How does this CSS produce a circle? | <p>This is the CSS:</p>
<pre><code>div {
width: 0;
height: 0;
border: 180px solid red;
border-radius: 180px;
}
</code></pre>
<p>How does it produce the circle below?</p>
<p><img src="https://i.stack.imgur.com/yTmLN.jpg" alt="Enter image description here"></p>
<p>Suppose, if a rectangle width is 180 ... | 16,189,351 | 5 | 4 | null | 2013-04-24 10:08:31.443 UTC | 82 | 2015-12-31 12:55:39.71 UTC | 2015-12-31 12:55:39.71 UTC | null | 2,606,013 | null | 2,313,718 | null | 1 | 210 | html|css|css-shapes | 21,779 | <blockquote>
<p>How does a border of 180 pixels with height/width-> 0px become a circle with a radius of 180 pixels?</p>
</blockquote>
<p>Let's reformulate that into two questions:</p>
<h2>Where do <code>width</code> and <code>height</code> actually apply?</h2>
<p>Let's have a look at the areas of a typical box (<... |
16,133,923 | 400 vs 422 response to POST of data | <p>I'm trying to figure out what the correct status code to return on different scenarios with a "REST-like" API that I'm working on. Let's say I have an end point that allows POST'ing purchases in JSON format. It looks like this:</p>
<pre><code>{
"account_number": 45645511,
"upc"... | 20,215,807 | 8 | 1 | null | 2013-04-21 17:13:39.107 UTC | 115 | 2022-05-06 21:02:53.68 UTC | 2020-12-16 00:12:44.22 UTC | null | 453,596 | null | 265,681 | null | 1 | 487 | rest|http-status-codes | 507,324 | <p><strong>400 Bad Request</strong> would now seem to be the best HTTP/1.1 status code for your use case.</p>
<p><strong>At the time of your question</strong> (and my original answer), <a href="https://www.rfc-editor.org/rfc/rfc7231" rel="noreferrer">RFC 7231</a> was not a thing; at which point I objected to <code>400 ... |
15,253,692 | MVC 4 Ajax.beginform submit - causes full postback | <p>MVC4 Internet project</p>
<p>I'm using Ajax.BeginForm to do a Postback with validation and it posts back the entire page rather than just the UpdateTargetID. I've looked at other posts on SO and haven't found the answer. I've built a new MVC4 Internet project just for testing (VS 2012 has been updated with 'ASP.NE... | 15,489,634 | 6 | 0 | null | 2013-03-06 17:11:04.18 UTC | 4 | 2016-02-10 18:43:51.583 UTC | 2013-03-10 19:07:26.58 UTC | null | 1,258,671 | null | 1,258,671 | null | 1 | 7 | asp.net-mvc|jquery | 38,214 | <p>The contents of the UpdateTargetID must be in a partial view and that partial view needs to be called from the Controller Post Action. Darin answered me through e-mail (thank you Darin). You need to use a parital view. I've tried to update his answer twice and the moderators have not done it or provided an explanati... |
24,604,817 | How to Add a Boolean Column in Android SQlite | <p>I have created a table for my <code>ContentProvider</code> using the following line :</p>
<pre><code>static final String CREATE_DB_TABLE =
" CREATE TABLE " + CONTACTS_TABLE_NAME +
" (_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
" pid TEXT NOT NULL, " +
" name TEXT NOT NULL,"+
"number TEXT NOT NULL);";
</... | 24,605,762 | 5 | 5 | null | 2014-07-07 07:09:13.733 UTC | 7 | 2018-01-17 16:07:27.213 UTC | null | null | null | null | 3,418,888 | null | 1 | 37 | android|sqlite|android-sqlite | 70,834 | <p>You could use something like this:</p>
<p>Create your table:</p>
<pre><code>static final String CREATE_DB_TABLE =
"CREATE TABLE " + CONTACTS_TABLE_NAME " +
" (_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"..." + " flag INTEGER DEFAULT 0)";
</code></pre>
<p>retrieve your value as:</p>
<pre><code>Boole... |
22,063,748 | django - get() returned more than one topic | <p>When I tried to relate an attribute with another one which has an <strong>M to M</strong> relation I received this error:</p>
<blockquote>
<p>get() returned more than one topic -- it returned 2!</p>
</blockquote>
<p>Can you guys tell me what that means and maybe tell me in advance how to avoid this error ?</p>
... | 22,064,255 | 8 | 2 | null | 2014-02-27 09:06:54.687 UTC | 20 | 2021-10-22 17:02:01.737 UTC | 2015-10-19 06:14:35.11 UTC | null | 2,968,265 | null | 2,968,265 | null | 1 | 91 | django|django-models|django-views | 154,355 | <blockquote>
<p><code>get()</code> returned more than one topic -- it returned 2!</p>
</blockquote>
<p>The above error indicatess that you have more than one record in the DB related to the specific parameter you passed while querying using <a href="https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.