Skip to content

Instantly share code, notes, and snippets.

View mseri's full-sized avatar
👻
Always with you with the MTGAP 2.0 keyboard layout

Marcello Seri mseri

👻
Always with you with the MTGAP 2.0 keyboard layout
View GitHub Profile
@mseri
mseri / chladni.py
Created April 9, 2024 19:51 — forked from profConradi/chladni.py
Chladni Square Plate Normal Modes Simulation
def energy(z, n, m, L):
return np.cos(n* np.pi *np.real(z) / L) *np.cos(m *np.pi*np.imag(z) / L) - np.cos(m*np.pi*np.real(z)/ L) *np.cos(n* np.pi *np.imag(z) / L)
class ChladniPlate:
def __init__(self, n, m, L=1, n_particles=10000):
self.L = L
self.n_particles = n_particles
self.n = n
self.m = m

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
mseri / branch.py
Created March 28, 2021 19:23 — forked from dpiponi/branch.py
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
else
let c = Char.lowercase_ascii (Bytes.get buf idx) in
@mseri
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
#!/usr/bin/env sh
# A .merlin must be present nearby the file.
# With dune it can be generated by calling `dune build @check`.
FILE="$1"
ocamlmerlin single dump -what ppxed-source -filename "$FILE" < "$FILE" | jq -r '.value' | ocamlformat --name="$FILE" -
@mseri
mseri / freeap.ml
Created July 8, 2017 17:40 — forked from leque/freeap.ml
Free Applicative Functors in OCaml
open Higher
(*
See `Free Applicative Functors' http://arxiv.org/abs/1403.0749
*)
type (_, _) t =
| Pure : 'a -> ('a, 'f) t
| Apply : ('a -> 'b, 'f) t * ('a, 'f) app -> ('b, 'f) t
let pure v = Pure v
@mseri
mseri / rtt.ml
Created July 8, 2017 17:39 — forked from leque/rtt.ml
(* See also: http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec238 *)
type _ typ =
| Unit : unit typ
| Int : int typ
| Float : float typ
| String : string typ
| Pair : ('a typ * 'b typ) -> ('a * 'b) typ
| List : 'a typ -> 'a list typ
@mseri
mseri / freer.ml
Created July 8, 2017 17:38 — forked from leque/freer.ml
Freer monad in OCaml
(*
Requirement: higher, ppx_deriving.show
*)
(*
Lightweight higher-kinded polymorphism
https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf
*)
open Higher
@mseri
mseri / gen.ml
Created May 25, 2017 21:39 — forked from dbuenzli/gen.ml
OCaml simple generators
(*---------------------------------------------------------------------------
Copyright (c) 2015 Daniel C. Bünzli. All rights reserved.
Distributed under the BSD3 license, see license at the end of the file.
%%NAME%% release %%VERSION%%
---------------------------------------------------------------------------*)
(* Simple generators according to:
Kiselyov, Peyton-Jones, Sabry
Lazy v. Yield: Incremental, Linear Pretty-printing
@mseri
mseri / Vagrantfile
Last active April 19, 2017 09:45 — forked from jonludlam/Vagrantfile
Vagrantfile for xapi development
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "boxcutter/ubuntu1604-desktop"