Skip to content

Instantly share code, notes, and snippets.

View keiichiw's full-sized avatar

Keiichi Watanabe keiichiw

View GitHub Profile
@keiichiw
keiichiw / split-mbox.py
Created July 1, 2021 15:22
Split an mbox file into multiple .patch files
#!/usr/bin/python3
import mailbox
import sys
import os
def main():
argv = sys.argv
if len(argv) != 2:
print(f'Usage: {argv[0]} <mbx file>')
@keiichiw
keiichiw / template_cpp_lib.hpp
Last active February 25, 2017 10:53
Library for ELVM's C++ Template Metaprogramming backend
// Library for ELVM's C++ Template Metaprogramming backend
// Input Buffer
constexpr static const char* input =
# include "input.txt"
;
// Memory Size
const int MEM_SIZE = 1 << 16;
@keiichiw
keiichiw / 0_regjmp.eir
Created December 3, 2016 09:06
ELVMのCバックエンド・constexprバックエンドの出力例
# 出典: https://github.com/shinh/elvm/blob/master/test/05regjmp.eir
mov A, l
jmp A
putc 78
exit
l:
putc 89
exit
@keiichiw
keiichiw / 0_mem.eir
Last active February 26, 2017 03:12
ELVMの変換例: EIR, C++Template, C, constexprの比較
# 出典: https://github.com/shinh/elvm/blob/master/test/06mem.eir
# "MEM" と出力される
mov B, 77
store B, 300
load A, 300
load A, 300
putc A
mov B, 69
store B, 30
store B, 30
@keiichiw
keiichiw / Bench.java
Last active July 8, 2016 02:45
Cloud 基盤ソフトウェア2016 課題2
import java.math.BigInteger;
public class Bench {
private final static long MOD = 1000000007;
public static long fib(long n) {
if (n <= 1) {
return 1;
} else {
return fib(n - 1) + fib(n - 2);
}
@keiichiw
keiichiw / merge_tex.py
Created June 15, 2016 08:53
main.tex内のinputを展開して、一つのall.texをつくる
#!/usr/bin/python
import shutil
shutil.copyfile("./main.tex", "all.tex")
flg = True
while flg:
flg = False
out = []
with open("all.tex", "r") as f:
@keiichiw
keiichiw / hungry.ml
Created May 26, 2015 20:32
空腹関数(iso-recursive, equi-recursive)
let rec fix f x = f (fix f) x;;
(* hungry function *)
(* iso-recursive *)
type iso_hungry = Hungry of (int -> iso_hungry);;
let iso_hungryfun = Hungry (fix (fun f n-> Hungry f));;
(* equi-recursive *)
#rectypes;;
@keiichiw
keiichiw / ones.ml
Created May 26, 2015 20:30
iso-recursive and equi-recursive
(* ones = (1,(1,(1,...)))*)
(* iso-recursive *)
type 'a infTuple = InfTuple of ('a * 'a infTuple);;
let rec iso_ones = InfTuple(1, iso_ones);;
(* equi-recursive *)
#rectypes;;
let rec equi_ones : (int * 'a) as 'a = (1, equi_ones);;
@keiichiw
keiichiw / Makefile
Last active November 2, 2017 10:13
demonstration of xv6 ported to GAIA processor
# If you execute `make run`, xv6 will be compiled by UCC and boot up in the simulator.
# You need OCaml and clang to compile UCC.
all: ucc xv6
ucc:
git clone git@github.com:kw-udon/ucc.git
make -C ./ucc/
xv6: