Skip to content

Instantly share code, notes, and snippets.

View rossjs's full-sized avatar

Ross Topol rossjs

  • Austin, TX
View GitHub Profile
@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@neilkennedy
neilkennedy / buffer.js
Created January 10, 2014 10:21
Use JSTS buffer function with Leaflet.js by exporting / importing GeoJSON
function buffer(leafletGeometry, distance){
var reader, input, buffer, bufferGeoJSON;
reader = new jsts.io.GeoJSONReader();
input = reader.read(leafletGeometry.toGeoJSON());
buffer = input.geometry.buffer(distance);
bufferGeoJSON = new jsts.io.GeoJSONWriter().write(buffer);
return L.geoJson(bufferGeoJSON);