Skip to content

Instantly share code, notes, and snippets.

View vsbuffalo's full-sized avatar

Vince Buffalo vsbuffalo

View GitHub Profile
@vsbuffalo
vsbuffalo / pairwise_cov.r
Created March 1, 2019 19:06
comparing two implementations of covariance with pairwise complete cases
library(tidyverse)
library(MASS)
pcov <- function(x) {
xs <- scale(x, scale=FALSE)
dd <- as.integer(!is.na(x))
dim(dd) <- dim(x)
denom <- (t(dd) %*% dd) - 1L
no_obs <- denom == 0L
xs[is.na(xs)] <- 0
library(purrr)
foo <- function(x) {
return(function(y) {
y + x
})
}
args <- list(1, 2)
foos_map <- map(args, foo)
@vsbuffalo
vsbuffalo / foo.R
Created April 13, 2016 18:42
23andme and bioc blog post
Title: Using Bioconductor to Analyze your 23andme Data
Bioconductor is one of the open source projects of which I am most
fond. The documentation is excellent, the community wonderful, the
development fast-paced, and the software *very* well written.
There's a new package in the development branch (due to be released as
2.10 very soon) called `gwascat`. `gwascat` is a package that serves
as an interface to the [NHGRI's](http://www.genome.gov/) database of
genome-wide association studies.
@vsbuffalo
vsbuffalo / .ycm_extra_conf.py
Created March 2, 2016 21:10
example YouCompleteMe file
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@vsbuffalo
vsbuffalo / trashpanda.R
Created November 9, 2015 17:20
get some sweet trashpanda pictures <3 trash panda
trashpanda <- function() {
if (!require('ecoengine')) {
install.packages("ecoengine", dependencies = TRUE)
library(ecoengine)
}
view_photos(ee_photos(scientific_name = "Procyon lotor", quiet = TRUE))
}
@vsbuffalo
vsbuffalo / Makefile
Last active November 28, 2018 14:04
finally, a LaTeX makefile that captures your anger and frustration
# Thanks https://github.com/EBI-predocs/latex-thesis/blob/master/Makefile for
# some tips
LATEXMK = latexmk -xelatex
# CONFIG
target = manuscript
references = bib.bib
# SETUP
includes := $(shell ls *.tex) ${references}
For every minute you are angry, you lose sixty seconds of happiness. ::: unknown
Anger is a momentary madness, so control your passion or it will control you. ::: Horace Walpole
When angry, count ten before you speak; if very angry, a hundred. ::: Jefferson
Anger is a wind which blows out the lamp of the mind. ::: Robert G. Ingersoll
Holding on to anger is like grasping a hot coal with the intent of throwing it at someone else; you are the one getting burned. ::: Buddha
The best remedy for a short temper is a long walk. ::: Jacqueline Schiff
@vsbuffalo
vsbuffalo / draw_lineage.js
Created September 5, 2015 16:53
example standlone d3 svg image generator
var fs = require('fs');
var d3 = require('d3');
var jsdom = require('node-jsdom');
var xmlserializer = require('xmlserializer');
var margin = {top: 2, right: 4, bottom: 2, left: 4};
var width = 200 - margin.left - margin.right,
height = 14 - margin.top - margin.bottom;
augroup Terminal
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id
augroup END
function! REPLSend(lines)
call jobsend(g:last_terminal_job_id, add(a:lines, ''))
endfunction
command! REPLSendLine call REPLSend([getline('.')])
@vsbuffalo
vsbuffalo / coal.js
Created April 21, 2015 03:25
dancing genealogies
function range(from, to, by) {
var by = typeof(by) === 'undefined' ? 1 : by;
var out = [];
for (var i = from; i <= to; i += by) out.push(i);
return out;
}
function sampleArrayWithoutReplacement(x, n) {
n = typeof x === 'undefined' ? 1 : n;