Skip to content

Instantly share code, notes, and snippets.

View inglesp's full-sized avatar

Peter Inglesby inglesp

View GitHub Profile
@inglesp
inglesp / gist:8866459
Created February 7, 2014 16:39
Django tutorial exercises
Here are some ideas for ways to extend the polls app built during the Django tutorial at https://docs.djangoproject.com/en/1.6/intro/tutorial01/.
# On the index page
* show the date that each poll was published
* show the total number of votes for each poll
* show the most popular response(s) for each poll
* only show the polls whose `pub_date` field is in the past
# On the detail page
* add a link to see the results directly, without voting
* order the options alphabetically

Keybase proof

I hereby claim:

  • I am inglesp on github.
  • I am inglesp (https://keybase.io/inglesp) on keybase.
  • I have a public key whose fingerprint is 7B50 BD7B 9413 E347 ECFA E03E 046A DEFC 000B 7381

To claim this, I am signing this object:

$ irb
2.2.2 :001 > def a l = def b; <<-NIGHTMARES; end; puts send l; end
2.2.2 :002"> 😱😱😱
2.2.2 :003"> NIGHTMARES
=> :a
2.2.2 :004 > a
😱😱😱
@inglesp
inglesp / microtetris.py
Created November 13, 2015 08:42
First attempts to get something tetris-like to run on a micro:bit, created at the London Python Dojo by lukasa and inglesp.
import microbit
SIZE = 5
TOP = 4
BOTTOM = 0
LEFT = 4
RIGHT = 0
{
"Aberdeen City": {
"leave_pc": 39,
"leave_pc_est": "34",
"region": "Scot",
"remain_pc": 61,
"remain_pc_est": "66"
},
"Aberdeenshire": {
"leave_pc": 45,
@inglesp
inglesp / csv2xlsx.py
Created March 16, 2020 17:12
Scripts to convert to and from .csv and .xlsx
#!/usr/bin/env python3
# Use this for converting a .csv to a .xlsx when you don't want to treat numbers as text.
import csv
import sys
import types
import xlsxwriter
@inglesp
inglesp / update_codelist.py
Last active May 25, 2020 13:11
Update opensafely/chemotherapy-or-radiotherapy
cl = Codelist.objects.get(slug="chemotherapy-or-radiotherapy")
headers, *rows = cl.table
f = open("chemotherapy-or-radiotherapy-updated.csv", "w")
writer = csv.writer(f)
writer.writerow(headers)
for row in rows:
code = row[0]
if len(code) == 5:
@inglesp
inglesp / ccg-changes.csv
Last active June 30, 2020 10:48
Scraper and data for 2020 CCG changes
old_code old_name new_name new_code
00D Durham Dales, Easington and Sedgfield CCG NHS County Durham CCG 84H
00J North Durham CCG NHS County Durham CCG 84H
00C Darlington CCG NHS Tees Valley CCG 16C
00K Hartlepool and Stockton-on-Tees CCG NHS Tees Valley CCG 16C
00M South Tees CCG NHS Tees Valley CCG 16C
03D Hambleton, Richmondshire and Whitby CCG NHS North Yorkshire CCG 42D
03M Scarborough and Ryedale CCG NHS North Yorkshire CCG 42D
03E Harrogate and Rural District CCG NHS North Yorkshire CCG 42D
02N Airedale, Wharfedale and Craven CCG NHS Bradford District and Craven CCG 36J
# -*- coding: utf-8 -*-
'''
Created on Wed Jun 17 15:21:46 2020
@author: JTM
'''
from time import time
from threading import Thread
import numpy as np