Skip to content

Instantly share code, notes, and snippets.

View lorello's full-sized avatar
🏠
Working from home

LoreLLo lorello

🏠
Working from home
View GitHub Profile
@lorello
lorello / purge-old-kernels
Created November 16, 2015 15:43
purge-old-kernels
#!/bin/sh
#
# purge-old-kernels - remove old kernel packages
# Copyright (C) 2012 Dustin Kirkland <kirkland@ubuntu.com>
#
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
# Kees Cook <kees@ubuntu.com>
# Lorenzo Salvadorini <lorello@openweb.it>
#
# This program is free software: you can redistribute it and/or modify
@lorello
lorello / swapping-processes.sh
Created November 18, 2015 11:38
swapping processes
#!/usr/bin/env bash
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`
do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
@lorello
lorello / syncthing-ids.txt
Last active December 12, 2016 23:30
syncthing-ids
rainbowdash DLOQPHP-2DZH5D4-XAG2EV3-24QMXUD-LZCJ76K-MFXYKEM-XLQDFIQ-YLTYIQ5
landi03 A3YHUBY-7HYDSWA-C7L7SLY-QQFPDL2-W3C74ID-BBC6CXD-CWEXOHQ-6JTBNQ2
landi04 RWTPXHR-ELIA43E-XUSFGZB-OTRHLEX-7YUMZSD-7WF3I36-6MVSXHX-7CP4ZAG
tamaki MPEYPUT-ZG2THYP-XJCVBJS-UCKU23C-ZZLVKF2-VLTOYOG-FGEBPNQ-EDFFCQC
maccio Y3IT2C5-Q2AZ3GW-QYRDBKC-FG26Q4R-L5JBWSV-QTN57X6-V35M2CU-UUOGRAL
moto-x 54OMV3J-BXK4XXA-JIF5VLU-F57ARPQ-3GAHQ3E-GLQB53R-Q6NQLUZ-2LROHQJ
batou GJVF6AV-YOWT3JX-GMHIMBO-P5TC67P-JDDHZAC-7D52PAQ-TWP2KLV-C6QWHAA
lucy DAEUL6D-R2BLFW3-5VHX2PQ-6HSENZ2-5WZ2QDE-UIOISPF-R7WXC6Y-J5G6WAO
@lorello
lorello / mysql-rebuild-indexes
Created December 21, 2015 16:08
mysql rebuild indexes
#!/bin/bash
#
# Rebuild indexes on a single table or in a whole database
#
DB=$1
TABLES=$2
function syntax() {
echo -e "\nSYNTAX\n\t$0 <dbname> [\"table1 table2 table3 ...\"]\n\n"
@lorello
lorello / bind-mitingating-denying-hosts.sh
Last active February 9, 2016 13:59
Bind 9 Mitigating DNS based attack using Iptables
#!/bin/bash
#
# Written for an old bind without rate-limiting feature
#
LOG_WINDOW=1000
SECURITY_LOG=/var/log/named/security.log
IPTABLES_CHAIN=INPUT
DENIED_LIMIT=10
@lorello
lorello / svn-repo-infos.sh
Last active February 23, 2016 11:43
SVN Repository Report
#!/bin/bash
#
# Create a simple CSV report with relevant info about
# your old SVN repositories, so you can easly decide
# what archive offline and what migrate to GIT :)
#
REPO_ROOT=/var/svn/
REPOS=$(find $REPO_ROOT -mindepth 1 -maxdepth 1 -type d)
echo "name,size,last commit date,last commit author"
set -e
[ ! -d .git ] && echo "Not a git repo, fatal error" && exit 1
[ ! -d log ] && mkdir log && echo "Create log dir"
if [ ! -f log/.keep ]; then
touch log/.keep
echo "Create log/.keep file"
git add log/.keep
@lorello
lorello / .bash_aliases
Created May 2, 2016 12:36
Ubuntu Two-Lines Prompt with GIT and SVN info
# A two-line colored Bash prompt (PS1) with Git branch and a line decoration
# which adjusts automatically to the width of the terminal.
# Recognizes and shows Git, SVN and Fossil branch/revision.
# Screenshot: http://img194.imageshack.us/img194/2154/twolineprompt.png
# Michal Kottman, 2012
RESET="\[\033[0m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
@lorello
lorello / mysql-master-binlog-purge
Created November 7, 2016 11:09
Mysql utility: purge master binlogs after as soon as slave has received them
#!/bin/bash
#
# This utility is thought to be run on a Mysql Slave and enables you to safely
# purge (delete) binary logs by ensuring that any files which are in use or
# required by the slave in a replication topology are not deleted.
# This is achieved by checking which binary logs have been read on the slave.
# This determines the minimal set of binary log files that can be purged.
#
# Inspired by mysqlbinlogpurge that cannot run on centos 6
# https://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqlbinlogpurge.html

Keybase proof

I hereby claim:

  • I am lorello on github.
  • I am lorello (https://keybase.io/lorello) on keybase.
  • I have a public key whose fingerprint is 3A46 1358 838A 8100 F5AE AC79 1D71 C87F E705 70C9

To claim this, I am signing this object: