Skip to content

Instantly share code, notes, and snippets.

View drAlberT's full-sized avatar

Emiliano 'AlberT' Gabrielli drAlberT

View GitHub Profile
@drAlberT
drAlberT / lambdaAMICleanup.py
Created November 3, 2017 12:17 — forked from bkozora/lambdaAMICleanup.py
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <bobby@kozora.me>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instance. We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
# snapshots associated with that AMI.
@drAlberT
drAlberT / update-docker-compose.sh
Last active September 25, 2020 15:15
Bash script to update docker-compose to the latest release
#!/bin/bash
#
# Updates docker-compose to the latest release
#
# Author: Emiliano Gabrielli <albert@faktiva.com>
DESTINATION_FILE="${DESTINATION_FILE:-$(command -v docker-compose)}"
set -e -o pipefail
@drAlberT
drAlberT / group-by-ip.sql
Created August 17, 2017 10:36 — forked from bennadel/group-by-ip.sql
Grouping The MySQL PROCESSLIST By IP Address To View Connection Counts
SELECT
tmp.ipAddress,
-- Calculate how many connections are being held by this IP address.
COUNT( * ) AS ipAddressCount,
-- For each connection, the TIME column represent how many SECONDS it has been in
-- its current state. Running some aggregates will give us a fuzzy picture of what
-- the connections from this IP address is doing.
FLOOR( AVG( tmp.time ) ) AS timeAVG,
@drAlberT
drAlberT / php-cs-fixer-git-hook.sh
Last active February 28, 2017 09:26
pre-receive / pre-commit git hook for PHP-CS-fixer
#!/bin/bash
FIXER_BIN=$(which php-cs-fixer.phar)
CFG_FILE=".php_cs"
COMMAND="${FIXER_BIN} fix --config=${CFG_FILE} -vvv --path-mode=intersection --dry-run --no-ansi"
TMP_DIR="$(mktemp -d -t CS-FIX.XXXXXXXXX)"
function do_cleanup {
#!/bin/bash
# Shell script to make a locally browseable version of a given URL
#
# @author Emiliano Gabrielli <albert@faktiva.com>
# @license MIT
LC_ALL=C
LANG=C
FONT_DEF=$'\033[0m'
<?php
define('FORCE_HTTPS', true); //set true if you want only https
//@see https://github.com/maxmind/geoip-api-php
define('GI_INCLUDE_PATH', __DIR__.'/includes/geoip');
require_once GI_INCLUDE_PATH.'/geoip.inc.php';
//XXX to be improved
$languages = array('en', 'it', 'de'); //first is default
@drAlberT
drAlberT / drAlberT.md
Last active March 8, 2016 11:12
onename-verify
@drAlberT
drAlberT / CS_ufw.md
Last active March 13, 2024 17:56
UFW Cheatsheet

UFW cheat sheet

Usage

ufw [--dry-run] enable|disable|reload
ufw [--dry-run] default allow|deny|reject [incoming|outgoing]
ufw [--dry-run] logging on|off|LEVEL
    toggle logging. Logged packets use the LOG_KERN syslog facility. Systems configured for rsyslog
#
# /usr/local/bin/listAliasByDomain
#
# Lists all aliases for mailboxes and distribution lists associated with a particular domain
#
# Syntax: listAliasByDomain someMailDomain.com
#
# The settings for the LDAP queries are guesses. They work for me, but if I have overlooked
# something, please let me know!
#
@drAlberT
drAlberT / CS_git-commands-reference.md
Last active December 16, 2017 15:55
Git / GitHub CheatSheet

Git / GitHub CheatSheet

Quick reference for git / GitHub daily workflow

Git

create branches

  • create the local branch