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
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
@cvan
cvan / HOWTO.md
Last active October 27, 2024 09:49
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
@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
@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"),
## For password management
git config --global user.email "[email protected]"
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
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 19, 2024 11:06
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).
#!/bin/bash
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
##
## CHANGE ME!!!
@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
@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")
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