gdgdiler@toRuby
元気ですかーーッ?!元気があれば何でもできる!
#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() { |
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 |
ぐんまRuby会議01参加者のためのしおりです。
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] |