I'm Travis, a 10 year veteran software developer with a broad background in web technologies and
software markets. I've been working with Rails as my weapon of choice for the last 3 years, and
more recently, developing applications on the iPhone SDK.
A refactoring habitué and TDD adherent, I've
a special interest in software development as a craft and science.
LATEST PROJECT: Secure Rails Admin Backend With Authlogic and Multiple Sessions
ActiveRecord associations are magical, and if you embrace the sundry offerings of finder plugins the world of parameterized queries becomes a vast and wondrous landscape indeed. So how do Rails developers typically organize and build dynamic queries without drenching their code in switch blocks, multiplying filter methods on the model, or contriving vestigial routes for search- and report- like GETs?
If there is a combinatorial way to bring aspects of a framework together in a breaking edge case, I will find that way and take that step. It’s a destiny one follows gladly; an instinct useful in defining the boundaries of an application’s logical complexities as they accumulate on the brain like bit patterns.
Comments and self-documenting code are like brandy and cigars, the first illuminating your source (meaning both the gentleman’s soul and the source code into which he pours it), and the second imparting a blazing instance of clarity where you can taste the meaning.
Adherents debating the styles travel parallel roads in the direction of improving maintainability, [...]
Here’s another little Rails code snippet for getting video details, this time from Youtube. The code simply retrieves an XML details object for a given video. Enjoy. . .
YOUTUBE_URL_REGEX = /(www.)?youtube\.com\/watch\?v=([^&]*)/i
url = http://www.youtube.com/watch?v=az-8Z1skhLs&feature=channel_page
begin
if YOUTUBE_URL_REGEX.match(url)
vid_id = YOUTUBE_URL_REGEX.match(resource_locator)[2]
youtube_url = "http://gdata.youtube.com/feeds/api/videos/#{vid_id}"
response = Net::HTTP.get_response(URI.parse(youtube_url))
results = Hash.from_xml(response.body)
@description = results["entry"]["group"]["description"]
@thumbnail_url = results["entry"]["group"]["thumbnail"][0]["url"]
end
rescue Exception => exc
# DNS failed…
end
See also: Getting Vimeo Video [...]
Here’s a little Rails code snippet, posted here for posterity or until Vimeo changes their developer API. The code simply retrieves a JSON details object for a given video. Enjoy. . .
VIMEO_URL_REGEX = /(www.)?vimeo\.com.*?\/(\d+?)$/
url = "http://www.vimeo.com/2233379"
begin
if VIMEO_REGEX.match(url)
vid_id = VIMEO_URL_REGEX.match(url)[2]
vimeo_url = "http://vimeo.com/api/v2/video/#{vid_id}.json"
response = Net::HTTP.get_response(URI.parse(vimeo_url))
results = JSON.parse(response.body)[0]
@description = results["description"]
@thumbnail_url = results["thumbnail_small"]
end
rescue Exception => exc
# DNS failed…
end