Skip to content

Instantly share code, notes, and snippets.

@dbuenzli
dbuenzli / init.el
Last active April 7, 2026 12:55
neocaml alternative font-lock-mode
;; OCaml stuff
; locate opam's site-lisp
(setq opam-share
(replace-regexp-in-string "\n$" ""
(shell-command-to-string "opam var share 2> /dev/null")))
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
; merlin
(require 'merlin)
@dbuenzli
dbuenzli / opam2json.ml
Last active July 15, 2025 07:19
Encode the opam file format to JSON
(*---------------------------------------------------------------------------
Copyright (c) 2025 The opam programmers. All rights reserved.
SPDX-License-Identifier: LGPL-2.1-only WITH OCaml-LGPL-linking-exception
---------------------------------------------------------------------------*)
(* Usage: opam2json < opam
opam switch export - | opam2json
Compile with:
ocamlfind ocamlopt -linkpkg -package opam-core,opam-format \
opam2json.ml -o opam2json *)
@dbuenzli
dbuenzli / open_issue.ml
Created June 21, 2025 00:17
open gh issue
#!/usr/bin/env ocaml
(*---------------------------------------------------------------------------
Copyright (c) 2025 Daniel C. Bünzli. All rights reserved.
SPDX-License-Identifier: ISC
---------------------------------------------------------------------------*)
#use "topfind"
#require "b0.std"
#require "b0.kit"
@dbuenzli
dbuenzli / .gitignore
Last active June 20, 2025 00:45
Two way string search
_b0
_build
@dbuenzli
dbuenzli / bigbytes_sig.mli
Created June 4, 2025 09:45
Bigbytes signature
(*---------------------------------------------------------------------------
Copyright (c) 2025 The bigbytes programmers. All rights reserved.
SPDX-License-Identifier: ISC
---------------------------------------------------------------------------*)
(** Bigarrays of bytes.
{b Note.} Getter and setters raise [Invalid_argument] on out of
bounds errors. Functions that encode 8-bit or 16-bit integers
represented by [int] values truncate their input their least
@dbuenzli
dbuenzli / ints.mli
Created March 31, 2025 08:47
OCaml integers
(*---------------------------------------------------------------------------
Copyright (c) 2018 Daniel C. Bünzli. All rights reserved.
SPDX-License-Identifier: ISC
---------------------------------------------------------------------------*)
(** Integer types.
[Ints] provides types for specifying sized integer types not
supported by the {!Stdlib}. It also provides bitwise conversion
functions and safe, magnitude preserving, conversions.
@dbuenzli
dbuenzli / .gitignore
Last active February 15, 2025 09:12
Edit distance toy benchmark
_b0
@dbuenzli
dbuenzli / .gitignore
Last active May 11, 2024 14:47
Priority queue docs without dupes
_b0
@dbuenzli
dbuenzli / bigbytes.ml
Last active October 21, 2023 01:24
Bigarray mmap RW
(* SPDX-License-Identifier: CC0-1.0 *)
let bigbytes_of_file ?(trunc = false) ?length access file =
let module Bigarray = Stdlib.Bigarray (* OCaml < 5 install woes *) in
let flags, shared = match access with
| `R -> Unix.[O_RDONLY], false
| `RW -> Unix.(O_CREAT :: O_RDWR :: if trunc then [O_TRUNC] else []), true
in
let fd = Unix.openfile file flags 0o644 in
let finally () = try Unix.close fd with Unix.Unix_error _ -> () in
@dbuenzli
dbuenzli / work_queue.ml
Created October 30, 2022 13:08
Webworker work queue
(*---------------------------------------------------------------------------
Copyright (c) 2022 The brr programmers. All rights reserved.
Distributed under the ISC license, see terms at the end of the file.
---------------------------------------------------------------------------*)
open Brr
open Brr_webworkers
open Brr_io
module type WORK = sig