Skip to content

Instantly share code, notes, and snippets.

View sansmischevia's full-sized avatar

Bryant Chou sansmischevia

  • Webflow
  • San Francisco, CA
View GitHub Profile
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@sansmischevia
sansmischevia / .vimrc
Created December 16, 2011 09:23
.vimrc modified from niw
" .vimrc
" http://github.com/niw/profiles
"{{{ Initialize
if !exists('s:loaded_vimrc')
" Don't reset twice on reloading, 'compatible' has many side effects.
set nocompatible
endif
@sansmischevia
sansmischevia / mockDynamo.js
Created January 8, 2013 20:49
A mock dynamo client that helps unit testing.
var DATABASE = {};
/**
* Start awk-sdk mock
*/
exports.getItem = function(params, cb) {
if (params.AttributesToGet) {
var ret = {
Item: {}
};
@sansmischevia
sansmischevia / value.js
Created March 12, 2013 23:41
convert DynamoDb JSON to regular JSON javascript objects
function Value(value) {
switch (typeof value) {
case "number": return {N: String(value)}
case "string": return {S: value}
}
if (value) switch (typeof value[0]) {
case "number": return {NS: value.map(String)}
case "string": return {SS: value}
}
@sansmischevia
sansmischevia / post-commit
Created March 15, 2013 20:03
@raydog's awesome post commit hook that takes a picture after every commit
#!/bin/sh
dest="$HOME/git-commit-snapshots/"
mkdir -p $dest
path=$dest/`date +%s`.jpg
imagesnap -w 1 -q $path &
@sansmischevia
sansmischevia / cluster.js
Created April 3, 2013 07:26
basic cluster bootloader
var cluster = require('cluster'),
os = require('os'),
http = require('http');
// List of 'active' workers:
var workers = [];
var start_count = 0;
// The amount of time we wait before killing a process during a reload:
@sansmischevia
sansmischevia / org-mongodb-mongod-plist
Created April 3, 2013 08:14
launchctl plist for mongodb. path: /Library/LaunchDaemons/org.mongodb.mongod.plist
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>1024</integer>
</dict>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>1024</integer>
</dict>
@sansmischevia
sansmischevia / Graphite on Amazon Linux
Last active August 10, 2017 12:01 — forked from outmost/Graphite on Amazon Linux
Sets up graphite, carbon, whisper, and statsd on ami-3275ee5b
# AMI: ami-3275ee5b
# Login: ec2-user
# Apply updates
sudo yum update
# Enable Epel Repo
sudo vim /etc/yum.repos.d/epel.repo.
# Under the section marked [epel], change enabled=0 to enabled=1.
@sansmischevia
sansmischevia / nginx.conf
Last active July 3, 2023 15:26
nginx http proxy to s3 static websites
##
## This nginx.conf servers as the main config file for webflow reverse proxy
##
## RCS:
## https://gist.github.com/sansmischevia/5617402
##
## Hardening tips:
## http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html
##
@sansmischevia
sansmischevia / pre-commit
Created July 25, 2014 20:25
JSHint git pre-commit hook
#!/bin/sh
files=$(git diff --name-only --diff-filter=ACM | grep ".js$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
echo "\nValidating JavaScript:\n"