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
# -*- encoding: utf-8 -*- | |
%w|rubygems mechanize open-uri|.each{|x| require x} | |
target = "http://ja.wikipedia.org/wiki/%E3%83%AB%E3%83%BC%E3%83%97%E3%82%82%E3%81%AE" | |
# scrape | |
doc = Mechanize.new{|a|a.user_agent_alias = "Windows Mozilla"}.get(target) | |
# get stories only | |
stories = doc.search('#bodyContent .mw-content-ltr').text.scan(/『(.+?)』/).map(&:first).uniq |
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 | |
# -*- encoding: utf-8 -*- | |
# 複数のIOに出力したいテスト | |
# テストだけ書いた | |
# Rubyist Magazine - 標準添付ライブラリ紹介 【第 6 回】 委譲 http://jp.rubyist.net/magazine/?0012-BundledLibraries | |
# instance method Forwardable#def_delegators http://doc.ruby-lang.org/ja/1.9.2/method/Forwardable/i/def_delegators.html | |
require 'minitest/unit' |
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
require "mechanize" | |
alice = Mechanize.new | |
list = [] | |
%w{a b c d e f g h i j k l m n o p q l s t u v w x y z 1 2 3 4 5 6 7 8 9 0}.each{|x| | |
%w{a b c d e f g h i j k l m n o p q l s t u v w x y z 1 2 3 4 5 6 7 8 9 0}.each{|y| | |
%w{a b c d e f g h i j k l m n o p q l s t u v w x y z 1 2 3 4 5 6 7 8 9 0}.each{|z| | |
list << x+y+z | |
} | |
} | |
} |
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
require "mechanize" | |
alice = Mechanize.new | |
(0..20).each{|q| | |
t = q*50 + 1 | |
page = alice.get "http://tophatenar.com/ranking/subscriber/#{t}?blog=hatena" | |
page.root.xpath("//td[@class='odd']/a").map{|x| x["href"].split("/").last}.uniq.each{|d| | |
begin | |
page = alice.get "http://delicious.com/register" | |
form = page.forms[1] | |
form.username = d |
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
/******************************************************* | |
# これは何か | |
はてなのエントリーページをすっきりさせるcss | |
## 動作確認用 | |
- 新ページ http://b.hatena.ne.jp/entry/www.google.co.jp/ | |
- 旧ページ http://b.hatena.ne.jp/entry?mode=more&url=http%3A%2F%2Fwww.google.co.jp%2F | |
- 及び旧ページの「コメントのみ表示」チェック状態 | |
## エントリーページ場合分け用セレクタ |
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
<% aliases = `git config --global --get-regexp alias\..+`.split("\n"). | |
map{|alias_item| alias_item.scan(/^alias\.([\w\-]+)\s+(.+)$/).first }. | |
map{|x| | |
command = x[1].gsub("'", '"') | |
# beginning "!" | |
if result = command.scan(/^\!(.*)/).first | |
command = result[0] | |
else | |
command = "git #{command}" | |
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
#!/bin/zsh | |
echo 'screen から起動されているかチェック' | |
echo 'screenから起動したshellから起動してください' | |
echo '結論としては、$STYをチェックするのが良さそうです' | |
echo | |
function check_screen() { | |
echo '## TERMをチェック' | |
# .screenrcで | |
# term xterm-256color |
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 | |
require 'webrick' | |
require 'webrick/httpproxy' | |
require 'RMagick' | |
# curl -o files/hanamasa.png http://w.ikenie.com/hanamasa/hanamasa.png | |
handler = Proc.new() { |req,res| | |
if res['content-type'] =~ /png/ |