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,789,627
How to change the timeout on a .NET WebClient object
<p>I am trying to download a client's data to my local machine (programatically) and their webserver is very, very slow which is causing a timeout in my <code>WebClient</code> object.</p> <p>Here is my code:</p> <pre><code>WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; webClient.DownloadF...
6,994,391
12
1
null
2009-11-24 11:59:58.95 UTC
34
2021-12-13 12:40:00.7 UTC
null
null
null
null
147,731
null
1
252
c#|.net|file|download|webclient
214,548
<p>You can extend the timeout: inherit the original WebClient class and override the webrequest getter to set your own timeout, like in the following example.</p> <p>MyWebClient was a private class in my case:</p> <pre><code>private class MyWebClient : WebClient { protected override WebRequest GetWebRequest(Uri u...
2,214,575
Passing arguments to "make run"
<p>I use Makefiles.</p> <p>I have a target called <code>run</code> which runs the build target. Simplified, it looks like the following:</p> <pre><code>prog: .... ... run: prog ./prog </code></pre> <p>Is there any way to pass arguments? So that</p> <pre><code>make run asdf --&gt; ./prog asdf make run the dog kicke...
2,214,593
14
1
null
2010-02-06 20:16:13.343 UTC
106
2022-09-01 16:55:07.407 UTC
2021-11-18 20:24:15.303 UTC
null
832,230
null
247,265
null
1
469
makefile
344,658
<p>I don't know a way to do what you want exactly, but a workaround might be:</p> <pre><code>run: ./prog ./prog $(ARGS) </code></pre> <p>Then:</p> <pre><code>make ARGS="asdf" run # or make run ARGS="asdf" </code></pre>
1,408,417
Can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?
<p>I know that PHP is compiled to byte code before it is run on the server, and then that byte code can be cached so that the whole script doesn't have to be re-interpreted with every web access.</p> <p>But can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?</p...
1,408,499
14
5
null
2009-09-11 00:23:28.577 UTC
99
2021-06-03 14:51:36.03 UTC
2019-07-15 03:02:58.94 UTC
null
63,550
null
84,478
null
1
239
php|bytecode
257,145
<p>After this question was asked, Facebook launched <strong>HipHop for PHP</strong> which is probably the best-tested PHP compiler to date (seeing as it ran one of the world’s 10 biggest websites). However, Facebook discontinued it in favour of HHVM, which is a virtual machine, not a compiler.</p> <p>Beyond that, goog...
8,517,304
What is the difference for sample/resample/scale/resize/adaptive-resize/thumbnail operators in ImageMagick convert?
<p>I found multiple ways to change the resolution of an image using <code>convert</code>:</p> <pre><code>-sample -resample -scale -resize -adaptive-resize -thumbnail </code></pre> <p>What's the difference of those?</p> <p>If I need to make various size large picture thumbnail with fixed aspect ratio (cropping needed...
13,078,621
1
2
null
2011-12-15 08:43:57.393 UTC
44
2021-08-23 03:10:58.08 UTC
2015-07-15 20:20:59.15 UTC
null
359,307
null
41,948
null
1
94
imagemagick|thumbnails
34,619
<p><strong>resize</strong></p> <blockquote> <p><strong><code>-resize 400x300+20+30</code></strong> (like the <code>-scale</code> and <code>-sample</code> examples below) converts an input to an output image which has the pixel dimensions of <code>400x300</code>. It also shifts the output by 20 pixels to the right and b...
6,478,364
How do you set percentage in Google Visualization Chart API?
<p>How do you set the vertical axis to display percent such as 25%, 50%, 75%, 100%?</p>
6,486,856
3
0
null
2011-06-25 14:27:27.85 UTC
2
2021-05-31 16:50:07.91 UTC
2019-02-27 15:39:30.313 UTC
null
759,866
null
336,920
null
1
23
api|charts|google-visualization|number-formatting
43,926
<p><pre><code>chart.draw(data, {vAxis: {format:'#%'} } ); </pre></code></p> <p>To get comma for thousands, use <code>{format:'#,###%'}</code>.</p> <p>See <a href="http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html" rel="noreferrer">http://code.google.com/apis/chart/interactive/docs/gallery/line...
6,476,763
Rails 3 route appends _index to route name
<p>I am migrating a Rails 2.3.8 version to Rails 3.0 and so ive rewritten my routes file. When i list the routes using <code>rake routes</code>, i see some route names have <code>_index</code> appended to them. I cant figure out why this is.</p> <p>Relevant routes:</p> <p>Rails 2.3.8:</p> <pre><code>map.namespace "t...
6,477,540
3
0
null
2011-06-25 08:38:36.053 UTC
4
2015-11-13 00:58:06.573 UTC
2011-06-25 09:06:32.967 UTC
null
285,614
null
285,614
null
1
34
ruby-on-rails|ruby-on-rails-3|routes
6,832
<p>It is because your resource is named <code>:planner</code> instead of <code>:planners</code> that Rails decided to add the _index to any collection nested underneath. My guess it is there for readability.</p> <p>The action named in the collection normally translates to a verb, so I can see why this makes sense. Tak...
15,596,020
Permission denied when opening localhost
<p>I had recently installed Apache, PHP and MySQL in Ubuntu. And copied the files I created to the <code>var/www</code> directory. But when I open <code>http://localhost</code> it is showing</p> <blockquote> <p>Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0</p> <p>Fatal error: U...
15,596,084
2
5
null
2013-03-24 07:04:35.987 UTC
1
2013-03-30 04:15:58.303 UTC
2013-03-30 04:15:58.303 UTC
null
13,295
null
2,140,143
null
1
9
php|ubuntu|permissions|localhost
41,439
<p>According to this article, you need to give read/execute permissions to Owner, Group, and Everyone.</p> <p>Set permissions on the problem file to 777. Note, you should avoid doing this on a server that's accessible from the internet. </p> <p><a href="http://webomania.wordpress.com/2007/03/12/permission-denied-in-u...
18,803,354
ending "+" prompt in R
<p>I'm fairly new to R and I made a type-o while entering some code and now instead of getting the ">" prompt I get a "+" prompt. I appear to be stuck in some kind of function that is looking for input, but I can't seem to get out of it. I figure that there must be a better way to fix this problem then closing R and re...
18,803,911
5
2
null
2013-09-14 15:31:20.197 UTC
9
2022-09-17 09:49:18.437 UTC
2013-10-02 01:36:21.12 UTC
null
636,656
null
2,779,461
null
1
74
r|r-faq
106,627
<p>It depends on how you’re running R.</p> <p>In the terminal, the “normal” way is <kbd>Control</kbd>+<kbd>C</kbd> – the “cancel” key combination.</p> <p>In the graphical R application and in RStudio, it’s <kbd>Escape</kbd>.</p>
19,042,894
Periodic iOS background location updates
<p>I'm writing an application that requires background location updates with <strong>high accuracy and low frequency</strong>. The solution seems to be a background NSTimer task that starts the location manager's updates, which then immediately shuts down. This question has been asked before:</p> <p><a href="https:/...
19,085,518
9
3
null
2013-09-27 04:44:30.337 UTC
91
2019-08-24 22:23:37.353 UTC
2018-09-10 21:38:07.02 UTC
null
5,175,709
null
1,601,957
null
1
93
ios|objective-c|core-location|background-task|ios-background-mode
97,398
<p>It seems that <code>stopUpdatingLocation</code> is what triggers the background watchdog timer, so I replaced it in <code>didUpdateLocation</code> with:</p> <pre><code>[self.locationManager setDesiredAccuracy:kCLLocationAccuracyThreeKilometers]; [self.locationManager setDistanceFilter:99999]; </code></pre> <p>whic...
40,050,397
Deep-Learning Nan loss reasons
<p>Perhaps too general a question, but can anyone explain what would cause a Convolutional Neural Network to diverge?</p> <p>Specifics:</p> <p>I am using Tensorflow's iris_training model with some of my own data and keep getting</p> <blockquote> <p>ERROR:tensorflow:Model diverged with loss = NaN.</p> <p>Traceback...</p...
40,434,284
13
4
null
2016-10-14 19:07:18.273 UTC
57
2022-06-12 13:08:30.77 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
5,031,496
null
1
134
python|tensorflow|machine-learning|keras|theano
188,819
<p>There are lots of things I have seen make a model diverge.</p> <ol> <li><p>Too high of a learning rate. You can often tell if this is the case if the loss begins to increase and then diverges to infinity. </p></li> <li><p>I am not to familiar with the DNNClassifier but I am guessing it uses the categorical cross ...
5,283,090
Clean solution (project) structure with EF, Repositories, Entities
<p>I like to keep the structure of the project as clean as possible. Sample:</p> <pre><code>--BlogApp.sln --BlogApp.Data BlogModel.edmx (the EF mappings) Post.cs (I end up having partial classes in here with attributes) --BlogApp.Domain --Entities Post.cs (I would like to have my POCOs her...
5,283,973
2
4
null
2011-03-12 14:29:26.347 UTC
9
2011-03-12 16:59:55.19 UTC
2011-03-12 15:44:31.367 UTC
null
67,392
null
420,555
null
1
10
asp.net-mvc|entity-framework|projects-and-solutions|project-structure
10,426
<p>My preferred structure is:</p> <blockquote> <pre><code>Solution -- Common - Shared features used accross all layers - You can also place interfaces for repositories and uow here -- Entities - shared among DataAccess, Business (and UI in small projects) - T4 template + partial classes + cust...
5,223,763
How to FTP in Ruby without first saving the text file
<p>Since Heroku does not allow saving dynamic files to disk, I've run into a dilemma that I am hoping you can help me overcome. I have a text file that I can create in RAM. The problem is that I cannot find a gem or function that would allow me to stream the file to another FTP server. The Net/FTP gem I am using requir...
7,589,083
2
0
null
2011-03-07 18:47:42.85 UTC
9
2015-03-29 00:09:23.143 UTC
2011-03-07 20:23:16.153 UTC
null
405,017
null
307,308
null
1
12
ruby|ftp|heroku
7,661
<p><a href="http://ruby-doc.org/stdlib/libdoc/stringio/rdoc/classes/StringIO.html#M003790" rel="noreferrer">StringIO.new</a> provides an object that acts like an opened file. It's easy to create a method like <a href="http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/classes/Net/FTP.html#M001277" rel="noreferrer">puttextf...
5,237,611
itertools.cycle().next()?
<p>Well, I was using <code>itertools.cycle().next()</code> method with Python 2.6.6, but now that I updated to 3.2 I noticed that <code>itertools.cycle()</code> object has no method <code>next()</code>.</p> <p>I used it to cycle a string in the <code>spin()</code>method of a <code>Spinner</code> class. So if we cycle ...
5,237,664
2
1
null
2011-03-08 20:00:50.64 UTC
6
2014-05-19 07:26:54.247 UTC
null
null
null
null
222,758
null
1
48
python-3.x|cycle|next|itertools
31,708
<p><code>iter.next()</code> was removed in python 3. Use <code>next(iter)</code> instead. So in your example change <code>itertools.cycle().next()</code> to <code>next(itertools.cycle())</code></p> <p>There is a <a href="http://www.diveintopython3.net/porting-code-to-python-3-with-2to3.html#next" rel="noreferrer">good...
369,438
Smooth spectrum for Mandelbrot Set rendering
<p>I'm currently writing a program to generate really enormous (65536x65536 pixels and above) Mandelbrot images, and I'd like to devise a spectrum and coloring scheme that does them justice. The <a href="http://en.wikipedia.org/wiki/File:Mandel_zoom_00_mandelbrot_set.jpg" rel="noreferrer">wikipedia featured mandelbrot ...
374,216
7
0
null
2008-12-15 19:26:33.75 UTC
24
2019-04-04 17:42:56.41 UTC
null
null
null
Arachnid
12,030
null
1
37
algorithm|colors|fractals|mandelbrot
35,887
<p>My eventual solution was to create a nice looking (and fairly large) palette and store it as a constant array in the source, then interpolate between indexes in it using the smooth coloring algorithm. The palette wraps (and is designed to be continuous), but this doesn't appear to matter much.</p>
870,173
Is there a limit on number of open files in Windows
<p>I'm opening lots of files with fopen() in VC++ but after a while it fails.</p> <p>Is there a limit to the number of files you can open simultaneously?</p>
870,224
7
3
null
2009-05-15 18:31:08.3 UTC
9
2017-10-25 09:14:32.393 UTC
null
null
null
null
73,869
null
1
44
c++|windows
76,882
<p>The C run-time libraries have a 512 limit for the number of files that can be open at any one time. Attempting to open more than the maximum number of file descriptors or file streams causes program failure. Use <code>_setmaxstdio</code> to change this number. More information about this can be read <a href="http://...
1,218,034
HTML anchor link with no scroll or jump
<p>I have various links which all have unique id's that are "pseudo-anchors." I want them to affect the url hash value and the click magic is all handled by some mootools code. However, when I click on the links they scroll to themselves (or to the top in one case). I don't want to scroll anywhere, but also need my jav...
1,218,038
8
4
null
2009-08-02 02:40:28.457 UTC
9
2021-04-13 20:54:13.023 UTC
null
null
null
null
49,411
null
1
29
javascript|html|xhtml|scroll|anchor
52,544
<p>I'm probably missing something, but why not just give them different IDs?</p> <pre><code>&lt;a href="#button1" id="button-1"&gt;button 1&lt;/a&gt; &lt;a href="#button2" id="button-2"&gt;button 2&lt;/a&gt; &lt;a href="#" id="reset"&gt;Home&lt;/a&gt; </code></pre> <p>Or whatever convention you'd prefer.</p>
226,693
Python Disk-Based Dictionary
<p>I was running some dynamic programming code (trying to brute-force disprove the Collatz conjecture =P) and I was using a dict to store the lengths of the chains I had already computed. Obviously, it ran out of memory at some point. Is there any easy way to use some variant of a <code>dict</code> which will page part...
226,796
8
0
null
2008-10-22 17:00:11.053 UTC
18
2022-01-01 08:43:05.11 UTC
null
null
null
Claudiu
15,055
null
1
44
python|database|dictionary|disk-based
18,085
<p>Hash-on-disk is generally addressed with Berkeley DB or something similar - several options are listed in the <a href="http://docs.python.org/library/persistence.html" rel="noreferrer">Python Data Persistence documentation</a>. You can front it with an in-memory cache, but I'd test against native performance first; ...
510,216
Can you make the settings in Settings.bundle default even if you don't open the Settings App
<p>I have an iPhone application with a settings.bundle that handles various settings for my application. I can set default values in my root.plist file (using the DefaultValue property), but these only get used the first time the user opens the settings app. Is there any way to get these values written out when your ap...
510,329
8
0
null
2009-02-04 05:51:15.597 UTC
48
2016-11-21 09:36:05.64 UTC
null
null
null
rustyshelf
6,044
null
1
58
iphone|cocoa-touch
30,148
<p>If I understood you correctly, you want to avoid having default values specified twice (once as "DefaultValue" keys in your Settings.bundle/Root.plist file, and once in your app initialization code) so you do not have to keep them in sync.</p> <p>Since Settings.bundle is stored within the app bundle itself, you can...
1,026,220
How to find out next character alphabetically?
<p>How we can find out the next character of the entered one. For example, if I entered the character "b" then how do I get the answer "c"?</p>
1,026,271
9
2
null
2009-06-22 09:15:20.85 UTC
3
2019-12-11 15:47:07.11 UTC
2009-09-04 09:23:54.81 UTC
null
124,875
null
124,875
null
1
39
c#|char
56,798
<p>Try this:</p> <pre><code>char letter = 'c'; if (letter == 'z') nextChar = 'a'; else if (letter == 'Z') nextChar = 'A'; else nextChar = (char)(((int)letter) + 1); </code></pre> <p>This way you have no trouble when the char is the last of the alphabet.</p>
1,237,778
How do I break down an NSTimeInterval into year, months, days, hours, minutes and seconds on iPhone?
<p>I have a time interval that spans years and I want all the time components from year down to seconds.</p> <p>My first thought is to integer divide the time interval by seconds in a year, subtract that from a running total of seconds, divide that by seconds in a month, subtract that from the running total and so on....
1,386,746
9
3
null
2009-08-06 09:08:48.853 UTC
29
2016-10-19 12:52:37.213 UTC
2010-02-02 03:13:17.363 UTC
null
30,461
null
23,973
null
1
55
iphone|cocoa|time|nstimeinterval
48,645
<p><strong>Brief Description</strong></p> <ol> <li><p>Just another approach to complete the answer of JBRWilkinson but adding some code. It can also offers a solution to Alex Reynolds's comment. </p></li> <li><p>Use NSCalendar method:</p> <ul> <li><p><code>(NSDateComponents *)components:(NSUInteger)unitFlags fromDate...
485,175
Is it safe to check floating point values for equality to 0?
<p>I know you can't rely on equality between double or decimal type values normally, but I'm wondering if 0 is a special case.</p> <p>While I can understand imprecisions between 0.00000000000001 and 0.00000000000002, 0 itself seems pretty hard to mess up since it's just nothing. If you're imprecise on nothing, it's n...
485,741
9
3
null
2009-01-27 20:50:14.62 UTC
26
2021-02-26 14:36:38.7 UTC
2016-02-21 12:38:22.657 UTC
null
96,780
PhoenixRedeemer
47,544
null
1
108
c#|.net|floating-point|precision|zero
81,652
<p>It is <strong>safe</strong> to expect that the comparison will return <code>true</code> if and only if the double variable has a value of exactly <code>0.0</code> (which in your original code snippet is, of course, the case). This is consistent with the semantics of the <code>==</code> operator. <code>a == b</code> ...
427,151
Algorithms for Simulating Fluid Flow
<p>I've got a game idea that requires some semi-realistic simulation of a fluid flowing around various objects. Think of a pool of mercury on an irregular surface that is being tilted in various directions.</p> <p>This is for a game, so 100% physical realism is not necessary. What is most important is that the calcu...
427,157
10
0
2009-01-09 15:43:30.027 UTC
2009-01-09 05:20:11.853 UTC
11
2021-06-04 09:13:35.37 UTC
2009-01-09 15:46:40.723 UTC
nemo
20,774
Kristopher Johnson
1,175
null
1
15
algorithm|simulation|cellular-automata
12,900
<p>This is not my area of research but I believe this is considered the canonical work:</p> <p>Fluid Simulation for Computer Graphics</p> <p><a href="https://www.routledge.com/Fluid-Simulation-for-Computer-Graphics/Bridson/p/book/9781482232837" rel="nofollow noreferrer">https://www.routledge.com/Fluid-Simulation-for-Co...
210,635
Teacher time schedule algorithm
<p>This is a problem I've had on my mind for a long time. Being the son of a teacher and a programmer, it occurred to me early on... but I still haven't found a solution for it.</p> <p>So this is the problem. One needs to create a time schedule for a school, using some constraints. These are generally divided in two c...
210,700
10
1
null
2008-10-16 23:27:33.18 UTC
26
2016-05-30 15:47:28.423 UTC
2017-05-23 11:53:38.5 UTC
Sklivvz
-1
Sklivvz
7,028
null
1
30
algorithm|scheduling|np-hard
20,747
<p>I am one of the developer that works on the scheduler part of a student information system. During our original approach of the scheduling problem, we researched genetic algorithms to solve constraint satisfaction problems, and even though we were successful initially, we realized that there was a less complicated s...
132,867
I have a gem installed but require 'gemname' does not work. Why?
<p>The question I'm really asking is why require does not take the name of the gem. Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!?</p> <p>As an example if I have <code>memcache-client</code> installed then I have to require it using</p> <pre><code>...
132,970
11
0
null
2008-09-25 12:01:13.993 UTC
9
2020-06-10 01:05:54.393 UTC
null
null
null
mloughran
18,751
null
1
63
ruby|rubygems
71,410
<p>There is no standard for what the file you need to include is. However there are some commonly followed conventions that you can can follow try and make use of:</p> <ul> <li>Often the file is called the same name as the gem. So <code>require mygem</code> will work. </li> <li>Often the file is the only .rb file in t...
526,255
Probability distribution in Python
<p>I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less unlikely (a more likely) object. I am wondering if you would have any suggestions, preferably an existing python module th...
526,300
12
12
2009-02-09 01:00:32.423 UTC
2009-02-08 19:52:22.713 UTC
23
2014-01-19 00:25:27.99 UTC
2009-02-10 15:56:55.267 UTC
Nicholas Leonard
49,985
Nicholas Leonard
49,985
null
1
21
python|algorithm|random|distribution|probability
20,787
<p><a href="http://code.activestate.com/recipes/117241/" rel="noreferrer">This activestate recipe</a> gives an easy-to-follow approach, specifically the version in the comments that doesn't require you to pre-normalize your weights:</p> <pre><code>import random def weighted_choice(items): """items is a list of tu...
576,775
As a programmer how would you explain imaginary numbers?
<p>As a programmer I think it is my job to be good at math but I am having trouble getting my head round imaginary numbers. I have tried google and <a href="http://en.wikipedia.org/wiki/Imaginary_number" rel="noreferrer">wikipedia</a> with no luck so I am hoping a programmer can explain in to me, give me an example of ...
576,800
13
0
null
2009-02-23 07:16:18.627 UTC
9
2015-03-11 21:47:14.183 UTC
2013-01-17 07:07:41.373 UTC
David Segonds
225,647
Ctrl Alt D-1337
36,157
null
1
18
math|complex-numbers
5,310
<p>I guess this <a href="http://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/" rel="nofollow noreferrer">blog entry</a> is one good explanation:</p> <p>The key word is <strong>rotation</strong> (as opposed to <strong><em>direction</em></strong> for negative numbers, which are as stranger ...
180,947
Base64 decode snippet in C++
<p>Is there a freely available Base64 decoding code snippet in C++?</p>
180,949
13
3
null
2008-10-08 00:25:26.463 UTC
43
2022-01-19 05:00:53.637 UTC
2021-01-09 16:46:23.643 UTC
null
63,550
null
19,104
null
1
94
c++|base64
199,010
<p>See <em><a href="http://www.adp-gmbh.ch/cpp/common/base64.html" rel="noreferrer">Encoding and decoding base 64 with C++</a></em>.</p> <p>Here is the implementation from that page:</p> <pre><code>/* base64.cpp and base64.h Copyright (C) 2004-2008 René Nyffenegger This source code is provided 'as-is', witho...
652,770
Delete with Join in MySQL
<p>Here is the script to create my tables: </p> <pre><code>CREATE TABLE clients ( client_i INT(11), PRIMARY KEY (client_id) ); CREATE TABLE projects ( project_id INT(11) UNSIGNED, client_id INT(11) UNSIGNED, PRIMARY KEY (project_id) ); CREATE TABLE posts ( post_id INT(11) UNSIGNED, project_id INT(...
4,192,849
14
5
null
2009-03-17 01:44:05.523 UTC
115
2020-10-27 10:14:23.037 UTC
2018-10-26 14:07:35.047 UTC
null
8,810,495
brioblue
74,980
null
1
564
mysql
372,098
<p>You just need to specify that you want to delete the entries from the <code>posts</code> table:</p> <pre><code>DELETE posts FROM posts INNER JOIN projects ON projects.project_id = posts.project_id WHERE projects.client_id = :client_id </code></pre> <p>EDIT: For more information you can see <a href="https://stacko...
249,357
Are there any CSS standards that I should follow while writing my first stylesheet?
<p>I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following.</p> <p>I would appreciate any links or first-hand advise.</p>
249,387
17
0
null
2008-10-30 05:34:42.283 UTC
14
2014-09-18 09:44:45.667 UTC
null
null
null
jjnguy
2,598
null
1
15
css
2,708
<p>An error that beginners make quite often:</p> <p>CSS is semantic as well. Try to express concepts, not formats. Contrived example:</p> <h3>Wrong:</h3> <pre><code>div.red { color: red; } </code></pre> <p>as opposed to:</p> <h3>Good:</h3> <pre><code>div.error { color: red; } </code></pre> <p>CSS should be the ...
126,445
Any way to remove IEs black border around submit button in active forms?
<p>I am implementing a design that uses custom styled submit-buttons. They are quite simply light grey buttons with a slightly darker outer border:</p> <pre><code>input.button { background: #eee; border: 1px solid #ccc; } </code></pre> <p>This looks just right in Firefox, Safari and Opera. The problem is with...
126,517
18
0
null
2008-09-24 10:46:10.39 UTC
22
2014-12-23 10:58:41.243 UTC
null
null
null
Magnar
1,123
null
1
40
css|internet-explorer
65,424
<p>Well this works here:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; span.button { background: #eee; border: 1px solid #ccc; } span.button input { background:none; border:0; ...
1,073,384
What strategies have you used to improve build times on large projects?
<p>I once worked on a C++ project that took about an hour and a half for a full rebuild. Small edit, build, test cycles took about 5 to 10 minutes. It was an unproductive nightmare.</p> <p>What is the worst build times you ever had to handle? </p> <p>What strategies have you used to improve build times on large proje...
1,073,434
20
2
null
2009-07-02 09:26:09.29 UTC
11
2014-05-26 07:02:50.773 UTC
2011-12-19 18:43:16.317 UTC
null
105,971
null
4,012
null
1
24
c++|compiler-construction|build-process|build-automation
5,403
<ol> <li>Forward declaration</li> <li>pimpl idiom</li> <li>Precompiled headers</li> <li>Parallel compilation (e.g. MPCL add-in for Visual Studio).</li> <li>Distributed compilation (e.g. Incredibuild for Visual Studio).</li> <li>Incremental build</li> <li>Split build in several "projects" so not compile all the code if ...
196,017
Unique (non-repeating) random numbers in O(1)?
<p>I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?</p>
196,065
22
7
null
2008-10-12 20:34:22.297 UTC
117
2019-11-02 09:44:16.297 UTC
2015-07-16 18:08:47.61 UTC
Pete Kirkham
1,711,796
dicroce
3,886
null
1
188
algorithm|math|random|language-agnostic
109,105
<p>Initialize an array of 1001 integers with the values 0-1000 and set a variable, max, to the current max index of the array (starting with 1000). Pick a random number, r, between 0 and max, swap the number at the position r with the number at position max and return the number now at position max. Decrement max by...
895,371
Why is Bubble Sort implementation looping forever?
<p>In class we are doing sorting algorithms and, although I understand them fine when talking about them and writing pseudocode, I am having problems writing actual code for them.</p> <p>This is my attempt in Python:</p> <pre><code>mylist = [12, 5, 13, 8, 9, 65] def bubble(badList): length = len(badList) - 1 ...
902,736
28
16
null
2009-05-21 21:47:24.853 UTC
26
2022-04-06 15:24:11.58 UTC
2022-04-06 15:24:11.58 UTC
null
8,372,853
null
2,592
null
1
131
python|algorithm|sorting|bubble-sort
112,947
<p>To explain why your script isn't working right now, I'll rename the variable <code>unsorted</code> to <code>sorted</code>.</p> <p>At first, your list isn't yet sorted. Of course, we set <code>sorted</code> to <code>False</code>.</p> <p>As soon as we start the <code>while</code> loop, we assume that the list is alr...
34,722,862
How to remove time part from Date?
<p>I have a date <code>'12/12/1955 12:00:00 AM'</code> stored in a hidden column. I want to display the date without the time.</p> <p>How do I do this?</p>
34,722,927
8
8
null
2016-01-11 13:34:05.62 UTC
6
2022-09-16 11:49:43.42 UTC
2022-03-14 18:41:38.82 UTC
null
3,345,644
null
3,913,690
null
1
103
javascript
211,191
<p>Split it by <code>space</code> and take first part like below. Hope this will help you.</p> <pre><code>var d = '12/12/1955 12:00:00 AM'; d = d.split(' ')[0]; console.log(d); </code></pre>
7,002,477
SQL Server default date time stamp?
<p>I have a field that when something is inserted I want it to get the current Date &amp; Time and insert this into the database. Is there a way to get the date &amp; time, and set it as the default value? </p> <p>Currently the default value is: (getdate()) Which sets only the date. How do I also set the time? </p>
7,002,513
5
5
null
2011-08-09 20:25:27.353 UTC
1
2014-03-24 08:36:02.197 UTC
2011-08-09 20:28:25.897 UTC
null
280,598
null
494,901
null
1
16
sql|sql-server
66,730
<p><code>GETDATE()</code> is a date and time in SQL Server.</p> <p>Run <code>SELECT GETDATE()</code> to verify this.</p> <p>What is the datatype of your field? If it's <code>DATE</code> then it will not hold time values as well.</p>
6,736,023
Which browsers (and versions) support the Canvas.toBlob method?
<p>I'm working on a minimalist image creation project and I need to have the ability to create images within the browser that are in-turn used on a server. So far, the <code>Canvas.toDataUrl()</code> method has met our needs, but I just learned of the <code>Canvas.toBlob()</code> method which would be much more conven...
56,499,809
5
3
null
2011-07-18 16:22:02.31 UTC
2
2019-09-16 19:03:02.493 UTC
2019-06-12 15:29:06.15 UTC
null
469,319
null
469,319
null
1
38
html|html5-canvas
19,358
<p>It's been nearly 8 years since I first asked this question. Considering that I still get a trickle-in of upvotes and this question is often at the top of Google Searches, I figured I'd give an update to the state of <code>Canvas.toBlob(...)</code> and it's implementation.</p> <p>The following table:</p> <pre><cod...
6,449,345
How to show a Horizontal Android Indeterminate Progress Bar
<p>How to show an indeterminate horizontal progress bar in android? The animation of the progress bar should start from 0 to 100 and then go back from 100 to 0 continuously. I am not looking for the wheel progress bar.</p>
6,450,417
5
2
null
2011-06-23 04:29:47.933 UTC
9
2018-10-03 13:09:46.04 UTC
2018-01-25 09:38:31.907 UTC
null
2,598,247
null
608,209
null
1
50
android|android-progressbar
90,030
<p>I already knew that <code>setIndeterminate</code> will give an infinite horizontal progress bar. But it will be similar to the loading wheel, except that it will be horizontal. If you see my question I was looking for horizontal bar which starts from 0 and goes all the way to 100 (a gradual increase). If you want to...
6,583,746
Matching Kinect Audio with Video
<p>I have a project dealing with video conferencing using the Kinect (or, more likely, four of them). Right now, my company uses these stupidly expensive cameras for our VTC rooms. The hope is, using a couple Kinects linked together, we can reduce the costs. The plan is to have four/five of them covering a 180 degree a...
6,674,061
6
4
null
2011-07-05 13:52:14.67 UTC
8
2011-07-15 13:10:50.177 UTC
2011-07-15 13:10:50.177 UTC
null
610,634
null
610,634
null
1
28
c#|kinect
2,496
<p>The API provided by Microsoft Research doesn't actually provide this capability. Kinect is essentially multiple cameras, and a microphone array with each sensor having a unique driver stack so there is no linkage to the physical hardware device. The best way to achieve this would be to use the Windows API instead, b...
6,928,374
Example of the Scala aggregate function
<p>I have been looking and I cannot find an example or discussion of the <code>aggregate</code> function in Scala that I can understand. It seems pretty powerful.</p> <p>Can this function be used to reduce the values of tuples to make a multimap-type collection? For example:</p> <pre><code>val list = Seq(("one", "i")...
6,932,050
7
0
null
2011-08-03 14:47:30.347 UTC
28
2019-04-21 17:35:42.807 UTC
2016-08-12 21:43:27.533 UTC
null
442,945
null
235,820
null
1
36
scala|aggregate-functions
40,583
<p>The aggregate function does not do that (except that it is a very general function, and it could be used to do that). You want <code>groupBy</code>. Close to at least. As you start with a <code>Seq[(String, String)]</code>, and you group by taking the first item in the tuple (which is <code>(String, String) =&gt; St...
6,929,662
How do I abort image <img> load requests without using window.stop()
<p>I have a very long page that dynamically loads images as users scroll through.</p> <p>However, if a user quickly scrolls away from a certain part of the page, I don't want the images to continue loading in that now out-of-view part of the page.</p> <p>There are lots of other requests happening on the page simultan...
6,974,878
7
3
null
2011-08-03 16:13:06.697 UTC
16
2017-06-01 23:10:36.557 UTC
2017-05-23 12:00:24.427 UTC
null
-1
null
793,472
null
1
48
javascript|jquery|html|ajax|image
27,229
<p>What you are trying to do is the wrong approach, as mentioned by <a href="https://stackoverflow.com/users/380487/nrabinowitz">nrabinowitz</a>. You can't just "cancel" the loading process of an image (setting the <code>src</code> attribute to an empty string is <a href="http://www.nczonline.net/blog/2009/11/30/empty-...
38,442,901
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<p>I am getting this kind of error, how to fix it.</p> <pre><code>Error:Unable to load class 'org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection'. Possible causes for this unexpected error Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-dow...
42,622,353
40
2
null
2016-07-18 17:41:54.393 UTC
31
2021-05-06 13:42:26.277 UTC
2016-07-22 13:31:45.3 UTC
null
2,741,598
null
4,693,397
null
1
111
android|gradle|gradle-plugin
204,057
<p>I updated my Android Studio to 2.3 and it asked me to update my gradle plugin to 3.3 that created issues with my running projects. I've gone through all the Stack solutions and nothing worked for me except this workaround: <strong>I changed my distribution url in gradle-wrapper.properties with this one.</strong></p...
15,675,689
How to upload a file to Google Drive
<p>So im trying to upload a text file to my google drive from an android app I am creating. I learned how to upload a picture from the Google tutorial. Also, I will be using the strings from my app in the text file. Potentially, I want to make it a spreadsheet. Any help?</p>
15,676,970
2
0
null
2013-03-28 06:38:44.96 UTC
10
2021-06-25 21:26:28.917 UTC
2013-03-28 08:00:41.587 UTC
null
2,178,759
null
2,178,759
null
1
14
android|google-drive-api
46,316
<p>Read <a href="https://developers.google.com/drive/quickstart-android" rel="noreferrer">Quick Start</a> on Google Android site. </p> <p>When you are done with all the authentication process, go for <a href="https://developers.google.com/drive/manage-uploads" rel="noreferrer">How to upload file to Google Drive</a>.<...
15,962,745
Draw a semicircle in the background of a View
<p>I am trying to create a TextView whose background is a half circle. I create a oval using a ShapeDrawable. I tried to create a semicircle by using ScaleDrawable to double the size vertical size of the oval and clip it. However, the ScaleDrawable has no effect. Why not? What is the best way to draw a semicircle in th...
15,963,620
5
1
null
2013-04-12 03:51:32.773 UTC
14
2021-05-25 15:47:39.6 UTC
2013-04-12 03:59:40.193 UTC
null
766,900
null
766,900
null
1
19
android
38,741
<p>You can implement you own Drawable. But that cannot be inflated from XML. You need to set the drawable from code using View.setBackgroundDrawable();</p> <p>See my sample implementation to draw a semi circle using drawable.</p> <pre><code>public class SemiCircleDrawable extends Drawable { private Paint paint; ...
15,952,812
Multiple command parameters wpf button object
<p>How can I send multiple parameters from <code>Button</code> in <code>WPF</code>? I am able to send single parameter which is value of <code>TextBox</code> properly. Here is the code.</p> <p><code>XAML</code></p> <pre><code>&lt;TextBox Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="133,22,0,0" Name...
15,952,864
2
4
null
2013-04-11 15:27:37.463 UTC
6
2017-11-13 07:45:51.503 UTC
2013-07-06 16:30:28.023 UTC
null
2,176,945
null
945,175
null
1
20
c#|wpf|button|mvvm|icommand
42,270
<blockquote> <p>How can i send multiple parameters from button in wpf. </p> </blockquote> <p>You can only send one parameter as the <code>CommandParameter</code>.</p> <p>A better solution is typically to just bind the <code>TextBox</code> and other controls to multiple properties in your ViewModel. The command wou...
15,907,079
CSS3 Transition - Fade out effect
<p>I am trying to implement the "fade out" effect in pure CSS. Here is the <a href="http://jsfiddle.net/dYBD2/" rel="noreferrer">fiddle</a>. I did look into a couple of solutions online, however, after reading the <a href="http://www.w3schools.com/css3/css3_animations.asp" rel="noreferrer">documentation online</a>, I a...
16,611,735
8
0
null
2013-04-09 16:10:52.48 UTC
36
2022-02-02 07:58:49.637 UTC
2020-05-20 06:24:54.577 UTC
null
6,904,888
user2246087
null
null
1
126
css|css-transitions
472,975
<p>You can use transitions instead:</p> <pre><code>.successfully-saved.hide-opacity{ opacity: 0; } .successfully-saved { color: #FFFFFF; text-align: center; -webkit-transition: opacity 3s ease-in-out; -moz-transition: opacity 3s ease-in-out; -ms-transition: opacity 3s ease-in-out; -o-tran...
36,233,477
Implementing an interface with two abstract methods by a lambda expression
<p>In Java 8 the <strong><em>lambda expression</em></strong> is introduced to help with the reduction of boilerplate code. If the interface has only one method it works fine. If it consists of multiple methods, then none of the methods work. How can I handle multiple methods? </p> <p>We may go for the following exampl...
36,233,545
4
6
null
2016-03-26 09:03:47.573 UTC
8
2018-12-06 14:10:54.013 UTC
2017-03-01 03:33:27.063 UTC
null
4,539,511
null
4,999,323
null
1
32
java|lambda|java-8|functional-interface
13,650
<p>Lambda expressions are only usable with functional interface as said by Eran but if you really need multiple methods within the interfaces, you may change the modifiers to <code>default</code> or <code>static</code> and override them within the classes that implement them if necessary.</p> <pre><code>public class T...
50,298,114
Django 2 - How to register a user using email confirmation and CBVs?
<p>This question specifically aims for a Django 2.0 answer as the <code>registration</code> module isn't available (yet) for it.</p> <p><em>More, this might seem to broad, but I often found myself in situations where I can't use any 3rd party module because ... oh well..policies. I'm sure many did. And I know that look...
50,330,016
3
4
null
2018-05-11 18:20:28.563 UTC
16
2020-08-20 23:18:41.133 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
3,316,077
null
1
21
python|django|authentication
14,286
<h2>The User Model</h2> <p>First, you will need to create a custom <code>User</code> model and a custom <code>UserManager</code> to remove the <code>username</code> field and use <code>email</code> instead.</p> <p>In <code>models.py</code> the <code>UserManager</code> should look like this:</p> <pre><code>from django.c...
25,127,468
Android: Placing ImageView on overlap between layouts
<p>I am trying to place an <code>ImageView</code> on the overlap point between two layouts. In the picture below, my goal would be to place the <code>ImageView</code> where the white square is. <b>NOTE: The overlap point will not necessarily be centered vertically as shown below</b></p> <p><img src="https://i.stack.i...
25,143,739
4
6
null
2014-08-04 21:01:39.383 UTC
8
2022-01-14 16:19:32.673 UTC
2016-08-03 17:43:34.547 UTC
null
3,019,655
null
3,019,655
null
1
15
android|android-layout|android-xml
19,239
<p>This will do what you want, with either an image of fixed height, or calculated programatically.</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;RelativeLayout android:...
37,876,288
Is there a one-liner to unpack tuple/pair into references?
<p>I frequently write snippets like</p> <pre><code>int x,y,z; tie(x,y,z) = g[19]; </code></pre> <p>where, for instance, <code>g</code> was declared earlier</p> <pre><code>vector&lt;tuple&lt;int,int,int&gt;&gt; g(100); </code></pre> <p>Problem is, maybe later I actually want <code>x</code> and <code>y</code> to poin...
45,866,028
3
6
null
2016-06-17 08:06:23.867 UTC
7
2018-08-20 23:28:39.087 UTC
null
null
null
null
6,478,097
null
1
46
c++
19,845
<p>Fortunately, C++17 has a solution for exactly this problem, the <a href="http://en.cppreference.com/w/cpp/language/structured_binding" rel="noreferrer">structured binding declaration</a>. Even the non-reference interface can be improved.</p> <pre><code>auto[x, y, z] = g[i]; </code></pre> <p>The above line declares...
37,714,152
How to select range of columns in a dataframe based on their name and not their indexes?
<p>In a pandas dataframe created like this:</p> <pre><code>import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(10, size=(6, 6)), columns=['c' + str(i) for i in range(6)], index=["r" + str(i) for i in range(6)]) </code></pre> <p>which could look as follows:</...
37,714,216
5
7
null
2016-06-08 22:45:40.797 UTC
1
2017-04-25 22:12:01.53 UTC
2017-05-23 12:17:56.673 UTC
null
-1
null
1,534,017
null
1
5
r|dataframe|subset|code-conversion
39,657
<p>It looks like you can accomplish this with a <code>subset</code>:</p> <pre><code>&gt; df &lt;- data.frame(c1=1:6, c2=2:7, c3=3:8, c4=4:9, c5=5:10, c6=6:11) &gt; rownames(df) &lt;- c('r1', 'r2', 'r3', 'r4', 'r5', 'r6') &gt; subset(df, select=c1:c4) c1 c2 c3 c4 r1 1 2 3 4 r2 2 3 4 5 r3 3 4 5 6 r4 4 5...
38,009,060
Is List<?> the common parent of List<Integer> and List<Number>?
<p>From <a href="https://docs.oracle.com/javase/tutorial/java/generics/subtyping.html">this Oracle tutorial</a>,</p> <blockquote> <p>Although <code>Integer</code> is a subtype of <code>Number</code>, <code>List&lt;Integer&gt;</code> is not a subtype of <code>List&lt;Number&gt;</code> and, in fact, these two types ...
38,009,294
5
14
null
2016-06-24 08:40:15.47 UTC
10
2016-06-29 12:08:37.86 UTC
2016-06-24 23:44:48.647 UTC
null
63,550
null
3,395,512
null
1
42
java|generics|inheritance|polymorphism
3,111
<p>The context you need to understand is not of <code>Integer</code> or <code>Number</code> but it's the <strong><code>List</code></strong>. Let's suppose you were the one creating the <code>List</code> class then how would you create the class so it will only support a specific type of class. </p> <p>Yes, that <code>...
35,452,178
What can `__init__` do that `__new__` cannot?
<p>In Python, <code>__new__</code> is used to initialize immutable types and <code>__init__</code> typically initializes mutable types. If <code>__init__</code> were removed from the language, what could no longer be done (easily)?</p> <p>For example,</p> <pre><code>class A: def __init__(self, *, x, **kwargs): ...
35,452,516
3
9
null
2016-02-17 09:09:05.063 UTC
4
2020-05-09 02:41:57.213 UTC
2016-02-17 09:40:51.827 UTC
null
99,989
null
99,989
null
1
30
python|initialization
3,091
<p>Everything you can do in <code>__init__</code> can also be done in <code>__new__</code>.</p> <p>Then, why use <code>__init__</code>?<br> Because you don't have to store instance in variable (<code>obj</code> in your example code), and later bother returning it. You can focus on what you realy want to do &ndash; ini...
22,666,828
No "pull" in Git Gui?
<p>How can I make a pull using Git GUI tool? It seems there is no pull command anywhere.</p> <p>Is there an equivalent menu option using Git GUI?</p> <p>Any help will be appreciated.</p>
22,666,879
3
2
null
2014-03-26 16:07:52.203 UTC
23
2022-06-06 06:51:45.397 UTC
2014-03-26 16:16:38.13 UTC
null
261,122
null
2,848,629
null
1
132
git-pull|git-gui
98,758
<p>Well, I found this useful forum post: <a href="https://web.archive.org/web/20200211180001/http://git.661346.n2.nabble.com/No-quot-pull-quot-in-git-gui-td1121058.html" rel="noreferrer">https://web.archive.org/web/20200211180001/http://git.661346.n2.nabble.com/No-quot-pull-quot-in-git-gui-td1121058.html</a></p> <p>A f...
13,579,632
Android: Date (year,month,day)
<p>I want to get the date as a <em>year, month ,day</em> without hours or minutes or any thing else, and I don't want to get the year alone and the month and the day each by its self. Because as a full date I need it to comparison with another date </p> <p>such as today <code>28.11.2012</code> and to compare it to <c...
13,579,719
5
5
null
2012-11-27 07:53:43.92 UTC
null
2020-04-23 15:56:36.503 UTC
2012-11-28 07:08:29.117 UTC
null
1,838,457
null
1,838,457
null
1
9
android|date|calendar|gettime
42,169
<p>you can use <code>SimpleDateFormat</code>.</p> <p>The basics for getting the current date </p> <pre><code>DateFormat df = new SimpleDateFormat("MMM d, yyyy"); String now = df.format(new Date()); </code></pre> <p>or</p> <pre><code>DateFormat df = new SimpleDateFormat("MM/dd/yy"); String now = df.format(new Date()...
13,458,992
Angle between two Vectors 2D
<p>I'm trying to compute the angle between two vectors. I tried this, but it always returns zero:</p> <pre><code>public double GetAngle(Vector2 a, Vector2 b) { double angle = Math.Atan2(b.Y, b.X) - Math.Atan2(a.Y, a.X); return angle; } GetAngle(new Vector2(1,1), new Vector2(50,50)); </code></pre> <p><a href="h...
13,459,068
9
5
null
2012-11-19 17:27:20.637 UTC
5
2022-08-24 19:27:48.267 UTC
2022-04-11 09:24:29.537 UTC
null
4,298,200
null
1,697,953
null
1
15
c#|vector|xna
56,560
<p>You should take a look at the documentation of <code>atan2</code> (<a href="http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx" rel="noreferrer">here</a>).</p> <p>What you're looking of is finding the difference between B (your upper left vector) and A (your bottom right vector), then pass this as a para...
13,784,434
How to use OpenSSL's SHA256 functions
<p>I'm writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL's SHA256 to become familiar with industry encryption standards, but I'm having issues with getting it working. I've isolated the error to the linking of OpenSSL with the compiled program. I'm w...
13,784,484
2
0
null
2012-12-09 03:47:05.427 UTC
5
2017-10-09 02:23:09.133 UTC
2017-10-09 02:23:09.133 UTC
null
608,639
null
1,633,848
null
1
16
c++|gcc|openssl|sha256
41,271
<p>You make a very common beginners mistake... Putting the libraries you link with in the wrong place on the command line when you build.</p> <p>Dependencies are reversed on the command line, so something that depends on something else should actually be put <em>before</em> what it depends on on the command line.</p> ...
13,320,011
Bootstrap modal dismiss if user click anywhere else..how to prevent this?
<p>I am using Twitter's Bootstrap modal.</p> <p>The modal is dismissed whenever the user clicks anywhere else on the screen except the modal.</p> <p>Is there a way I can prevent this, so the user has to click the Close button to dismiss the modal?</p> <p>Best,</p>
13,320,021
3
2
null
2012-11-10 06:48:45.02 UTC
5
2017-05-18 18:18:09.273 UTC
2012-11-10 06:59:19.867 UTC
null
1,725,145
null
1,260,138
null
1
44
javascript|jquery|css|twitter-bootstrap
29,615
<p>you can pass these options:</p> <pre><code>{ keyboard: false, backdrop: 'static' } </code></pre>
13,698,978
Git - undoing git rm
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/2125710/how-to-revert-a-git-rm-r">How to revert a “git rm -r .”?</a> </p> </blockquote> <p>Git SOS here. I worked 10 hours on a project without committing (I know, I know) and then I git added too many files, s...
13,699,072
1
0
null
2012-12-04 08:46:21.78 UTC
22
2019-10-15 09:00:16.853 UTC
2017-05-23 10:31:13.547 UTC
null
-1
null
1,436,111
null
1
97
git|git-rm
80,091
<p>If you already commited changes, then:</p> <pre><code>git reset (--hard) HEAD~1 </code></pre> <p>If not then:</p> <pre><code>git reset git ls-files -d -z | xargs -0 git checkout -- </code></pre>
13,246,211
How to get stage from controller during initialization?
<p>I want to handle stage events (i.e. hiding) from my controller class. So all I have to do is to add a listener like this:</p> <pre><code>((Stage) myPane.getScene().getWindow()).setOn*whatIwant*(...); </code></pre> <p>But the problem is that initialization starts right after this code:</p> <pre><code>Parent root = FX...
13,247,005
7
0
null
2012-11-06 07:18:36.13 UTC
23
2022-04-10 12:31:48.113 UTC
2022-04-10 12:31:48.113 UTC
null
452,775
null
1,711,975
null
1
99
javafx|initialization|javafx-2|javafx-8|stage
168,602
<p>You can get the instance of the controller from the <code>FXMLLoader</code> after initialization via <code>getController()</code>, but you need to instantiate an <code>FXMLLoader</code> instead of using the static methods then. </p> <p>I'd pass the stage after calling <code>load()</code> directly to the controller ...
13,483,430
How to make rounded percentages add up to 100%
<p>Consider the four percentages below, represented as <code>float</code> numbers:</p> <pre><code> 13.626332% 47.989636% 9.596008% 28.788024% ----------- 100.000000% </code></pre> <p>I need to represent these percentages as whole numbers. If I simply use <code>Math.round()</code>, I end up with ...
13,485,888
22
10
null
2012-11-20 22:38:55.757 UTC
102
2021-11-04 03:21:15.773 UTC
2017-06-03 15:41:43.807 UTC
user6547518
null
null
25,842
null
1
251
algorithm|math|rounding|percentage
135,533
<p>Since none of the answers here seem to solve it properly, here's my semi-obfuscated version using <a href="http://underscorejs.org/" rel="noreferrer">underscorejs</a>:</p> <pre class="lang-js prettyprint-override"><code>function foo(l, target) { var off = target - _.reduce(l, function(acc, x) { return acc + Mat...
51,973,856
How is the smooth dice loss differentiable?
<p>I am training a U-Net in keras by minimizing the <code>dice_loss</code> function that is popularly used for this problem: <a href="https://github.com/keras-team/keras/issues/3611" rel="noreferrer">adapted from here</a> and <a href="https://gist.github.com/wassname/7793e2058c5c9dacb5212c0ac0b18a8a" rel="noreferrer">h...
51,979,012
1
4
null
2018-08-22 19:27:16.41 UTC
8
2022-04-26 10:22:14.637 UTC
2021-12-05 12:35:42.893 UTC
null
1,714,410
null
7,892,871
null
1
11
tensorflow|image-processing|keras|image-segmentation|semantic-segmentation
5,235
<p>Adding <code>smooth</code> to the loss does not make it differentiable. What makes it differentiable is</p> <ol> <li>Relaxing the threshold on the prediction: You do not cast <code>y_pred</code> to <code>np.bool</code>, but leave it as a <em>continuous</em> value between 0 and 1</li> <li>You do not use set operation...
20,365,334
php - syntax error, unexpected T_DOUBLE_ARROW
<p>how i can rid of this error??</p> <pre><code>Parse error: syntax error, unexpected T_DOUBLE_ARROW in /var/www/core/restvt.api.php on line 35 </code></pre> <p>PHP Code :</p> <pre><code> $datax = Array(); foreach ($inis as $key =&gt; $data){ if ($data=="mem"){ $str = number_form...
20,365,479
2
2
null
2013-12-04 01:50:50.833 UTC
null
2016-10-17 19:46:53.943 UTC
2013-12-04 02:00:57.647 UTC
null
3,051,384
null
3,051,384
null
1
15
php|syntax
77,554
<p>I <strong>hate</strong> seeing people use array_push - I know it's legal. In this case, you can't <strong>push</strong> a <code>key =&gt; value</code> to your array, just do this instead:</p> <pre><code>$datax['mem'] = $str; </code></pre> <p>Manual: <a href="http://php.net/manual/en/function.array-push.php" rel="n...
3,877,006
where can I find mysql.data.dll for c#
<p>All I keep on finding are source files for compiling the project myself (which keeps on failing).</p> <p>Any ideas please?</p> <p>Thank You!</p>
3,877,080
2
4
null
2010-10-06 21:22:17.643 UTC
1
2015-05-07 06:15:41.677 UTC
null
null
null
null
126,015
null
1
14
c#|mysql
77,472
<p><a href="http://dev.mysql.com/downloads/connector/net/" rel="noreferrer">Here is where you can download the latest MySql .NET driver for ADO.NET.</a> </p> <p>Enjoy!</p>
3,552,223
ASP.NET - AppDomain.CurrentDomain.GetAssemblies() - Assemblies missing after AppDomain restart
<p>I have a Bootstrapper that looks through all Assemblies in an ASP.NET MVC application to find types that implement an <code>IBootstrapperTask</code> interface, and then registers them with an IOC Contrainer. The idea is that you can literaly place your IBootstrapperTasks anywhere, and organise your Projects how you ...
3,704,939
2
1
null
2010-08-23 22:34:30.137 UTC
12
2014-06-09 15:31:34.493 UTC
2017-05-23 12:17:14.827 UTC
null
-1
null
143,253
null
1
32
c#|asp.net|asp.net-mvc|reflection|assemblies
13,463
<p>I looked through the ASP.NET MVC 2.0 source code and looked up how <code>AreaRegistration.RegisterAllAreas();</code> is implemented. This line is usually put into the Global.asax Application_Start() method and internally it scans all Assemblies for types that implement the AreaRegistration abstract type. This is kin...
3,875,195
Google Chrome > Textboxes > Yellow border when active..?
<p>Ive been modifying a form today, and testing it in Chrome. I noticed that on selecting a textbox, with border: 0 or none, it still puts a yellow border around it. Does anyone know of a way to get rid of this border? I usually wouldnt be that bothered but it looks really horrible with the colour scheme I am using.</p...
3,875,216
2
3
null
2010-10-06 17:19:43.273 UTC
11
2014-03-13 00:39:12.847 UTC
null
null
null
null
297,683
null
1
43
css|google-chrome|input|textbox|border
42,683
<p>This is caused by an <a href="http://www.w3.org/TR/CSS2/ui.html#dynamic-outlines" rel="noreferrer">outline</a>, not a border. The specific style you see is defined in the user agent (browser) stylesheet.</p> <p>I agree that Chrome's large, highlighted outline looks bad in many cases, although it does make it obviou...
3,826,580
What rules does software version numbering follow?
<p>I have been developing some software and want to give it version numbers.</p> <p>How do I do this? </p> <p>How is it that some software gets two versions like 1.3v1.1</p> <p>or some have 3 numbers - 4.0.1 </p> <p>What is the method behind all this?</p> <p>Thanks.</p>
3,826,643
2
0
null
2010-09-29 23:18:33.49 UTC
72
2016-06-14 21:32:28.563 UTC
null
null
null
null
52,256
null
1
129
version-control
131,721
<p>The usual method I have seen is X.Y.Z, which generally corresponds to major.minor.patch:</p> <ul> <li>Major version numbers change whenever there is some significant change being introduced. For example, a large or potentially backward-incompatible change to a software package.</li> <li>Minor version numbers change...
45,493,948
Error: The truth value of a Series is ambiguous - Python pandas
<p>I know this question has been asked before, however, when I am trying to do an <code>if</code> statement and I am getting an error. I looked at this <a href="https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o">link</a> , but did not help much in my cas...
45,494,393
3
14
null
2017-08-03 20:26:39.563 UTC
5
2020-05-16 11:01:55.697 UTC
2018-09-02 12:27:08.273 UTC
null
6,605,349
null
6,626,093
null
1
16
python|pandas|logic
69,573
<p>Here is a small demo, which shows why this is happenning:</p> <pre><code>In [131]: df = pd.DataFrame(np.random.randint(0,20,(5,2)), columns=list('AB')) In [132]: df Out[132]: A B 0 3 11 1 0 16 2 16 1 3 2 11 4 18 15 In [133]: res = df['A'] &gt; 10 In [134]: res Out[134]: 0 False 1 False ...
29,473,830
Image in tooltip using bootstrap?
<pre><code>&lt;button title="Tooltip on right" data-placement="right" data-toggle="tooltip" class="btn btn-default mrs" type="button"&gt;Tooltip on right&lt;/button&gt; &lt;script&gt; $(function () { $('[data-toggle=tooltip]').tooltip(); }); &lt;/script&gt; </code></pre> <p>This works fine but I'd like to in...
29,474,000
1
3
null
2015-04-06 15:02:56.83 UTC
3
2015-04-06 15:12:22.777 UTC
2015-04-06 15:03:50.257 UTC
null
616,443
null
3,916,237
null
1
22
javascript|jquery|twitter-bootstrap|frontend
63,175
<p>You have to pass in the html option to when you initialize .tooltip. e.g. </p> <pre><code>&lt;div class="cart"&gt; &lt;a data-toggle="tooltip" title="&lt;img src='http://getbootstrap.com/apple-touch-icon.png' /&gt;"&gt; &lt;i class="icon-shopping-cart"&gt;&lt;/i&gt; &lt;/a&gt; </code></pre> <h2> ...
16,462,163
Java - How to access an ArrayList of another class?
<p>Hello I'm a beginner in Java and this is my question: I have this first class with the following variables:</p> <pre><code>import java.util.ArrayList; public class numbers { private int number1 = 50; private int number2 = 100; } </code></pre> <p>And I have this class too:</p> <pre><code>import java.util....
16,462,257
5
3
null
2013-05-09 12:48:41.287 UTC
13
2019-03-18 08:35:54.553 UTC
2013-05-09 14:53:48.677 UTC
null
1,622,894
null
2,304,521
null
1
19
java|arraylist
157,932
<pre><code>import java.util.ArrayList; public class numbers { private int number1 = 50; private int number2 = 100; private List&lt;Integer&gt; list; public numbers() { list = new ArrayList&lt;Integer&gt;(); list.add(number1); list.add(number2); } public List&lt;Integer&gt; getLi...
16,492,940
How to install and run lessc on top of node.js and Windows?
<p>Hi I am learning LESS and I would like to install lessc on my Windows 7.</p> <p>Following this tutorial <a href="http://verekia.com/less-css/dont-read-less-css-tutorial-highly-addictive">http://verekia.com/less-css/dont-read-less-css-tutorial-highly-addictive</a></p> <p>The first step is I dowloaded and installed ...
16,493,186
9
1
null
2013-05-11 01:42:14.863 UTC
3
2019-06-16 23:03:30.66 UTC
2013-08-29 21:56:43.167 UTC
null
404,623
null
997,474
null
1
19
windows|node.js|less
38,384
<p>In a console, run the following:</p> <pre><code>node C:\Users\Me\AppData\Roaming\npm\node_modules\less\bin\lessc style.less &gt; style.css </code></pre> <p><code>style.less</code> must be in the console's directory.</p>
16,549,137
How to get the style value using attr
<p>My HTML CODE HERE:</p> <pre><code> &lt;i id="bgcolor" style="background-color: rgb(255, 146, 180)"&gt;&lt;/i&gt; </code></pre> <p>I want to get the background-color value using jquery attr. What i tried is below:</p> <pre><code>$("#bgcolor").mouseleave(function(){ var bodyColor = $(this).attr("style"); ...
16,549,201
5
2
null
2013-05-14 17:18:47.1 UTC
2
2020-01-31 22:32:08.507 UTC
2020-01-31 22:32:08.507 UTC
null
2,912,011
null
2,373,354
null
1
20
jquery|html|css|attr
58,658
<p>Check out the documentation for .css: <a href="http://api.jquery.com/css/" rel="noreferrer">http://api.jquery.com/css/</a></p> <pre><code>var bodyColor = $(this).css("backgroundColor"); </code></pre>
16,077,341
How to reset all default styles of the HTML5 button element
<h2>Scenario</h2> <p>I use the <code>&lt;button&gt;</code> element which appeares just as plain text with an "+" on right end. <br/>On click a div element expands and reveals some information. I think the button element is semanticaley correct to represent such a ... button ... trigger.</p> <h2>Problem</h2> <p>So I ...
16,077,726
1
0
null
2013-04-18 07:50:15.3 UTC
5
2014-11-12 04:57:17.98 UTC
null
null
null
null
497,060
null
1
23
css|html|button|default|user-agent
59,035
<pre><code>button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } </code></pre> <p>add this one also in css it will solve your problem.</p>
16,164,044
What is the correct way to silently close InputStream in finally block without losing the original exception?
<p>I am wondering if the below code closes InputStream in finally block correctly</p> <pre><code>InputStream is = new FileInputStream("test"); try { for(;;) { int b = is.read(); ... } } finally { try { is.close(); } catch(IOException e) { } } </code></pre> <p>If an exceptio...
16,164,100
9
2
null
2013-04-23 08:01:30.047 UTC
null
2020-01-14 09:48:20.383 UTC
null
null
null
null
1,831,293
null
1
30
java
28,681
<p>The exception from is.close() will be suppressed and the exception from is.read() will be the one that propagates up.</p>
12,864,999
Sending and Receiving UDP packets
<p>The following code sends a packet on port 15000:</p> <pre><code>int port = 15000; UdpClient udp = new UdpClient(); //udp.EnableBroadcast = true; //This was suggested in a now deleted answer IPEndPoint groupEP = new IPEndPoint(IPAddress.Broadcast, port); string str4 = "I want to receive this!"; byte[] sendBytes4 = ...
12,867,005
1
7
null
2012-10-12 18:26:45.203 UTC
3
2017-12-20 13:23:00.157 UTC
2012-10-12 19:42:56.743 UTC
null
1,742,063
null
1,742,063
null
1
5
c#|udp|message|broadcast|packet
64,104
<p>Here is the <code>simple</code> version of Server and Client to send/receive UDP packets</p> <p><strong>Server</strong></p> <pre><code>IPEndPoint ServerEndPoint= new IPEndPoint(IPAddress.Any,9050); Socket WinSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); WinSocket.Bind(ServerE...
15,374,969
Determining if a string contains a word
<p>In Python, what is the syntax for a statement that, given the following context:</p> <pre><code>words = 'blue yellow' </code></pre> <p>would be an if statement that checks to see if <code>words</code> contains the word "blue"? I.e.,</p> <pre><code>if words ??? 'blue': print 'yes' elif words ??? 'blue': pr...
15,374,983
4
4
null
2013-03-13 00:37:51.817 UTC
4
2013-03-13 01:11:42.847 UTC
2013-03-13 00:52:31.447 UTC
null
722,332
null
2,157,472
null
1
6
python|if-statement
57,775
<pre><code>words = 'blue yellow' if 'blue' in words: print 'yes' else: print 'no' </code></pre> <h1>Edit</h1> <p>I just realized that <code>nightly blues</code> would contain <code>blue</code>, but not as a whole word. If this is not what you want, split the wordlist:</p> <pre><code>if 'blue' in words.split...
17,184,242
Command Prompt/Bat file - Create new folder named with today's date
<p>I use the following code to create a new folder that is named with todays date:</p> <pre><code>for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a mkdir c:\%date:/=% </code></pre> <p>Now the format is as follows:</p> <pre><code>20130619 </code></pre> <p>How do I change the format to?: </p> <pre><co...
17,184,479
4
0
null
2013-06-19 06:25:13.62 UTC
3
2017-09-17 00:23:18.53 UTC
null
null
null
null
1,140,828
null
1
5
command-line|batch-file
53,072
<pre><code>for /f "tokens=1-3 delims=/" %%a in ("%date%") do md "%%a_%%b_%%c" </code></pre>
24,614,474
Pandas Merge on Name and Closest Date
<p>I am trying to merge two dataframes on both name and the closest date (WRT the left hand dataframe). In my research I found one similar question <a href="https://stackoverflow.com/questions/21201618/pandas-merge-match-the-nearest-time-stamp-the-series-of-timestamps">here</a> but it doesn't account for the name as we...
25,962,323
3
6
null
2014-07-07 15:39:00.62 UTC
12
2018-07-18 14:25:35.84 UTC
2017-05-23 12:01:33.313 UTC
null
-1
null
3,314,282
null
1
18
python|date|pandas|merge
21,337
<p>I'd also love to see the final solution you came up with to know how it shook out in the end.</p> <p>One thing you can do to find the closest date might be something to calc the number of days between each date in the first DataFrame and the dates in the second DataFrame. Then you can use <code>np.argmin</code> to ...
21,983,097
Testflight: Cannot upload build, cannot download SDK
<p>I'm having difficulties with TestFlight today. I've tried to upload ipa for the new app but getting this error:</p> <blockquote> <p>Sorry, we are no longer accepting any new builds that use the TestFlight SDK. Please remove the SDK and re-upload. Learn More.</p> </blockquote> <p>Learn more just point to generic ...
21,983,289
2
3
null
2014-02-24 09:02:36.447 UTC
4
2015-03-02 07:26:54.813 UTC
2014-11-17 18:28:29.347 UTC
null
1,192,479
null
211,765
null
1
35
ios|testflight
13,836
<p>I think this is related to the <a href="http://techcrunch.com/2014/02/21/rumor-testflight-owner-burstly-is-being-acquired-by-apple/" rel="noreferrer">Apple purchase of TestFlight</a>.</p> <p>My colleague told me that Android has also been disabled for TestFlight so it wouldn't surprise me if they have taken the who...
21,891,218
Using $state methods with $stateChangeStart toState and fromState in Angular ui-router
<p>I'm writing a handler for <code>$stateChangeStart</code>:</p> <pre><code>var stateChangeStartHandler = function(e, toState, toParams, fromState, fromParams) { if (toState.includes('internal') &amp;&amp; !$cookies.MySession) { e.preventDefault(); // Some login stuff. } }; $rootScope.$on('$st...
24,010,392
1
7
null
2014-02-19 20:05:15.827 UTC
19
2018-07-20 12:56:30.32 UTC
2016-10-25 14:06:30.377 UTC
null
3,146,716
null
1,032,590
null
1
36
angularjs|angular-ui-router
104,647
<h3>Suggestion 1</h3> <p>When you add an object to <code>$stateProvider.state</code> that object is then passed with the state. So you can add additional properties which you can read later on when needed.</p> <p><strong>Example route configuration</strong></p> <pre><code>$stateProvider .state('public', { abstra...
17,283,018
The call is ambiguous between single method i.e extension method
<p>I have an extension method like</p> <pre><code>public static class Extension { public static string GetTLD(this string str) { var host = new System.Uri(str).Host; int index = host.LastIndexOf('.'), last = 3; while (index &gt;= last - 3) { last = index; ...
17,285,002
6
18
null
2013-06-24 19:00:55.073 UTC
3
2017-10-24 12:08:20.373 UTC
2013-06-24 20:30:46.48 UTC
null
270,348
null
1,306,394
null
1
29
c#|asp.net|runtime-error|ambiguous
11,083
<p>This is not a real solution and I can't explain how did it work but it worked.</p> <p>I was trying everything in Project Properties, References, bin, obj but nothing helped me really. And I was just trying every option and chose 'Convert to Web Application' from the context menu. Although It was a Web Application i...
17,178,907
How to get a permanent user token for writes using the Trello API?
<p>I'm trying to write an app that updates my Trello cards with the API. How do I get a permanent user token for the app to write to my Trello board?</p> <p>Thanks</p>
17,301,115
3
0
null
2013-06-18 21:04:21.397 UTC
17
2017-03-14 10:24:04.463 UTC
null
null
null
null
233,798
null
1
34
trello
13,818
<p>You can do this in one of 2 ways -</p> <p>Direct the user to the below address. This will direct the user to a page that has a token that she can copy and paste back to you. The important bit is that you ask for <code>expiration = never</code> and <code>scope = read,write</code></p> <pre><code>https://trello.com/1...
17,505,835
How do I set up the hosts file for multiple domains/hosts with the same IP?
<p>As you surely know you can map host names to IP addresses with the "hosts" file. This is very useful especially when you are developing as you can change localhost for project1.</p> <p>That part is clear, but unfortunately I can't figure out how to set this up to open multiple projects with the same IP. I've tried ...
17,893,591
3
0
null
2013-07-06 18:25:11.633 UTC
15
2022-09-15 07:49:27.263 UTC
2019-07-24 17:22:41.673 UTC
null
964,243
null
736,086
null
1
50
hosts|web-development-server
103,855
<p>I got this resolved thanks to Google and the collaborators, @jvilhena and @DRC. Here's how I did it:</p> <p>If you are using Windows and XAMPP as in my case the first step is to set up the 'hosts' file. If you are using Windows it's likely that you will find it in C:\Windows\System32\drivers\etc\hosts. You can use ...
18,647,611
Posting JSON data to API using CURL
<p>When I'm posting <code>json</code> data to API using <code>curl</code> - I'm not getting any output. I would like to send email invitation to recipient. </p> <pre><code>$url_send ="http://api.address.com/SendInvitation?"; $str_data = json_encode($data); function sendPostData ($url, $post) { $ch = curl_init($u...
18,648,053
3
0
null
2013-09-05 23:36:36.303 UTC
2
2018-09-12 15:57:13.337 UTC
2014-07-14 09:22:00.313 UTC
null
542,420
null
2,729,422
null
1
12
php|json|api|curl
77,320
<p>Try adding <code>curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);</code><br> And changing <code>http_build_query($post)</code> to <code>$post</code></p> <p>The implementation:</p> <pre><code>&lt;?php $data = array( "authorizedKey" =&gt; "abbad35c5c01-xxxx-xxx", "senderEmail" =&gt; "myemail@yahoo.com", "recipien...
9,796,101
Exchange - listing mailboxes in an OU with their mailbox size
<p>I'm trying to display all the mailboxes and their sizes for all our users in our Departed OU. I seem to be very close but my command seems to be adding some padding to the results.</p> <pre><code>[PS] C:\Windows\system32&gt;dsquery user "ou=Departed,ou=Staff,dc=COMPANY,dc=local" -limit 4 | dsget user -samid | Get-M...
9,796,371
2
0
null
2012-03-20 22:40:17.063 UTC
2
2019-01-25 10:34:55.07 UTC
null
null
null
null
1,273,286
null
1
3
powershell|exchange-server
103,260
<p>Why the dsquery?</p> <pre><code>get-mailbox -OrganizationalUnit "ou=Departed,ou=Staff,dc=COMPANY,dc=local" -resultsize unlimited | get-mailboxstatistics | ft DisplayName,TotalItemSize,Itemcount </code></pre>
23,401,652
fatal: The current branch master has no upstream branch
<p>I'm trying to push one of my projects to github, and I keep getting this error:</p> <pre><code>peeplesoft@jane3:~/846156 (master) $ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master </code></p...
23,402,125
31
7
null
2014-05-01 03:38:33.823 UTC
98
2022-09-21 06:53:39.03 UTC
2015-01-05 02:44:14.237 UTC
null
31,671
null
1,524,361
null
1
372
git|github
945,488
<p>You fixed the push, but, independently of that push issue (which I explained in "<a href="https://stackoverflow.com/a/17096880/6309">Why do I need to explicitly push a new branch?</a>": <code>git push -u origin master</code> or <code>git push -u origin --all</code>), you need now to resolve the authentication issue....
5,502,688
Using Markov chains (or something similar) to produce an IRC-bot
<p>I tried google and found little that I could understand.</p> <p>I understand <a href="http://en.wikipedia.org/wiki/Markov_chain" rel="noreferrer">Markov chains</a> to a very basic level: It's a mathematical model that only depends on previous input to change states..so sort of a FSM with weighted random chances ins...
5,502,971
3
0
null
2011-03-31 15:54:46.017 UTC
15
2011-06-16 11:42:40.12 UTC
2011-03-31 16:22:59.563 UTC
null
166,749
null
407,879
null
1
20
artificial-intelligence|nlp|markov-chains
8,164
<p>Yes, a Markov chain is a finite-state machine with probabilistic state transitions. To generate random text with a simple, first-order Markov chain:</p> <ol> <li>Collect bigram (adjacent word pair) statistics from a corpus (collection of text).</li> <li>Make a markov chain with one state per word. Reserve a special...
25,642,585
How to check if object is null or not except == null
<p>I want to make method that will check if the class instance is null or not.</p> <p>Simply I know that i can use <code>== null</code>, but I want to know that is there any other way that can be implemented to check if instance is null or not ?</p> <p>I have nearly <code>70-80</code> class instance. &amp; all that c...
25,642,884
1
3
null
2014-09-03 10:58:35.083 UTC
5
2014-09-03 11:34:10.003 UTC
null
null
null
null
3,145,373
null
1
21
java|null
124,732
<p>The easiest way to check is <code>entity == null</code>. There is no shorter way to do that.</p> <p>Note that there is a method for this in the standard lib:</p> <p><a href="http://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#isNull-java.lang.Object-" rel="noreferrer">Objects.isNull(Object obj)</a></p>...
25,802,786
Is there any way to recover recently deleted documents in MongoDB?
<p>I have removed some documents in my last query by mistake, Is there any way to rollback my last query mongo collection.</p> <p>Here it is my last query :</p> <pre><code> db.foo.remove({ "name" : "some_x_name"}) </code></pre> <p>Is there any rollback/undo option? Can I get my data back?</p>
25,809,807
2
3
null
2014-09-12 07:15:25.057 UTC
10
2020-01-20 05:28:24.657 UTC
2020-01-20 05:28:24.657 UTC
null
3,835,758
null
3,835,758
null
1
33
mongodb|rollback
81,051
<p>There is no rollback option (<a href="http://docs.mongodb.org/manual/core/replica-set-rollbacks/">rollback has a different meaning</a> in a MongoDB context), and strictly speaking there is no supported way to get these documents back - the precautions you can/should take are covered in the comments. With that said ...
9,136,674
Verify a method call using Moq
<p>I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I am trying to test.</p> <pre><code>class MyClass { SomeClass someClass; public MyClass(SomeClass someClass) { this.someClass = someClass; } public void MyMethod(string method) { meth...
9,136,721
1
5
null
2012-02-03 23:01:32.34 UTC
24
2019-11-24 10:43:40.777 UTC
2019-11-24 10:43:40.777 UTC
null
4,551,041
null
591,410
null
1
214
c#|testing|methods|moq
283,596
<p>You're checking the wrong method. Moq requires that you Setup (and then optionally Verify) the method in the dependency class.</p> <p>You should be doing something more like this:</p> <pre><code>class MyClassTest { [TestMethod] public void MyMethodTest() { string action = "test"; Mock&l...
18,588,927
Elasticsearch 503 error when checking server status
<p>I've been using elasticsearch as a search engine for my Rails application, however it stopped working properly due to a reason i can't understand. When making a curl request to elasticsearch server i get a 503 error.</p> <pre><code>curl -XGET http://localhost:9200 { "ok" : true, "status" : 503, "name" : "Kill...
21,629,814
4
1
null
2013-09-03 09:40:48.493 UTC
4
2020-08-27 09:00:45.653 UTC
null
null
null
null
1,022,108
null
1
28
search|curl|full-text-search|elasticsearch|tire
54,724
<p>There could be another instance in your local network with elasticsearch server up and running. Since shards in elasticsearch are working from the box and enabled by default there could be a conflict of master node. Please review your elasticsearch.log file. If there is something like </p> <pre><code>{"error":"Mast...
18,544,359
How to read user input into a variable in Bash?
<p>I'm trying to create a script that simplifies the process of creating a new user on an iOS device. Here are the steps broken down:</p> <pre class="lang-bash prettyprint-override"><code>fullname=&quot;USER INPUT&quot; user=&quot;USER INPUT&quot; group=$user uid=1000 gid=1000 home=/var/$user echo &quot;$group:*:$gid:$...
18,546,416
5
0
null
2013-08-31 04:03:08.007 UTC
40
2022-08-07 11:07:49.293 UTC
2022-08-07 11:04:09.283 UTC
null
775,954
null
2,602,638
null
1
162
bash|shell
220,330
<p>Use <a href="https://wiki.bash-hackers.org/commands/builtin/read" rel="noreferrer"><code>read -p</code></a>:</p> <pre><code># fullname=&quot;USER INPUT&quot; read -p &quot;Enter fullname: &quot; fullname # user=&quot;USER INPUT&quot; read -p &quot;Enter user: &quot; user </code></pre> <p>If you like to get the user'...
18,538,428
Loading a .json file into c# program
<p>I am trying to move my website from XML based config files to JSON based ones. Is there a way to load in a <code>.json</code> file in so that it turns into the object? I have been searching the web and I cannot find one. I already have the <code>.xml</code> file converted and saved as a <code>.json</code>. I would r...
18,538,469
6
5
null
2013-08-30 17:28:25.99 UTC
4
2020-04-16 02:18:21.023 UTC
2020-03-27 00:29:56.93 UTC
null
1,127,428
null
2,654,083
null
1
51
c#|json
217,499
<p>You <strong><em>really</em></strong> should use an established library, such as <a href="http://www.nuget.org/packages/NewtonSoft.Json/">Newtonsoft.Json</a> (which even Microsoft uses for frameworks such as MVC and WebAPI), or .NET's built-in <a href="http://msdn.microsoft.com/en-us/library/bb355316.aspx">Javascript...
18,580,066
How to Allow Remote Access to PostgreSQL database
<p>I have PostgreSQL 9.2 Installed in Windows 7 and I have windows XP installed in Virtual Machine, how do I connect these two databases and allow remote access to add/edit the database from both Systems ?</p>
18,580,598
8
1
null
2013-09-02 20:05:38.643 UTC
49
2022-02-08 10:08:58.957 UTC
null
null
null
null
2,355,951
null
1
100
windows|postgresql|virtual-machine
224,899
<p>In order to remotely access a PostgreSQL database, you must set the two main PostgreSQL configuration files:</p> <p>postgresql.conf<br> pg_hba.conf</p> <p>Here is a brief description about how you can set them (note that the following description is purely indicative: To configure a machine safely, you must be fam...
18,344,569
setting ng-href in <tr> elements
<p>The following code makes the client.name an anchor on each client in clients. I am interested in having the entire <code>&lt;tr&gt;</code> element be that link however. <code>ng-href</code> does not work on the <code>&lt;tr&gt;</code> element.. what can I do so that the entire row is a single link instantiated by <c...
18,344,639
9
2
null
2013-08-20 20:40:56.537 UTC
3
2021-07-17 19:09:49.837 UTC
null
null
null
null
759,466
null
1
19
angularjs
46,012
<p>You can use an <a href="http://docs.angularjs.org/api/ng.directive:ngClick" rel="noreferrer">ng-click</a> (instead of onClick) as Jason suggests as well.</p> <p>Something like:</p> <p><strong>HTML</strong></p> <pre><code>&lt;tr ng-repeat="client in clients" ng-click="showClient(client)"&gt; &lt;td&gt;&lt;a ng...
18,389,124
Simulate CREATE DATABASE IF NOT EXISTS for PostgreSQL?
<p>I want to create a database which does not exist through JDBC. Unlike MySQL, PostgreSQL does not support <code>create if not exists</code> syntax. What is the best way to accomplish this?</p> <p>The application does not know if the database exists or not. It should check and if the database exists it should be used...
18,389,184
10
0
null
2013-08-22 19:21:08.99 UTC
39
2021-08-03 21:21:51.433 UTC
2013-09-16 18:24:11.217 UTC
null
939,860
null
1,317,240
null
1
191
sql|database|postgresql|jdbc|ddl
210,174
<h3>Restrictions</h3> <p>You can ask the system catalog <a href="https://www.postgresql.org/docs/current/catalog-pg-database.html" rel="noreferrer"><code>pg_database</code></a> - accessible from any database in the same database cluster. The tricky part is that <a href="https://www.postgresql.org/docs/current/sql-creat...
15,007,637
Deleting carriage returns caused by line reading
<p>I have a list:</p> <pre><code>Cat Dog Monkey Pig </code></pre> <p>I have a script:</p> <pre><code>import sys input_file = open('list.txt', 'r') for line in input_file: sys.stdout.write('"' + line + '",') </code></pre> <p>The output is:</p> <pre><code>"Cat ","Dog ","Monkey ","Pig", </code></pre> <p>I'd like...
15,007,662
3
0
null
2013-02-21 16:41:40.34 UTC
3
2013-02-21 16:50:32.937 UTC
null
null
null
null
1,721,444
null
1
26
python|python-2.7
74,995
<p><a href="http://docs.python.org/2/library/stdtypes.html#str.rstrip" rel="noreferrer">str.rstrip</a> or simply <a href="http://docs.python.org/2/library/stdtypes.html#str.strip" rel="noreferrer">str.strip</a> is the right tool to split carriage return (newline) from the data read from the file. Note str.strip will st...
14,954,220
How to check if obtained homography matrix is good?
<p>This question was already <a href="https://stackoverflow.com/questions/11053099/how-can-you-tell-if-a-homography-matrix-is-acceptable-or-not">asked</a>, but I still don't get it. I obtain a homography matrix by calling <code>cv::findHomography</code> from a set of points. I need to check whether it's relevant or not...
14,965,352
2
1
null
2013-02-19 09:37:27.51 UTC
19
2017-02-08 10:46:14.423 UTC
2017-05-23 10:30:49.723 UTC
null
-1
null
609,063
null
1
29
opencv|image-processing|computer-vision|homography|ransac
15,520
<p>Your question is mathematical. Given a matrix of 3x3 decide whether it represents a good rigid transformation. It is hard to define what is "good" but here are some clues that can help you</p> <ol> <li>Homography should preserve the direction of polygonal points. Design a simple test. points (0,0), (imwidth,0), (wi...
15,085,118
PrettyPrint python into a string, and not stdout
<p>I'd like to use prettyprint to print out a dictionary, but into a string and not to console. This string is to be passed on to other functions.</p> <p>I know I can use the "stream" parameter to specify a file instead of sys.out but I want a string.</p> <p>How do I do that?</p>
15,085,170
3
5
null
2013-02-26 09:09:15.513 UTC
4
2013-02-26 10:42:24.72 UTC
null
null
null
null
1,724,926
null
1
40
python
15,196
<p>Just use the <a href="http://docs.python.org/2/library/stringio.html" rel="nofollow"><code>StringIO</code> module</a>:</p> <pre><code>import StringIO output = StringIO.StringIO() </code></pre> <p>Now you may pass <code>output</code> as a stream to <code>prettyprint</code>.</p>
28,099,683
Algorithm for dependency resolution
<p>I'm in the process of writing a package manager, and for that I want the dependency resolution to be as powerful as possible.</p> <p>Each package has a list of versions, and each version contains the following information:</p> <ul> <li>A comparable ID</li> <li><strong>Dependencies</strong> (a list of packages and ...
28,102,139
1
2
null
2015-01-22 22:17:02.93 UTC
17
2015-01-23 02:38:24.487 UTC
null
null
null
null
953,222
null
1
27
algorithm|dependency-management
12,461
<h2>It's NP-hard</h2> <p>Some bad news: This problem is NP-hard, so unless P=NP, there is no algorithm that can efficiently solve all instances of it. I'll prove this by showing how to convert, in polynomial time, any given instance of the NP-hard problem <a href="http://en.wikipedia.org/wiki/Boolean_satisfiability_p...
45,021,644
Is there way to determine why Azure App Service restarted?
<p>I have a bunch of websites running on a single instance of Azure App Service, and they're all set to Always On. They all suddenly restarted at the same time, causing everything to go slow for a few minutes as everything hit a cold request. </p> <p>I would expect this if the service had moved me to a new host, but t...
45,242,214
2
9
null
2017-07-10 21:10:38.603 UTC
21
2022-04-02 10:45:58.11 UTC
null
null
null
null
32,187
null
1
40
azure|azure-web-app-service
15,213
<p>So, it seems the answer to this is &quot;no, you can't really know <em>why</em>, you can just infer that it <em>did</em>.&quot;</p> <p>I mean, you can add some Application Insights logging like</p> <pre><code> private void Application_End() { log.Warn($&quot;The application is shutting down because of...