Skip to content

Instantly share code, notes, and snippets.

View fish2000's full-sized avatar
👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!

Alexander Böhn fish2000

👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!
  • Objects in Space and Time, LLC
  • Baltimore, MD
  • 23:44 (UTC -04:00)
  • X @fish2000
View GitHub Profile
@fish2000
fish2000 / OpenLibraryURLs-20100401-002050.json
Created September 9, 2011 20:19
My latest python serialization shootout: JSON libraries and friends compete on the green field of a new MacBook Air Core i7. Code, data, and the results -- all in one gist.
{
"9781568981352": {
"small": {
"url": "http://covers.openlibrary.org/b/isbn/9781568981352-S.jpg?default=false",
"source": "openlibrary"
},
"large": {
"url": "http://covers.openlibrary.org/b/isbn/9781568981352-L.jpg?default=false",
"source": "openlibrary"
},
@fish2000
fish2000 / cest-la-guerre.py
Created September 10, 2011 01:45
I had to delete this but I will miss the melodramatic comments
# If everything were perfectly predictable, we'd be able
# to replace these next two ifs with one that considers
# whether addendum.__package__ == addendumstring ... but no.
# C'est la guerre.
if hasattr(addendum, '__package__'):
if addendum.__package__ not in (None, ''):
@fish2000
fish2000 / namespaced-urls.py
Created October 16, 2011 01:57
Creating URL namespaces in Django
from django.conf.urls import patterns, include, url
# you can only define a namespace for urls when calling include() -- hence this rigamarole:
app_patterns = patterns('',
url(r'^(?P<pk>[\w\-]+)/$', 'yourapp.views.your_view_function',
name="your-view"),
)
urlpatterns = patterns('',
@fish2000
fish2000 / homebrew-linker-error-log-spew.log
Created December 3, 2011 01:58
Pango-sans-ENV.x11 linker error
ASIO-OTUS:tmp$ brew remove pango
Uninstalling /usr/local/Cellar/pango/1.29.4...
ASIO-OTUS:tmp$ brew edit pango
ASIO-OTUS:tmp$ brew -v install pango
Homebrew 0.8
==> Downloading http://ftp.gnome.org/pub/gnome/sources/pango/1.29/pango-1.29.4.tar.bz2
/usr/bin/curl -f#LA Homebrew 0.8 (Ruby 1.8.7-249; Mac OS X 10.7.2) http://ftp.gnome.org/pub/gnome/sources/pango/1.29/pango-1.29.4.tar.bz2 -o /Users/fish/Library/Caches/Homebrew/pango-1.29.4.tar.bz2
######################################################################## 100.0%
/usr/bin/tar xf /Users/fish/Library/Caches/Homebrew/pango-1.29.4.tar.bz2
==> ./configure --disable-dependency-tracking --disable-debug --prefix=/usr/local/Cellar/pango/1.29.4 --enable-man --with-x --with-html-dir=/usr/local/Cellar/pango/1.29.4/share/doc
@fish2000
fish2000 / vagrant-provisioning-script.sh
Created January 13, 2012 16:50
Provision Me Up A Boxy Vagrant
#!/bin/sh
#sudo chmod -R a+rw /etc/apt
#echo 'deb http://http.us.debian.org/debian unstable main contrib non-free' > /etc/apt/sources.list
export PATH=/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:${PATH}
sudo apt-get -y update
sudo apt-get --force-yes -f --install-recommends --fix-missing upgrade
sudo apt-get -y purge python2.6 python2.6-dev python2.7 python2.7-dev python3-minimal python3.2-minimal python3 python3.2
sudo apt-get -y autoclean
@fish2000
fish2000 / needs-moar-type-system.py
Created January 17, 2012 01:29
Needs moar type system.
from django.db.models.loading import cache
from apps.mercer import models as mx
def print_mf(mf):
print "%15s %20s %20s %20s" % (mf.db_column,mf.column,mf.name,mf.attname)
for modl in [cache.get_model('mercer', mi) for mi in mx.__dict__.keys()]:
if modl is not None and not modl._meta.object_name.lower().startswith('mm'):
@fish2000
fish2000 / strip-pdf-metadata.py
Created January 17, 2012 19:18
A very bare-bones PDF metadata-clobberer Python script.
#!/usr/bin/env python
# encoding: utf-8
"""
strip-pdf-metadata.py
Created by FI$H 2000 on 2012-01-17.
Copyright (c) 2012 Objects In Space And Time, LLC. All rights reserved.
See also:
@fish2000
fish2000 / python-flann-example.py
Created January 17, 2012 19:27
Trivial FLANN example snippet in Python
from pyflann import *
from numpy import *
from numpy.random import *
dataset = rand(10000, 128)
testset = rand(1000, 128)
flann = FLANN()
result,dists = flann.nn(dataset,testset,5,algorithm="kmeans",
branching=32, iterations=7, checks=16)
print ''
@fish2000
fish2000 / setup.py
Created January 17, 2012 19:29
Setup script for the Python VLFeat bindings
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Installation script for the vlfeat module
"""
import sys, os
from distutils.core import Extension, setup
from distutils.errors import DistutilsFileError
@fish2000
fish2000 / sift-python-qwt-qt.py
Created January 17, 2012 19:31
Somewhere in all of this QT GUI boilerplate, there's a Python SIFT example...
from guidata.qt.QtGui import (QMainWindow, QMessageBox, QSplitter, QListWidget,
QFileDialog, QVBoxLayout, QHBoxLayout, QWidget,
QTabWidget, QMenu, QApplication, QCursor, QFont)
from guidata.qt.QtCore import Qt, QT_VERSION_STR, PYQT_VERSION_STR, SIGNAL
import sys, platform, os.path as osp, os
import numpy as np
from guidata.dataset.datatypes import DataSet, ValueProp
from guidata.dataset.dataitems import (IntItem, FloatArrayItem, StringItem,