Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Risto-Stevcev / odoc.sh
Last active October 29, 2018 01:04
Helper shell script to run odoc for bucklescript projects
#!/bin/bash
readonly PKG_NAME_RE='.*\"name\":\s*"\(.*\)".*'
readonly PKG_NAME=$(
cat bsconfig.json \
| grep "\"name\":" \
| sed -e 's/'"${PKG_NAME_RE}"'/\1/g'
)
readonly DOCS=${1:-docs}
@Risto-Stevcev
Risto-Stevcev / test.ml
Created July 31, 2018 15:51 — forked from infinity0/test.ml
OCaml GADTs and avoiding "type constructor would escape its scope" errors
(* GADT list that exposes the type of the head element *)
type _ hlist =
| Nil: 'a hlist
| Cons: ('a * 'b hlist) -> 'a hlist
(* let rec len = function *)
(* let rec len (type a) (l: a hlist): int = match l with *)
(* both of the above result in a "type constructor would escape its scope" error *)
(* correct version: *)
let rec len : type a. a hlist -> int = function
@Risto-Stevcev
Risto-Stevcev / what-forces-layout.md
Created June 22, 2018 07:16 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
type scalar = float
type 'a one = [`one of 'a]
type 'a z = [`zero of 'a]
type 'a two = [`two of 'a]
type 'a three = [`three of 'a]
type 'a four = [`three of 'a]
let map2 f x y = Array.init (min (Array.length x) (Array.length y))
(fun n -> f x.(n) y.(n))
@Risto-Stevcev
Risto-Stevcev / init.vim
Last active January 5, 2018 16:34
Neovim config
call plug#begin('~/.local/share/nvim/plugged')
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'autozimu/LanguageClient-neovim'
" (Optional) Multi-entry selection UI.
" Plug 'junegunn/fzf'
" (Completion plugin option 1)
@Risto-Stevcev
Risto-Stevcev / sig
Created December 7, 2017 11:16 — forked from yawaramin/sig
Bourne Shell script to print out Merlin's inferred signature of an OCaml file (module)
#!/usr/bin/env sh
# Works with merlin version 2.5.4. Using protocol described at
# https://github.com/ocaml/merlin/blob/master/doc/dev/OLD-PROTOCOL.md#type-checking
usage ()
{
echo Usage: either of the following will work:
echo
echo ' sig module.ml'
@Risto-Stevcev
Risto-Stevcev / object-watch.js
Created November 16, 2017 22:47 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@Risto-Stevcev
Risto-Stevcev / AssocList.purs
Created November 14, 2017 13:08 — forked from Thimoteus/AssocList.purs
records as association lists
module AssocList where
import Data.List (List(..))
import Data.Record (delete, get)
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Tuple (Tuple(..))
import Type.Row (class RowLacks, class RowToList, Cons, Nil, RLProxy(RLProxy), kind RowList)
class RLToList
(rl :: RowList)
@Risto-Stevcev
Risto-Stevcev / Primitive.purs
Created September 25, 2017 12:42
Some initial experimentation with finally tagless sums for JS primitives in Purescript
module Primitive (class Primitive) where
class OnlyPrimitive a
instance intOnlyPrimitive ∷ OnlyPrimitive Int
instance boolOnlyPrimitive ∷ OnlyPrimitive Boolean
instance stringOnlyPrimitive ∷ OnlyPrimitive String
class OnlyPrimitive a ⇐ Primitive a
instance intPrimitive ∷ Primitive Int
instance boolPrimitive ∷ Primitive Boolean
@Risto-Stevcev
Risto-Stevcev / Foo.purs
Created September 5, 2017 12:40
Tests PR #56 for purescript-spec
module Test.Foo where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Console (log)
import DOM (DOM)
import DOM.HTML (window)
import DOM.HTML.Types (htmlDocumentToDocument)