Skip to content

Instantly share code, notes, and snippets.

@amutake
amutake / Main.hs
Created January 17, 2020 01:33
Haskell GC
View Main.hs
module Main where
main :: IO ()
main = do
putStrLn "Hello World"
@amutake
amutake / .gitignore
Last active January 10, 2020 13:03
resource-pool with HDBC-postgresql
View .gitignore
dist
dist-newstyle
.ghc.environment.*
@amutake
amutake / match.ml
Created January 11, 2019 01:43
extract nested match expressions
View match.ml
(* types *)
type erl_expr =
| ErlInt of int
| ErlVar of string
| ErlApp of erl_expr * erl_expr (* F(A) *)
| ErlMatch of erl_pat * erl_expr (* P = E *)
and erl_pat =
| ErlPatVar of string
@amutake
amutake / parsed.txt
Last active October 2, 2018 00:51
quic-14 ngtcp2 vector
View parsed.txt
クライアント -> サーバ (UDPパケット1つにQUICパケット1つ)
Header: Long Header (0b1000_0000)
Type: Initial (0x7f)
Version: IETF QUIC draft-14 (0xff00000e)
DCIL: 18 (0xf + 3)
SCIL: 17 (0xe + 3)
Dst Connection ID: 0xf2aca972962edd0f195aa1bb9a16734be91b
Src Connection ID: 0xd545b3713ec650dc4844f59652f737fa3a
Token Length: 0 (0x00, variable-length integer)
@amutake
amutake / fun_call_vs_msg_passing_heavy.erl
Created June 15, 2018 12:56
Erlang のメッセージパッシングのコストに関する雑なベンチマーク
View fun_call_vs_msg_passing_heavy.erl
-module(fun_call_vs_msg_passing_heavy).
-export([fun_call/1, msg_passing/1]).
fib(0) -> 0;
fib(1) -> 1;
fib(N) -> fib(N - 1) + fib(N - 2).
%% fib(20) (そこそこ重い処理のつもり) を N 回呼び出す
fun_call(N) ->
View coin.hs
module Main where
import Control.Monad
import Data.List (nub)
data Coin = Black | White | Blank deriving (Eq, Ord)
instance Show Coin where
show Black = "●"
show White = "○"
@amutake
amutake / 2005-pattern-binding-modes-ja.md
Last active November 20, 2017 07:01
2005-pattern-binding-modes-ja
View 2005-pattern-binding-modes-ja.md

概要

参照に関するパターンマッチをよりわかりやすくします。

現在、参照に関するパターンマッチは ref& を使いわけなければいけません。

@amutake
amutake / 1522-conservative-impl-trait.md
Last active November 6, 2017 07:00
1522-conservative-impl-trait-ja
@amutake
amutake / titles.js
Created July 7, 2017 07:11
https://satsukita-andon.com/artisan/classdata から、投票用のを取ってくるスクリプト
View titles.js
Array.prototype.map.call(document.querySelectorAll("table tbody tr"), function (tr) { var c = tr.children; return c[2].textContent + "年" + c[3].textContent + "組" + "『" + c[4].textContent + "』"; }).join("\n");
@amutake
amutake / focal_length.sh
Last active December 4, 2016 10:36
A script for making 'focal length - number' graph
View focal_length.sh
#!/usr/bin/env bash
FOCAL=focal.dat
WC=~/tmp/wc.rb
if [[ "$1" == "-t" && ! -z "$2" ]]; then
exiftool -T -focallengthin35mmformat *.JPG | grep -v '-' | awk '{print NR, $0}' > $FOCAL
gnuplot -p -e "set terminal png; set term png size 2000,500; set term png font 'ヒラギノ丸ゴ ProN W4, 16'; set output '$2'; set xlabel 'n枚目'; set ylabel '焦点距離'; plot '$FOCAL' using 1:2:(1) with boxes"
rm $FOCAL
open $2