January 2012
1 post
Building an API: Rails 3 vs Grape
I’ve been pretty impressed with the Grape Rack library for building an API, but I was curious how it stacks up against Rails 3, now that Rails has been Rack-ified and has steadily become more hospitable to APIs.
Using an existing Rails app with a Grape API mounted as middleware, I ran a benchmark against a vanilla API with this environment:
Grape 0.1.5
Rails 3.0.10
Passenger 3.0.5
Ruby...
December 2011
1 post
Hidden Secrets of the Rails Dev: Gotchas While...
Upon migrating from Rails 2 to 3, one might happen across some “gotchas”. I present a few such that you may heed caution.
ActiveSupport::Callbacks#run_callbacks
This method takes a &block parameter. In Rails 2, &block will run after each callback, and halt the chain if it returns false. In Rails 3, &block will run after the :before/:around callbacks and before the :after...
August 2011
1 post
Reorder your Authlogic persistence callbacks
One thing lacking from ActiveSupport::Callbacks, imo, is a way to reorder callbacks.
For instance, it would be nice if you could define the order in which Authlogic (which uses ActiveSupport::Callbacks) tries to persist a session (ie ‘remember’ cookie, then ‘session’ cookie, then ‘http_auth’, and so on).
Here’s some code to put at the end of your session...
November 2010
1 post
"SayIt ☎", a New Pronunciation Tool!
Have you ever argued with someone over the pronunciation of a word? Let “the cloud” resolve your issue!
“SayIt ☎” is my new Kynetx/Twilio/Forvo mashup that does 1 simple thing: pronounce words.
Try it… send “plasmometric” to 917.740.1911 …
May 2010
1 post
Import your data from RunnersWorld to RunKeeper!
If you need to move your information from Runner’s World into RunKeeper, but like me have run into the problem that RunKeeper doesn’t have an api (yet?) and doesn’t let you import data, then fear not!
If you like living “on the edge”, try running my script by following these steps:
Download the Ruby script here to any directory
You’ll have to run a command to...
April 2010
1 post
New Name/Site for Kynetx App!!
I found some tonight to return to Similar Stories Different Take and make a few changes:
renamed to Different Take (thx Cody)
added support for Bloomberg News!!!
more polishing of the news-search algorithm
website is now at http://different-take.com
added browser extensions (courtesy of Kynetx)… the options for getting your balance of news are:
Bookmarklet
Azigo card
Firefox...
February 2010
1 post
Kynetx App Contest: Similar News Stories
NAME: Similar News Stories
DESCRIPTION
When the user is on a major news site, this app will attempt to provide up to 20 links to similar news stories from other sources.
BACKGROUND:
This is a contest entry for the Kynetx App Contest. Go check out Kynetx if you haven’t yet— it’s a really nice platform for building context-based applications. Sort of like what hoodwink.d was...
January 2010
1 post
November 2009
2 posts
Testing ye olde "querystring cache busting" trick.
When setting your site’s file cache settings, there are 2 common ways to properly save bandwidth with HTTP headers.
First method: compare the browser cache’s current versions
Set an http header such as ETag or Last-Modified that allows a client (browser) to compare its cached version of a file with the one on the server. With ETag, for example, the client checks the ETag of its...
4 tags
Logfile art? Yeah I did.
Here’s a script that takes a filename, parses the file for IP addresses, maps each IP to an RGBA pixel, and creates a PNG (thanks seattle.rb!).
For example, the following would map 192.168.1.1 in reverse (i.e. 1.1.168.192)…
ruby ip_colorsquare.rb production.log 4,3,2,1
Here’s one example I created with a 24-hour chunk of logs from WhereWeDoWhatWeDo (disclaimer: I mixed up the...
October 2009
1 post
Troubles with JRuby and SoyLatte on OS X Snow...
I was trying to install JRuby on a new install of OS X Snow Leopard today, but got this error when trying to run stuff like “jruby -S gem”:
Trace/BPT trap
I’m using SoyLatte for Java development on my machine, and was able to fix the JRuby error by switching back to the Java 1.6 with which Snow Leopard ships.
So what’s the quick fix — so we don’t have to...
July 2009
1 post
Max Headroom ♥ CSS3 →
(latest build of WebKit required)
June 2009
3 posts
Looking for some +1's to get video_tag() into... →
4 tags
vijo doesn't overheat my cpu! (yet)
Here’s what I came up with during the Hack Day portion of the incredible Open Video Conference 2009 this weekend. It’s a VJ’ing tool written purely in HTML5 and JS.
Bear with me if it’s glitchy! It’s just a prototype.
go to vijo
Deprecating 'www' from Rails Requests with Metal
In ‘app/metal/deprecate_w_w_w.rb’:
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class DeprecateWWW
def self.call(env)
if env['HTTP_HOST'].slice!(/^www\./)
location = "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['REQUEST_URI']}"
RAILS_DEFAULT_LOGGER.info...
March 2009
2 posts
Radial Gradiant in Safari / Webkit (CSS3)
Many of the docs on gradient support in WebKit right now only include examples for “linear” style gradients, while just mentioning the syntax for “radial” styles:
-webkit-gradient(type, inner_center, inner_radius, outer_center, outer_radius, / stop...)
So here’s an example of how to do a “radial” background gradient:
background: -webkit-gradient(radial,...
3 tags
Keep it shortenTweet
Behold… shortenTweet! It’s a wee microapp for Twitter that tries to shorten your tweets using UTF-8, ASCII and some shorthand. It’s a combination of Sinatra + jQuery, and after doing this I’m all aboard this microapp train (esp. with how easy it is to deploy Rack-based apps on Passenger).
And — par for the course — after I “launched” it, I...
February 2009
1 post
Rails 2.3 : Uninitialized constant CGI::Session
Upgraded to Rails 2.3 today… very nice, but I ran into this
uninitialized constant CGI::Session
To solve, look for anywhere you reference the builtin session stores for rails (ie CookieStore), and change “CGI::Session” to “ActionController::Session”. (ie “CGI::Session::CookieStore” to “ActionController::Session::CookieStore”)
January 2009
1 post
Convention over Configuration'ing my Blog.
I’m pretty close to ditching my 3-year-old Typo/Joyent shared hosting blog setup soon. I might just replace it with this Tumblelog.
(apologies to anyone who was following my old blog feed)