Skip to content

Instantly share code, notes, and snippets.

@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 から、投票用のを取ってくるスクリプト
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
#!/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
@amutake
amutake / syuukei.rb
Last active July 16, 2016 01:22
行灯人気投票集計スクリプト
require 'csv'
classes = {}
file = ARGV[1]
GENEKI = '現役生'
OBOG = 'OBOG'
OTHER = 'その他'
CSV.foreach(file) do |row|
@amutake
amutake / ContT.v
Last active May 29, 2016 17:31
ContT and ContsT instances (for scalaz)
Set Implicit Arguments.
Unset Strict Implicit.
(** Type Definitions *)
Inductive IndexedContsT (W M : Type -> Type) (R O A : Type) : Type :=
| mkIndexedContsT : (W (A -> M O) -> M R) -> IndexedContsT W M R O A.
Definition runIndexedContsT W M R O A (c : IndexedContsT W M R O A) : W (A -> M O) -> M R :=
match c with
{-# LANGUAGE FlexibleContexts
, TypeOperators
, DeriveDataTypeable
, ConstraintKinds
, FlexibleInstances
, MultiParamTypeClasses
, UndecidableInstances #-}
import Control.Eff
import Control.Eff.Exception
@amutake
amutake / gist:7910653
Last active December 31, 2015 00:59
Anomaly: Not enough components to build the dependent tuple. Please report.
Inductive A : Set := a : A.
Definition fantom (n : nat) := A.
Definition fantom_succ {n : nat} : fantom n -> fantom (S n) :=
fun _ => a.
Inductive ty : forall n : nat, fantom n -> Prop :=
| zero : ty O a
| succ : forall (x : nat) (f : fantom x), ty x f -> ty (S x) (fantom_succ f).
@amutake
amutake / gist:6929670
Created October 11, 2013 04:38
FizzBuzz in Erlang
-module(fizzbuzz).
-export([start/1]).
start(End) ->
Pid = self(),
FizzBuzz = spawn(fun() -> fizzbuzz(Pid, End) end),
Fizz = spawn(fun() -> fizz(3) end),
Buzz = spawn(fun() -> buzz(5) end),
FizzBuzz ! {Fizz, Buzz},
receive
@amutake
amutake / Main.scala
Created December 19, 2015 22:14
bug of finch-0.9.2 (this is fixed by #485)
package finch.bug
import io.finch._
import com.twitter.io.Buf
import com.twitter.finagle.http._
import com.twitter.util.{ Await, Duration }
object Main extends App {
val string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
@amutake
amutake / DeBruijn.hs
Last active December 18, 2015 22:59
An evaluator for De Bruijn Index
module DeBruijn where
import Data.List
data Expr = Var Int | App Expr Expr | Abs Expr deriving (Eq, Show)
subst :: Expr -> Int -> Expr -> Expr
subst (Var n) m e
| n == m = e
| otherwise = Var n