Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pzrq's full-sized avatar

Peter Schmidt pzrq

View GitHub Profile
@pzrq
pzrq / NSW_LGA_list.txt
Last active January 15, 2020 01:29
List of all local government areas in NSW, without shire suffixes
Albury
Armidale Regional
Ballina
Balranald
Bathurst Regional
Bayside
Bega Valley
Bellingen
Berrigan
Blacktown
@pzrq
pzrq / 0_reuse_code.js
Created June 22, 2016 05:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pzrq
pzrq / subclass_utilities.py
Created February 3, 2016 11:25
Get All Subclasses of a Python Class and Get Concrete Django Models
def get_all_subclasses(python_class):
"""
Helper function to get all the subclasses of a class.
:param python_class: Any Python class that implements __subclasses__()
"""
python_class.__subclasses__()
subclasses = set()
check_these = [python_class]
@pzrq
pzrq / mro_exploration.py
Last active December 15, 2020 07:18
Better PyCharm mixin handling would make it far more useful for Django Class-Based Views, Managers, etc
# -*- coding: utf-8 -*-
"""
# usage: python mro_exploration.py
# https://github.com/pzrq/
Better PyCharm mixin handling would make it far more useful for
Django Class-Based Views, Managers, and in contexts others have identified
such as Werkzeug.
https://youtrack.jetbrains.com/issue/PY-7712
@pzrq
pzrq / test.py
Created March 24, 2015 06:04
SymPy RuntimeError test.py file
from sys import exit
import os
os.environ['SYMPY_USE_CACHE'] = 'no' # 'yes', 'no', 'debug'
from sympy import *
x, y, a, t, x_1, x_2, z, s = symbols('x y a t x_1 x_2 z s')
def test_issue_4737():
@pzrq
pzrq / bash and vi
Created November 18, 2014 23:08
PostgreSQL view logged queries OSX
# For OSX Yosemite 10.10 `brew install postgres` [v9.3.5.1]
DATA_DIR='/usr/local/var/postgres/'
vi ${DATA_DIR}postgresql.conf
# Find log_statement in vi, then uncomment and set to 'all'
/log_statement
log_statement = 'all'
# Save / Exit vi
# Remember to set log_statement = 'none' when finished with debugging
@pzrq
pzrq / form_fields.py
Last active August 29, 2015 14:09
Django Lazy ModelChoiceField
"""
In practice with four subclasses of LazyModelChoiceField
across a large project, we found existing __deepcopy__ based
alternatives such as
https://djangosnippets.org/snippets/2973/
simply didn't work in all the circumstances we needed them to.
Tested against Python 2.7 and Python 3.4 with Django 1.6.8
Hopefully this works for you too :)