Skip to content

Instantly share code, notes, and snippets.

@jtilly
jtilly / emax.m
Last active November 20, 2015 21:02
Emax Type I Extreme Value / Generalized Extreme Value
% Mean utilities
mu1 = 2;
mu2 = 3;
mu3 = 1;
% Scale parameter
sigma = 0.4;
% Draw Type I extreme value errors
R = -evrnd(0,1,100000,3);
@jtilly
jtilly / nan.f90
Created November 27, 2015 19:39
Intel Fortran NAN
real(dp), PARAMETER :: NAN = TRANSFER((/ Z'00000000', Z'7FF80000' /), 1.0_8)
@jtilly
jtilly / docker-install.sh
Last active November 29, 2015 16:41
Install docker-engine on Ubuntu Trusty
#!/bin/bash
sudo apt-get install docker-engine=1.8.3-0~trusty
sudo gpasswd -a ${USER} docker
sudo service docker restart
newgrp docker
@jtilly
jtilly / install-gfortran.sh
Created December 22, 2015 05:48
Install gfortran on Mac OS X for RcppArmadillo
#!/bin/bash
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
@jtilly
jtilly / checkmake.sh
Created December 30, 2015 03:31
Check makefile
#!/bin/bash
cat -e -t -v $1
@jtilly
jtilly / install_rstudio.sh
Last active January 7, 2016 14:38
Shell script that downloads and installs the latest version of RStudio Desktop (Ubuntu / Debian)
#!/bin/bash
# get the latest version
VER=$(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-desktop/current.ver)
# download it
wget https://download1.rstudio.org/rstudio-${VER}-amd64.deb
# install it
sudo dpkg -i rstudio-${VER}-amd64.deb
# clean up
rm -f rstudio-${VER}-amd64.deb
@jtilly
jtilly / random_numbers_parallel.Rmd
Last active January 15, 2016 21:55
Random Number Generation in Parallel: Reproducibility (https://goo.gl/eDglXT)
---
title: 'Random Number Generation in Parallel: Reproducibility'
author: "Jan Tilly"
date: "January 15, 2016"
output: html_document
---
```{r global_options, include=FALSE}
knitr::opts_chunk$set(results = 'hold')
```
@jtilly
jtilly / ols.f90
Created February 19, 2016 20:43
Compute OLS with Fortran and Lapack
function ols(y, x, n, k) result (beta)
implicit none
external DGELS
integer, intent(in) :: n, k
real(dp), allocatable, intent(in) :: y(:), x(:, :)
integer :: info, lwork
real(dp) :: beta(k)
@jtilly
jtilly / print_graph.R
Created April 10, 2016 21:27
Print graphs to screen and save them as Tikz or PDF
print_graph = function(g, type = NULL, filename = NULL, height = 6, width = 6, path = ifelse(type == "tikz", "tex", "pdf")) {
print(g)
if(!is.null(type)) {
if(type == "tikz") {
tikz(paste0(path, "/", filename), height = height, width = width)
print(g)
dev.off()
@jtilly
jtilly / time
Created May 30, 2016 14:07
Check memory usage
alias time='/usr/bin/time -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"'