Skip to content

Instantly share code, notes, and snippets.

@whartonn
whartonn / .eslintrc.json
Created November 30, 2016 19:22
current configuration
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
@whartonn
whartonn / benchmark_mod_even_vs_bit_even
Created April 7, 2013 14:47
mod-based even/odd vs bit-based even/odd
def odd_or_even_mod(number)
return "Even" if number % 2 == 0
return "Odd"
end
def odd_or_even_bit(number)
return "Even" if number & 1 == 0
return "Odd"
end
require 'benchmark'
@whartonn
whartonn / commands
Created July 6, 2011 18:28
I added rack 1.3.0 to my gemfile and then got these errors
$ bundle install
Fetching source index for http://rubygems.org/
You have requested:
rack = 1.3.0
The bundle currently has rack locked at 1.2.3.
Try running `bundle update rack`
$ bundle update rack
Fetching source index for http://rubygems.org/
@whartonn
whartonn / Gemfile
Created July 6, 2011 17:26
I'm using Capistrano and deploying to Ubuntu (lucid)(10.04.2) in EC2 with phusion passenger 3.0.7 / nginx / Rails 3.0.9
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# rake 0.9.0 is broken (should work with rails 3.0.8)
gem 'rake', '~> 0.8.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
require './rvm'
LoadError: no such file to load -- rvm/errors
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/lib/rvm.rb:59:in `<module:RVM>'
from /usr/local/rvm/lib/rvm.rb:56:in `<top (required)>'
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /var/www/fat/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
rvm info
ruby-1.9.2-p136@fat:
system:
uname: "Linux ip-10-171-45-26 2.6.31-302-ec2 #7-Ubuntu SMP Tue Oct 13 19:06:04 UTC 2009 i686 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu)"
zsh: " => not installed"
rvm:
ruby-1.9.2-p136 :005 > rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
=> "/usr/local//rvm"
ruby-1.9.2-p136 :006 > rvm_lib_path = File.join(rvm_path, 'lib')
=> "/usr/local//rvm/lib"
ruby-1.9.2-p136 :007 > $LOAD_PATH.unshift rvm_lib_path
=> ["/usr/local//rvm/lib", "/var/www/fat/releases/20110701220916/lib", "/var/www/fat/releases/20110701220916/vendor", "/var/www/fat/releases/20110701220916/lib/", "/var/www/fat/releases/20110701220916/lib/tasks/", "/var/www/fat/releases/20110701220916/lib/nike_plus/", "/var/www/fat/releases/20110701220916/lib/jobs/", "/var/www/fat/releases/20110701220916/app/models/observations", "/var/www/fat/releases/20110701220916/app/models/observations/", "/var/www/fat/releases/20110701220916/app/models/authentications", "/var/www/fat/releases/20110701220916/app/models/authentications/", "/var/www/fat/releases/20110701220916/app/helpers", "/var/www/fat/releases/20110701220916/app/controllers", "/var/www/fat/releases/20110701220916/app/models", "/var/www/fat/shared/bund
ruby-1.9.2-p136 :015 > rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
=> "/usr/local//rvm"
ruby-1.9.2-p136 :016 > rvm_lib_path = File.join(rvm_path, 'lib')
=> "/usr/local//rvm/lib"
ruby-1.9.2-p136 :017 > $LOAD_PATH.unshift rvm_lib_path
=> ["/usr/local//rvm/lib", "/usr/local//rvm/lib", "/var/www/fat/releases/20110701061923/lib", "/var/www/fat/releases/20110701061923/vendor", "/var/www/fat/releases/20110701061923/lib/", "/var/www/fat/releases/20110701061923/lib/tasks/", "/var/www/fat/releases/20110701061923/lib/nike_plus/", "/var/www/fat/releases/20110701061923/lib/jobs/", "/var/www/fat/releases/20110701061923/app/models/observations", "/var/www/fat/releases/20110701061923/app/models/observations/", "/var/www/fat/releases/20110701061923/app/models/authentications", "/var/www/fat/releases/20110701061923/app/models/authentications/", "/var/www/fat/releases/20110701061923/app/helpers", "/var/www/fat/releases/20110701061923/app/controllers", "/var/www/fat/releases/20110701061923/app/models", "/
@whartonn
whartonn / irb session
Created July 1, 2011 21:27
passenger error
Error message:
uninitialized constant RVM::Environment
Exception class:
NameError
Application root:
/var/www/fat/current
Backtrace:
# File Line Location
0 /usr/local/rvm/lib/rvm/environment.rb 6 in `'
1 /usr/local/rvm/lib/rvm/environment.rb 3 in `'
@whartonn
whartonn / .rvmrc
Created July 1, 2011 18:05
starting out with this install (ubuntu, nginx, rvm multi-user, rails 3.0.9)
if [[ -s "/usr/local/rvm/environments/ruby-1.9.2-p136@fat" ]] ; then
. "/usr/local/rvm/environments/ruby-1.9.2-p136@fat"
else
rvm --create use "ruby-1.9.2-p136@fat"
fi