Id
int64
4
8.51M
PostTypeId
int64
1
7
AcceptedAnswerId
int64
7
75.5M
ParentId
int64
4
41.8M
Score
int64
-208
27.7k
ViewCount
int64
11
12.4M
Body
stringlengths
0
45k
Title
stringlengths
2
150
ContentLicense
stringclasses
3 values
FavoriteCount
int64
0
225
CreationDate
stringdate
2008-07-31 21:42:52
2011-12-14 18:48:47
LastActivityDate
stringdate
2008-08-01 12:19:17
2023-03-05 04:40:26
LastEditDate
stringdate
2008-08-01 13:54:25
2023-03-05 03:12:45
LastEditorUserId
int64
-1
21.3M
OwnerUserId
int64
-1
21.1M
Tags
listlengths
1
6
34,482
2
null
13,941
12
null
If you have PyObjC (the Python - Objective-C bridge) installed or are running on OS X 10.5's system python (which ships with PyObjC), you can do ``` from AppKit import NSBeep NSBeep() ``` to play the system alert.
null
CC BY-SA 2.5
null
2008-08-29T15:47:05.843
2008-08-29T15:47:05.843
null
null
2,140
null
34,454
2
null
33,476
20
null
There is a pretty good diagram in the [JSF specification](http://java.sun.com/javaee/javaserverfaces/download.html) that shows the request lifecycle - essential for understanding this stuff. The steps are: - - - - - - - - This is a somewhat simplified version of events. Refer to the specification for more details. ...
null
CC BY-SA 2.5
null
2008-08-29T15:09:23.110
2008-08-29T15:09:23.110
null
null
304
null
34,481
2
null
34,439
27
null
On top of the more direct answers, I'd be remiss if I didn't mention [IPython](http://ipython.scipy.org/). Hit to see the available methods, with autocompletion. And once you've found a method, try: ``` help(object.method) ``` to see the pydocs, method signature, etc. Ahh... [REPL](http://en.wikipedia.org/wiki/REPL)....
null
CC BY-SA 4.0
null
2008-08-29T15:47:04.517
2020-12-02T13:09:00.997
2020-12-02T13:09:00.997
63,550
1,480
null
34,480
2
null
34,398
2
null
Your issue with mixing data may be how Sql 2005 sorts text data. It's not a 'natural' sort. If you have a varchar field and you do: ``` where value > '20.5' ``` Values like "5" will be in your result (as in a character based sort "5" comes after "20.5") You're going to be better off with separate columns for stora...
null
CC BY-SA 2.5
null
2008-08-29T15:44:36.673
2008-08-29T15:44:36.673
null
null
905
null
34,474
2
null
34,312
35
null
I prefer PHPUnit now, but when I started out I used SimpleTest as I didn't always have access to the command line. SimpleTest is nice, but the only thing it really has over PHPUnit, in my opinion, is the web runner. The reasons I like PHPUnit are that it integrates with other PHP developer tools such as [phing](http:...
null
CC BY-SA 3.0
null
2008-08-29T15:40:41.550
2011-10-01T22:30:14.967
2011-10-01T22:30:14.967
2,594
2,594
null
34,490
1
34,514
null
164
92,108
[SHA Hash functions](http://en.wikipedia.org/wiki/SHA-1)
How do I create a SHA1 hash in ruby?
CC BY-SA 2.5
0
2008-08-29T15:49:08.113
2013-11-06T17:51:39.103
2008-08-29T16:06:28.743
3,624
3,624
[ "ruby", "hash", "sha1" ]
34,476
1
34,504
null
12
681
I have to do some JavaScript in the future, so it is time to update my toolbox. Right now I use Firefox with some addons: - [https://www.squarefree.com/bookmarklets/webdevel.html](https://www.squarefree.com/bookmarklets/webdevel.html)- - - - I plan to use [Venkman Javascript debugger](http://www.hacksrus.com/~ginda/...
What is in your JavaScript development toolbox?
CC BY-SA 3.0
0
2008-08-29T15:41:45.060
2013-06-08T13:48:15.473
2013-06-08T13:46:56.187
938,089
720
[ "javascript", "debugging" ]
34,492
2
null
34,476
1
null
1. Web Developer Toolbar (Firefox Addon) 2. Nikhil's Web Development Helper (IE Toolbar)
null
CC BY-SA 2.5
null
2008-08-29T15:49:08.647
2008-08-29T15:49:08.647
null
null
2,343
null
34,499
2
null
34,488
0
null
I believe the LIMIT is something done after the data set is found and the result set is being built up so I wouldn't expect it to make any difference at all. Making name the primary key will have a significant positive effect though as it will result in an index being made for the column.
null
CC BY-SA 2.5
null
2008-08-29T15:51:53.130
2008-08-29T15:51:53.130
null
null
3,382
null
34,488
1
34,500
null
34
11,061
Will limiting a query to one result record, improve performance in a large(ish) MySQL table if the table only has one matching result? for example ``` select * from people where name = "Re0sless" limit 1 ``` if there is only one record with that name? and what about if `name` was the primary key/ set to unique? and...
Does limiting a query to one record improve performance
CC BY-SA 2.5
0
2008-08-29T15:48:23.390
2009-03-29T18:33:52.347
null
null
2,098
[ "sql", "mysql", "database" ]
34,493
1
34,719
null
5
2,493
We have a few very large Excel workbooks (dozens of tabs, over a MB each, very complex calculations) with many dozens, perhaps hundreds of formulas that use the dreaded INDIRECT function. These formulas are spread out throughout the workbook, and target several tables of data to look-up for values. Now I need to move ...
Excel: list ranges targeted by INDIRECT formulas
CC BY-SA 2.5
null
2008-08-29T15:49:25.307
2020-02-07T00:17:53.503
2020-02-07T00:17:53.503
4,240,030
2,230
[ "excel", "vba" ]
34,496
2
null
34,476
0
null
A couple more:: 1. IE Explorer Toolbar 2. Firefox Developer Toolbar
null
CC BY-SA 2.5
null
2008-08-29T15:50:17.737
2008-08-29T15:50:17.737
null
null
2,017
null
34,501
2
null
34,488
0
null
If "name" is unique in the table, then there may still be a (very very minimal) gain in performance by putting the limit constraint on your query. If name is the primary key, there will likely be none.
null
CC BY-SA 2.5
null
2008-08-29T15:52:42.817
2008-08-29T15:52:42.817
null
null
1,975,282
null
34,500
2
null
34,488
44
null
If the column has it's no faster because it will prevent sending any additional rows beyond the first matched, if any exist - -
null
CC BY-SA 2.5
null
2008-08-29T15:51:55.847
2009-03-29T18:01:57.230
2009-03-29T18:01:57.230
2,774
2,774
null
34,486
1
34,538
null
5
328
I have a small JS function that does Ajax for me and another like it that adds in POST data to the request. With Ajax being such a big topic with so many libraries about it, what am I missing from my function, is it insecure or something else worrying? ``` function loadPage(pagePath, displayElement) { var xmlHttp;...
What more is needed for Ajax than this function
CC BY-SA 2.5
null
2008-08-29T15:48:16.307
2011-07-20T11:22:25.657
null
null
1,384,652
[ "javascript", "ajax" ]
34,508
2
null
34,488
2
null
To answer your questions in order: 1) yes, if there is no index on name. The query will end as soon as it finds the first record. take off the limit and it has to do a full table scan every time. 2) no. primary/unique keys are guaranteed to be unique. The query should stop running as soon as it finds the row.
null
CC BY-SA 2.5
null
2008-08-29T15:55:07.460
2008-08-29T15:55:07.460
null
null
2,884
null
34,507
2
null
34,399
4
null
The browser displays the bullets because the style property "display" is initially set to "list-item". Changing the display property to "inline" cancels all the special styles that list items get. You should be able to simulate it with the :before selector and the content property, but IE (at least through version 7) d...
null
CC BY-SA 2.5
null
2008-08-29T15:54:47.883
2008-08-29T15:54:47.883
null
null
619
null
34,511
2
null
34,505
0
null
By default it does it based on the reference to the object, but that means that it's the exact same object, so both would return the same hash. But a hash should be based on the value, like in the case of the string class. "a" and "b" would have a different hash, but "a" and "a" would return the same hash.
null
CC BY-SA 2.5
null
2008-08-29T15:56:17.550
2008-08-29T15:56:17.550
null
null
77
null
34,504
2
null
34,476
8
null
I use both Firefox and IE for Web Development and a few add-ons in each: - [Firebug](https://addons.mozilla.org/en-US/firefox/addon/1843)- [Web Developer Toolbar](https://addons.mozilla.org/en-US/firefox/addon/60) - [IE Developer Toolbar](http://www.microsoft.com/en-us/download/details.aspx?id=18359)- [Fiddler](h...
null
CC BY-SA 3.0
null
2008-08-29T15:54:11.580
2013-06-08T13:48:15.473
2013-06-08T13:48:15.473
938,089
1,804
null
34,513
2
null
13,927
5
null
A bit of extra info that I've gained by painful experience: although NSNotificationCenter uses zeroing weak references when running under garbage collection, KVO does not. Thus, you can get away with not removing an NSNotificationCenter observer when using GC (when using retain/release, you still need to remove your ob...
null
CC BY-SA 2.5
null
2008-08-29T15:56:34.167
2008-08-29T15:56:34.167
null
null
2,140
null
34,502
2
null
34,390
65
null
Here's what I did: ``` <link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" /> ``` It fools Visual Studio into thinking you've added a stylesheet to the page but it doesn't get rendered. --- Here's an even more concise way to do this with multiple references; `...
null
CC BY-SA 2.5
null
2008-08-29T15:52:43.770
2008-11-25T22:35:52.873
2008-11-25T22:35:52.873
1,249
1,249
null
34,514
2
null
34,490
395
null
``` require 'digest/sha1' Digest::SHA1.hexdigest 'foo' ```
null
CC BY-SA 2.5
null
2008-08-29T15:56:48.347
2008-08-29T15:56:48.347
null
null
3,366
null
34,505
1
34,541
null
26
9,043
The MSDN documentation on [Object.GetHashCode()](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx) describes 3 contradicting rules for how the method should work. 1. If two objects of the same type represent the same value, the hash function must return the same constant value for either objec...
Is Object.GetHashCode() unique to a reference or a value?
CC BY-SA 3.0
0
2008-08-29T15:54:15.870
2015-09-23T09:48:08.830
2012-06-22T03:38:48.697
392
392
[ "c#", ".net" ]
34,516
1
34,533
null
38
22,280
Is there a standard convention (like phpdoc or python's docstring) for commenting C# code so that class documentation can be automatically generated from the source code?
Is there a standard (like phpdoc or python's docstring) for commenting C# code?
CC BY-SA 2.5
0
2008-08-29T15:57:44.537
2018-02-23T18:09:42.743
null
null
305
[ "c#", "comments" ]
34,519
1
null
null
414
273,761
A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it?
What is a semaphore?
CC BY-SA 2.5
0
2008-08-29T15:58:15.957
2022-02-14T14:03:13.893
null
null
1,931
[ "multithreading", "concurrency", "semaphore" ]
34,512
1
34,520
null
193
153,791
When writing multi-threaded applications, one of the most common problems experienced are deadlocks. My questions to the community are: 1. What is a deadlock? 2. How do you detect them? 3. Do you handle them? 4. And finally, how do you prevent them from occurring?
What is a deadlock?
CC BY-SA 3.0
0
2008-08-29T15:56:27.020
2023-01-21T09:51:55.513
2016-02-26T00:09:46.227
3,128,926
1,931
[ "multithreading", "concurrency", "locking", "deadlock" ]
34,518
1
null
null
23
10,618
How do you sort an array of strings [naturally](http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/) in different programming languages? Post your implementation and what language it is in in the answer.
Natural Sorting algorithm
CC BY-SA 3.0
0
2008-08-29T15:57:49.607
2022-03-29T21:02:06.817
2014-12-11T19:47:03.423
4,279
1,585
[ "algorithm", "language-agnostic", "sorting", "natural-sort" ]
34,510
1
34,550
null
1,277
828,532
When writing multithreaded applications, one of the most common problems experienced is race conditions. My questions to the community are: - - - -
What is a race condition?
CC BY-SA 4.0
0
2008-08-29T15:55:10.457
2022-11-03T01:28:25.220
2021-10-15T15:42:04.900
179,850
1,931
[ "multithreading", "concurrency", "terminology", "race-condition" ]
34,522
2
null
34,512
2
null
Deadlock occurs when two threads aquire locks which prevent either of them from progressing. The best way to avoid them is with careful development. Many embedded systems protect against them by using a watchdog timer (a timer which resets the system whenever if it hangs for a certain period of time).
null
CC BY-SA 2.5
null
2008-08-29T15:59:07.077
2008-08-29T15:59:07.077
null
null
317
null
34,529
2
null
34,519
-6
null
A semaphore is a way to lock a resource so that it is guaranteed that while a piece of code is executed, only this piece of code has access to that resource. This keeps two threads from concurrently accesing a resource, which can cause problems.
null
CC BY-SA 2.5
null
2008-08-29T16:01:36.133
2008-08-29T16:01:36.133
null
null
2,328
null
34,509
1
2,060,952
null
47
38,361
We have a large database on which we have DB side pagination. This is quick, returning a page of 50 rows from millions of records in a small fraction of a second. Users can define their own sort, basically choosing what column to sort by. Columns are dynamic - some have numeric values, some dates and some text. Whil...
Natural (human alpha-numeric) sort in Microsoft SQL 2005
CC BY-SA 3.0
0
2008-08-29T15:55:10.223
2022-03-04T21:56:25.217
2014-03-11T17:27:33.003
59,303
905
[ "sql-server", "sql-server-2005", "sorting", "natural-sort" ]
34,524
1
null
null
900
429,762
A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a mutex and how do you use it?
What is a mutex?
CC BY-SA 2.5
0
2008-08-29T15:59:25.437
2022-03-01T10:13:09.480
null
null
1,931
[ "multithreading", "concurrency", "mutex" ]
34,523
2
null
32,871
7
null
The trick is to use some simple JavaScript to resize the Flash DOM node: ``` function resizeFlash( h ) { // "flash-node-id" is the ID of the embedded Flash movie document.getElementById("flash-node-id").style.height = h + "px"; } ``` Which you call from within the Flash movie like this: ``` ExternalInterfac...
null
CC BY-SA 2.5
null
2008-08-29T15:59:24.750
2008-08-29T15:59:24.750
null
null
1,109
null
34,506
1
35,201
null
12
6,842
Is there anyway to have a sort of virtual static member in C++? For example: ``` class BaseClass { public: BaseClass(const string& name) : _name(name) {} string GetName() const { return _name; } virtual void UseClass() = 0; private: const string _name; }; class DerivedClass :...
Simulating a virtual static member of a class in c++?
CC BY-SA 2.5
0
2008-08-29T15:54:46.167
2022-08-01T08:01:17.910
null
null
3,373
[ "c++", "virtual-functions" ]
34,520
2
null
34,512
246
null
A occurs when multiple processes try to access the same resource at the same time. One process loses out and must wait for the other to finish. A occurs when the waiting process is still holding on to another resource that the first needs before it can finish. So, an example: Resource A and resource B are used by...
null
CC BY-SA 2.5
null
2008-08-29T15:58:34.957
2008-08-29T16:06:02.753
2008-08-29T16:06:02.753
905
905
null
34,532
2
null
34,516
1
null
C# has built in [documentation commands](https://learn.microsoft.com/en-us/dotnet/csharp/codedoc) Have fun!
null
CC BY-SA 3.0
null
2008-08-29T16:01:58.910
2018-02-23T18:09:42.743
2018-02-23T18:09:42.743
3,590
3,590
null
34,530
2
null
34,516
3
null
``` /// <summary> /// /// </summary> /// <param name="strFilePath"></param> ``` [http://msdn.microsoft.com/en-us/magazine/cc302121.aspx](http://msdn.microsoft.com/en-us/magazine/cc302121.aspx)
null
CC BY-SA 2.5
null
2008-08-29T16:01:37.493
2008-08-29T16:01:37.493
null
null
1,293
null
34,528
2
null
34,518
5
null
``` Array.prototype.alphanumSort = function(caseInsensitive) { for (var z = 0, t; t = this[z]; z++) { this[z] = [], x = 0, y = -1, n = 0, i, j; while (i = (j = t.charAt(x++)).charCodeAt(0)) { var m = (i == 46 || (i >=48 && i <= 57)); if (m !== n) { this[z][++y] = ""; n = m; ...
null
CC BY-SA 2.5
null
2008-08-29T16:01:29.880
2008-08-29T16:01:29.880
null
null
1,585
null
34,538
2
null
34,486
13
null
I strongly recommend you not roll your own Ajax code. Instead, use a framework such as Prototype, Dojo, or any of the others. They've taken care of handling all the ReadyStates you're not handling (2 means it's been sent, 3 means it's in process, etc.), and they should escape the reponse you're getting so you don't ins...
null
CC BY-SA 2.5
null
2008-08-29T16:03:11.933
2008-08-29T16:03:11.933
null
null
3,098
null
34,539
2
null
34,486
6
null
I would remove this line. ``` alert("Your browser does not support AJAX!") ``` Shouting at the user in a language he probably doesn't understand is worse than failure. :-)
null
CC BY-SA 2.5
null
2008-08-29T16:03:13.870
2008-08-29T16:03:13.870
null
null
437
null
34,525
2
null
34,476
3
null
I sometimes use Emacs with Steve Yegge's [js2-mode](http://code.google.com/p/js2-mode/), evaluating code with [Rhino](http://www.mozilla.org/rhino/) & John Resig's [env.js](http://ejohn.org/blog/bringing-the-browser-to-the-server/) to load jQuery or Prototype in my standalone scripts. This allows me to explore javascr...
null
CC BY-SA 2.5
null
2008-08-29T16:00:47.447
2008-08-29T16:08:56.913
2008-08-29T16:08:56.913
2,797
2,797
null
34,537
2
null
34,510
39
null
A race condition is a kind of bug, that happens only with certain temporal conditions. Example: Imagine you have two threads, A and B. In Thread A: ``` if( object.a != 0 ) object.avg = total / object.a ``` In Thread B: ``` object.a = 0 ``` If thread A is preempted just after having check that object.a is no...
null
CC BY-SA 3.0
null
2008-08-29T16:03:06.537
2013-05-16T05:08:54.293
2013-05-16T05:08:54.293
369
1,578
null
34,543
2
null
34,516
1
null
Microsoft uses "[XML Documentation Comments](http://msdn.microsoft.com/en-us/library/b2s063f7.aspx)" which will give IDE intellisense descriptions and also allow you to auto-generate MSDN-style documentation using a tool such as Sandcastle if you turn on the generation of the XML file output. To turn on the generation...
null
CC BY-SA 2.5
null
2008-08-29T16:04:10.730
2008-08-29T16:04:10.730
null
null
392
null
34,536
1
34,710
null
21
42,684
This most be the second most simple rollover effect, still I don't find any simple solution. I have a list of items and a corresponding list of slides (DIVs). After loading, the first list item should be selected (bold) and the first slide should be visible. When the user hovers over another list item, that list item...
How do you swap DIVs on mouseover (jQuery)?
CC BY-SA 4.0
0
2008-08-29T16:02:59.050
2019-03-22T15:08:58.550
2019-03-22T15:08:58.550
7,079,025
3,377
[ "javascript", "jquery", "html", "css" ]
34,542
2
null
34,518
5
null
For MySQL, I personally use code from a Drupal module, which is available at hhttp://drupalcode.org/project/natsort.git/blob/refs/heads/5.x-1.x:/natsort.install.mysql Basically, you execute the posted SQL script to create functions, and then use `ORDER BY natsort_canon(field_name, 'natural')` Here's a readme about th...
null
CC BY-SA 3.0
null
2008-08-29T16:03:47.940
2013-11-06T11:36:56.253
2013-11-06T11:36:56.253
428
979
null
34,544
1
63,555
null
1
839
I am writing a Browser Helper Object for ie7, and I need to detect DOM modification (i.e. via AJAX). So far I couldn't find any feasible solution.
Detect DOM modification in Internet Explorer
CC BY-SA 2.5
0
2008-08-29T16:04:25.113
2008-09-15T14:46:49.790
2008-08-31T00:10:56.247
383
3,448
[ "c++", "internet-explorer", "internet-explorer-7", "bho" ]
34,533
2
null
34,516
40
null
You can use XML style comments, and use tools to pull those comments out into API documentation. Here is an example of the comment style: ``` /// <summary> /// Authenticates a user based on a username and password. /// </summary> /// <param name="username">The username.</param> /// <param name="password">The password...
null
CC BY-SA 2.5
null
2008-08-29T16:02:39.923
2008-08-29T16:02:39.923
null
null
1,960
null
34,547
2
null
34,463
5
null
The way that windows locks open files might cause an issue requiring you to hook into the Volume Shadowcopy Service. About two years ago this fellow ported the algorithm to C#. I haven't taken a look at the code (or the provided binary), but it might be a place to start looking or someone to try contacting. [http:/...
null
CC BY-SA 2.5
null
2008-08-29T16:04:44.177
2008-08-29T16:04:44.177
null
null
3,269
null
34,548
2
null
34,524
78
null
When you have a multi-threaded application, the different threads sometimes share a common resource, such as a variable or similar. This shared source often cannot be accessed at the same time, so a construct is needed to ensure that only one thread is using that resource at a time. The concept is called "mutual exclu...
null
CC BY-SA 4.0
null
2008-08-29T16:04:47.797
2019-08-03T11:44:22.950
2019-08-03T11:44:22.950
2,202,101
2,973
null
34,546
2
null
34,512
11
null
A deadlock happens when a thread is waiting for something that never occurs. Typically, it happens when a thread is waiting on a mutex or semaphore that was never released by the previous owner. It also frequently happens when you have a situation involving two threads and two locks like this: ``` Thread 1 ...
null
CC BY-SA 2.5
null
2008-08-29T16:04:43.600
2008-08-29T16:16:50.293
2008-08-29T16:16:50.310
2,284
2,284
null
34,561
2
null
34,399
3
null
Keep them display blocked, give them a width and float left. That will make them sit by side, which is like inline, and should maintain the list style.
null
CC BY-SA 2.5
null
2008-08-29T16:07:56.963
2008-08-29T16:07:56.963
null
null
3,193
null
34,541
2
null
34,505
30
null
> Rules 1 & 3 are contradictory to me. To a certain extent, they are. The reason is simple: if an object is stored in a hash table and, by changing its value, you change its hash then the hash table has lost the value and you can't find it again by querying the hash table. It is important that while objects are stored...
null
CC BY-SA 2.5
null
2008-08-29T16:03:42.247
2008-08-29T16:03:42.247
null
null
1,968
null
34,560
2
null
34,519
18
null
@Craig: > A semaphore is a way to lock a resource so that it is guaranteed that while a piece of code is executed, only this piece of code has access to that resource. This keeps two threads from concurrently accesing a resource, which can cause problems. This is not restricted to only one thread. A semap...
null
CC BY-SA 2.5
null
2008-08-29T16:07:55.183
2008-08-29T16:07:55.183
null
null
2,973
null
34,562
2
null
34,510
42
null
A race condition is a situation on concurrent programming where two concurrent threads or processes compete for a resource and the resulting final state depends on who gets the resource first.
null
CC BY-SA 4.0
null
2008-08-29T16:07:57.913
2019-02-09T17:35:34.530
2019-02-09T17:35:34.530
2,695
2,695
null
34,558
2
null
34,524
2,791
null
When I am having a big heated discussion at work, I use a rubber chicken which I keep in my desk for just such occasions. The person holding the chicken is the only person who is allowed to talk. If you don't hold the chicken you cannot speak. You can only indicate that you want the chicken and wait until you get it...
null
CC BY-SA 3.0
null
2008-08-29T16:07:15.387
2016-06-04T21:21:30.507
2016-06-04T21:21:30.507
308,315
274
null
34,565
1
null
null
75
63,146
Additionally, how can I format it as a string padded with zeros?
How do I generate a random 10 digit number in ruby?
CC BY-SA 2.5
0
2008-08-29T16:08:47.990
2021-04-24T20:04:30.013
2008-10-06T15:31:34.123
1,599
3,624
[ "ruby", "random" ]
34,551
2
null
34,524
112
null
ual clusion. [Here's the Wikipedia entry on it.](https://en.wikipedia.org/wiki/Mutual_exclusion) The point of a mutex is to synchronize two threads. When you have two threads attempting to access a single resource, the general pattern is to have the first block of code attempting access to set the mutex before entering...
null
CC BY-SA 4.0
null
2008-08-29T16:05:38.747
2020-10-16T00:51:34.860
2020-10-16T00:51:34.860
1,402,846
1,975,282
null
34,550
2
null
34,510
1,600
null
A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change in d...
null
CC BY-SA 3.0
null
2008-08-29T16:05:23.100
2015-04-07T11:03:02.043
2015-04-07T11:03:02.043
3,001,736
142
null
34,556
2
null
34,524
250
null
A Mutex is a ually clusive flag. It acts as a gate keeper to a section of code allowing one thread in and blocking access to all others. This ensures that the code being controlled will only be hit by a single thread at a time. Just be sure to release the mutex when you are done. :)
null
CC BY-SA 4.0
null
2008-08-29T16:06:26.857
2022-03-01T10:13:09.480
2022-03-01T10:13:09.480
17,762,883
2,894
null
34,573
2
null
34,505
4
null
Rules 1 & 3 aren't really a contradiction. For a reference type the hash code is derived from a reference to the object - change an object's property and the reference is the same. For value types the hash code is derived from the value, change a property of a value type and you get a completely new instance of the v...
null
CC BY-SA 2.5
null
2008-08-29T16:11:24.240
2008-08-29T16:11:24.240
null
null
905
null
34,571
1
34,658
null
3,152
1,182,082
How do I use JUnit to test a class that has internal private methods, fields or nested classes? It seems bad to change the access modifier for a method just to be able to run a test.
How do I test a class that has private methods, fields or inner classes?
CC BY-SA 3.0
0
2008-08-29T16:11:09.933
2023-01-06T21:41:53.200
2021-10-19T20:41:15.027
6,296,561
3,098
[ "java", "unit-testing", "junit", "tdd" ]
34,564
2
null
34,536
0
null
The only thing that's wrong with this code (at least to me) is that you're not using a loop to process all elements. Other than that, why not to it like that? And with loop, I mean grabbing the container element via a JQuery and iterating over all child elements – basically a one-liner.
null
CC BY-SA 2.5
null
2008-08-29T16:08:41.047
2008-08-29T16:08:41.047
null
null
1,968
null
34,567
2
null
34,398
0
null
> I guess I could create separate fields, then have a view that sort of coalesces them into a single logical column. Any opinions on that? It depends on the source of the data. If you are getting the data from users (or some other system) in some free-form manner and don't really care what type of data it is, then th...
null
CC BY-SA 2.5
null
2008-08-29T16:09:59.127
2008-08-29T16:09:59.127
null
null
1,314
null
34,579
1
null
null
4
3,085
I've recently been working with a MySQL database, and using MySQL workbench to design the Database. When I use the export to SQL function, so I can actually get the layout in to the Database, I get: > "Error 1005: Cannot create table" This appears to be related to Foreign Keys in the create table statement. Does an...
MySQL "Error 1005" when adding tables
CC BY-SA 3.0
0
2008-08-29T16:12:31.273
2015-05-07T15:40:03.677
2015-05-07T15:40:03.677
812,149
655
[ "mysql", "mysql-workbench", "mysql-error-1005" ]
34,578
2
null
34,510
20
null
Race conditions occur in multi-threaded applications or multi-process systems. A race condition, at its most basic, is anything that makes the assumption that two things not in the same thread or process will happen in a particular order, without taking steps to ensure that they do. This happens commonly when two thr...
null
CC BY-SA 2.5
null
2008-08-29T16:12:09.120
2008-08-29T16:12:09.120
null
null
3,575
null
34,574
2
null
34,524
29
null
In C#, the common mutex used is the [Monitor](http://en.wikipedia.org/wiki/Monitor_(synchronization)). The type is '[System.Threading.Monitor](http://msdn.microsoft.com/en-us/library/system.threading.monitor.aspx)'. It may also be used implicitly via the '[lock(Object)](http://msdn.microsoft.com/en-us/library/c5kehkcz(...
null
CC BY-SA 3.0
null
2008-08-29T16:11:28.077
2015-04-08T02:07:45.483
2015-04-08T02:07:45.483
2,891,664
3,619
null
34,586
2
null
34,571
807
null
The best way to test a private method is via another public method. If this cannot be done, then one of the following conditions is true: 1. The private method is dead code 2. There is a design smell near the class that you are testing 3. The method that you are trying to test should not be private
null
CC BY-SA 2.5
null
2008-08-29T16:14:19.943
2008-08-29T16:14:19.943
null
null
2,822
null
34,582
2
null
34,565
95
null
To generate the number call rand with the result of the expression "10 to the power of 10" ``` rand(10 ** 10) ``` To pad the number with zeros you can use the string format operator ``` '%010d' % rand(10 ** 10) ``` or the `rjust` method of string ``` rand(10 ** 10).to_s.rjust(10,'0') ```
null
CC BY-SA 2.5
null
2008-08-29T16:13:42.050
2008-08-29T16:13:42.050
null
null
3,624
null
34,540
2
null
33,923
173
null
This excerpt from the book shows [how to make a proper tail recursion](http://www.lua.org/pil/6.3.html) (in Lua, but should apply to Lisp too) and why it's better. > A [tail recursion] is a kind of goto dressed as a call. A tail call happens when a function calls another as its last action, so it has nothing e...
null
CC BY-SA 3.0
null
2008-08-29T16:03:30.793
2016-02-25T21:26:20.097
2016-02-25T21:26:20.097
2,359,271
3,485
null
34,590
2
null
34,571
151
null
Generally a unit test is intended to exercise the public interface of a class or unit. Therefore, private methods are implementation detail that you would not expect to test explicitly.
null
CC BY-SA 3.0
null
2008-08-29T16:14:54.637
2012-12-29T09:52:20.260
2012-12-29T09:52:20.260
63,550
3,305
null
34,583
2
null
33,768
8
null
There's no need to use `mxmlc` on the command line just to be able to add compiler flags. Right click your project in the Flex Navigator, select Properties and then Flex Compiler in the dialog that appears. There you can add any extra compiler flags. Not sure that there's very much to do though, more code means more ...
null
CC BY-SA 2.5
null
2008-08-29T16:13:46.387
2008-08-29T16:20:03.830
2008-08-29T16:20:03.830
1,109
1,109
null
34,581
1
34,587
null
7
21,019
I expected the two `span` tags in the following sample to display next to each other, instead they display one below the other. If I set the `width` of the class `span`.right to 49% they display next to each other. I am not able to figure out why the right span is pushed down like the right span has some invisible `pad...
inline-block on span
CC BY-SA 4.0
null
2008-08-29T16:13:11.880
2020-08-12T21:52:01.783
2020-08-12T21:52:01.783
9,154,188
3,635
[ "html", "css", "css-float", "internet-explorer-6" ]
34,589
2
null
29,144
0
null
I definitely prefer the merge methodology. I've used Visual Sourcesafe (hopefully never again), CVS, subversion and bzr. Visual sourcesafe enforces the "checkout before editing" methodology and can be painful. CVS and subversion haven't been great at accepting merges historically, though I hear subversion 1.5 has im...
null
CC BY-SA 2.5
null
2008-08-29T16:14:39.410
2008-08-29T16:14:39.410
null
null
3,189
null
34,588
1
34,645
null
212
548,880
When running my application I sometimes get an error about `too many files open`. Running `ulimit -a` reports that the limit is 1024. How do I increase the limit above 1024? `ulimit -n 2048` results in a permission error.
How do I change the number of open files limit in Linux?
CC BY-SA 3.0
0
2008-08-29T16:14:25.417
2017-06-26T06:29:14.403
2012-04-25T23:00:18.420
1,332,690
3,535
[ "linux" ]
34,587
2
null
34,581
3
null
``` float: left; ``` Try adding that to span.left It will cause it to float to the left (as suggested by the syntax). --- I am not a CSS expert by any means so please don't take this as unarguable fact but I find that when something is floated, it makes no difference to the vertical position of things below it....
null
CC BY-SA 3.0
null
2008-08-29T16:14:25.247
2011-11-02T12:04:42.573
2011-11-02T12:04:42.573
1,288
1,384,652
null
34,594
2
null
34,571
68
null
The private methods are called by a public method, so the inputs to your public methods should also test private methods that are called by those public methods. When a public method fails, then that could be a failure in the private method.
null
CC BY-SA 2.5
null
2008-08-29T16:15:30.127
2008-08-29T16:15:30.127
null
null
572
null
34,599
2
null
29,168
3
null
You can have two git repositories (client and server) and add them to a "super-project" (app). In this "super-project" you can add the two repositories as submodules (check [this tutorial](https://git.wiki.kernel.org/articles/g/i/t/GitSubmoduleTutorial_c489.html)). Another possible solution (a bit more dirty) is to ha...
null
CC BY-SA 3.0
null
2008-08-29T16:16:23.573
2011-11-13T15:17:25.987
2011-11-13T15:17:25.987
28,451
161
null
34,602
2
null
33,814
0
null
If you've gotta stick to your current method of parsing, and it's a regex, you can use the [multi-line flag](http://us3.php.net/manual/en/reference.pcre.pattern.modifiers.php) "m" to span across multiple lines.
null
CC BY-SA 2.5
null
2008-08-29T16:18:16.423
2008-08-29T16:18:16.423
null
null
1,902,010
null
34,598
2
null
34,571
238
null
From this article: [Testing Private Methods with JUnit and SuiteRunner](http://www.artima.com/suiterunner/private.html) (Bill Venners), you basically have 4 options: > 1. Don't test private methods. 2. Give the methods package access. 3. Use a nested test class. 4. Use reflection.
null
CC BY-SA 4.0
null
2008-08-29T16:16:20.047
2021-04-24T21:04:52.087
2021-04-24T21:04:52.087
1,080,125
2,697
null
34,595
1
746,727
null
147
181,690
What is a good Hash function? I saw a lot of hash function and applications in my data structures courses in college, but I mostly got that it's pretty hard to make a good hash function. As a rule of thumb to avoid collisions my professor said that: ``` function Hash(key) return key mod PrimeNumber end ``` (mod is...
What is a good Hash Function?
CC BY-SA 3.0
0
2008-08-29T16:15:37.257
2022-10-11T08:49:41.773
2012-09-02T12:05:26.043
193,892
3,485
[ "algorithm", "language-agnostic", "hash" ]
34,611
1
35,741
null
13
6,123
What are some toolkits for developing 2D games in Python? An option that I have heard of is Pygame, but is there anything that has more range to do more things? What are the good and bad parts about the modules?
Toolkit Options for 2D Python Game Programming
CC BY-SA 3.0
0
2008-08-29T16:20:43.467
2013-12-17T22:44:49.797
2013-12-17T22:44:49.797
2,253,573
1,447
[ "python-3.x", "pygame", "libraries", "toolkit", "2d-games" ]
34,603
2
null
34,512
36
null
Deadlocks will only occur when you have two or more locks that can be aquired at the same time and they are grabbed in different order. Ways to avoid having deadlocks are: - - -
null
CC BY-SA 2.5
null
2008-08-29T16:19:17.077
2008-08-29T16:19:17.077
null
null
2,973
null
34,606
2
null
34,595
4
null
I'd say that the main rule of thumb is not to roll your own. Try to use something that has been thoroughly tested, e.g., SHA-1 or something along those lines.
null
CC BY-SA 2.5
null
2008-08-29T16:20:05.467
2008-08-29T16:20:05.467
null
null
2,964
null
34,625
2
null
34,486
1
null
jQuery is probably one of the lightest popular libraries out there.
null
CC BY-SA 2.5
null
2008-08-29T16:22:27.927
2008-08-29T16:22:27.927
null
null
1,902,010
null
34,621
2
null
34,510
46
null
A sort-of-canonical definition is "." In the situation the "reader" thread may get the old value or the new value, depending on which thread "wins the race." This is not always a bug—in fact, some really hairy low-level algorithms do this on purpose—but it should generally be avoided. @Steve Gury give's a good example ...
null
CC BY-SA 2.5
null
2008-08-29T16:21:41.577
2008-08-29T16:21:41.577
null
null
1,412
null
34,566
2
null
34,505
5
null
Not sure what MSDN documentation you are referring to. Looking at the current documentation on Object.GetHashCode ([http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx)) provides the following "rules": - If two objects compare a...
null
CC BY-SA 2.5
null
2008-08-29T16:09:29.690
2008-08-29T16:09:29.690
null
null
1,559
null
34,630
2
null
34,571
18
null
I tend not to test private methods. There lies madness. Personally, I believe you should only test your publicly exposed interfaces (and that includes protected and internal methods).
null
CC BY-SA 2.5
null
2008-08-29T16:23:45.893
2008-08-29T16:23:45.893
null
null
1,931
null
34,617
2
null
34,536
5
null
Here's the jQuery version: ``` <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"></script> <script type="text/javascript"> $(function () { $("#switches li").mouseover(function () { var $this = $(this); $("#slides div").hide(); $("#slide" + $this.a...
null
CC BY-SA 2.5
null
2008-08-29T16:21:23.857
2008-08-29T16:27:07.633
2008-08-29T16:27:07.633
1,414
1,414
null
34,614
2
null
33,814
1
null
Perhaps for future projects I'll use a parsing library, but that's kind of aside from the question at hand. This is my current solution. `rstrpos` is strpos, but from the reverse direction. Example use: ``` for($i=0; $i<count($lines); $i++) { $line = handle_mulitline_tags(&$i, $line, $lines); } ``` And here's th...
null
CC BY-SA 2.5
null
2008-08-29T16:20:57.163
2008-08-29T16:20:57.163
null
null
1,569
null
34,634
2
null
33,971
0
null
And what's funny (and frustrating!) is that the Microsoft apps (e.g. Entourage) use the standards. I develop on WinXP during the day but have an iMac at home, so it's confusing enough trying to switch modes between work and home. But then I have to remember if I'm writing an e-mail in Entourage, I need to revert ba...
null
CC BY-SA 2.5
null
2008-08-29T16:25:57.323
2008-08-29T16:25:57.323
null
null
2,773
null
34,635
1
34,651
null
8
6,077
I think the file that is produced is an .asm file, any idea how to produce this in Visual Studio when you do a build?
How do I get the assembler output from a C file in VS2005
CC BY-SA 2.5
0
2008-08-29T16:25:58.633
2012-05-02T04:10:47.983
2012-05-02T04:10:47.983
192,221
1,952
[ "c", "visual-studio", "assembly" ]
34,629
2
null
34,463
0
null
Have you seen this: [http://www.itefix.no/i2/taxonomy/term/39](http://www.itefix.no/i2/taxonomy/term/39) I have used cwrsync without any problem (and with the much of the usual cygwin misery), but I haven't had any need for unicode filenames, so I've not seen that problem. I don't really know why there isn't a nativ...
null
CC BY-SA 2.5
null
2008-08-29T16:23:18.797
2008-08-29T16:23:18.797
null
null
987
null
34,633
2
null
32,607
5
null
Ahh, just found this [CodePlex Article on using TFPT.exe](http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=Use%20Team%20Foundation%20Power%20Tools%20to%20Rollback%20a%20Change&referringTitle=Source%20Control%20Guidelines) (power tool) to rollback a changeset. Hope this helps you out.
null
CC BY-SA 2.5
null
2008-08-29T16:25:03.037
2008-08-29T16:25:03.037
null
null
3,381
null
34,626
2
null
34,398
0
null
You might consider using two columns, one "string" and one "numeric" (whatever variants of those are appropriate) with the "string" column NOT NULL and the "numeric" column allowing NULL values. When inserting a value, always populate the "string" column indpendent of the type, however if the value is numeric, ALSO sto...
null
CC BY-SA 2.5
null
2008-08-29T16:22:43.197
2008-08-29T16:22:43.197
null
null
null
null
34,639
2
null
34,611
0
null
I've only heard people talk about pygame. It has tons of followers & plenty of functionality. Recently I saw [this book](https://rads.stackoverflow.com/amzn/click/com/1590598725) at barnes & noble which I might check out one day. It looked good.
null
CC BY-SA 2.5
null
2008-08-29T16:27:49.347
2008-08-29T16:27:49.347
null
null
3,381
null
34,642
2
null
34,579
1
null
I ran into this situation recently when I attempted (in InnoDB tables) to make a foreign key reference to a column that had a different data type. [MySQL 5.1 Documentation](http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html)
null
CC BY-SA 2.5
null
2008-08-29T16:29:34.977
2008-08-29T16:29:34.977
null
null
3,449
null
34,640
2
null
34,611
3
null
I think pygame is the standard for game development in Python, I don't know of any others. A book you may be interested in is [Game Programming with Python, Lua, and Ruby](https://rads.stackoverflow.com/amzn/click/com/1592000770). Not only does it cover Python (and, I believe, the pygame module), but it also gives yo...
null
CC BY-SA 2.5
null
2008-08-29T16:28:33.323
2008-08-29T16:28:33.323
null
null
271
null
34,623
1
85,788
null
10
2,195
Why would you do an automatic HTML post rather than a simple redirect? Is this so developers can automatically generate a login form that posts directory to the remote server when the OpenID is known? eg. 1. User is not logged in and visits your login page. 2. You detect the user's openID from a cookie. 3. Form is ...
Why is HTML form redirection used in OpenID 2?
CC BY-SA 2.5
0
2008-08-29T16:21:47.600
2013-02-04T07:15:56.813
null
null
2,108
[ "openid", "redirect", "openid2" ]
34,638
1
34,917
null
6
5,339
The system I am currently working on requires some role-based security, which is well catered for in the Java EE stack. The system intends to be a framework for business domain experts to write their code on top of. However, there is also a requirement for data `security`. That is, what information is visible to an en...
data 'security' with java and hibernate
CC BY-SA 3.0
null
2008-08-29T16:27:43.000
2014-11-30T10:17:39.750
2014-11-30T10:17:39.750
3,867,570
3,295
[ "java", "security", "hibernate", "jakarta-ee" ]
34,641
2
null
32,338
2
null
The [IntelliJ](http://www.jetbrains.com/idea/index.html) IDE (Java, Scala, Ruby,...) has a [Locate Duplicate...](http://www.jetbrains.com/idea/features/code_duplicate.html) tool. Usefull indeed !
null
CC BY-SA 2.5
null
2008-08-29T16:29:28.160
2008-08-29T16:29:28.160
null
null
2,797
null