Skip to content

Instantly share code, notes, and snippets.

@warrenca
warrenca / https-socket-nginx.conf
Last active April 13, 2016 02:51
Nginx configuration for web socket server and api web server on top of HTTPS
# HTTP protocol
server {
underscores_in_headers on;
listen 80;
server_name yourwebsite.com;
return 301 https://$server_name$request_uri;
}
# HTTPS server
server {
@warrenca
warrenca / prepare-commit-msg
Created January 18, 2016 03:36
Auto-add git branch on commit
#!/bin/sh
# This file must be executable
# chmod u+x .git/hooks/prepare-commit-msg
BRANCH_NAME=$(git symbolic-ref --short HEAD)
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ]; then
# use ~ instead of / to accomodate branch names with forward slash
# e.g. branch name "user/feature-name-"
sed -i.bak -e "1s~^~[$BRANCH_NAME] ~" $1
fi
@warrenca
warrenca / ssh-socks-proxy
Created January 18, 2016 03:35
SOCKS Proxy for iOS and other mobile devices
# In your terminal, do this to make an SSH Proxy
# ssh -D <your computers IP>:8080 -N -C <username>@<remote server IP> -p <port number>
# ssh -D 192.168.0.100:8080 -N -C user@50.50.50.50
# Follow this to put in additional setup in your computer and phone
# http://www.systutorials.com/4876/how-to-configure-ios-for-iphone-and-ipad-to-use-socks-proxy-created-by-ssh/
@warrenca
warrenca / sendOverride.js
Created January 18, 2016 03:32
express sendOverride()
/**
* sendOverride()
* Override response.send to do nothing when response is already sent
* This is to minimize the error message
*/
function responseSendOverride() {
return function(req,res,next){
var _send = res.send;
var sent = false;
(function() {
/* == GLOBAL DECLERATIONS == */
TouchMouseEvent = {
DOWN: "touchmousedown",
UP: "touchmouseup",
MOVE: "touchmousemove"
}
/* == EVENT LISTENERS == */