Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta charset="utf-8" />
<title>Chronologie des mesures covid en France</title>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288419716939937511
#endif
#ifndef DEBUG
@Gro-Tsen
Gro-Tsen / num2english.pl
Created January 15, 2024 12:11
Numbers to text
#! /usr/local/bin/perl -w
# Convert a decimal number to its literal expression in English.
use strict;
use warnings;
use Getopt::Std;
my %opts;
getopts("u", \%opts);
@Gro-Tsen
Gro-Tsen / draw-binary-tree.pl
Created December 23, 2023 12:07
Draw the Stern-Brocot or dyadic tree
#! /usr/local/bin/perl -w
# Generate a graphical representation of either the Stern-Brocot or
# (with option -d) the dyadic tree on the interval [0,1].
# -- David A. Madore <http://www.madore.org/~david/> 2023-12-23
# Public Domain
use strict;
use warnings;
@Gro-Tsen
Gro-Tsen / pairing.hs
Created December 1, 2023 14:36
Closure-based pairs in various functional programming languages
-- (This is the Haskell version)
-- Define pairing and projection functions by storing values in a closure
let pairing = \x -> \y -> \f -> f x y
let proj1 = \p -> p (\x -> \y -> x)
let proj2 = \p -> p (\x -> \y -> y)
-- Conversion from and to native pairs
let fromnative = \(x,y) -> pairing x y
let tonative = \p -> p (\x -> \y -> (x,y))
let tonative_broken = \p -> (proj1 p, proj2 p)
-- This works as expected:
@Gro-Tsen
Gro-Tsen / cant.dot
Created November 13, 2023 17:04
Adjacency graph of French territorial divisions (in `graphviz` format)
graph cant {
c0101 [label="0101"];
c0104 [label="0104"];
c0101 -- c0104;
c0107 [label="0107"];
c0101 -- c0107;
c0110 [label="0110"];
c0101 -- c0110;
c0111 [label="0111"];
c0101 -- c0111;
sudo apt-get install postgresql-13-postgis-3 postgresql-13-postgis-3-scripts
createdb admin-express
sudo -u postgres psql -d admin-express -c 'CREATE EXTENSION postgis ;'
sudo -u postgres psql -d admin-express -c 'GRANT ALL ON TABLE public.spatial_ref_sys TO david ;'
## Go to <URL: https://geoservices.ign.fr/adminexpress >
## and download ADMIN-EXPRESS_3-2__SHP_LAMB93_FXX_2023-10-16.7z to /data/FTP
cd /data/tmp
7z x /data/FTP/ADMIN-EXPRESS_3-2__SHP_LAMB93_FXX_2023-10-16.7z
cd /data/tmp/ADMIN-EXPRESS_3-2__SHP_LAMB93_FXX_2023-10-16/ADMIN-EXPRESS/1_DONNEES_LIVRAISON_2023-10-16/ADE_3-2_SHP_LAMB93_FXX
ogr2ogr -f postgresql PG:"host=localhost dbname=admin-express" REGION.shp -nlt PROMOTE_TO_MULTI
## Compute the Fourier coefficients of the harmonic parametrization of the
## boundary of the Mandelbrot set, using the formulae given in following paper:
## John H. Ewing & Glenn Schober, "The area of the Mandelbrot set",
## Numer. Math. 61 (1992) 59-72 (esp. formulae (7) and (9)). (Note that their
## numerical values in table 1 give the coefficients of the inverse series.)
## The coefficients ctab[m] are the b_m such that z + sum(b_m*z^-m) defines a
## biholomorphic bijection from the complement of the unit disk to the
## complement of the Mandelbrot set. The first few values are:
## [-1/2, 1/8, -1/4, 15/128, 0, -47/1024, -1/16, 987/32768, 0, -3673/262144]
@Gro-Tsen
Gro-Tsen / x.svg
Created July 24, 2023 09:48
Twitter's new logo that looks suspiciously like U+1D54F MATHEMATICAL DOUBLE-STRUCK CAPITAL X
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Gro-Tsen
Gro-Tsen / ellipse-conformal-map.sage
Created December 15, 2022 16:34
Graphical representation of the Riemann mapping theorem for a square (inside and out) and an ellipse (inside and out)
# Square of eccentricity (but not that of the drawn ellipse):
modparm = 3/4
# The size of the drawn ellipse (semimajor and semiminor) is computed
# below.
### Mapping the inside of the disk to the inside of the ellipse:
prescale = N(modparm^(-1/4))
postscale = N(pi/(2*elliptic_kc(modparm)))