Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
PatrickJS / async-social-buttons-ga.js
Created Dec 2, 2013
Optimised async loading of cross-domain scripts
View async-social-buttons-ga.js
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active Sep 19, 2021
Node.js TCP client and server example
View nodejs-tcp-example.js
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');