Skip to content

Instantly share code, notes, and snippets.

@dracos
dracos / microproxy.py
Created Dec 18, 2016
A very small python HTTP proxy
View microproxy.py
#!/usr/bin/env python
"""
Microproxy
This code is based on http://pastebin.com/mdsAjhdQ based on code based on microproxy.py written by ubershmekel in 2006.
Microproxy is a very small HTTP proxy. It relays all bytes from the client to the server at a socket send and recv level.
It looks at the Host: header to recognise where to connect to.
"""
@dracos
dracos / venv-setup.sh
Created Mar 10, 2016
Installing python2 & python3 and virtualenv (Ubuntu 14.04)
View venv-setup.sh
# 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
View tax-credit.diff
1,2c1
<
< <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
---
> <!DOCTYPE html>
18a18,58
> <meta name=viewport content="initial-scale=1">
> <style>
> @media (max-width: 730px) {
>
View gist:e299671ee6683b5befb3
$ cpanm -L local Catalyst
$ cpanm -L local Catalyst::Devel
$ cpanm -L local Catalyst::View::TT
$ PERL5LIB=local/lib/perl5 local/bin/catalyst.pl MyApp
$ cd MyApp/
$ PERL5LIB=../local/lib/perl5 script/myapp_create.pl view Web TT
$ vim lib/MyApp/Controller/Root.pm # Change index line to $c->stash->{template} = 'foo.html';
$ PERL5LIB=../local/lib/perl5 script/myapp_server.pl
[info] *** Request 1 (0.200/s) [89599] [Thu Oct 8 17:44:14 2015] ***
[debug] Path is "/"
@dracos
dracos / https.py
Created Sep 24, 2015
A minimal HTTPS server in python
View https.py
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import ssl
# Use a higher port if you don't want to have to run as root
httpd = HTTPServer(('', 443), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='server.pem', server_side=True)
httpd.serve_forever()
View bruce.diff
> <meta name=viewport content="initial-scale=1.0">
> <style>
> @media all and (max-width: 40em) {
> body {
> display: -webkit-flex;
> display: flex;
> -webkit-flex-direction: column;
> flex-direction: column;
> }
> body > header {
View free-prescriptions.feature
#http://www.nhs.uk/NHSEngland/Healthcosts/Pages/Prescriptioncosts.aspx
Given a user is dispensed a prescription
When their age is >= 60
Then the prescription cost should be 0
Given a user is dispensed a prescription
And their age is < 16
Then the prescription cost should be 0
@dracos
dracos / overpass.geojson
Last active Aug 29, 2015 — forked from anonymous/overpass.geojson
OpenStreetMap allotments within the Birmingham council boundary
View overpass.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dracos
dracos / postactivate
Created Feb 22, 2015
Using virtualenv for ruby gems
View postactivate
# Put this in your virtualenv's postactivate
# (if you're using virtualenvwrapper, add to
# ~/.virtualenvs/postactivate (or wherever))
export GEM_HOME="$VIRTUAL_ENV/gems"
export PATH="$GEM_HOME/bin":$PATH
# If you don't want your default ruby gem
# locations searched, uncomment this line
# export GEM_PATH=""
@dracos
dracos / gist:53b026de75eb1da1dfb2
Created Feb 20, 2015
Ways to see FixMyStreet confirmation pages
View gist:53b026de75eb1da1dfb2
/contact/submit?_test_=1&success=(0|1)
/questionnaire/submit?token=_test_&been_fixed=(Unknown|Yes)&new_state=(confirmed|)
/questionnaire/submit?problem=_test_
/P/_test_
/A/_test_?confirm_type=(subscribe|unsubscribe)
/C/_test_