Skip to content

Instantly share code, notes, and snippets.

View my-align.el
;;; my-align.el
;; Copyright (c) 2017 Bill Evans (r2evans)
;;
;; Author: Bill Evans
;; Created: 2017 Aug 03
;; Keywords: code align programming
;;; Commentary:
;; Simple wrapper wround 'align-regexp' with sane defaults.
;; Based on code first seen here
@r2evans
r2evans / sequentialFilename.R
Last active Jul 4, 2017
numbered filenames, "guaranteed" to produce a unique and sequential filename
View sequentialFilename.R
#' Sequential file naming
#'
#' (https://stackoverflow.com/a/44868545/3358272)
#'
#' @param ptn string that includes a [base::sprintf()] format string for an
#' integer, either `%d` or `%03d`; for example, `"filename-%03d.pdf"`
#' @param full.names logical, passed to [base::files()]
#' @return character, representing a filename that did not exist the
#' moment the function was called; NB: there is a potential
#' race-condition here
@r2evans
r2evans / lazyExpandGrid.R
Last active Jun 6, 2020
lazy evaluation of a potentially very large expand.grid
View lazyExpandGrid.R
#' Lazy expand.grid.
#'
#' Provide a lazy-eval for expand.grid, similar to python's
#' \code{xrange}, where the source may be too large to be fit into
#' memory but still accessible.
#'
#' This function returns a list of functions for accessing the lazy
#' \code{expand.grid}.
#'
#' The available methods within each object: