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 'autotest/timestamp' | |
IMAGES_ROOT = File.expand_path("~/.dotfiles/autotest_images/small") | |
module Autotest::LibNotify | |
def self.notify(title, msg, urgency=:normal) | |
img = File.join(IMAGES_ROOT, "#{title.downcase}.png") |
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 | |
module ClassAccessors | |
def self.included(klass) | |
class << klass | |
def class_attr_reader(*args) | |
args.each do |attr| |
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 | |
class Array | |
def rotations | |
enum = Enumerator.new do |yielder| | |
r = dup | |
length.times do | |
yielder << r | |
r = r.rotate |
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
guard 'livereload' do | |
watch(%r{app/.+\.(erb|haml)}) | |
watch(%r{app/helpers/.+\.rb}) | |
watch(%r{(public/|app/assets).+\.(css|js|html)}) | |
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] } | |
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] } | |
watch(%r{config/locales/.+\.yml}) | |
end | |
guard 'spork', :wait => 30, :rspec => true, :rspec_env => { 'RAILS_ENV' => 'test' } do |
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
ObjectSpace.each_object(Class) do |klass| | |
puts klass.name if klass < Enumerable | |
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 ColorString < String | |
ABORT = "\e[0m" | |
ESC_SQS = { | |
:red => "\e[1m\e[31m", | |
:dark_red => "\e[31m", | |
:green => "\e[1m\e[32m", | |
:dark_green => "\e[32m", | |
:yellow => "\e[1m\e[33m", | |
:dark_yellow => "\e[33m", | |
:blue => "\e[1m\e[34m", |
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
PROGS = $(patsubst %.c, %, $(wildcard *.c)) | |
all: | |
make $(PROGS) | |
clean: | |
rm -f $(PROGS) |
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 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.on('-n') { options[:number_all_lines] = true } | |
opts.on('-b') { options[:number_nonblank_lines] = true } | |
opts.on('-s') { options[:squeeze_blank_lines] = true } |
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
1.upto(100) do |number| | |
str = '' | |
str << 'Fizz' if (number % 3).zero? | |
str << 'Buzz' if (number % 5).zero? | |
str << number.to_s if str.empty? | |
puts str | |
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 'forwardable' | |
class Stack | |
OverflowError = Class.new StandardError | |
UnderflowError = Class.new StandardError | |
extend Forwardable | |
def_delegators :@ary, :empty?, :size |
OlderNewer