Find the directories containing the most files

I needed to find the directories containing the most files, so I whipped up this bit of voodoo at the command line:

find . -type f -print | perl -na -F/ -e 'while (pop @F && @F) { print join ("/", @F)."n"; }' | sort | uniq -c | sort -n

This will count the number of files in each directory beneath your current directory, and print out those directories in ascending order by the number of files they contain. It will also print totals for parent directories–if “foo/bar” has one file, “foo/baz” has two, and “foo/” itself has one, then the line for “foo” will be printed with the number four.

Handy for me, possibly handy for you as well. This works in Linux and Mac OS X Leopard.

Add a dashboard jack for your car stereo’s rear aux input

When I bought my car, one of the first things I did was buy a fancy new Alpine head unit to replace the factory stereo. This gave me the ability to add an XM tuner and an iPod adapter. I ran the iPod cable into the glove compartment, so I could just connect the iPod in there and close the glove box when I hopped in the car.

This was pretty sweet. Between XM (BPM and The System mostly, since you asked) and my iPod, I never had to suffer through a commercial in the car again.

Then I, upon receiving instructions from Steve, went out and bought an iPhone.

That's now the iPod that I use most of the time. Strictly speaking, though, the glove compartment isn't the most useful place for one's phone (though it could be in the top 10). And, to boot, when I attached the iPod cable from the stereo to the iPhone, the screen cleared and just said “accessory attached”. Not terribly useful.

So, I decided I'd add an aux input to the radio, and hook it up to the iPhone's headphone jack. That part was easy; since I had an Alpine head unit, all I had to do was buy a $20 cable and attach it to the existing “AI-Net” bus. This gave me a pair of RCA-style connectors behind my radio.

Well, that project was far too straightforward and had little to no chance of inflicting significant damage rendering my vehicle undriveable, grotesque, or en fuego. I decided what I really needed was a jack on my dashboard so I could plug the iPhone in there, and wouldn't have an ugly cable crawling out from some dusty crevice in my dash. That would give the project the professional look that I want deserve pine for.


If you want to follow along, here is the stuff you'll need:

  1. A soldering iron (with solder, nimrod)
  2. A headphone extension cable (or any other stereo audio cable with a 1/8″ plug and a female connector on one end) such as this one
  3. A 1/8″ 3-conductor (stereo) jack, such as Radio Shack part 274-249
  4. A 1/8″ 3-conductor (stereo) to dual RCA cable, such as this one

The Plan

So, here's what we'll do:

  • Mount the jack in a convenient location in the dash area of the car.
  • Cut the extension cable and solder the female end to the connectors on the back of the jack.
  • Use the 1/8″ to dual RCA cable as-is, connected to the RCA female inputs on the head unit.
  • Then, connect the male 1/8″ plug from that cable to the female 1/8″ connector attached to the jack, and we'll be done!

When we're all finished, we'll be able to pump our awesome tunes through our car stereo, and look like smooth and sophisticated as we do it. 'Cause that's just the way we roll.

Note: I'll show you pictures of how things looked around my radio, but you'll be on your own to find a good, convenient spot to mount the jack. I highly recommend using a Crutchfield Mastersheet for your vehicle if you're not familiar with accessing the area behind your radio. I don't know that you can buy the Mastersheet by itself, so you might have to buy something else to get it. It won't be hard to find something you want.

Another note: Be careful. There are wires behind your dash, and some of them carry scary, impish little beasties called electrons that would love nothing better than to zap you and ruin your day. Don't give them the satisfaction.

Step 1: Rip stuff apart

First, I opened the dash according to the Mastersheet instructions to expose the aux input jack that I had attached to my head unit.

Aux input jacks; do not taunt

Step 2: Burn yourself with the soldering iron

Next, I went to my workbench to build the jack that I would install later.
Out of the box, the jack has three connections on the back–one each for left, right, and ground. On the back of the box, there's a helpful diagram that shows how the connections match up to the conductors on the inside. This diagram is not terribly helpful. Based on that diagram and some independent research, I've labeled the jack a little more clearly so you can see the purpose of each of the conductors in our project.

Connection diagram for the audio jack

Take your extension cable, and cut it a few inches behind the female connector. Inside it, there should be three wires, which will eventually match up with the three solder points on the jack. Usually there will be a red wire for the right audio channel, a black wire for the left audio channel, and a bare wire for the ground. You'll need to strip the outer covering of the wire for some length (maybe about an inch and a half) to expose the inner wires, then strip off about a half-inch from the shielding on the inner wires.

The end of the split cable

So, ok, it's time to solder. This involves a power tool, so you should feel good about yourself as you do it.

If you need an intro to soldering, you can find those on the web pretty easily. The only thing I'll say about the topic is that, if you need to buy a soldering iron, you should get one that uses butane fuel, like this one:

Butane soldering iron; totally 1337

In my opinion, these are better because you're not tethered to an electrical outlet, and they heat up faster than the cheap electrical soldering irons that I've used before. You can buy the butane fuel in the tools area of a hardware store for a few bucks. Plus, it's powered by FIRE! And fire is cool.

Anyhoo, attach the wires to the appropriate conductors and apply the solder. Once you're done, you should have something that looks like this, but maybe a little better since I just kinda learned how to solder on my own:

Wires soldered to conductors on the jack

After the solder cools, you should wrap a bit of electrical tape around the left and right conductors to make sure you don't get a short. If you had more foresight than me, or if you're reading this before actually doing it (ha!), you could also thread some heat shrink onto the wire before you solder, and then just move it into place and heat it up. But I didn't think of that at the time, so bah.

After you tape it up, it will look like this:

All taped up

At this point, you have done all of the electrical work. This would be a good time to test it out. If you have headphones and a 1/8″ stereo patch cable, you can attach one to each end of the device you've assembled (one to the end of the cord, and one to the jack), and then the extra male connector to some audio device, like your iPod, or a can of tuna. If you hear music through the headphones, that's a Good ThingTM. If not, then check your soldering to see if you have a loose connection.

Even if works just fine, bend the wire gently (not hard!) to see if it affects the sound. If it does, then you should check your connections and resolder. If not, then you totally rock.

Step 3: Mounting the jack

The next part is going to be highly specific to the vehicle you're installing the jack in, so I can't do much more than provide a case study of what I found. You need to find a spot in your dashboard, preferably on a piece that you can temporarily remove, that is thin enough and has enough room behind it to accommodate the back of the jack.

In my case, there was a spot right next to the radio that suited my needs just fine. The area surrounding my head unit is actually removable, so it was easy to take it over to my workbench. I originally was going to use a spot lower on the console near the gear shift, but ultimately decided against it since it was not removable, and thus much harder to access.

A couple other things to consider in selecting a spot: Give some consideration to how you'll run the wire from the aux input on the back of the radio to the installed jack. You'll make your life easier if you minimize the amount of cable fishing you have to do. Also, remember that you'll be plugging a wire into the front of this jack and running it to your portable device. I chose to put the jack on the right hand side of the radio instead of the left so the wire wouldn't obscure my view of the radio's display.

Next comes the big scary part: drilling the hole.

I started by removing the metal mounting collar from the jack (very important!), and choosing a bit that was obviously slightly smaller than the part that pushes through the hole. After taking a few nips of brandy, I drilled that small hole all the way through. I then repeatedly increased the size of the bit in 1/64″ increments and redrilled, until the jack would push through. I'm not going to lie to you, this was nerve-racking. It was difficult to get past the “ZOMG I'M DRILLING A HOLE IN MY CAR ZOMG” feeling, but I did it, and that means you can, too.

In my particular case, when the hole was large enough for the jack to fit through, I found that the plastic was slightly too thick so the threads on the front weren't quite exposed enough. The mounting ring couldn't grip them! To save the day, I broke out a Dremel with a grinder attachment and slightly deepened the hole on the back of the panel so the jack would poke though a little farther in the front, allowing the mounting ring to grip the threads. I also had to grind a little bit of the trim so the square backing of the jack would fit properly, but I was careful to only grind the inside edge so it wouldn't show once it was installed.

Grinding down parts of your car. Not scary at all.

Once I was done grinding, though, it fit just fine, and as you can see, the jack fit nice and flush against the back.

Aw, yeah.

The threads poked through in front, and the mounting ring grabbed them to hold the jack tight:

View from the front

Once the grinding was done, it looked like this:


Step 4: Hook it up

I just had to connect the wires and reinstall the panel in the vehicle to be all done.

It was a simple matter to attach the 1/8″ to dual-RCA cable to the female 1/8″ plug that I had just installed:

RCA cable attached

From there, I took the whole assembly back to the car, and connected the RCA cables as appropriate:

Everything connected

If you're following along at home, it's a good idea to test your setup at this point before your car is all put back together, so you don't have to take everything BACK apart if you have problems. If you connect your audio source to the jack with a patch cable and turn on your radio, it should work! If it doesn't, check your connections and go backwards, a step at a time, until you find the problem.

In my case, things worked just fine, so I put my car back together and admired my expert craftsmanship.

…and there was much rejoicing

Step 5: Drink heavily

And you're done! Now, when you've ripped your favorite music to your iPhone and you're jonesing bad in the car, you have a solution that doesn't compromise your style. And, it's pretty awesome to be able to put that patch cable away when you don't need it.

If you decide to do this project yourself, let me know how it goes in the comments!

PS: If you decide to buy something from Crutchfield as a result of this post, and you're a new customer, hook a brotha' up and give them referral code “p51zi-fiv3b-gx3yu”; you and I will each get a $20 credit. That's cool.

Technorati Tags:
, , , , ,

Using the iPhone for Presence Detection with MisterHouse… almost

I've got a reasonably interesting setup of MisterHouse (a nifty Perl-based home automation program) running on a Linux machine upstairs, that does stuff like turn on lights automatically when it's getting dark or when I enter a room, turn lights off when there hasn't been any activity in a room after a predefined time, and so forth. Maybe I'll post more on that later.

One thing that's missing, though, is a good way for the server to know if I'm home. As I mentioned, there are some lights that come on automatically when it gets dark, but some of that is really kind of a waste of energy if I'm not actually home. (Of course, some lighting would be good so our dogs can get around, but I think they'd be fine with a smidge fewer lumens than we expect.)

One suggestion that I've seen is to install a battery powered motion sensor (like this one somewhere inconspicuous in your car. This broadcasts on the X10 wireless spectrum, and would likely be within range if your car is at home. It broadcasts “motion” and “still” (i.e. “no motion”) signals, as well as “light” and “dark”, so it will send signals even if it doesn't see movement. Then, presumably, you can configure MisterHouse so that, if it notices these wireless signals, it assumes that you are home.

However, this solution has a couple of unpleasant attributes:

  1. It requires you to stick a motion sensor in your car
  2. Motion sensors are ugly
  3. It's not going to transmit continuously enough for your home automation system to know you're “still” there
  4. There's no way you'd be able to pick up chicks in your ride if they see ugly motion sensors, plus they'd probably think they were cameras and get all creeped out

Another way you could do it (that would be fantastically cool) would be with RFID. If, somehow, you carried an RFID tag around with you most of the time, a long-range RFID reader could tell when you're home and alert MisterHouse appropriately. This would be sweet. One idea (and I don't know if this is my own, or one that I read somewhere) is to put the RFID tag on your keychain, and then embed a reader in a hook where you hang your keys when you come in the door. That would work great, as long as you are diligent about putting your keys there as soon as you walk in the door. Me, that's not how I operate. As soon as I walk in the door, I like to baseball-pitch my keys into a neighboring town and/or state for convenience when I'm about to leave again. Oh, and also, I don't have any RFID stuff yet, so I'd have to buy some and learn it and integrate it. Devil you know and all that.

So, after getting my (awesome) iPhone and pairing it with my wireless network, I realized there was another possibility–if the phone is currently on the network, that's a pretty good indication that I'm home. My phone is always on, and always with me, so it seems there's a fairly low likelihood of false positives and false negatives. My basic plan is to try to ping the phone on some frequent basis, maybe once per minute, and see if it responds. If it does, then tell Misterhouse that I'm home.

One caveat: I use DHCP on my home network, so it's theoretically possible that I could have different IP addresses each time I join the network. Since I hacked my Linksys WRT54G to use DD-WRT, I could configure the router to give my phone a static DHCP assignment. That's too easy, though, so I decided I'd try to learn a bit and ping the phone by its MAC address (which is hardware-specific and never changes) instead of its IP address. Your system maintains a mapping from MAC address to IP address internally. This mapping is done via a protocol called ARP.

First, I looked in my phone settings to determine my MAC address. If you're a lucky iPhone user, too, you can find your MAC address at Settings > General > About > Wi-Fi Address, like so:

From this, I know that my iPhone's MAC address starts with 00:1B:63.

Next, I logged into my Linux machine upstairs (the one running MisterHouse) and sent a “ping” to the network broadcast address, which tells all hosts to respond:

[jason@assmonkey ~]$ ping -b
WARNING: pinging broadcast address
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=53.5 ms
64 bytes from icmp_seq=1 ttl=64 time=56.9 ms (DUP!)
64 bytes from icmp_seq=2 ttl=64 time=77.4 ms
64 bytes from icmp_seq=2 ttl=64 time=178 ms (DUP!)
64 bytes from icmp_seq=3 ttl=64 time=101 ms
64 bytes from icmp_seq=3 ttl=64 time=201 ms (DUP!)

--- ping statistics ---
3 packets transmitted, 3 received, +3 duplicates, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 53.509/111.650/201.997/58.103 ms
[jason@assmonkey ~]$ 

This has the effect of filling in the ARP cache on your system with the MAC addresses of all machines that responded to the ping. Now, I can look in the cache with the following command:

[jason@assmonkey ~]$ /sbin/arp -a
? ( at 00:1B:63:XX:XX:XX [ether] on eth0
Crap ( at 00:18:39:XX:XX:XX [ether] on eth0
macbook ( at 00:17:F2:XX:XX:XX [ether] on eth0
? ( at 00:0F:1F:XX:XX:XX [ether] on eth0
[jason@assmonkey ~]$

Bingo! Since we know that the MAC address started with 00:1B:63, we can tell that its IP address is Now, a good old-fashioned ping confirms that the phone is on the network:

[jason@assmonkey ~]$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=51.3 ms
64 bytes from icmp_seq=2 ttl=64 time=2.61 ms

--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.619/26.964/51.310/24.346 ms
[jason@assmonkey ~]$

But, oh noes! A few minutes later, I retried the ping, and found this:

[jason@assmonkey ~]$ ping
PING ( 56(84) bytes of data.

--- ping statistics ---
10 packets transmitted, 0 received, 100% packet loss, time 8999ms

[jason@assmonkey ~]$

The phone wasn't pingable anymore! I did some digging around, and came to the conclusion that the iPhone disconnects from the wireless network when you're not actively using it. This is probably done to conserve power. Unfortunately, though, this kind of defeats the point of the entire attempt, as I need the phone to be pingable on a continuous basis in order for my presence detection scheme to work.

So, that's why I put “almost” in the title. Anyone know a more clever way to do this?

DIY Laptop Bag Organizer

I recently decided that the reason I don't like any of the laptop bags I've ever tried to use is because they don't have enough pockets. Cables, adpaters, and everything else ends up in a big wad at the bottom of my bag, which drives me up the wall.

I made one that seemed to fit my somewhat picky specifications, and published a guide on how I made it. Hopefully it will come in handy to someone else out there who's as finicky about their bag as I am. (I hope they like Velcro.)

The organizer, ready for travel

DIY Podcasting

Using the ideas behind declan's blog post, I recently created
unofficial podcasts for two of my favorite WPTF radio talk shows: Neal Boortz (a Libertarian,
author of The
FairTax Book
) and Bill Handel (a true master of sarcasm,
delivered in the context of legal advice to
callers-in). Though I listen to the radio quite a bit during the day,
those shows come
on at inconvenient times. Truly, a technological solution could assist here, and
declan's blog
got me almost all the way there. Though his taste in radio
obviously differs quite a bit from my own, our needs were
the same in this regard.

radioShark, complete with terror-inducing fin. Soundtrack optional.

Here's an overview, for those impatient. I use a radioShark to schedule an automatic recording of
the shows I am interested in. I wrote a Perl script which runs after the
recordings finish that converts them into AAC
files (with an m4b extension, to support bookmarking on an iPod) using
a Nero
encoder and sends them via FTP to my web server. A specific URL on my web site invokes
a PHP script which scans the directory for those files and creates an on-the-fly RSS
XML document. Then, using iTunes or whatever software you may prefer, you can
register that URL to download new
episodes as you feel the need.

Ready to see how it's done? Good. Let's go.

[more below]


Step one: Obtain radioShark

I got mine on amazon,
where you can buy a new one for $45, or a used one for about $35.

The software that came with the radioShark was
quite outdated; there were much
newer, more functional versions available on the official radioShark download page.


Step two: Set up your recordings

Use the radioShark software to
schedule automatic recordings of the shows you
are interested in. In my case, I knew that the shows started about
5-6 minutes
after the hour (after a news break), so I took this into account; for the first
hour of Neal Boortz, I
started recording at 8:05pm and recorded for 55 minutes.
(Note: experimentation has shown that the show actually
begins at about 8:06pm, so
I might adjust this accordingly.) Neal's show broadcasts for two hours on
WPTF, so I
set up two recordings, one from 8:05pm-9:00pm, and another from
9:00pm-10:00pm. I did similar trickery for Bill
Handel's show. Remember to set your
programs up to recur on the appropriate days.


radioShark recording schedule. Note the separate
recordings for each
hour of programming, to skip news

The radioShark lets
you decide how to encode your recordings, and I chose to
save them as raw WAV files. These are quite large
(I believe around 550 MB per hour), but the purist in me wouldn't
let me encode them to MP3 just to re-encode
them later. (It probably would be fine
to do that so as to save massive amounts of disk space, since I'm going
use a high-compression encoding later, and let's not forget that it's already AM radio quality!
I'm just weird that way, and I couldn't bring myself
to do it. Ahh well, disk space is cheap.)


settings for recording one hour of

In your radioShark settings, note the directory
where your captured audio will
be stored, as we'll process files in that directory using our encoding and

At this point, your radioShark should be spamming your hard drive with massive
meggage of unencoded
audio on a regular basis. This cannot be, so we must
proceed to…


Step three: Encode and upload

Now, we must create encoded AAC files from our currently massive, unencoded WAV

In his blog, declan used the free FAAC encoder, but,
despite my repeated efforts, I could not get the results I
wanted; iTunes always complained that the audio
files were corrupted. I am most certain that it is
something I was doing wrong, despite the fact that I used the
exact same syntax
as he, but after much research and many failed attempts, I went with something
else: BeSweet v1.5 (beta) using the Nero DLL's.

Note that Nero is a commercial product, and so
you must have a license in
order to use this method. I did have such a license, so it was a good fit for me. If
don't have a license, I can only advise you to either get one (Nero is
an excellent product, that's why I
have a license) or try something else.

Download version 1.5 of BeSweet (this version is still in
beta, at the time of
this writing) and install it on your machine. Then, as it says in this (confusing) page, copy
aacenc32.dll, aac.dll, and NeroIPP.dll from your Common
Files/Ahead/AudioPlugins folder, into your BeSweet
installation directory.

Now, you have a functioning encoder. We just need to set it up to run on the
files generated by the radioShark. I do this via a Perl script which I set
to run every evening at 10:15pm, when all
of the day's recordings should have
completed. It scans the directory where the radioShark's recordings
encodes anything it finds, uploads the result to my web server via FTP, and then
cleans up.


radioShark recordings; these huge files are
generated automatically by radioShark

You likely don't
have Perl on your Windows machine, so you'll have to grab ActivePerl (which is free) and install it. This will
give you the ability to run the
encoding/upload script.

All that being said, here's my script:

use Net::FTP;
use Time::localtime;

$filepath = "C:/Public/RadioSharkRecordings/";
$besweet = "C:/BeSweet/BeSweet.exe";

$ftp_host = "####";
$ftp_user = "####";
$ftp_pw = "####";

@file_prefixes = ('Neal Boortz', 'Bill Handel');

# Add path prefix and ".wav" suffix to each, then concatenate the prefixes into a single string for "glob()"
$prefix_string = join " ", (map "${filepath}${_}*.wav", @file_prefixes);

# Now look for filename matches
while (defined($infile = glob($prefix_string))) {
print "Processing file $infilen";
# Parse the filename to extract the info it contains
if ($infile =~ /^.*[\/](.*)_(www)_(dd)_(dd)_(dd)_(dd).wav/i) {
($show_name, $day_of_week, $month, $day_of_month, $hour, $minute) = ($1, $2, $3, $4, $5, $6);
$year = localtime->year() + 1900;

$aacfile = "$filepath$year-$month-$day_of_month $show_name.m4b";

print "$besweet -core( -input "$infile" -output "$aacfile" ) -bsn( -vbr_tape -aacprofile_lc )";
system("$besweet -core( -input "$infile" -output "$aacfile" ) -bsn( -vbr_tape -aacprofile_lc )");

print "Connecting via FTP to $ftp_hostn";
$ftp = Net::FTP->new($ftp_host);
$ftp->login($ftp_user, $ftp_pw);
print "Sending $aacfilen";
print "Closing FTP connectionn";
print "FTP transfer finishedn";

print "Deleting $infilen";
unlink $infile;
print "Deleting $aacfilen";
unlink $aacfile;

print "DONE WITH $infilen";
} # while loop for one prefix

You'll note that the configuration information (location of BeSweet,
location of your recordings) is up at the
top for convenience. There's also a
list (@file_prefixes) that specifies the show names that should be
processed. The
script looks for recordings with the specified show names in the format used by
the radioShark
recording system. Note that, for the converted filename ($aacfile)
I switch up the format a bit, using an ISO
standard date format which also makes
the encoded files sort properly.

On the BeSweet command line, I
specify a variable bit rate encoding, using the
"tape quality" preset. Though this is a relatively low
encoding, it shrinks it down nicely from 550 MB to 20 MB, and the quality has been
completely adequate for
my crazy AM radio needs. Note that I also specify an
extension of .m4b, which indicates to iTunes that the file is
an audiobook, so
bookmarking is enabled.

As this is a Windows machine, I set it up a Scheduled Task in the
Panel to run this script every day.

Awesome. At this point, the radioShark is recording our shows,
and a Perl
script is converting t them to AAC format and uploading them to the webserver. Can
life get any better? I
submit that it can, if we only proceed to…


Step four: Generate

Now, a directory on your web server is expanding at a good clip (~20 MB/recorded
although not as quickly as the directory on your hard drive was before.
So, how do we present them as a podcast?

We give iTunes a URL that resolves to an XML document in RSS format, with
attachments for the recorded
audio. That's all a podcast is. iTunes will connect
using HTTP to download everything. So, all we have to do is
generate that XML in
a web page at a URL that iTunes can access, and we're home free. Sounds like
an excellent
task for PHP.

Behold the set of scripts that I authored to do just this task.

I wanted separate
feeds for Neal Boortz and Bill Handel, so I needed to write
everything in a way that would allow me to have only one
copy of most of the
code. I did this by writing two very small scripts, one for my Neal Boortz


create_podcast_feed (
"Unofficial Neal Boortz Podcast",
"*Neal Boortz*"

…and a separate one for my Bill Handel recordings:


create_podcast_feed (
"Unofficial Bill Handel Podcast",
"*Bill Handel*"

Both of these scripts use a function defined in
podcast_base.php, as follows:

function create_podcast_feed ($title, $url, $pattern) {
header("Content-type: application/xml");
echo "<?xml version="1.0" encoding="UTF-8"?>n";

<rss xmlns:itunes="" version="2.0">
<title><?php echo $title; ?></title>
<link><?php echo $url; ?></link>

$files = glob($pattern);
$aacfiles = array();
if (is_array ($files)) {
foreach ($files as $file) {
$modtime = date("YmdHis", filemtime($file));
$aacfiles[$modtime] = $file;
krsort ($aacfiles);

foreach ($aacfiles as $aacfile) {
if (preg_match("/^(dddd)-(dd)-(dd) (.*).(m4.)/i", $aacfile, $backrefs)) {
$year = $backrefs[1];
$month = $backrefs[2];
$day_of_month = $backrefs[3];
$show_name = $backrefs[4];
$extension = $backrefs[5];
$file_url = $url . "/" . rawurlencode($aacfile);

<title><?php echo "$show_name $month/$day_of_month/$year"; ?></title>
<enclosure url="<?php echo "$file_url"; ?>" type="audio/x-<?php echo "$extension"; ?>"/>
<guid><?php echo "$file_url"; ?></guid>
<pubdate><?php echo date("r", filemtime($aacfile)); ?></pubdate>

} // preg_match
} // foreach
} // if (is_array ($files))



As you can see, both of the small scripts pass in a
pattern, and the function
uses the PHP glob function to get a list of files that match that pattern. It
grabs the
modification time for each of the files and puts it all into a hash from
modification time (key) to filename
(value). I use the PHP krsort to sort the
hash by key, with newer dates at the top. Then, I iterate through the list
dump out the XML. Easy.


Podcast RSS XML in

Any-hoo, I just dropped those scripts into the
directory with the AAC-encoded
audio files, and magic happens when I call them up on my browser.


Step five: Bathe in self-adulation

Now, it should all work. Just
enter the URL for one of the small scripts as a
manual podcast in iTunes, and you're golden.

XBox – Now with remote controlled power!

Some of you may know that I installed a mod chip in my XBox, mostly so I can run the awesome XBox Media Center (XBMC). This is hugely awesome if you combine it with the XBox DVD Remote, as you can sit on your couch and use the remote to control a home theatre PC! (Actually, I have an RCU810 that I bought in 2001 or so that I hacked to make it JP1 compatible. I programmed that remote to use the XBox codes, and I use that one instead!)

The biggest problem, though, is that you still can't use the DVD remote to control the XBox power. You have to get up off the couch (horrors) and push the power button. No fun.

Well, Team Xecuter recently released a separate mod, the X3IR, which adds a separate IR receiver to the XBox, which allows you to control power, among other things. I ordered one, and installed it tonight. All of the directions I found, though, assumed that you had an Xecuter 3 Control Panel and an Xecuter mod chip, which I didn't; I have a SmartXX chip, which isn't compatible with the control panel.

After much, much digging, I finally found these instructions, which tell how to install with any mod chip. However, there is an error in the diagram on that page showing the solder points for a version 1.6 XBox! I discovered this when I connected it all up and discovered that it wouldn't power on. Comparing it to the other directions, though, I noticed that the solder points for the Red1 and White wires were reversed. So, I took it all apart again, swapped those wires, and it worked just fine. Yay!

Now we can be lazy and control the power from the couch. Life gets no better than this.

UPDATE: I sent a message to the guy who authored the instructions with the error, and he has graciously fixed them.

Explorer Message Center

My most recent project (which I actually started back in March or so, and left fallow until this past week) has been the installation of a message center in my Ford Explorer.  This is an available factory option, but it wasn’t in the vehicle I ended up purchasing back in 1998, even though I really wanted one!  It’s a display unit that tells you about your fuel efficiency, remaining fuel, engine oil quality, and other such, and it sits in the center console in the “corner” beneath the HVAC controls and in front of the cup holders.


Apparently, I am not the only other one in the universe who wants to do this, because there are pages on the web that give overviews of the installation process.  It seemed a little involved, but not enough to deter me, so I made a trip to a local junkyard back in March and bought a message center from a wrecked Explorer for $30.  Wedding stuff took precedence, so I put it down when I got back and didn’t really get a chance to look at it again until this past week, when I made the first connections.

Back in August, I hooked up an XM radio in the Explorer, and I had to do some wiring then because my DC outlets are always on, even when the keys are out.  So, I pulled the radio out, and with the help of another page on the web, I located a power wire that is activated only when the car is running, or the key is in “accessory” mode.  I used a very nifty device called a wire tap (with an even cooler name) to splice another wire off and connected it to a spare DC power outlet, which I could hide beneath the center console.  I tapped the ground wire for the power outlet similarly.  Then, I connected the plug for the XM radio into the new outlet, tucked it beneath the center console, replaced everything, and now it works like a champ.

Any-hoo, I started with the message center by tapping an always-on as well as an accessory wire, as I did for the XM radio, as well as connecting a few of the ground wires.  I also connected an “illumination” wire for the message center to a similar wire for the radio.  Now, the message center has power and the lights dim appropriately when I use the control on the driver’s side.  Cool!  However, it doesn’t really do anything yet, so I’m going to have to start hooking it up to sensors (mostly by tapping more wires) behind the dashboard.  I’ve ordered an Explorer service manual on CD from eBay, which should help me identify the wires that I need to use.  Until that arrives, I’m in a holding pattern, but I can still admire my message center constantly telling me I have “low washer fluid” until I can do more.  🙂