Skip to content

Instantly share code, notes, and snippets.

View anmonteiro's full-sized avatar

Antonio Nuno Monteiro anmonteiro

View GitHub Profile
open Ppxlib
let icon ~loc name =
let open Ast_helper in
Str.module_
(Mb.mk
{ loc; txt = Some name }
(Mod.structure
[ Str.primitive
(Val.mk

Using dune-release to release OCaml packages

Originally written 2020-05-16

dune-release is a good improvement over the old opam-publish, but releasing software is still clearly not a solved problem, and I find it hard to remember the exact steps involved in releasing an opam package, especially if some time has passed since the last release. This note is an attempt at having a place

@anmonteiro
anmonteiro / gist:a174fd2aef439cb3f4e231afa3afae65
Created May 25, 2021 22:24 — forked from kyledrake/gist:d7457a46a03d7408da31
Creating a self-signed SSL certificate, and then verifying it on another Linux machine
# Procedure is for Ubuntu 14.04 LTS.
# Using these guides:
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
# https://turboflash.wordpress.com/2009/06/23/curl-adding-installing-trusting-new-self-signed-certificate/
# https://jamielinux.com/articles/2013/08/act-as-your-own-certificate-authority/
# Generate the root (GIVE IT A PASSWORD IF YOU'RE NOT AUTOMATING SIGNING!):
openssl genrsa -aes256 -out ca.key 2048
openssl req -new -x509 -days 7300 -key ca.key -sha256 -extensions v3_ca -out ca.crt
open Lwt_engine;
[@ocaml.warning "-3"];
module Lwt_sequence = Lwt_sequence;
[@ocaml.warning "+3"];
module Fd_map =
Map.Make({
type t = Unix.file_descr;
let compare = compare;
use syn::{self, Item, ItemMod, ItemUse, UseGroup, UsePath, UseTree};
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::Read;
use std::process;
fn main() {
let mut args = env::args();
{
"resolutions": {
"@opam/conf-openssl": {
"source": "no-source:",
"override": {
"dependencies": {
"@opam/conf-pkg-config": "*",
"@esy-packages/esy-openssl": "*"
}
}
FROM ocaml/opam2:alpine-3.7-ocaml-4.06
RUN sudo apk --no-cache add ca-certificates
RUN sudo apk add --update m4 openssh-client
# Setup SSH.
RUN mkdir -p ~/.ssh
ARG SSH_PRIVATE_KEY
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN printf "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
@anmonteiro
anmonteiro / sse.re
Last active August 5, 2018 21:13
Server-sent events in http/af
let set_interval = (s, f, destroy) => {
let rec set_interval_loop = (s, f, n) => {
let timeout =
Lwt_timeout.create(s, () =>
if (n > 0) {
f();
set_interval_loop(s, f, n - 1);
} else {
destroy();
}

Code Splitting

NOTE: This gist uses the master branch of ClojureScript. Clone ClojureScript and from the checkout run ./script/bootstrap and ./script/uberjar. This will produce target/cljs.jar which you can use to follow this guide.

As client applications become larger it becomes desirable to load only the code actually required to run a particular logical screen. Previously ClojureScript :modules compiler option permitted such code splitting, but this feature only worked under :advanced compilation and users would still have to manage loading these splits. :modules also required manual

mov2gif(){
ffmpeg -i "$1" -vf scale=800:-1 -pix_fmt rgb24 -r 10 -f image2pipe -vcodec ppm - |\
convert -delay 10 -layers Optimize -loop 0 - "$2"
}