Skip to content

Instantly share code, notes, and snippets.

View erictleung's full-sized avatar
👨‍💻
Data sciencing

Eric Leung erictleung

👨‍💻
Data sciencing
View GitHub Profile
@erictleung
erictleung / check_associated_acts.py
Created January 30, 2024 04:01
Help audit, remove, and update musician infoboxes on Wikipedia
#!/usr/bin/env python3
"""
Help audit, remove, and update musician infoboxes.
https://en.wikipedia.org/wiki/Category:Pages_using_infobox_musical_artist_with_associated_acts
"""
import re
import requests
@erictleung
erictleung / extract_zoom_urls.sh
Last active January 25, 2024 18:15
Extract URls from Zoom chat
#!/usr/bin/env bash
# Description: Extract unique URLs from the plain text output from Zoom chat and
# save links to new file.
# Usage: bash extract_zoom_urls.sh
# Set path to where Zoom chat is, or `cd` to the directory itself
FILE=meeting_saved_chat.txt
# Get list of unique links shared in Zoom chat
@erictleung
erictleung / setup.sh
Last active October 28, 2022 19:22
Setup Exercism in Replit
# Follow instructions here for more:
# https://exercism.io/cli-walkthrough
# Releases:
# https://github.com/exercism/cli/releases
# Download and move around
# Change URL as needed for new versions
wget https://github.com/exercism/cli/releases/download/v3.1.0/exercism-3.1.0-linux-x86_64.tar.gz
mkdir bin
mv exercism bin/
@erictleung
erictleung / big_book_r_logo.R
Created June 13, 2022 16:57
Quick logo for Big Book of R
# Make logo
library(hexSticker)
library(showtext)
# Add Google Font
font_add_google(name = "Open Sans", family = "Open Sans")
showtext_auto() # Use this font in all rendering
# Picture of book that was quickly screenshot
imgurl <- "~/Downloads/Screenshot 2022-06-13 092720.png"
@erictleung
erictleung / smartphone_users.R
Last active May 4, 2022 19:55
Plot number of smartphone users over time, data from a tweet
library(dplyr)
library(stringr)
library(ggplot2)
d <- rtweet::search_tweets("from:stats_feed", n = 30) %>%
filter(status_id == "1521871339908263937") %>%
pull(text) %>%
str_split("\n") %>%
as_tibble(.name_repair = "universal") %>%
rename("data" = "...1") %>%
@erictleung
erictleung / example_data.csv
Created March 15, 2022 21:08
For each row, count number of other rows that fall within a time interval
start_date stop_date
1999-07-15 1999-11-15
1999-11-15 2000-02-15
1999-12-15 2000-02-15
2000-09-15 2002-02-15
2002-02-15 2003-12-15
2002-02-15 2003-12-15
2003-02-15 2004-03-15
2004-04-15 2004-08-15
2004-08-15 2005-04-15
@erictleung
erictleung / data_scientist_search.csv
Last active February 2, 2022 06:44
Correlation between data scientist and veganism
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
Category: All categories
Month,Data scientist: (United States)
2004-01,0
2004-02,0
2004-03,0
2004-04,0
2004-05,0
2004-06,0
2004-07,0
@erictleung
erictleung / google_trends_shows.R
Last active October 22, 2021 23:56
Google Trends plot for popular TV shows
@erictleung
erictleung / update_git.sh
Created July 26, 2021 05:31
Update local git repository from master to main branch on upstream
# Sources:
# - https://www.git-tower.com/learn/git/faq/git-rename-master-to-main/
# - https://gist.github.com/kelynch/9ba595e369c304b560477f3636b41e8a
git checkout master # Assumes master is default branch
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
@erictleung
erictleung / xaringan_outliner.R
Created July 18, 2021 21:59
Generate outline for {xaringan} presentations
# Load relevant packages
library(purrr)
library(stringr)
library(glue)
#' Programmatically generate xaringan outline
#'
#' @param file string name of generated xaringan RMarkdown
#' @param ... list of objects containing the structure for the presentation