Skip to content

Instantly share code, notes, and snippets.

View philippeowagner's full-sized avatar

Philippe O. Wagner philippeowagner

View GitHub Profile
#!/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
(function($){
ListFilterCollapsePrototype = {
bindToggle: function(){
var that = this;
this.$filterTitle.click(function(){
that.$filterContent.slideToggle();
that.$list.toggleClass('filtered');
});
},
init: function(filterEl) {
(*
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
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)
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;
}
# -*- 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):
from project.utils import classmaker
class Category(TranslatableModel, MPTTModel):
# https://github.com/ojii/django-nani/issues/39
__metaclass__ = classmaker()
# 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()
# -*- 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"
# -*- coding: utf-8 -*-
import re
import distutils.sysconfig as sysconfig
import os
__doc__ = '''set-me-up.
Usage:
set-me-up <projectdir>
'''