Skip to content

Instantly share code, notes, and snippets.

View eprparadocs's full-sized avatar

Chas. Wegrzyn eprparadocs

  • Twisted Storage
  • Boston MA
View GitHub Profile
@dkarchmer
dkarchmer / Django_Rest_Connection.py
Last active February 6, 2016 00:53
Python sample script for connecting to a Django Rest Framework based API
__author__ = 'David Karchmer'
'''
Main fucntionality to manage API calls to a Django based server (with django-rest-framework)
Demonstrates how to set token on header for secure gets/posts
'''
import json
import requests
import logging
DOMAIN_NAME = 'https://example.com'
@babakness
babakness / caselessDictionary.py
Created October 16, 2012 18:46 — forked from bloomonkey/caselessDictionary.py
A Python dictionary sub-class that is case-insensitive when searching, but also preserves the keys as inserted.
class CaselessDictionary(dict):
"""Dictionary that enables case insensitive searching while preserving case sensitivity
when keys are listed, ie, via keys() or items() methods.
Works by storing a lowercase version of the key as the new key and stores the original key-value
pair as the key's value (values become dictionaries)."""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():
@eberle1080
eberle1080 / module_watcher.py
Created June 7, 2011 20:50
Automatically reload python module / package on file change
#!/usr/bin/env python
# Author: Chris Eberle <[email protected]>
# Watch for any changes in a module or package, and reload it automatically
import pyinotify
import imp
import os
class ModuleWatcher(pyinotify.ProcessEvent):
"""
@brendano
brendano / autolog.py
Created October 10, 2008 23:00
python decorators to log all method calls, show call graphs in realtime too
# Written by Brendan O'Connor, [email protected], www.anyall.org
# * Originally written Aug. 2005
# * Posted to gist.github.com/16173 on Oct. 2008
# Copyright (c) 2003-2006 Open Source Applications Foundation
#
# 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
#