Skip to content

Instantly share code, notes, and snippets.

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

Rob Cornelius robcornelius

🏠
Working from home
View GitHub Profile
@lkrych
lkrych / stubbing_fetch_api.js
Created November 6, 2017 16:16
Stubbing the fetch API with sinon
////Constants //////////////////////////////////////////////
function jsonOk (body) {
var mockResponse = new window.Response(JSON.stringify(body), { //the fetch API returns a resolved window Response object
status: 200,
headers: {
'Content-type': 'application/json'
}
});
@midu
midu / no-console.log.sh
Created November 8, 2011 21:05
pre-commit git hook to prevent console.log in javascript files
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='console.log'
git diff --cached --name-only | grep -E $FILES_PATTERN | GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo 'COMMIT REJECTED Found "console.log" references in your javascript. Please remove them before commiting';
# my zsh does annoying things with !
[ $? -ne 0 ]