The following algorithms might be useful if you want to implement a spell checker (or Google-style “did you mean” feature):
A reader-writer lock is a lock which will allow multiple concurrent readers but only one writer. A reader-writer lock can be significantly more efficient than a standard mutex if reads on your shared memory far outnumber writes.
Reader-writer locks naturally fit together with caches, as caches are only effective if reads far outnumber writes.
Here is a general pattern for using a reader-writer lock with a cache:
- Acquire a reader lock.
- Check the cache for the value. If it exists, save the value and go to step 8.
- Upgrade the reader lock to a writer lock.
- Check the cache for the value. If it exists, save the value and go to step 7.
- Calculate the value (expensive, otherwise we wouldn’t cache it)
- Insert the value into the cache.
- Release the writer lock.
- Release the reader lock.
- Return the value.
The reason why we have to check the cache for the value again in step (4) is because of the following possibility (assume step 4 doesn’t exist):
Thread 1 Thread 2
============================ ===============================
- Acquire reader lock - Acquire reader lock
- Check cache for value - Check cache for value
with key A (not found) with key A (not found)
- Upgrade to writer lock - (block)
- Calculate value (expensive)
- Insert value into cache
- Release writer lock
- Release reader lock
- Upgrade to writer lock
- Calculate value (expensive)
(We are paying this cost
twice)
- Insert value into cache
(We are inserting two values
with the same key, which may
be fatal)
With step 4 it becomes:
Thread 1 Thread 2
============================ ===============================
- Acquire reader lock - Acquire reader lock
- Check cache for value - Check cache for value
with key A (not found) with key A (not found)
- Upgrade to writer lock - (block)
- Calculate value (expensive)
- Insert value into cache
- Release writer lock
- Release reader lock
- Upgrade to writer lock
- Check cache for value
with key A (found)
- Release writer lock
- Release reader lock
- Return value - Return value
Pricing models like the arbitrage pricing theory or the Fama-French factor models simply assume that prices are right, then extrapolate from that what the relevant risk factors must be that determine prices.
Fox, Justin. What we talk about when we talk about the efficient market hypothesis. The Curious Capitalist Blog: 8 October 2009.
Exactly!
When you are processing an HTTP request in ASP.NET you can retrieve the user-provided query string parameters using the HttpRequest.QueryString property. This property is an instance of the NameValueCollection class.
If the user has provided multiple parameters with the same key in the query string, HttpRequest.QueryString[key] will return all the values concatenated together with commas. If you would rather process the values individually, use HttpRequest.QueryString.GetValues(key), which will return an array of all the provided values.
For example:
URL: http://example.com?a=1&a=2 HttpRequest.QueryString["a"] = "1,2" HttpRequest.QueryString.GetValues("a") = { "1", "2" }
I spent many weeks of my childhood, along with a substantial portion of last weekend, playing Might and Magic 2, which I purchased in a bundle from GOG.com.
Fond memories.
Stare at the red dot at the center of this image for a minute or two:

![]() |
The Affluent Society by John Kenneth Galbraith |
![]() |
The Amazing Adventures of Kavalier & Clay by Michael Chabon |
![]() |
Gödel, Escher, Bach: An Eternal Golden Braid by Douglas R. Hofstadter |
![]() |
Damned Lies and Statistics: Untangling Numbers from the Media, Politicians, and Activists by Joel Best |
![]() |
A Short History of Nearly Everything by Bill Bryson |
![]() |
Beautiful Architecture: Leading Thinkers Reveal the Hidden Beauty in Software Design by Diomidis Spinellis, Georgios Gousios |
![]() |
A Random Walk Down Wall Street by Burton G. Malkiel |
Current Cubs team OBP: 0.328
Current Cubs team ERA: 3.79
This year’s prediction: 87-75 (Methodology)
Previous predictions: 82-80 (7/5), 82-80 (6/5), 78-84 (5/12)
Current Cubs team OBP: 0.322
Current Cubs team ERA: 3.90
This year’s prediction: 82-80 (Methodology)
Previous prediction(s): 82-80 (6/5), 78-84 (5/12)
Current Cubs team OBP: 0.329
Current Cubs team ERA: 4.17
This year’s prediction: 82-80 (Methodology)
Previous prediction(s): 78-84 (5/12)







Recent Comments