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 / Python Install with Macports
Created October 30, 2011 16:30 — forked from alexbw/PythonInstallwithMacports
Python installation w/ MacPorts
# Install Macports
# We'll install a relatively high-level package first, with a lot of dependencies,
# so that we pick up everything along the way
# Chaco is an enthought plotting package that'll
sudo port install py26-chaco
sudo port select python python26
sudo port install py26-ipython
@andrewgiessel
andrewgiessel / gist:2785137
Created May 25, 2012 00:49
copy/paste numpy arrays to/from excel (os x)
import subprocess
import tempfile
import numpy as np
import os
def npArrayFromClipboard():
"""Reads the current clipboard and tries to make an numpy array out of it"""
p = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE)
output = p.communicate()
@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 / pyside_matplotlib_example.py
Created August 28, 2012 00:02
Pyside GUI w/embedded matplotlib class in IPython Notebook
from PySide import QtCore, QtGui
import sys
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MatplotlibWidget(FigureCanvas):
def __init__(self, parent=None):
@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