skwpspace it’s pronounced ’scoop’. yan pritzker’s home on the web

Blog :: Photography :: About Me

hello, i'm yan

I blog here occasionally. I hope you like it.

Subscribe by Email

planypus

I'm the founder of Planypus, the place to share your plans!

cohesiveft

Accessible, manageable, virtualized application stacks ready to download or deploy to the cloud!

flickr

starlightthe playersredmoon theater - boneyard prayerredmoon theater - boneyard prayer-5redmoon theater - boneyard prayermetal goddessmetal monstersprofessor

Archives

Contact

Reach me at yan at pritzker.ws

Posts Tagged ruby

Ruby/html trick: wrap long strings with invisible wordwrap characters

def wrap_long_string(text,max_width = 20)
(text.length < max_width) ?
text :
text.scan(/\S{1,#{max_width}}/).join(“<wbr>“)
end


Twitter opens the floodgates of FUD

TechCrunch is reporting on rumors that twitter is leaving Ruby on Rails. Of course the comment threads are covered by a heated debate by people either bashing RoR, suggesting their favorite language and platform as the ‘only possible solution’, or both. Nevermind that Friends For Sale, with 630k active daily users scales just fine on [...]


fix for TextMate Ruby tests broken with stack level too deep

If you experience problems running single unit tests in TextMate with Rails 2, it may be due to a bug. The problem has something to due with conflicting builder.rb instances in Rails and TextMate. The simplest and least intrusive fix is to add this to the top of your test_helper.rb

$LOAD_PATH.reject! { |e| e.include? ‘TextMate’ }


Posted
13 March 2008 @ 7pm

Tagged
rails, ruby

webcrawler bot detection

def self.bot_agent_list
[ "panscient", "larbin", "dummy", "Teoma", "alexa",
"froogle", "inktomi", "looksmart", "URL_Spider_SQL",
"Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK",
"InfoSeek", "WebFindBot", "crawler", "girafobot", "Scooter",
"Baidu", "bot", "Google", "SiteUptime", "Slurp",
[...]


acts_as_versioned for a set of columns

acts_as_versioned is a great plugin for versioning a set of model attributes transparently every time you save. The plugin seems to be built with exclusion in mind (version all except these) but to get it to work only on a specific set of columns, this simple trick can be applied:
class Foo [:description_t]
def [...]


Clean svn tag support for Capistrano 2

If you find capistrano’s release directory naming conventions hard to use, a great alternative is to base releases on your svn tags. It turns out that implementing this in cap2 is quite simple. Unfortunately I can’t quite figure out how to turn this into a library so at this point it exists as a cut-n-paste [...]


ruby tricks: simple caching of method results

This is a simple trick based on the idea that everything in ruby returns a result. By using the block syntax we can do a series of expensive operations and cache the result somewhere. Here I’ve shown the result cached in an instance variable but it may just as well be something more exotic.
[...]


Noobkit: a better way to get your Rails API docs

Recently launched Noobkit is a great new way to get at your Rails API docs. The visual design is pleasing and it’s got an OpenID login system and ability to make bookmarks. It covers the Rails API and many common gems. The look is much more pleasing than the similar gotapi.com which covers more programming [...]


Tracking down stray console messages in Ruby

While working on Planypus we recently ran into an issue where something was outputting strange messages to the console. Luckily, Anton Mostovoy figured out a clever dynamic Ruby hack to track who was outputting the message:

$stdout.instance_eval do
alias :inner_puts :write
def write (str)
inner_puts %Q!#{str} was said by #{caller.join(”\n”)}!
end
end

Like Magic!