Skip to content

Instantly share code, notes, and snippets.

View abrookins's full-sized avatar

Andrew Brookins abrookins

View GitHub Profile
@abrookins
abrookins / gist:5478445
Last active December 16, 2015 18:29
Example code for in-memory proximity search with Python (1).
from scipy.spatial import cKDTree
from scipy import inf
# ... Some code removed for clarity ...
class PortlandCrimeTracker(object):
DEFAULT_DATABASE_NAME = 'db'
def __init__(self, db_filename=DEFAULT_DATABASE_NAME):
crime_db = self.load_crimes_db(db_filename)
@abrookins
abrookins / gist:5479607
Last active December 16, 2015 18:39
Example code for in-memory proximity search with Python (2).
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
abrookins / gist:1933635
Created February 28, 2012 16:57
A Sublime Text 2 Django project file with a test runner build system
{
"folders":
[
{
"path": "django_project_dir"
},
{
"path": "lib/python2.7"
}
],
@abrookins
abrookins / init.lua
Last active March 30, 2017 22:11
Restart fastkit with Hammerspoon when DNS changes
local network = hs.network.configuration.open()
local fastkitPath = '~/.rbenv/shims/fastkit'
local home = '/Users/andrew'
function fastkitCompleted(exitCode, stdOut, stdErr)
if exitCode ~= 0 then
hs.alert.show("Fastkit failed to reload")
log.d(stdOut)
end
end
@abrookins
abrookins / sVimrc
Last active September 5, 2017 16:12
let mapleader = ","
let newtaburl = "https://google.com"
let blacklists = ["*://safari.atlassian.net/*", "*://mail.google.com/*", "*://inbox.google.com/*", "*://calendar.google.com/*", "*://*.slack.com/*"]
let scrollstep = 20
map "<Leader> m" zoomPageIn
set smoothscroll
let blacklists = ["https://mail.google.com/*", "*://mail.google.com/*", "@https://mail.google.com/mail/*"]
@abrookins
abrookins / join_promotion
Created July 17, 2019 05:14 — forked from akaariai/join_promotion
Django 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]

Keybase proof

I hereby claim:

  • I am abrookins on github.
  • I am redis_andrew (https://keybase.io/redis_andrew) on keybase.
  • I have a public key ASC0tvyGuXJgPXJVzqX59sFJTHHXTMmgRVxkB3OaF7X_cwo

To claim this, I am signing this object:

@abrookins
abrookins / andrew.md
Last active July 15, 2020 03:11 — forked from gamesbrainiac/andrew.md
Andrew B Webinar Info

Date/Time

6th August 2020 - 7 PM CEST

Title

Database Performance Tips with Django

Description

from peewee import *
import datetime
db = SqliteDatabase('my_database.db')
class User(Model):
username = CharField(unique=True)