Skip to content

Instantly share code, notes, and snippets.

@quartzjer
Created July 9, 2014 22:17
Show Gist options
  • Save quartzjer/6a3270e0252a572236ad to your computer and use it in GitHub Desktop.
Save quartzjer/6a3270e0252a572236ad to your computer and use it in GitHub Desktop.
global consciousness project (gcp) - simple node.js based 'dot' api server wrapper around gcpdot.com to return hex
var request = require('request');
var express = require('express');
var app = express();
app.get('/', function(req, res){
request.get("http://gcpdot.com/gcpindex.php?small=1",function(err,r,body){
if(err || r.statusCode != 200 || typeof body != "string") return res.send("000000");
var high = 0;
body.match(/(0\.\d+)/g).forEach(function(gcp){if(gcp > high) high = gcp});
var color = "CDCDCD";
if(high >= 0.01) color = "FFA8C0";
if(high >= 0.05) color = "FF1E1E";
if(high >= 0.08) color = "FFB82E";
if(high >= 0.15) color = "FFD517";
if(high >= 0.23) color = "FFFA40";
if(high >= 0.30) color = "F9FA00";
if(high >= 0.40) color = "AEFA00";
if(high >= 0.90) color = "64FA64";
if(high >= 0.9125) color = "64FAAB";
if(high >= 0.93) color = "ACF2FF";
if(high >= 0.95) color = "0EEEFF";
if(high >= 1) color = "24CBFD";
res.send(color);
});
});
var server = app.listen(8888, function() {
console.log('Listening on port %d', server.address().port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment