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 / 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 / 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';
@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
@stefanocudini
stefanocudini / web_htop.sh
Last active January 3, 2023 04:23
web colored interface for htop
#!/bin/bash
# requirements: apt install nmap htop aha
# (aha is ANSI color to HTML converter)
ncat -k -l -p 9999 -c "echo 'HTTP/1.1 200 OK\nContent-type: text/html\nconnection: close\\n'; echo q | htop | aha --black --line-fix"
@stefanocudini
stefanocudini / getvars.js
Last active October 1, 2018 14:37
web scraping global javascript vars in nodejs
const Nightmare = require('nightmare')
const nightmare = Nightmare({
// show: true
});
var url = process.argv[2] || 'http://labs.easyblog.it/',
prop = process.argv[3] || undefined;
Object.byString = function(o, s) {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanocudini
stefanocudini / L.GeoJSONAutoClear.js
Created July 4, 2017 17:49
Leaflet layer geojson self cleaning on zoom out
L.GeoJSONAutoClear = L.GeoJSON.extend({
options: {
autoclear: true,
zoomdiff: 2
},
_autoClear: function(e) {
if(this.getLayers().length) {
if(e.target.getZoom() < e.target.getBoundsZoom(this.getBounds())-this.options.zoomdiff)
this.clearLayers();
}
@jasodeep
jasodeep / install-sass-and-compass
Created December 2, 2016 20:05
Install Sass & Compass on debian
sudo aptitude install ruby-full
sudo gem install sass
sudo gem install compass
@olih
olih / jq-cheetsheet.md
Last active June 22, 2024 18:30
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

Let [tag] = any tag in upstream repo
git fetch upstream --tags
git push origin --tags