View pg_searchable.rb
# Author: Ryan McGeary :
# License: MIT :
# TL;DR: A poor-man's full-text search.
# This module employs a mechanism by which we can easily add left outer joins
# to queries (typically for full-text-like searches that need to dig into
# specific associations).
# One way to do this is to just use ActiveRecord's `eager_load` as part of a
View promisify-node4.js
const promisify = (fn) => {
return function () {
const args = Array.from(arguments);
return new Promise(function (resolve, reject) {
fn.apply(undefined, args.concat([function (error, data) {
if (error) return reject(error);
if (data === undefined) return resolve();
return resolve(data);

Fast/efficient approach:

-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id =")
   -> 1.3197s

Slow/naïve approach:


Keybase proof

I hereby claim:

  • I am rmm5t on github.
  • I am rmm5t ( on keybase.
  • I have a public key whose fingerprint is 79DA 34B8 A2E7 3C96 E0CC 5BB2 005A C77D 7CBF 3EAF

To claim this, I am signing this object:

View bob.rb
class Bob
def respond_to(input)
@input = input.strip
return "Fine. Be that way!" if silence?
return "Whoa, chill out!" if shouting?
return "Sure." if question?
View hamming_bm.rb
# Courtesy @zenspider
class Hamming0
def self.compute s1, s2
length = [s1.length, s2.length].min
length.times.count { |i| s1[i] != s2[i] }
View Gemfile
source ''
ruby '2.1.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
gem 'sqlite3'
## Assets
gem "sprockets-rails", "~> 2.1.3"
# Use SCSS for stylesheets

ruby-1.9.3-p448 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p448 with the railsexpress patchsets:


You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

View euler010.rb
#!/usr/bin/env ruby
require "prime"
max = (ARGV[0] || 2_000_000).to_i
print "Sum of primes below #{max}: "
puts Prime.each(max - 1).inject(&:+)

Ruby 1.9.3-p392

$ time script/rails console
Loading development environment (Rails 3.2.12)
>> ^D

real    0m7.363s
user    0m6.352s
sys     0m0.919s