Skip to content

Instantly share code, notes, and snippets.

View Gabriellpweb's full-sized avatar
🎯
Focusing

Gabriel Gabriellpweb

🎯
Focusing
  • Dublin, Ireland
View GitHub Profile
@Gabriellpweb
Gabriellpweb / from2
Created February 19, 2016 18:02
Copy a list of files to a list of possible files that filename matches with 75% of assert rate.
#!/usr/bin/env python
from __future__ import print_function
import math
import difflib
import shutil
import os.path
recovered = 'tofiles.txt'
original = 'fromfiles.txt'
/^\[(?<time>[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+)\] (?<type>[^\.]*).(?<level>[^:]*): (?<message>.*)$/
@Gabriellpweb
Gabriellpweb / AWS_EC2_WWW_SYNC.sh
Last active March 24, 2016 17:24
Sync a ec2 instance inside a specific load balancer.
#!/bin/sh
# SCRIPT REQUIRE NGINX PERMISSIONS ON SYNC_PATH AND SSH ACCESS TO MACHINES.
ELB_NAME=MY_ELB_NAME
LIST_FILE=/tmp/instance_list_$(date +%Y%m%d%H%M%S).txt
LOG_FILE=/tmp/instance_sync_$(date +%Y%m%d%H%M%S).log
SYNC_PATH=/var/www
SEND_ALERT="aws sns publish --topic-arn MY_SNS_TOPIC --message"
@Gabriellpweb
Gabriellpweb / Documentation.md
Created March 28, 2016 17:58 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
#!/bin/sh
SUPERVISOR_INITD="/etc/init.d/supervisord"
SUPERVISOR_LOGDIR="/var/log/supervisord"
echo "Running install..."
easy_install supervisor;
mkdir -p /etc/supervisor/conf.d;
touch /etc/supervisor/supervisord.conf;
@Gabriellpweb
Gabriellpweb / csvcrypto.py
Last active October 27, 2017 19:06
Crypt and decrypt a csv file
#!/usr/bin/python
"""Crypt and decrypt a csv file content"""
import csv
import sys
import Crypto.Random
from Crypto.Cipher import AES
import hashlib
import base64
@Gabriellpweb
Gabriellpweb / B64Cypher.py
Created November 23, 2017 19:16
B64Cypher
#!/usr/bin/python
__author__ = "Gabriel Luiz Pereira <gabriel.pereira@rentcars.com>"
from base64 import b64encode, b64decode
class B64Cypher:
def __init__(self, salt, iterations):
self.salt = salt
self.iterations = range(0, iterations)
def encode(self, text):
@Gabriellpweb
Gabriellpweb / rdsls.sh
Created May 4, 2018 16:48
List AWS RDS Instances
#!/bin/bash
# USAGE: rdsls sa-east-1
# OUTPUT:
# Name |Engine |Ec2Type |CreatedAt
# myrdsdb |postgres@9.6.6 |db.t2.micro |2017-09-20T18:54:21.212Zs
aws --region $1 rds describe-db-instances \
| jq '.DBInstances[] | "\(.DBInstanceIdentifier) \(.Engine)@\(.EngineVersion) \(.DBInstanceClass) \(.InstanceCreateTime)"' \
| column -t -N 'Name,Engine,Ec2Type,CreatedAt' -o ' |' \
| sed -e 's/\"/\s/g'
@Gabriellpweb
Gabriellpweb / route53ls.sh
Last active May 4, 2018 17:08
List Route53 hosted zones
#!/bin/bash
# USAGE: route53ls
#
# OUTPUTS:
#
# Id |Domain |Records
# s/hostedzone/XXXXXXXXXXXXXX |mywebsite.com |5s
@Gabriellpweb
Gabriellpweb / route53subls.sh
Created May 4, 2018 20:36
List hosted zones and subdomains of route53
#!/bin/bash
# USAGE: route53subls
#
# OUTPUT:
#
# Domain |SubDomain |RecordType|RecordValue
# website.com. |sub.website.com. |A |dualstack.websitealb-12345678998.sa-east-1.elb.amazonaws.com.
#