Skip to content

Instantly share code, notes, and snippets.

View stewartli's full-sized avatar
😋

stewartli stewartli

😋
View GitHub Profile
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# ##### ### # #####
# # # # # # # # #
# # # # # # # #
# ##### # # # # #####
# # # # ####### # #
# # # # # # #
# ####### ### # #####
gen_plot <- function(xvals = c(1,12), yvals = c(1,10), n = 10,
distance = seq(-3,3,length.out =n),
seed = NULL, palette = c("red", "blue")){
# adapted from: https://stackoverflow.com/questions/50275195/
segment.shift <- function(x1,x2,y1,y2, d){
# calculate vector
v <- c(x2 - x1,y2 - y1)
---
title: "Fancy math"
output:
html_document: default
pdf_document: default
---
```{r setup, include=FALSE}
# Conditional tikz output types; use PDF if this is LaTeX, otherwise use a
# shrunken down high resolution PNG
@schochastics
schochastics / yt_rstudio.R
Last active February 1, 2024 13:55
Play youtube videos in Rstudio viewer pane
library(shiny)
xy <- c(784,479) #output of grDevices::dev.size("px")
url <- "https://www.youtube.com/watch?v=Ef2jmf2vy00" #copy yt link here
url <- gsub("watch\\?v=","embed/",url)
ui <- fluidPage(
HTML(paste0('<iframe width="',xy[1],'" height="',xy[2],'" src="',url,'" frameborder="0"></iframe>'))
)
server <- function(input, output, session) {
}
@bradtraversy
bradtraversy / mongodb_cheat_sheet.md
Last active November 17, 2024 10:01
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@PaulC91
PaulC91 / babynames.R
Last active October 26, 2018 12:03
R code to create tidy data frame from ONS Baby names in England and Wales, 1996 to 2017 excel file
# Data available here
# https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/birthsdeathsandmarriages/livebirths/adhocs/009010babynames1996to2017englandandwales/adhocallbabynames1996to2017.xls
library(tidyverse)
library(readxl)
rank_names <- map_chr(2017:1996, paste0, "-rank")
count_names <- map_chr(2017:1996, paste0, "-count")
cnames <- c(rank_names, count_names) %>% sort(decreasing = TRUE)
@hrbrmstr
hrbrmstr / final.png
Last active March 3, 2019 05:27
composite a footer onto a ggplot plot – highly recommend doubling h & w, res = 144 and more customizing. this was a quick hack for someone.
final.png