My EDM Podcasts of 2009

I discovered a lot of great electronic music in 2009 from a variety of sources, including these podcasts:

  • Club Autonomic - 2009 was a year for a lot of experimentation within the Drum & Bass genre. This podcast from D-Bridge and Instra:Mental showcases the latest sounds that some are dubbing "future beats" (web, subscribe).

  • Critical Music - Critical Music label boss Kasra presents the latest from his and other labels (web, subscribe).

  • DJ Marky - DJ Marky (Brazil) presents his latest mixes (web, subscribe).

  • John B - International Superstar DJ John B presents his selection of electro-influenced Drum & Bass (web, subscribe).

  • Hospital Records - Tony Colman (aka. London Elektricity) presents the latest selections from Hospital Records and other up-and-coming producers (web, subscribe).

  • Phuture Frequency - An Intenet radio station that went podcast-only in 2006. It features various DJs representing a variety of styles of Drum & Bass (web, subscribe).

  • Random Movement - This DJ / Producer has a regular show on Bassdrive and features his latest studio mixes on this podcast (web, subscribe).

  • Reprise Music Agency - Reprise represents a lot of well-known DJs / Producers, this podcast showcases mixes from the talent that they represent (web, subscribe).

  • Shogun Audio - DJ Friction showcases the latest from the Shogun Audio camp (web, subscribe).

  • Urban Nights - DJ Urbanite presents periodic mixes of some Liquid DnB selections (subscribe).

  • XLR8R - This podcast features the most eclectic collection of music, from hip-hop, to grime, to indie, they present a lot of different up-and-coming scenes and sounds. It's a good place to start to find a lot of interesting music. I summarized my favorite episodes from this podcast last year (web, subscribe).

  • Lifted Music - Label bosses Spor and Chris Renegade feature darker Drum & Bass from their label. This hasn't been updated in quite a while, but the older episodes are worth a listen (web, subscribe).

Go check these out (if you're into that sort of thing).

Using Helper Methods in Your Model? Yes.

At one point I found myself wanting to use Rails' auto_link helper in a to_html method on one of my models. If you need this functionality, here's how you would do it:

class Formatter

  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::TextHelper

  def initialize(content)
    @content = content
  end

  def to_html
    auto_link(@content)
  end

end

I had to include TagHelper to satisfy dependencies for the h() and content_tag() methods. Though I ended up writing a custom formatter class instead in this case, this is still a useful approach.

Passing Parameters to Rake Tasks

I recently discovered how to correctly pass parameters to Rake tasks from the command-line instead of the old, busted way of passing in environment variables. The post is up on the Viget Extend blog, but here's the short of it.

If you have a task that you want to parameterize:

task :echo do
  puts "Hello"
end

You can specify the parameters that it accepts and receive them as a hash inside of the task:

task :echo, :message do |t, args|
  message = args[:message] || 'Hello'
  puts message
end

It also honors task dependencies (using a different syntax):

task :echo, :message, :needs => :environment do |t, args|
  ...
end

Check out the post for the full details.

Coding with Confidence: The Talk

Last weekend I gave a talk on Test-Driven Development at the Fall 2009 CMAP Code Camp. Since this was a .NET event (and I'm a Ruby guy), I took a look at some previous talks I had given on the topic to focus on why someone might want to use a Test-Driven approach when developing software. It didn't hurt that there had been a lot of debate recently on the value of both unit testing and a test-first software development approach. The first part of my presentation focused on the benefits:

For the second portion of my talk, I did about 45 minutes of live coding (in Ruby) to demonstrate the process I go through when using tests to drive the code I write. During that time, we built a small working wrapper to the TwitterCounter API from the ground up. There was some good discussion afterwards about removing the remaining duplication and how best to evolve the design to better model the interaction with the API.

It was good to get in front of a different audience to talk about the value of testing as a design tool. Thanks to Chris Steen for the invitation and the rest of the CMAP group for organizing a great conference.

Dead Simple Delegation in Rails

I can't believe I didn't see this when it came out. Instead of this:

class Child < ActiveRecord::Base
  belongs_to :parent

  def parent_name
    parent.name
  end
end

Or this:

require 'forwardable'
class Child < ActiveRecord::Base
  extend Forwardable

  belongs_to :parent
  def_delegator :parent, :name, :parent_name
end

You can now do this (as of Rails 2.2.2)

class Child < ActiveRecord::Base
  belongs_to :parent
  delegate :name, :to => :parent, :prefix => true
end

Check out some more detailed examples in the documentation

Autotest and Me

Today, Mark and I were talking about some of the open source projects we've been working on. During our conversation, he mentioned how David's recent post about using Autotest on OSX was the catalyst for him to start using it on his projects. I decided that I would do the same, so I went about using it on a Ruby gem that I'm developing.

From the original post, using it on Rails is pretty straightforward, but getting it to work on a vanilla Ruby project requires a bit of tweaking. There's some outdated information out there, but I was able to find a solution that worked for me. My resulting .autotest file:

require 'autotest/growl'
require 'autotest/fsevent'

Autotest.add_hook :initialize do |at|
  at.clear_mappings

  at.add_mapping %r%/^lib/(.*).rb$% do |_, m|
    possible = File.basename(m[1])
    files_matching %r%^test/.*(#{possible}_test|test_#{possible}).rb$%
  end

  at.add_mapping(%r%^test/.*.rb$%) {|filename, _| filename }
end

With that patch in place, I get the results I want.

Access The Etsy API in Ruby

Long ago, my wife found a love for Etsy. When I recently discovered their public API, I figured that it was meant to be that I begin working on a clean implementation of the Etsy API in Ruby. So I did.

I'm releasing the first version to the public tonight that includes support for retrieving users, their shops, and associated listings.

Installation

A simple gem installation is all you need:

sudo gem install etsy

If you prefer to bleed:

sudo gem install reagent-etsy --source=http://gems.github.com

Usage

Once installed, set up your API key and you're ready to go:

require 'rubygems'
require 'etsy'

Etsy.api_key = 'snipsnap'

At the time of this post, all API calls are read-only so that's all you need to do. Let's get started by finding a user's shop:

user = Etsy.user('littletjane') # => #<Etsy::User:0x1057624 ... >
user.seller?                    # => true
user.shop.name                  # => "littletjane"

A shop can have multiple listings:

user.shop.listings  # => [#<Etsy::Listing:0x1001788 ... >, ... ]

listing = user.shop.listings.first

listing.title       # => "hanging with the bad boys matchbox"
listing.description # => "standard size matchbox, approx. 1.5 x 2 ... "

Each listing, in turn, can have one or more images:

image = listing.images.first

image.small_square # => "http://ny-image2.etsy.com/il_25x25.67765346.jpg"
image.large        # => "http://ny-image2.etsy.com/il_430xN.67765346.jpg"

For more information and usage examples, check out the documentation on Rubyforge. If you have feature requests or comments, open an issue on Github or send me an email.

SVN Cleansweep

Due to a very specific setup we have here at the office, I sometimes have to fix people's SVN working copies directly on the server. Sometimes I can run svn cleanup from the top-level directory, sometimes I can't.

With Kevin's help, I came up with this script to start at the deepest directories and clean all the way to the current directory:

Grab Flickr Tags and Comments With Fleakr

I just pushed out version 0.4.3 of the Fleakr gem that provides support for retrieving tags and comments for users, photos, and photosets. These are non-authenticated methods, so all you need is your API key:

Fleakr.api_key = 'your_api_key'

Once that's set, you can retrieve tags for users and photos:

user = Fleakr.user('teamviget')
user.tags.first.value
user.sets.first.photos.first.tags.first.value

Given a single tag, you can also retrieve a list of related tags:

user.tags.first.related.first

Tags associated with a photo have more information associated to them - see the documentation for what's available. Comments have no such limitation and are available for both sets and individual photos:

user = Fleakr.user('the decapitator')
user.sets.first.comments
user.photos.first.comments

Give it a try for yourself - check out the docs or send me an email if you get stuck. Enjoy

Am I Ruby 1.9?

Kevin and I were chatting about how to tell if your locally installed gems were compatible with Ruby 1.9. He was looking for a tool that would scan the list and figure out which ones worked. I pointed him to Is It Ruby 1.9?, he found the API and whipped up a gem that would tell you which of your gems would likely work (or not work) with the latest version of Ruby. Check it out:

$ sudo gem install n3bulous-amiruby19 --source=http://gems.github.com

Then let it loose on your system:

$ amiruby19

Oh, and it was built with simple-gem (shameless plug).