Hello
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 Array | |
def eql_all? &block | |
block = lambda {|a|a} unless block | |
max=self.length | |
i=0 | |
c = block.( self[i] ) | |
n = nil | |
result = while i+1<max | |
n=block.(self[i+1]) | |
break false unless c == 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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'open-uri' | |
check = lambda {|i| open("http://www.pixiv.net/member.php?id=#{i}").read.index("該当ユーザーは既に退会したか、存在しないユーザーIDです")} | |
i=3600000 | |
loop do | |
print "#{i-=1000} " | |
break unless check.(i) |
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
var tiiki = ["hokkaido", | |
"aomori", | |
"iwate", | |
"miyagi", | |
"akita", | |
"yamagata", | |
"fukushima", | |
"ibaraki", | |
"tochigi", | |
"gunma", |
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 Hash; def &(x) self.merge(x) end 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
<?php | |
function getLabel($opt) | |
{ | |
$colors = Array(1=> "blue", 0=> "pink" ); | |
$namings = Array( "ちゃん", "くん", "さん", "君" ); | |
extract( array_merge(Array( "name"=> "", "sex"=> 0, "suffix"=>"", "coloring"=>"","school"=>false ), $opt) ); | |
$color = $colors[ $sex ]; | |
$naming = $names[ ($sex | (($age >= 12)*2)) ]; |
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
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zprofile | |
echo 'eval "$(rbenv init -)"' >> ~/.zprofile | |
git clone git://github.com/sstephenson/ruby-build.git | |
cd ruby-build | |
./install.sh | |
CONFIGURE_OPTS="--with-readline-dir=/usr/local" rbenv install 1.9.3-p0 | |
rbenv global 1.9.3-p0 | |
rbenv rehash |
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
def extract_tiny_url(url) | |
url = URI.parse(url) if url.is_a?String | |
TCPSocket.open(url.host, url.port) do|s| | |
s.write("GET #{url.path} HTTP/1.1") | |
s.write("\nHost: #{url.host}") | |
s.write("\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20100101 Firefox/11.0") | |
s.write("\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") | |
s.write("\nAccept-Language: ja-JP-mac,ja;q=0.8,en-US;q=0.5,en;q=0.3") | |
s.write("\n\n") | |
text = (s.readlines.join('').scan /URL=([a-z:\/\.\_0-9]*)/).flatten.first |
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 Enumerator | |
def filter(c=nil,&b) | |
s = self | |
e = ::Enumerator.new do |y| | |
s.each do |x| | |
y << (c||b).call(x) | |
end | |
end | |
return e unless c | |
e.each &b |
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 AccessLog | |
class Handler | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
session = env["rack.session"] && user_id = session["user_id"] | |
ipaddress = env["REMOTE_ADDR"] | |
user_agent = env["HTTP_USER_AGENT"] | |
referer = env["HTTP_REFERER"] |
OlderNewer