Skip to content

Instantly share code, notes, and snippets.

View doublec's full-sized avatar

Chris doublec

  • Perth, Australia
View GitHub Profile
@doublec
doublec / config.nix
Created June 5, 2015 14:53
Building B2G with Nix package manager
{
allowUnfree = true;
packageOverrides = pkgs : with pkgs; rec {
# Tested with:
# $ nix-env -i b2g-env
# $ b2g-env
# $ git clone https://github.com/mozilla-b2g/B2G b2g
# $ cd b2g
# $ REPO_INIT_FLAGS="--depth=1" ./config.sh nexus-5
# $ ./build.sh
@doublec
doublec / keybase.md
Created May 10, 2015 02:12
keybase.md

Keybase proof

I hereby claim:

  • I am doublec on github.
  • I am doublec (https://keybase.io/doublec) on keybase.
  • I have a public key whose fingerprint is AA10 A0B5 334F A2E9 B21D 5131 736D 9F34 9753 DFAB

To claim this, I am signing this object:

(* Comparing to http://www.reddit.com/r/rust/comments/34rszb/pony_type_and_memory_safe_language/cqy2wo7 *)
#include "share/atspre_staload.hats"
extern castfn u64(n: uint): uint64
fun fib(n: uint64): uint64 =
if n < u64(2u) then n else fib(n - u64(1u)) + fib(n - u64(2u))
implement main0(argc, argv) = let
val () = assertloc(argc = 2)
@doublec
doublec / gist:e49bb07b5a3f63a8746e
Created May 28, 2014 10:24
Building AliceML on NixOS

Add the following to your ~/.nixpkgs/config.nix:

alicemlEnv = pkgs.myEnvFun {
  name = "alicemlEnv";
  buildInputs = [ stdenv gcc smlnj libtool gnumake381 autoconf automake111x
                  zlib file which zsh vimWrapper gmp m4 gnome.gtk
                  gnome.libgnomecanvas pango sqlite libxml2 pkgconfig ];
  extraCmds = ''
   LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:${gcc.gcc}/lib64

for i in $nativeBuildInputs; do

@doublec
doublec / keybase.md
Created May 9, 2014 02:01
keybase.md

Keybase proof

I hereby claim:

  • I am doublec on github.
  • I am doublec (https://keybase.io/doublec) on keybase.
  • I have a public key whose fingerprint is AA10 A0B5 334F A2E9 B21D 5131 736D 9F34 9753 DFAB

To claim this, I am signing this object:

@doublec
doublec / gist:10395713
Created April 10, 2014 15:45
ATS version of dtls1_process_heartbeat
(* A view for an array that contains:
byte = hbtype
ushort = payload length
byte[n] = bytes of length 'payload length'
byte[16]= padding
*)
dataview record_data_v (addr, int) =
| {l:addr} {n:nat | n > 16 + 2 + 1} make_record_data_v (l, n) of (ptr l, size_t n)
extern prfun free_record_data_v {l:addr} {n:nat} (pf: record_data_v (l, n)): void
@doublec
doublec / json.behavior.self
Created October 24, 2013 06:10
JSON parser in Self using the mango parser library
( |
"_" parent* = traits oddball.
object = (| eval = ( |dict = dictionary copy|
members elements do: [|:v. :k|
dict at: v string eval Put: v value eval
].
dict
)
|).
@doublec
doublec / list.rs
Created August 15, 2013 12:08
An attempt at a List that has the length encoded as a type parameter in Rust using phantom types. I wasn't able to get list_zip to compile unfortunately.
use std::cast::transmute;
struct Zero;
struct Succ<T>;
struct Prev<T>;
enum List<T,N> {
Nil,
Cons (T, ~List<T,N>)
}
@doublec
doublec / gist:6171436
Created August 7, 2013 05:24
ATS factorial with proof
/* From an example in the ATS distribution */
dataprop FACT (int, int) =
| FACTzero (0, 1)
| {n,r,r1:int | n > 0} FACTsucc (n, r) of (FACT (n-1, r1), MUL (n, r1, r))
fun fact {n:nat} .<n>. (n: int n): [r:int] (FACT (n, r) | int r) =
if n > 0 then let
val (pf1 | r1) = fact (n - 1)
val (pf_mul | r) = n imul2 r1
in
@doublec
doublec / Makefile
Created October 3, 2012 11:26
ATS stack example
all: stack1 stack2 stack3 stack4 stack5
stack1: stack1.dats
atscc -o stack1 stack1.dats
stack2: stack2.dats
atscc -o stack2 stack2.dats
stack3: stack3.dats
atscc -tc stack3.dats