Skip to content

Instantly share code, notes, and snippets.

View thetamind's full-sized avatar

Matthew Boehlig thetamind

View GitHub Profile
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
class BaseTask
def self.perform(*args)
ActiveRecord::Base.verify_active_connections!
end
end
class SomeTask < BaseTask
def self.perform(*args)
super
# do some stuff
@deepak
deepak / require_tracking.rb
Created July 6, 2010 14:17
Gather memory usage per files required and the time taken - useful to reduce startup time
# ACK:
# modified from
# http://gist.github.com/264496 by github.com/eric
# http://gist.github.com/465293 by github.com/alexyoung
# USAGE:
# 1) > ruby -rrequire_tracking -e "require 'active_support'"
# 2) put in config/preinitializer.rb
# WHAT: Provides a simple overview of memory allocation occuring
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
40+ newbie rails mistakes
themes:
Build for failure
expect services to be slow
expect services to be unavailable
Build so components can be easily replaced
Build so code can be easily reused
mistakes:
@jhenry
jhenry / tmux_textaurant.sh
Created January 11, 2011 02:50 — forked from dpickett/tmux_textaurant.sh
./tmux_starter_pistol.sh projectname
export PROJECT_NAME=$1
export WORKING_DIR=~/working/active/$PROJECT_NAME
cd $WORKING_DIR;
tmux start-server
tmux new-session -d -s $PROJECT_NAME -n work
tmux new-window -t$PROJECT_NAME:1 -n server
tmux new-window -t$PROJECT_NAME:2 -n test
@ryanb
ryanb / application.html.erb
Created January 19, 2011 19:31
Example of very simple password authentication.
<!-- layout file -->
<% if current_user %>
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %>
<% else %>
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>.
<% end %>
# rspec continuous runner script using watchr, growl and spork
# run this script via 'watchr'
# gist at: https://gist.github.com/797853/
# based on: https://gist.github.com/276317/
# you may want to install image file for growl.
if RUBY_VERSION >= "1.9" # multibyte encoding only supported in Ruby 1.9
Encoding.default_external = "UTF-8"
end
@panthomakos
panthomakos / Gemfile
Created May 18, 2011 18:41
Spork, RSpec, Sham and Caching Classes
source 'http://rubygems.org'
gem 'rails', '3.0.4'
group :test do
gem 'database_cleaner'
gem 'rspec-rails'
gem 'rspec-rails-matchers'
gem 'sham'
gem 'spork', '=0.9.0.rc7'
@apalmblad
apalmblad / fast-require-ruby-19.2-p180
Created May 30, 2011 20:46
fast require, ruby 1.9.2-180
diff --git a/array.c b/array.c
index b1616c5..16326fc 100644
--- a/array.c
+++ b/array.c
@@ -302,7 +302,7 @@ ary_alloc(VALUE klass)
return (VALUE)ary;
}
-static VALUE
+VALUE