Skip to content

Instantly share code, notes, and snippets.


Raphael Rafatpanah persianturtle

View GitHub Profile
MarcelCutts /
Created Sep 18, 2017
A super hacky attempt to get async fetching working on button press.
open Bs_fetch;
let sj json :list string => Json.Decode.(json |> list string);
type remoteData 'e 'a =
| NotAsked
| Loading
| Failure 'e
| Success 'a;
busypeoples /
Last active Nov 28, 2020
Phantom types in ReasonML

Phantom types in ReasonML


"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

busypeoples /
Last active Sep 19, 2019
Making Impossible States Impossible in ReasonML

Making Impossible States Impossible in ReasonML


If you have already seen Richard Feldman's talk entitled "Making Impossible States Impossible" or have read "Designing with types: Making illegal states unrepresentable" then you can skip the explanations and just head straight to the Reason examples.

This post is intended to display how to model your Reason Application to prevent creating impossible states. The benefits of being able to design a feature in this way include avoiding having to deal with complex test scenarios regarding defined business rules and a clear documentation of what is possible just by looking at the type definition. Long story short, let's see how this all works by implementing an example.


ryan-senn / LoginMsg.elm
Last active Dec 31, 2019
Update nesting
View LoginMsg.elm
module Modules.Auth.Login.Msg exposing (..)
import Http exposing (Error)
import Types exposing (User)
type LoginMsg
= LoginUpdateEmail String
| LoginUpdatePassword String
kavitshah8 / bind.js
Last active Jul 9, 2019
Frequently Asked Javascript Interview Questions
View bind.js
Function.prototype.bind1 = function (scope) {
let fn = this
let prefixArgs =, 1)
return function() {
let suffixArgs =
let args = prefixArgs.concat(suffixArgs)
return fn.apply(scope, args)
zcaceres /
Last active Jan 17, 2021
Understanding Binding and 'this' in Javascript by

How to Eyeball Your ‘This’ Context in Javascript


The early programmer struggles with the Javascript keyword this. But understanding your this context is easier than it seems.

This is all about where a function is invoked. Often, early programmers worry about where the function was declared. Perhaps the function was declared in a specific file or a particular object. Surely this changes it's this!


View javascript-trim-svg-whitespace.js
function trimSvgWhitespace() {
// get all SVG objects in the DOM
var svgs = document.getElementsByTagName("svg");
// go through each one and add a viewbox that ensures all children are visible
for (var i=0, l=svgs.length; i<l; i++) {
var svg = svgs[i],
box = svg.getBBox(), // <- get the visual boundary required to view all children

Comparison of ASP.NET and Node.js for Backend Programming

We will compare ASP.NET and Node.js for backend programming.
Source codes from examples.


This document was published on 21.09.2015 for a freelance employer. Some changes since then (14.02.2016):

  1. Koa.js no longer uses co-routines, it has switched to Babel's async/await. yield and await are used almost in the same way, so I see no point to rewrite the examples.
jaydenseric /
Last active Jan 24, 2021
A quick guide to using FFmpeg to create cross-device web videos.

Video conversion with FFmpeg


On mac:

  1. Download the latest release.
  2. Extract the binary and place it in /usr/local/bin.

Command basics