Skip to content

Instantly share code, notes, and snippets.

View arthuralvim's full-sized avatar

Arthur Alvim arthuralvim

View GitHub Profile
@arthuralvim
arthuralvim / gen.py
Created January 3, 2014 18:49
Simple script to generate passwords.
import random
import string
def gen_pass(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in range(size))
@arthuralvim
arthuralvim / saving_my_neck.ssh
Created January 12, 2014 20:10
I have accidentally deleted some .py untracked files. For my luck I found this project (https://github.com/wibiti/uncompyle2).
git clone git@github.com:wibiti/uncompyle2.git
cd uncompyle2/
python setup.py install
uncompyler2 thank_goodness_this_still_exists.pyc > recovered_file.py
@arthuralvim
arthuralvim / color-table.sh
Created January 17, 2016 15:00
Generates an 8 bit color table (256 colors) for reference purposes.
#!/bin/bash
# Generates an 8 bit color table (256 colors) for
# reference purposes.
# credits for Michael.
# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux
function boxcolor {
printf "\033[48;5;$1m \033[m "
@arthuralvim
arthuralvim / copa_crocovix.py
Last active January 22, 2016 17:23
Sorteio dos integrantes da Copa Crocovix de Futebol de Vídeo Game.
# -*- coding: utf-8 -*-
from random import shuffle
from random import sample
def sortear_partidas(duplas):
while duplas:
dupla = sample(duplas, 2)
print dupla[0], 'x========x', dupla[1]
@arthuralvim
arthuralvim / human.py
Created February 23, 2016 06:58
Studying mock objects in Python.
# -*- coding: utf-8 -*-
class NoConnectionException(Exception):
def __init__(self, message=None):
super(NoConnectionException, self).__init__(message)
self.message = 'No connection!'
@arthuralvim
arthuralvim / guia-etl.md
Last active April 18, 2016 14:06
Falando sobre ETL...

Tópicos Importantes sobre Boas Ferramentas de ETL

  1. Conectividade com os dados

Permitir que seja possível acoplar/conectar com qualquer fonte de dados seja ela um banco de dados relacional, não relacional, uma planilha ou um webservice.

  1. Performance

Processos de Extração, Transformação e Carga costumam demorar bastante devido ao poder de processamento e I/O demandados.

@arthuralvim
arthuralvim / shell-tests.md
Last active June 14, 2016 23:14
Shell testing.

Check if $var is set using ! i.e. check if expr is false

[ ! -z "$var" ] || echo "Empty" [ ! -z "$var" ] && echo "Not empty" || echo "Empty"

[[ ! -z "$var" ]] || echo "Empty" [[ ! -z "$var" ]] && echo "Not empty" || echo "Empty"

====== The classic test command ======

@arthuralvim
arthuralvim / docker.sh
Created June 25, 2016 01:01
Docker aliases and functions to work at zsh.
# docker
alias doco='docker-compose'
alias doma='docker-machine'
alias doenv='printenv | grep DOCKER'
alias doim='docker images'
alias dorm='docker rm'
alias dohosts='doma ls --format "{{.Name}} {{.Active}}"'
alias domals='doma ls'
alias dormi='docker rmi'
@arthuralvim
arthuralvim / Bibtex.sublime-build
Created June 1, 2012 15:13
Sublime Text 2 - build commands for bibtex and clean auxiliary files
// It's saved under path_to_Packages/User/
{
"cmd": ["bibtex", "$file_base_name"],
"path": "$PATH:/usr/texbin:/usr/local/bin",
"file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
"selector": "text.tex.latex"
}
@arthuralvim
arthuralvim / date_manipulation.py
Created August 2, 2016 11:53
Basic datetime manipulation in Python.
# -*- coding: utf-8 -*-
import datetime
from pytz import timezone
from pytz import utc
fmt = '%d/%m/%Y %H:%M:%S %Z'
date_utc_now = datetime.datetime.utcnow()