Skip to content

Instantly share code, notes, and snippets.

@formula1
formula1 / index.js
Created January 29, 2015 09:23
Markdown to Blessed
// Markdown to Contrib
var util = require("util");
var Transform = require("stream").Transform;
var async = require("async");
var blessed = require('blessed');
var highlight = require('console-highlight');
var Blocks = {
"horizontal line":{
label:"horizontal line",
@formula1
formula1 / blog.html
Created February 17, 2015 23:29
Proof of Concept
<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
<script type="text/javascript">
var path = "/NodeOS/NodeOS/issues";
</script>
</head>
<body>
<h1>NodeOs Blog</h1>
@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
@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 / 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 / .gitignore
Last active August 29, 2015 14:17
Waterline browser proof of concept
node_modules
npm-debug.log
@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 / 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 / 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 / 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;
}