Skip to content

Instantly share code, notes, and snippets.

View cameronmaske's full-sized avatar

Cameron Maske cameronmaske

View GitHub Profile
@cameronmaske
cameronmaske / tracer.py
Created March 6, 2014 18:08
Really useful for debugging functions, particularly in django's manage.py shell
import sys
def tracer(frame, event, arg):
if event != 'call':
return
co = frame.f_code
func_name = co.co_name
if func_name == 'write':
# Ignore write() calls from print statements
return

Keybase proof

I hereby claim:

  • I am cameronmaske on github.
  • I am cameronmaske (https://keybase.io/cameronmaske) on keybase.
  • I have a public key whose fingerprint is 08D0 2E91 2D9C 17EC 8873 E9F1 16AF 160A 264C 8ECB

To claim this, I am signing this object:

@cameronmaske
cameronmaske / Dockerfile
Created July 11, 2014 13:33
PhantomJS + Python (For Selenium)
FROM orchardup/python:2.7
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y libpng12-dev libsvga1-dev libjpeg8-dev libfreetype6-dev libjasper-dev fontconfig
# Install PhantomJS
RUN mkdir /opt/phantomjs-1.9.2
RUN apt-get install -y wget
RUN wget -O /tmp/phantomjs-1.9.2.tar.gz https://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-x86_64.tar.bz2
from tests import TestCase
def TestTasks(TestCase):
signals = False
def before(self):
self.model = Bla()
def after(self):
print("done")
@cameronmaske
cameronmaske / twister.py
Created December 27, 2014 00:38
A script to call out twisters moves written in Python! Only works on OSX.
from random import choice
from time import sleep
from subprocess import call
if __name__ == '__main__':
colors = ["green", "yellow", "blue", "red", "in the air", "other player's choice"]
parts = ["left hand", "right hand", "right foot", "left foot"]
while True:
part = choice(parts)
color = choice(colors)
for commit in $(git rev-list --all master)
do
echo $commit
git checkout $commit > /dev/null 2>&1; find . -name '*.py' | xargs wc -l
echo
done
git checkout master
import commands
import json
output_name = "commits-over-time"
data = []
past_changes = {}
commits = commands.getstatusoutput(
"git rev-list --all master")[1].split('\n')
[
{
"files": {
"pythonpy/__init__.py": 1,
"pythonpy/__main__.py": 208,
"pythonpy/pycompleter.py": 333,
"setup.py": 60,
"test/test_pythonpy.py": 50
},
"id": "5ba6f1ea925ee4a7edd26236812fac2cd57864db",

Contributing a new backend.

Contributing a new locking backend is greatly appreciated! Each new backend must implement the following methods...

class Backend(object):
    """
    Each new backend must implement the following methods,
    - __init__
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];