Skip to content

Instantly share code, notes, and snippets.

View samtsai's full-sized avatar
🏠
Working from home

Sam Tsai samtsai

🏠
Working from home
View GitHub Profile
@samtsai
samtsai / Set permissions for npm
Last active August 29, 2015 14:02
Npm permissions
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
@samtsai
samtsai / setup_launch_agents.sh
Created March 26, 2014 17:39
Setup launch agents (useful for automating brew installs and their startup script)
# Set Up Launch Agent to Run On Startup
function set_launch_agent() {
# retrieve the dependency's prefix
DEP_PREFIX=$(brew --prefix ${1})
# make the user local LaunchAgents directory (skip if already exists)
mkdir -p ~/Library/LaunchAgents
# copy brew generated plist to LaunchAgent
cp $DEP_PREFIX/*${1}*.plist ~/Library/LaunchAgents/
# load the agent now
launchctl load -w ~/Library/LaunchAgents/*${1}*.plist
@samtsai
samtsai / npm short list
Created December 4, 2013 15:13
List npm global modules installed without dependencies
npm ls --depth 0 -g
@samtsai
samtsai / normalize analytic strings
Created May 7, 2013 15:32
quick normalize functions for grooming strings passed into an analytics library like SiteCatalyst
// this would be set in a closure
// but leave some values to be cached (ie not created every function call)
// and the ability to override
var norm_regex = /\s+/g;
var norm_replace = "_";
function normalize( val, reg_pattern, separator ) {
// convert to string
var norm_val = val+"";
norm_regex = reg_pattern || norm_regex;
@samtsai
samtsai / Perf.md
Created August 16, 2012 14:30
Gist.io - a new way to write?

Perf Notes

Souders

The true cause of frontend SPOF is loading a script, stylesheet, or font file in a blocking manner.

Tag management/TAAS/Universal Tagging/etc.

@samtsai
samtsai / Premise.md
Created March 13, 2012 20:14 — forked from jswartwood/Premise.md
AE Code Golf #1

Fibonacci Sequence

Classics series

Print the Fibonacci series (the first 10 values) separated by spaces. If you've ever taken a Computer Science class, you should be all over this one.