Skip to content

Instantly share code, notes, and snippets.

View diofeher's full-sized avatar
🎯
Focusing

Diógenes Fernandes diofeher

🎯
Focusing
View GitHub Profile
@diofeher
diofeher / abstract_factory
Created June 1, 2010 16:22
Abstract Factory Pattern implemented in Python
#!/usr/bin/python
# -*- coding : utf-8 -*-
"""
@author: Diogenes Augusto Fernandes Herminio <[email protected]>
"""
from abc import ABCMeta
#Abstract Factory
class StandardFactory(object):
@diofeher
diofeher / factory_method.py
Created June 1, 2010 15:37
Factory Method implemented in Python
#!/usr/bin/python
# -*- coding : utf-8 -*-
"""
@author: Diogenes Augusto Fernandes Herminio <[email protected]>
"""
# Product
class Churrasco(object):
def __init__(self):
self.fala = None
@diofeher
diofeher / builder_python.py
Created June 1, 2010 12:48
Builder Pattern implemented in Python
#!/usr/bin/python
# -*- coding : utf-8 -*-
"""
@author: Diogenes Augusto Fernandes Herminio <[email protected]>
"""
# Director
class Director(object):
def __init__(self):
self.builder = None
++++++++++[>+++++++>++++++++++>+++++++++++>++++++++++++>+++<<<<<-]>+++.>>>>++.<<<++++++++.>+.+++++++.<-------.>>>.<+.<-------.++++++.>>+.<<<<<+++++++++++.
from django.template.defaultfilters import slugify
def slugify_file_name(filename):
'''
Slugify a file name
Use case:
>>> slugify_file_name('/home/diofeher/R5drgébvśdv_SVSvxpoj x,se.jpg')
u'/home/diofeher/r5drgebvsdv_svsvxpoj-xse.jpg'
'''