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 / intro.js
Created January 7, 2014 15:32
dustjs: proposal for the persistent storage of compiled templates
var dust = require('dustjs-linkedin');
//whitespaces added for clarification
module.exports = (function(){
dust.register("intro",body_0);
function body_0(chk,ctx){
return chk.write("Hello ").reference(ctx._get(false, ["name"]),ctx,"h").write("!");
}
//whitespaces added for clarification
(function(){
dust.register("intro",body_0);
function body_0(chk,ctx){
return chk.write("Hello ").reference(ctx._get(false, ["name"]),ctx,"h").write("!");
}
return body_0;
})();
@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 / packstations.php
Last active February 1, 2021 15:14
Minimal code example for a SOAP call to the DHL API (Packstations search)
<?php
$userName = 'fooUser';
$password = 'fooPassword';
$endpoint = 'https://cig.dhl.de/services/sandbox/soap';
$client = new SoapClient("https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/standortsuche-api/1.0/standortsuche-api-1.0.wsdl", [
'login' => $userName,
'password' => $password,
'location' => $endpoint,