Skip to content

Instantly share code, notes, and snippets.

import sys
from collections import namedtuple
from struct import unpack, calcsize
Header = namedtuple('Header', 'id totallength wavefmt format pcm channels frequency bytes_per_second bytes_by_capture bits_per_sample data bytes_in_data')
header_format = '4si8sihhiihh4si'
header_len = calcsize(header_format)
def read_wav(fname):
"Read in a wav file with simple header parsing, and return the sum of the absolute value of its samples"
@aisipos
aisipos / gist:2026960
Created March 13, 2012 05:18
Venus Jupiter Separation
import ephem, datetime, math
import matplotlib.pyplot as plt
venus = ephem.Venus()
jupiter = ephem.Jupiter()
observer=ephem.city('Los Angeles')
dates = [datetime.date(2012,3,1) + datetime.timedelta(days=x) for x in range(180)]
sep = []
for date in dates:
@aisipos
aisipos / gist:5339354
Created April 8, 2013 18:42
Output of a full `brew install -v python` I had a previous brewed python 2.7.3, which I removed via `brew rm python`
This file has been truncated, but you can view the full file.
==> Downloading http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python-2.7.4.tar.bz2
tar xf /Library/Caches/Homebrew/python-2.7.4.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python/2.7.4 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.4/share --datadir=/usr/local/Cellar/python/2.7.4/share --enable-framework=/usr/local/Cellar/python/2.7.4/Frameworks --without-gcc CFLAGS=-I/usr/local/include -I/usr/local/opt/sqlite/include LDFLAGS=-L/usr/local/lib -L/usr/local/opt/sqlite/lib MACOSX_DEPLOYMENT_TARGET=10.8
./configure --prefix=/usr/local/Cellar/python/2.7.4 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.4/share --datadir=/usr/local/Cellar/python/2.7.4/share --enable-framework=/usr/local/Cellar/python/2.7.4/Frameworks --without-gcc CFLAGS=-I/usr/local/include -I/usr/local/opt/sqlite/include LDFLAGS=-L/usr/local/lib -L/usr/local/opt/sqlite/lib MACOSX_DEPLOYMENT_TARGET=10.8
checking build system type... x86_64-apple-darwin12.3.0
check
@aisipos
aisipos / gist:5340011
Created April 8, 2013 20:04
Output of `pip install -v -v -v --force --upgrade pip`
» pip install -v -v -v --force --upgrade pip
Downloading/unpacking pip
Running setup.py egg_info for package pip
Running command python setup.py egg_info
running egg_info
writing requirements to pip-egg-info/pip.egg-info/requires.txt
writing pip-egg-info/pip.egg-info/PKG-INFO
writing top-level names to pip-egg-info/pip.egg-info/top_level.txt
writing dependency_links to pip-egg-info/pip.egg-info/dependency_links.txt
writing entry points to pip-egg-info/pip.egg-info/entry_points.txt
@aisipos
aisipos / brew_pyside_error.txt
Created December 27, 2013 09:22
Debug output for trying to brew install pyside
This file has been truncated, but you can view the full file.
brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: e126ec926b38ccfcc7c46d3ba32b85afd1ba63d2
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit haswell
OS X: 10.9.1-x86_64
Xcode: 5.0.2
CLT: 5.0.1.0.1.1382131676
@aisipos
aisipos / shiboken.txt
Created December 27, 2013 17:57
brew install shiboken --with-python3
==> Downloading http://download.qt-project.org/official_releases/pyside/shiboken-1.2.1.tar.bz2
Already downloaded: /Library/Caches/Homebrew/shiboken-1.2.1.tar.bz2
==> Verifying shiboken-1.2.1.tar.bz2 checksum
tar xf /Library/Caches/Homebrew/shiboken-1.2.1.tar.bz2
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file ext/sparsehash/google/sparsehash/sparseconfig.h
brew: PYTHONPATH=/usr/local/Cellar/shiboken/1.2.1/lib/python2.7/site-packages:/usr/local/Cellar/shiboken/1.2.1/libexec/lib/python2.7/site-packages
==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/shiboken/1.2.1 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_TESTS=ON -DPYTHON_INCLUDE_DIR='/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Headers' -DPYTHON_LIBRARY='/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib' ..
-- The C compiler identification is Clang 5.0.0
@aisipos
aisipos / shiboken2.txt
Created December 28, 2013 18:59
rm /usr/local/bin/python3.2* brew install -v --with-python3 shiboken
==> Downloading http://download.qt-project.org/official_releases/pyside/shiboken-1.2.1.tar.bz2
Already downloaded: /Library/Caches/Homebrew/shiboken-1.2.1.tar.bz2
==> Verifying shiboken-1.2.1.tar.bz2 checksum
tar xf /Library/Caches/Homebrew/shiboken-1.2.1.tar.bz2
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file ext/sparsehash/google/sparsehash/sparseconfig.h
brew: PYTHONPATH=/usr/local/Cellar/shiboken/1.2.1/lib/python2.7/site-packages:/usr/local/Cellar/shiboken/1.2.1/libexec/lib/python2.7/site-packages
==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/shiboken/1.2.1 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_TESTS=ON -DPYTHON_INCLUDE_DIR='/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Headers' -DPYTHON_LIBRARY='/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib' ..
-- The C compiler identification is Clang 5.0.0
# npm mirroring, courtesy @jbuck and Mozilla.
# See https://github.com/jbuck/npm-readonly-mirror
curl npmrc.zeke.xxx >> .npmrc
git add .npmrc
git commit -m "mozilla .npmrc"
git push heroku master

Keybase proof

I hereby claim:

  • I am aisipos on github.
  • I am aisipos (https://keybase.io/aisipos) on keybase.
  • I have a public key ASD-ZBCV-bWLgrbYByevZNFD5_2rMEunMnZnM3EGqtfgpgo

To claim this, I am signing this object:

import simplejson as json
import lxml
class objectJSONEncoder(json.JSONEncoder):
"""A specialized JSON encoder that can handle simple lxml objectify types
>>> from lxml import objectify
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>")
>>> objectJSONEncoder().encode(obj)
'{"price": 1.5, "author": "W. Shakespeare"}'
"""