This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Re: https://twitter.com/llaisdy/status/1558536851560054786?s=20&t=us8J3LvoJTlwVwod5bOqeQ *) | |
(* Use this if using the REPL, otherwise use dune to build with the library dependency *) | |
#require "uutf";; | |
(* Converts an array of ints (Unicode graphemes) into a UTF-8 encoded string. *) | |
let utf8_to_string uchars = | |
let buf = Buffer.create (2 * Array.length uchars) in | |
Array.iter (fun uchar -> Uutf.Buffer.add_utf_8 buf (Uchar.of_int uchar)) uchars; | |
Buffer.contents buf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Bindings for OpenAPI 3.0.0 - https://swagger.io/specification/#schema-object | |
ℹ️ JSON Schema validation for OpenAPI 3.0.0 must conform to this version: | |
https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00 | |
""" | |
schema Ref: | |
$ref: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
usage() { | |
cat <<EOF | |
USAGE | |
$(basename $0) FILENAME [COMMENT] | |
Get or set file comment. | |
ARGUMENTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Run with: | |
-- $ sqlite3 ecb_rates.db | |
-- sqlite> .read ecb_rates.sql | |
drop table if exists eurofxref_hist; | |
drop table if exists ecb_rates; | |
create table ecb_rates ( | |
date text not null, | |
curr text not null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Good morning everyone, I'm currently learning ocaml for one of my CS class and needed to implement | |
an avl tree using ocaml. I thought that it would be interesting to go a step further and try | |
to verify the balance property of the avl tree using the type system. Here's the resulting code | |
annotated for people new to the ideas of type level programming :) | |
*) | |
(* the property we are going to try to verify is that at each node of our tree, the height difference between | |
the left and the right sub-trees is at most of 1. *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[@bs.module "formik"] | |
[@react.component] | |
external make: ( | |
~initialValues: Js.t('a), | |
~validate: (. Js.t('a)) => Js.Dict.t(string), | |
~onSubmit: (. Js.t('a), {. "setSubmitting": [@bs.meth] bool => unit }) => unit, | |
~children: (. {. "isSubmitting": bool }) => React.element, | |
) => React.element = "Formik"; | |
module Form = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
An incomplete implementation of a type-safe SQL query in F#. | |
The idea is that a query is built up clause by clause, by representing | |
each additional clause being added on to the query as a state transition | |
between different types of queries. We capture these different types as | |
phantom types to make sure that only valid transitions (query clause | |
additions) as defined by us can be carried out. | |
The final result is a 'total query' that can be converted to a string, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import type { $Request, $Response, Middleware, NextFunction, Router } from 'express' | |
type Path = express$Path | express$Path[] | |
export type TypedMiddleware<A> = | |
| ((req: $Request & A, res: $Response, next: NextFunction) => mixed) | |
| ((error: Error, req: Request & A, res: $Response, next: NextFunction) => mixed) |
NewerOlder