Skip to content

Instantly share code, notes, and snippets.

@MetaThis
MetaThis / index.html
Created March 7, 2011 03:39
Psychedelic Protovis Experiment
<html>
<head>
<title>Psychedelic Protovis experiment by @MetaThis</title>
<script type="text/javascript" src="http://vis.stanford.edu/protovis/protovis-r3.2.js"></script>
<style type="text/css">
body {
background: black;
margin: 0;
}
#fig {
@MetaThis
MetaThis / nestedSort.js
Created June 20, 2011 23:32
JS Nested Sort Example (with comparator function factory for composing arbitrary nesting levels)
//some sample data for the example
var people = [ {firstName: "Bob", lastName: "Barker", age: 100}, {firstName: "John", lastName: "Smith", age: 40}, {firstName: "Sam", lastName: "Adams", age: 42}, {firstName: "John", lastName: "Adams", age: 42}, {firstName: "Bernard", lastName: "Adams", age: 42}, {firstName: "Adam", lastName: "Adams", age: 42} ];
//generalized comparator function factory enabling composition with nested comparators
var comparatorComposer = function(compareBy, nextComparator) {
var comparator = function(a, b) {
return ((a[compareBy] < b[compareBy]) ? -1 : ((a[compareBy] > b[compareBy]) ? 1 : (nextComparator ? nextComparator(a, b) : 0)));
};
return comparator;
};
@MetaThis
MetaThis / server.js
Created August 25, 2011 22:03
Simple example of a Node.js proxy to CouchDB GET requests
var http = require('http'),
request = require('request'), // request module from https://github.com/mikeal/request
url = require('url');
http.createServer(function (req, res) {
var href = url.parse(req.url,true).href;
request('http://127.0.0.1:5984' + href).pipe(res);
}).listen(1337);
// now try something like http://127.0.0.1:1337/your_db_name/_all_docs/?limit=10