Skip to content

Instantly share code, notes, and snippets.

@nagachika
nagachika / .vimrc
Created July 30, 2009 04:36
Vim settings
set nocompatible
set noerrorbells
set backup
set backupdir=.backup,~/.vimbackup
set keywordprg=man
"set number
set ruler
set showmode
set showmatch
set ignorecase
@nagachika
nagachika / .irbrc
Created July 30, 2009 05:19
irb initialization file
require "irb/completion"
require "irb/ext/save-history"
IRB.conf[:SAVE_HISTORY] = 500
IRB.conf[:HISTORY_FILE] = ENV['HOME']+'/.irb_history'
if ENV["TS_SERVER"]
begin
require "drb"
require "rinda/rinda"
@nagachika
nagachika / .screenrc
Created July 30, 2009 05:24
screen initialization file
defescape ^Tt
escape ^Tt
bind ' ' windowlist -b
bind l windowlist -b
bind ^l windowlist -b
bind o focus
bind ^O focus
bind O focus up
@nagachika
nagachika / opt_size.patch
Created August 18, 2009 14:15
This patch add new instruction opt_size to ruby-1.9
Index: insns.def
===================================================================
--- insns.def (revision 24573)
+++ insns.def (working copy)
@@ -1945,6 +1945,39 @@
/**
@c optimize
+ @e optimized size
+ @j 最適化された recv.size()。
@nagachika
nagachika / Makefile.pd_external
Created September 14, 2009 14:59
Makefile for PureData external object
CC = gcc
CFLAGS = -I/Applications/Pd-extended.app/Contents/Resources/include \
-fPIC
LDSHARED = $(CC) -dynamic -bundle -undefined suppress -flat_namespace
PD_DYLIB_EXT=pd_darwin
SRC = helloworld.c
OBJ = ${SRC:.c=.o}
@nagachika
nagachika / spectrum.rb
Created October 28, 2009 15:35
spectrum analyzer using resonance
require "wavefile"
class Oscilator
def initialize(opt={})
@freq = opt[:freq] || 440.0
@sample_rate = opt[:sample_rate] || 44100
@delta_time = 1.0 / @sample_rate
# k/M (k = strength of spring, M = mass of object) => @k
@k = (2.0*Math::PI*@freq)**2
@nagachika
nagachika / ieee754.rb
Created November 9, 2009 04:29
IEEE 754 (double precision) decode practice.
def ieee754_double(num)
int64 = [num].pack("d").unpack("Q")[0]
sign = (int64 & (1 << 63)) == 0 ? 1 : -1
exp = (int64 & 0x7ff0000000000000) >> 52
frac = (int64 & 0x000fffffffffffff)
if exp == 0 and frac == 0
return sign * 0.0
end
@nagachika
nagachika / birthday_present.rb
Created November 10, 2009 16:26
Birthday present for id:ku-ma-me
#!/usr/bin/env ruby
"AAAAAAA AAAAAA
AggIA/B+ICAA AAIIFAIIQR
BAAAACCCICCEEIgAAAA/hBA/B+B
wAAAAII/4IAQAIAAAACCQBCAEACAA
AAAgkAQgBAAgAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAD/Bwfx/yBPwIQQgIIECB
AgSCFEEIECBAgQIEgSIiD+AgfwECB
IFBIggQIEIBA/yBfxwICCBBAQIE
@nagachika
nagachika / eigen_image.rb
Created April 13, 2010 16:33
create eigen image
# encoding: utf-8
#
require "narray"
require "png"
def read_pgm(filepath)
open(filepath) do |io|
raise "#{filepath}: only P5(Graymap rawbits) is supported" unless io.gets == "P5\n"
width, height = io.gets.split(/\s+/).map{|i| i.to_i }
@nagachika
nagachika / ao-render-gcd.rb
Created May 12, 2010 22:53
AO Bench script (Normal and GCD version)
# -*- encoding: utf-8 -*-
# AO render benchmark (GCD version for MacRuby 0.6)
# Original program (C) Syoyo Fujita in Javascript (and other languages)
# http://lucille.atso-net.jp/blog/?p=642
# http://lucille.atso-net.jp/blog/?p=711
# Ruby(yarv2llvm) version by Hideki Miura
# http://github.com/miura1729/yarv2llvm/blob/a888d8ce6855e70b630a8673d4cfe075a8e44f0e/sample/ao-render.rb
# Modified by Tomoyuki Chikanaga
#