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 String | |
def strimwidth(width) | |
self.split(//)[0...width].join | |
end | |
end | |
#see also http://www.ruby-lang.org/ja/man/html/Array.html#self.5bstart.2e.2eend.5d |
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 = Hash.new {|h, k| h[k] = Hash.new(&h.default_proc) } |
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 | |
for n in 1..30 | |
if 0 == n % 15 | |
p "fizzbuzz" | |
elsif 0 == n % 5 | |
p "buzz" | |
elsif 0 == n % 3 | |
p "fizz" | |
else |
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
preexec() { | |
if [ ${1} ]; then | |
key=`ruby -rubygems -e 'require "pit";print Pit.get("outputz.com")["key"]'` | |
curl -s http://outputz.com/api/post -F key=${key} -F uri=http://zsh.localhost/ -F size=${#1} >/dev/null | |
fi | |
} |
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 -Ku | |
arr = ["abc","foo","def","foo","ghi","foo","jkl","bar","mno","bar","pqr"] | |
v = "" | |
i = 0 | |
c = 0 | |
arr.each do |n| | |
arr.each do |m| |
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 -Ku | |
# abcdefghijklmnopqrstuvwxyz | |
# bcdefghijklmnopqrstuvwxyza | |
# cdefghijklmnopqrstuvwxyzab | |
# defghijklmnopqrstuvwxyzabc | |
# .......................... | |
# wxyzabcdefghijklmnopqrstuv | |
# xyzabcdefghijklmnopqrstuvw | |
# yzabcdefghijklmnopqrstuvwx |
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 -Ku | |
require 'rubygems' | |
require 'RMagick' | |
require 'digest/sha1' | |
Dir::glob("/home/foo/*.jpg").each do |f| | |
original = Magick::Image.read(f).first | |
resized = original.change_geometry("200x200") { |cols, rows| original.thumbnail(cols, 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
#!/usr/bin/env ruby | |
# vim:fileencoding=utf-8 | |
def lenghten(text) | |
uri = URI(text) | |
Net::HTTP.start(uri.host, uri.port).head(uri.request_uri)["Location"] | |
rescue | |
nil | |
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:fileencoding=utf-8 | |
require 'socket' | |
require 'digest/sha1' | |
def send(msg) | |
print msg + "\r\n" |
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
javascript:args = '%s'.split(/ /i); if (args.length > 1) { var serv = args[0]; var id = args[1];} else { var serv = 'd'; var id = args[0] } location.href = "http://" + serv + ".hatena.ne.jp/" + id; |
OlderNewer