Skip to content

Instantly share code, notes, and snippets.

View tom-henderson's full-sized avatar
🇳🇿

Tom Henderson tom-henderson

🇳🇿
View GitHub Profile
@tom-henderson
tom-henderson / settings.py
Last active August 29, 2015 14:15
Highlighting active navbar menu items in Django
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
)
@tom-henderson
tom-henderson / forms.py
Created February 23, 2015 23:24
Django ModelForm with related One to One models.
class CustomerForm(forms.ModelForm):
class Meta:
model = Customer
fields = [
'name',
'delivery_addressee',
'billing_addressee',
]
def __init__(self, *args, **kwargs):
# This file contains a list of unacceptable file name/file type and creator patterns, one per line.
# It also contains some 'helpful' text that replaces the attachment.
#
# The help text is one or more lines that start with a colon.
# The attachment names are case-insensitive, and use the DOS wildcard convention
# of * and ?
# Macintosh file type and creator patterns can be specified as well,
# using the syntax 'TTTT:CCCC' where TTTT is the file type, and CCCC
# is the creator. Use ? as a wildcard character.
#
@tom-henderson
tom-henderson / 90-graylog2.conf
Last active August 29, 2015 14:19
Greylog Configuration
$template GRAYLOGRFC5424,"%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msg%\n"
*.* @syslog.example.com:514;GRAYLOGRFC5424
@tom-henderson
tom-henderson / deploy.sh
Last active August 29, 2015 14:19
Django deploy script
#!/bin/bash
echo "Activating virtualenv"
source /home/django/.virtualenvs/my_app/bin/activate
source /home/django/.virtualenvs/my_app/bin/postactivate
which python
echo
echo "Fetching master branch"
cd /opt/my_app
@tom-henderson
tom-henderson / unifi-auth.py
Last active January 11, 2021 14:24
Authenticating unifi wireless guest users.
import json
import ssl
import requests
from requests_toolbelt import SSLAdapter
# URL or IP Address of the unifi controller:
PORTAL_URL = 'https://ubiquiti.example.com/'
# Username and password for the unifi controller:
PORTAL_LOGIN_PARAMS = {
@tom-henderson
tom-henderson / fc-pause-mirror.bat
Created July 9, 2015 01:32
Pause and resume FirstClass mirroring
echo off
cls
:: Run this script before backing up the mirror drive.
:: This script will exit with 0 if the mirror was successfully paused.
:: Any other exit code means the mirror is not safe to back up.
:: The MCHECK command returns a valid error level code.
:: The return codes are checked in descending order.
:: Any code greater than or equal to will match the tested error condition.
@tom-henderson
tom-henderson / Export Chrome windows to text.scpt
Last active August 29, 2015 14:24
Export Chrome windows to text
(*
◸ Veritrope.com
Export All Chrome Tabs to a Text File
VERSION 1.0
September 8, 2012
// INSPIRED BY:
Francesco Di Lorenzo (@frankdilo)
// UPDATE NOTICES
@tom-henderson
tom-henderson / config.php
Created January 16, 2016 03:59
Observium geocoding setup options
// Observium Geocoding settings
$config['geocoding']['enable'] = TRUE; // Enable geocoding
$config['geocoding']['api'] = 'yahoo'; // Geocoding API
$config['geocoding']['default']['lat'] = "37.7463058"; // Default latitude for devices
$config['geocoding']['default']['lon'] = "-25.6668573"; // Default longitude for devices
$config['location_menu_geocoded'] = FALSE; // Build locaion menu from location data
$config['frontpage']['map']['region'] = "world"; // Map region
$config['frontpage']['map']['center']['lat'] = "37.7463058"; // Initial latitude for map
$config['frontpage']['map']['center']['lng'] = "-25.6668573"; // Initial longitude for map
$config['frontpage']['map']['zoom'] = '14'; // Initial zoom level for map
firewall {
all-ping enable
broadcast-ping disable
ipv6-receive-redirects disable
ipv6-src-route disable
ip-src-route disable
log-martians enable
name WAN_IN {
default-action drop
description "WAN to internal"