Skip to content

Instantly share code, notes, and snippets.

@alexanderGugel
alexanderGugel / logger.js
Created Jun 16, 2014
Minimal Node.JS logger for 12-factor apps
View logger.js
// 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 Aug 29, 2015
Linked List without a single if-statement? - Challenge accepted!
View linkedList.js
// PoC: Implemented methods: addToTail(value), removeHead() #=> value, contains(value) #=> boolean
var tail = {
next: this,
removeHead: function () {
return null;
},
contains: function (value) {
return false;
},
View gist:d473ccc6270eba16cdcf
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 Nov 6, 2014
Recursively extract keys from nested object
View gist:aceb9d83c3769d113853
var object = {
hello: 'world',
hallo: {
german: 'welt',
test: {
test: true,
test: false
}
}
};
@alexanderGugel
alexanderGugel / gist:c77c65ac881da9e82f41
Created Nov 12, 2014
JS: Return all matches instead of only the first one when executing a regular expression on a string
View gist:c77c65ac881da9e82f41
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 Nov 29, 2014
My slate configuration (stolen from someone else)
View .slate.js
slate.configAll({
'defaultToCurrentScreen': true,
'checkDefaultsOnLoad': true
});
var layout = {
maximize: S.op('move', {
'x' : 'screenOriginX',
'y' : 'screenOriginY',
'width' : 'screenSizeX',
View .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
View gist:f3a20f8dc42f4726e0d0
<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>
View gist:a20d920f6c4e059c6cb4
<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>
@alexanderGugel
alexanderGugel / ping.go
Created Mar 29, 2015
PING server using Go
View ping.go
// Start using
// go run ping.go -addr=:3141
// Query using
// nc -u localhost 3141
package main
import (
"log"
"net"