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
=begin | |
Termtter plugin. | |
Mark everytime timeline is updated. inspired by plugin/mark.rb | |
=end | |
config.plugins.mark_on_update.set_default( :wrap_color, 'on_red' ) | |
config.plugins.mark_on_update.set_default( :time_format, 'TIMELINE at %R' ) | |
Termtter::Client.register_hook( | |
:name => :mark_on_update, | |
:points => [:post_filter], |
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/ruby -wKu | |
# vim: set fileencoding=utf-8 : | |
=begin | |
return the results of both Enumerable#take and Enumerable#drop | |
=end | |
module Enumerable | |
def split_between val | |
first = true | |
first_ary = [] |
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 'socket' | |
module SocketSpecs | |
# helper to get the hostname associated to 127.0.0.1 | |
def self.hostname | |
# Calculate each time, without caching, since the result might | |
# depend on things like do_not_reverse_lookup mode, which is | |
# changing from test to test | |
Socket.getaddrinfo("127.0.0.1", nil)[0][2] | |
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
#!/usr/bin/ruby -wKu | |
# vim: set fileencoding=utf-8 : | |
class ObjectPattern | |
def initialize obj, method=:[] | |
@delegate_object = obj | |
@delegate_method = method | |
end | |
attr_reader :delegate_object, :delegate_method | |
def === other |
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 | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
##DIDN'T WORK!!## | |
#see( Japanese ) http://www.ruby-lang.org/ja/man/html/_C0A9B8E6B9BDC2A4.html#case | |
print 'foo/bar/hoge: ' | |
case gets #no chomp | |
when *DATA | |
puts 'former when caluse.' |
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/r | |
TSVSNAP.FILE = paste("snap/", Sys.Date(),".tsv", sep="") | |
tsvsnap = function(obj, ...){ | |
UseMethod("tsvsnap") | |
} | |
tsvsnap.summary.lm = function(obj) tsvsnap.table( as.table( coefficients( obj ) ) ) | |
tsvsnap.table = function(obj){ | |
cat("", colnames(obj), file=TSVSNAP.FILE, sep="\t", append=TRUE, "\n") | |
rows = rownames(obj) | |
row.num = length(rows) |
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 each_with_object(memo, &block) | |
each do |element| | |
block.call(element, memo) | |
end | |
memo | |
end unless public_method_defined? :each_with_object | |
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
#!/usr/bin/env ruby | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
=begin | |
Count the number of characters in the clipboard. | |
=end | |
require 'rubygems' | |
require 'clipboard' | |
require 'kconv' |
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 | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
require 'set' | |
def dig *args | |
args.inject{|x, y| 10 * x + y} | |
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
#!/usr/bin/env ruby | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
=begin | |
Queue#to_enum | |
=end | |
require 'thread' | |
class Queue |
OlderNewer