Skip to content

Instantly share code, notes, and snippets.

View igorrs's full-sized avatar

Igor Ribeiro Sucupira igorrs

View GitHub Profile
@igorrs
igorrs / aws_instance_types.rb
Last active October 24, 2019 16:25
Dump AWS RDS and EC2 instance types to CSV files
#!/usr/bin/env ruby
# Install dependencies with:
# gem install aws-sdk-rds aws-sdk-ec2
require 'aws-sdk-rds'
require 'aws-sdk-ec2'
require 'csv'
aws_regions = %w[us-east-1 us-east-2 us-west-1 us-west-2 sa-east-1]
@igorrs
igorrs / probability_of_collision.rb
Created September 19, 2019 15:50
Probability of collision after generating k random base-32 numbers with x digits
def probability_of_collision(k, x)
total_numbers = 32**x
1 - Math::E**(((k-1)*-k) / (2.0*total_numbers))
end
# Example
probability_of_collision(100000, 8)
@igorrs
igorrs / cfn-template-dump.rb
Last active April 8, 2016 23:41 — forked from gabriellett/cfn-template-dump.rb
AWS CloudFormation Template dumper
# This script will look for cloudformation stacks on your account and download all the templates for you!
# Author: Gabriel Lett Viviani <http://github.com/gabriellett>
# Make sure you have aws-cli installed and configured on your machine,.
require 'json'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: cfn-template-dump.rb [options]"
@igorrs
igorrs / gtk-redshift.sh
Created March 11, 2014 05:41
If gtk-redshift crashes at Unity's startup because no network connection is available, you can start it with this script instead, to keep trying every 10 seconds until it succeeds.
#!/usr/bin/env bash
while true; do
pgrep redshift && exit # Already running.
gtk-redshift
# Died? Check again after 10 seconds.
sleep 10
done