Skip to content

Instantly share code, notes, and snippets.

@formula1
formula1 / icecomm.es6
Created April 6, 2015 04:36
Angular2 + Icecomm if angular could handle setTimeouts
/* jshint esnext: true */
import {Component, Template, NgElement, For, If, bootstrap} from 'angular2/angular2';
// Annotation section
@Component({
selector: 'ice-comm'
})
@formula1
formula1 / install.js
Created April 4, 2015 08:33
Lazy Path Registration
var c = require("child_process");
var _ = require("lazy.js");
var fs = require("fs");
var matches = /^\s*(LIB|LIBPATH|PATH|PlatformToolset|sdkdir|TARGET_PLATFORM|VS\d{3}COMNTOOLS|WindowsSDKDir)=/;
var HOME = require("osenv").home();
if(process.argv[2] && process.argv[2].toString("utf8") === "uninstall"){
uninstall();
}else{
install();
@formula1
formula1 / SortFilerIterate.js
Created April 4, 2015 04:50
Functional Programming Example
function SortFilterIterate(array){
this.ari = array;
this.fliter = [];
}
SortFilterIterate.prototype.filter = function(fn){
this.fliters.push(fn);
return this;
}
@formula1
formula1 / bug.js
Last active August 29, 2015 14:18
vm timers and cancelling
var PassThrough = require("stream").PassThrough;
var temp = new PassThrough();
process.stdin.pipe(temp);
setImmediate(function(){
process.stdin.unpipe(temp);
});
@formula1
formula1 / merg.js
Last active August 29, 2015 14:17
Merging Arrays
function mergeUnIntersectingLists(lists, sortFn, order,iterator){
standardIterator(lists, sortFn, order,iterator,function(lists,order,i){
while(lists[i].length > 0){
var item = getOrder(lists[i],sortFn)==order?lists[i].shift():lists[i].pop();
iterator(item,i);
}
lists.splice(i,1);
});
}
@formula1
formula1 / easy.js
Created March 16, 2015 19:56
On the fly Middleware without editing the callback array
var MIDDLEWARE_TYPES = [
"validate",
"create",
"update",
"destroy"
];
var MIDDLEWARE_TIMINGS = [
"before",
"after"
@formula1
formula1 / .gitignore
Last active August 29, 2015 14:17
Waterline browser proof of concept
node_modules
npm-debug.log
@formula1
formula1 / waterline.js
Created March 16, 2015 17:15
Waterline Queue
var ee = require("events").EventEmitter;
function Waterline(){
ee.call(this);
this.adapters = {};
this.connections = {};
this.collections = {};
}
Waterline.prototype = Object.create(ee.prototype);
@formula1
formula1 / middleware.js
Created March 9, 2015 19:23
Middleware for waterline
var async = require("async");
function MIDDLEWARE_FN(type,time){
return function(values,next){
async.series(this.middleware[type][time],function(fn,next){
fn(values,next);
},function(err){
cb(err,values);
});
};
@formula1
formula1 / api.min.js
Last active August 29, 2015 14:15
NodeOS-Blog api
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],2:[function(require,module,exports){var process=module.exports={};var queue=[];var draining=fa