Skip to content

Instantly share code, notes, and snippets.

@alexanderGugel
alexanderGugel / logger.js
Created June 16, 2014 03:54
Minimal Node.JS logger for 12-factor apps
// Usage:
// var logger = require('./logger');
// logger.debug('Debug message');
// logger.info('Info message');
// logger.warn('Warn message');
// logger.error('Error message');
// logger.addLevels({
// silly: 'white'
// });
// logger.silly('Silly message');
@alexanderGugel
alexanderGugel / linkedList.js
Last active August 29, 2015 14:04
Linked List without a single if-statement? - Challenge accepted!
// PoC: Implemented methods: addToTail(value), removeHead() #=> value, contains(value) #=> boolean
var tail = {
next: this,
removeHead: function () {
return null;
},
contains: function (value) {
return false;
},
@alexanderGugel
alexanderGugel / gist:d473ccc6270eba16cdcf
Created November 5, 2014 16:20
Node.JS email to gravatar
var crypto = require('crypto');
var getGravatarImage = function (email) {
return ('//www.gravatar.com/avatar/' + md5(email)).trim();
};
var md5 = function (str) {
var hash = crypto.createHash('md5');
hash.update(str.toLowerCase().trim());
return hash.digest('hex');
@alexanderGugel
alexanderGugel / gist:aceb9d83c3769d113853
Created November 6, 2014 18:13
Recursively extract keys from nested object
var object = {
hello: 'world',
hallo: {
german: 'welt',
test: {
test: true,
test: false
}
}
};
@alexanderGugel
alexanderGugel / gist:c77c65ac881da9e82f41
Created November 12, 2014 00:15
JS: Return all matches instead of only the first one when executing a regular expression on a string
var execMultiple = function (regex, str) {
var match = regex.exec(str);
var matches = [];
while (match != null) {
matches.push(match);
match = regex.exec(str);
}
return matches;
};
@alexanderGugel
alexanderGugel / .slate.js
Created November 29, 2014 20:51
My slate configuration (stolen from someone else)
slate.configAll({
'defaultToCurrentScreen': true,
'checkDefaultsOnLoad': true
});
var layout = {
maximize: S.op('move', {
'x' : 'screenOriginX',
'y' : 'screenOriginY',
'width' : 'screenSizeX',
@alexanderGugel
alexanderGugel / .gitconfig
Created December 2, 2014 19:11
My .gitconfig
[user]
name = Alexander Gugel
email = alexander.gugel@gmail.com
[alias]
lazy = !git add -A && git commit -m 'Too lazy for a commit message'
yolo = push origin master --force
back = revert HEAD
pom = !git pull origin master && git push origin master
shit = reset --hard HEAD
<h2>Buttons</h2>
<button class="white">white</button>
<button class="red">red</button>
<button class="pink">pink</button>
<button class="purple">purple</button>
<button class="deep-purple">deep-purple</button>
<button class="indigo">indigo</button>
<button class="blue">blue</button>
<button class="light-blue">light-blue</button>
<button class="cyan">cyan</button>
<div class="card depth-0">card depth-0</div>
<div class="card depth-1">card depth-1</div>
<div class="card depth-2">card depth-2</div>
<div class="card depth-3">card depth-3</div>
<div class="card depth-4">card depth-4</div>
<div class="card depth-5">card depth-5</div>
@alexanderGugel
alexanderGugel / ping.go
Created March 29, 2015 16:07
PING server using Go
// Start using
// go run ping.go -addr=:3141
// Query using
// nc -u localhost 3141
package main
import (
"log"
"net"