Skip to content

Instantly share code, notes, and snippets.

View joethorley's full-sized avatar

Joe Thorley joethorley

View GitHub Profile
@joethorley
joethorley / ext.R
Last active August 29, 2015 13:56
Wrappers to get, remove, replace, add and test file name extensions
library(tools)
library(assertthat)
#' @title Filename extension utilities
#'
#' @description Replaces, adds or removes (rm) extensions from filenames or test whether
#' filename has an extension or is a filename with a particular extension.
#' Functions are primarily wrappers
#' on the tools package functions \code{file_ext} and \code{file_path_sans_ext}.
#'
@joethorley
joethorley / brewbasictex
Created April 1, 2016 23:46
Install basictex using brew for R
brew tap caskroom/cask
brew cask install basictex
sudo tlmgr update --self
sudo tlmgr update --all
sudo tlmgr install titling framed inconsolata
@joethorley
joethorley / brewR
Last active April 18, 2016 19:44
brewing R
First of all made sure that command line developer tools (but not XCode were installed)
<http://railsapps.github.io/xcode-command-line-tools.html>
```
brew tap caskroom/cask
brew install Caskroom/cask/xquartz
brew cask install java
brew cask install basictex
@joethorley
joethorley / osx_install.sh
Created April 4, 2016 19:00 — forked from t-io/osx_install.sh
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@joethorley
joethorley / normalize.R
Created January 4, 2017 23:29
normalize
normalize <- function(x) {
if (min(x) > 0) {
if (max(x) < 1) {
x <- logit(x)
} else
x <- log(x)
}
x
}
@joethorley
joethorley / dprint.R
Last active January 10, 2017 18:49
print when debugging
dprint <- function(x, note = NULL, do = getOption("dprint.do", TRUE)) {
if (!do) return(invisible())
if (!is.null(note))
cat("\n**", note, "**\n")
cat("\n", deparse(substitute(x)), ": \n", sep = "")
print(x)
}
@joethorley
joethorley / update_git_repos.sh
Created May 2, 2017 22:33 — forked from douglas/update_git_repos.sh
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@joethorley
joethorley / project-create.sh
Created October 24, 2018 20:46 — forked from francoisromain/project-create.sh
A bash script to create a Git post-receive hook to deploy after a Git push
#!/bin/bash
# Call this file with `bash ./project-create.sh project-name [service-name]`
# - project-name is mandatory
# - service-name is optional
# This will creates 4 directories and a git `post-receive` hook.
# The 4 directories are:
# - $GIT: a git repo
# - $TMP: a temporary directory for deployment