Skip to content

Instantly share code, notes, and snippets.

View MilesMcBain's full-sized avatar

Miles McBain MilesMcBain

  • Queensland Fire and Emergency Services
  • Brisbane, Queensland
View GitHub Profile
@MilesMcBain
MilesMcBain / yaml_frontmatter_r_github_document.yaml
Created September 13, 2017 01:52 — forked from jennybc/yaml_frontmatter_r_github_document.yaml
YAML frontmatter for R Markdown to cause rmarkdown::render() to retain intermediate Markdown file for .R and .Rmd files, respectively
#' ---
#' title: "Something fascinating"
#' author: "Jenny Bryan"
#' date: "`r format(Sys.Date())`"
#' output: github_document
#' ---
@MilesMcBain
MilesMcBain / gltf_bookmarklet.js
Created September 1, 2017 13:54 — forked from fernandojsg/gltf_bookmarklet.js
THREE.js and AFRAME glTF exporter bookmarklet
javascript:(function(){
var link = document.createElement( 'a' ); link.style.display = 'none'; document.body.appendChild( link );
function save( blob, filename ) { link.href = URL.createObjectURL( blob ); link.download = filename; link.click(); }
function saveString( text, filename ) { save( new Blob( [ text ], { type: 'application/json' } ), filename );}
var script=document.createElement('script');
script.src='https://threejs.org/examples/js/exporters/GLTFExporter.js';
script.onload = function () {
var exporter = new THREE.GLTFExporter();
simple_roc <- function(labels, scores){
labels <- labels[order(scores, decreasing=TRUE)]
data.frame(TPR=cumsum(labels)/sum(labels), FPR=cumsum(!labels)/sum(!labels), labels)
}
@MilesMcBain
MilesMcBain / ipython-notebook.conf
Last active December 12, 2017 16:35 — forked from whophil/ipython-notebook.conf
Upstart file (Ubuntu) for Jupyter / IPython notebook
start on filesystem or runlevel [2345]
stop on shutdown
description "Jupyter / IPython Notebook Upstart script"
script
export HOME="/home/ubuntu/"; cd $HOME
echo $$ > /var/run/ipython_start.pid
exec su -s /bin/sh -c 'exec "$0" "$@"' ubuntu -- /home/ubuntu/anaconda2/bin/jupyter-notebook --config='/home/ubuntu/.jupyter/jupyter_notebook_config.py'
end script
@MilesMcBain
MilesMcBain / patch.R
Created March 10, 2016 01:52 — forked from dholstius/patch.R
Patch data on-the-fly (DRAFT)
#' Patch data on the fly.
#'
#' @param object to be patched
#' @param cond logical condition(s) to be evaluated within scope of object
#' @param \dots name-value pairs
#' @param quiet suppress messages
#'
#' @examples
#' patch(mtcars, where(vs == 0, am == 1), gear = Inf, carb = carb + 10)
#'