George Carlin

Posted by Matt on June 23, 2008


Farewell George.

Georgecarlin

Congratuations 10% of America! 1

Posted by Matt on June 16, 2008

Today gay couples have won the right to marry in California.

I’m very happy to see that an estimated 10% of our nation now has the opportunity to legally express their devotion and love to another. It’s long overdue.

The holy war surrounding this issue is ridiculous. We live in a free society; meaning that as consenting adults, we’re free to make our own decisions (well, as much as they allow us to).

If you are against gay marriage; great. Opinions are wonderful. However, why would someone legislate someone else’s happiness and fulfillment? The entire point of this existance is to find and connect with others, and marriage is the highest order.

Remember “Life, Liberty, and the Pursuit of Happiness”?
Remember the last time the nation tried “Separate But ‘Equal’”?

Congratuations to all the newlyweds tonight in California!


gay_rights

Complete Awesomeness

Posted by Matt on June 04, 2008

Congratulations on doing what they said couldn’t be done, and for making history in such an elegant and eloquent fashion.


obama

Iterating over all Models in Rails

Posted by Matt on May 16, 2008

Neat little snippet of code in those odd times you need to loop over every model in your application programmatically.

This exact snippet loops over every model, and converts each timestamp (created_at, updated_at) to UTC. It can be quite helpful if you’re adding Time Zone support to your Rails 2.1 application and you have existing non-UTC timestamps.


Object.constants.each do |o|
  klass = eval(o, TOPLEVEL_BINDING)
  if klass.is_a?(Class) && klass.superclass == ActiveRecord::Base
    puts "\n\nUpdating #{klass} timestamps to UTC"
    klass.all.each do |obj|
      offset_hours = (Time.zone.utc_offset / 1.hour) * -1
      obj.created_at = obj.created_at + (obj.created_at.dst? ? offset_hours - 1 : offset_hours).hours
      obj.updated_at = obj.updated_at + (obj.updated_at.dst? ? offset_hours - 1 : offset_hours).hours
      obj.save
      print '.'
    end
  end
end

*Please note: I haven’t tested this very thoroughly, but it does seem to do the trick. As we know, Dates and Times can be total PITAs!

I Love Ruby

Posted by Matt on May 16, 2008

In the application I’m currently developing a User has_many Jobs, and each Job has a bunch of nested resources. The application calls for a Dashboard, filled with the latest changes to any Job the currently logged-in user is assigned to.

Sounds difficult huh?


def self.get_latest_items_for(current_user)
  assigned_job_ids = current_user.jobs.collect(&:id)
  find(:all, :conditions => ["job_id in (?)", assigned_job_ids])
end

In order to get the currently logged-in user’s list I just do:


RecentItem.get_latest_items_for(current_user)

Simple, elegant, understandable, and concise.

AWS, EC2 and SSL 1

Posted by Matt on May 15, 2008

I spent a greater part of this day attempting to get nginx, SSL, and EC2 to play nice together. The funny thing was that nginx (which was hosting a mongrel_cluster) would serve standard HTTP requests just fine, but HTTPS requests just kind of hung there.

I could see that nginx was in fact listening to port 443 and could connect locally, but the whole shebang fizzled out anywhere outside the local box. No firewall either.

After pulling my hair out for a bit, I happened across this article that alluded to the ‘ec2-authorize’ command.

Seems as though you have to remotely manage the “firewall” of a running instance!

Anyhow; cutting to the chase: To enable HTTPS on your EC2 instance just run:


ec2-authorize default -p 443

Rails, Git, and Plugins

Posted by Matt on May 12, 2008

One of Rails’ greatest strengths lies with the plugin system. Git is the new source control kid on the block that all the girls are talking about, but Git breaks existing systems to manage plugins, such as Piston and the great ’./script/plugin install -x’ command.

Git giveth and Git taketh away.

Git has the supernatural ability to track submodules in your application. The below command adds RESTful_ACL as a submodule to your application inside the vendor/plugins directory, checks the project out for you, and commits changes in your application (added info in .gitmodules).


git submodule add git://github.com/mdarby/restful_acl.git vendor/plugins/restful_acl
	

git commit -a

When you go to clone to a different machine, just run the following two commands to checkout all of your submodules:


git submodule init
git submodule update

You’re off and running!

Forays into freelancing

Posted by Matt on March 28, 2008

I’ve suddenly realized that while I do really like my fulltime gig, I’m not getting paid for the insane amount of overtime I normally put in. I’m not asked to do this work, but I do as I get bored and hey, I really like to code.

So I logged onto workingwithrails.com and sent my resume out to a few prospective clients that allow telecommuting developers. Why the blog post? I don’t know, I guess I’m kind of excited about the process. I will be nice to use my craft on different problem domains for once.

I have been attending meetings with the Columbus Ruby Brigade for the last three months and this month’s meeting was about freelancing. One thing that member Joe O’Brien said stuck in my head. To paraphrase; “If you waited until you were sure you were the top expert in your field, you would never get started”.

I really respect Joe from afar as he’s a super bright guy with a solid history of experience. Wisdom is learning from others, so I’ve decided to throw my hat in the ring.

Wow, I’ve referenced myself 21 times in this post. My (22) high school English teacher is probably freaking out somewhere.

Scribd_fu featured!

Posted by Matt on March 26, 2008

Oh man, how awesome is this. Nary two hours after releasing Scribd_fu, it is already featured on Scribd’s Resources page! I hope this will help to drum up usage of Scribd_fu across the Rails community.

A big thanks to Scribd for the nod, and the link!

Scribd_fu is now live! 1

Posted by Matt on March 26, 2008

I’m pleased to announce my latest plugin: Scribd_fu.

What it does:
Scribd_fu hides out in the shadows like a document converting ninja, just waiting to process your data into a convenient Flash format (like YouTube) with the help of the black majick of Scribd.com. Imagine imbedding huge documents right inline with your web UI, no downloading, no necessary programs on the client side to view your data. It’s pretty damned cool, and it works with Attachment_fu!

Full write-up, repository, etc is here