Skip to content

Instantly share code, notes, and snippets.

View Leonidas-from-XIV's full-sized avatar

Marek Kubica Leonidas-from-XIV

View GitHub Profile
@Leonidas-from-XIV
Leonidas-from-XIV / jbuild
Created May 25, 2018 11:18
protoc & dune
(rule
((targets (foo_types.mli
foo_types.ml
foo_pb.mli
foo_pb.ml
foo_pp.mli
foo_pp.ml))
(deps (foo.proto))
(action (run ocaml-protoc -int32_type int_t -int64_type int_t -ml_out . ${<}))))
@Leonidas-from-XIV
Leonidas-from-XIV / github-iosevka.css
Created February 24, 2018 11:28
Apply on domain 'github.com'
#files .file .data pre,
#files .file .line-data,
#files .file .line-number,
.blob-code-inner,
#readme code,
#readme pre {
font-family: Iosevka, monospace !important;
}
@Leonidas-from-XIV
Leonidas-from-XIV / parser.mly
Created February 20, 2018 20:14
Shift-reduce conflict with arbitrary resolution
Warning: one state has shift/reduce conflicts.
Warning: one shift/reduce conflict was arbitrarily resolved.
File "src/variable/parser.mly", line 16, characters 3-3:
Warning: production value_sequence -> is never reduced.
Warning: in total, 1 productions are never reduced.
@Leonidas-from-XIV
Leonidas-from-XIV / gist:daf3c9078f49afbaa6a5b85fe013e36c
Created February 15, 2018 12:29
Programming Rust fonts — Arial
IBNDXA+GuardianSans-Regular Type 1C Custom yes yes yes 10540 0
IBNDXA+URWTypewriterTOT-LigNar Type 1C Custom yes yes yes 10541 0
IBNDXA+URWTypewriterTOTThinNar Type 1C WinAnsi yes yes yes 10542 0
IBNDXA+GuardianSansNarrow-Regular Type 1C WinAnsi yes yes yes 10543 0
LYDGIT+MinionPro-SemiboldIt Type 1C Builtin yes yes yes 13 0
LYDGIT+MinionPro-SemiboldIt Type 1C Custom yes yes yes 14 0
LYDGIT+MyriadPro-SemiboldCond Type 1C Custom yes yes yes 16 0
LYDGIT+MyriadPro-Cond Type 1C Custom yes yes yes 17 0
LYDGIT+MinionPro-Regular Type 1C Custom yes yes yes 21 0
LYDGIT+MinionPro-It Type 1C Custom yes yes yes 24 0
@Leonidas-from-XIV
Leonidas-from-XIV / 0_if_expr.ml
Last active December 13, 2017 17:18
Why if needs to be an expression
let result = match is_correct some_value with
| true -> some_result_function 42
| false -> some_error_function 23
in
(* use result here, no mutation, generalizes to n cases easily *)
@Leonidas-from-XIV
Leonidas-from-XIV / collab_lib.ml
Last active November 21, 2017 10:28
Failure to run js_of_ocaml-ppx
We couldn’t find that file to show.
@Leonidas-from-XIV
Leonidas-from-XIV / mysql_config
Created November 15, 2017 13:36
mysq_config because homebrew mysql is broken
#!/bin/bash
case "$1" in
"--libs")
echo "-L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -ldl -lm -lpthread"
;;
*)
/usr/local/Cellar/mysql-connector-c/6.1.11/bin/mysql_config "$@"
;;
esac
@Leonidas-from-XIV
Leonidas-from-XIV / peano-cps.ml
Created November 9, 2017 19:11
Peano arithmetics in Continuation Passing Style
let const v k =
k v
let inc k v =
k (v + 1)
let print v =
Printf.printf "Value %d\n" v
let () =
@Leonidas-from-XIV
Leonidas-from-XIV / gadtdecoder.ml
Last active October 10, 2017 12:56
Mapping specifications into function signatures
type _ elem =
| Int : int elem
| String : string elem
type (_, _) spec =
| [] : ('a, 'a) spec
| (::) : 'a elem * ('b, 'c) spec -> (('a -> 'b), 'c) spec
let decode_elem = function
| String -> fun x -> x
@Leonidas-from-XIV
Leonidas-from-XIV / jbuild
Created October 2, 2017 19:22
How do I get `jbuild runtest -p redis-async` to work?
(jbuild_version 1)
(library
((name redis_test)
(modules test)
(wrapped false)
(libraries (redis oUnit))))
(executable
((name test_sync)