Skip to content

Instantly share code, notes, and snippets.

View tana's full-sized avatar

Satoshi Tanaka tana

View GitHub Profile
@tana
tana / play.html
Created April 3, 2012 14:19
diff再生
<html>
<head>
<title>diff player</title>
<script type="text/javascript" src="play.js"></script>
</head>
<body>
<textarea id="text"></textarea>
<br />
<textarea id = "diff"></textarea>
<button id="start">start</button>
@tana
tana / test.html
Created April 2, 2012 15:45
js diff test
<html>
<head>
<title>difftest</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<textarea id="text"></textarea>
<br />
<textarea id="res"></textarea>
</body>
@tana
tana / hs-devdsp.hs
Created February 3, 2012 11:18
Haskellで音を鳴らす
-- http://d.hatena.ne.jp/ku-ma-me/20100901/p1 ここ参考にして書いた
import Data.Char
samplingRate = 8000
sinWaveGen f cnt = sin (2 * pi * f / (fromIntegral samplingRate) * cnt * 1.0)
sinWave f = map (\i -> 256 / 2 + 60 * sinWaveGen f i) [1..]
wave = (take 4000 $ sinWave 440) ++ (take 4000 $ sinWave 880)
@tana
tana / openuser.rb
Created September 30, 2011 10:39
mikutterでユーザー名を指定して開くプラグイン
# ユーザー名を指定して開く 変なところあるかも
require 'net/http'
# Userオブジェクト生成 idはスクリーンネーム(例: "toshi_a")
# ここ適当なのでもっと良い方法があるかも
def openuser_create_user(id)
json = nil
Net::HTTP.start("api.twitter.com", 80) {|http|
res = http.get("/1/users/show/" + id + ".json")
@tana
tana / gtk_webicon.rb
Created September 23, 2011 14:05
mikutter icon memory cache
# -*- coding: utf-8 -*-
require File.expand_path('utils')
miquire :core, 'environment'
miquire :mui, 'skin'
require 'gtk2'
require 'net/http'
require 'uri'
require 'digest/md5'
require 'thread'
@tana
tana / iconoverbutton_menu.txt
Created June 19, 2011 14:14
mikutterの改造
# cairo_miracle_painter.rb
def clicked(x, y, e)
@event = e
case e.button
when 1
iob_clicked
if not textselector_range
index = main_pos_to_index(x, y)
if index
l = message.links.segment_by_index(index)
@tana
tana / tco.rb
Created June 4, 2011 19:50
mikutterでt.coの短縮URLを戻すプラグイン。
miquire :core, 'messageconverters'
miquire :addon, 'addon'
class TCo < MessageConverters
require 'uri'
require 'net/http'
def plugin_name()
:tco
end
def shrink_url(url)
@tana
tana / sleepsort.rb
Created May 19, 2011 14:29
Sleep Sortみたいなの
# 元ネタ: http://dis.4chan.org/read/prog/1295544154
# Sleep Sortみたいなものを時間待ちも無ければプロセス生成も無い方法で
class A
def initialize(a)
@a = a
@b = a
end
def next
@a = @a - 1
SleepSort.add(@b) if @a == 0
@tana
tana / rbtest_d.d
Created April 13, 2011 15:51
D言語からRubyを呼び出す。コンパイルは「dmd rbtest_d.d -L-lruby1.8」
import std.string;
extern (C) {
alias uint VALUE;
extern void ruby_init();
extern VALUE rb_eval_string(const char*);
extern void ruby_cleanup(int);
}
int main() {
@tana
tana / orz2.rb
Created March 22, 2011 15:43
orzなスクリプト
require 'curses'
to_o_pos = [[3, 2], [4, 2], [5, 2], [2, 3], [6, 3], [2, 4], [6, 4], [2, 5], [6, 5], [3, 6], [4, 6], [5, 6]]
to_r_pos = [[9, 2], [12, 2], [13, 2], [9, 3], [11, 3], [9, 4], [10, 4], [9, 5], [9, 6]]
to_z_pos = [[16, 2], [17, 2], [18, 2], [19, 2], [20, 2], [19, 3], [18, 4], [17, 5], [16, 6], [17, 6], [18, 6], [19, 6], [20, 6]]
def make_rand_pos_arr(count)
arr = []
count.times {
arr << [rand(21), rand(9)]