Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@bradmontgomery
bradmontgomery / rvm_apache_passenger.txt
Created January 10, 2012 04:45
RVM + Apache + passenger setup for Ubuntu
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
@gautamrege
gautamrege / notify.js
Created January 28, 2012 14:43
Notification node server
var express = require('express')
, app = express.createServer()
, io = require('socket.io').listen(app);
app.use(express.bodyParser());
app.listen(13002);
var connections = {}
@ralph
ralph / install.sh
Created February 20, 2012 11:09
Install Ruby 1.9.3-p125 with falcon patchset, without XCode
brew install https://raw.github.com/adamv/homebrew-alt/master/duplicates/autoconf.rb
brew link autoconf
brew install https://raw.github.com/adammw/homebrew-alt/automake/duplicates/automake.rb
brew link automake
rvm cleanup all
rvm install 1.9.3-perf --patch falcon,debug
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active March 23, 2025 21:22
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
  1. I find a mistake in the book or somebody else points one out using the review system's notes.
  2. I fix the mistake in the ERB/XML version of the book.
  3. The ERB/XML version is then automatically converted into an XML document via a running Guard process.
  4. I commit both files to the Git repository for the book, and then push these to GitHub
  5. GitHub tells the review tool that a push has occurred, and sends through a push notification.
  6. The review tool receives the notification and stores a job in Resque to parse the book.
  7. A resque worker runs the job, detecting which files have changed and then updates just those chapters.
  8. For each chapter, each element is processed individually using an XSLT file and stored in a MongoDB database as HTML (I know, right?)
  9. When a user requests a chapter, this page is then read from the database and then cached back to Redis.
  10. Every time a chapter is updated, be it by the automated process or by a user putting a note on the book, the cache is reset.
@gnepud
gnepud / test_helper.rb
Created April 6, 2012 08:57 — forked from sethbro/test_helper.rb
MiniTest::Spec with Rails 3.2 setup
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require 'capybara/rails'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
@sj26
sj26 / 0-readme.md
Created May 5, 2012 05:39 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p194 with patches for boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@bsodmike
bsodmike / fast-one.rb
Created May 11, 2012 12:09 — forked from jeremyf/fast-one.rb
A command line tool to help with testing pull requests.
#!/usr/bin/env ruby
# Before you use this:
# git clone git://github.com/some-other-user/their-repo
# This assumes that origin is the repo that you are merging into!
require 'rubygems'
gem 'rest-client'
gem 'crack'
require 'rest-client'
@bsodmike
bsodmike / Gemfile
Created May 23, 2012 11:14
Resque + Bluepill Nirvana
gem 'resque-ensure-connected'