Skip to content

Instantly share code, notes, and snippets.

View DarwinAwardWinner's full-sized avatar

Ryan C. Thompson DarwinAwardWinner

View GitHub Profile
@DarwinAwardWinner
DarwinAwardWinner / .Rprofile
Created January 11, 2020 17:32
The environment setup for my R profile
local({
## Put everything in a separate environment and attach that
## environment. Re-use the existing one from the search path it
## it's available, so that re-executing this file doesn't add a
## new environment to the search path every time.
custom_env <- tryCatch(as.environment("rct_custom_env"),
error=function(...) {
attach(NULL, name="rct_custom_env")
as.environment("rct_custom_env")
library(dplyr)
library(tidyr)
d6 <- 1:6
# We'll call the 3 dice X, Y, and D (D is the dragon die)
all_rolls <- expand.grid(X=d6, Y=d6, D=d6) %>%
mutate(
## Sum of all 3 dice; determines if you hit
sum = X + Y + D,
## TRUE if this roll has doubles in it
library(dplyr)
library(matrixStats)
library(stringr)
library(ggplot2)
## Using point buy table from https://www.d20pfsrd.com/basics-ability-scores/ability-scores/
## Assume anything less than 7 is just -4 points
point_buy_values <-
c(-4, -4, -4, -4, -4, -4, -4, -2, -1, 0, 1, 2, 3, 5, 7, 10, 13, 17) %>%
set_names(seq_along(.))
@DarwinAwardWinner
DarwinAwardWinner / Snakefile
Last active February 15, 2019 07:28
Snakefile for building presentations from Markdown using pandoc
import mistune
from lxml import html
from snakemake.utils import min_version
min_version('3.7.1')
rule all:
input: 'presentation.pdf'
rule pdf_to_png:
input: 'images/{filename}.pdf'
## 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)
@DarwinAwardWinner
DarwinAwardWinner / patreon-fees.R
Created December 7, 2017 18:36
code to compare the new and old Patreon fee structures described here: https://blog.patreon.com/updating-patreons-fee-structure/
library(magrittr)
library(dplyr)
library(ggplot2)
library(purrr)
library(forcats)
library(glue)
pledge.amount <- 1
x <- list(
Old_WorstCase=c(
@DarwinAwardWinner
DarwinAwardWinner / # argyll-cms - 2017-08-20_11-54-00.txt
Created August 20, 2017 18:55
argyll-cms on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for argyll-cms on macOS 10.11.6
Build date: 2017-08-20 11:54:00
;;; 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: