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 / wget.ext.sh
Created August 18, 2022 14:02
wget file ext
wget -A pdf,jpg -m -p -E -k -K -np http://site/path/
@stefanocudini
stefanocudini / .tmux.conf
Created February 11, 2022 16:47
tmux enable mouse for version 2.6
set-option -g mouse on
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanocudini
stefanocudini / stripYmlComments.js
Created October 18, 2021 15:30
Strip Yaml Comments in nodejs
function stripComments(ymltext) {
const lines = ymltext.split(/\r?\n/).map(line => {
const trim = line.trim();
return trim[0]!=='#' ? line : '';
}).filter(line => {
return line;
});
return lines.join('\n')+'\n';
@stefanocudini
stefanocudini / expressjs_get_entrypoint.js
Created October 14, 2021 09:13
expressjs list of defined entrypoint in app
function availableRoutes() {
return app._router.stack
.filter(r => r.route)
.map(r => {
return {
method: Object.keys(r.route.methods)[0],
path: r.route.path
};
});
}
@stefanocudini
stefanocudini / filesize.js
Created October 6, 2021 18:41
filesize human in nodejs/javascript
function filesize(bytes) {
if (bytes === 0) return bytes;
var sizes = ['Bytes','KB','MB','GB','TB'],
i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 1) + ' ' + sizes[i];
}
@stefanocudini
stefanocudini / bbox4routing.js
Created September 15, 2021 11:39
osm bbox for routers
function getBoundingBox(data) {
var bounds = {}, coordinates, point, latitude, longitude;
// Loop through each "feature"
for (var i = 0; i < data.features.length; i++) {
coordinates = data.features[i].geometry.coordinates;
if(coordinates.length === 1){
// It's only a single Polygon
// For each individual coordinate in this feature's coordinates...
@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.