Skip to content

Instantly share code, notes, and snippets.

View sebbacon's full-sized avatar

Seb Bacon sebbacon

View GitHub Profile
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.09kB 0.0s done
#1 DONE 0.0s
#2 [internal] load metadata for docker.io/ebmdatalab/datalab-jupyter:python3.8.1-2328e31e7391a127fe7184dcce38d581a17b1fa5
#2 DONE 0.5s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
This log output shows Chris running `python run.py` on Windows. It shows two issues.
1. A syntax error in jupyterlab
2. A config error (presumably due to deprecated config) for jupyterlab
```txt
(base) C:\Users\cwood\Documents\GitHub\rich_test_1>python run.py
Building docker image. This may take some time (particularly on the first run)...
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
@sebbacon
sebbacon / shotter.py
Created January 22, 2024 12:53
Use console-based javascript to parse a complicated DOM; and playwright to run it against specific URLs
import subprocess
from PIL import Image
# This is the complex parsing. It locates every single italic character in the text,
# and then adds a custom inline style to it
js = """document.querySelectorAll('*').forEach(element => {
const fontStyle = window.getComputedStyle(element).fontStyle;
if (fontStyle === 'italic') {
element.style.backgroundColor = 'lightgrey';
@sebbacon
sebbacon / gist:bee36e34e5aef06b8f0fbe7f310cd877
Created January 17, 2024 09:36
transcribe_bbc_interview.py
"""Hacky script to download audio from a BBC interview and transcribe, with OpenAI tools
"""
import subprocess
from optparse import OptionParser
# Define command line options
Data Set FileName Record Count Comments
National Waiting List TPP_NWL_ClockStops_20231124_0819.txt 195,596 This is a cumulative load eg we only send the latest weeks data to be appended.
National Waiting List TPP_NWL_Diagnostics_20231124_0819.txt 945,519 This is a cumulative load eg we only send the latest weeks data to be appended.
National Waiting List TPP_NWL_OpenPathways_20231124_0819.txt 6,599,819 This is a cumulative load eg we only send the latest weeks data to be appended.
Antiviral Data TPP_Antiviral_20231124_0823.txt 109,611 This is a full refresh of all data.
PHE Data TPP_PHE_Tests_Positive_20231124_0827.txt 6,132,4
select s1.d, n1, n2, cast(n2 as decimal) / cast(n1 as decimal)
from
(
select d, count(*), n1 from (
select convert(varchar(7), admission_date, 23) d
from apcs_cost c
join apcs a
on c.apcs_ident = a.apcs_ident
) s
group by d
-- Uploading file for patient_index_date
CREATE TABLE #tmp1_patient_index_date_file (
patient_id BIGINT,
patient_index_date DATE
)
GO
-- Query for patient_index_date
-- Query for dereg_date
SELECT * INTO #dereg_date FROM (
SELECT
t.Patient_id,
end_date AS value
FROM (
SELECT
Patient_ID AS patient_id,
MAX(EndDate) AS end_date
FROM
@sebbacon
sebbacon / variable_names.txt
Created October 20, 2021 15:04
popular variable names in opensafely studies
sex 115 ############################################################
age 114 ############################################################
imd 84 ############################################
ethnicity 67 ###################################
region 64 ##################################
stp 63 #################################
care_home_type 51 ###########################
registered 47 #########################
bmi 45 ########################
chronic_cardiac_disease 44 #######################
This file has been truncated, but you can view the full file.
-- Query for age
SELECT * INTO #age FROM (
SELECT
Patient.Patient_ID AS patient_id,
CASE WHEN
dateadd(year, datediff (year, DateOfBirth, '20200331'), DateOfBirth) > '20200331'
THEN
datediff(year, DateOfBirth, '20200331') - 1
ELSE
datediff(year, DateOfBirth, '20200331')