Author Archives: Tony

Recursive custom to_json in Ruby for arrays of objects or nested objects

Let’s say we want to customize the json template for an object: class User def to_json super(:except => [:password, :password_salt, :encrypted_password, :last_sign_in_ip, :updated_at, :current_sign_in_ip, :remember_token, :reset_password_token, :remember_created_at]) end end Apparently this is fixed in Ruby 1.9 but for now only converting an object [...]
Posted in Software | Tagged , , , , , | Comments closed

Deduping join data in ruby based on multiple attributes

In the past I created an app using Rails built in HABTM and no unique index on the join tables. I’m more into the has_many :through choice today. In order to migrate my data with a unqiue index, I had a bunch of de-duping to do. It was a bit trickier than [...]
Posted in Software | Tagged , , , , , | Comments closed

More cool stuff with ruby’s tap method

I had to write up a quick data processor at work today and I wanted a decent output at the end of execution. The ruby tap method came in handy here. class AssetDeliveryPopulater   def self.populate results_text = [] asset_secrets_count, asset_delivery_count, asset_not_found_count, asset_delivery_creation_errors = 0,0,0,0   Email.all.tap{|emails| [...]
Posted in Software | Tagged , | Comments closed

Tap before you squash

Tap is a pretty awesome ruby method I recently discovered. Let’s say I have the following request: post '/api/v1/users/', params.merge(:sig => Authentication.calculate(TestAuthData.secret_access_key,params.to_query) ).to_json I realize [...]
Posted in Software | Tagged , , | Comments closed

RSpec 2, Sinatra and Mongoid example

I spent yesterday coding a very abbreviated version of an authentication service that uses Sinatra, Mongoid and RSpec 2. It took more than a couple hours because there are so many outdated code samples on the web that just don’t work. I put my code up on github for people to see. [...]
Posted in Software | Tagged , , , , , | Comments closed

Rails Authentication with Devise and CanCan part 2 – Restful Resources for Administrators

About two months ago I wrote an article on getting started with Devise and CanCan. Since then, I’ve implemented the Devise + CanCan combo on three projects and wrote a couple specs for Ryan Bates to help improve CanCan functionality. This article will focus more on Devise with some CanCan sprinkled in there. [...]
Posted in Software | Tagged , , , , , , , , , | Comments closed

Gym Shuffle

Gym Shuffle is the world's first workout randomizer for your iPhone.
Posted in portfolio | Tagged , , | Comments closed

Better Human Race

Better Human Race is the easiest way to raise money for charity. Search with Yahoo, Shop with Amazon, Connect with Facebook, and use our toolbar. I am co-founder and currently the developer of all Better Human Race technology.
Posted in portfolio | Tagged , , , , , , , , , , , | Comments closed

Rails Authentication with Devise and CanCan – Customizing Devise Controllers

I’m tired of spending loads of time creating user authentication systems with permissions or swimming against the current to customize what’s available. There’s great open source stuff out there but until now, I haven’t gotten the full package with really easy customization. The Devise and CanCan combo for user authentication and permissions in Rails is my [...]
Posted in Software | Tagged , , , , , , , | Comments closed

Safely turn off Spotlight and remove from menu bar in OS X Snow Leopard

I don’t like the Spotlight indexing and search that is included in Mac OS X. I use Quicksilver instead but have been procrastinating turning off Spotlight. Well I finally got around to disabling Spotlight and wanted to go about it in a safe way. I came across too many forum posts doing dangerous things [...]
Posted in Software | Tagged , , , , , | Comments closed