Skip to content

Instantly share code, notes, and snippets.

View ptone's full-sized avatar

Preston Holmes ptone

View GitHub Profile
@ptone
ptone / vpcgraph.py
Last active August 29, 2015 13:56 — forked from j3tm0t0/vpcgraph.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import boto.ec2
import boto.vpc
def dprint (body):
# print >> sys.stderr, body
return
@ptone
ptone / gist:6437039
Last active December 22, 2015 07:19
Pycon 2014 talk proposal. I'm open to any and all feedback. Would you be interested in this talk? Are you more interested in the generalizations, or the specifics? What do you think would make this talk more interesting to an even broader pycon audience?

Blending art, technology, and light. Designing Birdfish, an expressive Python Library for interactive and real time LED installations

Category

Other

Python Level

Intermediate

@ptone
ptone / index.html
Created June 27, 2013 15:33
recording keypresses with browser & websockets uses: https://github.com/aaugustin/websockets
<html>
<head>
<title>key press test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<h1>Press keys...</h1>
WebSocket status : <span id="message"></span>
<script>
var ws = new WebSocket('ws://127.0.0.1:8866/');
@ptone
ptone / convert-lsm.py
Created June 12, 2013 01:16
a heavily annotated python script to breakout and combine channels of LSM confocal images
import sys
import os
import scipy
from numpy import array, dstack
from pylsm import lsmreader
# all of the above imports pull into our program features we use of other
# modules. Ideally anything not defined in our program can be seen above
# sys.argv contains a list of all the files passed to our script when it is called
@ptone
ptone / devices.py
Last active December 18, 2015 00:09
I'm working on something that takes physical hardware and allows one to add additional behaviors to it. In the end, I'd like the API to present the modeled logical item as a single entity in code with all state flattened. If the logical objects that add behaviors to the physical devices were 1:1 with the physical devices, then it would make sens…
class PhysicalDevice(object):
def __init__(self, channel=0):
self.channel = channel
self.physical_state = False
class LogicalDeviceBase(object):
def __init__(self):
self.logical_state = False
import sys
from birdfish.input.osc import OSCDispatcher
from birdfish.lights import RGBLight, Chase, LightShow
from birdfish.output.lumos_network import LumosNetwork
from birdfish import tween
osc_dispatcher = OSCDispatcher(('0.0.0.0', 8998))
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index 2589068..bca79a4 100644
--- a/django/contrib/auth/tests/forms.py
+++ b/django/contrib/auth/tests/forms.py
@@ -100,7 +100,8 @@ class AuthenticationFormTest(TestCase):
form = AuthenticationForm(None, data)
self.assertFalse(form.is_valid())
self.assertEqual(form.non_field_errors(),
- [force_text(form.error_messages['invalid_login'])])
+ [force_text(form.error_messages['invalid_login']
@ptone
ptone / gist:4271278
Created December 12, 2012 20:27
Problem trying to run notebook with extra static paths
(notebook)element:nbcast$ ipython notebook --NotebookApp.extra_static_paths="['./profile_nbcast/static/']"
Traceback (most recent call last):
File "/Users/preston/Projects/Python/virtualenvs/notebook/bin/ipython", line 9, in <module>
load_entry_point('ipython==0.14.dev', 'console_scripts', 'ipython')()
File "/Users/preston/UNIX/src/ipython/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Users/preston/UNIX/src/ipython/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/preston/UNIX/src/ipython/IPython/frontend/terminal/ipapp.py", line 313, in initialize
@ptone
ptone / gist:4270659
Created December 12, 2012 19:13
load popcorn dynamically
// load popcorn dynamically
var script = document.createElement("script");
script.type = "text/javascript";
script.src = '/static/js/popcorn.js';
document.getElementsByTagName("head")[0].appendChild(script);
function popcornReady() {
// this is called when script loaded, but before Popcorn global ready
console.log("popcorn ready callback");
// console.log(Popcorn);
"""
Tween functions
t = current time
b = start value
c = change in value
d = total duration
"""
def OUT_EXPO(t, b, c, d ):
return b+c if (t==d) else c * (-2**(-10 * t/d) + 1) + b