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
def get_each_const(const, context=::Object) | |
const.to_s.split(/::/).inject(context) {|parent, c| | |
parent.const_get(c) | |
} | |
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
def import(feature, as={}) | |
ret = require feature | |
self.class.instance_eval do | |
as.each do |(orig, dest)| | |
c = const_get(orig) | |
remove_const(orig) if const_defined?(orig) | |
const_set(dest, c) | |
end | |
end unless as.empty? | |
ret |
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 | |
# | |
# usage: | |
# $ git clone git://github.com/motemen/git-vim.git git-vim | |
# $ ruby vsm.rb git-vim/ | |
VIMDIR = '~/.vim' | |
SRCDIR = ARGV[0] | |
require 'pathname' |
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
/* Shell Color */ | |
.bg-std { background-color: rgb( 51, 51, 49) } | |
.fg-std { color: rgb(230, 230, 230) } | |
.fg-black { color: rgb( 51, 51, 49) } | |
.fg-red { color: rgb(255, 51, 60) } | |
.fg-green { color: rgb( 40, 204, 76) } | |
.fg-yellow { color: rgb(224, 230, 57) } | |
.fg-blue { color: rgb( 46, 122, 230) } |
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
hash = {:a => 40, :b => 60, :c => 50, :d => 30} | |
# #sort_by -> #reverse | |
hash.sort_by {|k, v| v }.reverse | |
# => [[:b, 60], [:c, 50], [:a, 40], [:d, 30]] | |
# #sort_by | |
hash.sort_by {|k, v| -v } | |
# => [[:b, 60], [:c, 50], [:a, 40], [:d, 30]] |
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
module Enumerable | |
def like?(val, op = :===) | |
any? {|i| i.__send__(op, val) } | |
end | |
end | |
ignore_pattern = [/\.$/, /\.(?:svn|git)$/] | |
ignore_pattern.include?('..') # => false | |
ignore_pattern.like?('..') # => 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
class Greeting | |
def hello; end | |
private do | |
def bonjour; end | |
end | |
protected do | |
def guten_morgen; 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 Integer | |
def english_name(delimiter='-') | |
if self < 20 | |
english_table[self] | |
else | |
ret = english_table[(self / 10) * 10] | |
(self % 10) == 0 ? ret : ret + delimiter.to_s + english_table[self % 10] | |
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 TaniRyoko | |
def initialize(shout) | |
@shout = shout | |
end | |
def to_s | |
"#{@shout}! 新谷良子、#{@shout}!!" | |
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
TaniRyoko = "谷良子" | |
def new(syntanix, shout=nil) | |
if shout | |
puts "#{shout}! 新#{syntanix}, #{shout}!!!" | |
else | |
puts "New #{syntanix} って…100万回も言われてます。もうあきましたっ!!ばーかばーか。" | |
end | |
end |
OlderNewer