Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View durden's full-sized avatar

Luke Lee durden

View GitHub Profile
@durden
durden / delete_class_methods.py
Created March 7, 2014 23:01
Deleting class methods in Python..a bad idea
>>> class Foo(object):
... def a(self): return 'a'
...
>>> x = Foo()
>>> print x.a()
a
>>>
>>> def b(self):
... return 'b'
...
@durden
durden / numpy_ordering.py
Created March 14, 2014 14:04
Python numpy array ordering
>>> import numpy
>>> x = numpy.arange(27).reshape((3,3,3))
>>> x
array([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
[[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17]],
@durden
durden / pytest_failure.py
Created April 3, 2014 14:44
Demonstrate py.test failure
def func_1():
return ['a', 'b', 'c']
def func_2():
"""
>>> func_1()
['a', 'b', 'c']
"""
pass
@durden
durden / gist:1028560
Created June 16, 2011 02:27
Deployment of Django 1.2 app to Gondor (http://gondor.io)
** Structure should have repo directory then django project directory under it.
** Only files that are committed to the repo are used in deployment.
** Make sure to not have any other .git projects/directories in your project
other than the one at the top level. This causes problems like not finding
settings files, etc.
** <project> refers to the 'main' project where your git repository (.git
directory resides)
** <project_name> refers to the 'main' django project directory (were
settings.py resides)
@durden
durden / create_virtualenv.sh
Created June 25, 2011 18:08
Shell script wrapper for easily starting/populating a virtual env
#!/bin/sh
# This is a function so that we can use 'workon' to switch since it will
# refresh the environment and pass it onto the caller. Thus, no reason to run
# another shell after this command or calling workon manually, etc.
start_virtualenv_main() {
# Assume your working in the directory of the project name
curr=`pwd`
proj=`basename $curr`
This is an updated test from frappy
@durden
durden / liquid sn0b
Created July 12, 2011 03:42
dash idea
Liquid Snobs (DIY Drinker)
- Categories (post type):
1. Coffee
2. Beer
3. Cocktails
** might could add tea or something else
- Each part has it's own slightly different css/look and feel
import sys, types
module = sys.modules[__name__]
for name, var in vars(module).items():
if type(var) == types.FunctionType and name.startswith('filter_'):
value = var(value)
#django dash test
@durden
durden / listchunk.py
Created September 10, 2011 15:37
Iterate of a list chunk by chunk
class ListChunk:
def __init__(self, items, chunksize):
self.items = items
self.chunksize = chunksize
self.ii = 0
def __iter__(self):
return self
def next(self):
if self.ii >= len(self.items):
raise StopIteration