Skip to content

Instantly share code, notes, and snippets.

@cooncesean
cooncesean / email.txt
Created September 3, 2013 21:57
Email from John (Thinkify co-founder) regarding the T6 command.
....
In the T6 command, the reader streams data as it comes in.
If your software isn't keeping up with him, eventually the serial buffer on the PC will fill up. When that happens, the reader pauses reading and will flash the LEDs to indicate that it's waiting for the host. If you empty the buffer, it should start up again and keep reading. Maybe this is happening intermittently in your setup.
You can emulate this behavior in terraterm.
Connect to the reader, issue a t6 with tags present. Then, close hyperterm while the reader is running. It should keep reading for a few seconds, then it will stop and go into flashing mode. If you reconnect the terminal program, data should start streaming again.
....
@cooncesean
cooncesean / remove.py
Created August 26, 2013 21:51
remove pending .mov keys
from boto.s3.connection import S3Connection
from boto.s3.key import Key
from django.conf import settings
PROCESSED_PATH = 'uploads/videos/processed/'
David Halberstam ("Being a professional means doing your job on the days you don't want to do it"),
Ferris Bueller ("Life moves pretty fast — if you don't stop and look around once in awhile, you could miss it")
Milton Berle ("If opportunity doesn't knock, build a door")? Hmmmmmm. I'd go with this advice …
SG: Don't worry about what other people are doing. Worry about what you're doing.
@cooncesean
cooncesean / generate_events.py
Created August 14, 2013 18:21
Design pattern to handle anonymous users and event tracking using bitmapist.
import bitmapist
ANONYMOUS_USER_KEY = 'anonymous_user'
def generate_event(event_name, user_id=None):
if user_id is None:
user_id = 'anon:%s' % bitmapist.get_redis().incr(ANONYMOUS_USER_KEY)
bitmapist.mark_event(event_name, user_id)
@cooncesean
cooncesean / rfid.py
Last active August 9, 2021 08:26
Sample script to loop indefinitely and look for RFID tags using pyserial.
# `serial` refers to the pyserial library which can be found here: http://pyserial.sourceforge.net/
import serial
BAUD_RATE = 9600
RFID_BYTES = 12
START_CHAR = '\x02'
ser = serial.Serial('/dev/tty.usbserial-AH01D7DV', BAUD_RATE)
while True:
@cooncesean
cooncesean / gopro.py
Created June 24, 2013 23:39
Sample API for how I envision the GoPro interface working.
class GoProInterface(object):
"""
This is a sample API (written in Python) of how I envision
the calls to be made to the firmware.
Sample (Python) Usage:
>>> gpi = GoProInterface('~/gopro/videos/')
>>> gpi.start()
>>> gpi.stop()
/Users/sean/gopro/videos/0001.m4v
@cooncesean
cooncesean / script.py
Created June 21, 2013 18:14
GoPro Automated Recording Script
"""
This program interfaces with the GoPro camera and records footage for a
set amount period of time defined by the optional `--seconds` arg.
"""
import argparse
import time
import serial
parser = argparse.ArgumentParser(description='Captures video from GoPro for set number of seconds.')
parser.add_argument(
@cooncesean
cooncesean / patch_photo_redis.py
Created May 31, 2013 23:09
This is a quick stab at fixing the old photo urls (currently pointing to turn) and repointing them to the new bucket..... Feel free to comment/fork/whatever..... don't run this without checking with @honza or Prague (and maybe testing on a staging env first).... we prolly need to deal with Formatted Photos as well.
from ella.photos.models import Photo, redis, REDIS_PHOTO_KEY
OLD_BASE_URL = 'http://production-media.turn.com'
NEW_BASE_URL = 'http://production-media.purpleclover.com'
for p in Photo.objects.all().order_by('id'):
print 'p', p.id, p
# Get the photo hash from redis
@cooncesean
cooncesean / turn_tags.py
Created May 31, 2013 22:19
Template tag `get_franchise_gallery_items()` to get recent GalleryItems associated to a specific Category.
from django.core.cache import cache
from ella_galleries.models import GalleryItem
@register.assignment_tag
def get_franchise_gallery_items(category_tree_path, results=5):
"""
Takes a `category_tree_path`, an optional arg `results` and
returns a list of most recent GalleryItems in the Category.
Since this is an expensive query, we'll cache the results for
@cooncesean
cooncesean / update_promo_links.py
Created May 31, 2013 21:42
Update promo base urls from Turn to PurpleClover.