Skip to content

Instantly share code, notes, and snippets.

View idkjs's full-sized avatar

Alain Armand idkjs

View GitHub Profile
@mlms13
mlms13 / CommonInfix.re
Last active December 5, 2019 10:07
Commonly-used infix functions in functional programming (Reason edition)
let (<|) = ('a => 'b, 'a) => 'b; // purescript and haskell use ($)
let (|>) = ('a, 'a => 'b) => 'b; // purescript uses (#)
let compose: ('b => 'c, 'a => 'b, 'a) => 'c;
let (<<) = compose; // purescript uses (<<<), haskell uses (.)
let composeFlipped: ('a => 'b, 'b => 'c, 'a) => 'c;
let (>>) = composeFlipped; // purescript uses (>>>)
// This is a proper alternative to
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14
// The one in that file uses Promise, but that's *wrong*.
// We only used promise as a demo of its API. We'll remove it soon.
// As you can see below, the pure XMLHttpRequest code is just as clean,
// less mysterious for all, more performant, extensible, and actually correct.
// Ignore these externals for now. They're just for illustration
// purposes. I just copy pasted the Js code from
@danylokos
danylokos / aria2c.md
Created October 29, 2019 08:57
aria2c multithread download
aria2c \
-x 16 \
-s 16 \
--load-cookies=cookies.txt \
https://download.developer.apple.com/Developer_Tools/Xcode_10.3/Xcode_10.3.xip
@danieldietrich
danieldietrich / README.md
Last active February 14, 2024 13:15
The easiest way to bundle a simple TypeScript web application

THIS README IS OUTDATED AND UNMAINTAINED - PLEASE DON'T RELY ON THIS

The easiest way to bundle a simple TypeScript web application

Packaging JavaScript applications can be a bit overwhelming. The popular project uglifyjs does not support ES6, it is cumbersome to configure the allmighty Webpack, bundlers like Parcel and Microbundle still have bugs or do not compile to ESM bundles that work in a browser. It is hard to figure out the best way to bundle an application.

Here I give a small example, how we achieve the goal using the

open Belt;
type t(+'a) = Js.Promise.t('a);
type error = Js.Promise.error;
type result('ok, 'error) = t(Result.t('ok, 'error));
external errorToString: error => string = "%identity";
[@bs.new]
@Schmavery
Schmavery / reason-dojo.md
Last active August 15, 2019 01:25
reason-dojo twitter
  • Go to https://reasonml.github.io/reason-react/ and follow the QuickStart instructions (you don't need to run npm run webpack)
  • Open another shell and run npm run server to start a webserver displaying your site - visit localhost:8000 to see the site.
  • Run npm install reason-urql. This will let you make graphql queries using react hooks.
  • Run npm install graphql_ppx. This will let you construct your graphql queries safely and easily.
  • Open bsconfig.json and add reason-urql to your "bs-dependencies" list (reason-react should already be there).
  • Also add "ppx-flags": ["graphql_ppx/ppx"].
  • Run npx send-introspection-query http://cc265406.ngrok.io/graphql.
  • Check out the examples in the reason-urql to see how to use the hooks. Example query and hook.
  • The graphql server is at `http://cc
open Typeclasses;
// a binary search tree is a binary tree that holds order-able members and
// keeps lesser values on the left and greater or equal values on the right
module Make = (Order: Ord) => {
type t =
| Empty
| Node(t, Order.t, t);
// O(log n) operation to add a new value in a valid position in the tree
@Leonidas-from-XIV
Leonidas-from-XIV / list_set_exn.ml
Created July 16, 2019 12:54
Quick and dirty, non-TR list_set_exn
open Core
let rec list_set_exn index v = function
| [] -> []
| _ :: xs when index = 0 -> v :: xs
| x :: xs -> x :: list_set_exn (Int.pred index) v xs
@justgage
justgage / BEM.re
Created April 21, 2019 03:04
BEM.re
let whitespaceRegex = Js.Re.fromString("\\s+");
/**
* This is a little helper to make sure that classNames are BEM style
*
* Example:
* module B =
* BEM.Block({
* let block = "Legal";
* });
@jtpaasch
jtpaasch / Dune.md
Created April 9, 2019 18:36
Notes on using `dune` for OCaml.

Dune

A first pass

A library and then an executable that uses that library.

A simple library

Create a folder called foo: