Skip to content

Instantly share code, notes, and snippets.

{
"privacyStatement": "https://example.org/privacy.html",
"countriesDataHeld": ["IE", "LU"],
"portability": {
"description": "You can download your raw account data",
"url": "https://example.org/give-me-my-data.html"
},
"deletion": {
"description": "To delete your data, you must contact our support team",
"url": "mailto:support@example.org"
def recommend_union(job, employer):
results = []
job = job.lower()
employer = employer.lower()
if 'journalist' in job:
results.append(models.Union.objects.get(name='National Union of Journalists'))
if 'uber' in employer:
results.append(models.Union.objects.get(name='GMB'))
@richardjpope
richardjpope / minimumwage.py
Last active August 29, 2015 14:24
Minimum wage rates 2014
#https://www.gov.uk/national-minimum-wage-rates
def minimum_wage(age, apprentice=False, apprenticeship_year=None):
if apprentice:
if age < 19 or apprenticeship_year == 1:
return 2.73
if age < 18:
return 3.79
@richardjpope
richardjpope / free-prescriptions.feature
Last active August 29, 2015 14:24
Free prescriptions (cucumber)
#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
### Keybase proof
I hereby claim:
* I am memespring on github.
* I am memespring (https://keybase.io/memespring) on keybase.
* I have a public key whose fingerprint is 190E 773E 1D53 996A AE42 0F30 1B5D 919C B3D0 024C
To claim this, I am signing this object:
@richardjpope
richardjpope / gist:789debb25ae64a373d4c
Last active August 29, 2015 14:10
String to colour in python
def string_to_colour(s):
s = s.lower()
r = ((ord(s[0])-96.0)/26)*255
g = ((ord(s[int(len(s)/2)])-96.0)/26)*255
b = ((ord(s[len(s)-1])-96.0)/26)*255
return '#%02X%02X%02X' % (r,g,b)
{% if form.errors %}
<div class="alert alert-danger">
<ul>
{% for field_name, field_errors in form.errors|dictsort if field_errors %}
{% for error in field_errors %}
<li>{{ form[field_name].label }}: {{ error }}</li>
{% endfor %}
{% endfor %}
</ul>
</div>
@richardjpope
richardjpope / gist:30898d24ccaabf77c455
Created July 21, 2014 11:06
WTForms bootstrap macro
{% macro render_field(field) %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{{ field.label(class_="control-label") }}
{{ field(class_="form-control", **kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="help-block">{{error}}</span>
{% endfor %}
{% endif %}
</div>
@richardjpope
richardjpope / gist:4452689
Last active December 10, 2015 15:09
Oyster Card backup script for ScraperWiki.com Vault
# This is a very basic script to backup oyster card data to a scraperwiki vault
# Notes:
# 1) You need an oyster card that has been registered on tfl.gov.uk
# 2) This script requires you to enter your username and password (this about what that means before progressing, and do so at your own risk)
# 3) This script should be run in a PRIVATE SCRAPERWIKI VAULT ONLY https://scraperwiki.com/pricing/ not a public scraper, or the world will know your password
import scraperwiki
import mechanize
import lxml.html
from lxml.etree import tostring