Skip to content

Instantly share code, notes, and snippets.

@dbuenzli
dbuenzli / ocamlib.md
Last active August 22, 2022 07:38
OCaml compiler support for library linking
@dbuenzli
dbuenzli / ocaml-emacs.md
Last active August 11, 2022 00:39
Emacs setup for ocaml

Install the following opam packages:

opam install caml-mode merlin ocp-indent

Tweak your .emacs file with some or all of the following:

; shift tab to complete
(global-set-key (kbd "S-<tab>") 'company-complete)
@dbuenzli
dbuenzli / ioserial.ml
Last active April 12, 2019 12:39
Serial connection
(*----------------------------------------------------------------------------
Copyright (c) 2009, Daniel C. Bünzli. All rights reserved.
Distributed under a BSD license, see license at the end of the file.
----------------------------------------------------------------------------*)
let str = Printf.sprintf
let exec = Filename.basename Sys.executable_name
let pr = Format.printf
let pr_err s = Printf.eprintf "%s:%s\n" exec s

Adding UTF-X decoding support to the stdlib

Since 4.06 we have UTF-X encoding support via the Buffer module. The following is a proposal to add UTF-X decoding (and bytes encoding) support with the following goals:

  1. Provide a low-level, allocation-free codec API in bytes. This API provides all the information needed to implement loops for making   higher-level UTF-X codec APIs (e.g. Uutf's folding functions) operating on bytes and string values. It's not geared towards the end-user
@dbuenzli
dbuenzli / opam
Last active January 17, 2018 18:04
opam-set-env
opam-version: "2.0"
synopsis: "Build setenv"
maintainer: "Daniel Bünzli <daniel.buenzl i@erratique.ch>"
setenv: [[BLA += "BLA"]]
authors:[]
build:[[ "env" ]]
@dbuenzli
dbuenzli / opam
Created January 12, 2018 22:25
opam-build-env
opam-version: "2.0"
synopsis: "Build environment"
maintainer: "Daniel Bünzli <daniel.buenzl i@erratique.ch>"
authors:[]
build:[[ "env" ]]
@dbuenzli
dbuenzli / Vagrantfile
Created December 21, 2017 23:48
Install OCaml 4.06 in a Win10 VM with vagrant
# Download vagrant box for Windows 10 from:
#
# https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
#
# Unzip and add with:
#
# vagrant box add --name win10 MSEdge\ -\ Win10.box
#
# During the first `vagrant up` need to connect to vm UI to do this:
#
@dbuenzli
dbuenzli / opam-v2-switch-init.md
Created July 16, 2017 23:06
opam v2 switch init

Switch creation and initialization in opam v2.

The first point for me is that we should as much as possible get to a system where the following basic sequences of steps are possible.

opam switch create bla               # Create switch
opam install non-ocaml-pkg           # Doesn't depend on ocaml
opam install ocaml.V.VV.V+variant

or

@dbuenzli
dbuenzli / utf_8.mli
Last active July 9, 2017 22:59
UTF_8 module
(* See http://erratique.ch/software/uutf/doc/Uutf.String.UTF_8.html
If you want to test the API use:
opam pin add uutf https://github.com/dbuenzli/uutf.git#string-utf-8 *)
(** UTF-8 encoded strings.
The [UTF_8] module provides a {{!t}datatype} that asserts
that a string value is valid UTF-8 and a few functions
@dbuenzli
dbuenzli / sys-pkg-list.md
Last active July 20, 2017 11:48
Package lists for system package managers depexts