Creating DSLs with Ruby

For ages I wanted to understand how to build DSLs with Ruby. After some Googling, I came up with a bunch of links.

Fuck. This. Bailout.

No. Seriously, no. This is fucking ridiculous.

As an update, kos at DailyKos is right.

I am now certain that this is all a giveaway to the GOP’s friends on Wall Street and an effort to financially handcuff the next administration. It has little to do with saving the economy. Otherwise, Treasury and White House officials wouldn’t be talking about bribing and arm twisting these banks into taking government handouts.

This is extortion, plain and simple. Give us money, or the economy gets it. wtf?

naked capitalism is a great resource.

Sign the Sanders letter! This guy gets it! h/t to the awesome OpenLeft.

In his post The bailout and 2010, kos is absolutely right. I certainly won’t forgot who votes for this bill. It’ll be right next to the list of people that voted for the FISA compromise this Spring. (Senator Bill Nelson, I’m looking at you.)

Matt Stoller channels my progressive rage: Opening the Day: Why Democratic Candidates Aren’t Harder Edged

Yay Obama:

Mr. Obama, in a statement, said: “When taxpayers are asked to take such an extraordinary step because of the irresponsibility of a relative few, it is not a cause for celebration. But this step is necessary.”

No, bullshit. I call bullshit. The top 0.5% can shoulder the burden of their own bailout. To force 99.5% of Amercians to pay for the blunders of the top 0.5% is simply unconscionable. This is revolting. Apparently, no we can’t, eh?

Quicksbooks Pro 2006 on Windows Vista 64

While QBP 2006 is apparently unsupported by Intuit (surprise!), it is possible to install it on Windows Vista Home, 64-bit edition. I encountered two problems, with both solutions documented somewhere on a QB support site, but only viewable via the Google page cache. To ensure their availability, I am re-posting the steps here.

During the install, there will be a failure in registering a OCX file for shipping, ZRush_ShipRush3_QB.ocx. The error will be regarding 1904.module. I simply clicked “Ignore” and install finished successfully.

Next, I ran reboot.bat which is located in the Quickbooks 2006 directory under Program Files (x86)/Intuit. It will register various files.

Finally, I changed the EXE files for QBP to run in Windows 2000 SP2 compatibility mode and started Quickbooks. It should be possible to run Help -> Update QuickBooks…

When starting Quickbooks after, the update installer will run, but still explodes on ZRush_ShipRush3_QB.ocx. I simply clicked Ignore again. The update did succeed. The error recurs during each update.

Error 1904.Module
"C:\Program Files (x86)\Common Files\Intuit\QuickBooks\ZRush_ShipRush3_QB.ocx"
failed to register.

I never had all the updates actually apply, so it remains to be seen if the above actually works.

Update, November 12th. Thus far, it doesn’t seem to have worked. I haven’t had the interest in messing with it anymore of late.

IE7 backspace sucks

Seriously, who the fuck at Microsoft thought the backspace key should have the dual purposes of erasing the character immediately preceding the cursor and taking you back a page. If you arrive on a page that requires substantial form input and happens to be dynamically generated like, say, nearly every Web page with forms on all of the fucking Internets, hitting backspace outside of a form field completely fucks all your data entry.

Why the fucking fuck would you want that behavior? That’s broken by design. And there’s no way to turn it off, unless you’re the Web application owner, give a fuck, and hack it away with JavaScript. Fuck you, Microsoft. Bastards. (If it wasn’t a cluelessly designed IE-only Web application, I’d be using any other browser but IE.)

And fuck Web application developers that, in 2008, still think using JavaScript to auto-tab between fields for idiot users is a great idea. (Ties into my first point, fuck IE, because auto-tabbing will eventually tab you out to the submit button, which triggers the fucked up behavior if you thought you were backspacing to correct the prior field.)

rate limit gnump3d with Apache 2.2 and mod_bw

While you can reencode MP3s fairly trivially with gnump3d, no limiting is applied. Whatever you’ve reencoded will be delivered to the client as quickly as it can accept the packets being sent. If your objective is to limit the stream to the neighborhood of the reencoded MP3’s new bitrate, you will need some Apache reverse proxying magic.

First, you need mod_bw 0.7. Building is a simple process.

# /usr/bin/apxs2 -i -a -c mod_bw.c

If there’s a build fail, you may need to edit mod_bw.c accordingly:

-/* Compatibility for ARP < 1 */
-#if (APR_MAJOR_VERSION < 1)
-    #define apr_atomic_inc32 apr_atomic_inc
-    #define apr_atomic_dec32 apr_atomic_dec
-    #define apr_atomic_add32 apr_atomic_add
-    #define apr_atomic_cas32 apr_atomic_cas
-    #define apr_atomic_set32 apr_atomic_set
-#endif

On Debian GNU/Linux, activating the module is straightforward.

# a2enmod bw
# a2enmod proxy_html proxy_http rewrite

Finally, a new virtual host is created.

<VirtualHost *:80>

ServerName mp3.example.com

DocumentRoot /var/www

ErrorLog /var/log/apache2/mp3.example.com_error.log
LogLevel warn
CustomLog /var/log/apache2/mp3.example.com_access.log combined
ServerSignature On

So far, the usual stuff.

ProxyRequests Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>

We need to ensure we can reverse proxy. By default on Debian all requests are denied.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/mp3$
RewriteRule . /mp3/ [R=301,L]

Using mod_rewrite, the root URL is redirected to our proxy location.

BandWidthModule On
LargeFileLimit .mp3 250 16384

mod_bw is enabled and any file with an MP3 extension (not a MIME check) that is at least 250K is size is limited to 16KB/s, perfectly suitable for MP3s reencoded to 128Kbps.

ProxyPass /mp3/ http://10.10.1.1:8888/
<Location /mp3/>
ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap / /mp3/
</Location>

</VirtualHost>

Finally, the magic for the reverse proxy. All requests are proxied to our gnump3d server running on another system. The HTML sent back from GNUmp3d is filtered using the proxy-html filter to ensure all the links are rewritten. However, the m3u files will still be incorrect.

At least two options are available. The simplest way is to modify the existing gnump3d.conf so the m3u file uses the correct path, bouncing it through our reverse proxy.

use_client_host = 0
host_rewrite = mp3.edseek.com/mp3

The second option would be to filter m3u files and use an external tool, say, sed, to rewrite the URLs in the m3u file with Apache’s ext_filter module.

Race for the Galaxy near Orlando, FL

I finally managed to secure a copy of Race for the Galaxy (R4TG). Of course, outside of Cool Stuff Games on Wednesday, I have no one to play with. If anyone happens upon this post and wants to play, let me know.

Recession Squeezing Customer Options

The current economic climate in the U.S. is causing downsizing of customer options in leiu of price increases. Recently, Subway nuked the small drink size option. Panera no longer allows a half sandwich order. It’s a defacto price increase. Store hours are among the casualties, too.

CoolMax CN 350 NAS

I recently picked up the CoolMax CN-350 NAS for only $20 after a $30 mail-in rebate and a $10 Google Checkout signup bonus. So far I have been pleased with the device. It comes with the following noteworthy features.

* Fast Ethernet (100Mbps)
* USB2
* CIFS/SMB or FTP access (network)
* Attached storage (USB2)

If you are using the device over Ethernet, it will both offer an IP via DHCP and make DHCP lease requests. If a DHCP server answers, it will assume the assigned IP. So you can plug it into an isolated system and an IP will be offered to the attached computer.

The SMB performance is awful. The maximum sustained speed is around 4MB/s. If your primary usage mode is over Ethernet, buy something else. (You’re also limited to about 30GB since the vfat implementation is weak, in additional to the under powered microprocessor.) The USB performance — what the device was obviously intended for — is great, at around 20MB/s.

I ultimately received my rebate quickly. For the money I paid, it’s a nice device, if you can supply your own drive and don’t care about the awful Ethernet performance.

Okay, I am done with RadioShack forever

I wander into my local RadioShack for a simple RCA to S-Video adapter (or SVHS). After looking around, I ask the lady and she finds one for me. It looks unimpressive enough. I ponder a cable to plugin to it, since the original one being replaced was male to female and this was female to female. She starts to grab one of those expensive monster cable sets, but I waive her off.

I proceed to buy the adapter, at which point she rings it up… It was almost $25! No kidding. I said no thanks. Visibly annoyed, she canceled the order and I walked out, never to return.

Years ago I recall I ordered cables with success from CCT. Sure enough, they have what I need for about $1.77. Yes, more than $20 less than RadioShack. Same part.

RadioShack is a failure.

gnump3d and downsampling mp3s

Recently I discovered gnump3d. It supports downsampling, which is a feature I especially need. However, the example reencoding command for handling MP3s doesn’t seem to work. Instead, I am using a different variant.

downsample_medium_mp3 = \
  /usr/bin/sox -t mp3 $FILENAME -t wav - | /usr/bin/toolame  -b 128 - -

The original uses the lame encoder to both read the MP3 source file and then reencode it, but that seems to fail miserably. Fortunately, using sox seems to resolve it.

It’s useful to note that this will not throttle the client connection, so if your goal was to limit the stream to, say, 128Kbps, it won’t work. Instead, you need to rate limit some other way.