Skip to content

Instantly share code, notes, and snippets.

View cho45's full-sized avatar

Satoh, Hiroh cho45

View GitHub Profile
@cho45
cho45 / reproxy-and-serverpush.t
Last active April 5, 2016 09:34
commit: e01f1ade2d55a5dcc33d04a89c757250c75a5831
subtest "reproxy and server-push" => sub {
plan skip_all => 'nghttp not found'
unless prog_exists('nghttp');
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
reproxy: ON
mruby.handler: |
"arm-none-eabi-size" -B -d .pioenvs/lpc1114fn28/firmware.elf
text data bss dec hex filename
17476 128 440 18044 467c .pioenvs/lpc1114fn28/firmware.elf
arm-none-eabi-objcopy -O binary .pioenvs/lpc1114fn28/firmware.elf .pioenvs/lpc1114fn28/firmware.bin
text data bss dec hex filename
22948 124 340 23412 5b74 .pioenvs/lpc1114fn28/firmware.elf
arm-none-eabi-g++ --version
arm-none-eabi-g++ (GNU Tools for ARM Embedded Processors) 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
def sizeof(template)
x = Class.new(Numeric) do
def to_str; ""; end
def to_int; 0; end
# implicit to_f is called only with Numeric subclass
def to_f; 0.0; end
end.new
size = template.scan(/([a-zA-Z][_!]?[<>]?)([0-9]*)/).reduce(0) {|r,(_,n)|
r + (n.empty?? 1 : n.to_i)
}
#!ruby -v
string = "\xA9foobar".force_encoding("ASCII-8BIT")
p string.unpack("C*") == "\xA9foobar".unpack("C*")
#=> true
p string == "\xA9foobar"
#=> false (depends on magic comment, default literal is UTF-8)
#!/usr/bin/env ruby
require "serialport"
SerialPort.class_eval do
TCGETS2 = 0x802c542a
TCSETS2 = 0x402c542b
CBAUD = 0x100f
BOTHER = 0x1000
@cho45
cho45 / main.cpp
Last active January 13, 2016 16:57
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include "rtc_memory.hpp"
#include "config.h"
WiFiClient wifiClient;
struct {
#include <iostream>
// デストラクタで func を実行するだけ
template <class T>
class ScopeGuard {
const T func;
public:
ScopeGuard(T f) : func(f) {}
~ScopeGuard() {
func();
#include <cstdio>
#include <stdint.h>
#include <iostream>
template <class T, class U>
void is(T got, U expected) {
if (got == expected) {
std::cout << "ok" << std::endl;
} else {
std::cout << "not ok " << got << " != " << expected << std::endl;
}
@cho45
cho45 / disasm
Last active December 29, 2015 16:22
avr-objdump -d main.elf
main.elf: file format elf32-avr
Disassembly of section .text:
00000000 <__vectors>:
0: 34 c0 rjmp .+104 ; 0x6a <__ctors_end>
2: 00 00 nop