Skip to content

Instantly share code, notes, and snippets.

View davidchchang's full-sized avatar
💭
We're Hiring!

David Chang davidchchang

💭
We're Hiring!
View GitHub Profile
@davidchchang
davidchchang / rotate.sh
Created May 22, 2022 15:23
Rotate an image using default macOS Terminal CLI
# Rotates image.jpg 23 degrees clockwise and "fill in" the empty space with white.
# If you rotate PNGs, the alpha channel should be retained.
# From: https://apple.stackexchange.com/a/60570/106967
sips -r 23 --padColor FFFFFF image.jpg
@davidchchang
davidchchang / git-tricks.md
Created November 24, 2021 16:22
Git Commands to Know

From Chris:

TIL: If you want to modify some files on your local environment that you should not commit for some reason git update-index --skip-worktree <file_name> is the git command you need to avoid having to remember to NOT commit these files. It will ignore the changes and keep your git status clean

@davidchchang
davidchchang / npm-autoswitch.zshrc
Created May 8, 2020 14:48
Add this to .zshrc to automatically switch node versions
# Auto switch node version
autoload -U add-zsh-hook
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
elif [[ $(nvm version) != $(nvm version default) ]]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
@davidchchang
davidchchang / clean-everything.sh
Last active March 24, 2020 20:07 — forked from simistern/gist:bb026e68877b6d49cb54e1740328159b
Catch-all script for clearing react-native caches and resetting the build (this uses yarn)
echo "Cleaning up node modules";
rm -rf node_modules;
yarn install;
echo "Clearing all temp directories";
rm -rf $TMPDIR/react-native-packager-cache-*;
rm -rf $TMPDIR/metro-*;
rm -rf $TMPDIR/react-*;
rm -rf $TMPDIR/haste-*;
watchman watch-del-all;
echo "Cleaning up iOS folders"
@davidchchang
davidchchang / index1.html
Created February 27, 2020 16:55
Super simple cross-tab cookie test
<html>
<head>
</head>
<body>
<div id="test"></div>
<script type="text/javascript">
document.cookie = "username=John Smith; expires=Thu, 18 Dec 2020 12:00:00 UTC; path=/";
setInterval(function() {
document.getElementById("test").innerHTML = document.cookie;
}, 1000);
@davidchchang
davidchchang / docker-commands.sh
Created February 24, 2020 16:11
Docker Command Reference
# Use this after stopping leaf (docker) to clean out docker images and volumes and free up space on your machine.
# NOTE: This is a destructive command, if you have other docker images or volumes apart from leaf they will all get removed.
docker system prune -af && docker volume prune -f
# Installing php56-mongodb:
==> Installing homebrew/php/php56-mongodb dependency: libxml2
==> Downloading https://homebrew.bintray.com/bottles/libxml2-2.9.4_2.sierra.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring libxml2-2.9.4_2.sierra.bottle.1.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
macOS already provides this software and installing another version in
@davidchchang
davidchchang / xdebug-setup.md
Last active March 16, 2017 17:24
Getting xdebug, MongoDB integrated with your local Docker containers on Mac

Installing PHP with Xdebug on Mac OS X (Sierra) and integrating with PhpStorm (2016.3.2) and Docker (Alpine Linux)

Installing xdebug on Alpine Linux

Update your docker-compose.yml:

# docker-compose.yml
server:
  build: . # path to Dockerfile

expose:

@davidchchang
davidchchang / parse.py
Last active August 8, 2016 05:53
Find all recent events (on Macs)
import sys
from icalendar import Calendar, Event
for line in sys.stdin:
# line = 2016-08-08 01:07:17.000000000 -0400 ./Calendar Cache-wal
filename = line[36:].strip()
if filename[-3:] != "ics":
print 'skipping: ', filename
continue
# DTSTART;VALUE=DATE:20150620
# DTEND;VALUE=DATE:20150621
@davidchchang
davidchchang / setup.txt
Last active February 3, 2016 16:11
Setup xdebug to run on localhost with PhpStorm
// Run the following:
brew install php55-xdebug
// where 55 is the PHP version number (php -v) - in this case, PHP 5.5
// You may be required to change permissions before you can install php55:
sudo chown -R $USER:admin /usr/local
// where $USER is your local account
// Caveats:
To finish installing xdebug for PHP 5.5: