Skip to content

Instantly share code, notes, and snippets.

@ondblclick
ondblclick / Hex.js
Created January 17, 2018 19:41
Hexagons math
class Hex {
static DIRECTIONS = [
new Hex({ q: 1, r: 0, s: -1 }),
new Hex({ q: 1, r: -1, s: 0 }),
new Hex({ q: 0, r: -1, s: 1 }),
new Hex({ q: -1, r: 0, s: 1 }),
new Hex({ q: -1, r: 1, s: 0 }),
new Hex({ q: 0, r: 1, s: -1 }),
];
@ondblclick
ondblclick / gist:1affae69fa4f579f3e0b25b677c4b665
Created December 22, 2016 09:23
Splitting string into chunks
function getChunkedString(str) {
return str.match(/.{1,3}/g).join('-');
}
moduleKeywords = ['extended', 'included']
class App.Classes.Module
@extend: (obj) ->
for key, value of obj when key not in moduleKeywords
@[key] = value
obj.extended?.apply(@)
@
@ondblclick
ondblclick / get_query_params.js
Created October 28, 2015 11:55
Parse search string
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {};
var tokens;
var re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
return params;
}