Skip to content

Instantly share code, notes, and snippets.

View pingswept's full-sized avatar

Brandon Stafford pingswept

  • Tufts University
  • Somerville, Massachusetts, USA
View GitHub Profile
### Keybase proof
I hereby claim:
* I am pingswept on github.
* I am brandonstafford (https://keybase.io/brandonstafford) on keybase.
* I have a public key whose fingerprint is 96E3 30F7 534B B328 14BD 92AF F3B1 AADE 8B45 35C0
To claim this, I am signing this object:
@pingswept
pingswept / smack-blog.py
Last active August 29, 2015 14:03
Code for monitoring the 3D printers at Happy Workhorse Farms
# Add in cat /etc/supervisor/conf.d/smack-blog.conf
#
# [program:smack-blog]
# command=/root/smack-blog.py
#!/usr/bin/python
import Adafruit_BBIO.UART as UART
import os, pytumblr, serial, time
@pingswept
pingswept / evolver.py
Last active August 29, 2015 14:02
Skeleton of Python code for Evolver
import time
TUBES = range(1,49)
while(1):
ReadOpticalSensors()
ReadTemperatures()
ReadFluidFlowStatus()
(speeds, temps, flows) = DecideExperimentSpecificStuff() # This is where the custom stuff goes!
@pingswept
pingswept / evolver-experiment.ini
Last active August 29, 2015 14:01
First cut at turbidostat experiment config file
[optical density]
max_od=0.25
min_od=0.1
od_logging_interval=30
[stirrer]
speed="medium"
[temperature]
target=37.0
@pingswept
pingswept / scrape-sos-ri-gov.py
Last active January 28, 2016 19:27
Code to automatically retrieve representative and senatorial districts from ri.gov
import csv, re, requests
pattern = re.compile('<li>REPRESENTATIVE: (\d\d)</li>\n\t\t\t<li>SENATORIAL: (\d\d)</li>')
infile = csv.reader(open('addresses.csv', 'r'))
with open('output.csv', 'wb') as outfile:
for line in infile:
unique_id = line[0]
address = line[1]
@pingswept
pingswept / 18_bit_precision_voltage_shield.ino
Created March 24, 2014 19:37
Demonstration code for the 18-bit variant of the Rascal Micro Precision Voltage Shield
#include <SPI.h>
#define RESOLUTION 18
#define SCALE_FACTOR 0.00003814697265625
// 10/(2^18) = 0.00003814697265625
#define BUSY 3
#define RESET 4
#define START_CONVERSION 5
#define CHIP_SELECT 10
@pingswept
pingswept / card-reader.pde
Created March 19, 2014 19:26
Code to read UID from Charlie Card using Adafruit PN532 NFC shield
/**************************************************************************/
// Based on code from Adafruit's PN532 NFC shield example
// BSD license
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>
#define IRQ (2)
@pingswept
pingswept / gist:9295878
Created March 1, 2014 19:37
Nginx conf for test.rm.com
server {
listen 0.0.0.0:80;
server_name test.rascalmicro.com;
access_log /var/log/nginx/test.rascalmicro.com/access.log;
error_log /var/log/nginx/test.rascalmicro.com/error.log;
location / { # catch-all directive
proxy_set_header X-Real-IP $remote_addr;
@pingswept
pingswept / test-4x4-driver-shield.ino
Created February 7, 2014 19:22
Test code for the 4x4 driver shield. Pulses all 16 outputs on and off with a 1 second delay in between.
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
@pingswept
pingswept / ghost-import.py
Created February 6, 2014 02:07
The sorriest excuse for a Markdown file importer for Ghost that can be imagined.
def insert_post_into_database(list_of_posts):
import sqlite3
con = sqlite3.connect('ghost-dev.db')
cur = con.cursor()
for post in list_of_posts:
print(post)
cur.execute('INSERT INTO posts(uuid, title, slug, markdown, featured, page, status, language, author_id, created_at, created_by) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', post)