Skip to content

Instantly share code, notes, and snippets.

@kapcod
kapcod / ilya.track_sleep.plist
Created May 24, 2016 10:46
Track sleep of the computer with Mac OSX agent config for autoload
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ilya.track_sleep</string>
<key>Program</key>
<string>/Users/sa/track_sleep.rb</string>
<key>WorkingDirectory</key>
<string>/Users/sa</string>
@kapcod
kapcod / find-commit.rb
Created May 1, 2016 15:43
Finds git commit that merged other commit into master
commit = ARGV[0]
master = ARGV[1] || 'origin/master'
unless commit
puts "Usage: find-commit.rb commit [master-branch]"
puts "Will show commit that merged <commit> into <master-branch>"
exit 1
end
parents = `git rev-list #{commit}..#{master} --reverse --first-parent --merges`.split("\n")
@kapcod
kapcod / deep_freeze.rb
Last active July 6, 2017 08:32
Ruby Deep Freeze for Hash and Array classes
# Adds deep_freeze! method to Hash
Hash.class_eval do
def deep_freeze!
each_value{|val| val.deep_freeze! if val.respond_to?(:deep_freeze!) }
freeze
end
end
# Adds deep_freeze! method to Array
Array.class_eval do