This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* https://keleshev.com/advanced-error-handling-in-ocaml *) | |
let failwithf f = Printf.ksprintf failwith f | |
(* | |
t -> bool | int | |
e -> true | false | |
| 0 | 1 | 2 | … |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* https://keleshev.com/composable-error-handling-in-ocaml *) | |
open Printf | |
let (>>=) = Result.bind | |
let (let*) = Result.bind | |
module Exceptions_example (X: sig | |
type tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Printf | |
module CLI = struct | |
type t = { | |
verbose: bool; | |
max_files: int; | |
dir_to_list: string; | |
sort_order: [`alpha | `chrono | `owner] option; | |
args: string list; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Make (X: sig | |
val block_size: int | |
val hash: string -> string (* binary, not digest *) | |
end) = struct | |
let o_pad = String.make X.block_size '\x5C' | |
let i_pad = String.make X.block_size '\x36' | |
let block_xor left right = | |
let result = Bytes.create X.block_size in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
from flask import Flask, Response, request | |
app = Flask('hello') | |
@app.route('/') | |
def hello(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (=>) left right = print_char (if left = right then '.' else 'F') | |
open Printf | |
let id x = x | |
let const x = fun _ -> x | |
let sum = List.fold_left (+) 0 | |
let (>>) f g x = g (f x) | |
let () = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ocaml | |
let fprintf = Format.fprintf | |
type t = | |
| Tag of {name: string; attributes: (string * string) list; body: t list} | |
| String of string | |
let format_attribute f (key, value) = fprintf f " %s=\"%s\"" key value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: build install | |
ifeq ($(PREFIX),) | |
INSTALL_FLAGS= | |
else | |
INSTALL_FLAGS=--prefix=$(PREFIX) | |
endif | |
build: | |
dune build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: always_run | |
%.exe: %.s always_run | |
@arm-linux-gnueabihf-gcc -static -o $@ $< | |
@-qemu-arm-static $@; echo $$? | |
@rm -f $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 |