This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var websocket = require("websocket"); | |
var client = new websocket.client(); | |
client.on("connect", function(connection) { | |
var remaining = 762; // based on start, stop, and step | |
connection.on("message", function(message) { | |
if (message.type === "utf8") { | |
if (!--remaining) connection.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"), | |
http = require("http"); | |
function get(url, callback) { | |
if (/^http:/.test(url)) { | |
http.get(url, function(response) { | |
var body = []; | |
response | |
.on("data", function(data) { body.push(data); }) | |
.on("end", function() { callback(null, body.join("")); }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function key(type, code) { | |
var e = document.createEvent("Event"); | |
e.initEvent(type, true, true); | |
e.keyCode = code; | |
document.getElementById("hplogo").dispatchEvent(e); | |
} | |
setInterval(function() { | |
key("keydown", 37); | |
key("keypress", 37); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>fileTypes</key> | |
<array> | |
<string>csv</string> | |
</array> | |
<key>name</key> | |
<string>Comma-Separated Values</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express"), | |
gitteh = require("gitteh"), | |
path = require("path"); | |
var server = express(); | |
server.get("/", function(request, response) { | |
gitteh.openRepository(path.join(__dirname, "repository", ".git"), function(error, repository) { | |
if (error) return response.end(error.toString()); | |
repository.getBlob("9b4b40c2bca67e781930105fa190b9b90235cfe5", function(error, blob) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a scale, but don't set the domain until the data is known. | |
var x = d3.scale.linear() | |
.range([0, width]); | |
// Load the data. | |
d3.json("data.json", function(data) { | |
// Now we can compute the domain and update the scale. | |
x.domain([0, d3.max(data)]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var roundPrecision = 1e6; | |
fs.readFile("/dev/stdin", "utf-8", function(error, input) { | |
var collection = JSON.parse(input); | |
switch (collection.type) { | |
case "FeatureCollection": return cleanupFeatureCollection(collection); | |
case "GeometryCollection": return cleanupGeometryCollection(collection); | |
default: throw "unknown type: " + collection.type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"type":"MultiPolygon","coordinates":[[[[-155.59,20.14],[-155.58,20.13],[-155.57,20.13],[-155.56,20.14],[-155.55,20.14],[-155.53,20.14],[-155.49,20.11],[-155.45,20.11],[-155.34,20.06],[-155.21,20],[-155.17,19.97],[-155.09,19.88],[-155.08,19.87],[-155.08,19.84],[-155.08,19.77],[-155.07,19.74],[-155.06,19.74],[-155.02,19.75],[-154.99,19.74],[-154.98,19.73],[-154.98,19.72],[-154.97,19.67],[-154.96,19.65],[-154.92,19.61],[-154.87,19.59],[-154.79,19.54],[-154.8,19.52],[-154.81,19.5],[-154.82,19.48],[-154.83,19.46],[-154.91,19.42],[-154.92,19.41],[-155.01,19.33],[-155.02,19.33],[-155.05,19.32],[-155.07,19.32],[-155.1,19.3],[-155.17,19.28],[-155.19,19.28],[-155.27,19.28],[-155.29,19.27],[-155.3,19.27],[-155.32,19.25],[-155.35,19.22],[-155.37,19.22],[-155.38,19.21],[-155.4,19.2],[-155.42,19.18],[-155.44,19.17],[-155.49,19.14],[-155.5,19.14],[-155.55,19.1],[-155.55,19.08],[-155.57,19.03],[-155.61,18.97],[-155.63,18.96],[-155.64,18.95],[-155.66,18.93],[-155.67,18.93],[-155.67,18.94],[-155.69,18.96],[-155.71,18.99],[-15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
projection.line = function(coordinates, context) { | |
if (!(n = coordinates.length)) return; | |
context = radiansAndRotateContext(projectAndTransformContext(context)); | |
var i = 0, | |
n = coordinates.length, | |
p = coordinates[0]; | |
context.moveTo(p[0], p[1]); | |
while (++i < n) context.lineTo((p = coordinates[i])[0], p[1]); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.json("us-counties.json", function(error, topology) { | |
if (error) throw error; | |
var infoByArc = {}, | |
arcsByState = {}; | |
topology.objects[0].geometries.forEach(function(object) { | |
object.arcs.forEach(object.type === "MultiPolygon" | |
? function(polygon) { polygon.forEach(function(ring) { ring.forEach(info); }); } | |
: function(ring) { ring.forEach(info); }); |