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
| #!/usr/bin/env python | |
| # | |
| # When triggered via a HTTP request, execute a command. | |
| # | |
| # Written by Senko Rasic <senko.rasic@goodcode.io> | |
| # Released into Public Domain. Use it as you like. | |
| # | |
| # Usage: python trigger.py <host> <port> <key> <command>... | |
| # | |
| # HTTP GET and POST requests are supported. If you need more verbs or need |
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
| (function($){ | |
| ListFilterCollapsePrototype = { | |
| bindToggle: function(){ | |
| var that = this; | |
| this.$filterTitle.click(function(){ | |
| that.$filterContent.slideToggle(); | |
| that.$list.toggleClass('filtered'); | |
| }); | |
| }, | |
| init: function(filterEl) { |
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
| (* | |
| Applescript to launch a diff tool to compare two notes in Evernote. | |
| Useful to compare conflicting notes | |
| 1. Place the script file in ~/Library/Scripts/Applications/Evernote | |
| 2. Ensure Applescript menu bar item is on. Option to turn on/off is under General Preferences in AppleScript Editor | |
| 3. The variable difftool can be change to any command line tool you require | |
| *) | |
| -- opendiff launches FileMerge.app developer tool |
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 redis | |
| import threading | |
| class Listener(threading.Thread): | |
| def __init__(self, r, channels): | |
| threading.Thread.__init__(self) | |
| self.redis = r | |
| self.pubsub = self.redis.pubsub() | |
| self.pubsub.subscribe(channels) | |
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
| function getCSRFToken() { | |
| var cookieValue = null; | |
| if (document.cookie && document.cookie != '') { | |
| var cookies = document.cookie.split(';'); | |
| for (var i = 0; i < cookies.length; i++) { | |
| var cookie = jQuery.trim(cookies[i]); | |
| if (cookie.substring(0, 10) == ('csrftoken' + '=')) { | |
| cookieValue = decodeURIComponent(cookie.substring(10)); | |
| break; | |
| } |
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
| # -*- coding: utf-8 -*- | |
| from django.utils.translation import get_language, activate, deactivate_all, deactivate | |
| class LanguageFieldProxy(object): | |
| def contribute_to_class(self, cls, name): | |
| self.name = name | |
| setattr(cls, self.name, self) | |
| def __get__(self, instance, instance_type=None): |
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 project.utils import classmaker | |
| class Category(TranslatableModel, MPTTModel): | |
| # https://github.com/ojii/django-nani/issues/39 | |
| __metaclass__ = classmaker() | |
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
| # modified version of http://tomforb.es/using-python-metaclasses-to-make-awesome-django-model-field-choices | |
| # that preserves order of definition | |
| import inspect, itertools | |
| class Option(object): | |
| _counter = itertools.count() | |
| def __init__(self, value, verbose_name=None): | |
| self._count = Option._counter.next() |
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
| # -*- coding: utf-8 -*- | |
| """Shipping backend that skips the whole shipping process.""" | |
| from django.conf.urls.defaults import patterns, url | |
| class SkipShippingBackend(object): | |
| backend_name = "Skip Shipping Backend" | |
| url_namespace = "skip-shipping" |
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
| # -*- coding: utf-8 -*- | |
| import re | |
| import distutils.sysconfig as sysconfig | |
| import os | |
| __doc__ = '''set-me-up. | |
| Usage: | |
| set-me-up <projectdir> | |
| ''' |