Skip to content

Instantly share code, notes, and snippets.

View iandanforth's full-sized avatar

Ian Danforth iandanforth

View GitHub Profile
@iandanforth
iandanforth / botoBatchWrappers.py
Created April 30, 2012 23:00
Boto DynamoDB batch_write and batch_get wrappers. Overcomes 25 and 100 item limits respectively.
def unlimitedBatchRead(logger, db, keys):
'''
Takes a list of N keys and breaks it into requests of 100 keys or less.
This is the max per call key count as imposed by Amazon.
* db - A boto Table object
* keys - A list of item hash keys
'''
conn = db.layer2
finalItems = []
@iandanforth
iandanforth / batch-import.py
Created November 29, 2012 21:40 — forked from ajcronk/batch-import.py
Python CSV batch import example
import dateutil.parser
import optparse
import csv
import tempodb
from threading import Thread
from Queue import Queue
class Worker(Thread):
"""Thread executing tasks from a given tasks queue"""
@iandanforth
iandanforth / medianflowtracker.py
Last active December 16, 2015 18:00
This is a revision of mftrack.py by jayrambhia from here: https://github.com/jayrambhia/MFTracker
##############################################################################
# Full Imports
import time
import cv
import cv2
import sys
##############################################################################
# Partial Imports
from bb import getBB, getRectFromBB
@iandanforth
iandanforth / learningLoop.py
Last active December 16, 2015 20:29
Learning Loop - A simple bit of python code that illustrates biological style learning.
#!/usr/bin/python
import time
from random import randint
"""
#############################
Learning Loop
Our scenario is that of a simple creature in a very simple world.
@iandanforth
iandanforth / gist:5835609
Created June 22, 2013 02:35
Dynamixel Setup
'''
How to work with the AX1 Sensor
git clone [email protected]:iandanforth/pydynamixel.git
git checkout axs1
python setup.py install
'''
import dynamixel
import time
@iandanforth
iandanforth / kmeansExample.py
Last active May 13, 2024 14:00
A pure python implementation of K-Means clustering. Optional cluster visualization using plot.ly.
#############################################################################
# Full Imports
from __future__ import division
import math
import random
"""
This is a pure Python implementation of the K-means Clustering algorithmn. The
original can be found here:
#! /usr/bin/python
import os
import subprocess
import time
iteration = 1
def main():
@iandanforth
iandanforth / command-line-tool-template.py
Last active December 22, 2015 07:29
Python command line tool template.
#! /usr/bin/python
import optparse
def main(options):
'''
Performs the amazingly useful tasks for this command line tool
'''
pass
########
### Assuming Tag Key == 'params' and Tag Value = 'frontend:foo:bar:numenta'
tag = 'params'
filters = {}
if tag:
filters["tag-key"] = tag
# Stupid EC2 wrapper needs to be removed
@iandanforth
iandanforth / smg_boto_get_data.py
Created October 1, 2013 19:13
Updated, smugmug specific boto data collection script.
#-------------------------------------------------------------------------------
# Copyright (C) 2013 Numenta Inc. All rights reserved.
#
# The information and source code contained herein is the
# exclusive property of Numenta Inc. No part of this software
# may be used, reproduced, stored or distributed in any form,
# without explicit written authorization from Numenta Inc.
#-------------------------------------------------------------------------------
desc = """
This tool will find instances with the tag specified in the accompanying