Skip to content

Instantly share code, notes, and snippets.

View Faliszek's full-sized avatar

Paweł Falisz Faliszek

View GitHub Profile
@mscharley
mscharley / Generator.re
Last active January 19, 2022 02:45
Example of using JavaScript generators in ReasonML.
/* Note, this is only for library interop code. This is *not* a good way to do things in pure Reason code. */
module type GeneratorType {
type value('a);
type t('a);
type fn('a) = unit => t('a);
let valueGet: value('a) => option('a);
let doneGet: value('a) => bool;
@jdeisenberg
jdeisenberg / QueryString.re
Last active August 22, 2019 04:25
Parse a query string in ReasonML
/*
* Define a type that can be either a single string or a list of strings
*/
type queryItem =
| Single(string)
| Multiple(list(string));
/*
* Make a string “safe” by
@jaredly
jaredly / BasicServer.re
Created January 2, 2018 05:24
Simple Static File Server in Reason/OCaml
let recv = (client, maxlen) => {
let bytes = Bytes.create(maxlen);
let len = Unix.recv(client, bytes, 0, maxlen, []);
Bytes.sub_string(bytes, 0, len)
};
let parse_top = top => {
let parts = Str.split(Str.regexp("[ \t]+"), top);
switch (parts) {
@muziyoshiz
muziyoshiz / mix.exs
Created March 21, 2017 10:27
Sample of GraphQL Relay server on Phoenix
# mix.exs
defmodule PhoenixRelaySample.Mixfile do
use Mix.Project
def project do
[app: :phoenix_relay_sample,
version: "0.0.1",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
@lindig
lindig / dir.ml
Last active May 9, 2024 04:54
OCaml - list recursively regular files in a directory
(** [dir_is_empty dir] is true, if [dir] contains no files except
* "." and ".."
*)
let dir_is_empty dir =
Array.length (Sys.readdir dir) = 0
(** [dir_contents] returns the paths of all regular files that are
* contained in [dir]. Each file is a path starting with [dir].
@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active May 17, 2024 12:59
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: