Skip to content

Instantly share code, notes, and snippets.

@rpietro
rpietro / search_file_contents
Created December 31, 2019 21:53
Searching file contents (from the fzf examples page)
ag --nobreak --nonumbers --noheading . | fzf
@rpietro
rpietro / init.vim
Created December 31, 2019 21:51 — forked from danmikita/init.vim
File preview with FZF, RG, Bat, and Devicons
nnoremap <silent> <leader>e :call Fzf_dev()<CR>
" ripgrep
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" Files + devicons
@rpietro
rpietro / Submitting Rmd to Arxiv.md
Created October 22, 2019 14:59 — forked from JJ/Submitting Rmd to Arxiv.md
Submitting RMarkdown articles to Arxiv

Mini-HowTo submit RMarkdown articles to ArXiV

ArXiV is a place for publishing scientific technical reports and drafts which is tightly tied to LaTeX. That is why if you generate a PDF from your RMarkdown article it will tell you, hey, this has been generated using LaTeX, I want the LaTeX source. In principle, RStudio does not admit LaTeX as a final format, only .doc, .pdf or HTML. But it is no big deal.

You only need to add this to the metadata in the RMarkdown document

output: 
  pdf_document:
    keep_tex: true
@rpietro
rpietro / rangerkeybidnings.txt
Created December 31, 2017 13:39
ranger shortcuts (keybindings)
Keybindings in `browser'
Q quit!
q quit
ZZ quit
ZQ quit
R reload_cwd
<c-r> reset
<c-l> redraw_window
<c-c> abort
<escape> change_mode normal
Searching for "autoload/tcomment.vim" in "/home/rpietro/.vim,/home/rpietro/.vim/bundle/vim-commentary,/home/rpietro/.vim/bundle/vim-markdown,/home/rpietro/.vim/bundle/vimwiki,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/home/rpietro/.vim/bundle/vim-markdown/after,/home/rpietro/.vim/after"
Searching for "/home/rpietro/.vim/autoload/tcomment.vim"
chdir(/home/rpietro/.vim/autoload)
fchdir() to previous dir
sourcing "/home/rpietro/.vim/autoload/tcomment.vim"
line 1: " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
line 2: " @Website: http://www.vim.org/account/profile.php?user_id=4037
line 3: " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
@rpietro
rpietro / classifiers.R
Created August 2, 2015 11:54
Script from a blog post on classifiers
# http://freakonometrics.hypotheses.org/20002
n = 500
set.seed(1)
X = rnorm(n)
ma = 10-(X+1.5)^2*2
mb = -10+(X-1.5)^2*2
M = cbind(ma,mb)
set.seed(1)
Z = sample(1:2,size=n,replace=TRUE)
@rpietro
rpietro / nmfHeatmap.R
Created August 1, 2015 22:25
Script for NMF heatmap vignette
# http://nmf.r-forge.r-project.org/vignettes/heatmaps.pdf
# random data that follow an 3-rank NMF model (with quite some noise:
# sd=2)
X <- syntheticNMF(100, 3, 20, noise = 2)
# row annotations and covariates
n <- nrow(X)
d <- rnorm(n)
e <- unlist(mapply(rep, c("X", "Y", "Z"), 10))
e <- c(e, rep(NA, n - length(e)))
@rpietro
rpietro / tableplot.R
Created August 1, 2015 22:12
Script for tableplot vignette
# https://cran.r-project.org/web/packages/tabplot/vignettes/tabplot-vignette.html
require(ggplot2)
data(diamonds)
is.na(diamonds$price) <- diamonds$cut == "Ideal"
is.na(diamonds$cut) <- (runif(nrow(diamonds)) > 0.8)
tableplot(diamonds)
tableplot(diamonds, select = c(carat, price, cut, color, clarity), sortCol = price)
tableplot(diamonds, select = c(carat, price, cut, color, clarity), sortCol = price,
from = 0, to = 5)
@rpietro
rpietro / tripod.md
Created May 30, 2015 13:00
TRIPOD in md format

Title

  • Identify the study as developing and/or validating a multivariable prediction model, the target population, and the outcome to be predicted.

Abstract

  • Provide a summary of objectives, study design, setting, participants, sample size, predictors, outcome, statistical analysis, results, and conclusions.

Introduction

@rpietro
rpietro / hdp.R
Last active May 31, 2024 04:03
hdp or Hospital, Doctor and Patient simulated dataset
# Introduction to SAS. UCLA: Statistical Consulting Group. from http://www.ats.ucla.edu/stat/sas/notes2/ (accessed November 24, 2007).
# install.packages('lme4', repos='http://cran.us.r-project.org')
# install.packages('corpcor', repos='http://cran.us.r-project.org')
require(lme4)
require(compiler)
require(MASS) # for multivariate normal function
require(corpcor) # to make a matrix positive definite
## Loading required package: corpcor