Skip to content

Instantly share code, notes, and snippets.

class ListResource(ModelResource):
'''
API resource for lists
Logged in user is mapped to the model using this:
http://django-tastypie.readthedocs.org/en/latest/cookbook.html#creating-per-user-resources
'''
class Meta:
queryset = List.objects.all()
@jorilallo
jorilallo / urls.py
Created September 23, 2011 17:04 — forked from sjl/urls.py
Monkeypatch the Celery admin to show a column for task run time in the list view.
# Put this in your urls.py file after the admin.autodiscover() line.
# ---------------------------------------------------------------------------------
# Monkeypatch the Celery admin to show a column for task run time in the list view.
from djcelery.admin import TaskMonitor
from djcelery.models import TaskState
admin.site.unregister([TaskState])
TaskMonitor.list_display += ('runtime',)
admin.site.register(TaskState, TaskMonitor)
@jorilallo
jorilallo / gist:1249356
Created September 28, 2011 21:51
Backbone History bug fix
_.extend Backbone.Router.prototype, {
# load a new fragment, replacing the current history entry with the new fragment
# this is used to prevent a back-button-redirect loop
redirect:(fragment) ->
Backbone.history.redirect(fragment)
}
_.extend Backbone.History.prototype, {
redirect:(fragment) ->
frag = (fragment || '').replace(/^#*/, '')
@jorilallo
jorilallo / Github's usage of the showdown.js in example
Created October 13, 2011 01:16
Showdown.js with GitHub Flavored Markdown
$(function() {
var converter = new Showdown.converter();
$("#user_input").keyup(function(){
var txt = $("#user_input").val();
var html = converter.makeHtml(txt);
$("#result").html(html)
$("#html_result").val(html.replace(/>/g, ">\n").replace(/</g, "\n<").replace(/\n{2,}/g, "\n\n"));
});
var sample = "#### Underscores\nthis should have _emphasis_\nthis_should_not\n_nor_should_this\n\n\
@jorilallo
jorilallo / json-response.py
Created October 17, 2011 22:51 — forked from leah/json-response.py
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
https://www.facebook.com/dialog/oauth?scope=email%2Cpublish_stream%2Coffline_access&state=&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fsocial%2Ffacebook%2Fcallback%2F&response_type=code&client_id=2645809696793984
@jorilallo
jorilallo / gist:1509950
Created December 22, 2011 11:16
Grove's weechat config
# Add new server for organization YYYYYY
/server add grove YYYYYY.irc.grove.io/6667
/set irc.server.YYYYYY.password "YYYYYY"
# Set your username to BBBB
/set irc.server.YYYYYY.username "BBBB"
/set irc.server.YYYYYY.nicks "BBBB"
# Set your password
/set irc.server.YYYYYY.command "/msg NickServ identify xxxxxx"
@jorilallo
jorilallo / grove.io.js
Created January 7, 2012 11:36
GitHub'fy Grove.io with dot.js
/*
** GitHub'fy Grove.io with dot.js
**
** source: http://github.github.com/github-flavored-markdown/scripts/showdown.js
** dotjs: http://defunkt.io/dotjs/
*/
var repo = 'Organization/repo';
setInterval(function(){
@jorilallo
jorilallo / gist:1577837
Created January 8, 2012 09:28
Hook to desktop notifications
document.getElementById('groveNotificationEventDiv').addEventListener('groveNotificationEvent', function() {
var eventData = document.getElementById('groveNotificationEventDiv').innerText;
console.log(JSON.parse(eventData)); // Show data for notifications
// Do notification here
});