This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import copy | |
| def make_hash(obj): | |
| """Make a hash from an arbitrary nested dictionary, list, tuple or | |
| set. | |
| """ | |
| if isinstance(obj, set) or isinstance(obj, tuple) or isinstance(obj, list): | |
| return hash(tuple([make_hash(e) for e in obj])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ wget "http://www.getsentry.com" [18:13:49] | |
| --2013-07-16 18:19:37-- http://www.getsentry.com/ | |
| Resolving www.getsentry.com (www.getsentry.com)... 67.228.250.100 | |
| Connecting to www.getsentry.com (www.getsentry.com)|67.228.250.100|:80... failed: Connection timed out. | |
| Retrying. | |
| --2013-07-16 18:21:45-- (try: 2) http://www.getsentry.com/ | |
| Connecting to www.getsentry.com (www.getsentry.com)|67.228.250.100|:80... failed: Connection timed out. | |
| Retrying. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import template | |
| """It's sometimes really handy to be able to do basic arithmetic in | |
| Django templates. | |
| """ | |
| register = template.Library() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.test import TestCase | |
| class ResponseTestCase(TestCase): | |
| """Some additional assertions for Django responses.""" | |
| def assertHttp200(self, response): | |
| status_code = response.status_code | |
| self.assertEqual( | |
| status_code, 200, | |
| "Expected a HTTP 200 response, but got HTTP %d" % status_code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib import admin | |
| from django.contrib.auth.admin import UserAdmin | |
| from django.contrib.auth.models import User | |
| class MyUserAdmin(UserAdmin): | |
| actions = ['my_action'] | |
| def my_action(self, request, queryset): | |
| # stuff here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [program:irc] | |
| command = /usr/bin/ii -s irc.freenode.org -i /tmp -n bot_user_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // replace real checkboxes with fake ones using spans that work the same | |
| $('input[type=checkbox]').each(function() { | |
| var $input = $(this); | |
| $input.hide(); | |
| var $fakeCheckbox = $('<div class="fake-checkbox"><span class="icon-TICK"></span></div>'); | |
| $input.after($fakeCheckbox); | |
| // when our fake checkbox is clicked | |
| $fakeCheckbox.click(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.urlresolvers import reverse | |
| from django.utils.safestring import mark_safe | |
| import django_tables2 as tables | |
| class ClickableColumn(tables.Column): | |
| """Renders a link to edit the current object.""" | |
| def __init__(self, url_name, *args, **kwargs): | |
| self.url_name = url_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title></title> | |
| <style> | |
| #dock { | |
| width: 70px; | |
| background-color: green; | |
| height: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; tco.el --- tail-call optimisation -*- lexical-binding: t -*- | |
| (require 'dash) | |
| (eval-when-compile (require 'cl)) | |
| (setq lexical-binding 't) | |
| (defun tco-add-trampoline (fun-name new-name form) | |
| "Given quoted soure FORM, replace calls to FUN-NAME (a symbol) | |
| with a lambda expression that returns the result of the FUN-NAME call." | |
| (--map |