Skip to content

Instantly share code, notes, and snippets.

View toots's full-sized avatar

Romain Beauxis toots

View GitHub Profile
@toots
toots / gist:5136523
Created March 11, 2013 18:39
IndexedDb export function.
exportDb = (name, cb) ->
handler = indexedDB.open(name)
handler.onsuccess = (sender) ->
db = sender.target.result
stores = db.objectStoreNames
results = {}
transaction = db.transaction stores, "readonly"
@toots
toots / gist:5137788
Created March 11, 2013 21:10
Node-webkit: pop out a "save as" dialog with a given default name to save the given data.
saveAs: (name, data) ->
blob = new Blob [data]
url = URL.createObjectURL blob
# HTML5, jQuery, WebKit.. you all SUCK!
# (feels better now!)
$("<a>").attr(href: url, download: name).get()[0].click()
@toots
toots / gist:6140577
Last active December 20, 2015 13:39
Audiosocket hubot script for giphy
# Description:
# A way to search images on giphy.com
#
# Configuration:
# HUBOT_GIPHY_API_KEY
#
# Commands:
# hubot gif (foo room) <query> - Returns an animated gif matching the requested search term.
# Sends result to rooms["foo"] if specified
@toots
toots / tsvector_agg.sql
Created April 4, 2019 18:49 — forked from glittershark/tsvector_agg.sql
Postgresql aggregate function for tsvectors
CREATE OR REPLACE FUNCTION concat_tsvectors(tsv1 tsvector, tsv2 tsvector)
RETURNS tsvector AS $$
BEGIN
RETURN coalesce(tsv1, to_tsvector('default', ''))
|| coalesce(tsv2, to_tsvector('default', ''));
END;
$$ LANGUAGE plpgsql;
CREATE AGGREGATE tsvector_agg (
BASETYPE = tsvector,
.PHONY: clean all
x := cmx
i := cmi
V := @
OCAMLOPT := ocamlfind ocamlopt
OCAMLDEP := ocamlfind ocamldep
OCAMLFLAGS := -g -linkpkg -package sedlex -package sedlex.ppx -package menhirlib
@toots
toots / unicode.ml.diff
Last active June 18, 2019 09:16
Diff on unicode.ml
--- /tmp/unicode63.ml 2019-06-18 11:01:28.000000000 +0200
+++ _build/default/src/syntax/unicode.ml 2019-06-18 11:13:17.000000000 +0200
@@ -1,144 +1,162 @@
+let version = "12.1.0"
+
module Categories = struct
- let cc = [0000, 0x1f; 0x7f, 0x9f]
+ let cc =
+ [0x85, 0x85; 0x7f, 0x9f; 0x9, 0xd; 0x0, 0x1f]
module Def (S : Cstubs.Types.TYPE) = struct
let af_inet = S.constant "AF_INET" S.int
let af_inet6 = S.constant "AF_INET6" S.int
let af_unix = S.constant "AF_UNIX" S.int
let af_unspec = S.constant "AF_UNSPEC" S.int
let sa_data_len = S.constant "SA_DATA_LEN" S.int
let sa_family_len = S.constant "SA_FAMILY_LEN" S.int
let sock_dgram = S.constant "SOCK_DGRAM" S.int
let sock_stream = S.constant "SOCK_STREAM" S.int
let sock_seqpacket = S.constant "SOCK_STREAM" S.int
let c_headers = "
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#endif
#define SA_DATA_LEN (sizeof(((struct sockaddr*)0)->sa_data))
include Ctypes
let lift x = x
open Ctypes_static
let rec field : type t a. t typ -> string -> a typ -> (a, t) field =
fun s fname ftype -> match s, fname with
| View { ty }, _ ->
let { ftype; foffset; fname } = field ty fname ftype in
{ ftype; foffset; fname }
| _ -> failwith ("Unexpected field "^ fname)
@toots
toots / dune
Last active December 1, 2019 11:24
(executable
(name gen_constants_c)
(modules gen_constants_c)
(libraries sys-socket.constants ctypes.stubs))
(rule
(targets gen_constants.c)
(deps (:gen ./gen_constants_c.exe))
(action (run %{gen} %{targets})))