Josh Peck - Nerdlog » Posts in 'Software Development' category

Amazon FPS SigHelper for Ruby

I spent a little more time hacking on Amazon FPS today. Ended up needing a signature helper that worked, and after a couple hours of messing with the one provided on the website, I ended up building my own.

The old one attempted to implement the raw RFC in the library itself. I opted out and used the openssl libraries. Sure, it doesn’t work on windows without some effort, but I don’t need it to.

require 'openssl' require 'base64' require 'uri' require 'cgi' # Provides a simpler signature helper than the one currently provided # by the community. # # Dependencies: # * OpenSSL # * Base64 # * URI # * CGI # # Usage: # SigHelper::get_encoded_url('http://example.com?a=1&b=2&c=3', 'AWS_SECRET_KEY') # module SigHelper def self.get_encoded_url(url, key) # Parse URL and set up vars uri = URI.parse(url) t = String.new q = CGI::parse(uri.query) # Sort and re-form sorted query string t = q.keys.sort.collect{|k| "#{k}=#{CGI::escape(q[k].shift)}" }.join('&') uri.query = t t = uri.path + '?' + uri.query # Generate signatures hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), key, t) sig = Base64.encode64(hmac) # URL-encode signature and return new url sig = CGI.escape(sig.strip) uri.query = uri.query + "&awsSignature=#{sig}" uri.to_s end end

Of course, this allows you to say something like this:

uri = URI::parse(SOME_URL) signed_url = SigHelper::get_encoded_url(uri.to_s, AWS_SECRET_ACCESS_KEY)

amazon-fps-ruby 0.1.0 Released

amazon-fps-ruby version 0.1.0 has been released!

http://code.google.com/p/amazon-fps-ruby/

Provides a simple wrapper around the Amazon FPS SOAP web service.

DESCRIPTION

Supports all features in the WSDL from Amazon:

http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=125

CHANGELOG

0.1.0 / 2008-11-07

  • Initial Release
  • Publish as a gem

http://code.google.com/p/amazon-fps-ruby/

Stupid Pointless Patents

It all started innocuously enough. I was talking to a colleague recently and
through no fault of our own, the conversation turned to intellectual property.

He boldly stated:

“What you really need to do is to apply for a patent for your [software]
technology”

It’s too bad really, I used to think he was smart…

For me, patents have always been a tradition of a bygone era, almost like a
land-line telephone or dial-up internet. Patents addressed a problem that
doesn’t exist in software and most of modern technology. Sure everyone wants
to patent their invention because it seems like the thing to do, but is it
really?

Three things happen when you apply for a patent and two of them are bad.

  • Someone reads you patent documents, makes a trivial modification to it and
    uses it in a way that’s virtually impossible to prove. (50% probability)
  • Your legal fees eat all your profits for the next 5 years. (60% probability)
  • Everyone respects your patent, thinks you are a genius, and throws money at
    you to use your technology. (0% probability)

Read more »

Border Rivalries and Team Dynamics

Against my best instincts, I recently began using Facebook. While on the site, I managed to stumble into a message board where there was some discussion of where the best hamburger in Kansas City could be obtained. My interest was piqued immediately, since I do love a tasty burger. I prepared my saliva ducts and began reading the comments, foolishly expecting that the discussion would center on the finer attributes of culinary delight that can be received when the Chef du jour is an acne-ridden 16 year old.

However, within 5 comments, the thread had completely devolved into a discussion of the cultural heritage of the commenter. When reading this, it became clear that there was a major rift between the people who live in Kansas City, Kansas versus those who live in Kansas City, Missouri. By the time the thread reached about 20 comments, the discussion had completely devolved into a discussion of who was the worst driver.

Apparently, all Kansas drivers believed that Missouri drivers were the worst and all Missouri drivers believed Kansas drivers were the worst. Now, we all know that Oklahoma drivers are the worst drivers in the known universe, but they were ignoring this simple fact and critiquing each other’s driving habits ad nauseam. So, here’ my question…

Why does someone’s driving acumen have anything to do with their taste in hamburgers? Even more importantly, why is it that everyone believes that their neighbors are the worst drivers in the world?

Read more »

Ruby on Rails - Fixing Deprecated Statements

So, I just upgraded one of my projects to use Ruby on Rails v1.2.1 and it turns out I was using a lot of deprecated statements in my code (especially in testing code). As a pragmatic programmer, I didn’t want to update each of these files manually, so I created a group of conversion scripts that can be used to update several major problems I had to the Rails 2.0 way of life.

Since it seems hard to edit files by hand and easy to write programs in Ruby, I did the latter and have build a few little scripts to convert deprecated statements in Ruby on Rails to their new precated (why isn’t that a real word?) equivalents. As with any script that modifies your code in-place, be sure to have high quality backups at your disposal!

Download the scripts now: Fix Deprecated 2.0

For a more complete list of deprecated statements, see:
Ruby on Rails Deprecations Part 1: ActionController

© 2008 Josh Peck - Nerdlog is powered by WordPress