Skip to content

Instantly share code, notes, and snippets.

View tobynet's full-sized avatar

tobynet tobynet

  • Toyama, Japan
View GitHub Profile
@tobynet
tobynet / time-loop-story-lang_ja.rb
Created November 24, 2011 00:31
ループものの作品名を列挙するやつ for scraperwiki https://scraperwiki.com/scrapers/time-loop-story-lang_ja/
# -*- 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
@tobynet
tobynet / multilogger-test.rb
Created October 13, 2011 15:43
test for multiple logger
#!/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'
@tobynet
tobynet / sanmoji.rb
Created September 27, 2011 14:40 — forked from ssig33/sanmoji.rb
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
}
}
}
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
@tobynet
tobynet / hatebu_uzai.css
Created August 11, 2011 01:56 — forked from ssig33/hatebu_uzai.css
スッキリはてブエントリー
/*******************************************************
# これは何か
はてなのエントリーページをすっきりさせる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
- 及び旧ページの「コメントのみ表示」チェック状態
## エントリーページ場合分け用セレクタ
@tobynet
tobynet / git-aliases.zsh.erb
Created August 9, 2011 10:36
git-aliases generator for zsh. git のaliasからzshのalias設定を出力する
<% 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
@tobynet
tobynet / screen-detection.zsh
Created August 7, 2011 09:52
screen detection test
#!/bin/zsh
echo 'screen から起動されているかチェック'
echo 'screenから起動したshellから起動してください'
echo '結論としては、$STYをチェックするのが良さそうです'
echo
function check_screen() {
echo '## TERMをチェック'
# .screenrcで
# term xterm-256color
@tobynet
tobynet / hanamasize_proxy.rb
Created June 12, 2011 16:01 — forked from tobynet/pixelize_proxy.rb
hanamasize proxy
#!/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/