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 |
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 | |
`which' command for Ruby libraries. | |
=end | |
lib = ARGV.shift | |
exts = %w/ .rb .so .dll / | |
puts $LOAD_PATH.map{|path| |
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 | |
# -*-coding:utf-8-*- | |
$VERBOSE = true | |
=begin | |
Project Euler: 2 | |
By considering the terms in the Fibonacci sequence whose values do not exceed four million, | |
find the sum of the even-valued terms. | |
=end | |
fib = Hash.new{|hsh, n| hsh[n] = hsh[n-2] + hsh[n-1] } |
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 python | |
import random | |
def choice_by(seq, criteria): | |
""" | |
Choose an elements from sequence with weight at random. | |
""" | |
#Initial value | |
itr = iter(seq) |
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
#!/bin/sh | |
story_id=$(git rev-parse --abbrev-ref HEAD | sed -n 's#.*stories/\([0-9]\+\).*#\1#p') | |
if [ -n "$story_id" ]; then | |
echo user story: https://www.pivotaltracker.com/story/show/$story_id >> $1 | |
fi |