Skip to content

Instantly share code, notes, and snippets.

View TimTaylor's full-sized avatar

Tim Taylor TimTaylor

View GitHub Profile
@TimTaylor
TimTaylor / git-feature-workflow.md
Created January 8, 2019 16:54 — forked from blackfalcon/git-feature-workflow.md
Git basics - a general workflow

There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.

The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.

When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].

Basic branching

When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.

@TimTaylor
TimTaylor / GitHub-Forking.md
Created April 10, 2019 15:35 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@TimTaylor
TimTaylor / twee-demo.Rmd
Created May 8, 2019 10:33 — forked from jennybc/twee-demo.Rmd
twee(): emulating the tree directory listing command
---
title: "twee demo"
author: "Jenny Bryan"
date: "17 August, 2014"
output:
html_document:
toc: TRUE
keep_md: TRUE
---
@TimTaylor
TimTaylor / gh-pages.sh
Created May 9, 2019 15:42 — forked from skratchdot/gh-pages.sh
Initialize gh-pages branch
# create gh-pages branch
git checkout --orphan gh-pages
git rm -rf .
touch README.md
git add README.md
git commit -m 'initial gh-pages commit'
git push origin gh-pages
# add gh-pages as submodule
git checkout master

Keybase proof

I hereby claim:

  • I am tjtnew on github.
  • I am timtaylor (https://keybase.io/timtaylor) on keybase.
  • I have a public key ASBfsV7dKpI13xT_Gj_jah7CBZFR0WVz6FLumNymt7qR1Qo

To claim this, I am signing this object:

## Empty list -- just use the empty environment for this.
nil <- function() {
emptyenv()
}
## Test if a list is the empty list:
is_empty <- function(lis) {
identical(lis, nil())
}
@TimTaylor
TimTaylor / postcode_validation.R
Created March 5, 2020 13:02
R postcode validation
# Can't remember why I have two of these (found while cleaning up my files so put here)
valid_postcode_1 <- function(x) {
# remove whitespace
x <- gsub("\\s", "", x)
# convert to upper case
x <- toupper(x)
# regex (this allows for cas)
@TimTaylor
TimTaylor / scrape.R
Last active March 9, 2020 14:24
scrape uk covid updates
library(rvest)
# parameters
url <- "https://www.gov.uk/government/publications/coronavirus-covid-19-number-of-cases-in-england/coronavirus-covid-19-number-of-cases-in-england"
filename <- "~/cases.csv"
# get data
html <- read_html(url)
overview <- html_text(html_nodes(html, "#contents p:nth-child(1)"), trim = TRUE)
headings <- html_text(html_nodes(html, "th, th"), trim = TRUE)
@TimTaylor
TimTaylor / defaultdict.R
Last active May 12, 2020 11:00
attempt at defaultdict in R
library(collections)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Create a dict with a default value
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defaultdict <- function(value) {
structure(dict(), class = c('defaultdict'), value = value)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@TimTaylor
TimTaylor / safely-demo.R
Created November 5, 2020 11:26
Examples of safely function
# safe wrapper for functions ---------------------------------------------------
safely <- function(fun) {
function(...) {
warn <- err <- NULL
res <- withCallingHandlers(
tryCatch(fun(...), error = function(e) {
err <<- conditionMessage(e)
NULL
}),
warning = function(w) {