Skip to content

Instantly share code, notes, and snippets.

outdated = `port outdated`.split("¥n")
if /No installed ports are outdated./ =~ outdated[0]
puts outdated[0]
exit 0
end
unless /The following installed ports are outdated:/ =~ outdated[0]
$stderr.puts "port outdated failed, maybe..."
$stderr.puts *outdated
exit 1
@nagachika
nagachika / eucjp_filter.rb
Created July 24, 2009 05:38
termtter plug-in for euc-jp terminal
# -*- coding: utf-8 -*-
# Termtter plugins for EUC-JP terminal.
#
require "kconv"
module ::Readline
class << self
alias :readline_old :readline
end
@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 / sine.cpp
Created August 10, 2009 15:23
RtAudio example - Sine Wave Tone (440Hz)
// RtAudio exsample - Sine Wave (440Hz)
#include <math.h>
#include <RtAudio/RtAudio.h>
#if defined(__cplusplus)
extern "C" {
#endif
@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