Skip to content

Instantly share code, notes, and snippets.

@pqwy
pqwy / lambda.ml
Created June 30, 2014 02:41
P-HOAS + typed object language = higher-kinded parameter -- finally!
open Higher
module F = struct
module Id : Newtype1 with type 'a s = 'a =
Newtype1 ( struct type 'a t = 'a end )
module Const (T : sig type t end) : Newtype1 with type 'a s = T.t =
Newtype1 ( struct type 'a t = T.t end )
@pqwy
pqwy / format_sexp.ml
Created June 20, 2014 14:11
sexp formatter
(*
* ocamlfind ocamlopt -linkpkg -syntax camlp4o
* -package lwt,lwt.syntax,lwt.unix,sexplib
* format_sexp.ml -o format_sexp
*)
open Lwt
open Sexplib
@pqwy
pqwy / reformatted
Created June 20, 2014 13:56
Safari traces v.2
((state-in
((handshake
((version TLS_1_2) (machina (Server ServerInitial))
(config
((ciphers
(TLS_RSA_WITH_AES_256_CBC_SHA TLS_DHE_RSA_WITH_AES_256_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA TLS_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_MD5))
(version (TLS_1_2 TLS_1_0)) (hashes (SHA512 SHA384 SHA256 SHA MD5))
(use_rekeying true) (requre_sec_rek true) (validator ()) (peer_name ())
(certificate (<CERTIFICATE>))))
| (server, server_raw) :: certs_and_raw ->
let now = Sys.time () in
let trusted = find_trusted_certs now in
let rec climb pathlen cert cert_raw = function
| (super, super_raw) :: certs ->
( match validate_relation pathlen super cert cert_raw with
| `Ok -> climb (succ pathlen) super super_raw certs
| err -> err )
@pqwy
pqwy / GenS.hs
Created November 27, 2013 19:29
autopeek / autopoke
{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-}
module GenS (AutoStorable) where
import Control.Applicative
import GHC.Generics
import Data.Word
import Foreign
@pqwy
pqwy / Peek.hs
Created November 27, 2013 02:29
peek / poke
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE OverlappingInstances, UndecidableInstances #-}
module Peek (
module Data.Monoid
, Store, runStore, store, stores
, Restorable, restore
, AutoSize, autoSizeOf
) where
@pqwy
pqwy / meta.rkt
Last active December 7, 2024 06:31
dat metacircular evaluation
#lang racket
;;
;; Run-of-the mill metacircular evaluator for (a small subset of) scheme.
;; Includes delimited continuations, and the tower of (positive) meta-levels.
;;
(struct closure [vars body environment])
(struct primitive [procedure])
@pqwy
pqwy / app.ls
Created November 12, 2012 16:27
basic livescript/express scaffold
express = require \express
app = express!
..set \views, "#__dirname/../views"
..use express.static "#__dirname/../pub"
app.get '/', (req, res) ->
res.render 'index.jade'
app.listen 3001
@pqwy
pqwy / inversions.cpp
Created November 7, 2012 05:09
Inverzije...
#include <iostream>
#include <fstream>
#include <vector>
#include <sys/time.h>
using namespace std;
typedef vector<int> vec;
typedef vector<int>::iterator ix;
@pqwy
pqwy / gist:3988500
Created October 31, 2012 17:29
index occurrence ids
// nb. we have a typo with occurrences -- sometimes they are called "occurences".
var filter = {};
var projection = {
_id : true,
facebook_occurence_ids : true
};
db.movies.find(filter, projection)