Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2
# encoding: utf-8
import subprocess
def __get_output(command):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
output = process.communicate()
retcode = process.poll()
if retcode == 0:
#!/usr/bin/env python2
# encoding: utf-8
class singledispatch(object):
__slots__ = (
'resolver',
'default',
'last',
)
def __init__(self, func):
#!/usr/bin/env python
# encoding: utf-8
import cProfile
class singledispatch(object):
__slots__ = (
'resolver',
'default',
'last',
@magnunleno
magnunleno / geraCPF.py
Created July 29, 2013 22:45
Gerador de CPF para ser utilizado em bases de teste :)
#!/usr/bin/env python
# encoding: utf-8
import sys
from random import random
def geraCPF():
cpf = []
for i in range(9):
cpf.append(int(random()*10))
{{extend 'layout.html'}}
<h1>Clientes</h1>
<div id='contents'>
<table class="table">
<tr>
<th>ID</th>
<th>Cliente</th>
@magnunleno
magnunleno / hex-cairo.py
Last active December 25, 2015 03:09
Script that draws Hexagons with Python and Cairo
#!/usr/bin/env python
# encoding: utf-8
import cairo
import rsvg
import math
WIDTH, HEIGHT = (500, 500)
HEX_W, HEX_H = (50, 50)
#!/usr/bin/env python2
# encoding: utf-8
# Decoding: https://twitter.com/diegoboot/status/510846108973953024
bins = [
'01001000', '01100001', '01110000',
'01110000', '01111001', '00100000',
'01010000', '01110010', '01101111',
'01100111', '01110010', '01100001',
@magnunleno
magnunleno / python.vim
Created August 4, 2015 18:07
VIM's Python syntax customizations
" Match (only 'bar') in function calls like: 'foo.bar()' or 'bar()'
syn match pythonFunction /\(^\s*\(def\|class\)\s*\w*\)\@<!\w\{1,}\ze(/
" Match dunder methods/attributes
syn match pythonBuiltin "__\w*__"
" Match under methods/attributes
syn match pythonIdentifier "_\w*_"
" Match self (not in function declarations)
syn match pythonFunction /\(^\s*def \s*\w*\s*(\)\@<!self/
" Match self in function declarations
syn match pythonIgnore /\(^\s*def \s*\w*\s*(\)\@<=self\ze\s*[,)]/
@magnunleno
magnunleno / brogrammer-plus.vim
Created August 5, 2015 00:56
Brogrammer+ VIM Colorscheme
runtime colors/brogrammer.vim
let g:colors_name = "brogrammer+"
" Fix NonText (tab, CR and etc)
hi NonText ctermfg=22 ctermbg=234 cterm=NONE guifg=#30312a guibg=#1a1a1a gui=NONE
" Makes the Line Number color closer to the default BG
hi LineNr term=underline ctermfg=244 ctermbg=236 guifg=#838586 guibg=#232323
" Makes the current line number highlight changes only the FG