Skip to content

Instantly share code, notes, and snippets.

@c-l-nguyen
c-l-nguyen / init.lua
Last active February 28, 2021 10:55
Hammerspoon virtual numpad for macOS
k = hs.hotkey.modal.new('ctrl-shift', 'n')
function k:entered() hs.alert'Virtual Numpad' end
function k:exited() hs.alert'Exit Virtual Numpad' end
k:bind('ctrl-shift', 'n', function() k:exit() end)
hs.fnutils.each({
{ key='j', padkey='pad1'},
{ key='k', padkey='pad2'},
{ key='l', padkey='pad3'},
{ key='u', padkey='pad4'},
@c-l-nguyen
c-l-nguyen / clean_git_repo.sh
Created February 1, 2020 23:25
clean large repo
# find top 10 largest files
git rev-list --objects --all | grep -f <(git verify-pack -v .git/objects/pack/*.idx| sort -k 3 -n | cut -f 1 -d " " | tail -10)
# clean repo
git filter-branch --index-filter 'git rm --cached --ignore-unmatch *.mov' -- --all
rm -Rf .git/refs/original
rm -Rf .git/logs/
git gc --aggressive --prune=now
# push changes
@c-l-nguyen
c-l-nguyen / up-in-the-airbnb-stopwords.py
Last active January 23, 2020 05:06
stopwords used for wordcloud
# define stopwords to remove in word cloud
# some of these words were not useful in describing an area
# others were just so obvious that they appeared too much to be useful
stopwords = set(STOPWORDS)
unigram_stopwords = ["clean", "nice", "perfect", "austin", "great", "place", "stay", "definitely",
"would", "host", "house", "location", "home", "beautiful", "highly", "recommend",
"comfortable", "space", "would", "us", "everything", "'s", "bed", "amazing",
"room", "apartment", "ing", "really", "loved", "wonderful", "good", "needed",
"time", "thank", "need", "ed"]
@c-l-nguyen
c-l-nguyen / data-melt.py
Last active January 17, 2021 17:16
Melt pandas DataFrame from wide, fat format to long, skinny format
import pandas as pd
df = pd.read_csv("Global Temperature Anomalies.csv")
print(df.columns)
# parameter values
id_vars = ['Hemisphere', 'Year']
cols_to_pivot = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'J-D', 'D-N', 'DJF', 'MAM', 'JJA',
'SON']