Skip to content

Instantly share code, notes, and snippets.

View maephisto's full-sized avatar

Marius Mischie maephisto

View GitHub Profile
@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.

@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 / 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 / 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 / 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-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 / solution.js
Created January 29, 2015 21:03
Trello Javascript challenge solution
// what we're working with
var characterList = 'acdegilmnoprstuw';
// what we're going for
var theHashWeWereLookingFor = 956446786872726;
var theMagicString = '';
//Now reverse engineer
while (theHashWeWereLookingFor > 7 ) {
var counter = 0;
@maephisto
maephisto / AWS base64 image upload
Created June 16, 2014 11:30
Node upload base64 image data to AWS
var config = {
"aws" : {
"bucket": "...",
"domain" : "...",
"prefix" : "..",
"path": "my/test/",
"credentials" : {
"accessKeyId": "...",
"secretAccessKey": "..."
}
@maephisto
maephisto / get languages spoken in a certain country (by country code)
Created February 28, 2014 14:38
This gist shows how to get languages spoken in a certain country (by country code)
var countryToLanguages = { AD: [ 'ca' ],
AE: [ 'ar', 'fa', 'en', 'hi', 'ur' ],
AF: [ 'fa', 'ps', 'uz', 'tk' ],
AG: [ 'en' ],
AI: [ 'en' ],
AL: [ 'sq', 'el' ],
AM: [ 'hy' ],
AO: [ 'pt' ],
AR: [ 'es', 'en', 'it', 'de', 'fr', 'gn' ],
AS: [ 'en', 'sm', 'to' ],
@maephisto
maephisto / Javascript ISO country code to country name conversion
Last active August 15, 2024 03:08
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',