Skip to content

Instantly share code, notes, and snippets.

View rizo's full-sized avatar

Rizo I rizo

  • London, UK
View GitHub Profile
type ('a,'r) iter =
| Done of 'r
| Cont of ('a option -> ('a,'r) iter)
let head = let k x = Done x in Cont k
let len () =
let rec k acc x =
@rizo
rizo / README.md
Created March 30, 2020 12:32 — forked from hofmannsven/README.md
Increase key repeat rate on macOS

Increase key repeat rate on macOS

Settings: System Preferences » Keyboard » Key Repeat/Delay Until Repeat

Use the commands below to increase the key repeat rate on macOS beyond the possible settings via the user interface. The changes aren't applied until you restart your computer.

Source: https://apple.stackexchange.com/a/83923

type 'a printer = Format.formatter -> 'a -> unit
let inspect (pp : 'a printer) =
Format.(kfprintf (fun f -> pp_print_newline f ()) std_formatter "%a" pp)
let print ?(channel=stdout) fmt =
let f = Format.formatter_of_out_channel channel in
Format.(kfprintf (fun f -> pp_print_newline f ()) f fmt)
let int_to_bin_byte d =
if d < 0 then invalid_arg "bin_of_int" else
if d = 0 then "0" else
let rec aux acc d =
if d = 0 then acc else
aux (string_of_int (d land 1) :: acc) (d lsr 1)
in
let res = String.concat "" (aux [] d) in
if String.length res mod 8 <> 0 then
String.make (8 - String.length res mod 8) '0' ^ res
type property = string
(** Logic subsumption type: p |= q *)
type t = (property → property → bool)
(** Converts a property to a string representation. *)
let string_of_property p = p
module Continuation : sig
type ('a, 'r) t = ('a -> 'r) -> 'r
val return : 'a -> ('a, 'r) t
val (>>=) : ('a, 'r) t -> ('a -> ('b, 'r) t) -> ('b, 'r) t
end = struct
type ('a, 'r) t = ('a -> 'r) -> 'r
let return x = fun k -> k x
@rizo
rizo / Dockerfile
Last active January 30, 2020 10:22
Dockerfile for esy projects.
# Build image
FROM node:10.13-alpine as build
# Prepare the environment to install esy.
RUN apk add --no-cache \
ca-certificates wget \
bash curl perl-utils \
git patch gcc g++ musl-dev make m4

Query commands are:

case-analysis -start <position> -end <position>

   -start <position>  Where analysis starts
     -end <position>  Where analysis ends

When the range determined by (-start, -end) positions is an expression, this command replaces it with [match expr with _] expression where a branch is introduced for each immediate value constructor of the type that was determined for expr. When it is a variable pattern, it is further expanded and new branches are introduced for each possible immediate constructor of this variable.

(* Helper definitions *)
let pass = fun () -> ()
let output_line str chan =
Pervasives.output_string chan (str ^ "\n")
let open_in path =
print (format "> open_in %s" path);
FROM ocaml/opam2:alpine-3.7-ocaml-4.06
RUN sudo apk --no-cache add ca-certificates
RUN sudo apk add --update m4 openssh-client
# Setup SSH.
RUN mkdir -p ~/.ssh
ARG SSH_PRIVATE_KEY
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN printf "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config