Skip to content

Instantly share code, notes, and snippets.

View seabbs's full-sized avatar
🏠
Working from home

Sam Abbott seabbs

🏠
Working from home
View GitHub Profile
@jarvisc1
jarvisc1 / aa_plot_continent.r
Last active May 26, 2020 16:28
Plot range of Rt for continents
library(data.table)
library(ggplot2)
cases <- fread('_nowcasts/covid-global/national-summary/cases.csv')
df <- fread('_nowcasts/covid-global/national-summary/rt.csv')
continents <- fread('_nowcasts/covid-global/data/continents_cnty.csv')
cases <- cases[, .(country, date, cases = median)]
dfcont <- merge(df, continents, by.x = "country", by.y = "country_name", all.x = TRUE)
dfcont <- merge(dfcont, cases, by = c("country", "date"), all.x = TRUE)
library(future)
# //////////////////////////////////////////////////////////////////////////////
# Fresh R session takes around 40MB
pryr::mem_used()
#> Registered S3 method overwritten by 'pryr':
#> method from
#> print.bytes Rcpp
#> 35.7 MB
@seabbs
seabbs / data-read-plus-munge
Last active July 24, 2019 08:57
Read in, munge and save a set of csvs + profiling information
# Get required packages - managed using pacman ---------------------------
# This installs packages if they are missing and otherwise loads them.
if (!require(pacman)) install.packages("pacman"); library(pacman)
p_load("tidyverse")
p_load("fs")
p_load("data.table")
p_load("lubridate")
p_load("purrr")
p_load("furrr")
@seabbs
seabbs / spending_gap_normalised
Created June 7, 2019 10:37
Looking at normalised spending gap for global Tuberculosis funding
# Install and load the package --------------------------------------------
if(!require(pacman))install.packages("pacman")
pacman::p_load('dplyr', 'ggplot2', 'getTBinR')
pacman::p_load_gh('thomasp85/patchwork')
pacman::p_load_gh('bbc/bbplot')
# Look at available datasets\ ---------------------------------------------
available_datasets
#!/bin/bash
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
##
## CHANGE ME!!!
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active September 20, 2024 17:41
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
## For password management
git config --global user.email "s.e.abbott12@gmail.com"
git config --global user.name "Sam Abbott"
git config --global credential.helper cache
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
# github settings
# developer settings
# create access token and copy
# git pull/push
@cpsievert
cpsievert / app.R
Last active October 23, 2018 03:36
Targeting views
library(plotly)
library(shiny)
# compute a correlation matrix
correlation <- round(cor(mtcars), 3)
nms <- names(mtcars)
ui <- fluidPage(
mainPanel(
plotlyOutput("heat"),
@mattjbayly
mattjbayly / Replace_multiple_strings.R
Last active October 16, 2022 05:42
Replace multiple strings across multiple text files
#' Replace multiple strings across multiple files with original values and replacement values.
#'
#' files - A character string of file names to work through.
#' f - A character string of original values that you want to replace.
#' r - A character string of replacement values (f->r).
multi_replace <- function(files="", f="", r=""){
file_line = data.frame() # (optional) tracking table
#loop through each file separately
for(j in 1:length(files)){
nl <- suppressWarnings(readLines(files[j])) # read file line by line
@cvan
cvan / HOWTO.md
Last active September 15, 2024 06:14
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you