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-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/[email protected]/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,
@stefanocudini
stefanocudini / ping_server.sh
Created February 25, 2020 13:50
listen incoming ping requests
#!/bin/bash
tcpdump -nni lo icmp
@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 / words_here.sh
Last active September 18, 2019 20:18
list each words in this directory
#!/bin/bash
grep -rhoE '\w+{3,10}' --exclude-dir=node_modules --exclude-dir='.git' . | sort | uniq -c | sort -n | tail -n 100