Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / date_conv.rb
Created February 21, 2015 22:34
def date_to_a(t)
[
"#{t.year}年",
"#{t.month}月",
"#{t.day}日",
" #{t.hour}時#{t.min}分",
]
end
def date_conv(t1, t2)
@kokudori
kokudori / レジスタベースVMの簡易実装雑感.md
Last active August 29, 2015 14:01
レジスタベースVMの簡易実装雑感

概要

簡単なレジスタベースVMを作り、fib(38)を実行した時のマイクロベンチ結果

実装

Rustで下位3bit tagged-poinetr

アドレスのアラインメントを利用した埋め込みを実装した処理系
オブジェクトは環境非依存で64bit固定
ポインタをmodifyする必要がある

Rustで上位16bit tagged-poinetr

@nixpulvis
nixpulvis / term_size.rb
Last active October 18, 2017 11:50
Get the terminal window size. Not in a bullshit ENV dependent manor.
# From the tty_ioctl man page in Linux.
#
# TIOCGWINSZ struct winsize *argp
# Get window size.
#
# TIOCSWINSZ const struct winsize *argp
# Set window size.
#
# The struct used by these ioctls is defined as
#
@yhara
yhara / lazy_fizzbuzz.rb
Created December 3, 2012 09:09
FizzBuzz using Enumerable#lazy.
fizzer = [nil, nil, "Fizz"].cycle
buzzer = [nil, nil, nil, nil, "Buzz"].cycle
puts (1..Float::INFINITY).lazy.zip(fizzer, buzzer)
.map{|i, fizz, buzz|
fizz || buzz ? "#{fizz}#{buzz}" : i
}
.first(20)