Skip to content

Instantly share code, notes, and snippets.

View fgaudin's full-sized avatar

Francois Gaudin fgaudin

  • San Francisco, USA
View GitHub Profile
@fgaudin
fgaudin / gist:948960
Created April 29, 2011 20:18
Comparing list
(Pdb) issues = response.context['issues']
(Pdb) should = [i2, i1, i3, i4]
(Pdb) issues == should
False
(Pdb) issues[0] == should[0]
True
(Pdb) issues[1] == should[1]
True
(Pdb) issues[2] == should[2]
True
o = request.GET.get('o', 'last_comment_date')
if o not in ('subject', 'author', 'update_date', 'last_comment_date', 'category', 'comments', 'votes'):
o = 'last_comment_date'
if o == 'author':
order = 'owner__last_name'
else:
order = o
ot = request.GET.get('ot')
if ot not in ('asc', 'desc'):
@fgaudin
fgaudin / The Ocean - Bathyalpelagic Series Tab
Last active January 17, 2016 15:20
The Ocean - Bathyalpelagic Series Tab
Work in progress...
Made from https://www.youtube.com/watch?v=w60m2r7VNnA
Bathyalpelagic I: Impasses
D------------|--------------------------|---------------------|
A--10--9-----|-8/10-12-13-15-13-12-11---|-10/12-13-15-17-19---|
F--9---10----|-x/x--x--x--x--x--x--x--9-|--x/x--x--x--x--x----|
C--7---12--0-|-5/7--9--10-12-10-9--8----|--7/9--10-12-14-16-0-|
@fgaudin
fgaudin / decorators.md
Created May 31, 2017 19:10
Decorators in python

from @fgaudin blogpost that disappeared from the Internet

Probably like a lot of you, I’ve googled or checked Django’s code to know how to write my own decorators. And every time I was a bit confused, just copy/pasting the examples and changing the code until it works.

While working on a decorator which was basically an aggregation of other decorators, I’ve finally had to get a deeper understanding, so I’ll try to make it clear for you.

Decorators are functions

First, we’ll forget the annotation notation with the @ to understand them better. So when you do: