Skip to content

Instantly share code, notes, and snippets.

View igorlg's full-sized avatar

Igor Gentil igorlg

View GitHub Profile
@igorlg
igorlg / aws_tags.rb
Last active June 6, 2016 08:16
Facter for AWS EC2 Instance Tags
require 'open-uri'
require 'aws-sdk-core'
def aws_metadata(path)
return open("http://169.254.169.254/latest/meta-data/#{path}").read.split("\n")[0]
end
Aws.config[:region] = aws_metadata('placement/availability-zone')[0..-2]
Aws.config[:credentials] = Aws::InstanceProfileCredentials.new
ec2 = Aws::EC2::Client.new
@igorlg
igorlg / README.md
Created September 30, 2016 00:26
Simple Python Code Challenge

QUESTION

Write a function that, given an input array of integers and a desired target_sum, returns the number of combinations, of any length, that add up to that target_sum.

Keybase proof

I hereby claim:

  • I am igorlg on github.
  • I am igorlg (https://keybase.io/igorlg) on keybase.
  • I have a public key ASDKo31X3pr6syAi9zz3oFyns-h0nk9evecYBjpm_dtaWwo

To claim this, I am signing this object:

@igorlg
igorlg / vpc-nat-ha.json
Last active April 20, 2017 18:58
AWS CloudFormation VPC Templates
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template for a VPC with High Availability NAT for ECS",
"Parameters": {
"NATInstanceType": {
"Description": "NAT instance type",
"Type": "String",
"Default": "t2.micro",
"AllowedValues": [
"t2.micro",
@igorlg
igorlg / days.py
Created June 27, 2017 23:08
Show number of each weekday in a year
from datetime import datetime, timedelta
from tabulate import tabulate
from calendar import day_name
import sys
def wd(d):
return list(day_name)[d]
def sorted_week():
return sorted([(j+1)%7 for j in range(7)], key=lambda n: (n+1)%7)
@igorlg
igorlg / Gemfile
Created July 28, 2017 03:06
Small ruby script to print the Profiles from ~/.aws/config
source 'https://rubygems.org'
gem 'colorize'
gem 'inifile'
@igorlg
igorlg / README.md
Last active July 31, 2017 01:44
List AWS AZs and Regions

Required Gems

  • aws-sdk
  • terminal-table

Install: gem install aws-sdk terminal-table

Usage

Run ruby awsazs-update.rb to generate the JSON file.

Run ruby awsazs.rb to see the output:

@igorlg
igorlg / ecs-autoscaing.json
Created June 12, 2015 21:54
AWS CloudFormation template for ECS AutoScaling Group
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template for a VPC with High Availability NAT for ECS",
"Parameters": {
"ClusterName": {
"Description": "The ECS Cluster Name",
"Type": "String"
},
"InstanceType": {
"Description": "NAT instance type",
@igorlg
igorlg / README.md
Created September 13, 2018 03:27
Build VLC on Raspiberry Pi with Hardware Acceleration
@igorlg
igorlg / README.md
Created November 2, 2018 00:58
CloudWatch Dasboard for EC2/EBS

Creates a basic CloudWatch Dashboard for an EC2 instance and it's EBS volumes.

usage: cw_dashboard_ec2.py [-h] [--dashboard_name DASHBOARD_NAME]
                           [--skip_devices [SKIP_DEVICES [SKIP_DEVICES ...]]]
                           [--volume_group VOLUME_GROUP]
                           [--aws_profile AWS_PROFILE] [--dump]
                           instance_id

Generate a CloudWatch Dashboard for an EC2 Instance