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
  • 04:26 (UTC -04:00)
  • X @fish2000
View GitHub Profile
@fish2000
fish2000 / hexagons-actionscript-1.as
Created January 17, 2012 19:36
Ten-year-old ActionScript 1 code for manipulating a grid of hexagons
/// init
/// build grid
g = new Array();
g[0] = new Array();
g[1] = new Array();
/// do grids
@fish2000
fish2000 / yo-dogg-i-heard-you-like-metaprogramming.py
Created January 17, 2012 19:39
Really sketchy and monkeypatch-y test for rewriting classes in the __main__ namespace (from before django-imagekit switched from class-based ImageProcessors to an instance-based API).
#!/usr/bin/env python
# encoding: utf-8
"""
yodogg.py
Created by FI$H 2000 on 2011-09-02.
Copyright (c) 2011 Objects In Space And Time, LLC. All rights reserved.
"""
@fish2000
fish2000 / the-c-in-cython-is-for-quote-cunty-compiler-pragmatics-endquote.pyx
Created January 17, 2012 19:41
Problematic Cython implementation of some basic image-fuckery implementations.
#!/usr/bin/env python
# encoding: utf-8
# cython: profile=True
"""
processors.pyx
Cython alternative implementations of some of the ImageProcessors from imagekit.processors.
Created by FI$H 2000 on 2011-10-06.
Copyright (c) 2011 Objects In Space And Time, LLC. All rights reserved.
@fish2000
fish2000 / pyascii.py
Created January 17, 2012 19:43
PyGame-based image ascii-art-ifier that I got from someone's blog and then edited a little.
#!/usr/bin/env python
# encoding: utf-8
"""
pyascii.py
Render an image as ASCII art using PyGame.
Originally by tommih:
http://tommih.blogspot.com/2009/01/image-to-ascii-art-with-python.html
@fish2000
fish2000 / I-smell-an-abstraction-layer-in-here-guys.py
Created January 17, 2012 19:45
This ended up being some boilerplate I had to put into all my django-imagekit forks' model fields' functions that got called on pre_save/post_save signals.
def clear_exif_data(self, **kwargs): # signal, sender, instance
"""
Stores ICC profile data in the field before saving, and refreshes
the profile hash if an ICCHashField has been specified.
"""
instance = kwargs.get('instance')
@fish2000
fish2000 / solr-reschematize.py
Created January 17, 2012 19:48
Untested Python snippet to automatically update a Solr instances' schema.xml with the puke from the django-haystack build_solr_schema command.
import sys, os, uuid, tempfile
from django.core.management import call_command
def main():
# create /tmp/log with default bitmask of 0777
os.makedirs('/tmp/log')
#
@fish2000
fish2000 / hyperlocal-temporary.sh
Created January 17, 2012 19:54
Spin up a temporary Vagrant VirtualBox machine instance
#!/bin/sh
#
# where are we?
# courtesy http://stackoverflow.com/a/246128/298171
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
DEST=/tmp/ovst2-$$
class TaggedQuerySet(JSONQuerySet):
count_re = re.compile(r'(select) (distinct) (.+) (count)(.*)(group by)(.+)(asc)$', flags=re.S|re.I|re.M)
@delegate
def tagged(self, name=None):
""" Return a QuerySet of the model instances tagged with the named tag. """
if name:
try:
t = tags.Tag.objects.filter(name=name).get()
@fish2000
fish2000 / gearman-upgrade-output.txt
Created February 21, 2012 21:33
Homebrew Gearman Link Flag Problem
ASIO-OTUS:tmp$ brew -v upgrade
Homebrew 0.8.1
==> Upgrading 2 outdated packages, with result:
gearman 0.28, gearman-php 1.0.1
==> Upgrading gearman
==> Downloading http://launchpad.net/gearmand/trunk/0.28/+download/gearmand-0.28.tar.gz
File already downloaded in /Users/fish/Library/Caches/Homebrew
/usr/bin/tar xf /Users/fish/Library/Caches/Homebrew/gearman-0.28.tar.gz
==> ./configure --prefix=/usr/local/Cellar/gearman/0.28
./configure --prefix=/usr/local/Cellar/gearman/0.28
@fish2000
fish2000 / homebrew-gificle-error-and-fix-output.txt
Created February 22, 2012 05:40
Homebrew Gifsicle '-lX11' Error and Fix
ASIO-OTUS:tmp$ brew -v install gifsicle
Homebrew 0.8.1
==> Downloading http://www.lcdf.org/gifsicle/gifsicle-1.61.tar.gz
/usr/bin/curl -qf#LA Homebrew 0.8.1 (Ruby 1.8.7-249; Mac OS X 10.7.3) http://www.lcdf.org/gifsicle/gifsicle-1.61.tar.gz -o /Users/fish/Library/Caches/Homebrew/gifsicle-1.61.tar.gz
######################################################################## 100.0%
/usr/bin/tar xf /Users/fish/Library/Caches/Homebrew/gifsicle-1.61.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/gifsicle/1.61 --enable-all
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/gifsicle/1.61 --enable-all
checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes