This file contains 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
/** | |
* | |
* usage: $('#select-container').nested({url:'/path/to/backend/which/returns/options/'}) | |
* | |
*/ | |
(function($){ | |
$.fn.extend({ | |
//pass the options variable to the function | |
nested: function(options) { | |
//Set the default values |
This file contains 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 tempfile | |
import hotshot | |
import hotshot.stats | |
def profile(func): | |
def wrapper(request, *args, **kwargs): | |
tmpfile = tempfile.NamedTemporaryFile() | |
prof = hotshot.Profile(tmpfile.name) | |
result = prof.runcall(func, request, *args, **kwargs) |
This file contains 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
def tastypie_template(template_name="base.html", var_name='data', serialize=True): | |
""" | |
Decorator. | |
Wrap Tastypie Resource class with it to render into template. | |
Usage: | |
@tastypie_template() | |
class UserResource(ModelResource): | |
... |
This file contains 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 | |
# | |
# This is a modified version of initial parser implementation | |
# described here: http://www.poldylicious.de/node/25 | |
import re | |
class ApacheConfig(object): | |
""" |
This file contains 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 | |
# | |
# Copyright 2009 Facebook | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains 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
class PersonaAuthHandler(BaseHandler): | |
@tornado.web.asynchronous | |
def post(self): | |
assertion = self.get_argument('assertion') | |
http_client = tornado.httpclient.AsyncHTTPClient() | |
domain = 'localhost' # MAKE SURE YOU CHANGE THIS | |
url = 'https://browserid.org/verify' | |
data = { | |
'assertion': assertion, |
This file contains 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
#include <Python.h> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
Py_Initialize(); | |
PyObject* po_operator = PyImport_ImportModule("operator"); | |
PyObject* po_division = PyObject_GetAttrString(po_operator, "div"); |
This file contains 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
#python manage.py runserver --noreload | |
from django.conf.urls import patterns, include, url | |
from django.conf import settings | |
from django.http import HttpResponse | |
import sys | |
def reload_urls(request, urlconf=None): | |
if urlconf is None: | |
urlconf = settings.ROOT_URLCONF |
This file contains 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 time | |
from collections import OrderedDict | |
class Cache(): | |
""" | |
In process memory cache. Not thread safe. | |
Usage: | |
This file contains 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
# rsyslog v5 configuration file | |
#### MODULES #### | |
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command) | |
$ModLoad imklog # provides kernel logging support (previously done by rklogd) | |
#$ModLoad immark # provides --MARK-- message capability | |
# Provides UDP syslog reception | |
$ModLoad imudp |
OlderNewer