This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unicode => human readable format | |
uni_text = u'café' | |
print type(uni_text) | |
print isinstance(uni_text, str) | |
print len(uni_text) | |
uni_str_convert = uni_text.encode('UTF-8') | |
# str => bytes | |
str_text = 'café' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import inspect | |
class TransitionObject(object): | |
""" | |
TransitionObject: | |
Uma classe para ajudar nas passagens de transições em fluxos. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# requirements | |
# pip install unipath | |
# pip install python-decouple | |
from os.path import join | |
from unipath import Path | |
from decouple import config | |
import csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto.s3.connection import S3Connection | |
conn = S3Connection('awskey', 'awssecret') | |
bucket = conn.get_bucket('awsbucket') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v = verbose | |
// a = archive | |
// z = compress | |
// h = progress | |
rsync -vazh --dry-run --partial -e "ssh -p port" /path/to/local/files/ user@111.111.111.111:/path/to/remote/files/ | |
rsync -vazh --dry-run --partial -e "ssh -p port" user@111.111.111.111:/path/to/remote/files/ /path/to/local/files/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from logging.handlers import RotatingFileHandler | |
LOG_FILENAME = "log_name.log" | |
LOG_LEVEL = logging.INFO | |
log = logging.getLogger("Notifier") | |
log.setLevel(LOG_LEVEL) | |
# Add the log message handler to the logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class MyClass(object): | |
error_msgs = { | |
'integer': "This doesn't look like an integer." | |
} | |
def __init__(self, default=0, raise_errors=True): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class NoConnectionException(Exception): | |
def __init__(self, message=None): | |
super(NoConnectionException, self).__init__(message) | |
self.message = 'No connection!' | |