Skip to content

Instantly share code, notes, and snippets.

View vestige's full-sized avatar

Makoto Yonezawa vestige

View GitHub Profile
@seki
seki / co2.ino
Created April 11, 2020 16:31
M5Stack + MH-Z14 CO2 censor
#include <M5Stack.h>
#define NBIN 30
static int16_t s_ring[NBIN];
static int s_curr;
static int16_t s_bg;
static int s_delay = 20000;
static unsigned long s_tm;
void setup() {
@tkojitu
tkojitu / kaigi.md
Last active November 5, 2017 00:40

とちぎRuby会議07のレポート

書いた人

gdgdiler@toRuby

口上

元気ですかーーッ?!元気があれば何でもできる!

@seki
seki / shuffle.rb
Created May 21, 2013 15:37
merge sort for ikezawa-san
class Merge
def initialize(*fnames)
@file = fnames.collect {|fn| MergeFile.new(fn)}
delete_empty
end
def delete_empty
@file.delete_if {|f| f.empty?}
end
@seki
seki / erblock.rb
Created December 3, 2012 15:32
ERB and block
require 'erb'
class MyERB < ERB
class CompilerWithBlock < ERB::Compiler
def add_put_cmd(out, content)
out.push("#{@put_cmd} #{content_dump(content)}")
end
BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
def add_insert_cmd(out, content)
#include "stdafx.h"
#include <memory.h>
#include <map>
void add(
int *buffer,
std::map<int,int>& plot,
int key,
int value)
{
function Sandbox(){
    // 必要なモジュールの初期化
    for (var i = 0,len = modules.length; i < len; i++) {
        Sandbox.modules[modules[i]](this);
    }
}

ここでのthisはSandboxのインスタンスなので、

def measure(in_a)
rule = { 0=>[-1, 0], 1=>[ 0,-1], 2=>[ 1 ,0], 3=>[ 0, 1] }
m = {0=>[0,0]}
in_a.each_with_index do |a,i|
b = m[a[0]]
d = a[1]
m[i+1] = [b[0]+rule[d][0],b[1]+rule[d][1]]
end
t = m.values.transpose
[t[0].max-t[0].min+1, t[1].max-t[1].min+1]