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 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
#!/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
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 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 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 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 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
alias tweet='cat ~/your-token.yaml | tw-post.rb' |
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/bash | |
#Execute command twice. | |
#Sample to show that | |
# It's more useful to use +eval+ and +source+ | |
# if you want to decide which command to execute in your script | |
shopt -s expand_aliases # don't work even if expand_aliases is enabled. | |
# $@ #don't work well: don't expand the alias |
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
"Settings | |
let g:vimplayer_mplayer_extra_options = [] | |
let s:vimplayer_pipe_mplayer = {} | |
function! vimplayer#play(...) abort | |
let vimplayer_filenames = a:000 | |
if !empty(s:vimplayer_pipe_mplayer) "mplayer already playing something | |
call s:vimplayer_pipe_mplayer.stdin.write("quit\n") |