$ 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
require 'time' | |
repo = 'xxxx/yyyy' | |
run = false | |
usage = "Usage: #{$0} [--run]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sudoku | |
def initialize(matrix) | |
@matrix = matrix.split("\n").map(&:chars) | |
end | |
def run | |
show | |
step while @matrix.flatten.include?(' ') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RPN | |
def initialize(expression) | |
@tree = Tree.new(expression) | |
end | |
def calculate | |
@tree.calculate | |
end | |
class Tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder