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 bash | |
cmd=$1 | |
function start_tor() { | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.tor.plist | |
} | |
function stop_tor() { | |
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.tor.plist |
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 bash | |
cmd=$1 | |
PROG=/usr/local/opt/varnish3/sbin/varnishd | |
VCL=/usr/local/etc/varnish/default.vcl | |
OPTS="-n /usr/local/var/varnish -f $VCL -s malloc,1G -T localhost:6082 -a :6081" | |
function start_varnish() { | |
echo "Running [$PROG $OPTS]" | |
$PROG $OPTS |
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 | |
# A Ruby bulk file renaming script | |
require 'fileutils' | |
require 'pry' | |
require 'colored' | |
require 'trollop' | |
class BulkFileRename | |
include FileUtils |
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 bash | |
# Script for ruby-install | |
build=`which ruby-install` | |
rubies="$HOME/.rubies" | |
if [[ ! -x $build ]]; then | |
echo "'brew install ruby-install' before using install_ruby" | |
exit 1 | |
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
#!/usr/bin/env ruby | |
require 'pry' | |
require 'colored' | |
require 'trollop' | |
class CherryPickExternal | |
attr_accessor :external_repo, :sha, :elapsed, :color_output, :test_run | |
def self.run(*args) | |
start_time = Time.now |
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 Hash | |
def grep(pattern) | |
inject([]) do |res, kv| | |
res << kv if kv[0] =~ pattern or kv[1] =~ pattern | |
res | |
end | |
end | |
# Usage { :a => 1, :b => 2, :c => 3}.except(:a) -> { :b => 2, :c => 3} | |
def except(*keys) |
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 Array | |
def count_occurrences | |
k = Hash.new(0) | |
self.each{|x| k[x] += 1} | |
k | |
end | |
def randomize | |
self.sort_by { rand } | |
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
class File | |
class Stat | |
def self.device_name(file) | |
Dir['/dev/*'].inject({}) { |h, v| | |
h.update(File.stat(v).rdev => v) | |
}.values_at(File.stat(file).dev).first || nil | |
end | |
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
class Fixnum | |
# Format a number with commas and a decimal point | |
def commify | |
to_s =~ /([^\.]*)(\..*)?/ | |
int, dec = $1.reverse, $2 ? $2 : "" | |
while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3') | |
end | |
int.reverse + dec | |
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
require 'thor' | |
require 'midwire_common' | |
module MidwireCommon | |
# RakeHelper helps to automate gem release and versioning tasks | |
class RakeHelper | |
include Rake::DSL if defined? Rake::DSL | |
def self.install_tasks(opts = {}) |