Skip to content

Instantly share code, notes, and snippets.

View craigloftus's full-sized avatar

Craig Loftus craigloftus

  • Dendra Systems
  • Oxford, UK
View GitHub Profile
@craigloftus
craigloftus / capacity_script.py
Created February 6, 2016 12:56
Simple script to count bicycle parking capacity from overpass data
#!/usr/bin/env python
import json
geojson = json.load(open('bicycle_parking.geojson', 'r'))
features = geojson['features']
with_capacity = [f for f in features if f['properties'].get('capacity')]
without_capacity = [f for f in features if not f['properties'].get('capacity')]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@craigloftus
craigloftus / nginx_server.conf
Last active August 29, 2015 14:10
Example of SSL config for nginx
ssl_session_cache shared:SSL:1m; # 1MB is ~4000 sessions, if it fills old sessions are dropped
ssl_session_timeout 1440m; # Reuse sessions for 24hrs
# Redirect all traffic to SSL
server {
listen 80 default;
server_name www.example.com example.com;
access_log off;
error_log off;
return 301 https://example.com$request_uri;
@craigloftus
craigloftus / reboot-required.sh
Last active August 29, 2015 14:05
This is an ultra simple shell script to send an email notification if an Ubuntu machine needs a reboot for packages to be upgraded.
#!/bin/bash
# Simple script to send an email when a server restart is required.
# Requires mailutils package and will send the email to the local user by default.
if [ ! -f /var/run/reboot-required ]; then
# No reboot required
exit 0
else
# Reboot required, so notify by email