Skip to content

Instantly share code, notes, and snippets.

View c-cube's full-sized avatar

Simon Cruanes c-cube

View GitHub Profile
@polytypic
polytypic / article.md
Last active March 6, 2024 18:00
Using `[@poll error]` attribute to implement systhread safe data structures

For a long time OCaml has supported lightweight threads exposed via the Thread module. These threads are often called “systhreads”, but I will simply call them “threads” in this post.

The OCaml Stdlib also provides many mutable data structures such as Hashtbl, Queue, and Stack. As the documentation alerts, none of these are thread-safe.

@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@leque
leque / freer.ml
Last active September 30, 2021 07:44
Freer monad in OCaml
(*
Requirement: higher, ppx_deriving.show
*)
(*
Lightweight higher-kinded polymorphism
https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf
*)
open Higher
@5nizza
5nizza / smt2.vim
Created September 28, 2013 18:44
Slightly modified version of Roberto Vigo's smt2 syntax file for vim.
" Vim syntax file
" Language: SMT-LIB
" Maintainer: Roberto Vigo
" Latest Revision: 23 Jan 2012
if exists("b:current_syntax")
finish
endif
" Keywords
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: