Skip to content

Instantly share code, notes, and snippets.

>>> from pinax.apps.projects.models import Project
>>> from django.contrib.auth.models import User
>>> from pinax.apps.tasks.models import Task
>>> t1 = Task.objects.get(pk=1)
>>> t2= Task.objects.get(pk=2)
>>> t2.get_absolute_url()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/issackelly/envs/new/lib/python2.6/site-packages/django/utils/functional.py", line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
timeEvents = Object()
timeEvents["#somevid"]["125"] = function(){ $("#somediv").show() }
function timeListener(el) {
$(el).bind('timeupdate', function(){
time = this.currentTime;
if timeEvents[el][time]
timeEvents[el][time]()
});
}
import pprint
class SqlDumpMiddleware(object):
def process_response(self, request, response):
from django.db import connection
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(connection.queries)
return response
@issackelly
issackelly / gist:719568
Created November 29, 2010 04:12
brew install pyqt troubles
$ brew install pyqt
Warning: It appears you have MacPorts or Fink installed.
Software installed with MacPorts and Fink are known to cause problems.
If you experience issues try uninstalling these tools.
==> Downloading http://www.riverbankcomputing.co.uk/hg/sip/archive/4.11.2.tar.gz
######################################################################## 100.0%
==> Downloading patches
==> Patching
patching file build.py
patching file siputils.py
@issackelly
issackelly / gist:736712
Created December 10, 2010 19:56
How to use biblion tags in your template...untested
{% load biblion_tags %} <!-- at the top of the page -->
{% latest_blog_posts as posts %}<!-- gets 5 posts -->
{% for post in posts %}
{% if forloop.first %}
<h1><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h1>
{{ post.content_html|truncatewords_html:30 }}
{% else %}
<h3><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
"""/doc <something>: return python 2.7's documentation for <something>"""
import re
import importlib
import pydoc
from chatbot import send, p
#by default, render_doc uses shell escapes. Stop that.
class PlainTextDoc(pydoc.TextDoc):
def bold(self, x): return x
from django.conf import settings
import django.core.exceptions
from django.http import HttpResponsePermanentRedirect
from django.utils import translation
# TODO importing undocumented function
from django.utils.translation.trans_real import parse_accept_lang_header
from localeurl import settings as localeurl_settings
from localeurl import utils
# Make sure the default language is in the list of supported languages
@issackelly
issackelly / gist:928783
Created April 19, 2011 16:48
Django Template {{ block.super }} example
# Template: A.html
<html>
<head></head>
<body>
{% block hello %}
HELLO
{% endblock %}
</body>
</html>
@issackelly
issackelly / gist:947085
Created April 28, 2011 19:16
Beginning API Consumption
.. Proposal submission template for PyOhio 2011
.. Columbus, OH July 30 - 31, 2011
.. Information at http://pyohio.org or pyohio-organizers@python.org
.. Submit by June 7, 2011 to cfp@pyohio.org
.. Template uses reStructuredText format: http://docutils.sourceforge.net/rst.html
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22349542-1']);
_gaq.push(['_trackPageview']);
var pageTracker;
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';