Skip to content

Instantly share code, notes, and snippets.

GPU enabled docker on Ubuntu

Check host is running at least Ubuntu 16.04

$ cat /etc/issue
Ubuntu 16.04 LTS \n \l

Check host has CUDA capable card with compute capability 3.0 or higher

@wkmor1
wkmor1 / greta_test.R
Last active November 27, 2017 01:26
Greta test
#devtools::install_github("wkmor1/msmod")
library(msmod) # for eucs dataset
library(lme4)
library(greta)
sc = function(x) scale(x)[, 1] / 2 # center and scale covariates by 2 sds
# Fit glmer model
m_glmer = glmer(
present ~ sc(logit_rock) + (1 + sc(logit_rock) | species),
data = eucs, family = stats::binomial
#' Convert doi to bibtex
#'
#' Convert a digital object identifier (doi) string into a bibtex entry using the
#' webserice \link{http://www.doi2bib.org}.
#'
#' @param doi The character string of the doi.
#'
#' @return a bibtex entry as a character string.
#'
#' @importFrom httr accept content GET
@wkmor1
wkmor1 / rasterToKML.r
Last active December 24, 2015 09:08
convert raster objects or raster readable files to .kml overlay files
rasterToKML <- function(x, out='Rgrid', png=FALSE, name=out, proj="+proj=longlat") {
require(raster)
require(maptools)
require(rgdal)
require(rgeos)
x <- raster(x)
SG <- as(x, 'SpatialGridDataFrame')
proj4string(SG) <- CRS(proj)
SG <- GE_SpatialGrid(SG)
if(png) png <- sprintf('%s.png', out) else png <- tempfile()
@wkmor1
wkmor1 / plotvc
Last active December 19, 2015 20:59
plot variance components from a GLMM fit in JAGS
plot.vc <-
function (model, comps, ylabs) {
vc <- matrix(F, ncol=5, nrow=length(comps))
row.names(vc) <- comps
for (i in comps) {
vc[i, ] <- quantile(
eval(parse(text=sprintf('model$BUGSoutput$sims.list$%s', i))),
prob = c(0.025, 0.1587, .5, 0.8413, 0.975))
}
plot.new()