Skip to content

Instantly share code, notes, and snippets.

View seriousManual's full-sized avatar
🐷
stuff

Manuel Ernst seriousManual

🐷
stuff
View GitHub Profile
@seriousManual
seriousManual / Foo.js
Last active August 29, 2015 13:58
i2c blocking
function Foo() {
Emitter.call(this);
this._init(function(error) {
console.log('init done');
if (error) {
that.emit('error', error);
} else {
that.emit('initialize');
}
@seriousManual
seriousManual / gist:761f2d9dc5b252f92e29
Last active August 29, 2015 14:06
REST API invalidation scheme
thoughts on possible concept to cache responses of a rest api
* save any response to GET with the called URL as the key (including relevant get parameters like limit, offset or order)
* on each POST to a certain resource invalidate cache keys by the following scheme
POST /user
/user(\?(.+))?
POST /user/1/transaction
/user
@seriousManual
seriousManual / file1.js
Created September 17, 2014 11:26
iterate an array of arrays
var _ = {
concat: function() {
var arrays = Array.prototype.slice.call(arguments);
return {
forEach: function(iterator) {
arrays.forEach(function(subArray) {
subArray.forEach(function(value) {
iterator(value);
});
@seriousManual
seriousManual / macro.sjs
Last active August 29, 2015 14:06
inline arguments via sweet js
macro inlineArgs {
rule {} => {
(function(outerArguments) {
var argsArray = [];
for (var i = 0; i < outerArguments.length; i++) {
argsArray.push(outerArguments[i]);
}
return argsArray;
})(arguments)
}
@seriousManual
seriousManual / gist:b862a26326147f87f2bc
Created October 2, 2014 12:45
deployment strategy
Project I: Foo_API
Project II: Foo_Frontend
Project III: Foo_Configuration
Project IV: Bundle of API, Frontend, Configuration
Build, Test and Deployment of all four Projects should happen whenever one of the four projects changes.
@seriousManual
seriousManual / SitemapXml.php
Last active August 29, 2015 14:18
shopware sitemap
<?php
/**
* Shopware 4
* Copyright © shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
@seriousManual
seriousManual / combinations.js
Last active August 29, 2015 14:22
Lazy creation of all combinations of a array of arbitrary length
var iterator = combinations([1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13]);
var handle = setInterval(function() {
var next = iterator.next();
if (next.done) {
clearInterval(handle);
} else {
console.log(next.value);
}
}, 1000);
@seriousManual
seriousManual / StateWrapper.js
Last active August 29, 2015 14:27
wrapper the altitude state
var Emitter = require('events').EventEmitter;
var util = require('util');
function StateWrapper(client) {
Emitter.call(this);
this._state = {
altitude: 0
};
@seriousManual
seriousManual / asynchronicity_synchronicity
Created February 15, 2012 08:42
showing the problem of asynchrounos functions that behave not asynchrounos
function myObject() {
function initialize() {
//do something
someAsynchrounosFunction( function (err, data) {
this.emit( 'init' );
} );
}
initialize();
@seriousManual
seriousManual / node_irrational_highCPU
Created March 29, 2012 13:13
replicating very high cpu usage when not doing any calculation at all
var data = []
,number = 5000
,numberElements = 130
,numberQueries = 15;
for( var i = 0; i < number; i++ ) {
data[ i ] = {};
for( var x = 0; x < numberElements; x++ ) {