Skip to content

Instantly share code, notes, and snippets.

View doublec's full-sized avatar

Chris doublec

  • Perth, Australia
View GitHub Profile
@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 / 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 / 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 / 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: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

(* 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 / 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:

@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 / ...
Created October 2, 2015 09:59
Building Self on Ubuntu 15.04
$ sudo apt-get install gcc-multilib g++-multilib libx11-dev:i386 libXext-dev:i386 libncurses5-dev:i386
$ git clone https://github.com/doublec/self
$ cd self
$ make -f Makefile.linux
$ cd objects
$ ../vm/Self
Self Virtual Machine Version 4.1.13, Fri 02 Oct 15 09:48:48 Linux i3864.4.alpha2-437-g43ebab6
Copyright 1989-2003: The Self Group (type _Credits for credits)
for I386: LogVMMessages = true
@doublec
doublec / lambda_fac.pony
Created May 5, 2016 23:57
Calling a lambda functoin recursively in Pony
actor Main
new create(env:Env) =>
let fac = lambda (n:U32): U32 => if n == 0 then 1 else n * this(n - 1) end end
env.out.print("fac 5 = " + fac(5).string())