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

RailsConf 2008: Friday Early Afternoon

Dialogue Concerning the Two Chief Modeling Systems

  • it’s a Play

(again you should read the slides)

  • choosing the right name will make the dev think about this model and give it the right property
  • Jim keeps saying we’re skipping layers
  • using story cards
  • jammed up over reoccurring events
  • objects = data + behavior, so you can’t just talk about the data (rows/tables), you must look at behavior
  • pull out the Class, Responsibilities, and Collaborator cards
  • card only useful for organizing your thoughts not need to fill them all out
  • “temporal expressions”
  • CJ Date: apparently wrote a lot about data modeling
  • Code Smell in Refactoring by Chad Fowler

Flexible Scaling: How to Handle 1 Billion Pageviews – TJ

  • WoW: you see all kinds of human behaviors: Mafia, Philantropis
  • Building games on Facebook
  • He’s the author of Warbook: Rise of the Infernals
  • w/i a week he had to fix stuff
  • w/i 3 weeks had to rewrite
  • started with firebug’s net tab
  • look at your logs: pl_analyze
  • iostat
  • you need tools, but you also need strategies
  • don’t need it? ditch it.
  • slowing it down? simplify it.
  • logging it? stop
  • selecting it? cache it.
  • memcache
  • put sessions in cache
  • no-select design
    • use memcache
    • cache_fu already does this
  • using ec2
  • 1 db box
  • 1 memcache box
  • 1 static file
  • X mongrel boxes
  • The Hard Part
    • Scale Everything Else
    • Scale your deploymnet
      • use capistrano
    • Scaling your support
    • community management
      • give them updates every day
  • server cost $2000 a month
  • you need money
  • warbook makes $100,000/month
  • 1.5 million users
  • 16 million page views
Q&A
  • remove transactional saves
  • save per fields
  • how to solve the persistence problem on ec2? db not on amazon
  • which facebook lib? started with rfacebook, facebooker, bebo

Slides

#railsconf2008

RailsConf 2008: Friday Late Morning

Entrepreneurs On Rails – Dan Benjamin

  • Successful biz fills a need
  • What do you need
    • paper work important, expressing the idea idea is better, being flexable on that idea
    • energy
  • so much you have to do before hand, why are you doing this?
  • set goals – we need to do x by y, if we don’t get there we’ll change things
  • have a path to cash
  • have an exit strategy
  • why create a company
    • Liability – legal protection from your bugs :)
    • Taxes – more buying power, talk to an accountant
    • working with other companies
    • easy of working with other companies
    • Ownership – knowing who gets what
    • perception of credibility – but don’t try to be what you are not (cd of office noises for phone calls)
  • types of business
  • Fictitious Name
  • LLC is a good idea
  • You don’t have to do this in Delaware
  • hire lawyer/accountant
  • your website should be very clear about what you wanted
  • we build things we need, but if you look at say moms with kids at home you have a much bigger audience
  • marketing. peepcode logo (myers: I’ve always thought it looked like a lingerie ad)
    • you will spend 40% or more of you time marketing
  • making it work is the hard part not the (unknown) paper work
  • hard part: adjusting the the lack of stability
  • common to be in a feast or famine situation
  • co-working is a way to get an office with others
  • creativity zone
  • biz deals goes like this
    • NDA – worth it for a 10k deal to have your lawyer look at it
    • proposal – 40 pages shortest he ever did
    • contract – you should write the contract, here’s what I’ll do, he’s what I’m liabile and not liabile for
    • Functionality Outline – evolution of a statement of work
    • getting the money – net 30, net 60, net 15, net 0 – put it in your contract, also “there is a 2% fee for late payments”
  • products: it’s about liability
  • TOS/privacy policy – be clear, be up front
  • ways to get money (see slides)
  • on hivelogic he’ll post a sample SOW

Surviving the Big Rewrite: Moving YELLOWPAGES.COM to Rails

  • biggest website at&t runs
  • all rails
  • 1 year ago 1/2 as big
  • (long slides)
  • why a big rewrite? – it’s a great bundler
  • no automated tests, new features really hard
  • lots of code being replace with site redesign
  • hard to leverage
  • java: get around this web thing with design patterns so you get to the real business of talking to middleware
  • devs except that not everything they want will get done
  • core team never more that 4 – trying to keep it small
  • they looked at django and ejb3/jboss
  • no to django
    • better automated testing integration (hear hear)
    • more platform maturity
    • clearer path to C if necessary for performance (I don’t agree with that. Python + C is easy, plus you have psyco and ctype that let you get C performance or use c libs with pure python)
    • developer comfort and experience
  • not convinced anyone needs MOM
  • only one developer that knew rails at the start
  • project got stuck
  • project lead appointed to make decision-making and communication with executive team, or at least the appearance
    • sometimes she decided in private with her bosses
  • freeze current site
  • if it’s not simple to decide how to change a current site behavior, don’t change it. save it for a later phase.

(it’s worth it to read the slides, even for a non rewrite project. The slides are probably have too much on them, but that’s good for you)

  • they spent an amazing amount of time communicating what was changing.
  • F5 Load Balancers
  • switched to erubis in web tier
#railsconf2008