This file contains 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
#!/bin/sh | |
# Shamelessly stolen from: | |
# https://github.com/michaeldfallen/git-radar/blob/master/git-radar#L7-L13 | |
if [[ "$OSTYPE" == *darwin* ]]; then | |
READLINK_CMD='greadlink' | |
else | |
READLINK_CMD='readlink' | |
fi |
This file contains 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 SourceAnnotationExtractorExtension | |
extend ActiveSupport::Concern | |
included do | |
def find_in_with_rabl dir | |
results = {} | |
Dir.glob("#{dir}/*") do |item| | |
next if File.basename(item)[0] == ?. |
This file contains 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
# abuse of `inject` and `tap` | |
# | |
# it's not really short | |
# but shows some nice Ruby stuff | |
%w[bigdecimal /util].inject(""){|a,e|(a<<e).tap{|r|require r}} |
This file contains 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
require "yaml" | |
begin | |
application_yml = YAML.load_file(File.join(File.dirname(__FILE__), "../config/application.yml")) | |
global_envs = application_yml.select { |key, _| key =~ /([A-Z_])+/ } | |
environment = ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development" | |
env_envs = application_yml.fetch(environment, {}) | |
current_envs = global_envs.merge(env_envs) | |
current_envs.each_pair do |key, value| | |
ENV[key.to_s.upcase] ||= value.to_s |
This file contains 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
=begin | |
Message Pack vs similar utilities | |
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] | |
Packing | |
user system total real | |
pack: bert 60.850000 0.270000 61.120000 ( 62.003839) | |
pack: bson 2.750000 0.010000 2.760000 ( 2.799844) | |
pack: bson (moped) 12.260000 0.030000 12.290000 ( 12.468642) |
This file contains 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
#!/bin/sh | |
# Conflict markers | |
git diff --cached --diff-filter=ACMR | awk '/\+(<<<[<]<<<|>>>[>]>>>|===[=]===$)/ { exit 1 }' | |
CODE=$? | |
if [ "$CODE" != "0" ]; then | |
echo "COMMIT ABORTED: Conflict markers found." >&2 | |
exit $CODE | |
fi |
This file contains 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 ZoneConversion | |
module_function | |
def float2zone(offset) | |
("%+06.2f" % offset).tr(".", ":") | |
end | |
end | |
### Example |
This file contains 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 Token | |
module_function | |
MAX_RETRIES = 3 | |
TokenTakenError = Class.new(StandardError) | |
def token_generator | |
# SecureRandom.hex(32) | |
("a".."z").to_a.sample |
This file contains 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
require "forwardable" | |
class ProcString | |
extend Forwardable | |
def_delegators :stringified_proc, :to_s, *("".methods - BasicObject.methods) | |
attr_reader :proc | |
def initialize(&string_proc) | |
@proc = string_proc |
This file contains 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
sunday = (Date.today .. (Date.today + 7)).detect { |date| date.cwday == 7 } |
OlderNewer