Skip to content

Instantly share code, notes, and snippets.

View augustomen's full-sized avatar

Augusto Men augustomen

  • Canada
View GitHub Profile
@augustomen
augustomen / makeword.py
Created February 10, 2016 21:57
Gerador de palavra aleatória
import random
consonants = 'bcdfghjlmnpqrstvxz'
vowels = 'aeiou'
def new_word(syllables=None):
if syllables is None:
syllables = random.randint(2, 5)
result = ''
for i in range(syllables):
@augustomen
augustomen / README.md
Last active October 21, 2015 18:56
SQLite3 to MySQL dump converter

Usage:

sqlite3 <sqlite3_filename> .dump | sqlite3-to-mysql.py | mysql <params>

or

sqlite3 <sqlite3_filename> .sch | sqlite3-to-mysql.py | mysql <params>
@augustomen
augustomen / templatetree.py
Created October 20, 2014 18:07
templatetree - builds a inheritance tree of all templates in a Django project or folder
# coding: utf-8
__author__ = "Augusto Men"
__version__ = "$Revision: 0.1 $"
__date__ = "$Date: 2014/09/29 $"
DESCRIPTION = """Builds a tree of template files based on inheritance."""
import os
import re
@augustomen
augustomen / gist:6765090
Created September 30, 2013 15:01
get_template_block() - returns a part of a template
from django.template import loader, loader_tags
def get_template_block(template_name, block_name):
"""Searchs a returns a single block inside a template.
Useful for ajax reloading inside a template.
- template_name can be a filename or a list of filenames.
- block_name is the name of the block to look for:
{% block block_name %}
This function returns a BlockNode instance, which can be rendered to
@augustomen
augustomen / lookups.py
Last active December 11, 2015 02:39
WordModelLookup: a Django Selectable lookup that searches anywhere in the field
import operator
from django.db.models import Q
from selectable.base import LookupBase, ModelLookup
# if term is 'foo - bar', the middle '-' is ignored
SEARCH_IGNORED = (',', '.', '-', '/', ';', ':', '=', '\\',)
def split_terms(get_query):
""" This decorator breaks a single string received in the request by a
list of strings.