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 / xp2b_3-20-6_manip_type_fix.py
Created May 3, 2014 17:54
XPlane2Blender 3.20.6 to 3.20.7 manipulator type fix
'''
This script fixes manipulator types in blends that have been created with XPlane2Blender <= 3.20.6.
Usage: Select the objects with wrongly assigned manipulator types and then run this script in Blender's text-editor.
'''
import bpy
for object in bpy.context.selected_objects:
if object.xplane.manip.enabled:
if object.xplane.manip.type == 'command':
@der-On
der-On / fn_prototype.js
Last active August 29, 2015 14:11
JS prototype with immediatly called function
// define constructor
function User() {
}
// define prototype using "this"
User.prototype = new (function() {
this.name = 'new User';
var pass = 'secret'
@der-On
der-On / db.js
Last active August 29, 2015 14:12
Geddy unit testing mocks and helpers
"use strict";
var exec = require('child_process').exec;
var sqlAdapters = ['mysql', 'sqlite', 'postgres'];
var utils = require('utilities');
function noop() {}
function getAdapter()
{
@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 / gist:5480130
Last active December 16, 2015 18:49
XPlane2Blender 3.20 manipulator type fix
'''
This script fixes manipulator types in blends that have been created with older versions of XPlane2Blender.
Usage: Select the objects with wrongly assigned manipulator types and then run this script in Blender's text-editor.
'''
import bpy
for object in bpy.context.selected_objects:
if object.xplane.manip.enabled:
if object.xplane.manip.type == 'delta':
@der-On
der-On / uploader.js
Created May 14, 2013 22:48
node.js uploader based on "formidable"
var formidable = require('formidable');
var path = require('path');
var fs = require('fs');
var UploaderException = function(message)
{
this.message = message;
this.toString = function()
{
return 'Uploader error: '+this.message;
@der-On
der-On / DateUtil.php
Created June 28, 2013 12:48
DateUtil
<?php
class DateUtil
{
public static $weekday_names = array(
1 => 'Montag',
2 => 'Dienstag',
3 => 'Mittwoch',
4 => 'Donnerstag',
5 => 'Freitag',
@der-On
der-On / application.js
Last active December 26, 2015 05:49
execute this method in a geddy controller needing cross-domain CORS
var Application = function () {
// allow cross domain XHR
this.allowCORS = function()
{
this.options = function(req, resp, params)
{
if (req.method.toLowerCase() == 'options') {
resp.setHeaders(200,{
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*',