Skip to content

Instantly share code, notes, and snippets.

View kiyoka's full-sized avatar

Kiyoka Nishiyama kiyoka

View GitHub Profile
@kiyoka
kiyoka / rspec_formatter_for_emacs.rb
Created August 22, 2011 21:59
RSpec formatter for Emacs E-x compile feature
require 'rspec/core/formatters/progress_formatter'
# Example of a formatter with custom bactrace printing. Run me with:
# ruby bin/spec xxxxx.rb -r ./test/rspec_formatter_for_emacs.rb -f CustomFormatter
class CustomFormatter < RSpec::Core::Formatters::ProgressFormatter
def backtrace_line(line)
str = line.gsub(/([^:]*\.rb):([0-9]+):in /) do
path = "#{$1}"
lineno = "#{$2}"
if path.match( /lib/ ) and path.match( /rspec/ )
@kiyoka
kiyoka / watcher.sh
Created January 24, 2012 12:15
hourly restarter for Kahua workers
#!/bin/bash
# Please specify OT_SITE variable in config.sh
source config.sh
restart_workers() {
# ids of kahua workers
ids=`kahua-admin -S=$OT_SITE ls | awk ' $1 ~ /[0-9]+/ { print $1}'`
echo ids: $ids
@kiyoka
kiyoka / Using fuzzy-string-match from irb.
Created March 27, 2012 21:56
fuzzy-string-match and RubyInline
# I suspect RubyInline generates .so files on your ~/.ruby_inline directory.
~ $ which ruby
/usr/local/bin/ruby
~ $ uname -a
Linux genkan 2.6.32-5-amd64 #1 SMP Thu Nov 3 03:41:26 UTC 2011 x86_64 GNU/Linux
~ $ cat /etc/debian_version
6.0.4
~ $ gem list fuzzy
@kiyoka
kiyoka / eager.scm
Created August 11, 2012 11:05
example #1 eager filter
#!/bin/sh
:; #-*- mode: nendo; syntax: scheme -*-;;
:; exec /usr/local/bin/nendo $0 $*
;; print the peek memory usage of this process.
(define (print-peek-memory)
(with-open "|cat /proc/#{Process.pid}/status"
(lambda (f)
(STDERR.puts (+ "=> " (car (to-list (f.readlines.grep #/vmpeak/i))))))))
@kiyoka
kiyoka / generator.scm
Created August 11, 2012 11:07
example #2 filter with generator
#!/bin/sh
:; #-*- mode: nendo; syntax: scheme -*-;;
:; exec /usr/local/bin/nendo $0 $*
;; print the peek memory usage of this process.
(define (print-peek-memory)
(with-open "|cat /proc/#{Process.pid}/status"
(lambda (f)
(STDERR.puts (+ "=> " (car (to-list (f.readlines.grep #/vmpeak/i))))))))
@kiyoka
kiyoka / lazy.scm
Created August 11, 2012 11:08
example #3 lazy filter
#!/bin/sh
:; #-*- mode: nendo; syntax: scheme -*-;;
:; exec /usr/local/bin/nendo $0 $*
;; print the peek memory usage of this process.
(define (print-peek-memory)
(with-open "|cat /proc/#{Process.pid}/status"
(lambda (f)
(STDERR.puts (+ "=> " (car (to-list (f.readlines.grep #/vmpeak/i))))))))
@kiyoka
kiyoka / lazy_syntax.scm
Created August 11, 2012 12:18
lazy special form sample
(define-syntax lazy
(syntax-rules ()
((lazy)
(error "lazy requires (lazy s-expression)"))
((lazy s-exp)
(let-syntax
((map
(syntax-rules (%lazy-map)
((map)
(error "map requires (map func lst ...)"))
@kiyoka
kiyoka / sqlite3_error_message.txt
Created August 19, 2012 02:18
Sqlite3 install error message
sqlite3 install fails. on Debian 6.0 enviroment.
Ruby 1.9.3-p194 was built from source code.
~ $ dpkg --list | grep sqlite3
ii libaprutil1-dbd-sqlite3 1.3.9+dfsg-5 The Apache Portable Runtime Utility Library - SQLite3 Driver
ii libsqlite3-0 3.7.3-1 SQLite 3 shared library
ii libsqlite3-dev 3.7.3-1 SQLite 3 development files
ii sqlite3 3.7.3-1 A command line interface for SQLite 3
@kiyoka
kiyoka / decrypt_aws_password.sh
Created October 9, 2012 12:03
Decrypt password tool for windows EC2 instance
#!/bin/bash
#
# Decrypt password tool for windows EC2 instance
#
# 1. Launch windows instance
# 2. Select [Get System Log] item from [Instance Actions] pull down menu.
# 3. Copy the text between the <password> and </password> tags into a temp file.
# 4. Decrypt the file
# decrypt_aws_password.sh tempfile.txt
#
@kiyoka
kiyoka / pastehub_debian_package_error.txt
Created October 24, 2012 13:41
Error message on pastehub debian package.
root@genkan:/tmp# dpkg -i --force-architecture pastehub_0.1.5-2_i386.deb
dpkg: 警告: --force が有効なので、問題を無視します:
パッケージアーキテクチャ (i386) がシステム (amd64) と一致しません
未選択パッケージ pastehub を選択しています。
(データベースを読み込んでいます ... 現在 130296 個のファイルとディレクトリがインストールされています。)
(pastehub_0.1.5-2_i386.deb から) pastehub を展開しています...
pastehub (0.1.5-2) を設定しています ...
/opt/pastehub/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.