Skip to content

Instantly share code, notes, and snippets.

View arruda's full-sized avatar

Felipe Arruda Pontes arruda

View GitHub Profile
@arruda
arruda / simple_awk.sh
Created December 6, 2012 21:15
AOU aula 2
grep labccet /etc/passwd | awk -F: '{print $7}'
@arruda
arruda / polls_tags.py
Created December 6, 2012 00:28
Django – Simple Template Tag Without a String as Argument
#-*- coding:utf-8 -*-
from django import template
register = template.Library()
from polls.models import Poll
@register.simple_tag(takes_context=True)
def get_userInfo_for_poll(context,poll, user):
context['userInfo'] = poll.getUserInfo(user)
return ''
@arruda
arruda / ping_pong.py
Created December 5, 2012 15:22
Desafio Ping Pong
#!/usr/bin/python
NUM_MAXIMO = 100
for i in xrange(1,NUM_MAXIMO+1):
if not i % 3 is 0 and not i % 5 is 0:
print i
else:
if i % 3 is 0:
print "ping"
@arruda
arruda / Foca no código
Created August 28, 2012 18:33 — forked from zenorocha/Foca no código
Foca no código
/* Véi, foca no código
.---.
/o o\
__(= " =)__
//\'-=-'/\\
) (_
/ `"=-._
/ \ ``"=.
@arruda
arruda / trac-post-receive-hook-0.12-new-commits-from-all-branches-with-logfile.py
Created August 17, 2012 16:54
trac-post-receive-hook-0.12-new-commits-from-all-branches-with-logfile.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Grzegorz Sobański
# 2012 Juan Fernando Jaramillo
#
# Version: 2.1
#
# - adds the commits to trac
# based on post-receive-email from git-contrib
@arruda
arruda / api.js
Created June 4, 2012 21:34 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@arruda
arruda / fabric.py
Created May 27, 2012 16:40
Django - Models e métodos dinâmicos usando "templates"
def model_factory(name,desc,field):
"""Fabricates a model with the given name, using MODEL_TEMPLATE as reference.
"""
format_dict = {
'CLASS_NAME' : name.capitalize(),
'CLASS_DESC' : desc,
'FIELD_NAME' : field,
}
@arruda
arruda / profile_middleware.py
Created April 24, 2012 13:00 — forked from kesor/profile_middleware.py
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG:
@arruda
arruda / broker.sh
Created April 9, 2012 13:45
Django-Celery In Daemon
sudo apt-get install rabbitmq-server
@arruda
arruda / my_formfield_utils.py
Created February 6, 2012 20:39
Adicionando um widget no seu formfield, usando inlineformset_factory
from django.db import models
def my_nice_formfield_callback(f):
formfield = f.formfield()
if isinstance(f, models.FileField):
formfield.widget = NoFullPathLinkFileInput()
return formfield