Skip to content

Instantly share code, notes, and snippets.

(function() {
/* == GLOBAL DECLERATIONS == */
TouchMouseEvent = {
DOWN: "touchmousedown",
UP: "touchmouseup",
MOVE: "touchmousemove"
}
/* == EVENT LISTENERS == */
@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;
@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 / 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 / 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 / bamboo-to-slack.py
Created August 3, 2016 14:20 — forked from remmelt/bamboo-to-slack.py
Post an Atlassian Bamboo build result to Slack
#!/usr/bin/python
"""
Create a stage in your project, make it the last stage.
Make a task in the stage with this inline script:
#! /bin/bash
/some/path/bamboo-to-slack.py "${bamboo.planKey}" "${bamboo.buildPlanName}" "${bamboo.buildResultsUrl}"
@warrenca
warrenca / ultimate-ut-cheat-sheet.md
Created December 22, 2016 03:12 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@warrenca
warrenca / callback-hell.js
Created March 3, 2017 10:33
Callback hell
function process(callback) {
var name = "john";
if (name==="john") {
callback(null, "My name is john");
} else {
callback("I am not john");
}
}
process(function(error, message) {
@warrenca
warrenca / async-await.js
Last active May 17, 2017 23:25
Async/Await ES7
async function process() {
let name="john";
if (name==="john") {
return Promise.resolve("My name is john");
} else {
return Promise.reject("I am not john");
}
}