Skip to content

Instantly share code, notes, and snippets.

View LiYingWang's full-sized avatar
:octocat:
Working

LI-YING WANG LiYingWang

:octocat:
Working
View GitHub Profile
@benmarwick
benmarwick / inspect-rmd-diff-from-last-commit.R
Last active May 23, 2025 03:30
GitHub doesn't show rich diffs for Rmd files. That can make collaborative writing tough. Here's how to see rich diffs of two commits of a single R Markdown document on a GitHub repo or local Git repo
# another method
# remotes::install_github("ropenscilabs/reviewer")
browseURL(reviewer::diff_rmd("analysis/paper/paper.qmd",
# this gets the sha of the previous commit
git2r::commits(n=2)[[2]]$sha)$raw)
@benmarwick
benmarwick / wikipedia-page-edit-proportions.R
Last active February 11, 2019 13:10
Inspect the edit history of a bunch of wikipedia pages to measure the proportion of the page contributed by each editor
library(tidyverse)
the_pages <- c(
"https://en.wikipedia.org/wiki/Angela_McGowan",
"https://en.wikipedia.org/wiki/Caroline_Bird_(archaeologist)",
"https://en.wikipedia.org/wiki/Jo_McDonald",
"https://en.wikipedia.org/wiki/Laurajane_Smith",
"https://en.wikipedia.org/wiki/Louise_Zarmati",
"https://en.wikipedia.org/wiki/Marcia-Anne_Dobres",
"https://en.wikipedia.org/wiki/Sarah_Colley",
@benmarwick
benmarwick / academicjobs.wikia.com.R
Last active April 7, 2023 17:17
Scraping academic jobs on wikia.com
library(tidyverse)
base_url <- "http://academicjobs.wikia.com/wiki/Archaeology_Jobs_"
# starts at 2010-2011
years <- map_chr(2010:2019, ~str_glue('{.x}-{.x +1}'))
# though it seems to start at 2007-8: https://academicjobs.fandom.com/wiki/Archaeology_07-08
urls_for_each_year <- str_glue('{base_url}{years}')