This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this script installs GCC 4.9.3 | |
# to use it navigate to your home directory and type: | |
# sh install-gcc-4.9.3.sh | |
# download and install gcc 4.9.3 | |
wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.gz | |
tar xzf gcc-4.9.3.tar.gz | |
cd gcc-4.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script installs libcurl and R 3.3.0 on a linux server | |
# when you can't use apt-get. Note that libcurl is a requirement | |
# for R 3.3.0 | |
# also see: http://pj.freefaculty.org/blog/?p=315 | |
export PATH=$HOME/packages/bin:$PATH | |
export LD_LIBRARY_PATH=$HOME/packages/lib:$LD_LIBRARY_PATH | |
export CFLAGS="-I$HOME/packages/include" | |
export LDFLAGS="-L$HOME/packages/lib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias time='/usr/bin/time -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
latexmk -pdf -pvc $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
convert -density 300 $1 /tmp/page_%04d.jpg | |
convert /tmp/page_*.jpg $2 | |
rm /tmp/page_*.jpg | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# making mixture models numerically robust | |
set.seed(4) | |
rm(list = ls()) | |
nobs = 1000 | |
alpha = 0.1 | |
p = runif(nobs, min = 0.0, max = 1.0) | |
q = runif(nobs, min = 0.0, max = 1.0) | |
# naive computation of log-likelihood contribution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// timer.h | |
#include <iostream> | |
#include <sstream> | |
#ifndef timer_h | |
#define timer_h | |
class timer { | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef print_mat_h | |
#define print_mat_h | |
void print_mat(arma::mat my_matrix) { | |
uint cols = my_matrix.n_cols; | |
uint rows = my_matrix.n_rows; | |
Rcout << "--------\n"; | |
for(uint rX = 0; rX < rows; rX++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls()) | |
dict.orig = unique(readLines("https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english.txt")) | |
txt2numeric = function(word.orig, return.orig = TRUE) { | |
word = tolower(word.orig) | |
word = gsub("([^a-z]){1}", 1, word) | |
word = gsub("(a|b|c){1}", 2, word) | |
word = gsub("(d|e|f){1}", 3, word) | |
word = gsub("(g|h|i){1}", 4, word) |