Skip to content

Instantly share code, notes, and snippets.

@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* 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],
@linus
linus / complex.coffee
Created December 27, 2010 19:27
Mandelbrot set in CoffeeScript and Canvas
# Complex class from http://docstore.mik.ua/orelly/webprog/jscript/ch08_05.htm#jscript4-CHP-8-EX-6
class Complex
constructor: (@x, @y) ->
magnitude: ->
Math.sqrt @x * @x + @y * @y
negative: ->
new Complex -@x, -@y