Skip to content

Instantly share code, notes, and snippets.

View jsilve24's full-sized avatar

Justin Silverman jsilve24

View GitHub Profile
@jsilve24
jsilve24 / print-helper.el
Created December 2, 2021 01:03
Simple print helper, its a thin wrapper around pdf-tools' pdf-misc-print-document that lets you select a printer registered with CUPS.
;; see cups help page for lots on how to print with lpr and lp
;; the below functions assume these options are set
(setq pdf-misc-print-program-executable "/usr/bin/lpr"
pdf-misc-print-program-args (list "-o sides=two-sided-long-edge"))
;;; print-helper -- not enough to make a stand-alone package
(require 'dash)
;;;###autoload
(defun ph--get-list-of-priters ()
@jsilve24
jsilve24 / colQuantiles.cpp
Last active August 20, 2018 20:11
Fast calculation of quantiles for each column of a matrix using Rcpp
#include <Rcpp.h>
using namespace Rcpp;
// q is a vector of quantiles to calculate for each column of x
// [[Rcpp::export]]
NumericMatrix colQuantiles(NumericMatrix x, NumericVector q) {
int c = x.ncol();
int r = x.nrow();
int n = q.length();
NumericMatrix out(n, c);
@jsilve24
jsilve24 / Clean Optimizing Output from Rstan
Created July 10, 2018 14:28
Takes output from Stan Optimizing and cleans it to more standard form.
#' Clean Output of Stan Optimizing Samples
#'
#' @param optimfit result of call to rstan::optimizing
#' @param pars optional character vector of parameters to include
#'
#' @return list of arrays
#' @importFrom stringr str_count
#' @importFrom rlang syms
#' @importFrom dplyr matches select mutate
#' @importFrom tidyr gather separate