..flipping the script..

Future of web

Published October 19, 2012 - 0 Comments

Lately I’ve seen various specs show up that seem to look promising and could potentially be the future of the web (some of these items have been evolving for a while but aren’t necessarily mainstream yet):

Rich Web Client

source: http://www.w3.org/2006/rwc/Activity.html

  • XMLHttpRequest (Level) 2
  • Server-Sent Events (SSE)
  • Web Sockets
  • Web Database
  • Web Storage
  • Web Workers

Web Applications

source: http://www.w3.org/2008/webapps/

I could seriously spend days reading through stuff on the w3c site, there’s TONS of information there.

Node.js Resources

Published September 6, 2012 - 0 Comments

I’m interested in node.js, in fact I have been since the 0.1.x days but I’ve never sunk real time into it. Right now I’m gathering a list of resources to dive in and get started, here they are so far:

  • http://nodejs.org/
  • https://github.com/creationix/nvm
  • https://npmjs.org/
  • http://toolbox.no.de/
  • http://www.nodebeginner.org/
  • http://book.mixu.net/index.html
  • http://www.nodetuts.com/
  • http://nodebits.org/
  • http://howtonode.org/
  • http://www.youtube.com/watch?v=jo_B4LTHi3I&feature=youtu.be
  • http://radar.oreilly.com/2011/07/what-is-node.html
  • https://github.com/kissjs/node-mongoskin http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js

Sublime Text 2:

Miscellaneous (not node.js):

Shared Mongo Config in Rails

Published March 28, 2012 - 0 Comments

I’ve developed a handful of Rails (3.x) applications which all used MongoDB as the persistence layer. In fact, I’ve yet to build a SQL backed Rails application during my “day job”. Thus far I’ve preferred Mongoid vs. MongoMapper, primarily because of the documentation. Although, I haven’t gone back to look at MongoMapper in almost a year…but at this point, I don’t have a need to change.

Typically with Mongoid, you’ll have a mongoid.yml file that has your database configuration. That’s really super when you only use Mongoid to interact with your database. However, if you end up using another library/gem that needs to work with your database you’ll have to duplicate your database configuration. NOT! Being a star developer (you know you are), you’ll come up with some solution so you don’t have to copy your database configuration around to multiple files.

I ran into this situation when I began using Qu. Qu is a library for “queueing and processing background jobs”. It’s easy to use, has a dandy API and works with either MongoDB or Redis. It might be worth mentioning here thatBrandon Keepers, the creator of Qu, worked for Ordered List which was recently acquired by GitHub.

Anyways, back to my solution for not duplicating database configuration. I’ve recently started using the settingslogic gem on my Rails project to manage my application configuration. I have a “application.yml” file that now contains my database configuration. Using settingslogic is not a requirement, in fact Rails has a built-in method for dealing with application configuration, so use what you like.

Once I had my database configuration in a file, I setup two initializers: one for Mongoid and one for Qu. The best way I found was to create a MongoDB URI formatted string. Check out the following gist:

Loading gist…

Now Mongoid and Qu use the same database configuration settings and it all comes from one file. Of course, you might want Mongoid and Qu to use different configuration settings, but hopefully you can see the benefit to my approach.

Now that I’ve checked the time, I’m going to get 5 hours of sleep. So, like a chef, I’m cooked.

Make some objects for goodness sake

Published March 28, 2012 - 0 Comments

There’s been lots of discussion lately about making Rails more object oriented. I’m not sure what spurred all the recent discussions, but I think it’s great that there are lots of discussions spreading around the community.

When I first began learning Rails I quickly bumped into those articles talking about fat models and skinny controllers. I quickly followed suite as it seemed to make sense; initially. Then I got to a point where thought, “why not put some of this stuff into plain old ruby objects in the lib directory?”. I began doing that and have continued doing that ever since and I, as many recent Rails developers have written and talked about, think you should too.

Some of the recent libraries, posts or books related to more object oriented Rails include:

Prior to all of those, and I’m sure I’m missing some, I heard Jeff Casmir’s talk at RailsConf 2011. He talked about potentially getting away from the dogma of fat models, skinny controllers by suggesting people create more libraries/gems, use the presenter pattern, etc.

In parting I’d just like to say, don’t be afraid of having code outside of app/models and app/controllers. Ruby is object oriented and Rails is a framework that is built with Ruby, so go ahead and use your bad ass OO skills already! Rails provides lots of conventions and opinionated views, but that doesn’t mean you can’t do what makes the most sense for your applications. And please, feel free to use the lib directory or even create some gems that you could potentially reuse. Hell, get real crazy and build some engines! (I’ve built 3 in the last 2 months).

Underscore in IRB

Published March 26, 2012 - 0 Comments

I was watching Play by Play: Aaron Patterson today and saw him use a cool feature of IRB that I never knew existed, the underscore.

Open up an IRB console and paste in the following:

ruby {name: "tenderlove"}

Now type the following in your IRB console:

ruby puts _[:name]

You should see “tenderlove” printed out! The underscore stores the last value from your IRB session. In this case it’s a Hash that you created at the first step. Pretty awesome right?

Map/Reduce With Hadoop and Ruby

Published December 18, 2011 - 0 Comments

Unless you’ve been passed out at a bar you’ve probably heard about Map/Reduce, Hadoop or just the “cloud”. Afterall, it’s the “next big thing”, if you’re into that sort of stuff.

At work the “cloud”, Map/Reduce, analytics are all the hotness. I figured I’d try out the Hadoop Streaming API by piping data in and out with Ruby. I started out with a very small text file. Next I wrote the mapper which reads lines of text from STDIN and emits results through STDOUT.

The reducer would be as trivial as the mapper except that it needs to keep track of when the key changes. Unlike the standard reducer API which provides a key with all of its values, the streaming API doesn’t do that. Besides that the reducer (at least in my trivial example) is rather simple.

The best part, is you can do all of this without ever setting up or using Hadoop! Now wait a minute, I thought I was trying out the Hadoop Streaming API. Well, you can do all the work and even test your mapper and reducer without using Hadoop. By simply piping data into and out of the mapper and reducer you can simulate what Hadoop will do. If you want to get real fancy pants you can throw in an intermediate sort before piping data to your reducer.

Check out my gist which does the minimal thing before getting Hadoop involved.

Pretty cool stuff I think. Now I just run this with a real cloudy Hadoop setup and everything will be real groovy!

Becoming Enumerable

Published August 18, 2011 - 0 Comments

My first post on RubySource, hasn’t been published as of 08/18/2011, covers using mixin’s in Ruby. Shortly after writing that article I ran across a presentation titled “The Enumerable Module” presented by Haris Amin at Cascadia Ruby Conf 2011. The general idea is that you can make your classes enumerable (e.g. have lots of cool methods you’re used to seeing when working with Arrays, Hashes, etc).

Since the process of making a class enumerable requires the use of mixin’s I figured I provide a brief demonstration of how to do it.

class Followers
    include Enumerable

    def initialize
        @followers = []

    def add_follower(name)
        @followers << name

    def degrees_of_separation(name)
        # calculate

    # must implement the each method
    def each
        # simple in this example
        @followers.each do |val|
            yield val

The Followers class stores an array of values which we iterate over in our implementation of the #each method.

Check it out:

f = Followers.new
f.add_follower 'shaun'
f.add_follower 'cliff'
f.add_follower 'sean'
f.add_follower 'nick'
f.add_follower 'tim'

f.find_all {|val|
  val.match /^s/i
# output: ["shaun", "sean"]

f.collect do |val|
# result: ["SHAUN", "CLIFF", ...]

Sorry for the lame example (e.g. “followers”) but I think you get the point.

Writing for Rubysource

Published August 13, 2011 - 0 Comments

I’ve been writing articles for various online sites (and publications) for the past four years. It really all started after I got to know Scott Delap, the guy behind Client Java. I was a Java 2D and Swing developer from 2003 – 2008, and the Client Java site was a great resource. I ended up doing some consulting type work for Scott and he ended up asking me about writing for InfoQ. I did some trial type posts and ended up getting the gig.

Catching Up with Scala was my first post and was published on August 22, 2007. That post was published jointly with Scott, but my first “solo” post was titled “Has JPA Killed the DAO?”. I ended up writing 32 news articles and 2 featured articles during my 2+ years with InfoQ (my last news article was published on December 12, 2009, titled “IntelliJ IDEA 9: Java EE6, OSGi, Flex and More”).

Before I stopped writing for InfoQ I got in contact with Michael Kimsal, founder of webdev publishing, GroovyMag, JSMag and plenty of other things, about an opportunity to work on the GroovyMag publication (a digital magazine, in PDF format). Here’s the original email I sent to Michael on February 4, 2009:

Hi, I recently started subscribing to/reading GroovyMag and I really enjoy it. I am a software engineer by day (java/swing/flex/python/jython…groovy/grails hopefully) and Java Editor for InfoQ by night/weekends (part-time). I am learning Groovy and Grails because I believe there is a lot of potential and usefulness and I hope to incorporate them into my day job sometime (sooner than later hopefully).

Anyhow, I saw there opportunities to write for GroovyMag and I was wondering how I might be able to get involved. If it seems like a possibility hit me back and we’ll go from there.



I officially got started as a technical editor for both publications (GroovyMag and JSMag) on February 12, 2009 and I continued through April/May 2010. During that time I also wrote several articles:

  • Easy Behavior Driven Development, Using easyb for BDD (sept 2009)
  • Metaprogramming with Groovy, part 1 (dec 2009)
  • Metaprogramming with Groovy, part 2 (jan 2010)
  • Catching Up with Griffon, Q&A with Andres Almiray (feb 2010)

Working on GroovyMag was interesting and frustrating. The frustration usually came from waiting for authors to submit their posts for review and having to sort through some pretty poor grammar and spelling (and believe me, I’m nowhere near perfect myself).

This leads me to my latest endeavor, writing for RubySource. I’ve chosen to take on this opportunity because I’ve been working with Ruby for about 6 months and I’d like to share my experiences and learn more (through the process of writing). I’ve worked with Aaron Osteraas to get started and I’m looking forward to having my first post on the site in the next couple of weeks.

On a side note, I also signed up to be a moderator for the super-awesome RailsCasts site. Ryan Bates has published 278 free screencasts covering all sorts of Rails aspects including lots of 3rd party gems/plugins. Ryan has used moderators to help fight spam, keep the comments formatted properly and help find any mistakes in the videos or the associated source code.

In short, here’s the timeline of my writing/editing career:

  • InfoQ: 08/2007 – 12/2009
  • GroovyMag/JSMag: 02/2009 – 05/2010
  • RailsCasts Moderator: 07/2010 – ?
  • RubySource: 08/2011 – ?