Skip to content

Instantly share code, notes, and snippets.

View j0sh's full-sized avatar
🐠

Josh Allmann j0sh

🐠
View GitHub Profile
@j0sh
j0sh / pusub.ml
Last active March 11, 2016 19:11
(*
pubsub semantics:
previous message is stored and sent to newly subscribing clients if present.
unpublishes will clear any previously stored messages
unsubscribes will push None to wake up any read loops
*)
type ('a, 'b) t = {
msg_tbl : ('a, 'b) Hashtbl.t;
sub_tbl : ('a, ('b option -> unit)) Hashtbl.t;
module Sqlexpr = Sqlexpr_sqlite.Make(Sqlexpr_concurrency.Lwt)
module S = Sqlexpr
open Lwt.Infix
let test_retry_begin =
let __ppx_sqlexpr_shared_1 =
{
Sqlexpr.statement =
{
Sqlexpr.sql_statement = "SELECT COUNT(*) FROM foo";
stmt_id = (Some "9e11a7554f37de62d53f51cdd7f94b6b");
diff --git a/_oasis b/_oasis
index 5dcf0cc..bd22d8f 100644
--- a/_oasis
+++ b/_oasis
@@ -1,6 +1,7 @@
OASISFormat: 0.3
Name: ocaml-sqlexpr
Version: 0.7.0
+OcamlVersion: >= 4.02
Synopsis: Type-safe, convenient SQLite database access.
@j0sh
j0sh / mapper.ml
Last active February 29, 2016 23:11
let call fn loc = function
| PStr [ {pstr_desc = Pstr_eval (
{ pexp_desc = Pexp_constant(Const_string(sym, _))}, _)} ] ->
with_default_loc loc (fun () -> fn sym)
| _ -> raise (Location.Error(Location.error ~loc (
"sqlexpr extension accepts a string")))
let call_sqlcheck loc = function
| PStr [ {pstr_desc = Pstr_eval ({ pexp_desc =
Pexp_constant(Const_string("sqlite", None))}, _)}] ->
@j0sh
j0sh / gist:6c7d21ae90e1c8a7bd4d
Last active January 28, 2016 22:18
fix typo in FSRTC javascript
From 4bc402f7fc7362b1ccbb41e26a99a6234d35733c Mon Sep 17 00:00:00 2001
From: Josh Allmann <joshua.allmann@gmail.com>
Date: Thu, 28 Jan 2016 22:15:59 +0000
Subject: [PATCH] Fix a typo causing an exception in fsrtc.
---
html5/verto/js/src/jquery.FSRTC.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html5/verto/js/src/jquery.FSRTC.js b/html5/verto/js/src/jquery.FSRTC.js
diff --git a/src/ppx/ppx_sqlexpr.ml b/src/ppx/ppx_sqlexpr.ml
index 8fd5763..b13ebbd 100644
--- a/src/ppx/ppx_sqlexpr.ml
+++ b/src/ppx/ppx_sqlexpr.ml
@@ -13,11 +13,11 @@ let new_id =
sprintf "__ppx_sql_%d" !n
let gen_stmt loc ~cacheable sql inp =
- let mkstr s = Exp.constant (Const_string (s, None)) in
+ let mkstr s = Exp.constant ~loc (Const_string (s, None)) in
@j0sh
j0sh / output
Last active November 3, 2015 19:58
gadt in 'guard' like pattern branch
File "test.ml", line 17, characters 13-32:
Error: This pattern matches values of type int prim expr
but a pattern was expected which matches values of type a#0 expr
Type int prim is not compatible with type a#0
@j0sh
j0sh / Makefile
Last active October 14, 2015 15:53
jsoo reactive table headers not rendering
PKGS=js_of_ocaml,js_of_ocaml.log,js_of_ocaml.tyxml,js_of_ocaml.ppx,lwt.syntax
all: test.js
%.js: %.byte
js_of_ocaml +weak.js $^
%.byte: %.ml
ocamlfind ocamlc -package $(PKGS) -linkpkg -o $@ $^
@j0sh
j0sh / out
Created August 10, 2015 17:25
File "t.ml", line 14, characters 6-16:
Error: This pattern matches values of type param t
but a pattern was expected which matches values of type literal t
Type param is not compatible with type literal
@j0sh
j0sh / nat.c
Created May 28, 2015 17:02
nat with libre
/**
* @file ice.c ICE Candidate Gathering
* Copyright (C) 2015 Josh Allmann of Foresight Informatics
*/
#include <stdio.h>
#include <unistd.h> // for sleep
#include <re.h>
#define DEBUG_MODULE "ice"