Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'json'
require 'time'
repo = 'xxxx/yyyy'
run = false
usage = "Usage: #{$0} [--run]"
#include <M5StickC.h>
#include <HTTPClient.h>
#include <Ticker.h>
#include <WiFi.h>
#define M5_LED_OFF HIGH
#define M5_LED_ON LOW
#define LCD_BACKGROUND_COLOR BLACK
class Sudoku
def initialize(matrix)
@matrix = matrix.split("\n").map(&:chars)
end
def run
show
step while @matrix.flatten.include?(' ')
end
class GameOfLife
def initialize
@field = Field.new
end
def run(fps:)
loop do
puts "\e[0;0H\e[2J#{@field}"
sleep 1.0 / fps
step
class RPN
def initialize(expression)
@tree = Tree.new(expression)
end
def calculate
@tree.calculate
end
class Tree
@kirikiriyamama
kirikiriyamama / tmux.md
Last active January 1, 2016 00:39
install tmux 1.8 on CentOS 6.4

install deps

$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
$ tar zxf libevent-2.0.21-stable.tar.gz
$ cd libevent-2.0.21-stable
$ ./configure
$ make
$ sudo make install
$ su -
# echo /usr/local/lib > /etc/ld.so.conf.d/libevent.conf
# ldconfig
@kirikiriyamama
kirikiriyamama / rpn.rb
Created September 14, 2013 15:19
tapで逆ポーランド記法
def rpn(expression, separator = '')
[].tap do |stack|
expression.split(separator).each do |token|
if token =~ /[\d.]+/
stack.push token.to_f
else
stack.push stack.pop(2).inject(token)
end
end
end.pop
@kirikiriyamama
kirikiriyamama / weechat.md
Last active December 23, 2015 01:49
weechat いろいろ

Install

$ sudo yum install weechat

Start

$ weechat-curses

Add IRC server

/server add {server} {host}[/{port}] -autoconnect

Add channel

@kirikiriyamama
kirikiriyamama / rpn.rb
Created September 14, 2013 14:28
injectで逆ポーランド記法
def rpn(expression, separator = '')
expression.split(separator).inject([]) do |stack, token|
if token =~ /[\d.]+/
stack.push token.to_f
else
stack.push stack.pop(2).inject(token)
end
end.pop
end
@kirikiriyamama
kirikiriyamama / rpn.rb
Created September 14, 2013 14:25
逆ポーランド記法
def rpn(expression, separator = '')
stack = []
expression.split(separator).each do |token|
if token =~ /[\d.]+/
stack.push token.to_f
else
rhs = stack.pop
lhs = stack.pop
stack.push lhs.send(token, rhs)
end