A Little Tidbit

Gamespy just posted an article on the specs for the next Xbox. Note the last line in particular:

CPU – Xenon’s CPU has three 3.0 GHz PowerPC cores. Each core is capable of two instructions per cycle and has an L1 cache with 32 KB for data and 32 KB for instructions. The three cores share 1 MB of L2 cache. Alpha 2 developer kits currently have two cores instead of three.

I’ve been sitting on this until it became public knowledge, but when I saw a dev machine last year, it occurred to me that it’d explain why that Microsoft blogger was fired a year and a half ago.

Bloc Party

Wow, Bloc Party‘s new album, Silent Alarm has caught me by surprise. I haven’t been this excited about an album in a while. I’m loving it. A lot. Here’s their opener:

Looks like they’re going to be in town right after SXSW. (Hmm, Troub is sold out already)

  • 21.03.2005 Pomona, CA Glasshouse
  • 22.03.2005 Los Angeles, CA Troubadour

Exponentially Smoothed Moving Averages in PHP

Wow, I’m a dumbass. While closing out tabs this morning, I found an article on Smoothing Time Series that actually explains this stuff in code terms instead of subscripted letters that made my eyes glaze over.

Looking back at the formula at the bottom of John Walker’s Exponentially smoothed moving averages page, it’s pretty clear how trivially easy the code is:


// Exponentially smoothed moving average function
function esma($in) {
  $out[0] = $in[0];
  for($i=1; $i<sizeof($in); $i++) {
    $out[$i] = $out[$i-1] + 0.1 * ($in[$i] - $out[$i-1]);
  }
  return $out;
}

Here’s an output comparing a 20-day simple moving average, a 20-day exponential moving average, and the exponentially smoothed moving average. You can see the latter two are almost identical. The advantage of the exponential averages are that they track from the first point (instead of the simple moving average’s offset). The exponentially smoothed average uses a smoothing constant, so it doesn’t depend on the a size window):

Also, here’s the source.

WordPress 1.5 Apache Authentication Haxie

Before I forget here’s a quick and dirty hack for enabling Apache Authentication in WordPress 1.5 that I whipped up the other week:


# line 20 of wp-login.php

if($_SERVER['REMOTE_USER']) {
  $action = 'login';
}

# line 162 of wp-login.php
if($_SERVER['REMOTE_USER']) {
  $user_login = $_SERVER['REMOTE_USER'];
  $user_pass = $user_login;
}


# at the top of wp_login in wp-include/functions.php

if($username == $_SERVER['REMOTE_USER']) {
  
  $login = $wpdb->get_row("SELECT ID, user_login, user_pass 
                           FROM $wpdb->users 
                           WHERE user_login = '$username'");
  if ($login) {
    return true;
  }
}

.htaccess are applied to <File wp-login.php> and to the wp-admin directory

There’s a more “proper” WP 1.5 Authentication Plugin but I couldn’t get it to work and the do_action() callbacks were annoying/impossible to debug. Daniel generously offered to help get it working, but if we use it for what we’re planning to, the above hack should be fine until Apache auth makes it into WP core.

One other note: there’s no ‘scheme’ so http/https is broken on the CSS linking for the admin. That needs to be changed from the WP options.

JpGraph

Being landlocked by the marathon for most of the day, I ended up mostly hacking around with JpGraph instead of doing the countless other things I should have been doing.

That being said, I don’t think it was a total waste of time. My goal was to try to replicate the floater/sinker graphs that EatWatch creates, and I more or less succeeded. I’m using a simple moving average rather than a full blown exponentially smoothed moving average (I think it’s pretty straightforward to implement, TODO) and I don’t know how (or if) the first values are dealt with in EatWatch.

The above is fake data, but it gives an idea (I don’t have enough data points yet for the SMA to kick in). Here’s a look at the source, and also the patch for the floater/sinker enabled scatterplot (against JpGraph 1.17)

iPod iTunesDB Parsing

I spent a couple hours today messing around with parsing the iPod iTunesDB.

Ostensibly, this is for the purpose of writing an Audioscrobbler plugin for syncing the songs played. (iScrobbler does this, but not if you don’t have autosyncing on – since my iPod is pruned from a much larger collection, I have manually manage my songs).

At first glance, there seem to be many options, but neither Mac::iPod::DB nor Mac::iPod::GNUpod support the ‘lastplay’ fields. libitunesdb and Sam Wood’s iPodDB.cpp are out of the running because my C/C++ skills have now faded to nothing.

Anyway, it turns out that GNUpod does support the lastplay field, and after you install the scripts, it also installs the GNUpod::iTunesDB package. Using the tunes2pod.pl as a base, it was pretty straightforward to pull the tracks from the “Recently Played” list and sort by lastplay date.

That’s about as far as I got, so I get output like this:

2005-03-05 18:55:14 - Bloc Party - Plans
2005-03-05 18:47:34 - Bloc Party - Banquet
2005-03-05 18:42:32 - Doves - Black And White Town
2005-03-05 16:29:53 - daft_punk - on_off
2005-03-05 16:22:26 - Bloc Party - Compliments
2005-03-05 16:18:05 - daft_punk - emotion
2005-03-04 21:54:48 - Four Tet - Tangle
...

I’m also calculating percent played based on the next played item to try to insure that it’s over 240s/50%, although I’m not sure exactly how skipped songs are counted, so I’ll have to experiment a bit w/ that.

What’s left to make this actually functional:

  • cron/daemon to check for songs when iPod is newly attached
  • md5sum + date check if iTunesDB should be read (reads are expensive, my 2400 song DB takes about 20s of full CPU usage)
  • queing submissions
  • submitting to Audioscrobbler (I’ll need to get a client id)

I’m probably not going to have time to get to finishing this anytime soon, but in case anyone is working on something similar, here’s what I hacked together today.

Some misc notes:

  • The iPodLinux site has a very comprehensive page on the iTunesDB format (see the discussion as well)
  • A pair of perl scripts that weren’t directly applicable to what I want to do, but are worth mentioning: tunes2html and tunesxml2html that convert iTunesDB and the iTunes Library XML to HTML listings
  • One of the peculiarities of the date format is that its stored in Mac epoch time, which starts at January 1, 1904 instead of January 1, 1970. I couldn’t find the second offset anywhere online (it’s 2082844800 seconds) and I ended up calculating it in JavaScript after not being able to figure out an easy way to do it with Date::Calc:
    var d1 = new Date("January 1, 1904")
    var d2 = new Date("January 1, 1970")
    diff = d2.getTime() - d1.getTime();
    document.write(diff/1000);
    

random($archives)

Over the weekend I wrote some import processing scripts to dump in all my old random($foo) archives. That would be 3822 entries over the past 5 years. No matter which way you slice it, that’s a lot of text.

I’m working to do imports from my ’98-’99 stuff and miscellaneous other posts. I suppose having a better way to view archives would probably be a good idea. And then some graphs…

OS X CD Fun

This command will disable autoplay for audio CDs:

defaults write com.apple.finder AutoplayAudioCD '0'

There’s a fun utility called drutil that is quite useful. It has a poll command which will run and output status/state changes (you could also manually poll with status, both are quite useful for scripting as you can imagine). It also has all kinds of related information dumps and of course, allows controlling of the tray and ejection.

Lastly, all the tools that you’d want for ripping/making CDs are available via Fink, although cdrdao requires compiling, and cd-discid and abcde are only available in the unstable branch.

Now that I have to suffer through frequent Tomcat restarts and other interminable waitstates, I figure I will have lots of time to pop CDs in and out at work. If I do 20 a day, I could be done in less than a month.

Back From the Dead

With a crunch mostly over at the beginning of the week, I don’t have much of an excuse not to be posting anymore, especially considering this new layout was supposed to highlight my content production, not my conspicious lack thereof.

I spent some time tonight doing some cleanup/sorting. For example, filing and closing out about 30 unsaved OmniOutliner files that have been precariously sitting in my dock. I’ve upgraded to OmniOutliner 3 Pro, which among other features, has the ability to select and restrict views of sections. This eases on mental clutter, and is a great idea:

OmniOutliner 3 Sections

Also, over the past week, I’ve been much more diligent in scheduling the upcoming day in iCal. This works out well for two reasons. I already track my billable hours in iCal (I have a server-side script that processes the iCalendar file after it gets transferred via WebDAV that automatically updates our billing system as well as generates reports) and the additional scheduling only helps me keep on top of that, and also at the end of the day, I’m able to push off the things I haven’t gotten to and have half the next day scheduled. It’s one of those virtuous cycles, or something like that.