Skip to content

Instantly share code, notes, and snippets.

View avorio's full-sized avatar

André Avorio avorio

View GitHub Profile
@avorio
avorio / gist:f732f1733b03e04e411b
Created March 7, 2015 11:32
Sending links to Colette using a bookmarklet
javascript: var siteURL='colette', nodeType='link', d=document, w=window, e=w.getSelection, k=d.getSelection, x=d.selection, s=(e?e():(k)?k():(x?x.createRange().text:0)), l=d.location, e=encodeURIComponent, url='http://'+siteURL+'/node/add/'+nodeType+'?edit[title]='+e(d.title); if(s) { url+='&edit[body][und][0][value]='+e(s); url+='&edit[field_url][und][0][url]='+l;} a=function(){if(!w.open(url,'quickpost','toolbar=0,resizable=1,scrollbars=1,status=1,width=1024,height=570')) l.href=url;}; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
@Nagyman
Nagyman / workflows-in-django.md
Last active July 14, 2024 16:13
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)
@trevormunoz
trevormunoz / pandas_dishes.ipynb
Created January 10, 2014 17:35
An IPython notebook demonstrating how the Pandas data analysis library can be used to help curate data from the New York Public Library's What's On the Menu? Project
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@c4urself
c4urself / url_patterns.py
Created June 16, 2011 08:39
URL Patterns with Optional Arguments
(r'^articles/(?P<year>\d{4}/?$, 'main.views.year'),
# When a use case comes up that a month needs to be involved as
# well, you add an argument in your regex:
(r'^articles/(?P<year>\d{4}/(?P<month>\d{2})/?$, 'main.views.year_month'),
# That works fine, unless of course you want to show something
# different for just the year, in which case the following case can be
# used, making separate views based on the arguments as djangoproject