Skip to content

Instantly share code, notes, and snippets.

from boto.s3.connection import S3Connection
conn = S3Connection('awskey', 'awssecret')
bucket = conn.get_bucket('awsbucket')
arthuralvim / Vagrantfile
Last active Aug 29, 2015
Playing with Docker.
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
apt-get update
locale-gen en_US en_US.UTF-8 pt_BR pt_BR.utf8 pt_PT.utf8
dpkg-reconfigure locales
apt-get install -y --force-yes curl git
arthuralvim /
Last active Aug 29, 2015
Examples of Provyfile.
# -*- coding: utf-8 -*-
from provy.core import Role
from provy.more.debian import AptitudeRole
from provy.more.debian import NginxRole
from provy.more.debian import SupervisorRole
from provy.more.debian import TornadoRole
from provy.more.debian import UserRole
arthuralvim / breakpoint.less
Last active Aug 29, 2015
Bootstrap 3 Media Queries for Breakpoints.
View breakpoint.less
// Custom Iphone screen (MIN)
@screen-iphone-min: 320px !default;
// Extra small screen / phone (MIN)
@screen-xs-min: 480px !default;
// Small screen / tablet (MIN)
@screen-sm-min: 768px !default;
// Medium screen / desktop (MIN)
@screen-md-min: 992px !default;
// Large screen / wide desktop (MIN)
@screen-lg-min: 1200px !default;
arthuralvim /
Created Aug 28, 2014
Fast check if your SMTP settings are ok.
# Enter python shell
from django.core.mail import EmailMessage
email = EmailMessage('Subject', 'Message', to=[''])
# It should return 1 if everything is ok.
arthuralvim /
Created Sep 7, 2014
[Django Rest Framework] Serializer for a PrimaryKeyRelatedField where we use a unique key instead of the primary key.
class ModelA(models.Model):
attr1 = models.Charfield()
attr2 = models.Charfield(unique=True)
class ModelB(models.Model):
foreign = models.ForeignKey(ModelA)
class OtherFieldUniqueSerializer(serializers.PrimaryKeyRelatedField):
arthuralvim / pre-commit
Created Feb 4, 2015
Git pre-commit hook to check if there's any debugger breakpoint inside your python files.
View pre-commit
pdb_check=$(git grep pdb -- '*.py')
if [ ${#pdb_check} -gt 0 ]
echo "COMMIT REJECTED: commit contains code with break points. Please remove before commiting."
echo $pdb_check
exit 1
echo "Code contains no break points"
arthuralvim /
Last active Aug 29, 2015
Encryption example.
# -*- coding: utf-8 -*-
from Crypto.Cipher import XOR
import base64
import functools
import hashlib
def func_encrypt(key, plaintext):
cipher =
arthuralvim /
Created Feb 24, 2015
Testing Postgres Connection
import psycopg2
import sys
host = ''
dbname = ''
user = ''
password = ''
port = 5432
arthuralvim /
Created Mar 14, 2015
Google Developer Day 2010: Na pacata vila campestre de Ponteironuloville, todos os telefones têm 6 dígitos. A companhia telefônica estabelece as seguintes regras sobre os números: Não pode haver dois dígitos consecutivos idênticos, porque isso é chato; A soma dos dígitos tem que ser par, porque isso é legal; O último dígito não pode ser igual ao…
# -*- coding: utf-8 -*-
from itertools import tee
class ListaTelefones(object):
def __init__(self, lista_de_telefones):
self.telefones = lista_de_telefones.split()
self.telefones_validos = []