Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / README.md
Last active March 29, 2024 22:26
EPCIs from DROM moved to area of metropolitan French area

Générer une version de données où les EPCI des DROM sont regroupés à proximité du territoire métropolitain

Cette demande fait suite à une demande pour avoir un résultat similaire à "Contours des communes de France simplifié, avec régions et département d'outre-mer rapprochés" https://www.data.gouv.fr/fr/datasets/contours-des-communes-de-france-simplifie-avec-regions-et-departement-doutre-mer-rapproches/

Nous avions vu passer le billet de blog d'Eric Mauvière à ce sujet https://www.icem7.fr/cartographie/un-fond-de-carte-france-par-commune-optimise-pour-le-web-et-lanalyse-statistique/

Méthodologie adoptée

Il passait par les codes départements pour déterminer quelles entités devaient être translatés/redimensionnées sur la métropole. Nous avons fait le choix de partir des rectangles englobants ("bounding box") pour pouvoir assigner les mêmes codes et réutiliser une partie de la recette du billet de blog. Ce fonctionnement présente en outre l'avantage d'être générique à toutes les unités administratives i

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Display a map</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.css">
<style type="text/css">
@ThomasG77
ThomasG77 / README.md
Created March 21, 2024 13:07
HTML browser favorites to CSV recipe with CLI

HTML browser favorites to CSV

Need pup (Go based), jq (install as binary) and he (Node based)

Take the html export from your browser

cat your_favorites.html | pup a json{} | jq -c -r '["title","url"], (.[] | [.text,.href]) | @csv' | he --decode >| your_favorites_decoded.csv
@ThomasG77
ThomasG77 / index.html
Last active March 9, 2024 19:36
Leaflet simple marker
<!doctype html>
<html>
<head>
<title>Exemple de Leaflet sans Browserify</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<style type="text/css">
#map { height: 380px; }
</style>
node_modules/
@ThomasG77
ThomasG77 / README.md
Created January 24, 2024 18:15
Reset your MySQL root password

Reset your MySQL root password

Only used on localhost so did not feel concerned about the password weakness here

sudo service mysql stop
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'basicPassword1234';" >| $HOME/mysql-init
sudo mysqld --init-file=$HOME/mysql-init &
sudo service mysql start
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ThomasG77
ThomasG77 / dict_zip
Last active January 9, 2024 13:23
Javascript equivalent to python dict(zip(['AB', 'CD', 'EF', 'GH'],[1, 2, 3, 4])) - 2 js arrays to one js object
var keys = ['AB', 'CD', 'EF', 'GH'];
var values = [1, 2, 3, 4];
// Equivalent to python dict(zip(['AB', 'CD', 'EF', 'GH'],[1, 2, 3, 4])) in javascript
function dictZip(key_array, val_array) {
if (key_array.length === val_array.length) {
return key_array.reduce((acc, curr, index) => {
acc[curr] = val_array[index];
return acc;
}, {});
@ThomasG77
ThomasG77 / countries.geojson
Last active January 4, 2024 19:54
Sample Leaflet with GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.