Skip to content

Instantly share code, notes, and snippets.

View stefanocudini's full-sized avatar
🏔️
working from Alps

Stefano Cudini stefanocudini

🏔️
working from Alps
View GitHub Profile
@stefanocudini
stefanocudini / random_points.py
Created July 17, 2026 10:59
Generate zipped shapefiles of random points
#!/usr/bin/env python3
"""Generate zipped shapefiles of random points inside a square area.
Only dependency: GDAL python bindings (osgeo).
Given a center (lon/lat EPSG:4326), the side of a square in km, the number
of points per shapefile and the number of shapefiles, it creates:
./points_<npoints>_<lon>_<lat>_<crs>/
<npoints>_<crs>_1.zip
@stefanocudini
stefanocudini / git-slug.sh
Last active July 2, 2026 13:45
given a GitHub issue number prints "fix-<number>-<title-slug>"
#!/usr/bin/env bash
#
# git-slug — given a GitHub issue URL, prints "fix-<number>-<title-slug>"
#
# Usage: ./git-slug [-q] <github-issue-url | issue-number>
# -q quiet: print only the slug, without the git command
# if the parameter is just a number, the default base URL (MapStore2) is used
#
# Usage with pipe, create new branch immediatly
# git-slug 1123 | sh
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanocudini
stefanocudini / gist:af8bfd0da0c4e1ef24917f5f4171d00b
Created November 7, 2023 15:11
fix ubuntu audio bluetooth
##https://askubuntu.com/questions/1248886/how-to-set-default-profile-for-bluetooth-headset
echo "load-module module-card-restore restore_bluetooth_profile=true" >> /etc/pulse/default.pa
sudo alsa force-reload
sudo systemctl restart bluetooth.service
@stefanocudini
stefanocudini / read_stdin.js
Created August 11, 2023 16:03
read stdin in nodejs
let rawInput = '';
process.stdin.on('readable', function() {
const chunk = process.stdin.read();
if (chunk !== null) {
rawInput += chunk;
}
});
process.stdin.on('end', function() {
const converted = convert(rawInput);
@stefanocudini
stefanocudini / ssh-pipe.sh
Created May 11, 2023 22:22
trasnfer pipe via ssh
#TODO test
outfile=$(basename $1)
dd if=$1 | ssh remoteuser@ip.addresss.of.remote.machine 'dd of=${outfile}'
@stefanocudini
stefanocudini / secure-random.sh
Created May 2, 2023 23:53
cryptographically secure random
#https://security.stackexchange.com/questions/183948/unix-command-to-generate-cryptographically-secure-random-string
LC_ALL=C tr -dc '[:alnum:]' < /dev/urandom | head -c32
@stefanocudini
stefanocudini / backup-mate-panel.sh
Created April 23, 2023 12:00
backup restore mate panel launchers
#!/bin/bash
dconf dump /org/mate/panel/ > panel.conf
#restore
#dconf load /org/mate/panel/ < panel.conf
@stefanocudini
stefanocudini / valid-locations.js
Last active January 17, 2023 22:16
regexpression test stringified array of locations
/**
test str is formatted "11.2,46.1|11,46|11.2,46.1|11.1,46.2"
*/
function validLocations(str) {
const regAll = /(?=^([^\|]*\|){3}[^\|]*$)(?=^([^,]*,){4}[^,]*$)/
// contains min 3 pipe and 4 commas
, regPipe = /^([^\|]*\|){3,}[^\|]*$/
@stefanocudini
stefanocudini / geopicker_api.md
Last active September 7, 2023 15:27
geopocker api rest endpoints

API Rest endpoints

The API is work in progress. This basic structure can be extended starting from the environment variable PREFIX which by default /

(✔️ Work ❌ TODO 🚧 Work in Progress)

Status Method Path Return Description
✔️ GET / html default demo map page if enabled by env var DEMO_PAGE=true