Monthly Archive for July, 2006

Nintendo DS Lite

From the impulse buy department, here’s a picture of my new Nintendo DS Lite:

New Super Mario Bros on Nintendo DS Lite

The designers of the New Super Mario Bros. found some cool ways to utilize the two screens. For instance, when Mario goes down a pipe, the game switches to the lower screen.


Update:

I got myself a copy of Tetris DS and discovered another cool feature: you can play online (via WiFi) without any monthly-fee baloney.

Tech Update:
The DS wouldn’t associate with my DIY Linux access point until I switched from WEP Open (insecure) to WEP Shared (even less secure). With MADWiFi, the required command is iwpriv ath0 authmode 2.

Variable Length Arrays

Last week, my buddy Kent sent some mail, lamenting the fact that this code didn’t work quite as well as the traditional countof macro:


template <typename T, unsigned N>
inline unsigned countof( T const (&)[N] ) { return N; }

int main()
{
        int a[10];
        int b[countof(a)]; // BOOM!
}

The heart of the matter lies in the fact that the standard does not allow this:


int array[foo()];

We simply can’t force compilers to stop and analyze foo — we can’t standardize the optimizer. Some might do better analysis and might prove more than others, leading to a portability nightmare. Furthermore, it’s not guaranteed that the foo’s definition will even be available at this point. We can’t require whole-program optimization (aka, LTCG).

It all made sense until Bheeshmar chimed in with the following shocker: “It works on GCC”. I was confused until I realized that GCC already supports C99-like variable length arrays.

Normal C arrays are terribly stupid. Their size must be known at compile time (yet they manage to completely forget this information after their point of definition). VLAs don’t have this restriction because they simply do an alloca-style stack allocation at runtime.

OK so VLA support enabled Kent’s code to build. But wait, Kent’s array has a compile-time constant size. What’s going on here?

With VLAs, we can define arrays without fear. The compiler thinks to himself, “No big deal, I can call alloca() later if I must.” Because of this safety net, compilation can proceed to the optimizer which may eventually prove that the array actually has a compile-time constant length. Eventually, a smart optimizer might turn the VLA back into a regular ‘ole static array, saving some stack manipulation.

Let me say that again in case you missed it: VLA support enables us to discover that we don’t need VLA support.

MPAA Accidentally Picks on Someone Own Size

The MPAA and RIAA have become infamous for their cowardly tactics — threatening children and grandmothers with statuatory maximum damages, but ultimately offering to settle for 2500 bucks. However, in a stunning display of incompetance Tuesday, the MPAA mistakenly sued someone who actually has the resources to go to trial.

I can’t wait to see them lose. I’m astonished that nobody has faught these allegations to date. In the age of dynamic IPs and wide-open wireless access points, I’m pretty sure a public defender could create reasonable doubt.

Update:
You can’t make this crap up… Turns out that Universal City Studios Productions LLLP, the entity suing Shawn Hogan, may not actually own the rights to the movie they accuse him of downloading. Hogan has filed a motion to dismiss. I hope his next act is some kind of counter-suit.

Linkage: Techdirt, RIAAvPeople

Update 2:
This is only incidentally related, but here’s a story about another lawsuit victim who successfully employed the “open wifi defense” I mentioned above.

New File Server

This evening I put together a badass RAID file server as a birthday present for my beautiful wife (yes she is watching me type this). Here’s the ingredients list:

iTunes with mt-daapd

The LSI card was simple to configure and has great Linux support. The drives are configured for RAID 5, which means one drive gets sacrificed to the parity gods (but the other 3 are all data, baby).

I also installed mt-daapd, for which this picture is worth a thousand words. As I type, Kassidy is in the office uploading music over Samba. Every few minutes another hundred songs pop into iTunes. Rock!

Anyway, check out the df -H:


Filesystem             Size   Used  Avail Use% Mounted on
/dev/hda1               39G   8.4G    29G  23% /
/dev/sda1              946G    15G   883G   2% /raid

If you squint it almost looks like a terabyte.

AMD Merges With ATI

Yep, the rumors have turned out to be true.

Logos for AMD and ATI

The new company will retain the AMD name and Hector Ruiz as CEO. Cool. Welcome to the company, ATI’ers! I can hardly wait to put our collective heads together and build some killer products. The possibilities are endless.

Menger Sponge

At work, Wendy and I have been talking about the Cantor set, and a related 3D doohicky called the Menger sponge. It’s easiest to describe a Menger sponge by showing the iterative process which creates one:

Menger Sponge

In the limit, a Menger sponge has infinite surface area, but zero volume. Neat!

Video of Cory Doctorow’s Microsoft DRM Talk

I just discovered the video of Cory Doctorow’s talk, DRM and MSFT: A Product No Customer Wants, over at ResearchChannel.org. Cory gave this lecture at Microsoft Research two years ago. Legend has it that the transcript has since become the most widely linked text file on the internet.

Folks on the Microsoft corporate network have had access to this since the day it was recorded, but the public was left out until now. Kudos to Microsoft for “declassifying” it.

Update:
The official link “requires” IE6 and Windows Media player. For the rest of us, here’s a direct link to the ASF stream.

Update #2:
I sent this to Cory and he’s posted it to BoingBoing.

Console Resize Utility for Windows

For you command-line junkies, I present size.exe. You can use it to resize a console window programmatically. Here’s an example:

  C:\scripts >type vimdiff.cmd
  @echo off
  size 60 120
  vim -d %*
  size 60 80

I wrote this in C++ using Boost. If you’re interested, the source is available here.

Update 4/8/2008:
Turns out that Windows actually does have built-in support for this, it’s just hidden in a dusty corner as usual. Good thing, too, because my program didn’t work worth a damn. Here’s the official method:

   mode 120,60

(Credit to Sahil Malik)

A Straight and Narrow %PATH%

Although Windows has supported fancy filenames nearly forever, I find that they can still cause problems. Of particular trouble on the x64 OS are PATH variables which contain “C:\Program Files (x86)”. The parenthesis can cause scripts to die with error messages like “\Microsoft was unexpected at this time.”

I found a cute hack on the newsgroups that helps deal with this. Below is a script which will sanitize a PATH variable, cleaning up all that troublesome stuff.


@echo off
setlocal enabledelayedexpansion
set FIXED=
FOR %%I IN ("%PATH:;=" "%") do (
    set FIXED=!FIXED!%%~fsI;
)
for %%D in (a) do (
    endlocal
    set PATH=%FIXED%
)

OpenDNS.ocm

OpenDNS is a free (as in beer) set of DNS servers that anyone can use. It comes with typo correction and some anti-phishing features. I just switched to these at home and did a quick ping www.google.ocm to see if it was working. It worked perfectly, correcting the suffix to “com”.

This should save me a lot of time, given my propensity for fat-fingering URIs.

If you are a bind user, just add this to your named.conf


forwarders {
   // OpenDNS
   208.67.222.222;
   208.67.220.220;
   // Lower priority servers here
};

(via Mark Jeftovic on the EasyDNS blog)




Creative Commons Attribution-NonCommercial 3.0 United States
Creative Commons Attribution-NonCommercial 3.0 United States