Skip to content

Instantly share code, notes, and snippets.

@matheus-santos
matheus-santos / cheat_sheet_socketio
Last active May 1, 2019 19:23
SocketIO cheat sheet to emit messages through sockets
// SocketIO cheat sheet
// SocketIO is a library that makes websockets communications easier.
// Page: http://socket.io/
// ref: http://stackoverflow.com/a/10099325
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
@DTrejo
DTrejo / top3stories.js
Created January 21, 2011 22:41
Gets top three articles from frontpage and newpage of Hacker News. Blog post on scraping: http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//