Skip to content

Instantly share code, notes, and snippets.

@fission6
fission6 / geos.rb
Created November 23, 2013 21:06
If you are using and old version of django (1.4 or lower) but are installing the latest dependancies for GEO DJANGO, specifically GDAL using brew install gdal. The below maybe helpful. This is a brew recipe to install geos on macos that plays well with older django versions and avoids "django.contrib.gis.geos.error.GEOSException: Could not parse…
require 'formula'
class Geos < Formula
homepage 'http://trac.osgeo.org/geos'
url 'http://download.osgeo.org/geos/geos-3.4.2.tar.bz2'
sha1 'b8aceab04dd09f4113864f2d12015231bb318e9a'
option :universal
option :cxx11
@fission6
fission6 / managers.py
Created June 10, 2016 13:37
Django 1.9.6 Case Insensitive Username Logins
from django.db.models.functions import Lower
from django.db.models import CharField
from django.contrib.auth.models import UserManager as DjangoUserManager
CharField.register_lookup(Lower, 'lower')
class UserManager(DjangoUserManager):
"""
Allow case insensitive usernames for authenticating.
def orders_report(request, company):
import cProfile
pr = cProfile.Profile()
pr.enable()
....code to profile
# stop profiling and output to console
@fission6
fission6 / clean_old_slack_files.py
Created March 16, 2017 20:45
Clean out old slack files to free up space
import os
import requests
from datetime import datetime, timedelta
# Days aged
DAYS_AGED = 30
# token from https://api.slack.com/web
TOKEN = os.environ.get('SLACK_TOKEN') # set an env variable for slack token
ENDPOINT = 'https://slack.com/api/{}'