Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dracos
dracos / venv-setup.sh
Created March 10, 2016 13:56
Installing python2 & python3 and virtualenv (Ubuntu 14.04)
# Python 2
sudo apt-get install python-pip
pip install --user virtualenv
python ~/.local/bin/virtualenv venv2
# Python 3, option 1
sudo apt-get install python3-pip
pip3 install --user virtualenv
python3 ~/.local/bin/virtualenv venv3
# Python 3, option 2
sudo apt-get install python3.4-venv
@dracos
dracos / gist:6307176
Last active September 1, 2017 20:55
Stopping the daemon fixmystreet app, and starting it in debug mode, printing everything to console
$ sudo /etc/init.d/fixmystreet stop
$ sudo /etc/init.d/nginx stop
$ sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
$ sudo su - fms
$ cd /var/www/fixmystreet/fixmystreet
$ script/server
§ mkvirtualenv philtest
New python executable in /Users/matthew/.virtualenvs/philtest/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/matthew/.virtualenvs/philtest/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/matthew/.virtualenvs/philtest/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/matthew/.virtualenvs/philtest/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/matthew/.virtualenvs/philtest/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/matthew/.virtualenvs/philtest/bin/get_env_details
(philtest) § pip install watchdog libsass
Collecting watchdog
@dracos
dracos / changelog.php
Created August 18, 2017 12:29
Hook that passes/fails a PR based upon whether we updated the changelog
<?php
$secret = '...';
$token = '...';
$payload = $_POST['payload'];
$signature_header = $_SERVER['HTTP_X_HUB_SIGNATURE'];
$signature_calc = 'sha1=' . hash_hmac('sha1', 'payload=' . urlencode($payload), $secret, false);
if (!hash_equals($signature_header, $signature_calc)) {
exit("Signature did not match");
@dracos
dracos / betaparl-twfy-match.csv
Last active August 12, 2017 18:27
CSV matching TWFY IDs with beta.parl person IDs (and photo IDs where present)
TheyWorkForYou person ID beta.parliament person ID beta.parliament photo ID
24769 http://id.ukpds.org/2PbBvbwn http://id.ukpds.org/cu8BXNWP
24934 http://id.ukpds.org/6jaB1p3Z
24825 http://id.ukpds.org/Ck8wwcfN http://id.ukpds.org/8IaGHQzb
11626 http://id.ukpds.org/eieTmLXh http://id.ukpds.org/cs77uhlV
25304 http://id.ukpds.org/gE4aCnm0
10084 http://id.ukpds.org/jV72kIxb http://id.ukpds.org/yBBERkOB
10383 http://id.ukpds.org/dVovQSbU
11943 http://id.ukpds.org/tJDr7qN7
25654 http://id.ukpds.org/DJ4HErt4 http://id.ukpds.org/QfjSFljl
@dracos
dracos / uk-council-homepages.csv
Last active July 6, 2017 20:54
List of councils in UK and their homepages, using GOV.UK data
gss govuk_slug homepage_url
S12000033 aberdeen http://www.aberdeencity.gov.uk/
S12000034 aberdeenshire http://www.aberdeenshire.gov.uk/
E07000223 adur http://www.adur-worthing.gov.uk/
E07000026 allerdale http://www.allerdale.gov.uk
E07000032 amber-valley http://www.ambervalley.gov.uk/
S12000041 angus http://www.angus.gov.uk
N09000001 antrim-newtownabbey http://www.antrimandnewtownabbey.gov.uk
N09000011 ards-and-north-down http://www.ardsandnorthdown.gov.uk
S12000035 argyll-and-bute http://www.argyll-bute.gov.uk
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dracos
dracos / three-data-checker.py
Created April 2, 2017 13:51
Script to tell me how much data I have left on my 3 SIM
#!/usr/bin/env python
import os
import re
import requests
s = requests.Session()
class ThreeWebsite(object):
username = os.environ['PHONE_NUMBER']