Skip to content

Instantly share code, notes, and snippets.

@maephisto
maephisto / git-pre-commit-hook validator
Last active August 29, 2015 14:14
Pre-commit hook doing a jshint and less before comitting.
#!/bin/sh
echo "\nLet me check if you can commit!"
jsFiles=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
lessFiles=$(git diff --cached --name-only --diff-filter=ACM | grep ".less$")
if [ "$jsFiles" = "" ]; then
echo "\033[32mNo JavaScript files were modified.\033[0m"
if [ "$lessFiles" = "" ]; then
@maephisto
maephisto / DustJS Access Array By Index
Created March 6, 2015 10:18
How to access elements by index in DustJs
{#names}{@idx}
{@if cond="('{.}' == 0)"}
First is: {name}
{:else}
Other: {name}
{/if}
{/idx}{/names}
@maephisto
maephisto / git-prepush-hook
Last active August 29, 2015 14:19
git prepush hook
#!/bin/sh
echo "\nLet me check if you can push this!"
echo "\nExecuting unit tests..."
testValidationResult=$(grunt test | grep "Done, without errors")
if [ "$testValidationResult" != "" ]; then
echo "\033[32mUnit tests execution passed. Wow, such tests, much green!\033[0m"
else
@maephisto
maephisto / Bohemian Rhapsody in Javascript
Created May 20, 2015 10:14
Bohemian Rhapsody in Javascript
try {
assert(Life.isReal);
assert(Life.isFantasy);
} catch (LandSlideException ex) {
while(!Reality.isEscapable) {
self.eyes.forEach(function(eye) {
eye
.open()
.lookTo(Sky)
.see();
@maephisto
maephisto / expressive-console.js
Created August 28, 2017 14:29
A expressive layer added on top of Javascript's `console` to better illustrate what that voice in your mind is saying.
var _log = console.log;
var _error = console.error;
var _warning = console.warn;
console.error = function (errMessage) {
errMessage = 'Ooooh 💩💩💩 : ' + errMessage;
_error.apply(console, arguments);
};
console.log = function (logMessage) {
@maephisto
maephisto / module-README.md
Last active June 26, 2018 07:10
Module README template

Package name

Short description about the intended purpose of the package.E.g. This package offers a way to create and manage dragons.

Usage

How does one use this package? Provide examples. E.g. Package can be installed from NPM registry via npm i dragon

Package API

Documents the public API fo the module. E.g.