Skip to content

Instantly share code, notes, and snippets.

View andrewgiessel's full-sized avatar
🧬
hackhackhack

andrew giessel andrewgiessel

🧬
hackhackhack
View GitHub Profile
@andrewgiessel
andrewgiessel / gist:2955714
Created June 19, 2012 18:19
downsample code
def downsample2d(inputArray, kernelSize):
"""This function downsamples a 2d numpy array by convolving with a flat
kernel and then sub-sampling the resulting array.
A kernel size of 2 means convolution with a 2x2 array [[1, 1], [1, 1]] and
a resulting downsampling of 2-fold.
:param: inputArray: 2d numpy array
:param: kernelSize: integer
"""
@andrewgiessel
andrewgiessel / archive_tweets.py
Created July 31, 2012 21:39 — forked from tmcw/archive_tweets.py
Archive Tweets
import requests, os, glob, json
you = 'giessel'
data = 'tweets'
try: os.mkdir(data)
except Exception: pass
def run(max_id = False):
already = glob.glob("%s/*.json" % data)
@andrewgiessel
andrewgiessel / playNPArray.py
Created August 13, 2012 23:20
Embedded playing of numpy arrays in an Ipython notebook
from IPython.display import HTML
import subprocess
import tempfile
from PIL import Image
def playNPArray(array, frameRate = 6):
# ffmpeg is fussy- images must be in the right format to encode right
uint8_array = np.uint8(array.astype('float').copy() / float(array.max()) * 2**8-1)
fileName = 'temp'
@andrewgiessel
andrewgiessel / gist:3375545
Created August 17, 2012 02:55
python nb for manual inlining
{
"metadata": {
"name": "manual inline mode"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@andrewgiessel
andrewgiessel / disconnect.rb
Created September 13, 2012 14:50 — forked from gljeremy/disconnect.rb
bulk-export run data from Garmin Connect
#!/usr/bin/env ruby
## disconnect
# ./disconnect.rb -u yourusername [-o /your/path] [-p yourhttpproxyserver]
#
# This is a command-line utility for the bulk-downloading of run data from
# the connect.garmin.com web application, which has lackluster export
# capabilities.
#
@andrewgiessel
andrewgiessel / gist:3767511
Created September 22, 2012 19:26
astro_ml_tutorial.ipynb
{
"metadata": {
"name": "astro_ml_tutorial"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@andrewgiessel
andrewgiessel / basesian_blocks.py
Created September 27, 2012 15:45
bayesian block algorithm for finding the optimal number of histogram bins
def bayesian_blocks(t):
"""Bayesian Blocks Implementation
By Jake Vanderplas. License: BSD
Based on algorithm outlined in http://adsabs.harvard.edu/abs/2012arXiv1207.5578S
Parameters
----------
t : ndarray, length N
data to be histogrammed
@andrewgiessel
andrewgiessel / correlation\ example\ with\ a\ 2d\ gaussian.ipynb
Created November 5, 2012 22:17
2d correlation example with a gaussian ipython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewgiessel
andrewgiessel / NLTK_and_python_syntax.ipynb
Created December 11, 2012 15:49
python nltk and some simple python syntax
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.