Skip to content

Instantly share code, notes, and snippets.

@joshsusser
joshsusser / gist:9241494
Created February 27, 2014 00:01
nuclear physics limerick
the alchemist turned lead to gold
as tales through the ages have told
but alpha decay
meant the gleam didn't stay
so those isotopes never got old
@joshsusser
joshsusser / gist:9793740
Created March 26, 2014 21:15
git - list remote branches ordered by recent activity
git for-each-ref --sort=-committerdate refs/remotes/origin/ --format='%(committerdate:short) %(refname:short)'
require 'benchmark'
include Benchmark
class Weeble
attr_reader :name, :age, :salary, :language
def initialize(name, age, salary, language)
@name, @age, @salary, @language = name, age, salary, language
end
def sorter
options.scan(/\w+=\w+/).inject({}) { |h,opt| k,v = opt.split('=',2); h[k] = v; h }
require 'benchmark'
class Validated
def valid?
true
end
end
c1 = [Validated.new]
c10 = c1 * 10
Host project1.github.com
HostName github.com
User git # Probably not needed but just a note if you want to skip it
IdentityFile ~/.ssh/your_key_file
IdentitiesOnly yes # This is only if you want to avoid trying other identities which can speed things up a bit.
# at the very least, use inheritance!
class Object
alias_method :try, :send
end
class NilClass
def try(*args)
nil
end
class ApplicationController < ActionController::Base
around_filter :you_are_here
def you_are_here
puts "***** NEW ACTION: #{controller_name} - #{action_name} *****"
begin
yield
ensure
puts "<pre>"
if $! then
export PS1="\[\033[36m\]\h:\W>\[\033[0m\] "
export PS1="\[\033[36m\]\h:\w \[\033[33m\]\$(parse_git_branch)\$(parse_svn_branch)\[\033[00m\]$\[\033[00m\] "
# drop this in config/initializers/count_fix.rb to work around
# hmt/named_scope count bug https://rails.lighthouseapp.com/projects/8994/tickets/2189
class ActiveRecord::Base
protected
def self.construct_count_options_from_args(*args)
name_and_options = super
name_and_options[0] = '*' if name_and_options[0].is_a?(String) && name_and_options[0] =~ /\.\*$/
name_and_options
end