Skip to content

Instantly share code, notes, and snippets.

@blowmage
blowmage / foo.rb
Created August 3, 2012 11:42
Shouldify MiniTest
class Foo
def bar
"bar"
end
def baz
"baz"
end
end
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ejschmitt
ejschmitt / gist:3790307
Created September 26, 2012 20:16
Install vim on heroku
cd /tmp && curl -O ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2 && bunzip2 -c vim-7.3.tar.bz2 | tar -xf - && cd vim73 && ./configure --prefix=/tmp && make install && echo PATH='$PATH:/tmp/bin/' > path && source path
@jashkenas
jashkenas / app.js
Created October 17, 2012 13:40
Quick Benchmark vs. Haml vs. ERB. vs. Slim (http://news.ycombinator.com/item?id=4663724)
var http = require('http');
var fs = require('fs');
var _ = require('underscore');
var items = {
"Headline 1": "Link1 Link2 Link3 Link4 Link5 Link6 Link7".split(' '),
"Headline 2": "Link1 Link2 Link3 Link4 Link5 Link6 Link7".split(' '),
"Headline 3": "Link1 Link2 Link3 Link4 Link5 Link6 Link7".split(' '),
"Headline 4": "Link1 Link2 Link3 Link4 Link5 Link6 Link7".split(' ')
};
module UserAuthenticator
module_function
# Validates that the unencrypted password belongs to the passed user.
#
# @param [User] user The user object to validate against. (should respond to #password_digest)
# @param [String] unencrypted_password The password to verify
# @retun [Boolean] confirms or denies the validity of the unencrypted password.
def valid?(user, unencrypted_password)
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@roidrage
roidrage / .travis.yml
Created November 14, 2012 16:04
How to fix debugger gem woes with Ruby 1.9.3p327
bundler_args: --without debug
@funny-falcon
funny-falcon / changes.md
Last active August 15, 2024 15:13
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@pamelafox
pamelafox / catalog_test.js
Created November 29, 2012 18:48
Coursera catalog view test
describe('catalogyBody', function() {
var chai = require('chai');
var path = require('path');
var env = require(path.join(testDir, 'lib', 'environment'));
var requirejs = env.requirejs(staticDir);
var sinon = requirejs('js/lib/sinon');
var fs = require('fs');
var server;
var router;
@rubiii
rubiii / how_it_works.md
Created December 2, 2012 11:14
MacVim-Formatter for RSpec
$ rspec --format MacVimFormatter --color spec