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 'benchmark' | |
module MyShortcuts | |
def consonants | |
self.gsub /[aeiuo0-9]/i, '' | |
end | |
def vowels | |
self.gsub /[^aieou]/i, '' | |
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
module MyString | |
def consonants | |
self.gsub /[aeiuo0-9]/i, '' | |
end | |
def vowels | |
self.gsub /[^aieou]/i, '' | |
end | |
def capitols |
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 MyString | |
attr_accessor :str | |
def initialize str | |
self.str = str | |
end | |
def consonants | |
str.gsub /[aeiuo0-9]/i, '' | |
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
module Logfiles | |
def name | |
self.sub(/\.gz$/) | |
end | |
def skip? | |
!(@options[:unzip] && self.gzip?) | |
end | |
def gzip? |
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
Dir['*'].each do |file| | |
gzip = false | |
if file.match(/\.gz$/) | |
use_file = file.sub(/\.gz$/) | |
gzip = true | |
else | |
use_file = file | |
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
def github_user | |
@github_user ||= begin | |
github_user, shell_user = %x{git config --get github.user}.chomp, ENV['USER'].to_s | |
raise Exception, 'Unable to determine github user' if (github_user + shell_user).empty? | |
github_user.empty? ? shell_user : github_user | |
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
ruby-1.9.2-p0 > a = []; ObjectSpace.each_object(Kata) {|o| a << o.class if o.respond_to? 'gets'} | |
=> 20576 | |
ruby-1.9.2-p0 > a | |
=> [IRB::Locale, File, ARGF.class, IO, IO, IO, Module, RubyLex, IO, IO, IRB::ReadlineInputMethod] |
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
1.upto(10) {|i| puts %w{current after before}[i <=> 5]} |
NewerOlder