[Nearly] Silence your Butterfly Labs Little Single Bitcoin Miner

Last week my Butterfly Lab Little Single (SC) Bitcoin miner finally arrived. The good: it works as advertised and mines Bitcoins at about 30 GH/sec. Setup was a breeze on Windows 8; plug in the miner, install the WinUSB driver using Zadig, startup cgminer, and away it goes.

The bad: it runs with all the subtlety of a jet engine. This thing is far and away louder than the eight GPUs I used to have running full-bore minting Bitcoins. Something needed to be done.

I took it apart to see if any improvements could be made. Two problems stood out: the heatsink fan was pointing in the wrong direction, and there was no air intake fan. Rummaging in the closest revealed a pair of Corsair 120mm fans and a 3-pin power splitter, so I already had all the hardware I needed. Flipping the heatsink fan around, replacing the stock exhaust fan with a quieter model, and adding an intake fan took about 10 minutes. The noise coming out of the unit is easily half of what it was; using a cheap iPhone sound meter gave a reading of 60 dB (for comparison, the same meter read 55 dB for a pair of mining GPUs).

Not only is it quieter—it’s also running cooler. Prior to this mod, it ran at about 80° C. Post-mod, it bounces between 68°–70° C. I’ve noticed that when it gets down to 68º the fans spin down further, to the point where it’s nearly silent. When the temp creeps up to 70º the fans spin back up, but still nowhere near the loudness level of the stock cooling solution.

If you want to do this yourself, here’s what you’ll need:

The steps are simple:

  1. Remove the four Torx screws from one end of the unit.
  2. Slide off the casing.
  3. Disconnect the exhaust fan from the 3-pin connector (located in the middle of the unit’s mainboard).
  4. Remove the four Torx screws from the opposite end of the unit.
  5. Remove the two Philips screws from the heatsink fan.
  6. Turn the heatsink fan upside and screw it back onto the heatsink. This fan should be blowing air down onto the heatsink; BFL installed it so that it draws air up and away from the heatsink. (An easy way to test the direction a fan is blowing is to hold a piece of tissue paper over it while it’s running.)
  7. Install one of the 120mm fans as an exhaust fan next to the heatsink (replacing the fan BFL supplied). This should be blowing hot air out of the unit.
  8. Install the other 120mm fan as an intake fan on the other side of the unit (BFL didn’t include a fan here on my unit). This should be drawing cold air into the unit.
  9. Use the 3-pin Y-splitter to connect both fans to the single 3-pin fan connector on the mainboard.
  10. Slide the case back on and screw the end-caps back in place using the Torx screws.

Here’s a photo showing what it should look like (with the case removed). The blue arrows indicate the direction of airflow for each fan.

Improved airflow on the BFL Little Single.

Improved airflow on the BFL Little Single.

It’s not completely silent, but it’s quiet enough for me to run 24/7 now. Thanks to Butterfly Labs for providing excellent Bitcoin mining hardware; I just wish they’d had put a bit more thought into the unit’s airflow. Thankfully, that’s easy to fix on our own.

Cygwin and the Case of the Unreadable Blues

Cygwin includes some nice built-in aliases for colorizing terminal output, but the default blue hue is so dark as to be unreadable on the black background. It’s easy to fix, though; just add the following Blue and BoldBlue lines to your ~/.minttyrc file:


These lines will use a lighter shade of blue than the default, so you’ll be able to read it in a less-than-pitch-dark room. As an example, here’s my complete ~/.minttyrc file:


Safely sharing your Internet connection with the neighbors: Using DD-WRT to setup a Linksys WRT54G in repeater mode

How do you bring down the high cost of cable Internet access? Share it with your neighbors (for a price, obviously)! You can do this naively by telling your neighbors your wi-fi network name and password, but this introduces a few problems:

  1. Liability: Do your neighbors use file-sharing services like BitTorrent? Comcast monitors that sort of traffic and sends cease-and-desist e-mail to customers sharing [unencrypted] torrents.
  2. Coverage: Unless you live particularly close together, a single wi-fi access point will probably not be sufficient for everyone to have a strong wi-fi signal everywhere they use their computers, tablets, and smart phones.
  3. Performance: No one wants their Internet connection to slow to a crawl because their neighbor is using all of the available bandwidth to download the latest Game of Thrones episode.

For this guide, I’m assuming you already have a home wi-fi router and want to learn how setup a shared network with enhanced coverage and performance, while reducing liabilities. All without running extra cables around your house or apartment!

Equipment needed

  • A broadband Internet connection
  • A wi-fi router for your home or apartment (I’m using an Apple Airport, but any decent, modern router should work)
  • A Linksys WRT54GL wifi-router for your neighbors (you can find these online for less than $50)
  • DD-WRT firmware to unlock the full power of your Linksys router

 Network overview

Our basic idea is to create a private wi-fi network for yourself, and a public wi-fi network for your neighbors. This is why you’ll need two wi-fi routers. Plus, the public router allows you to position it where your neighbors will get the best signal strength, while you can still position your private router wherever it works best for you. The network you create will look something like this (solid lines represent Ethernet cables, dashed lines represent wi-fi connections):

Network topography: By introducing a second, public wifi router, you can keep your computers separated from your neighbors’ computers.

As this diagram shows, we’ll have an Ethernet cable running from your cable/DSL model to your private router, but that’s it! No other cables necessary!

Setting up your private network

I’ll assume you’ve already setup your private wi-fi router (just about all of them come well-configured out-of-the-box these days), but here are some recommendations for a fast, secure network:

  • Enable WPA2 encryption: this is much more secure than WEP encryption, and lets you use easy-to-remember passwords instead of arcane sequences of hex characters. DD-WRT (which we’ll be using to setup your public router) only works well with WPA2 encryption, so this isn’t just a good idea; it’s required if you want your private router and public router to communicate wirelessly.
  • Pick an unused wi-fi channel: the most common channels are 1, 6, and 11. You can use a tool like iStumbler (Mac) or Kismet (PC) to identify which channels are already being used by nearby wi-fi routers. If channel 1, 6, or 11 is available, use it. If there are already a lot of other people using those channels, choose 3 or 9 to reduce wi-fi interference as much as possible.

Setting up the public network

Once you have your private wi-fi working properly, it’s time to setup your new Linksys WRT54GL to share your connection with the neighbors. We’ll also install DD-WRT firmware on it, which allows this old router to learn new tricks and perform significantly faster than it does out-of-the-box.

What’s firmware? Firmware is the software that controls your router. By upgrading from the Linksys firmware to DD-WRT, you are essentially installing software that can do more things (and do them faster!) than the Linksys software.

  1. Download the following files, and save a copy of this guide to your computer. You’ll be disconnected from the Internet while you initially configure your router:

    It may also be worthwhile to check this forum thread for newer recommended builds, but I know the r14929 has worked extremely reliably for me. Additional information about installing DD-WRT on the WRT54GL can be found here.

  2. Do a hard reset of your Linksys WRT54GL router. A hard reset involves four steps:
    1. With the router powered on, press and hold the power button for 30 seconds (I usually use a pen to press this button)
    2. Unplug the router from the power outlet while continuing to press the power button for an additional 30 seconds.
    3. Plug the router back into the power outlet while continuing to press the power button for an additional 30 seconds.
    4. Release the power button to let the router turn itself back on.

    So, you’ll be pressing and holding the power button for a total of 90 seconds. I can’t stress how important this step is—I skipped it the first time I setup my WRT54GL, and while everything looked fine, nothing actually worked properly.

  3. Connect your computer to the WRT54GL using an Ethernet cable plugged into the jack labeled 1 on the back of the router and turn off wi-fi on your computer.
  4. Open up a web browser and type into the address bar, then hit the return key. You should be asked for a username and password. Leave the username blank, and type in admin as the password (this is the default way to login to Linksys WRT54 routers).
  5. Upgrade your WRT54GL with the micro DD-WRT firmware you downloaded earlier. We need to start with the micro firmware because of a bug in the Linksys firmware—some routers will stop working entirely if you try to install the standard DD-WRT firmware first. Linksys provides step-by-step instructions for installing new firmware.
  6. Wait about 5 minutes for the upgrade process to complete and the router to restart. Do not unplug the router during this time.
  7. Once the router has restarted, visit again to confirm that everything is online. Then perform another hard reset (step 2 above).
  8. Once the router has restarted again, visit in your web browser. Click on the Administration tab at the top of the page. You should be asked to log in; the default username is root, and the default password is admin.
  9. Click the Firmware Upgrade tab (beneath the Administration tab). Click on the Browse… button and select the standard firmware file you downloaded earlier, then click Upgrade.
  10. As with step 6, wait about 5 minutes for the upgrade process to complete.Do not unplug the router during this time.
  11. Once the router has restarted, visit to confirm that everything is online, and then perform another hard reset (step 2 above). Yes, that’s three hard resets, and yes, they’re all necessary. I tried to skip these steps and found that none of my settings were saved by the router; each time it restarted it would revert to the default settings. Learn from my mistake!
  12. Now for the fun stuff! Visit in your web browser and click on the Setup tab. If prompted to login, the username is root and the password is admin. (Feel free to change these at any time from the Administrationtab.) Most of the settings can be safely left at their default values, while others will depend on your personal network configuration. The sections below  describe the necessary changes to get your public wi-fi network running, plus some recommended (but optional) settings that I find work well. Each step refers to settings on a specific tab and sub-tab of the router’s configuration webpage (

    Always click the ‘Save’ button before moving on to the next tab!

    1. Setup→Basic Setup
      • Local IP Address (optional): My private router uses the IP address, so I set this field to to easily tell them apart. If you make this change, you’ll need to connect to instead of for the rest of this guide.
      • Static DNS 1 (optional): Set this to Google’s public DNS server,
      • Static DNS 2 (optional): Set this to Google’s backup DNS server,
      • NTP Client (optional): Enable this and set the time zone appropriately.
      • Server IP/Name (optional): If you enable NTP, then set this to 0.us.pool.ntp.org.
    2. Wireless→Basic Settings
      • Wireless Mode: Repeater.
      • Wireless Network Name: Set this to your private network name. For example, before I added the public wi-fi router, I had one wi-fi network named Prydain, which is what I entered here.
      • Wireless Channel: Set this to your private network channel. You may need to log in to your private wi-fi router to determine (or set) the channel it uses. I would set it to 1, 6, or 11, and not the auto mode most routers default to.
      • Network Configuration: Bridged.
      • Now click the Add button. A set of fields will appear for your new virtual interface (this will be the public wi-fi network). Configure them as follows:
      • Wireless Network Name: Set this to your public network name. For example, I named my public network A Series of Tubes, which is what I entered here. Almost anything will do.
      • Wireless SSID Broadcast: Enable so your neighbors can easily find your wi-fi.
      • Wireless Channel: Set this to your private network channel, same as above.
      • AP Isolation: Disable so if your neighbors have multiple computers, they’ll be able to share files with one another via wi-fi.
      • Network Configuration: Bridged.
    3. Wireless→Wireless Security
      • Security Mode: WPA2 Personal (If you haven’t already done so, your private router also needs to be configured for WPA2 Personal security with AES encryption. Most modern routers (as of 2012) default to this security type, but it’s a good idea to verify it.)
      • WPA Algorithms: AES.
      • WPA Shared Key: Enter your private wi-fi password (i.e., the password you normally use to connect your computer to your wi-fi network).
      • Under the Virtual Interfaces section, use the exact same settings as above, except for the WPA Shared Key. Make this different, so that your neighbors will use a separate password than you use. The virtual interface’s Wireless Network Name is the wi-fi name you’ll tell them to connect to, and its WPA Shared Key is the password they’ll need to successfully connect.
    4. Wireless→Advanced Settings
      • Frame Burst (optional): Disable
      • TX Power (optional): I experimented with higher values, and found 110 to result in a strong signal for my neighbors without causing interference. I wouldn’t set this any higher than 150; return it to the default of 71 if you experience problems.
      • WMM Support (optional): Disable to conserve memory.
    5. Services→Services
      • DNSMasq (optional): Enable (These settings enable local DNS caching with a memory limit)
      • Local DNS (optional): Enable
      • Additional DNSMasq Options (optional): cache-size=100
    6. Security→Firewall
      • SPI Firewall (optional): Disabled (The firewall isn’t needed inside of the network, and interferes with bridging mode)
    7. Access Restrictions→WAN Access
      • Catch all P2P Protocols (optional): Enable this setting to block all unencrypted peer-to-peer traffic for your neighbors.
    8. NAT / QoS→QoS
      There are a lot of options on this page for controlling Quality of Service (QoS), which essentially means setting speed limits on certain Internet activities. If you set Start QoS to Enabled, you’ll have the option of setting a bandwidth limit on your neighbors’ Internet speed, or use the Services Priority section to only limit certain types of activities (like BitTorrent downloads) by setting their priority to bulk.
  13. Restart the router by unplugging the power cable for a few seconds, and then plug it back in. Enjoy your new, secure shared network!

Hash strings to integers in PHP with the DJB hashing algorithm

I recently found myself needing a PHP implementation of the DJB hashing algorithm, but ran into a problem—in 64-bit PHP5, integers don’t overflow. Instead, they magically turn into floating point variables large enough to hold the new value. For short strings this isn’t really a problem (the hashing algorithm won’t cause an integer overflow in the first place), but for anything over five or six characters, you end up with numbers that aren’t comparable with other implementations of the algorithm (nor, for that matter, will they fit into any of MySQL’s numeric data types).

So, here’s a short function that uses PHP’s GNU Multiple Precision (GMP) module to perform the arithmetic at the necessary level of precision, then convert the result back to a standard PHP int:

define('PHP_INT_MIN', ~PHP_INT_MAX);

function hash_djb2($str){
	$hash = 5381;
	$length = strlen($str);

	for($i = 0; $i < $length; $i++) {
		$hash = gmp_add(gmp_mul($hash, 33), ord($str[$i]));
		while (gmp_cmp($hash, PHP_INT_MAX) > 0) {
			$diff =	gmp_sub($hash, PHP_INT_MAX);
			$hash =	gmp_add($diff, PHP_INT_MIN);
			$hash =	gmp_sub($hash, 1); // off by 1
	return gmp_intval($hash);

I’ve only tested this on 64-bit PHP5 on Linux. PHP seems to handle integers a little differently across different platforms, so your mileage may vary. Enjoy!

iCloud and Outlook: Installation Order Matters!

Nice work, nVidia. Today marks the third time in three years I’ve had to send my Mac back to Apple to replace one of your faulty GPUs. What the hell happened?

I spent the morning setting up an old Windows box so I can at least keep up on e-mail while my Mac gets a less-broken logic board. Figured this would be a good chance to checkout iCloud on Windows, so I downloaded it, installed it, and then installed Outlook 2010. Went into the iCloud control panel, told it to synchronize my Outlook Contacts, and… no. Got this useful error instead:

Error: 0x8004010F: ZebraMapiCopySession::CreateMobileMeMessageStore: CreateMessageService failed

What the hell does that mean? Turns out, it means that you shouldn’t install Outlook after iCloud; you need to install Microsoft Office first. Uninstalling and then re-installing iCloud fixed the problem. Now I’ve got my calendar, contacts, and e-mail all showing up nicely in Outlook. Which would be awesome, except—it’s still Outlook.

And Apple? Your error messages could use some work…

Apple TV and iTunes Match

My 3rd generation Apple TV (with iOS 5) has some problems streaming media. First noticed it with NetFlix; the stream would pause for about 30 seconds every couple of minutes. iTunes Match had a different problem; after playing about 10 minutes of music, the screen would go blank (my TV started searching for different inputs, so I think the Apple TV’s output signal completely died), then return to the Apple TV home screen. I haven’t had any problems using NetFlix or iTunes Match on my computer, so I assumed the wifi (an Airport Extreme) and Internet connection weren’t to blame.

Finally seem to have tracked down the problem (or at least, one of them): it’s something in the Dolby Digital output. Go into Settings/Audio & Video/Dolby Digital and change the value to Off. I have my Apple TV hooked up to a receiver via an optical cable, so I’d turned this setting on to get surround sound. Since disabling, I’ve been able to listen to entire albums on iTunes Match for the first time—they had never made it past the 10 minute mark before. Here’s hoping a software update will fix this issue and restore the surround sound feature…

Update: Spoke too soon—just dropped the audio stream again, though it’s definitely not happening as consistently as before. *sigh*.

Wellgates Scholar Scam

Phishing scams don’t generally deserve write-ups, but the Wellgates Scholar Program is a new scam that avoids a lot of the common red flags. Since Google doesn’t turn up much about it yet, figured I’d contribute a warning.

The e-mail for this scam claims that one of your peers nominated you; if you checkout their website, you get an incredibly generic page with an application form. They’re not (obviously) trying to collect money, but they are asking for personal information, likely so they can sell it to other scammers. My “invitation” was sent to my university e-mail account, which is publicly available and easy to spam using brute-force techniques (the common <last name><first initial>@<university name>.edu format). The message specifically asks for the names and e-mail addresses of three of my peers, so they’re clearly trying to make this thing go viral.

Why is this so plainly a scam? Checkout what’s missing from their webpage:

  • List of previous winners and their accomplishments
  • List of industry/academic sponsors
  • Board of Trustees (or the names of anyone in charge)
Real scholarships don’t omit these details, but the site looks clean and is generally free of the grammatical mistakes we often use to red-flag scam attempts.
Most damningly, however, the link from the e-mail includes a unique identifier, allowing them to know which addressees they’ve spammed are active. You usually can’t see this without hovering over the link or copying/pasting it to your browser, but it’s there. Don’t fall for it.

iOS 5.1 disabled iMessage

Not sure if anyone else has had this problem, but it looks like yesterday’s iOS 5.1 update turned off iMessage support, at least on my AT&T iPhone 4. A quick trip to Settings→Messages→iMessage was all that it took to get iMessages working again (they had somehow been turned off during the update).

Anyway, just posting in case someone else is trying to figure out why their iPhone suddenly stopped receiving iMessages.

New look!

Finally gave this old site something of a make-over. Most of my energy these days goes into research, art, and music, so I’ve made space for those topics and removed all of the old, long-unloved software projects. They were mostly just gathering bit-dust here, anyway—the successful ones found new homes years ago.

So, if you came here looking for something specific but keep hitting 404′s trying to find it, drop me a line. I’ll point you in the right direction.

Yet Another WordPress Flash Uploader Problem (with solution!)

This was a new one for me. Every time I tried to upload a photo to a WordPress site, I received a very informative “HTTP Error” message while the upload progress bar read “Crunching…”. Thanks in part to the stunningly generic error message, it took a while to figure out exactly what was going on.  The problem, it turns out, was HTTP authentication; I had enabled Apache’s basic HTTP login for the site, but being a plugin, Adobe Flash was not similarly authenticated.  So, trying to use the Flash-based image uploader kept silently failing because it couldn’t authenticate with the server.  The fix is simple: just tell Apache not to use authentication for the script that handles Flash-based uploads.  You can do this by modifying the .htaccess file in the root of your WordPress directory like so:

<FilesMatch "(async-upload.php)$">
    Satisfy Any
    Order allow,deny
    Allow from all
    Deny from none