Skip to content

Instantly share code, notes, and snippets.

View durden's full-sized avatar

Luke Lee durden

View GitHub Profile
@durden
durden / heroku_deployment
Created October 1, 2011 18:04
Codrspace deployment for heroku
Install rvm (ruby community equivalent of virtualenv):
- bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Install ruby 1.9.2:
- rvm install 1.9.2 && rvm use 1.9.2 --default
Heroku:
- gem install heroku
- heroku create --stack cedar
- Automatically adds a git remote called 'heroku'
@durden
durden / workstation_setup.txt
Created November 2, 2011 15:24
New Linux workstation setup
Install
-------------------
- colordiff (svn diff w/ colors)
- git
- gvim w/ python support
- exuberant-ctags
- xchat
- pylint
@durden
durden / github_usage.py
Created February 28, 2012 04:03
Space used by github account
# Requires github.com/durden/frappy
from frappy.services.github import Github
g = Github()
sizes = 0
res = g.users.durden.repos()
@durden
durden / hack.sh
Created April 1, 2012 02:17 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@durden
durden / codrspace_processor.py
Created October 2, 2012 02:51
Custom processor for markedapp
#!/usr/bin/env python
"""
Simplified stand-alone script to mimic codrspace.com short code processing.
Script takes 1 optional argument, the path of your python environment.
The rest of the input is read directly from stdin and expected to be codrspace
markdown text. The output is codrspace html after all markdown and codrspace
specific short codes have been processed.
class DictDiffer(object):
"""
Calculate the difference between two dictionaries as:
(1) items added
(2) items removed
(3) keys same in both but changed values
(4) keys same in both and unchanged values
"""
def __init__(self, current_dict, past_dict):
self.current_dict, self.past_dict = current_dict, past_dict
@durden
durden / do_not_use_this.py
Created November 13, 2012 21:32
Just experimenting with weird stuff like monkey patching base object to do evil stuff
class myobject(object):
ATTR_CACHE = {}
def __init__(self, *args, **kwargs):
for arg in args:
print arg
super(myobject, self).__init__(*args, **kwargs)
def __new__(cls, *args, **kwargs):
# At this point cls is NOT created, it's just a string :)
@durden
durden / class_state_watcher.py
Created November 15, 2012 21:44
Watch when variables change in your class
def watch_variables(var_list):
"""Usage: @watch_variables(['myvar1', 'myvar2'])"""
def _decorator(cls):
def _setattr(self, name, value):
if name in var_list:
import traceback
import sys
# Print stack (without this __setattr__ call)
traceback.print_stack(sys._getframe(1))
print '%s -> %s = %s' % (repr(self), name, value)
@durden
durden / github_zen.py
Created November 25, 2012 15:55
Little script to try and get unique 'zen' values from github api
import argparse
import requests
import time
def _parse_args():
parser = argparse.ArgumentParser(description='Zen out with github')
# Github api limits 60/hour for unauthenticated requests
parser.add_argument('--sleep', type=float, default=60.0, action='store',
@durden
durden / generate_static_c.py
Created November 28, 2012 00:15
Python generator attempting to simulate static variable in a C function
# Just playing around and thinking about how itertools.count might work (without # looking at source :) )
# Simple version of a 'static' variable in C, just keep state internally
# and use next() to get values out
def counter():
for ii in xrange(100):
yield ii
cnt = counter()
print cnt.next()