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 / draggable.polygon.js
Created September 14, 2021 22:33
leaflet draggable polygon
//require https://github.com/w8r/Leaflet.Path.Drag
var imagePoly = [
imageBounds.getNorthEast(),
imageBounds.getNorthWest(),
imageBounds.getSouthWest(),
imageBounds.getSouthEast()
];
var poly = new L.Polygon([imagePoly], {
//draggable:true,
@stefanocudini
stefanocudini / mkhtml.php
Created August 1, 2021 12:21
php cli script to genrate html boilerplate
#!/usr/bin/env php
<?php
ob_start();
if(isset($argv[1]))
$outfile = $argv[1];
else
$outfile = 'index.html';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanocudini
stefanocudini / random-string.sh
Last active December 7, 2020 23:21
random string
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-10} | head -n 10
head -c32 /dev/urandom | xxd -c 64 -p
xxd -c 32 -p /dev/urandom | head -n1
@stefanocudini
stefanocudini / integermap.html
Created November 16, 2020 23:59
show integer and primes coordinates in the world
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" rel="stylesheet" type="text/css" />
<style>
#map {
position: absolute;
top: 0;
@stefanocudini
stefanocudini / envtmpl.js
Last active October 2, 2020 11:02
environment vars to template to file
/*
usage:
cat config.template.yml | VAR1=test node envtmpl.js > config.valued.yml
*/
const fs = require('fs');
//const tmplReg = /\$\{(.+?)\}/g
const tmplReg = /\$\{([\w_\-]+)\}/g
//const tmplReg = /\{ *([\w_\-]+) *\}/g
/*
set windows border width to Linux Unbuntu as window manager: metacity,marco
usage(run by root):
$ npm i cheerio
$ sudo wget -O- https://gist.githubusercontent.com/stefanocudini/0a7c06c202e6a61ddd8e67430717c023/raw/df8d9d8da9d9dce5a4af7c45e18b3e2280e9c184/ubuntu-windows-border-width.js | nodejs
*/
const cp = require('child_process');
const fs = require('fs');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var http = require('http');
http.createServer(onRequest).listen(3000);
function onRequest(client_req, client_res) {
console.log('serve: ' + client_req.url);
var options = {
hostname: 'www.google.com',
port: 80,