Skip to content

Instantly share code, notes, and snippets.

@fanghuiz
fanghuiz / soc
Created Nov 5, 2019 — forked from nkthiebaut/soc
Codes to names mapping for the O*NET-SOC job titles classification (https://www.onetcenter.org/taxonomy.html)
View soc
SOC_MAJOR_GROUPS = {
"11": "Management Occupations",
"13": "Business and Financial Operations Occupations",
"15": "Computer and Mathematical Occupations",
"17": "Architecture and Engineering Occupations",
"19": "Life, Physical, and Social Science Occupations",
"21": "Community and Social Service Occupations",
"23": "Legal Occupations",
"25": "Education, Training, and Library Occupations",
"27": "Arts, Design, Entertainment, Sports, and Media Occupations",
@fanghuiz
fanghuiz / map_active_fire.R
Created Sep 23, 2019
Animated map showing daily active fires in Indonesia this September
View map_active_fire.R
# Set up
library(ggplot2)
library(dplyr)
library(ggmap)
library(maps)
library(gganimate)
# Request raw data from https://firms.modaps.eosdis.nasa.gov/active_fire/#firms-txt
# Data used for this map
url <- "https://raw.githubusercontent.com/fanghuiz/random_viz/master/data/fire_IND_201909.csv"
@fanghuiz
fanghuiz / movie_color_bar.py
Last active Mar 2, 2022
Script to generate a color timeline based on video input (movie etc.) Modified from https://github.com/lint/avg-color-bar
View movie_color_bar.py
from PIL import Image, ImageEnhance
import os
import subprocess
import sys
# Requires ffmpeg https://www.ffmpeg.org/ffmpeg.html
# Run script as
# python movie_color_bar.py input_video output_frame_folder output_image
@fanghuiz
fanghuiz / heatmap_daily_temp_england.R
Created Sep 4, 2019
Create heatmap to visualize the daily temperature in England over 100 years
View heatmap_daily_temp_england.R
library(tidyverse)
library(lubridate)
# Dataset URL
url_eng_daily_max <- "https://www.metoffice.gov.uk/hadobs/hadcet/cetmaxdly1878on_urbadj4.dat"
# Read in data from URL
eng_daily_max <- data.table::fread(
url_eng_daily_max,
# Encode -999 as NA