This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = David Billskog | |
email = [email protected] | |
[color] | |
diff = true | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = true | |
[core] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeepStruct | |
attr_reader :hash | |
def initialize(hash) | |
@hash = hash.with_indifferent_access | |
end | |
def method_missing(method, *args, &block) | |
if hash.key?(method) | |
value = hash[method] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TimeLogger | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
attr_writer :time_logger | |
def time_logger | |
@time_logger ||= Logger.new(File.join(Rails.root, 'log', 'time_logger.log')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) | |
if [ $? -eq 0 ]; then | |
echo " "${ref#refs/heads/}"" | |
fi | |
} | |
function hitch_pair { | |
source ~/.hitch_export_authors | |
if [ `git symbolic-ref HEAD 2> /dev/null` ] \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable logging | |
ActiveRecord::Base.logger = Logger.new(nil) | |
# Make sure all models are loaded | |
Dir.glob("app/models/*.rb").each do |f| | |
begin | |
require File.basename(f).sub(".rb", "") | |
rescue | |
puts "could not require #{f}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log Array#to_s to make sure we are not using it and expeting the Ruby 1.8.x behaviour | |
class Array | |
alias :_to_s :to_s | |
def to_s(*args) | |
Rails.logger.warn "Was calling Array#to_s from #{caller.first.split(":in").first}" | |
_to_s(*args) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_line | |
caller.first.split(":in").first | |
end | |
puts current_line # current.rb:5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- A scaffolded edit view converted to mustache --> | |
<h1>Editing post</h1> | |
{{#form}} | |
{{#errors?}} | |
<div id="error_explanation"> | |
<h2>{{error_header}}</h2> | |
</div> | |
<ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rand(32**8).to_s(32) # => "kff09q5l" |