Skip to content

Instantly share code, notes, and snippets.

View urschrei's full-sized avatar

Stephan Hügel urschrei

View GitHub Profile
@urschrei
urschrei / call.txt
Last active December 19, 2015 19:49
This gist is now a proper repo: https://github.com/urschrei/lovecraft
Iä!
@urschrei
urschrei / CMakeCache.txt
Created July 8, 2013 12:32
OS X 10.8.4 Python 2.7.5 from Python.org Numpy 1.7.1 from pip OpenCV dependencies from Homebrew OpenCV built from source
# This is the CMakeCache file.
# You'll have to modify all instances of /users/sth to your own user path
# Modified PYTHON_LIBRARY:FILEPATH setting: /Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
# For build in directory: /Users/sth/dev/py_tesseract/release
# CMAKE_INSTALL_PREFIX:PATH=/usr/bin
# In order to use Python bindings, prepend /Users/sth/dev/py_tesseract/release:lib to $PYTHONPATH
# It was generated by CMake: /usr/local/Cellar/cmake/2.8.11.1/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
@urschrei
urschrei / latlon_to_bng.py
Last active December 27, 2019 16:29
A function to convert WGS84 lat, long points to BNG (OSGB36) Eastings and Northings. Based entirely on code by Hannah Fry: http://hannahfry.co.uk/2012/02/01/converting-british-national-grid-to-latitude-and-longitude-ii/
import math
def bng(input_lat, input_lon):
"""
Convert WGS84 lat and long (ie. from GPS) to OSGB36 (BNG)
Expects two floats as input
Returns a tuple of Easting, Northing floats
Accurate to ~5m
For testing purposes:
@urschrei
urschrei / latlong.py
Created May 13, 2013 20:07
Plot a dict of Lat, Lon points in an image. Requires the PIL.
# Courtesy of Charlie Loyd (@vruba), it's a black box for now
# Expects a dict of points, 'points' with keys 'Lat.', and 'Lon.'
from PIL import Image
from math import *
# these are London-specific
latrange = [51, 52]
lonrange = [-1, 1]
@urschrei
urschrei / extract_exif_gps.py
Last active October 26, 2023 20:11
Extract GPS data from jpg files, and write it to a CSV. Requires the PIL. Tested (haha) on Python 2.7.x
"""
Extract GPS coordinates and filename, output to CSV file
Run this file from the same directory the images are in
run using ./process_exif.py or python process_exif.py, or
%run process_exif.py from an IPython instance
Ensure you have PIL installed
refer to http://www.exiv2.org/tags.html for a full detailed tag listing
This is what the GPSInfo dict looks like for an iPhone 5 jpg:
@urschrei
urschrei / ipython_pandas_requirements.txt
Created April 30, 2013 15:27
Pip requirements file for installing IPython and Pandas, and running in Notebook mode in a browser
# requirements for Web-based iPython Notebook in Pylab mode
# includes all requirements for Pandas data analysis and plotting
# you should also easy_install readline
# USE A VIRTUALENV
# if on OS X, install XCode and command-line tools before attempting any of this
# I'm leaving out SciPy, because it's SUCH a pain to install
ipython
tornado
pyzmq
pandas
@urschrei
urschrei / gist:5452643
Created April 24, 2013 14:40
Alembic 0.5.0 Postgres Partial Index stack trace
Traceback (most recent call last):
File "/Users/sth/dev/brockley_analytics/venv/bin/alembic", line 8, in <module>
load_entry_point('alembic==0.5.0', 'console_scripts', 'alembic')()
File "/Users/sth/dev/brockley_analytics/venv/lib/python2.7/site-packages/alembic/config.py", line 265, in main
CommandLine(prog=prog).main(argv=argv)
File "/Users/sth/dev/brockley_analytics/venv/lib/python2.7/site-packages/alembic/config.py", line 260, in main
self.run_cmd(cfg, options)
File "/Users/sth/dev/brockley_analytics/venv/lib/python2.7/site-packages/alembic/config.py", line 247, in run_cmd
**dict((k, getattr(options, k)) for k in kwarg)
File "/Users/sth/dev/brockley_analytics/venv/lib/python2.7/site-packages/alembic/command.py", line 123, in upgrade
@urschrei
urschrei / extract_from_gpx.py
Last active June 18, 2024 15:40
Extract basic GPS data (lat, lon, elevation, timestamp) from GPX, and dump it into a CSV file. Requires the gpxpy library.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Output Elevation, Lat, Long, and Timestamp series from GPX to CSV
Requires gpxpy
This script expects your input GPX to be located in a subdir named 'data'
"""
import os
@urschrei
urschrei / gist:5349468
Created April 9, 2013 21:15
A simple coroutine example
def lazy_writer():
with open("out.txt", "w") as o:
while True:
line = (yield)
# do whatever you like to line here
out = "%s%s\n" % (line, " added")
o.write(out)
wl = lazy_writer()
# initialise the coroutine before you send anything in
@urschrei
urschrei / parseml.py
Last active April 1, 2025 02:05
Extract attachments from EML files in the current dir, and write them to the output subdir
#!/usr/bin/env python
"""
2020 update:
- More iterators, fewer lists
- Python 3 compatible
- Processes files in parallel
(one thread per CPU, but that's not really how it works)
"""