Skip to content

Instantly share code, notes, and snippets.

View giuliocalzolari's full-sized avatar

Giulio Calzolari giuliocalzolari

View GitHub Profile
@giuliocalzolari
giuliocalzolari / install_openldap.sh
Last active August 29, 2015 14:23
CentOS OpenLDAP + Webmin
#!/bin/bash
## OpenLDAP simple installation script. As tested on CentOS 6.3
## This script must be run as root
#http://blog.secaserver.com/2013/01/centos-install-openldap-webmin-simple-way/
hostname=`hostname`
echo "==========================================================="
echo " This script will install OpenLDAP"
echo "It assumes that there is no OpenLDAP installed in this host"
@giuliocalzolari
giuliocalzolari / git-remote-check.sh
Created June 24, 2015 14:12
in case of new commit you can execute multiple action
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --quiet --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
// createSnapshots - Create snapshots from a list of volumes
// Include the AWS SDK and set the region
var AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';
// New EC2 object
var ec2 = new AWS.EC2();
// Build a YYYYMMDD formatted current date string
var now = new Date();
@giuliocalzolari
giuliocalzolari / multiple_knife.rb
Created July 20, 2015 15:12
Multiple Knife configuration
# adaptive knife.rb
def colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
def red(text); colorize(text, 31); end
def green(text); colorize(text, 32); end
PIDFILE="/var/run/puppet-sync.pid"
TMPFLD="/usr/src/puppet_local_repo"
DEPLOYTMPFLD="/etc/puppet"
removePID () {
rm -rf $PIDFILE
}
@giuliocalzolari
giuliocalzolari / dd.log
Created October 11, 2016 11:36 — forked from ktheory/dd.log
EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge
# /tmp/test = EBS-SSD
# /mnt/test = instance-store
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 3.26957 s, 82.1 MB/s
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
@giuliocalzolari
giuliocalzolari / s3-to-es-lambda.py
Last active January 27, 2021 18:25
S3 Logs to Elasticsearch
##################################################
### Elasticsearch host name
ES_HOST = "search-******************.ap-northeast-1.es.amazonaws.com"
### Elasticsearch prefix for index name
INDEX_PREFIX = "elb_log"
### ELB name for type name
ELB_NAME = "*****"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:DescribeClassicLinkInstances",
"ec2:DescribeCustomerGateways",
"ec2:DescribeDhcpOptions",
@giuliocalzolari
giuliocalzolari / sg-query.py
Created February 6, 2018 17:03
AWS SG Query
import boto3
def find_public_addresses(ec2):
public_instances = {}
instance_public_ips = {}
instance_private_ips = {}
instance_ident = {}
instances = ec2.instances.filter(Filters=[{'Name': 'instance-state-name', 'Values': ['running'] }])
# Ranges that you define as public subnets in AWS go here.