You are viewing careytilden

Previous 10

Sep. 1st, 2011

SSH VPN recipe

SSH options for $remote

PermitRootLogin yes
PermitTunnel yes

As root@$local

ssh -w 0:0 root@$remote 'while true; do echo "[$(date)] $(uptime)"; sleep 10; done'
ifconfig tun0

As root@$remote

ifconfig tun0

This will set the remote endpoint to and the local endpoint to

May. 4th, 2011

The best T-SQL median query ever made

Despite having used them awkwardly before, the ranking functions in SQL Server finally clicked for me. Compared to the gymnastics I have gone through to emulate such functions in MySQL, this is downright gorgeous. Instead of going on at length, here's an example. The best T-SQL median query ever made.

    AVG(zip_size) AS median_size
        ROW_NUMBER() OVER (
            PARTITION BY machine_name
            ORDER BY DATALENGTH(zip_data) DESC
        ) AS row,
        CAST(1+COUNT(*) OVER (
            PARTITION BY machine_name
        ) AS DECIMAL)/2 AS med,
        CAST(DATALENGTH(zip_data) AS DECIMAL)/1024/1024 AS zip_size
    FROM tblLocalUploads
) AS q
WHERE CASE WHEN row BETWEEN med-0.5 AND med+0.5 THEN 1 ELSE 0 END = 1
GROUP BY machine_name

Mar. 6th, 2011

A source control kind of life

A quick anecdote.  I was struggling to find a good way to keep track of some sensitive docs, such as my password list and financial information.  For a while I carried these around on a flash drive, but that never sat right with me.  Plugging it in all the time was a real drag.  And heaven forbid I dropped it; someone could have unfettered access to my docs.

My first attempt at a better solution was to use my existing JungleDisk account.  It'd been great for offsite backup, but trying to use it as a network drive proved to be too glitchy.  Between network availability and the vagaries of automatic syncing, I was constantly frustrated.

Then I landed on an idea that should have been obvious from the beginning: I put these docs under source control.  I set up a repository on my virtual host, made it accessible only via a password protected ssl URL, and voila, it fit the bill perfectly!  It was reasonably secure; I could work with local files most of the time; I had control over when changes got pushed and pulled (rather than relying on the autosync to notice my changes); and I suddenly had a plethora of sophisticated tools available to manage changes.

Finally, the point of this post?  Gosh, I love source control.  My current preference is Mercurial, but Subversion still holds a warm place in my heart.  Regardless of which one I'm using, I love taking control of my changes.  It's just lovely.

Jul. 23rd, 2009

Music management part 27

I finally gave in.  I'm using iTunes to maintain my music library.  I'm still tagging with MusicBrainz, but then tweaking a bunch of stuff in iTunes.  Here's the basic workflow:
  1. Add files to itunes
  2. Load from itunes music folder into musicbrainz
  3. Tag but don't rename
  4. Reload updated metadata in itunes and clean it up by hand

The hand cleanup goes like this.  These are listed in order of importance.
  1. Remove sort names
  2. Rename artists to fit personal preferences
  3. Ensure album artist is set to album's primary artist
    • For a tribute album, use the original artist
    • For a compilation, use the overwhelming majority artist
    • If no overwhelming majority artist, use "Various Artists"
  4. Ensure track number is in N of M format
  5. Remove compilation flag unless it's clearly a compilation, for example
    • Greatest hits albums
    • Soundtracks
    • Grab bag releases (e.g., "Now That's What I Call Music" series)
  6. Ensure album has a release year
  7. Set genres, using wikipedia and for guidance
Update: Added step for compilations
Update: Added step for track number format
Update: Added step for release year

Feb. 15th, 2009

Ramblings on organizing music

I love MusicBrainz a whole lot, but there are a few things I don't like about their data.  Eventually I will come up with some way to override these things automatically (perhaps with Picard plugins), but for now I'm making a raft of changes by hand:
  • Artist name substitutions.  Say all you want about "original intent", but I get really agitated by artist names in all caps or all lowercase.  I change these, and a handful of other naming oddities (e.g., "blink-182" becomes "Blink 182").
  • Sort name hack-n-slash.  I end up removing the sort name tag from all but the few artists that need one.  The vast majority of sort names I keep are to remove "The" from the beginning of a bunch of artists, but there are a few other cases (e.g., to remove the dots in front of "...And you will know us by the trail of the dead").  I completely abhor the "Last name, First name" convention.
  • Genre cleanup.  Using folksonomy tags for genre is a good starting point, but I've been changing a lot of them by hand.  I sometimes wonder if it's even worth the effort.
I also decided to flatten my file naming convention a little bit.  I switched to the following:
  • Albums/{Artist} - {Album} - {Total tracks} tracks/{Track num} - {Track name}
  • Albums/[multiple artists] - {Album} - {Total tracks} tracks/{Track num} - {Artist} - {Track name}
This gives me one directory for each album release, even in the cases when there are more than one release with the same name (unless both releases have the same number of tracks).  It reduces nesting and makes it easier to browse the collection more naturally (more analogous to a single set of shelves, rather than a bunch of rooms with separate shelves).

Oct. 25th, 2008

Political compass

I was curious if my political tendencies have shifted, so I took the excellent political compass test again. My scores are about the same as I remember them. Perhaps I shifted a little to the center in the economic scale, but I'm still in the same quadrant. Without further ado, here are my results:

The Political Compass

Economic Left/Right: 0.62
Social Libertarian/Authoritarian: -2.82

Jun. 28th, 2008


I heard a story on NPR the other day which, at first, made me incredulous. It was discussing MPG vs GPM as a useful measure of fuel efficiency. It stated that a smaller increase in MPG at the low end--say, 10 MPG to 15 MPG--was worth more than a bigger increase at the high end--say, 30 MPG to 50 MPG.

Intuitively, this seems ridiculous. But once you do a little bit of math, it makes more sense. The most useful measure of efficiency is how much gas it takes to get from point A to point B. That is, you have a set distance, and you want to compare the amount of fuel used. That leads to GPM as a more direct measure. Since GPM is the reciprocal of MPG, it has a non-linear relationship. This throws off all our intuitive responses and makes MPG somewhat deceptive.

Here's a graph to demonstrate the relationship:

And an example to demonstrate the point:

  • 10 MPG uses 10 gallons per 100 miles, 15 MPG uses 6.7 gallons per 100 miles. Moving from 10 MPG to 15 MPG saves 3.3 gallons for a 100 mile trip.
  • 30 MPG uses 3.3 gallons per 100 miles, 50 MPG uses 2 gallons per 100 miles. Moving from 30 MPG to 50 MPG saves 1.3 gallons for a 100 mile trip.

Feb. 15th, 2008

I am awesome; a conversation in demonstration

(8:20:15 AM) William: was down
(8:20:33 AM) William: oh squelcher where have you gone!?
(8:20:35 AM) Carey: Oh, nice
(8:21:50 AM) Carey: Will go check the machine, brb
(8:21:58 AM) William: thx
(8:29:16 AM) Carey: Starting back up... la la la... 10 minutes eta
(8:29:22 AM) Carey: brb again
(8:39:08 AM) Carey: Back up
(8:39:15 AM) Carey: Look at that, almost exactly 10 minutes. I rule

Jul. 27th, 2007

Duplicate artists listed in iTunes and on iPod

Googling will reveal issues with duplicated artists to be fairly common, but the solutions always center around fixing spelling errors, removing spurious spaces, or cleaning up other textual errors in the tags. Since I'm a MusicBrainz tag nazi, this isn't the problem for me. After a bit of flailing and comparing tracks from these problematic artists, I found the cause for all the problems in my collection boiled down to:

  1. Different id3v2 versions
  2. Different sort names

Fixing problem (1) was easy. I converted all tracks to id3 v2.4, which they probably should have been already. This was a simple matter of selecting all tracks, right clicking, and selecting the "convert tags..." option.

Problem (2) was about as simple, but much more tedious. I scanned through looking for dupes in the iTunes artist list, and unified all the tracks to the same sort name. Unfortunately, iTunes wouldn't allow me to change this option en masse, so I had to do one at a time.

After I finished, I noticed there were still a few repeated artists left in the iPod, but not repeated in iTunes. Loading the collection back up in iTunes, I realized these few remaining were due to yet another problem:

  1. Some tracks missing a sort name

Which is sort of a variant of problem (2), but only affected the iPod. This time I could either add a sort name to some of the tracks, or remove it from the others. I opted for an economy-of-motion approach. I decided separately for each artist, depending on which option would require the fewest changes. I don't like having sort names for only some artists, but considering that iTunes only let me do one at a time, I bit the bullet and saved myself some time.

Jul. 15th, 2007

Google reader subscriptions

After using Google reader for a while, I've built up a pretty good list of subscriptions. In case anybody is interested (and as a bit of return on investment for those who helped me build up my initial list of feeds), here are the feeds I'm currently subscribed to. Enjoy.

Previous 10

mouth open shock horror

September 2011



RSS Atom
Powered by