Skip to content

Instantly share code, notes, and snippets.

View theosanderson's full-sized avatar

Theo Sanderson theosanderson

View GitHub Profile
@theosanderson
theosanderson / query.sql
Created March 20, 2019 23:33
Identify fastest growing petitions (min time between two defined numbers of signatures)
SELECT *, count_diff/time_diff AS rate FROM (SELECT petitions.action AS petitition, (countb2-count1) AS count_diff, t2-t1 AS time_diff FROM (SELECT * FROM (SELECT MIN(count) AS count1, petition_id AS pid1 FROM timeseries WHERE count>100000 GROUP BY petition_id) a INNER JOIN (SELECT time AS t1, petition_id AS pid2, count AS count2 FROM timeseries) b ON count1=count2 AND pid1=pid2) first INNER JOIN (SELECT * FROM (SELECT MIN(count) AS countb1, petition_id AS pidb1 FROM timeseries WHERE count>150000 GROUP BY petition_id) a INNER JOIN (SELECT time AS t2, petition_id AS pidb2, count AS countb2 FROM timeseries) b ON countb1=countb2 AND pidb1=pidb2) second ON pid1 = pidb1 AND count1 !=countb1 INNER JOIN petitions ON pid1=petitions.id ORDER BY time_diff) c ORDER BY rate DESC
string=[]; for (i in data){string.push(a.date.toString()+","+a.n+"\n")}; string.join("")
perl -0777 -pe 's/\\begin{figure[*]*}.*?\\end{figure[*]*}//gs' paper.tex | perl -0777 -pe 's/\\begin{table[*]*}.*?\\end{table[*]*}//gs' | perl -0777 -pe 's/\\%/&percnt;/gs' | perl -0777 -pe 's/%.*?\n//gs' | perl -0777 -pe 's/\n\n/§/gs' | perl -0777 -pe 's/[§\n]+/§\n/gs' | perl -0777 -pe 's/§\n/<\/p>\n<p>/gs' | perl -0777 -pe 's/\\textit{(.+?)}/<i>\1<\/i>/gs' | perl -0777 -pe 's/[ ]*\\cite[p]*{(.+?)}/<dt-cite key="\1"><\/dt-cite>/gs' | perl -0777 -pe 's/<p>\\section[*]*{(.+?)}<\/p>/<h2>\1<\/h2>/gs' | perl -0777 -pe 's/<p>\\subsection[*]*{(.+?)}<\/p>/<h3>\1<\/h3>/gs' > out.html
@theosanderson
theosanderson / gist:ec0db2fe4f3542783a2a36aee04a053b
Last active August 25, 2020 16:02
Up Goer Five GPT2 Samples

I work on finding out how to tell your computer what your color is, and what its type, and how it works.

I work on finding out how very small things that don't die can make things we know turn in different ways. We look for things we can tell by looking at what the little things are saying to us.

I work on finding out more about whether it is possible that different animals come from the same place, or whether we have to look at lots and lots of different places to find the different animals.

I work on finding out how often our tiny star bodies are hit by stars outside the big group of stars in the sky.

I work on finding out what causes small cells to not form. We are trying out a new approach to find out which cells are important in the little cells in your blood, stomach, stomach, small heart and brain. We hope to know more about how the number of different kinds of cells can change how big, and if that also has an effect on how well the tiny tiny things stick together to form the big cell.

Date Positivity Rate
01/07/2020 0.35
02/07/2020 0.44
03/07/2020 0.53
04/07/2020 0.48
05/07/2020 0.64
06/07/2020 0.62
07/07/2020 0.47
08/07/2020 0.36
09/07/2020 0.45
areaName cases_added
91 Liverpool 274.0
84 Lancashire 261.0
85 Leeds 231.0
10 Birmingham 212.0
17 Bradford 124.0
135 Sheffield 119.0
14 Bolton 101.0
103 Newcastle upon Tyne 97.0
176 Wirral 95.0
@theosanderson
theosanderson / test.py
Created October 9, 2020 16:09
Code producing internal server error on UK covid API
from uk_covid19 import Cov19API
cases = {
"date": "date",
"newCasesBySpecimenDate": "newCasesBySpecimenDate",
}
api = Cov19API(filters=['areaType=utla',f'areaCode=N09000011'], structure=cases)
library(tidyverse)
library(gganimate)
library(lubridate)
data <- read_csv("D:/cases_anim/cog_metadata_microreact_public.csv")
kent <- data %>% filter(latitude==.7334,longitude==51.2245)
data$sample_date = ymd(data$sample_date)
data$diff_days = data$sample_date - ymd("2020-09-01")
data_sub <- data %>% filter(sample_date>"2020-09-01")
@theosanderson
theosanderson / plot.R
Created December 20, 2020 03:11
Code for N501Y plot
library(tidyverse)
library(gganimate)
library(lubridate)
data <-
read_csv("D:/cases_anim/cog_metadata_microreact_public.csv.txt")
data$sample_date = ymd(data$sample_date)
library(sp)
library('sf')
ltlas <-
iso_3166_code lat long
37 41.46361111 44.81083333
98630 NaN NaN
AD-02 42.566378 1.60094
AD-03 42.536111 1.582778
AD-04 42.544166666 1.516388888
AD-05 42.555 1.533055555
AD-06 42.47 1.49
AD-07 42.5015 1.4980466666666667
AD-08 42.508889 1.540833