During my work I try to extract reusable code as much as possible, in the form of Ruby gems. Not (only) because of laziness, but mostly to reduce the amount of bugs and get fixes deployed as quickly as possible.
Here is a list of things you can use in your own projects. They’re all open source so they are free to use and modify. If you have feature requests or bug reports, send me an email, tweet or use the issue trackers on the following Github pages.
I use all the following gems in production.
SimpleSolr
Solr client for Ruby on Rails with as few features as possible. Solr is a popular full text search engine. The usual Solr clients for Ruby/Rails are full-featured; this one is not. It uses the Solr REST API directly. It’s super light, super fast but exposes a lot of metal too. github
Nilly Vanilly
This Rails plugin stores NULL values in your database, instead of empty strings. I am more or less an odd duck in the Rails world in that I keep my database schema tight and always define defaults, NOT NULLs and foreign key constraints. Nilly Vanilly helps me store NULL when Rails thinks it can safely store empty strings. This in turn allows me to use unique indexes, which are the fastest kind available. github
Capistrano Transmit
Rails tasks to work with production data and assets. Type ‘cap transmit:get:mysql’ to fetch the entire production database at once. I really recommend this instead of working with (fake) seed data, since it will clearly expose troublesome points in your code. Not recommended when you are developing Facebook though. github
Randomizr
SQL compliant random Active Record. Do not use “order by rand()” to randomize database results! Really, you shouldn’t. It scans every row which kills IO on the database, which in turn negatively effects all other queries. Randomizr uses current best practice to select a random row in the database, ie it doesn’t use a simple shuffle in Ruby land. github
Gimme a Break
Rails plugin to throttle ActiveRecord object creation. This way your website will not be overrun by abusers creating many records in quick succession. It monitors the most recent created_at, which I admit is rather crude but it does work well. github
Elfproef
Validate Dutch bank account numbers using the Elfproef checksum. One of my older plugins, but still quite functional. Dutch bank account numbers are validated using a modulo-11 checksum. Our VAT numbers too. And SSNs as well. So I should probably rename it ModuloElevenChecksumVerifier or something. github
DNSBL_Check
Rails plugin to check http connects against DNS Blackhole Lists. If I am not mistaken, my oldest plugin. And it still works, although I don’t use it in production anymore. It was meant as a way to stop spammers; it does a DNS request to blackhole lists. DNS is quick and the concept proved effective. Plus it’s invisible for users and you don’t need to use any external API, just your own DNS server. github