Skip to content

Instantly share code, notes, and snippets.

@AliciaSchep
AliciaSchep / git-branches-by-commit-date.sh
Created April 22, 2019 17:34 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@AliciaSchep
AliciaSchep / cute_email_gadget.R
Created April 14, 2019 16:24
Shiny Gadget For Emailing Cute Puppies
library(shiny)
library(miniUI)
library(gmailr)
library(rtweet)
library(purrr)
use_secret_file("~/client_id.json")
send_email <- function(to_address, picture_url, msg = "",
subject = "Cute Picture", expanded_url = picture_url){
@AliciaSchep
AliciaSchep / plotly_dropdown_example.R
Created April 14, 2019 16:20
Plotly Dropdown Example
p <- plot_ly(mtcars, x = ~wt) %>%
add_markers(y = ~mpg, name = "A") %>%
add_markers(y = ~hp, name = "B", visible = F) %>%
layout(
title = "Drop down menus - Update",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "mpg"),
updatemenus = list(
list(
y = 0.7,
@AliciaSchep
AliciaSchep / deploy_to_gh_pages.r
Last active March 9, 2019 18:10
Deploy a pkgdown site to gh_pages branch
## Adapted from r-lib/pkgdown source code from RStudio https://github.com/r-lib/pkgdown
## Helper functions, directly from pkgdown code --------------------------------
git <- function(...) {
processx::run("git", c(...), echo_cmd = TRUE, echo = TRUE)
}
github_clone <- function(dir, repo_slug) {
remote_url <- sprintf("git@github.com:%s.git", repo_slug)
cli::rule("Cloning existing site", line = 1)
@AliciaSchep
AliciaSchep / event_listener_bug_example.Rmd
Created April 12, 2018 05:01
Example document showcasing a bug with inappropriate insertion of wheel event listener by rstudio in rmarkdown inline view / notebook
---
title: "event listener bug"
author: "Alicia Schep"
date: "April 11, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@AliciaSchep
AliciaSchep / get_libs_used.r
Created February 19, 2018 07:17
Find the r packages used in directory
get_r_files <- function(path = ".", recursive = FALSE, include_rmd = TRUE){
all_files <- normalizePath(list.files(path, full.names = TRUE,
recursive = recursive))
r_files <- grep(".*\\.(r|R)$", all_files, value = TRUE)
if (include_rmd){
r_files <- c(r_files,
grep(".*\\.(r|R)md$", all_files, value = TRUE))
}
@AliciaSchep
AliciaSchep / fresh_r_libraries.r
Created February 19, 2018 06:01
Setup use of a new, fresh library directory in R
create_lib_dir <- function(name, path = "."){
dir_path <- file.path(path, name)
if (!dir.exists(dir_path)) {
message("Creating new dir: ", dir_path)
dir.create(dir_path)
}
normalizePath(dir_path)
}
setClass("DummyClass",
slots = c(y = "numeric"))
setClass("SpecialClass",
slots = c(x = "numeric"),
contains = c("DummyClass"))
setClass("SpecialList",
@AliciaSchep
AliciaSchep / get_footprint.R
Created November 30, 2017 04:54
Compute aggregate footprint around position
library(GenomicRanges)
library(S4Vectors)
# Footprint does not include +/- 4 correction for ATAC-seq
# Modified tabulate funcion ----------------------------------------------------
tabulate2 <- function(x, min_val, max_val) {
if (max_val <= min_val) {
stop("max_val must be greater than min_val")
@AliciaSchep
AliciaSchep / complex_layout.json
Created November 19, 2017 05:07
vegalite hconcat plus vconcat plus layer
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "Two horizonally concatenated charts that show a histogram of precipitation in Seattle and the relationship between min and max temperature.",
"data": {
"url": "data/weather.csv",
"format": {
"type": "csv"
}
},
"transform": [