Skip to content

Instantly share code, notes, and snippets.

@talex5
talex5 / runenv.rs
Last active July 12, 2016 01:45
My attempt at a Rust replacement for 0install's _runenv.py
/* Rust version of this Python code:
import os, sys, json
envname = os.path.basename(sys.argv[0])
args = json.loads(os.environ["0install-runenv-" + envname])
os.execv(args[0], args + sys.argv[1:])
*/
extern mod std;
@talex5
talex5 / test.xml
Last active December 17, 2015 19:39
Testing XML parsing in OCaml
<foo:one xmlns:foo='http://example.com/'><foo:two xmlns:foo='http://foo/'><foo:three/></foo:two></foo:one>
@talex5
talex5 / json.sats
Created May 31, 2013 15:40
My attampt at implementing runenv.py in ATS. This works, but some of the external declarations aren't quite right (e.g. returning strings rather than strptrs). Looks like proper versions of the support code (null_array, json) will be in ATS 2. The main function at the end of runenv.dats is where the real code is.
%{#
#include "json/json.h"
%}
absviewtype json_object_vtype (l:addr) = ptr
viewtypedef json_object (l:addr) = json_object_vtype l
viewtypedef json_object0 = [l:addr] json_object_vtype l
viewtypedef json_object1 = [l:addr;l>null] json_object_vtype l
@talex5
talex5 / bench.ml
Created June 1, 2013 09:29
Test driver for benchmarks
(* ocamlfind ocamlc -o quick -package unix -linkpkg quick.ml *)
(* a tiny C binary that prints argv[0], argv[1] and argv[2] *)
let test_binary = "/home/tal/tmp/run-bench/fast";;
let expected_output = test_binary ^ "\none\ntwo\n";;
let subjects = [
("ATS", "/home/tal/Projects/ats/runenv");
("OCaml (native)", "/home/tal/Projects/ocaml/runenv-opt");
("Haskell", "/home/tal/Projects/Haskell/runenv/Runenv");
### Keybase proof
I hereby claim:
* I am talex5 on github.
* I am talex (https://keybase.io/talex) on keybase.
* I have a public key whose fingerprint is DA98 25AE CAD0 8975 7CDA BD8E 0713 3F96 CA74 D8BA
To claim this, I am signing this object:
@talex5
talex5 / config.ml
Created June 25, 2015 09:31
Mirage test that sends one byte to TCP endpoint (10.0.0.1/7001), with tracing on
open Mirage
let main = foreign "Unikernel.Main" (stackv4 @-> job)
let stack console =
match get_mode () with
| `Xen -> direct_stackv4_with_default_ipv4 console tap0
| `Unix -> assert false
let tracing = mprof_trace ~size:1000000 ()

Keybase proof

I hereby claim:

  • I am talex5 on github.
  • I am talex (https://keybase.io/talex) on keybase.
  • I have a public key whose fingerprint is 5DD5 8D70 899C 454A 966D 6A51 7513 3C8F 94F6 E0CC

To claim this, I am signing this object:

0000000000004470 <camlMain__entry>:
4470: 48 83 ec 18 sub $0x18,%rsp
4474: 48 c7 c0 48 c2 12 00 mov $0x12c248,%rax
447b: 48 c7 c3 e8 be 12 00 mov $0x12bee8,%rbx
4482: 48 89 03 mov %rax,(%rbx)
4485: 48 c7 c0 30 c2 12 00 mov $0x12c230,%rax
448c: 48 89 43 08 mov %rax,0x8(%rbx)
4490: 48 c7 c0 01 00 00 00 mov $0x1,%rax
4497: e8 c4 ff ff ff callq 4460 <camlMain__make_float_82>
449c: 48 89 44 24 08 mov %rax,0x8(%rsp)