Archive for the ‘Linux Stuff’ Category

We’re a Squeezebox household now.

Tuesday, June 19th, 2007

When we turned off the PC that we used to use for watching TV, it also took away our ability to play music in the livingroom (since the HD TiVo that we have doesn’t support HME or HMO). So, we decided to break down and buy a couple more Squeezeboxes for the rest of the house. We got systems for the livingroom, upstairs, and the nursery.

I was a bit hesitant about the new Squeezebox v3 form factor, but when the units arrived, my opinion was totally changed. First, they’re a lot smaller than they look on the website. All the low-angle photography makes them look a lot bigger than they are. Small is good.

Second, they have much nicer displays than the Squeezebox v2 that we have in the kitchen. (We now have a total of 4). The display is larger in size as well as larger in pixels. It also supports multiple levels of brightness (per pixel) which means that the big fonts are nicely antialiased. It also means that there’s a cool mode that shows a dim spectrogram underneath the normal “Now Playing” track info display. Its really slick.

I’m going to be using the upstairs unit as an alarm clock, since the server software can turn the units on at a specified time and play any playlist. The cool thing about that is that because of the NPR podcasts, I can wake up to CarTalk on Monday, This American Life on Tuesday, etc. It’ll be great!

A real double metaphone implementation in C++

Sunday, May 20th, 2007

I’ve been doing some work on a baby name explorer web app, and I needed a good C++ implementation of the double metaphone algorithm. There are several C and C++ implementations mentioned on the web site, but most of them are chock full of usage-specific junk, like Perl strings, Microsoft Visual Studio cruft, etc. So, I took the C implementation from the Perl module, removed all the perl string code, and replaced in with STL strings.

It works great, and I’m on my way to a proper baby name explorer web app. Here’s the derivative C++ double-metaphone implementation.

ampache is a great replacement for Netjuke!

Friday, March 9th, 2007

After the troubles with Netjuke after my upgrade to FC6, I decided to start looking around for a replacement for it. In my searching, I came across ampache, which offers basically everything Netjuke did, and more. Here’s a short version of all the great things:

  • A ’search’ that searches everything (artists, albums, tracks) all at the same time
  • Automatic import of album art from amazon, painlessly.
  • The notion of a “Catalog” thats a collection of music.
  • Automatic support for remote Catalogs, with API keys and security! Hey guys, if you read this, and install Ampache, I’d be happy to share my music collection — drop me a line. You know who you are. :) Oh, and if you want an account to try it out, drop me an e-mail and I’ll set one up for you.
  • Builtin support for per-track ratings, and suggestions via last.fm. Awesome
  • The UI is quite fast.
  • Builtin support for downsampling.
  • Cool community features, like the ability to see the last N tracks played (by everyone) as well as what each user is listening to right now.

The only downside is that I had to increase my PHP memory limit to import my music collection, but once I figured that out, it imported all my music, and works great. Rescanning for new music is painless and reasonably fast, as well. All it needs now is a color theme that isn’t so bland, and a better logo…

Patch for Netjuke & Fedora Core 6 & PHP 5.1

Friday, March 9th, 2007

After upgrading to FC6, which includes PHP 5.1, when I clicked on the “play” icons in the Netjuke UI, the playlist would show in the browser instead of starting playback. The problem seemed to be that Netjuke was now returning “text/html” for the mime type of the generated .m3u, instead of whatever it used to be. The problem boiled down to some simple code in play.php. To fix the problem, change the following line:

header (”Content-type: audio/x-mpegurl\r\nContent-Disposition: inline; filename=netjuke-”.substr(time(),-7).”.m3u” );

to

header (”Content-type: audio/x-mpegurl”);
header (”Content-Disposition: inline; filename=netjuke-”.substr(time(),-7).”.m3u” );

I’m not sure why they originally wrote it that way — its a really silly way to set 2 headers at the same time. Too bad Netjuke isn’t maintained anymore… :(

P.S. Jinzora still blows.

Burning CDs on linux with cdrecord

Sunday, March 4th, 2007

I don’t know why, but I find the program “cdrecord” the most problematic of almost all Linux commands. It never works right, always fails with mysterious messages, and even in the “best case” prints out cryptic things like “Warning: using inofficial libscg transport code version (schily - Red Hat-scsi-linux-sg.c-1.83-RH ‘@(#)scsi-linux-sg.c 1.83 04/05/20 Copyright 1997 J. Schilling’).”. Yuk!

Thankfully, I don’t need to burn CDs or DVDs often (only when I upgrade to a newer version of Linux) and since the Fedora Project just discontinued support for Fedora Core 4, that time has come!

Here’s a command that works for me on by sort of old Pioneer DVR-106D. I could try “speed=16″ (the rating of the drive) and see what happens.

cdrecord -tao -v speed=2 dev=ATA:0,0,0 /home/shared/linux/Zod-binary-x86_64/FC-6-x86_64-disc1.iso

Mostly, I’m writing this down for my own memory, so that I can search around the next time I have to do this…

NOTE: Well, the command succeeded, but the disc that was burned was bogus (it got i/o errors). I hate cdrecord. It sucks. I wonder if my drive is busted? Sometimes it gets stuck in “performing OPC” and never returns, hanging my IDE bus, and thus, hanging my entire computer, and then when I have to restart, my RAID setup goes into rebuild mode, and takes hours to recover. Yuk!

Switched to GMail.

Monday, February 12th, 2007

Well, I’ve finally become a convert. After using GMail for a while at work, I’ve become addicted enough to want to use it on my personal accounts. I looked into Google Apps For Your Domain, created an account, but decided not to go that way. Here’s how I saw things:

  • Good: It totally takes over your e-mail.
  • Bad: You have to change your MX record — no way to keep a copy of the e-mails yourself.
  • Good: Its easy to use, and branded to “my domain” (like that really matters)
  • ???: Can I unify my old GMail account with my Google Apps account? How?

Anyway, since I was really intent on keeping a copy of all my e-mail on my own server, I decided that I shouldn’t use Google Apps, and that I should just have postfix send an extra copy to my exsiting gmail account. That way, I get to keep the originals, as well as have the nice web interface that I’ve become addicted to. Its seeming to work out really well so far, and I’ve set it up to set the “reply-to” as my old account name, so unless people are really paying a lot of attention, they shouldn’t even be able to tell I’m using gmail.

Hooray!

(I’ll post here if there are any other problems in the future…)

strchr() Considered Harmful

Tuesday, January 30th, 2007

You tell me whats wrong with the following, which is the standard definition of the strchr() function:

char *strchr(const char *s, int c);

Give up? Well, think about this code:

void FunctionThatDoesntExpectItsArgumentsToChange(const char *input_string) {
char *unconst = strchr(input_string, input_string[0]);
strcpy(unconst,”You’ve been pwned”);
}

Do you know what just happened there? The compiler let me write on top of a const string, without ever having a cast from const to non-const! Take a look at all the string functions that have this hideous syntax:

strchr, strrchr, strchrnul, strpbrk, strstr.

I mean, what a huge list of suspects! This has got to be one of the biggest holes I’ve ever seen. What a mess. I’ve lost all faith in the designers of the standard C library. What a bunch of bozos.

Spamassassin 3.1 on Fedora Core 4

Monday, January 15th, 2007

Well, I finally bit the bullet.

Spam has been flooding into my mailbox recently, and Spamassasin 3.0 just wasn’t cutting it. I had hesitated to install Spamassassin 3.1 because there was no “official” Fedora Core 4 RPM around. I had 3 options: Upgrading my whole machine to FC6, installing Spamassassin from source, or getting it through CPAN. I wasn’t sure what to do.

It turns out that installing from source is totally the way to go. Spamassassin provides a tarball and easy instructions on building your own rpm straight from the source. So, I download the source pack, and ran rpmbuild, per their instructions. The RPM was quickly built, and I ran “rpm –upgrade” on them.

Everything went amazingly smoothly, and my spam today has been greatly reduced. Messages that used to get less than a 5.0 and miss my filter are now scoring in the mid-30’s. The biggest rule improvements are the URL blackhole lists, which account for the majority of the big boosts in score.

Thanks, Spamassassin!

Venus T4U USB Enclosure & Linux

Monday, January 15th, 2007

Well, after returning the Netgear SC101 piece of junk, I decided to pick up my second choice, which was a “Venus T4U” USB 2.0 enclosure by AMS Electronics. The cool part about this thing is that it holds 4 drives, a power supply, and a simple USB chipset thats smart enough to unify all the drives into one single volume.

So, for the price of the T4U, I’ve not got 4 old drives all joined together into a single backup volume.

The advantage: It was about half the cost of getting a drive of that capacity new.
The disadvantage: I’m now reliant on the T4U for its JBOD capability — if there’s a hardware failure in the unit, I’m pretty much screwed. I’m not too worried about this, since the T4U is my backup drive, and I leave it powered off most of the time.

Steve

Why does everybody always do things the hard way?

Thursday, January 11th, 2007

Problem: You’ve got a 250G drive sitting around, and you want to use it. You’ve already got 1 USB drive attached and adding another seems like a pain in the butt.

Solution: You go to Fry’s and see an empty SAN shell made by Netgear. You think: “Netgear is a good company, and even though it doesn’t say that its Linux supported on the box, nothing ever does, and its got to just be a Windows Samba share, right?”

WRONG! The Netgear SC101 runs a proprietary filesystem (Zetera), and uses a proprietary networking interface. Custom drivers are needed for any platform that wants to access the data.

Result: You have to go back to Fry’s to return the piece of crap that you bought. Thankfully, you were smart enough to research the situation before opening it, so the return will be an easy one.