Skip to content

Instantly share code, notes, and snippets.

@EnoF
EnoF / gist:8930564
Last active August 29, 2015 13:56
EnoFJS Inheritance
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
});
@EnoF
EnoF / gist:8930612
Last active August 29, 2015 13:56
Overriding the Bad way
function Animal(){}
Animal.prototype = {
name: 'animal',
sayHello: function sayHello(){
return 'Hi, my name is ' + this.name + '!';
}
};
function Dog(){}
@EnoF
EnoF / gist:8940237
Last active August 29, 2015 13:56
Override in EnoFJS
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
});
@EnoF
EnoF / gist:8940949
Created February 11, 2014 18:27
Protected in EnoFJS
var Animal = clazz(function Animal(){
this.protected = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.protected.name + '!';
}
};
});
@EnoF
EnoF / gist:8941149
Created February 11, 2014 18:37
Super and Constructor!
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
@EnoF
EnoF / gist:9256893
Created February 27, 2014 19:08
express.js example
'use strict';
var express = require('express');
var mongoskin = require('mongoskin');
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
function Router(){
this.addRoute = function addRoute(route){
route.url = route.url || 'defaultUrl';
route.name = route.name || 'defaultName';
// Do your stuff
}
}

REST.IO

Small extendable REST framework for express and mongoose. wercker status

Installation

$ npm install rest-io --save

New in v1.0.0

  • Custom Resource declarations
@EnoF
EnoF / banana.yml
Created May 8, 2016 14:51
Example rest-io Resource description
---
Banana
type: object
properties:
id:
type: string
description: Mongoose ID
description:
type: string
description: Some text to describe this specific banana
@EnoF
EnoF / dup.sh
Last active June 15, 2016 16:34
Docker UP
#!/bin/bash
function print_help_dup() {
echo " usage:"
echo " dup [-i|--image] (options)"
echo
echo " -i|--images required The name of the docker image you to load into your container"
echo " dup -i node"
echo " -cmd|--command optional Provide a different command to run"
echo " default: /bin/bash"