Skip to content

Instantly share code, notes, and snippets.


Andrew Brookins abrookins

View GitHub Profile
abrookins /
Last active Jul 15, 2020 — forked from gamesbrainiac/
Andrew B Webinar Info


6th August 2020 - 7 PM CEST


Database Performance Tips with Django



Keybase proof

I hereby claim:

  • I am abrookins on github.
  • I am redis_andrew ( on keybase.
  • I have a public key ASC0tvyGuXJgPXJVzqX59sFJTHHXTMmgRVxkB3OaF7X_cwo

To claim this, I am signing this object:

abrookins / join_promotion
Created Jul 17, 2019 — forked from akaariai/join_promotion
Django join promotion
View join_promotion
Join promotion in the ORM
[NOTE: We need better terms than promote and demote for changing the join
type. These terms are extremely easy to mix up. Maybe the ORM methods could
be to_inner_joins and to_louter_joins instead of promote_joins and demote_joins?
I tried to clean up the mis-usages of promotion/demotion but there could still
be some cases where these are mixed up]
abrookins / gist:3440646
Created Aug 23, 2012
Set the path of an ImageField in Django
View gist:3440646
from django.db import models
# Assuming this model.
class Example(models.Model):
image = models.ImageField(upload_to="somewhere/special")
# You want to set this field to point to an existing image (in a script, or a view, etc.).
example = Example.objects.get(id=1)
View cVimrc
set smoothscroll
let blacklists = ["*", "*://*", "@*"]
View sVimrc
let mapleader = ","
let newtaburl = ""
let blacklists = ["*://*", "*://*", "*://*", "*://*", "*://**"]
let scrollstep = 20
map "<Leader> m" zoomPageIn
abrookins / init.lua
Last active Mar 30, 2017
Restart fastkit with Hammerspoon when DNS changes
View init.lua
local network =
local fastkitPath = '~/.rbenv/shims/fastkit'
local home = '/Users/andrew'
function fastkitCompleted(exitCode, stdOut, stdErr)
if exitCode ~= 0 then"Fastkit failed to reload")
abrookins / gist:1933635
Created Feb 28, 2012
A Sublime Text 2 Django project file with a test runner build system
View gist:1933635
"path": "django_project_dir"
"path": "lib/python2.7"
abrookins / gist:5479607
Last active Dec 16, 2015
Example code for in-memory proximity search with Python (2).
View gist:5479607
import flask
from flask.ext.cache import Cache
from siren import util, crime_tracker
from siren.decorators import jsonp
app = flask.Flask(__name__)
app.config.from_envvar('SIREN_SETTINGS', silent=True)
cache = Cache(app)
crime_db = crime_tracker.PortlandCrimeTracker()
abrookins / gist:5478445
Last active Dec 16, 2015
Example code for in-memory proximity search with Python (1).
View gist:5478445
from scipy.spatial import cKDTree
from scipy import inf
# ... Some code removed for clarity ...
class PortlandCrimeTracker(object):
def __init__(self, db_filename=DEFAULT_DATABASE_NAME):
crime_db = self.load_crimes_db(db_filename)
You can’t perform that action at this time.