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
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| $VERBOSE = true | |
| =begin | |
| Maybe usable as generator expression in Python | |
| requires ruby1.9 or facets ( >= 2.9.1 ) | |
| =end | |
| if RUBY_VERSION < '1.9' | |
| require 'rubygems' |
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
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| $VERBOSE = true | |
| =begin | |
| Maybe usable as generator expression in Python | |
| requires ruby1.9 or facets ( >= 2.9.1 ) | |
| =end | |
| $KCODE = 'u' if RUBY_VERSION < '1.9' |
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
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| module MyTwitterFavUtils | |
| FORMAT = 'tsv' | |
| SEP = "\t" | |
| FILE = 'fav-tweets.' + FORMAT | |
| BACKUP_SUFFIX = '~' | |
| TRUNCATE_LEN = 20 | |
| 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
| user system total real | |
| Array#push and join 0.360000 0.040000 0.400000 ( 0.398396) | |
| String#concat 1 0.240000 0.030000 0.270000 ( 0.267289) | |
| String#concat 2 0.260000 0.040000 0.300000 ( 0.297610) | |
| Array#join with a const 0.090000 0.030000 0.120000 ( 0.121947) | |
| String#concat with const 0.100000 0.030000 0.130000 ( 0.134064) |
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
| #!/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 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
| #!/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 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
| #!/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 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
| #!/usr/bin/env ruby | |
| # vim: set fileencoding=utf-8 : | |
| $VERBOSE = true | |
| =begin | |
| Queue#to_enum | |
| =end | |
| require 'thread' | |
| class Queue |
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
| #!/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 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
| #!/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' |