Skip to content

Instantly share code, notes, and snippets.

View arruda's full-sized avatar

Felipe Arruda Pontes arruda

View GitHub Profile
@TheNicholasNick
TheNicholasNick / relax.js
Created April 2, 2009 23:56
CouchDB Map/Reduce Example
// Data
[
{"_id":"pvg:IHC09A","_rev":"1-3881006720","nvic":"IHC09A","family":"159","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJU09A","_rev":"1-243536901","nvic":"IJU09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJV09A","_rev":"1-3794903136","nvic":"IJV09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJY09A","_rev":"1-1301614913","nvic":"IJY09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:J3X09A","_rev":"1-1398113861","nvic":"J3X09A","family":"V8","couchrest-type":"GRD::Pvg","make":"ASTON MARTIN"}
]
// Map
@JakeWharton
JakeWharton / post-receive
Created April 9, 2010 13:57
git post-receive hook for updating Trac 0.12
#!/usr/bin/python
import sys
import subprocess
GIT_PATH = '/usr/bin/git'
TRAC_ADMIN_PATH = '/usr/local/bin/trac-admin'
VALID_BRANCHES = ['master']
TRAC_ENV = '/path/to/trac'
@kesor
kesor / profile_middleware.py
Last active March 16, 2021 15:37
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:
@henriquebastos
henriquebastos / formrange.py
Created December 27, 2011 16:59
Snippet para demonstrar validação de um form com range e valor entre eles.
from django import forms
from django.test import RequestFactory
class RangeForm(forms.Form):
min = forms.IntegerField()
max = forms.IntegerField()
valor = forms.IntegerField()
def clean(self):
//layout.jade
!!! 5
html
head
title test
body
block content
@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\
__(= " =)__
//\'-=-'/\\
) (_
/ `"=-._
/ \ ``"=.
django-admin.py startproject --template=https://github.com/githubuser/dj_project_templates/blob/master/project_template.tar --extension="md,py" myproject
@vbmendes
vbmendes / sublpymodule.py
Created April 3, 2013 17:42
Script to open source code of python modules in sublime. Useful to see your dependencies source code.
#!/usr/bin/env python
# coding: utf8
import imp
import sys, os
module_name = sys.argv[1]
bits = module_name.split('.')
name = imp.find_module(bits[0])[1]
if len(bits) > 1:
@dan-blanchard
dan-blanchard / .1.miniconda.md
Last active December 11, 2019 22:38
Quicker Travis builds that rely on numpy and scipy using Miniconda

For ETS's SKLL project, we found out the hard way that Travis-CI's support for numpy and scipy is pretty abysmal. There are pre-installed versions of numpy for some versions of Python, but those are seriously out of date, and scipy is not there are at all. The two most popular approaches for working around this are to (1) build everything from scratch, or (2) use apt-get to install more recent (but still out of date) versions of numpy and scipy. Both of these approaches lead to longer build times, and with the second approach, you still don't have the most recent versions of anything. To circumvent these issues, we've switched to using Miniconda (Anaconda's lightweight cousin) to install everything.

A template for installing a simple Python package that relies on numpy and scipy using Miniconda is provided below. Since it's a common s

@Nagyman
Nagyman / workflows-in-django.md
Last active January 27, 2024 08:29
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)