Skip to content

Instantly share code, notes, and snippets.

View wilsonpage's full-sized avatar

Wilson Page wilsonpage

View GitHub Profile
.icon-foo:before {
font-family: 'icons';
content: 'foo'
}
<span class="icon-foo"></span>
function MyClass(external) {
this.external = external;
}
MyClass.prototype.publicMethod = function() {};
MyClass.prototype.privateMethod = function() {};
module.exports = function () {
var myClass = new MyClass(this);
@wilsonpage
wilsonpage / credit.md
Last active August 29, 2015 14:19 — forked from annevk/credit.md

After Ryosuke, Travis, Wilson, William, and I discussed the problem for an hour over a burrito, William came up with this approach. All hail William.

var XFooPrototype = {
createdCallback: function() {
this.createShadowRoot({ mode: 'open' });
new MutationObserver(() => distribute(this)).observe(this, { childList: true });
distribute(this);
}
}
function distribute(host) {
var slots = host.shadowRoot.querySelectorAll('content');
@wilsonpage
wilsonpage / my-manager.js
Created May 1, 2015 18:29
Running a service in Window or Worker
threads.manager({
my-service: {
src: 'window.html',
type: 'window'
},
// my-service: {
// src: 'worker.js',
// type: 'worker'
// }
@navigation-enter(0.5s) {
html {
background-color: transparent;
animation: fade-in 0.5s;
}
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
document.addEventListener('navigationstart', e => {
e.waitUntil(new Promise(resolve => {
// Do animation however you please:
// - WebAnimations https://w3c.github.io/web-animations/
// - CSS transitions
// - CSS @keyframe
// - rAF
resolve(); // ... then call resolve when complete
});
@wilsonpage
wilsonpage / umd-module.es6.js
Created June 17, 2015 13:26
A module wrapper that supports AMD, CommonJS and Window Globals
!((define)=>{define((require,exports,module)=>{
module.exports = 'stuff';
});})((typeof define)[0]=='f'&&define.amd?define:((n,nn,w)=>{return(typeof
module)[0]=='o'?c=>{c(require,exports,module);}:(c)=>{var m={exports:{}};
c(n=>w[n],m.exports,m);w[n]=m.exports;};})('moduleName',this));
@wilsonpage
wilsonpage / moduleA.test.js
Created November 21, 2011 16:56 — forked from Raynos/x.js
define([/* dependencies */], function(){
nodeunit.run({
"test my module": function (test) {
// run test
}
});
<!DOCTYPE html>
<html>
<head>
<title>DOM-shim unit tests</title>
<link rel="stylesheet" href="resources/nodeunit.css" type="text/css" />
<script src="resources/es5-shim.js"></script>
<script src="resources/nodeunit.js"></script>
<script src="../code/my/file"></script>
</head>
<body>