Skip to content

Instantly share code, notes, and snippets.

View JohnSpeno's full-sized avatar
🦋
I may never respond.

John Speno JohnSpeno

🦋
I may never respond.
View GitHub Profile
@JohnSpeno
JohnSpeno / My Python style guide.md
Last active September 20, 2019 12:25
John Speno's personal Python style guide

John Speno's Python Style Guide

If you don't use it, you are dead to me.

  • Avoid long lines and do not use a backslash for line continuation. Figure it out. Look at some of these examples for help:
zone_sums = dict(
    one_free=Sum('ports__one_gig_available'),
 one_total=Sum('ports__one_gig_total'),
@JohnSpeno
JohnSpeno / pythonrc
Created March 3, 2013 17:45
My .pythonrc file
import rlcompleter
import atexit
import os
import readline
import sys
from pydoc import help
# Make TAB complete stuff
readline.parse_and_bind("tab: complete")
@JohnSpeno
JohnSpeno / .tmux.conf
Last active December 15, 2015 07:29 — forked from jgeewax/.tmux.conf
# Leader key should be the same as screen (C-a)
set -g prefix C-a
# Double tap to go to previous window
bind C-a last-window
# Splitting windows should use | and -
unbind %
bind | split-window -h
bind - split-window -v

Upgrade Django from 1.1 to 1.5.1. This highlights some of the issues that one may encounter when updating Django. It's not possible to cover every case, but this should provide a good general starting point.

Change to DATABASES variable in settings.py.

Django now supports multiple databases and changes are needed to how the database connections are defined.

  • Changed in Django 1.2
  • Change Required by Django 1.4
  • Source:
#!/bin/sh
#
# gunicorn_sr Startup script for gunicorn for sr
#
# chkconfig: - 86 14
# processname: gunicorn
# pidfile:
# description: Python application server
#
### BEGIN INIT INFO
@JohnSpeno
JohnSpeno / .screenrc
Created September 24, 2014 17:37
my .screenrc file
shell -$SHELL
startup_message off
defscrollback 8192
bind j focus down
bind k focus up
bind t focus top
bind b focus bottom
bind W windowlist
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
class PeekIter:
""" Create an iterator which allows you to peek() at the
next item to be yielded. It also stores the exception
and re-raises it on the next next() call.
"""
def __init__(self, iterable):
self._exn = None
self._it = iter(iterable)
self._peek = next(self._it)
create type numeric_quartiles_plus as (
min float,
q05 float,
q10 float,
q25 float,
q50 float,
q75 float,
q90 float,
q95 float,
max float,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="""
I never freaking remember argparse syntax and the docs are so all over the place
that I need this for an example.