Skip to content

Instantly share code, notes, and snippets.

Always with you with the MTGAP 2.0 keyboard layout

Marcello Seri mseri

Always with you with the MTGAP 2.0 keyboard layout
  • Rijksuniversiteit Groningen
  • Groningen, NL
View GitHub Profile
mseri /
Created March 1, 2022 11:06
Hatched contourf plots in matplolib
# From
# Content as in example
# ------------------------------
import matplotlib.pyplot as plt
import numpy as np
# invent some numbers, turning the x and y arrays into simple
# 2d arrays, which make combining them together easier.
x = np.linspace(-3, 5, 150).reshape(1, -1)
y = np.linspace(-3, 5, 120).reshape(-1, 1)
View gist:82b5ffc88ba3364dba925c23b7f872a1

How to setup a practically free CDN

I've been using [Backblaze][bbz] for a while now as my online backup service. I have used a few others in the past. None were particularly satisfactory until Backblaze came along.

It was - still is - keenly priced at a flat $5 (£4) per month for unlimited backup (I've currently got just under half a terabyte backed-up). It has a fast, reliable client. The company itself is [transparent about their operations][trans] and [generous with their knowledge sharing][blog]. To me, this says they understand their customers well. I've never had reliability problems and everything about the outfit exudes a sense of simple, quick, solid quality. The service has even saved the day on a couple of occasions where I've lost files.

Safe to say, I'm a happy customer. If you're not already using Backblaze, [I highly recommend you do][recommend].

Taking on the big boys with B2

mseri / picam.swift
Last active December 10, 2021 08:56
Set resolution for the picamera, I use it to select the field of view, see
View picam.swift
// picam.swift
// picam
// Created by Marcello Seri on 31/05/2021.
import Foundation
import AVFoundation
mseri /
Created March 28, 2021 19:23 — forked from dpiponi/
Branched flow with taichi
import math
import numpy as np
import random
import matplotlib.pyplot as plt
medium_size = 1024
x = np.linspace(-1., 1., medium_size)
y = np.linspace(-1., 1., medium_size)
x, y = np.meshgrid(x, y, indexing='ij')
module Trie = struct
type t = { mutable count : int; children : t option Array.t }
let[@inline] empty () = { count = 0; children = Array.make 128 None }
let add buf pos len t =
let rec loop idx t =
if idx > pos + len - 1 then t.count <- t.count + 1
let c = Char.lowercase_ascii (Bytes.get buf idx) in
mseri / ppxed-source
Created September 10, 2019 06:59 — forked from Khady/ppxed-source
Use merlin to print an ocaml file after being processed by a ppx
View ppxed-source
#!/usr/bin/env sh
# A .merlin must be present nearby the file.
# With dune it can be generated by calling `dune build @check`.
ocamlmerlin single dump -what ppxed-source -filename "$FILE" < "$FILE" | jq -r '.value' | ocamlformat --name="$FILE" -
mseri / sundials3.rb
Created August 23, 2019 23:05
Homebrew formula to install Sundials3 for sundialsml
View sundials3.rb
class Sundials3 < Formula
desc "Nonlinear and differential/algebraic equations solver"
homepage ""
url ""
version "3.2.1"
sha256 "47d94d977ab2382cdcdd02f72a25ebd4ba8ca2634bbb2f191fe1636e71c86808"
revision 1
depends_on "cmake" => :build
depends_on "gcc" # for gfortran
View ocaml jupyter matplotlib
open Matplotlib;;
let plot () =
let data = Mpl.plot_data `png in
ignore (Jupyter_notebook.display ~base64:true "image/png" data);;
let () =
Mpl.set_backend Agg;
Mpl.style_use "ggplot"
mseri /
Created November 23, 2018 12:40
Upgrade all opam files in the folder to opam2
(* requires opam-format and opam-state *)
let opam_files =
Sys.readdir "."
|> Array.to_list
|> List.filter (fun l -> match String.split_on_char '.' l with | _ :: ["opam"] -> true | _ -> false)
let make_opam_file fname =
fname |> OpamFilename.of_string |> OpamFile.make
mseri /
Created October 30, 2018 12:52
How pkcs11 is solving the issue of ctypes Carray lifetimes
module Reachable_ptr : sig
type 'a t
val typ : 'a Ctypes_static.typ -> 'a t Ctypes_static.typ
val setf : ('b, 'c) Ctypes.structured ->
('a t, ('b, 'c) Ctypes.structured) Ctypes.field -> 'a Ctypes.ptr -> unit
val getf : ('b, 'c) Ctypes.structured ->
('a t, ('b, 'c) Ctypes.structured) Ctypes.field -> 'a Ctypes.ptr
end = struct