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
@avsm
avsm / install-mirage.sh
Last active August 29, 2015 14:07
Install Mirage using opam-installext
#!/bin/sh -ex
opam remote add mirage git://github.com/mirage/mirage-dev
opam installext -j 3 mirage-www
eval `opam config env`
git clone git://github.com/mirage/mirage-skeleton
cd mirage-skeleton
make configure && make build
@avsm
avsm / opam install
Last active August 29, 2015 14:11 — forked from anonymous/foo
Reproduced failure with debugging for https://github.com/mirage/mirage-skeleton/issues/59
00:00.000 046309 46309 locking /home/avsm/.opam/lock
00:00.000 046309 FILE(config) Read ~/.opam/config in 0.000s
00:00.000 046309 SYSTEM unlocking /home/avsm/.opam/lock (46309)
00:00.000 046309 SYSTEM rm /home/avsm/.opam/lock
00:00.000 046309 STATE LOAD-STATE(switch-lock)
00:00.000 046309 FILE(config) Read ~/.opam/config in 0.000s
00:00.013 046309 STATE Loaded /home/avsm/.opam/state.cache in 0.011s
00:00.013 046309 FILE(aliases) Read ~/.opam/aliases in 0.000s
00:00.018 046309 FILE(repo-config) Read ~/.opam/repo/default/config in 0.000s
00:00.058 046309 FILE(repo-index) Read ~/.opam/repo/package-index in 0.021s
@avsm
avsm / gist:bd4511551c2cbda713c9
Created February 10, 2015 20:53
testing some unix stuff
open Unix
let () =
let server_sock = socket PF_INET SOCK_STREAM 0 in
(* so we can restart our server quickly *)
setsockopt server_sock SO_REUSEADDR true ;
if not (getsockopt server_sock SO_REUSEADDR) then prerr_endline "fail1";
(* build up my socket address *)
@avsm
avsm / usr_local_bin_opam
Created February 24, 2015 16:03
systrace policy for opam
# Policy for opam.
#
Policy: /usr/local/bin/opam, Emulation: native
native-rename: filename match "/tmp/*" and filename[1] match "/tmp/*" then permit
native-rename: filename match "/tmp/*" and filename[1] match "$HOME/.opam/*" then permit
native-rename: filename match "$HOME/.opam/*" and filename[1] match "$HOME/.opam/*" then permit
native-rename: filename match "$HOME/.opam/*" and filename[1] match "/tmp/*" then permit
native-chown: filename match "$HOME/.opam/*" then permit
native-chown: filename match "/tmp/*" then permit
native-fswrite: filename match "/tmp/*" then permit
module Int = struct
type t = int
let compare : int -> int -> int = compare
end
module M = Map.Make(Int)
type +'a elt
type 'a map = 'a elt M.t
let addA (x : 'a) (m : [> `A of 'a] map) =
(* defines the Ast.binding for a function of form:
let fun_name ?(opt_arg1) ?(opt_arg2) final_ident = function_body ...
XXX: figure out the quotation magic for this, if such exists
*)
let function_with_label_args _loc ~fun_name ~final_ident ~function_body ~return_type opt_args =
let opt_args = opt_args @ [ <:patt< $lid:final_ident$ >> ] in
let rec fn _loc = function
|hd::tl ->
Ast.ExFun(_loc,
Ast.McArr(_loc,
@avsm
avsm / gist:166645
Created August 12, 2009 18:03 — forked from jaked/gist:166609
(* defines the Ast.binding for a function of form:
let fun_name ?(opt_arg1) ?(opt_arg2) final_ident = function_body ...
*)
let function_with_label_args _loc ~fun_name ~final_ident ~function_body ~return_type opt_args =
let opt_args = opt_args @ [ <:patt< $lid:final_ident$ >> ] in
<:binding< $lid:fun_name$ =
$List.fold_right (fun b a ->
<:expr<fun $b$ -> $a$ >>
) opt_args <:expr< ( $function_body$ : $return_type$ ) >>
$ >>
#!/usr/bin/env ruby
require 'rubygems'
require 'findmyiphone'
username = ENV.fetch("MOBILEME_USERNAME")
password = ENV.fetch("MOBILEME_PASSWORD")
puts "logging in as: #{username}@me.com"
i = FindMyIphone.new(username, password)
Ast.ExApp (_loc,
Ast.ExApp (_loc,
Ast.ExApp (_loc, Ast.ExId (_loc, Ast.IdLid (_loc, "fn")),
Ast.ExId (_loc, Ast.IdLid (_loc, "arg1"))),
Ast.ExId (_loc, Ast.IdLid (_loc, "arg2"))),
Ast.ExId (_loc, Ast.IdLid (_loc, "arg3")))
#!/usr/bin/env python
import sys, os, subprocess
import XenAPI, inventory, xmlrpclib
xenconsole = "/usr/lib/xen/bin/xenconsole"
def attach_console(session, uuid):
vmref = session.xenapi.VM.get_by_uuid(uuid)
try: