Skip to content

Instantly share code, notes, and snippets.

View diofeher's full-sized avatar
🎯
Focusing

Diógenes Fernandes diofeher

🎯
Focusing
View GitHub Profile
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'
'''
++++++++++[>+++++++>++++++++++>+++++++++++>++++++++++++>+++<<<<<-]>+++.>>>>++.<<<++++++++.>+.+++++++.<-------.>>>.<+.<-------.++++++.>>+.<<<<<+++++++++++.
#include<stdio.h>
int main() {
unsigned long int a, b;
while(scanf("%lu %lu", &a, &b)==2) {
if (a > b){
printf("%lu\n", a - b);
}
else {
printf("%lu\n", b - a);
@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 <diofeher@gmail.com>
"""
# Director
class Director(object):
def __init__(self):
self.builder = None
@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 <diofeher@gmail.com>
"""
# Product
class Churrasco(object):
def __init__(self):
self.fala = None
@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 <diofeher@gmail.com>
"""
from abc import ABCMeta
#Abstract Factory
class StandardFactory(object):
@diofeher
diofeher / games
Created September 26, 2010 17:38
Jogos que já zerei:
* SNES
- Biker Mace From Mars
- The Legend of Zelda
* Mega Driver
* PS1
Movies:
Resident Evil
Hot Tube Time Machine
#coding:utf-8
class Desktop(object):
"""
Computador novinho, ainda está todo embalado.
"""
def __init__(self, preco):
self.preco = preco or 'a combinar'
self.monitor = 'Monitor AOC Widescreen 19'' 912Vwa'
self.cpu = 'Daten'
self.extras = {'mouse':True, 'mousepad': True, 'teclado': True}
diofeher$ brew install -vd pango --config
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2
==> Downloading http://ftp.gnome.org/pub/GNOME/sources/pango/1.28/pango-1.28.1.tar.bz2
File already downloaded and cached to /Users/diofeher/Library/Caches/Homebrew