Skip to content

Instantly share code, notes, and snippets.

View avsm's full-sized avatar
💭
never gonna git u up, never gona git u down, never gonna turn around and reset u

Anil Madhavapeddy avsm

💭
never gonna git u up, never gona git u down, never gonna turn around and reset u
View GitHub Profile
module type FLOW = sig
(* Type of an individual flow *)
type t
(* Type that manages a collection of flows *)
type mgr
(* Type that identifies a flow source and destination endpoint *)
type src
type dst
(* Read and write to a flow *)
@avsm
avsm / gist:918401
Created April 13, 2011 20:59
Echo server
let echo () =
lwt mgr, mgr_t = Manager.create () in
let src = None, 8081 in
Flow.listen mgr (`TCPv4 (src,
(fun (addr, port) t ->
Console.log "From %s:%d" (ipv4_addr_to_string addr) port);
let rec echo () =
lwt res = Flow.read t in
match res with
|None ->
@avsm
avsm / gist:984125
Created May 21, 2011 01:29
delimcc fragment that seems to fail on ocamlopt but work in ocamlc
open Printf
open Delimcc
let p = new_prompt ()
let main () =
let kr = ref (fun _ -> ()) in
push_prompt p (fun () ->
let foo = 15 in
let bar = foo +
@avsm
avsm / hmod.ml
Created September 1, 2011 22:47
hotplug with objects
module type DEVICE = sig
type t
val create: string -> t
val id: t -> string
val read: t -> string
end
module Dummy : DEVICE = struct
type t = string
let create id = id
@avsm
avsm / gist:1245418
Created September 27, 2011 15:41
devices + first class modules
open Printf
(* Generic device module type *)
module type DEVICE = sig
type t
val make: unit -> t
val read: t -> string
val write: t -> string -> unit
end
@avsm
avsm / myocamlbuild.ml
Created July 3, 2012 14:33
myocamlbuild.ml for compiler-libs tag on ocaml4
open Ocamlbuild_plugin
let _ = dispatch begin function
| Before_rules ->
flag ["ocaml"; "compile"; "compiler-libs"] & S[A"-I"; A"+compiler-libs"];
flag ["ocaml"; "link"; "compiler-libs"] & S[A"-I"; A"+compiler-libs"];
| _ -> ()
end
gdb ocamlbuild
GNU gdb 6.3.50-20050815 (Apple version gdb-1820) (Sat Jun 16 02:40:11 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done
(gdb) run -clean
#internal OPAM solver
preamble:
property: installed-root: bool = [false], reinstall: bool = [false], buildessential: bool = [false], essential: bool = [false], sourceversion: int = [1], sourcenumber: string = [""], source: string = [""], number: string, recommends: vpkgformula = [true!]
package: bitcoin
version: 112
depends: lwt , ocamlnet , yojson
conflicts: bitcoin
number: 1.1
source: bitcoin
@avsm
avsm / ocamlot-deploy.sh
Last active December 22, 2015 00:59
ocamlot worker setup script
#!/bin/sh -ex
OCAML_BRANCH=4.01
MAKE=make
inst=`pwd`/inst
if [ ! -d inst ]; then
rm -rf opam
git clone git://github.com/OCamlPro/opam
cd opam
@avsm
avsm / opam debug.sh
Created September 2, 2013 13:56
debugging with @samoht
clink:packages avsm$ opam update --debug
00:00.000 060536 60536 locking /Users/avsm/.opam/lock
00:00.001 060536 FILENAME cleandir /Users/avsm/.opam/log
00:00.001 060536 SYSTEM rmdir /Users/avsm/.opam/log
00:00.004 060536 SYSTEM mkdir /Users/avsm/.opam/log
00:00.005 060536 FILE(aliases) read /Users/avsm/.opam/aliases
00:00.005 060536 STATE LOAD-STATE(global-lock)
00:00.005 060536 FILE(config) read /Users/avsm/.opam/config
00:00.010 060536 FILE(aliases) read /Users/avsm/.opam/aliases
00:00.013 060536 FILE(repo-config) read /Users/avsm/.opam/repo/opamdoc/config