Skip to content

Instantly share code, notes, and snippets.

let read_lines p =
let rec loop () = match input_line p with
| exception End_of_file -> close_in p ; []
| line -> line :: loop ()
in loop ()
let process cmd =
let (stdout, _, stderr) as p =
Unix.open_process_full cmd (Unix.environment ())
in
@sagotch
sagotch / makorel.sh
Created April 28, 2014 07:47
makorel - Release new OPAM package version easily - shell script version
#!/usr/bin/env bash
USAGE="usage: makorel version [package]"
# with:
# - version: new version to release
# - package: /path/to/package/root/directory (optionnal)
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "${USAGE}. Exiting with 1.";
@sagotch
sagotch / uXXXX.ml
Created April 18, 2014 09:25
Convert Unicode escaped \uXXXX sequence to utf-8 encoded string
(*
* Imported from https://gist.github.com/sagotch/
*
* For more informations about unicode to utf-8 converting method used see:
* http://www.ietf.org/rfc/rfc3629.txt (Page3, section "3. UTF-8 definition")
*
* decimal conversions of binary used:
* 10000000 -> 128; 11000000 -> 192; 11100000 -> 224
*)