using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
/* == GLOBAL DECLERATIONS == */ | |
TouchMouseEvent = { | |
DOWN: "touchmousedown", | |
UP: "touchmouseup", | |
MOVE: "touchmousemove" | |
} | |
/* == EVENT LISTENERS == */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 [email protected] | |
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTTP protocol | |
server { | |
underscores_in_headers on; | |
listen 80; | |
server_name yourwebsite.com; | |
return 301 https://$server_name$request_uri; | |
} | |
# HTTPS server | |
server { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function process() { | |
let name="john"; | |
if (name==="john") { | |
return Promise.resolve("My name is john"); | |
} else { | |
return Promise.reject("I am not john"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
OlderNewer