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
class HashWithIndifferentAccess < Hash | |
def [](key) | |
super(convert_key(key)) | |
end | |
def []=(key, value) | |
super(convert_key(key), value) | |
end | |
def self.[] (*args) |
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
[alias] | |
cleanup = "!git fetch -p && git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d" |
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
// example program | |
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/garyburd/redigo/redis" | |
) |
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
class Crap | |
attr_accessor :crappiness | |
def initialize(tolerability = 5) | |
@crappiness = 0 | |
@tolerability = tolerability | |
end | |
def +(int) | |
result = dup |
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
# Ruby 1.9: | |
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ] | |
# => {"key"=>"value"} | |
# Ruby 2.0+: | |
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ] | |
# ArgumentError: invalid number of elements (0 for 1..2) | |
# from (pry):1:in `[]' |
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
#!/usr/bin/env ruby | |
require 'qif' | |
if ARGV.size != 1 | |
$stderr.puts "usage: fix-credit-card-qif-and-load.rb <CC qif file>" | |
end | |
input_filename = ARGV[0] | |
output_filename = input_filename.sub(/\.qif/, "-fixed.qif") |
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
fizz = [nil, nil, "Fizz"].cycle | |
buzz = [nil, nil, nil, nil, "Buzz"].cycle | |
(1..100).zip(fizz, buzz) do |num, *fb| | |
puts fb.compact.reduce(:+) || num | |
end |
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
Process: Tweetbot [10718] | |
Path: /Applications/Tweetbot.app/Contents/MacOS/Tweetbot | |
Identifier: com.tapbots.TweetbotMacAdHoc | |
Version: 0.8.0 (758) | |
Code Type: X86-64 (Native) | |
Parent Process: launchd [261] | |
Date/Time: 2012-09-21 13:10:53.983 +0100 | |
OS Version: Mac OS X 10.7.5 (11G56) | |
Report Version: 9 |
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
# As seen in Ruby Weekly newsletter http://rubyweekly.com/archive/102.html | |
# http://www.alphasights.com/apply/ruby-developer-london | |
by_time = log.reduce(Hash.new{|hash,key| hash[key] = {}}) do |memo, val| | |
memo[val[:time]].merge!(val.reject{|k,v| k == :time}) | |
memo | |
end | |
by_time.map{|k,v| v.merge(time: k)} |
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
# from the top level of an extracted report tarball | |
$ find . -type d -depth 1 | xargs -I {} ./filename_fixer.sh {} |
NewerOlder