This is a template for R projects that should work both on the command line as well as in an interactive session.
The template is made up of three files:
- foo.r
suppressMessages(library(lintr)) | |
files <- commandArgs(trailingOnly = T) | |
messages <- function(file) { | |
result <- lint(file) | |
print(result) | |
return(length(result)) | |
} |
#!/usr/bin/env bash | |
set -efu -o pipefail | |
# returns staged files | |
function staged.files { | |
if git rev-parse --verify HEAD &> /dev/null | |
then | |
against=HEAD | |
else |
#!/bin/bash | |
GIT_HOOK_DIR="$0.d" | |
if [[ -d $GIT_HOOK_DIR ]] ; then | |
while IFS= read -r -d $'\0' hook ; do | |
"./$hook" || error="yes" | |
done < <(find "$GIT_HOOK_DIR" -mindepth 1 -print0) | |
[[ -n $error ]] && exit 1 |
shellPrompt := { state => | |
(scala.Console.CYAN + "sbt @ %s $ " + scala.Console.RESET) format { | |
Project.extract(state).getOpt(sbt.Keys.name) getOrElse { | |
Project.extract(state).currentProject.id | |
} | |
} | |
} |
#!/usr/bin/env python | |
from argparse import ArgumentParser, FileType | |
# ------------------------------------------------------------------------------ | |
# defaults | |
# ------------------------------------------------------------------------------ | |
default_nthreads = 1 | |
default_verbose = False |
library(optparse) | |
# ------------------------------------------------------------------------------ | |
# defaults | |
# ------------------------------------------------------------------------------ | |
default.nthreads <- 1 | |
default.verbose <- FALSE | |
# ------------------------------------------------------------------------------ |
#!/usr/bin/env r | |
# create input file with: | |
# $ find /path/to/dir -type f -printf '%s\n' | gzip > dir.file.sizes.gz | |
# start with: | |
# $ zcat dir.file.size.gz | fshist.r | |
# edit breaks to your needed sizes | |
# leave the breaks "0" and "2^50" for the edges | |
suppressMessages(library(stats)) |
// this gist has been superseded by | |
// https://github.com/wookietreiber/scala-cli-tools |
// this gist has been superseded by | |
// https://github.com/wookietreiber/scala-cli-tools |