Putting Rails to Work

Posted on : 15-11-2006 | By : Tony Stubblebine | In : Uncategorized

Tags: , , ,

0

Bill Katz led a great panel at last night’s Ruby Meetup, hosted by Obvious Corp. The panelists were Coda Hale, Evan Henshaw-Plath, Michael Kovacs, Josh Susser, Chris Wanstrath, and Florian Weber (I’ve worked with three of those guys!).

Josh Susser talked about how he’d abandoned rails generate in favor of maintaining an exemplar project in subversion. After tweaking acts_as_authenticated and acts_as_taggable I think that’s not a bad idea.

Chris Wanstrath talked about how CNet is using Rails to build Chow.com and Chowhound.com. They use microformats to syndicate content from one site to another. I’m know that’s not the first production use of microformats but it’s definitely the first time I’ve heard someone outside of the microformats website talking about a real world use. Chris just released mofo, a microformats parser for ruby.

Michael Kovacs showed his new get_sorted_objects plugin for creating sortable HTML data tables.

Coda Hale talked about the importance of a staging environment and how effective Wesabe’s integration of campfire (group chat) and continuous integration is. I’ve done continuous integration with breakages going out over email and the group chat way is definitely more effective. I never check in code without waiting in the chatroom to see that the tests didn’t break. Looking bad in front of your coworkers is an ok deterrent. But knowing that they’re going to start talking smack about you behind your back, that’s a great deterrent. Also the company that Coda and I have been working on might launch very very soon. Look out for Wesabe!

Evan Henshaw-Plath talked about the caboo.se documentation project. It looks awesome. That sparked a discussion about how the rails core team needs more support.

Florian Weber, who’s on Rails core, agreed, but thought there was some confusion caused by people who were complaining without offering constructive advice. He also pointed out that at least Rails is headed in the right direction, it’s filling a major need and it isn’t suffering from feature bloat.

There were also a few lighting talks and announcements.

My favorite was a round of people announcing that they were hiring. After about ten people made this announcement the question was flipped to “who’s looking for a job?” Nobody.

Tyler Kovacs from ZVents.com showed off his new custom_benchmarks plugin for adding your own information to the benchmark line logged at the end of each rails request.

Kongregate, a flash games community and marketplace gave a demo. They’re in private beta but you can request an invite from their home page. Special preference for people at the Ruby meetup. Here’s what TechCrunch had to say about them. If you don’t think flash games can be cool, check out Raiden-X.

YouTube API How-To

Posted on : 08-11-2006 | By : Tony Stubblebine | In : Uncategorized

Tags: , , , , , , , ,

8

What is it

The YouTube API lets you search for videos and display them on your site. For example, I use the API to pull videos tagged dance and display them on Rate My Dance Moves. The YouTube API is currently the 10th most popular API on ProgrammableWeb with 46 mashups.

To get started you need to sign up for a developer account. That will give you the developer id required to use the API.

Using the API

The major API methods are for retrieving lists of videos, which you can do by tag, user, user favorites, and featured. The information returned from the list methods is usually enough to display a video on your site. All you have to do is plug the video id into the web snippit below.


<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/ID&autoplay=1">
</param>
<embed src="http://www.youtube.com/v/ID&autoplay=1"
type="application/x-shockwave-flash" width="425" height="350"></embed>
</object>

Most of the information you need is in the video list methods. However, if you want a list of comments or channels for the video you’ll need to call the get_details method.

One complaint I had with list_by_tag is that the results come back ordered by relevance rather than recency. That means if you want to build a self-updating site you need to either regularly crawl the entire result set (results are paged) or sit on one of the RSS Feeds.

API Wrappers

There are good libraries for using the YouTube API with Perl, Ruby, and .NET. If you’re using another language, say Java, PHP or Python, you’ll have to write some code yourself. I’ve included links to example PHP and Python code and listed an example Ruby program that you can use as a template for whatever language you’re writing in.

There’s two competing Perl modules, but Hironori Yoshida’s WebService::YouTube and WebService::Youtube::Feeds seem best based on the recent development activity and strength of documentation. His is the only wrapper which includes support for the feeds, nice since the feeds have functionality thats not in the API (namely list by recency).

Shane Vitarana released a YouTube Ruby Gem after I’d built RateMyDanceMoves. Too bad, since it seems like the most polished of all the wrappers.

Eamonn Flynn has a .NET wrapper for the YouTube API.

There doesn’t seem to be a packaged PHP library but these two tutorials from waxjelly should be enough to get you started.
Simple PHP Script Using the YouTube API with Pagination
A More Complex PHP Script Using the YouTube API with Pagination.

ThinkHole labs has some example YouTube API code for Python users. Apparently using the API can be as simple as passing a dictionary to YouTube’s XML-RPC interface.

Code Example

I’d written my own code before the Ruby library came out. I want to show it here so you can see how simple writing your own code would be.


#!/usr/bin/env ruby
require 'open-uri'

tag = "dancing"
per_page = "100"
def_id = "YOUR_DEV_ID_HERE"
url = "http://www.youtube.com/api2_rest?" \
+ "method=youtube.videos.list_by_tag" \
+ "&tag=#{tag}&per_page=#{per_page}&dev_id=#{dev_id}&page=1"

open(url) do |f|
xml = f.read
end

doc = REXML::Document.new(xml)

elements = doc.root.get_elements("//video")
elements.each do |v|
puts v.get_elements("id").first.get_text.to_s
puts v.get_elements("title").first.get_text.to_s
puts v.get_elements("tags").first.get_text.to_s
puts v.get_elements("thumbnail_url").first.get_text.to_s
end

More Info

The Amazing YouTube Tools Collection has a long collection of YouTube tools, mashups, and plugins.

Blaine’s Odeo Extractions

Posted on : 17-09-2006 | By : Tony Stubblebine | In : Uncategorized

Tags: , , ,

0

I fixed the update mechanism for gemjack and now you can see two ruby gems that Blaine Cook extracted from the Odeo code base.

FakeWeb
A test helper that makes it simple to test HTTP interaction

WeightedSelection
A simple library for obtaining weighted randomized selections (like for web AB testing perhaps).

Search Ruby Gem (rdoc) Documentation

Posted on : 14-05-2006 | By : Tony Stubblebine | In : Uncategorized

Tags: , , ,

3

rdoc documentation for every ruby gem

Itch scratched. Now ruby is as good as perl (for me at least). I can’t make heads or tails of a library module unless I can read the API documentation.

So I put up GemJack.com as a place to host the rdoc documentation for every ruby gem. It updates once a day based on polling the ruby gems repository.

Other features like deep search, ratings, comments, RSS feeds, and better meta-data can come later.

ETel 2006: Day 1.

Posted on : 24-01-2006 | By : Tony Stubblebine | In : Uncategorized

Tags: , , , , , , , ,

0

I’m at ETel today, mostly to see old friends but still really enjoying myself. Kudo’s to the O’Reilly conference team for always putting on such great events. Here’s some notes.

RAGI
Every O’Reilly ‘emerging tech’ conference comes up with one technology that is suddenly very easy and very accessible. I think RAGI, a Rails to Asterisk interface, wins this time. I managed to miss the presentation but heard great buzz afterwards. Here’s an O’Reilly introduction. An anonymous Odeo engineer asked about scaling issues in Rails and got back a response that Rails scales well as evidenced by sites like Odeo =)

AstLinux – HA

This is a linux distro tweaked for running Asterisk (mostly the same tweaks that real-time apps get). He’s working on adding in High Availability support which would give people an N+1 architecture. Too buzz-wordy? Key detail was that HA would work better and be impemented sooner for VOIP.

Zork on Asterisk.
Awesome! Coolest demo of the day goes to Zasterisk, a project to let you play Zork over the phone. It’s does Asterisk to speech recognition (Sphinx) to Zork to text-to-speech (Festival) and back out.

Imagine playing Zork while on hold or playing a MUD during your commute (VMUD).

VC Fireside Chat.
Sort of dreading this one but the others in the time slote didn’t look good. Turns out Marc Hedlund was on the panel. Point was start off with a product for yourself, but know when to make the switch to a product for others.

Other VC talking about the types of people he sees in early stage investing (spore stage). Two. One with a plan and no product. The other with a hack but no plan. He’s especially interesting if someone has already payed for the hack.

I think the key concept in those two points is that it’s extremely important to prove that someone likes the product (important if you’re trying to get investment).

Favorite phrase of the day was along the lines of: vc’s blog in order to ‘chum the waters’

Marc gave more advice, be plain spoken. Common theme in his engineering management. Complexity is a sign that you don’t understand the problem. Plain speech also gives people the impression that you know what you’re doing. Convoluted speech just gives people the impression that _they_ don’t know what’s going on.

More Marc. Hit it where they ain’t. Find a need that nobody is talking about and go after that. It’s not that you’ll be the only person in the space, but that you’ll be in the first wave.

Quinn Weaver. Open Source is viral marketing. If you create software that is used my millions you can create a company after. Another example of having proven customers. MySQL is a good example of a funded company and 37Signals of a private company. His company Fairpath is planning to give away a Perl to Asterisk software, Dido. Release tomorrow. I like Quinn.

Usability.
A YakPak guy asked who did not have a microphone on their computer. Several Mac people raised there hands. My hand went straight to my forehead.

Favorite Encounter.
Cooper Marcus of Spark Parking. He’s got a nice clear business model, pragmatic goals, and cool tech that involves phones and gluing wireless devices to the ground. He’s also Lowell ‘90.

Online Ruby Training

Posted on : 17-07-2005 | By : Tony Stubblebine | In : Uncategorized

Tags: , , ,

2

Scott Gray, the founder of UserActive, was talking to me about how important hands-on learning is to any sort of training. We talked a little bit about me writing a Ruby or Ruby on Rails class for UserActive and I wanted to get a sense for how the classes work.

I started with Learning PHP. The class is self-paced, you read lab material and type code into an integrated programming sandbox. Then at the end of the lab you take a short test or do a short programming assignment. A grader looks over your work and gives you feedback.

The hands-on piece works! The programming sandbox is really useful and gives you a chance to immediately hack on whatever the lab is teaching you.

The Learning PHP class was geared towards people new to programming or new to the web, for instance there’s a “What is a variable” section. That got me thinking, how would I gear a Ruby on Rails tutorial, towards beginners or towards experts.

Rails has a real following among high level programmers because it abstracts a lot of menial details while also offering enough flexibility to override the defaults. It looks like a Java killer so it’s ending up in a lot of flame wars about how enterprise ready it is.

People haven’t explored how easy it is for designers or part-time programmers to use. Is it a PHP killer? Well, you don’t need to know any Ruby to get a Rails application up. That’s a good sign. You usually don’t need to know any SQL. That’s another good sign.

I wonder if the Model-View-Controller model is too abstract for most non-programmers? In my experience, people will do fine. Our web producers work with a much more abstracted system.

In any case, I think the online lab + sandbox model that UserActive offers would be a great introduction to people who probably aren’t going to go through the trouble of installing Rails themselves.

In the mean time, here’s the full UserActive catalog.

Web Startups for Cheap

Posted on : 02-07-2005 | By : Tony Stubblebine | In : Uncategorized

Tags: , ,

1

I had a nice talk last night with a friend who’s working on a web startup. I’m excited for him – the barrier to entry for starting your own company has plummeted.

Software and software techniques have solidified. An agile, keep it simple, release as soon as you have value development methodology is emerging from the bureaucratic promise everything and deliver crap, marketing driven dot-com mess. There’s also a much better understanding of how to get and keep users and how to market your company on the cheap.

Here’s the list of reading material that everyone starting a web company should be familiar with.

Ruby
Ruby on Rails is a web framework that lets you get web sites out fast. Very fast. And it has all the flexibility and robustness that you hope you’ll need down the road when your site becomes popular.
www.rubyonrails.com/

KISS Development
Ruby’s brought to you by 37 Signals, the company behind Basecamp. They’re also on the cutting edge of low overhead development methods. It’s worth following their blog (although they’ve watered down their content with generic blog entries).
37signals.com/svn/
37signals.com/svn/archives2/scoble_wonders_if_37signals_is_influencing_microsoft.php
37signals.com/svn/archives2/entrepreneurs_angels_and_the_cost_of_launch.php

Passion
Kathy Sierra, who created O’Reilly’s Head First Series, has great writing on what’s going to make your users enjoy their experience and come back for more.
headrush.typepad.com/creating_passionate_users/
headrush.typepad.com/creating_passionate_users/2005/06/building_a_succ.html

Blogvertising
Hugh Macleod’s blog, gapingvoid.com, teaches blogvertising by example. You think he’s talking explicitly about blogvertising or maybe making crass commentary on society. Then you realize that you want to buy some stormhoek wine and a english cut $3000 tailored suit. You just got sold to. I’m still not sure how I feel about that. All I do know is that I want a new suit.
www.gapingvoid.com/

Ruby/Rails/Fedora/Apache2

Posted on : 02-07-2005 | By : Tony Stubblebine | In : Uncategorized

Tags: , ,

0

I had much more trouble with this install than I did for Ubuntu, probably because I was trying to do more.

I started by trying to get packages with yum.
yum install ruby irb ruby-devel

That lead to a dependancy issue. I needed apxs, but what package is it in? Ended up being in the httpd-devel package.

Then I moved on to installing mod_ruby. Having the ruby interpreter run inside Apache seems like a good idea – at least from a performance standpoint. Here’s the guide I worked from.
http://www.modruby.net/en/doc/?InstallGuide

However, it turns out that mod_ruby comes with a slew of namespace complications. From the rails wiki, “considered unsafe to use mod_ruby and Rails with more than one application.”

FastCGI is a safer alternative. The rails wiki has good setup documentation:

http://wiki.rubyonrails.com/rails/show/RailsOnFedora

I did run into trouble with MySQL – I needed to tell Rails where the mysql.sock file was. Here’s a ticket explaining the problem.
http://dev.rubyonrails.com/ticket/200

Ubuntu on Rails: Getting up to speed with Ruby on Rails and Ubuntu

Posted on : 27-06-2005 | By : Tony Stubblebine | In : Uncategorized

Tags: , ,

1

I got my introduction to Rails with O’Reilly’s Rolling with Ruby on Rails article. Unfortunately, it’s very Windows oriented. Thankfully there’s great docs for getting everyting going on Debian or Ubuntu.

Install Ruby on Rails
The Ruby on Rails wiki provides a great tutorial. Basically, you apt-get install a bunch of ruby packages, manually install rubygems (a ruby module manager a la CPAN), and then use gems to install rails. I needed to have sudo to run most of the commands.

Read About Rails
You can start on page 2 of the O’Reilly Article, since the first page is all about installing on Windows. There’s more Windows-centricity to work around, see below.

The Webserver
The article recommends using the supplied webserver. I used that for now since I was more interested in getting a taste of Ruby than I was of Apache conf files. Initially I started the webserver in the background, but it spits a lot of output. You’ll probably want to redirect the output with a command like.

ruby script/server &> /tmp/rubylog

The Database
The article assumes a GUI MySQL admin interface. I prefer the command line. Here’s a sql file that handles all the table creations for you.

Gotchas
The database/model naming convention is goofy. Table names are plural, foreign keys singular, and models singular. That tripped me up. I’d much prefer the table names be singular so that they can match the foreign keys.

A lot of the commands in the article were written for a Windows server so some of the slashes are backwards.

Resources
Rolling on Rails, Part Two
Explanation of Minutae in the Rolling Articles
Programming Ruby, the book, online, for free.
Ruby on Rails site