Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan C. Thompson DarwinAwardWinner

  • Icahn School of Medicine at Mount Sinai
  • NYC area
View GitHub Profile
@DarwinAwardWinner
DarwinAwardWinner / shortsleep-unlock.py
Last active Nov 12, 2021
Script to auto-unlock GNOME after short sleeps
View shortsleep-unlock.py
#!/usr/bin/env python3
# shortsleep-unlock.py - Keep GNOME unlocked on short lid closes
# Copyright (C) 2021 Ryan C. Thompson <rct@thompsonclan.org>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
View badrepel.R
library(ggplot2)
library(ggrepel)
library(dplyr)
library(stringr)
library(scales)
## https://github.com/tidyverse/ggplot2/issues/980
mysqrt_trans <- function() {
trans_new("mysqrt",
transform = base::sqrt,
inverse = function(x) ifelse(x<0, 0, x^2),
@DarwinAwardWinner
DarwinAwardWinner / .Rprofile
Created Jan 11, 2020
The environment setup for my R profile
View .Rprofile
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")
View colville-rollstat.R
## License: WTFPL
library(reshape2)
library(matrixStats)
library(ggplot2)
library(magrittr)
library(dplyr)
## You also need the Hmisc package installed, but I don't load it
## because of namespace clashes with dplyr
## Enumerate all possible 4d6 rolls, then order each row from high to
View da_stunt.R
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
View statroll.R
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 Feb 15, 2019
Snakefile for building presentations from Markdown using pandoc
View Snakefile
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'
@DarwinAwardWinner
DarwinAwardWinner / analyze_pkg_usage.R
Last active Nov 27, 2020
Script for finding loaded but unused packages in R scripts
View analyze_pkg_usage.R
#!/usr/bin/env Rscript
suppressPackageStartupMessages({
library(globals)
library(readr)
library(stringr)
library(rex)
library(magrittr)
library(rlang)
library(knitr)
@DarwinAwardWinner
DarwinAwardWinner / patreon-fees.R
Created Dec 7, 2017
code to compare the new and old Patreon fee structures described here: https://blog.patreon.com/updating-patreons-fee-structure/
View patreon-fees.R
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 Aug 20, 2017
argyll-cms on macOS 10.11.6 - Homebrew build logs
View # argyll-cms - 2017-08-20_11-54-00.txt
Homebrew build logs for argyll-cms on macOS 10.11.6
Build date: 2017-08-20 11:54:00