Skip to content

Instantly share code, notes, and snippets.

iMil iMilnb

Block or report user

Report or block iMilnb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
iMilnb /
Created Aug 28, 2015
Automatic SpamCop report validation with python mechanize
import mechanize
br = mechanize.Browser()
iMilnb /
Created Aug 2, 2015
Basic Flask snippet to handle AWS SNS messages and subscription
from flask import Flask, request
import requests
import json
app = Flask(__name__)
def msg_process(msg, tstamp):
js = json.loads(msg)
msg = 'Region: {0} / Alarm: {1}'.format(
js['Region'], js['AlarmName']
iMilnb /
Last active Mar 3, 2020
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
iMilnb /
Last active Oct 11, 2016
Transform Debian Jessie AMI to `sysvinit`
# Simply add the following to the Userdata script so the
# instance bootstrap sequence transforms the debian jessie
# systemd init to good old sysvinit.
# initial method from
# but using a safer and actually working `cat ><<EOF` method
apt-get -y install sysvinit-core sysvinit sysvinit-utils
apt-get remove --purge --auto-remove systemd
cat >/etc/apt/preferences.d/systemd<<EOF
Package: systemd
iMilnb / grub_default_kernel
Last active Aug 29, 2015
Change the default boot kernel with `grub` 2.0.2beta
View grub_default_kernel
dpkg -i linux-image-${mykern}_amd64.deb
sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
UUID=`blkid -s UUID -o value /dev/xvda1`
grub-set-default "gnulinux-advanced-$UUID>gnulinux-$mykern-advanced-$UUID"
iMilnb / gist:ba7b46dfc854544bf3c8
Last active Sep 4, 2018
Dynamic ipsec and racoon configuration generation for AWS EC2 VPN using boto3 and Jinja2
View gist:ba7b46dfc854544bf3c8
#!/usr/bin/env python
# $ cat ipsec_conf.tmpl
# {#
# cgw_in_addr: customer_gateway tunnel_inside_address ip_address
# cgw_in_cidr: customer_gateway tunnel_inside_address network_cidr
# vgw_in_addr: vpn_gateway tunnel_inside_address ip_address
# vgw_in_cidr: vpn_gateway tunnel_inside_address network_cidr
# cgw_out_addr: customer_gateway tunnel_outside_address
iMilnb /
Last active Jun 16, 2018
Dynamic Troposphere + boto3 template that creates a complete and functional VPC through AWS CloudFormation
#!/usr/bin/env python
from troposphere import Join, Output
from troposphere import Parameter, Ref, Tags, Template
from troposphere.ec2 import PortRange
from troposphere.ec2 import NetworkAcl
from troposphere.ec2 import Route
from troposphere.ec2 import VPCGatewayAttachment
from troposphere.ec2 import SubnetRouteTableAssociation
from troposphere.ec2 import Subnet
iMilnb /
Created May 27, 2015
AWS EC2 simple manipulation script using python and boto3
#!/usr/bin/env python
# Simple [boto3]( based EC2 manipulation tool
# To start an instance, create a yaml file with the following format:
# frankfurt:
# - subnet-azb:
# - type: t2.micro
# image: image-tagname
iMilnb / gist:b09f45e112b226b97a36
Last active Dec 4, 2017
Minimalistic jinja2-based page generator
View gist:b09f45e112b226b97a36
import sys
import markdown
import yaml
import os
from jinja2 import Environment, FileSystemLoader
with open(sys.argv[2], 'r') as f:
content = yaml.safe_load(
for k in content:
iMilnb / gist:7604f04223d44a3e13af
Last active Aug 29, 2015
Keep track of Twitter "unfollowers"
View gist:7604f04223d44a3e13af
# track unfollows on twitter using "t"
# usage:
# to check if any of your followers has stopped following you since the last
# time the script wall called, use:
# $ this_script followers
# to check if YOU stopped following someone (it appears many of us witnessed
You can’t perform that action at this time.