Skip to content

Instantly share code, notes, and snippets.

View DarwinAwardWinner's full-sized avatar

Ryan C. Thompson DarwinAwardWinner

View GitHub Profile
;;; bcup-closures.el --- -*- lexical-binding: t -*-
;; Closure-manipulating function/macros
(defmacro enclose (arg)
`(lambda () ,arg))
(defmacro enclose-args (&rest args)
(let ((enclose-exprs
(mapcar (lambda (arg) `(enclose ,arg)) args)))
`(list ,@enclose-exprs)))
(defun unenclose (arg) (funcall arg))
@DarwinAwardWinner
DarwinAwardWinner / assign_general.R
Last active July 14, 2017 07:08
Proof-of-concept of general assignment function and related functions
library(rlang)
library(assertthat)
library(magrittr)
library(glue)
library(tibble)
## Takes LHS and RHS as strings
assign_general_ <- function(lhs, rhs, envir) {
expr <- parse(text=glue("{lhs} <- {rhs}"))
eval(expr, envir)

Keybase proof

I hereby claim:

  • I am darwinawardwinner on github.
  • I am rcthompson (https://keybase.io/rcthompson) on keybase.
  • I have a public key ASBVf3s3y1AIHHATFqG8c6WHdw8t4PpcbMIsc2slD2-XBwo

To claim this, I am signing this object:

@DarwinAwardWinner
DarwinAwardWinner / random-plot-order.Rmd
Last active February 1, 2017 21:22
Example of a Rmd file that produces 10 plots labeled A-J. They appear in random order in RStudio's notebook.
---
title: "Random Plot Order Test"
author: "Ryan C. Thompson"
date: "February 1, 2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@DarwinAwardWinner
DarwinAwardWinner / # pcre2 - 2016-06-14_13-49-25.txt
Created June 14, 2016 20:52
pcre2 on "CentOS release 6.7 (Final)" - Homebrew build logs
Homebrew build logs for pcre2 on "CentOS release 6.7 (Final)"
Build date: 2016-06-14 13:49:25
@DarwinAwardWinner
DarwinAwardWinner / multiple-analyses-example.R
Created January 5, 2016 16:00
Example of running multiple variants of an analysis in R
#!/usr/bin/env Rscript
library(matrixStats)
library(plyr)
library(lubridate)
library(reshape2)
library(minfi)
library(limma)
library(sva)
library(celltypes450)
subsetListOfArrays <- function (object, i, j, IJ, IX, I, JX, J) {
len <- vapply(object, length, 0)
I <- intersect(I, names(len)[len > 1L])
J <- intersect(J, names(len)[len > 1L])
if (missing(i)) {
IX <- I <- character(0)
if (missing(j))
IJ <- character(0)
}
else {
## This will allow you to use dplyr functions with Bioconductor's
## S4Vectors::DataFrame class. They simply call "as.data.frame" on
## DataFrame objects and then pass them to the methods for
## "data.frame". Note that this entails conversion of S4 vector
## columns to primitive vectors. No attempt is made to convert the
## results back to DataFrame, since such a conversion would not
## restore S4 vector columns that were converted to primitive vectors.
library(S4Vectors)
library(dplyr)
#!/bin/sh
# -*- mode:R -*-
#PBS -l nodes=1:ppn=8,mem=30gb
'\' >/dev/null 2>&1 || true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
@DarwinAwardWinner
DarwinAwardWinner / python-bash-wrapper.py
Last active November 9, 2020 20:43
Put bash cluster setup code and python script in a single file
#!/bin/bash
# -*- mode:python -*-
#PBS -l nodes=1:ppn=8,mem=30gb
''''/bin/true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
# Bash setup code ends here
python - "$@" <<EOF
''' # Python starts here '''