Memoize in Clojure is cool. Memoize is even built in to the core Clojure API. Resetting the built-in version is impossible since the atom used as a cache is hidden in a closure, but it’s easy to write a custom resettable version. Here are two versions that we came up with on IRC today. Continue Reading »

Popularity: 40% [?]

Yahoo! Finance allows clients to download free historic stock data. Transparentech’s YahooFinance Ruby gem works well, but getting historic data for a large number of symbols is painfully slow. YahooFinance (the gem)’s download of the end-of-day historic quotes for about 10,000 symbols was taking 2 hours or more. With Typhoeus and its parallel connections, I can run the same download in under 7 minutes.

Paul Dix’s Typhoeus appeared while Googling today. Not only is it an awesomely fast wrapper for libcurl, it allows you to queue requests and then execute them concurrently.

Update: I’ve just released a Ruby gem based on this code. It’s on Gemcutter, and the source is on GitHub. You can install it by just doing a “sudo gem install yahoofinance-typhoeus“.
Continue Reading »

Popularity: 48% [?]

jQuery’s Tablesorter is easily customizable to sort by absolute value or anything else you’d like. In my case, I have a column of “standard deviations above or below the mean” that I want to display sorted by absolute value. This was pretty easy with a little Javascript code. Continue Reading »

Popularity: 38% [?]

Clojure-mode for Emacs will clobber any line-final commas, even if they’re embedded in a string literal. O_o Continue Reading »

Popularity: 3% [?]

I just read “A Constructivist Take on the Strait” by Max Tsung-Chi Yu. The information on Taiwanese internal politics with regard to China and of the various nations’ stances towards growing Chinese power was interesting and informative. What I disliked was the explicitly intersubjective analysis of the “One China, different interpretations” declaration. Intersubjectivity and notions of mutually constructed non-objective reality are intrinsically phenomenological nonsense, thus irretrivably corrupting any theory thence derived. (And despite the superficially warm and fuzzy happy hippie overtones in which phenomenology and its offspring postmodernism and constructivism usually present today, let’s not forget where it came from and what it was invented to support, and what it could easily be turned to again in the future, with very little if any theoretical modification from its present form.) Continue Reading »

Popularity: 8% [?]

Omerta by Mario Puzo is entertaining during a long airplane ride, even if it falls short as Great Literature. Like The Godfather before it, there is plenty of Machiavellian intrigue to unravel and various betrayals and plot twists to keep your attention. Perhaps more than its predecessor, Omerta suffers from pervasively flat and stereotypical characters drawn variously from 1930s gangster films and 1960s political-doomsday dramas, replete with their now-stilted and anachronistic dialects intact.

The Godfather suffered from these same problems to a lesser extent, not only because its much earlier setting renders the use of Italian immigrant dialect and ’30s gangster slang slightly less archaic and unbelievable, but because there is actually some change in at least a few of the characters over the course of the book. Well, at least Michael Corleone has some interesting internal struggles and dilemmas going on… Which life to choose? The content family man, or the powerful Mafia boss? Is it any different than what Senators and Presidents do every day? Omerta has none of that depth. The characters of Omerta are straightforward and shallow, all motives and desires lying on the surface. The only interest and complexity is in the mechanics of how they try to get to them.

We have Nicole, old Don Aprile’s daughter, a young lawyer who devotes her time to the abolition of the death penalty and pro bono representation of the indigent, to her father’s bemused derision. Echoes of The Sopranos? I thought so, too. Sopranos creator David Chase (born David DeCesare) has repeatedly said he thinks The Godfather was amazing, etc., and The Sopranos is peppered with Godfather references. It seems he also checked out Puzo’s last work, Omerta.

There is the Argentine aristocrat-turned-drug-lord, now based in Colombia, who is trying to build his own personal nuclear weapon. The massively corrupt Peruvian consul, who will do anything for a price. Astorre, the protagonist, is the young scion of two old school Mafia dons, his biological and adoptive fathers; he is the last true Mafioso operating in the world. He is sent to Don Craxxi, an old retired Mafioso at hand to dispense sage advice and Italian-syntax aphorisms when needed. The two of them can summon a cadre of nameless henchmen who instantly appear from Sicily when needed, every one not only an expert in all manner of weapons and fighting but also unquestioningly loyal to and utterly ready to die for a man they haven’t seen in 20 years.

The verdict: Omerta is entertaining if you’re into the Mafia-fiction genre and you set your expectations appropriately. Don’t expect another Godfather and you’ll be fine.

Popularity: 6% [?]

So I wanted to write a cron job on my Mac. Just run this script every day at midnight. Nothing fancy.

In standard Unix, this is one line in a crontab:

0 0 * * * /some/script

That’s it. Put that in your crontab and /some/script will run every day at midnight.

Naturally, I typed man crontab on my Mac to get started. Apple likes to make weird minor modifications to standard Unix commands sometimes. I found:

(Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.)

More flexible, huh? I’m all about more flexible! Sounds good. Another well thought out Apple improvement, sweeping away 30+ years of Unix cruft at a stroke!

Not quite. Continue Reading »

Popularity: 19% [?]

The shared key (password) used to encrypt a WPA2 wireless connection to a DD-WRT router has a maximum length associated with it. If the key you enter is too long, it won’t work. (This may also be the case for other encryption protocols besides WPA2; I haven’t tried.)

Unfortunately, the web interface does not limit the WPA2 shared key text entry field to whatever its maximum length is, and no error message is produced if you try to use it with an overlong WPA2 password. The wireless connection simply does not work. Silent failure.

So if you’ve got a very long WPA2 shared key, everything else seems to be configured correctly, and you just can’t connect, try a shorter key.

Popularity: 19% [?]

The DD-WRT forum has some cargo cult tech support floating around on the topic of blank pages and the inability to update settings after a firmware upgrade. Many people are saying that you must use Internet Explorer to flash your router to DD-WRT, or else you will get a blank page (at apply.cgi) that does nothing when you try to apply settings, because it doesn’t like Firefox for some reason.

This is not true. The problem lies not in Firefox per se, but in the authentication mechanisms used to access the site. When you flash your router to DD-WRT, you will be prompted to change the username and password. Firefox (but apparently not IE) doesn’t like it when a site suddenly switches authentication regimes after having previously authenticated. (IE apparently handles the situation better. I don’t know the details since I have a Mac and I haven’t tried it with IE.)

The workaround is simple: in Firefox, just go to the Tools menu and click “Clear recent history…” Wipe out any active logins and cookies in the last hour (or however long it’s been since you started messing with DD-WRT), and it should work fine. (If you’re using the Web Developer plugin, you can do the same thing under “Miscellaneous -> Clear Private Data”.) Hit “refresh” on a page belonging to your DD-WRT router, and you should be prompted to log in again. After that, everything should work fine.

Popularity: 29% [?]