Skip to content

Instantly share code, notes, and snippets.

@mbylstra
mbylstra / gist:aae6eac98d162a5cc9c2
Last active September 20, 2016 06:32
python mixin inheritance
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# MixinParent
# |
# Mixin A
# └--┐ |
# B
@mbylstra
mbylstra / gist:385fa8cbf22e58b3aa62
Last active December 3, 2015 13:38
django 1.7+ standalone script
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
django.setup()
################################################################################
@mbylstra
mbylstra / gist:c33077198227115ae590
Created March 18, 2015 06:19
turn on/off psql pager (annoying for \dt)
\pset pager
@mbylstra
mbylstra / gist:813d1a9c25cf671bb1a4
Created March 18, 2015 05:27
linux: temporarily change timezone for ls command
env TZ=Australia/Melbourne ls -al
@mbylstra
mbylstra / django_manage_daemon.yml
Created October 8, 2014 12:37
An Ansible playbook for daemonising long running django manage.py commands using runit
---
- hosts: django
user: root
vars:
- runit_app_dir: /etc/sv
- runit_enabled_dir: /etc/service
- dj_manage_daemons:
- slug: "unique_name_slug_1"
@mbylstra
mbylstra / gist:9412f80ffcaad3d76474
Created October 5, 2014 09:11
remove all .pyc files recursively
find . -name "*.pyc" -exec rm '{}' ';'
@mbylstra
mbylstra / gist:415501b38544d1e6db02
Created August 27, 2014 02:12
show me nginx access.log 500's with surrounding 10 lines.
awk '{ print $9, $7}' access.log | grep -C 10 '^500'
@mbylstra
mbylstra / gist:1409f46992c81b6f0e6e
Created August 22, 2014 07:57
recursively sort python files by number of lines of code
find . -name '*.py' | xargs wc -l | sort -k1 -rg | less