Skip to content

Instantly share code, notes, and snippets.

@yamaimo
yamaimo / stairs.rb
Last active June 1, 2019 02:41
階段昇降
# 毎日『m段上ってn段下がる』を繰り返したら、x日目にd段目に初めて着いた。
# xをd,m,nで表せ。
# 文字はすべて正の整数で、m>nとする。
# https://twitter.com/hyuki/status/1134018952416321536
class Stairs
def initialize(dest, up, down)
@dest = dest
@up = up
@down = down
@yamaimo
yamaimo / snapshot.rb
Created July 26, 2020 13:31
Simple Snapshot Script
#!/usr/bin/env ruby
require 'fileutils'
USAGE =<<END_OF_USAGE
$ ./snapshot <target>.<ext>
Save snapshot of taget into HISTORY_DIR/<target>-yyyymmdd.<ext>
END_OF_USAGE
# 設定 --------------------
@yamaimo
yamaimo / attr_sample.rb
Last active June 23, 2021 01:44
Curses for Ruby
#!/usr/bin/env ruby
# coding: utf-8
require 'curses'
Curses.init_screen
text = "TEXT"
attrs = {
normal: Curses::A_NORMAL,