Currently Playing

Like you care…

XBox 360

  • Dead Rising (love it)
  • GTA IV
  • Mass Effect
  • Beautiful Katamari
  • Half Life 2 (replaying for the achievements)
  • Castle Crashers (need to try online coop)
  • Braid (hurting my brain)

PS2

  • Champions of Norrath 2 (waiting to visit Jason and hack our way thru)
  • God of War (suck in that room of blades on a grid that needs timing that I can’t do)

Wii

  • Mario Galaxy
#video-games

Validing with an XSD in ruby

    xml = generate_xml
    require 'xml'
    Tempfile.open(self.class.to_s) do |tmp|
      tmp.write(xml)
      tmp.close
      document = XML::Document.file(tmp.path)
      schema_doc = XML::Document.file("some.xsd")
      schema = XML::Schema.document(schema_doc)
      assert document.validate(schema), "the xml isn't valid.  look above for error."
    end

A review of ruby s3 librarys

gem install s3sync

Has the right idea about how to store files, but the lib it uses does not abstract things enough. Does not use http keep alive to avoid the slow startup of tcp. Does not have an easy way to iterate over all keys in a bucket, but this helps to do this:

  def each_object(bucket_name)
    next_marker = nil
    while true do
      response = CONN.list_bucket(bucket_name, {'marker' => next_marker, 'max-keys' => 10})
      response.entries.each do |s3obj|
        yield s3obj
      end
      break unless response.properties.is_truncated
      next_marker = response.entries.last.key
    end
  end

gem install aws-s3

Again no built in way to iterate over all keys. Has problems with ‘/’ at the start of file names.

gem install right_aws

Uses the same http connection, can iterate over all keys with a single method (though, it makes a full array of all the keys rather than allowing you to supply a block). Here’s my thumbnailer:

  require 'rubygems'
  require 'right_aws'
  require 'RMagick'
  require 'pp'

  s3 = RightAws::S3.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

  picture_bucket = s3.bucket('OurPictures')
  thumbnail_bucket = s3.bucket('OurPicturesThumbnails')

  picture_bucket.keys.each do |key|
    thumbnail_key = RightAws::S3::Key.create(thumbnail_bucket, key.name)
    next if key.name !~ /.jpg$/i
    next if thumbnail_key.exists?
    image = Magick::Image.from_blob(key.data).first
    image.change_geometry!('256x256>') do |cols, rows, img|
      img.thumbnail!(cols, rows)
    end
    thumbnail_key.put(image.to_blob, 'private')
    p thumbnail_key.full_name
    image = nil
    GC.start
  end
#ruby

RailsConf 2008: Saturday Eaily Morning

(mostly randy here again. I was putting up my first ec2 instance. :)

Saturday Keynotes

  • funny video from the RailsEnvy guys about testing
DHH introducing Jeremy Kemper
  • Jeremy has done a buttload of work lately in the Rails core
  • dhh on a coding vacation?
  • some people think about one part of rails Jeremy thinks about the whole thing
Jeremy’s talk about Rails 2… where it’s going, etc
  • “it’s all about resources”
  • “we shed a lot of fat” – split things off into plugins
  • “we gained speed” – “i’m not concerned about rails being super super quick” — huh???
  • 1600 patches… it’s hard to read all that code! so we embraced git and lighthouse instead of svn and trac
  • Rails 2.1
    • refactoring
    • documentation
    • thinner + faster
    • (he looks exhausted… too much free five runs beer and cheese pies)
    • he wants rails to look pretty.
    • use rubyprof
    • merging migrations
    • making timezones fitter, happier, more productive
    • migrations now have change_table block for modifying tables (just like create_table)
    • gem dependencies
    • improved memcache… making it a first-class citizen in rails. memcache-client now bundled with rails
    • much of what he’s covering Myers read in this tutorial on rails 2.1
    • dirty – AR now knows when an attribute has changed
      • message.body_changed?
      • message.body_was
      • message.changed?
      • enables partial updates
    • smarter :include — it’s not as eager to join on the first query. this seems like it will be slower, but benchmarking supposedly proves that querying the join table on an as-needed basis is faster
    • named_scope
      • so you can say user.messages.recent instead of user.recent_messages by saying named_scope :recent, :order -> 'created_at desc’ in the Message model
    • Message.scoped(:limit => 10)
    • jruby -S jetty_rails (run rails on jruby)
    • rbx script/server (run rails on rubinius)
    • rails now runs on ruby 1.9
  • rails 2.1 out today (a gem update at 10:14am didn’t do anything tho… it will be later… so not a Steve Jobs “and you can buy it right now”)
#railsconf2008

RailsConf 2008: Friday Night Keynote

DHH keynote

  • surplus of productivity
  • company’s needs that special in the problems we encounter
  • We ceded flexibility
  • “people like choices a lot more than they like to choose” – dhh, just now
  • why is this not in the framework, someone make this choice for me
  • we decided tech matters
  • “great people rarely fail because of poor technology” – but come on, do you want to just “not fail”?
  • we cared about us
  • “ruby is designed to make programmers happy” – matz
  • the surplus will not last forever
    • why? the mainstream will copy rails (dhh doesn’t think so)
    • dramatic alternative arrives (dhh doesn’t think so)
    • rails becomes the mainstream
  • business as usual – which is blowing your surplus, running at 110% all the time
  • another day, another fire
  • Lost in the mechanics – when running at 110% means you can’t see anything else
  • fatigued, disinterested, passionless
  • it’s just a job – most depressing statement
  • one place to invest that will pay back: you
  • 1:10 programmer productivity
  • no one is born a rock star programmer, you become it
  • recharge tangentially – or some other word, do something else besides sit in front of a computer all day: making spoons, play the banjo, fly a plane
  • can’t just focus on one muscle
  • speaking about taking people to the next level: sleep more (applause)
  • stop to read paper
  • suggested reading
    • my job went to india (and all i got was this lousy book)
    • implementation patterns
    • innovator’s dilemma
    • tufte’s envisioning information
  • all this helps you judge what is valuable or not
  • is this lack of a seam on the iphone what matters.
  • program less
  • when you have only 10 hours to program a week, you know what matters
  • sometimes good to start a project from scratch
  • share: you benefit from the sharing
  • “the purpose of playing this game well is to be able to get the best position of the next game” – alistair cockburn, 1999
  • 4 day work week means more focus
  • summary: this surplus is not going to last forever don’t blow it all on hookers and fur coats
#railsconf2008