Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Schmidt pzrq

View GitHub Profile
@pzrq
pzrq / NSW_LGA_list.txt
Last active Jan 15, 2020
List of all local government areas in NSW, without shire suffixes
View NSW_LGA_list.txt
Albury
Armidale Regional
Ballina
Balranald
Bathurst Regional
Bayside
Bega Valley
Bellingen
Berrigan
Blacktown
@pzrq
pzrq / 0_reuse_code.js
Created Jun 22, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Feb 3, 2016
Get All Subclasses of a Python Class and Get Concrete Django Models
View subclass_utilities.py
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 Dec 15, 2020
Better PyCharm mixin handling would make it far more useful for Django Class-Based Views, Managers, etc
View mro_exploration.py
# -*- 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 Mar 24, 2015
SymPy RuntimeError test.py file
View test.py
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 Nov 18, 2014
PostgreSQL view logged queries OSX
View bash and vi
# 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 Aug 29, 2015
Django Lazy ModelChoiceField
View form_fields.py
"""
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 :)