Skip to content

Instantly share code, notes, and snippets.

View pioz's full-sized avatar
🧙‍♂️
[object Object]

Enrico pioz

🧙‍♂️
[object Object]
View GitHub Profile
@pioz
pioz / iptables.txt
Created September 23, 2016 10:12
Drop a range of ports except for localhost
iptables -A INPUT -p tcp --match multiport --dports 3000:6000 -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p tcp --match multiport --dports 3000:6000 -j DROP
# to remove this rules
iptables -D INPUT -p tcp --match multiport --dports 3000:6000 -s 127.0.0.1 -j ACCEPT
iptables -D INPUT -p tcp --match multiport --dports 3000:6000 -j DROP
# Use iptables-persist to make this rules persistant
@pioz
pioz / tiramisù.md
Last active January 11, 2022 17:00
Ricetta Tiramisù

Tiramisù

(thick cream)

  • 500g mascarpone
  • 4 eggs
  • 80g sugar

(the original one)

@pioz
pioz / wowpvpstats.rb
Last active January 11, 2022 17:00
Grab some pvp stats in World of Warcraft
require 'net/http'
require 'json'
require 'tty-progressbar'
SPECID_MAP = {
250 => 'Death Knight Blood',
251 => 'Death Knight Frost',
252 => 'Death Knight Unholy',
577 => 'Demon Hunter Havoc',
@pioz
pioz / deep_search.js
Created February 17, 2017 15:16
Deep recursively search object by id from object
const deep_search = (obj, id) => {
if (obj) {
if (obj.constructor === Object) {
if (obj.id === id) {
return obj
} else {
const keys = Object.keys(obj)
for(let i = 0; i < keys.length; i++) {
let r = deep_search(obj[keys[i]], id)
if (r) return r
@pioz
pioz / doc-to-gh-pages
Created July 19, 2017 17:14
Push content of doc directory in master branch to gh-pages branch
#!/bin/bash
set -e
current_dir=$PWD
die() { cd $current_dir; echo $* >&2; exit 1; }
if [ $# != 1 ]; then
die "Usage: $0 REPO_PATH"
@pioz
pioz / rename
Created August 8, 2017 13:29
Rename file in batch
ls * | cat -n | while read i f; do mv "$f" `printf "%04d.${f#*.}" "$i"`; done
ls * | cat -n | while read i f; do mv "$f" `printf "$(basename $f .${f#*.})_%04d.${f#*.}" "$i"`; done
https://stackoverflow.com/a/45569550/302005
@pioz
pioz / string_bench.rb
Last active November 24, 2017 21:22
Benchmark different way to concat strings in Ruby
require 'benchmark/ips'
puts "Ruby #{RUBY_VERSION} at #{Time.now}"
puts
firstname = 'soundarapandian'
middlename = 'rathinasamy'
lastname = 22
Benchmark.ips do |x|
@pioz
pioz / install_elasticsearch_on_ubuntu.md
Created December 20, 2017 08:42
How to install Elasticsearch 6.x on Ubuntu

How to install Elasticsearch on Ubuntu

Install Java 8

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@pioz
pioz / json-rpc.go
Last active January 11, 2022 16:54
Golang json-rpc sample
package main
import (
"errors"
"fmt"
"log"
"net"
"net/rpc"
"net/rpc/jsonrpc"
)
@pioz
pioz / 1000.md
Last active October 21, 2018 13:41
Ricetta Millesfoglie

Millesfoglie di Pioz

Ingredienti

  1. 4 rotoli di pasta sfoglia rotondi

  2. Zucchero a velo per spolverare le sfoglie

  3. Zucchero a velo per la copertura

  4. Bignè da farcire

  5. 6 tuorli d'uovo