Skip to content

Instantly share code, notes, and snippets.

@neilj
neilj / 15b436de1f9107f3778aad525e5d0b20.js
Created December 3, 2011 07:09
Solution to Part 2 of canyoucrackit.co.uk
//--------------------------------------------------------------------------------------------------
//
// stage 2 of 3
//
// challenge:
// reveal the solution within VM.mem
//
// disclaimer:
// tested in ie 9, firefox 6, chrome 14 and v8 shell (http://code.google.com/apis/v8/build.html),
// other javascript implementations may or may not work.
@neilj
neilj / gist:1532562
Created December 29, 2011 07:22
Sugared DOM: Better Than Templates
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@neilj
neilj / window-controller.js
Last active November 4, 2022 21:41
Cross-tab window controller
function WindowController () {
this.id = Math.random();
this.isMaster = false;
this.others = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );
this.broadcast( 'hello' );
@neilj
neilj / renderHTML.js
Created October 18, 2013 05:26
Rendering HTML with styles in a way that doesn't conflict with other styles on the page, without using an iframe for each HTML fragment.
var styleFrame = document.createElement( 'iframe' ),
stylesWaiting = [],
styleFrameIsReady = false;
styleFrame.setAttribute( 'style',
'visibility:hidden;position:absolute;top:0;left:0;width:1px;height:1px;' );
styleFrame.addEventListener( 'load', function () {
var doc = styleFrame.contentDocument,
html, i, l;