Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Spiros Eliopoulos seliopou

💭
I may be slow to respond.
View GitHub Profile
View release.sh
#!/usr/bin/env bash
TMPFILE=$(mktemp)
trap "rm $TMPFILE" exit
set -x
set -e
error_and_exit() {
echo -e "$(basename $0): $1"
View dune
(executable (name test_rng) (libraries async mirage-crypto-rng-async) (preprocess (pps ppx_jane)))
View gist:043d93eb6a3f2e40c26b16244aaabf88
module String = StringLabels
type t = Bytes.t
external unsafe_get_64 : Bytes.t -> int -> int64 = "%caml_string_get64u"
external unsafe_set_64 : Bytes.t -> int -> int64 -> unit = "%caml_string_set64u"
let pp_hum fmt t =
Printf.fprintf fmt "x%.16Lx" (unsafe_get_64 t 0);
Printf.fprintf fmt "x%.16Lx" (unsafe_get_64 t 8);
View bind_port.c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@seliopou
seliopou / _oasis
Last active Oct 25, 2016
Oasis pack bug
View _oasis
OASISFormat: 0.4
Name: packbug
Plugins: META (0.4), DevFiles (0.4)
BuildTools: ocamlbuild
Authors: garbage
Version: garbage
License: PD
Synopsis: garbage
@seliopou
seliopou / json-results.txt
Last active Jul 21, 2016
angstrom.0.1.0 benchmarks
View json-results.txt
# twitter1.json
┌─────────────────────────┬──────────┬────────────┬──────────┬──────────┬─────────┬──────────┬───────────────┬──────────┬──────────┬─────────────────┬────────────┐
│ Name │ Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ mGC R^2 │ mGC/Run │ 95ci │ mjGC R^2 │ mjGC/Run │ 95ci │ Percentage │
├─────────────────────────┼──────────┼────────────┼──────────┼──────────┼─────────┼──────────┼───────────────┼──────────┼──────────┼─────────────────┼────────────┤
│ twitter1: angstrom-json │ 16.12us │ 7_590.08w │ 10.25w │ 10.25w │ 1.00 │ 28.95e-3 │ -0.06% +0.06% │ 0.20 │ 0.09e-3 │ -21.97% +22.24% │ 75.47% │
│ twitter1: ezjsonm │ 21.35us │ 11_403.10w │ 17.20w │ 17.20w │ 1.00 │ 43.50e-3 │ -0.06% +0.06% │ 0.21 │ 0.13e-3 │ -20.83% +21.49% │ 100.00% │
│ twitter1: yojson │ 8.44us │ 652.00w │ │ │ 1.00 │ 2.49e-3 │ -0.37% +0.37% │ │ │ │ 39.52% │
└───────────────────────
@seliopou
seliopou / angstrom_perf.txt
Last active May 14, 2016
Angstrom benchmarks
View angstrom_perf.txt
$ ./pure_benchmark.native -q 30 +time # 4.02.3
Estimated testing time 1m (2 benchmarks x 30s). Change using -quota SECS.
┌──────┬──────────┬──────────┬───────────────┬─────────┬──────────┬──────────┬────────────┐
│ Name │ Time R^2 │ Time/Run │ 95ci │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├──────┼──────────┼──────────┼───────────────┼─────────┼──────────┼──────────┼────────────┤
│ json │ 1.00 │ 21.16ms │ -0.59% +0.62% │ 18.67Mw │ 239.28kw │ 239.28kw │ 47.53% │
│ http │ 1.00 │ 44.52ms │ -0.28% +0.29% │ 32.01Mw │ 65.11kw │ 65.11kw │ 100.00% │
└──────┴──────────┴──────────┴───────────────┴─────────┴──────────┴──────────┴────────────┘
$ ./pure_benchmark.native -q 30 +time # 4.03.0+flambda
Estimated testing time 1m (2 benchmarks x 30s). Change using -quota SECS.
@seliopou
seliopou / Permutation.hs
Created Jul 17, 2013
Random Code, Permutations, and unsafePerformIO
View Permutation.hs
module Permutation
( permute -- :: RandomGen g => [a] -> g -> ([a], g)
, permuteST -- :: RandomGen g => [a] -> g -> ST s ([a], g)
, permuteIO -- :: [a] -> IO [a]
, unsafePermute -- :: [a] -> [a]
) where
import Control.Monad ( foldM )
-- N.B. Unsafe operations have been deprecated in the original module and have
-- been moved to Control.Monad.ST.Unsafe.
@seliopou
seliopou / gist:5623971
Created May 21, 2013
how to do that thing
View gist:5623971
var g = svg.selectAll('g')
.data(/* the data */)
g.enter().append('circle')
g.selectAll('circle')
.attr('r', function(d) { /* radius */ })
@seliopou
seliopou / d3-transform-chaining.md
Last active Dec 15, 2015
A discussion of the API behavior of d3-transform.
View d3-transform-chaining.md

d3-transform chaining

An unnecessarily thorough analysis

The Methods of d3.selection

When you look at the behavior of the methods on a d3.selection, they fall into one of two categories:

  • those that create a new selection, e.g., .filter(), .exit(), .enter(), .append(), etc.; and
  • those that mutate the existing selection, e.g., .attr(), .style(), on(), etc.

Question: Are these categories disjoint and exhaustive?