Skip to content

Instantly share code, notes, and snippets.

View rochacbruno's full-sized avatar
🛠️
Working on Galaxy_ng and Dynaconf

Bruno Cesar Rocha rochacbruno

🛠️
Working on Galaxy_ng and Dynaconf
View GitHub Profile
class MyInline(admin.TabularInline):
model = MyModel
extra = 0
template = 'admin/edit_inline/list.html'
def get_formset(self, request, obj=None, **kwargs):
FormSet = super(ActivationKeyInline, self).get_formset(request, obj, **kwargs)
class NewFormSet(FormSet):
def _construct_forms(self, *args, **kwargs):
qs = self.get_queryset()
# coding=utf-8
"""
**Implementa um Webcrawler para extracao de dados da pesquisa de media de precos realizada periodicamente pela ANP**
Desenvolvido por Fabio C. Barrioneuvo da Luz. - 2013
Simple crawler to ANP site
Copyright (C) 2013 Fabio C. Barrioneuvo da Luz.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
"""
Usage:
python jinja2web2py.py jinjatemplate.html > web2pytemplate.html
Disclaimer. It is not perfect. Some times minor manual tweaks may be necessary.
Notice the web2py template language was invented in 2007 and consists of pure Python code.
The opposite conversion is not possible because arbitrary Python code cannot be converted to a jinja template.
"""
import sys
from turtle import *
def drawPython():
begin_fill()
forward(90)
circle(50, 90)
forward(80)
circle(5, 90)
forward(140)
circle(5, 90)
import os
import gearman
from PIL import Image
MINI_SIZE = (50, 50)
THUMB_SIZE = (150, 150)
MOBILE_SIZE = (600, 600)
FULL_SIZE = (1024, 1024)
def quicksort(v):
if len(v) <= 1:
return v
pivot = v[0]
equals = [x for x in v if x == pivot]
smaller = [x for x in v if x < pivot]
higher = [x for x in v if x > pivot]
return quicksort(smaller) + equals + quicksort(higher)
@rochacbruno
rochacbruno / poesia.py
Last active August 29, 2015 14:10 — forked from fmasanori/poesia.py
#traduzido e adaptado de http://blog.trinket.io/writing-poetry-in-python/
from random import choice, randint
adjetivos = '''compreensivo temperamental confiável confiável honesto desonesto
interessante chato carinhoso simpático amigável generoso ciumento invejoso
inseguro ambicioso ansioso bondoso sensato sensível teimoso preguiçoso
trabalhador calmo paciente inteligente esperto espirituoso astuto neurótico
ousado apático cínico sarcástico irônico cético alegre conservador pessimista
otimista tolerante corajoso educado mal-educado determinado sociável
solidário arrogante maldoso desajeitado burro independente confiável dependente
# anyjson
from anyjson import loads
# bunch
from bunch import bunchify
# decimal
from decimal import Decimal
# lxml
@rochacbruno
rochacbruno / bobp-python.md
Created November 8, 2015 13:59 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@rochacbruno
rochacbruno / pypi-release-checklist.md
Created December 16, 2015 17:40 — forked from audreyfeldroy/pypi-release-checklist.md
My PyPI Release Checklist
  • Update HISTORY.rst
  • Commit the changes:
git add HISTORY.rst
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch