Skip to content

Instantly share code, notes, and snippets.

View blorenz's full-sized avatar

Brandon Lorenz blorenz

View GitHub Profile
@blorenz
blorenz / virtualenv_cmd.sh
Last active December 21, 2015 06:29
Activating virtualenvs for use with supervisord example /etc/supervisord.conf: [program:PROJECT] command = /virtualenvs/virtualenv_cmd.sh /virtualenvs/VIRTUALENV python PROJECT/manage.py run_gunicorn -b 127.0.0.1:9920 -t 1200
#!/bin/bash
# Activating virtualenvs for use with supervisord example /etc/supervisord.conf:
# [program:PROJECT]
# command = /virtualenvs/virtualenv_cmd.sh /virtualenvs/VIRTUALENV python PROJECT/manage.py run_gunicorn -b
VIRTUAL_ENV=$1
if [ -z $VIRTUAL_ENV ]; then
echo "usage: $0 </path/to/virtualenv> <cmds>"
exit 1
fi
@blorenz
blorenz / GeoDjango PostGIS
Last active December 21, 2015 08:08
Create a PostGIS database
brew install postgis20
#now link it properly by getting the information for it
brew info postgresql92
initdb /usr/local/var/postgres -E utf8
# YOU MADE NEED TO: rm -rf /usr/local/var/postgres
export POSTGIS_SQL_PATH='/usr/local/Cellar/postgis20/2.0.4/share/postgis/'
# Creating the template spatial database.
@blorenz
blorenz / Common Messups
Last active December 21, 2015 15:08
Common messups and solutions
### MacOSX Postgres won't start
rm /usr/local/var/postgres/postmaster.pid
Users are getting "ImportError: No module named setuptools" when using pip to upgrade a package since distribute-0.7.3 was released.
e.g. when running a command like this: pip install --upgrade pyramid
Solution
.video { position: relative; padding-bottom: 56.25%; /* 16:9 */ height: 0; }
.video img { position: absolute; display: block; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; cursor: pointer; }
.video:after { content: ""; position: absolute; display: block;
background: url(play-button.png) no-repeat 0 0;
top: 45%; left: 45%; width: 46px; height: 36px; z-index: 30; cursor: pointer; }
.video iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
/* image poster clicked, player class added using js */
.video.player img { display: none; }
.video.player:after { display: none; }
@blorenz
blorenz / Ipython Notebook on Mac
Last active December 26, 2015 17:09
Install IPython notebook on Mac for Django
pip install ipython sphinx pyzmq pygments tornado nose django-extensions
easy_install readline pyzmq
# Now can run with django
# ./manage.py shell_plus --notebook
@blorenz
blorenz / gist:cf54986669acb8dc778d
Created July 28, 2014 18:47
Rotating photos based on EXIF data
from PIL import Image, ExifTags
photo = Image.open(args['filename'])
photo_exif = None
try:
# See if this image has any exif
photo_exif = Image.open(args['filename'])._getexif()
except:
pass
from django.forms import widgets
from datapoint.models import Datapoint, Annotation
from rest_framework import serializers
from rest_framework.exceptions import ParseError
from tags.serializers import TagSerializer
from tags.models import Tag
from users.serializers import UserSerializer
import simplejson as json
class Annotation(models.Model):
datapoint = models.ForeignKey('datapoint.Datapoint', related_name='%(class)s_parent_datapoint_relation')
owner = models.ForeignKey('users.User', related_name='%(class)s_creator_relation')
tags = models.ManyToManyField('tags.Tag', related_name="%(class)s_tags_relation", blank=True)
# Key fields from the Annotator JSON Format: http://docs.annotatorjs.org/en/latest/annotation-format.html
annotator_schema_version = models.CharField(max_length=8, blank=True)
text = models.TextField(blank=True)
quote = models.TextField()
@blorenz
blorenz / install.sh
Created October 18, 2016 19:12 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
*PPD-Adobe: "4.3"
*%%%% PPD file for ZPL Label Printer with CUPS.
*%%%% Created by the CUPS PPD Compiler CUPS v2.1.3.
*% Copyright 2007-2014 by Apple Inc.
*% Copyright 1997-2007 by Easy Software Products.
*%
*% These coded instructions, statements, and computer programs are the
*% property of Apple Inc. and are protected by Federal copyright
*% law. Distribution and use rights are outlined in the file "LICENSE.txt"
*% which should have been included with this file. If this file is