Skip to content

Instantly share code, notes, and snippets.

@rennerocha
rennerocha / config.ini
Created January 10, 2012 18:40
Manipulação de arquivos INI com Python
[database]
host = localhost
dbname = example
port = 1234
user = admin
password = secret
[repository]
type = git
url = [email protected]:user/project.git
@rennerocha
rennerocha / README
Created May 3, 2012 20:01
Custom django-admin command that prints the CREATE TABLE SQL statements for all installed apps.
== Instructions ==
https://docs.djangoproject.com/en/1.4/howto/custom-management-commands/
Commands:
- python manage.py sqlproject
- python manage.py sqlallproject
@rennerocha
rennerocha / requirements
Created November 30, 2012 00:54
Requirements for testing flask-login extension
Flask==0.9
Flask-Login==0.1.3
Jinja2==2.6
Werkzeug==0.8.3
import string
def holes(letter):
holes_input = string.ascii_letters
holes_output = "1101101000000011100000000012010000000000111100000000"
holes_table = maketrans(holes_input, holes_output)
return int(letter.translate(holes_table))
def count_holes(text):
text = text.replace(' ', '') # Ignore spaces
@rennerocha
rennerocha / email_lhc
Last active December 27, 2015 13:49
E-mail para lista do LHC pedindo $$$ para nova sede
Após dois anos em apertados 15m², o LHC pretende ir para uma casa maior!
Com mais espaço, a diversidade de atividades tende a crescer. Com mais
espaço, passamos a ter uma área de convívio com tendências a
virar a segunda casa de muita gente.
[outros hackerspaces animais.jpg]
Pesquisamos várias casas na região de Campinas e encontramos uma que
serviu como uma luva! De fácil acesso por transporte público e situada
@rennerocha
rennerocha / ics_lhc.py
Last active August 29, 2015 13:56
ics calendar for LHC
# -*- coding: utf-8 -*-
from datetime import datetime
from icalendar import Calendar, Event
import json
import os
import urllib2
if __name__ == '__main__':
LHC_ICS_FILE = '/home/hscps/hsc.tia.mat.br/lhc.ics'
@rennerocha
rennerocha / cartao_itau_moneylog.py
Created April 9, 2014 14:45
conversor cartão itau para moneylog
#!/usr/env/python
import re
import sys
def read_credit_card_data(purchases_file, year, tags=None):
with open(purchases_file, 'r') as purchases_data:
purchases = purchases_data.readlines()
@rennerocha
rennerocha / packtpub.py
Created March 30, 2017 10:39
Check today's free ebook from Packpub
import datetime
import os
import re
import socket
import Tkinter as Tk
import urllib2
import webbrowser
FREE_EBOOK_URL = 'https://www.packtpub.com/packt/offers/free-learning'
@rennerocha
rennerocha / packtpub_free_ebook.py
Created March 30, 2017 10:59
Return name of today's free ebook of Packtpub
import datetime
import re
import urllib2
def today_packtpub_free_ebook():
FREE_EBOOK_URL = 'https://www.packtpub.com/packt/offers/free-learning'
try:
request = urllib2.Request(FREE_EBOOK_URL)
response = urllib2.urlopen(request)
except:
@rennerocha
rennerocha / flatten.py
Created June 29, 2017 13:21
Citrusbyte - Array flatten function
def recursive_flatten(nested):
"""Return a flatten array from an arbitrarily nested array of integers
This function is recursive so it could not be used with lists with high
levels of nesting to avoid recursion errors
>>> recursive_flatten([])
[]
>>> recursive_flatten([1, 2, 3])