Skip to content

Instantly share code, notes, and snippets.

View leonardobiffi's full-sized avatar
💭
working... ☕

Leonardo Biffi leonardobiffi

💭
working... ☕
View GitHub Profile
#!/usr/bin/env bash
echo ">> Current kernels:"
rpm -qa kernel-core
old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q))
if [ "${#old_kernels[@]}" -eq 0 ]; then
echo "No old kernels found"
exit 0
fi
#! /bin/bash
# Usage: ./export-records-terraform.sh <zone_name>
# Example: ./export-records-terraform.sh example.com
# Dependencies: jq, aws-cli
# This script retrieves all DNS records from AWS Route53 DNS zone
# and format file compatible with Terraform Module
# https://github.com/terraform-aws-modules/terraform-aws-route53/blob/master/examples/complete/main.tf
@leonardobiffi
leonardobiffi / getenv.sh
Created July 25, 2024 16:43
Get AWS Secrets Manager or Parameter by name
#!/bin/bash
# Default variable values
type=""
name=""
region=""
# Function to display script usage
usage() {
echo "Usage: $0 [OPTIONS]"
@leonardobiffi
leonardobiffi / drop-table.sh
Created February 23, 2024 16:46
MySQL drop all tables in database
#!/bin/bash
USER="$1"
PASS="$2"
DB="$3"
HOST="$4"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
GREP=$(which grep)
@leonardobiffi
leonardobiffi / delete_vpc.sh
Created January 23, 2024 20:40
Script to delete AWS default VPCs from regions using AWS CLI
#!/usr/bin/env bash
REGIONS='us-east-1
us-east-2'
INDENT=' '
echo "Using profile $AWS_PROFILE"
for region in $REGIONS; do
@leonardobiffi
leonardobiffi / Remove all git tags
Created July 12, 2022 11:59 — forked from okunishinishi/Remove all git tags
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@leonardobiffi
leonardobiffi / redis_migrate.py
Created September 14, 2021 17:04 — forked from josegonzalez/redis_migrate.py
A simple script to migrate all keys from one Redis to another
#!/usr/bin/env python
import argparse
import redis
def connect_redis(conn_dict):
conn = redis.StrictRedis(host=conn_dict['host'],
port=conn_dict['port'],
db=conn_dict['db'])
return conn
@leonardobiffi
leonardobiffi / Makefile
Created November 18, 2020 17:37 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@leonardobiffi
leonardobiffi / checkSession.php
Last active October 14, 2020 14:26 — forked from lukas-buergi/checkSession.php
Check whether sessions work in php
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1);
if(!isset($_GET['action'])){
die('Param is missing. Look at the <a href="https://gist.github.com/2995743">source</a>.');
}
switch($_GET['action']) {
@leonardobiffi
leonardobiffi / function.py
Created February 10, 2020 13:46 — forked from brandond/function.py
Python script to auto-tag AWS EBS Snapshots and Volumes using AMI and Instance tags
import copy
import logging
import os
import boto3
logging.basicConfig(level=os.environ.get('LOG_LEVEL', 'INFO'))
ec2 = boto3.client('ec2')
logger = logging.getLogger(__name__)