Skip to content

Instantly share code, notes, and snippets.

View maraigue's full-sized avatar

H.Hiro maraigue

View GitHub Profile
@maraigue
maraigue / find_date_from_PI.rb
Created March 15, 2009 04:49
円周率の中から、日付とみなせる10桁の部分文字列を発見する
#!/usr/bin/env ruby
# 円周率の中から、日付とみなせる10桁の部分文字列を発見する
# (http://d.hatena.ne.jp/hyuki/20090314#pi)
# PI_STRは、円周率の小数第1位~500位を文字列で表したもの
# from ftp://pi.super-computing.org/pub/pi10m/pi10m.ascii.01of10
PI_STR = (
"14159265358979323846264338327950288419716939937510"+
"58209749445923078164062862089986280348253421170679"+
@maraigue
maraigue / kozirokyun.js
Created March 22, 2009 15:41
Twitterのページ中の「@koziro_P」をすべて「@こじろーきゅん」に置換
// Twitterのページ中の「@koziro_P」をすべて「@こじろーきゅん」に置換
// 使い方:以下のコードをコピーし、ブラウザのアドレスバーに貼り付けてEnter
javascript:(function(){document.body.innerHTML=document.body.innerHTML.replace(/>koziro_P?/g,'>こじろーきゅん')})();
// 3/24 0:45(JST)更新:「@koziro_P」のほか「@koziro_」も置換対象に追加。
@maraigue
maraigue / show-my-crontab.sh
Created March 27, 2009 13:37
現在のユーザのcrontabを表示する
#!/bin/sh
EDITOR=cat crontab -e 2>/dev/null
#!/bin/sh
# Twitterクライアント P3:PeraPeraPrv
# (http://sites.google.com/site/peraperaprv/)を
# 最新版に更新する
#
# PeraPeraPrv.jarのあるディレクトリにこのファイルを置き、
# 最新版に更新したいときに実行する。
# Remove all old files and download P3 archive
{てってってー言語 http://chiraura.hhiro.net/tettette/}
{内容はこんなところです。}
ー\d00006\d00012てー {0番目の値に6を、1番目の値に12をセットする。}
{方針としては、4番目の値に最終的な結果を格納する。}
てっててーてっててー {ポインタを0に戻す}
てってっててー
  {足し算の回数カウントのため、0番目の値を1減らす}
  てっー
@maraigue
maraigue / bombtter-status.rb
Created April 23, 2009 16:39
@bombtterの忙しさ(爆発要求からかかった時間)を表示
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'open-uri'
require 'json'
require 'time'
# @bombtterの忙しさ(爆発要求からかかった時間)を表示
def main
@maraigue
maraigue / montmort.rb
Created April 24, 2009 14:31
モンモールの問題
#!/usr/bin/env ruby
# モンモールの問題
# http://blog.livedoor.jp/maraigue/archives/884785.html
MAX = 20
# 順列を計算する
class Integer
def P(other) # a.P(b) と書くことで aPb を計算できるようにする
@maraigue
maraigue / decide-if-comment.rb
Created April 30, 2009 08:31
与えられた文字列の先頭が、特定の文字(ASCIIに限定してよい)であるか判定(Ruby1.8, 1.9共通)
#!/usr/bin/env ruby
# 与えられた文字列の先頭が "#" であるか判定
def comment?(str)
str[0] == "#"[0]
end
@maraigue
maraigue / yayoi.rb
Created May 8, 2009 17:45
うっうー!
#!/usr/bin/env ruby1.9
# -*- coding: utf-8 -*-
# 要 Ruby1.9
class Yayoi
def *(other); self; end
def <(other); puts other; false; end
end
ζ = Yayoi.new
@maraigue
maraigue / ReTweet.js
Created May 24, 2009 02:27
Source code for Twitter "ReTweet" bookmarklet (use in Twitter status page)
(function(){
var h,x,b;
if(location.href.match(/^https?:\/\/(m\.|explore\.)?twitter\.com\/([0-9A-Z_a-z]+)\/status/)){
h="RT+@"+RegExp.$2+":+";
}else{
alert("Not in a tweet page!");
return;
}
x=(document.getElementsByTagName("body"))[0].innerHTML.match(/<span class="?entry-content"?>(.+?)<\/span>/ig);
if(x && x.length==1){