Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
arthuralvim / md5deep.sh
Created October 22, 2016 21:28 — forked from deltheil/md5deep.sh
Files and directory comparison with md5deep matching mode (see http://md5deep.sourceforge.net/start-md5deep.html#match).
# Create a reference folder with some data
mkdir foo
echo "hey" > foo/A.txt
echo "scm" > foo/B.txt
echo "git" > foo/C.txt
# Generate the list of hashes for each file
# -b = bare mode (strips any leading directory
# information from displayed filenames)
md5deep -b foo/* > hashes.txt
@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()
@arthuralvim
arthuralvim / flaskapp.py
Created July 18, 2016 10:06
Flask ModelView.
from flask import Flask
import peewee
from flask.ext import admin
from flask.ext.admin.contrib.peewee import ModelView
app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
db = peewee.SqliteDatabase('test.sqlite', check_same_thread=False)
class BaseModel(peewee.Model):
@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 / 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 / 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 / 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 / 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 / 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 / setter_exemplo.py
Created November 23, 2015 11:33
Estudando classes e properties.
# -*- coding: utf-8 -*-
class MyClass(object):
error_msgs = {
'integer': "This doesn't look like an integer."
}
def __init__(self, default=0, raise_errors=True):