Skip to content

Instantly share code, notes, and snippets.

View der-On's full-sized avatar

der_On der-On

View GitHub Profile
@der-On
der-On / formatters.js
Last active August 29, 2015 14:14
Chainable formatters
"use strict";
/*
Chainable formatters
Usage:
function trim(value) {
return value.trim();
}
@der-On
der-On / promisify_models.js
Last active August 29, 2015 14:14
promisify geddy models
"use strict";
/*
Usage:
require('./promisify_models')(geddy.model);
geddy.model.allPromise()
.then(function(result) { ... })
.catch(function(err) { throw err; });
@der-On
der-On / improve_model_assocs.js
Created June 20, 2015 07:20
Improve model associations with loader methods and promises
/**
* Adds a loader method to the model innstance that will automatically populate the property for the assoc after load
* Example: this.belongsTo('User') will add a "loadUser" method
* @param instance
*/
module.exports.improveAssocs = function(instance)
{
var model = getModel();
var type = instance.type;
var def = model.descriptionRegistry[type];
@der-On
der-On / metalsmith_express_dynamic_page.js
Created January 29, 2016 21:58
Express middleware to create a dynamic HTML page using metalsmith.
'use strict';
var metalsmith = require('metalsmith');
var layouts = require('metalsmith-layouts');
var fs = require('fs');
var lorem = fs.readFileSync('./lorem.txt', 'utf8');
var n = 0;
// generates a single page
@der-On
der-On / run_cron.php
Last active August 22, 2016 08:34
Syncs all files for contao metamodels openimmo
<?php
// initialize the contao framework
define('TL_MODE', 'FE');
require('../system/initialize.php');
$cron = new \MetaModelsOpenImmo\Cron();
$cron->run();