May 2007 Archives

Session audio recordings hopefully on the way...

… but, in the meantimne, enjoy the “JQuery” and “Automated Scaffold” BoF audio recordings.

Donwload - [JQuery BoF]

Donwload - [Automated Scaffold BoF (Streamlined, ActiveScaffold, Hobo, AutoAdmin)]

As for the sessions, I ran into a minor snag with my audio recordings. While the MBP mic picked up the audio adequately, it also did a fantastic job of capturing my typing during several of the sessions. Another RailsConf attendee, one with a radio background, is attempting to clean the audio up. With luck, I’ll have some sessions posted soon.

Posted by evan on May 27, 2007

RailsConf 2007 Day 1

After a day of tutorials covering Streamlined and Script.aculo.us, the first official day of RailsConf kicked off today to Chad Fowler and a yukalele. Yes, a yukalele.

Minute musical machinations aside, it’s been a helluva first day.

The most amazing thing about RailsConf is the sheer breadth of the community. I have been introduced to more technologies in a day than I can easily recount off of the top of my head. To name a few, there’s GeoKit - a Rails plugin for location-based apps that uses Google for geocoding, Telegraph - a Rails plugin that provides a DSL for easily generating voice user interfaces through Asterisk from Rails, UJS - Rails plugin for generating accessible JavaScript for Rails, Merb - a performance plugin for Mongrel that considerably improves Mongrel’s ability to handle uploads, RAAKT, LiquidLayout, ActiveWarehouse, and RVideo – just to name a few.

So far, the most impressive I have seen, by far, has been Telegraph. Jon Palley’s demo simply knocked my socks off. Jon essentially built JAHJAH in about 10 lines of code. If you’re too lazy to follow the link, his simple web app took 2 phone numbers as inputs and connected both numbers via a VOIP call initiated from his Asterisk PBX. I’m dead serious: 10 lines (give or take a few). Telegraph looks to be that powerful. It provides functionality for statusing and managing call states including call recording. Walking out of the sesion, my brain was abuzz with the possibilities. Feel like building your own WebEx or web-enabled conference calling system? Honestly, it looks pretty darn simple from the demo.

Granted that another conference attendee told me that developing for Asterisk can be it’s own pain.

And, so far, I’ve totally neglected to mention the bevvy of improvements that DHH announced for Rails 2.0 today in his keynote: a “new” (it’s been in the wings for a fair bit although I haven’t played with it) REST-centric approach to controllers allowing them to render any number of different types of views with support for rhtml, builder, and XML (although still generting XML that is tightly bound to your DB schema) out of the box, declarative breakpoints in Rails that will drop you instantly into IRB at the breakpoint, and a new and DRYer DB migration syntax, to name a few.

It’s been a full day and my list of technologies to research and review is only partially covered above.

And there are two more days yet. :D

Posted by evan on May 19, 2007

RailsConf 2007 session audio to follow

I’ve obtained the permission of several RailsConf presenters to post recordings, made courtesy of my laptop, up here. I hope to have them up sometime Monday or Tuesday evening after getting home from RailsConf and getting my bearings.

Watch this space.

Posted by evan on May 19, 2007

At RailsConf 2007!

I just pulled into RailsConf about 30 minutes ago and am now sitting in the Portland Convention Center eating breakfast – and oddly already running into familiar faces from years back. I’m off to my first tutorial session in 20 minutes.

Posted by evan on May 17, 2007

Searching MediaWikis with Ruby (or treating MediaWiki a little like a database)

Here’s a little treat that I threw together to help me search Wikipedia for film data. It’s pretty simple. Example usage below:

wikipedia = MediaWiki::Search.new "http://en.wikipedia.org"
result = wikipedia.search("Firefox")    
if results.is_a? String
    # Then I've obtained the content for an actual page in a MediaWiki
else 
    # I have an Array containing Hashes with metadata about the top 20 candidates
    # Now, for giggles, I'll get the content for the first hit
    html = Net::HTTP.get_response URI.parse(result.first[:url])
end

The returned Array of Hashes, in the second case, has three keys: :url - The complete URL to the page in the MediaWiki :title - The Wikipedia page title :weight - The percentile weight supplied by the MediaWiki search.

Pretty simple? I thought so.

Code follows:

require \'net/http\'
require \'uri\'

module Wikipedia
  class Search

    SEARCH_PG_PTN = \'wgPageName = \"Special:Search\";\'
    SEARCH_ITEM_START_PTN = \'<li style=\"padding-bottom: 1em;\">\'
    SEARCH_ITEM_END_PTN = \'</li>\'
    ITEM_HIT_START = \'<a href=\'

    # <i>wiki_url</i>: The URL of the wiki to search
    def initialize(wiki_url)
      wiki_url.chop! if wiki_url =~ /\\/$/
      @wiki_url = wiki_url
      @search_url = wiki_url + \"/wiki/Special:Search\"
    end

    # borrowed from Net::HTTP
    def fetch(uri_str, limit = 10)
      raise ArgumentError, \'HTTP redirect too deep\' if limit == 0
      response = Net::HTTP.get_response(URI.parse(uri_str))
      case response
        when Net::HTTPSuccess     then response
        when Net::HTTPRedirection then fetch(response[\'location\'], limit - 1)
        else response.error!
      end
    end

    def search(query_str)
      response = Net::HTTP.post_form URI.parse(@search_url), :search => query_str, :go => \"Go\"
      if response.body =~ /#{SEARCH_PG_PTN}/
        multiple_search_results_in response
      elsif response.is_a? Net::HTTPRedirection
        fetch(response[\'location\']).body
      else
        response.body  
      end
    end

    private
    def multiple_search_results_in(response)
      raw = response.body.split(/#{SEARCH_ITEM_START_PTN}|#{SEARCH_ITEM_END_PTN}/)
      hits = raw.select { |l| l =~ /^#{ITEM_HIT_START}/ }
      hits.collect do |h|
        h =~ /href=\"(.*)\" title.*>(.*)<\\/a>.*Relevance: (.*)%/
        { :url => @wiki_url + $1, :title => $2, :weight => $3 }
      end
    end
  end
end

Update: And it still isn’t 100% functional yet either. It turns out, that after beating my head for a whole weekend against MediaWiki, that there are several permutations of user inputted metadata into MediaWiki. Simply fetching the movie poster would be simple enough. However, the writer, director, and starring sections are quite a bit more complex. I’m actually fairly close. Actually, the problem can be more easily solved if I simplify the regexps to just yank out the contents of entire cells within the table, just strip the HTML, and otherwise leave the cell contents intact without making assumptions about the comment (and further borking the formatting).

Posted by evan on May 12, 2007

"SimpleSkype"

O, happy day! One of the WxRuby devs (Alex Fenton) was kind enough to track down the memory leak. I understand that the fix should be released with the 0.40 verison in the next few days!

Prior to hearing word back from Alex, I had rewritten the entire UI in Ruby/Tk. I have to say, it was amazingly simple. IO went from knowing nothing about Ruby/Tk to having a complete Tk GUI in just a few hours. However, sadly, there doesn’t seem to be a a method to access the “Metal” look and feel. For me, this is a huge plus for using WxRuby. Being able to turn off the window controls significantly simplifies the usability of the application.

I’ll post the code for both version of “SimpleSkype” after the coming 1.0 release – and a rebranding. I don’t want to infringe on Skype’s trademark as this can be detrimental to one’s sanity.

I also just discovered Rubyscript2exe which promises to greatly simplify the deployment of my app to OS X! And here I thoughtthat I was going to have to write one from scratch. Man, I love the free software community!

Posted by evan on May 06, 2007