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
| #!/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 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
| #!/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 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 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 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 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 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 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 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 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 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
| 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 = {}) |
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
| require 'rubygems' | |
| require 'rake' | |
| require 'readline' | |
| require 'fileutils' | |
| require 'pry' | |
| module Bundler | |
| class GemHelper | |
| protected |
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 MidwireCommon | |
| class TimeTool | |
| # converts the given time (HH:MM:SS) to seconds | |
| # | |
| # +time+ the time-string | |
| def self.time_to_seconds(time) | |
| return -1 if time.nil? or time.strip.empty? | |
| times = time.split(/:/).reverse |
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 Time | |
| class << self | |
| def timestamp | |
| "#{Time.now.strftime("%Y%m%d%k%M%S")}" | |
| end | |
| end | |
| end |