Skip to content

Instantly share code, notes, and snippets.

@gbakernet
gbakernet / app.js
Last active July 2, 2018 10:46 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4 with quick and dirty SSR support
// Preserve the server render markup
// This has to run before the root render
let preservedMarkup = {}
if (typeof document !== "undefined") {
[...document.querySelectorAll("[data-async-component]")].map(node =>
preservedMarkup[node.getAttribute("data-async-component")] = node.innerHTML
)
}
// getComponent is a function that returns a promise for a component
@gbakernet
gbakernet / es6proxy.htm
Created September 8, 2011 22:52 — forked from nzakas/es6proxy.htm
Example of ES6 Proxy
<!DOCTYPE html>
<!--
This is a simple experiment relying on ECMAScript 6 Proxies. To try this out,
use Aurora (http://www.mozilla.org/en-US/firefox/channel/).
The goal was to create a HTML writer where the method names were really just
the HTML tags names, but without manually creating each method. This uses
a Proxy to create a shell to an underlying writer object that checks each
method name to see if it's in a list of known tags.
"npm install socket-io" & you are ready to go
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!
// callback function is passed the last image to load
// as an argument, and the collection as `this`
/*!
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010
* http://benalman.com/
*
* Original Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron
*
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.pubsubLogging = false;
.mouse, #preview{
position: absolute;
background-repeat: no-repeat;
height: 22px;
min-width: 15px;
z-index: 100;
}
.mouse{
background-image: url('../images/cursor.png');
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
;(function(geolocation){
if (geolocation) return;
var cache;