Skip to content

Instantly share code, notes, and snippets.

Cooperative Micro-hacks

The most effective way to get to know a new tool, API or library is to get some hands-on experience with using it, otherwise known as having a hack. Unfortunately, before we get stuck into writing code we often have to spend our time with setup, installation & debugging.

I’ll take us through a collaborative coding environment which optimises our time-to-hack by distributing setup & boilerplate tasks between developers: allowing us to get straight in to play with stuff.

We’ll see how this approach can be useful for hack-days, workshops, and even lightning talks!

Back to front with service workers

var subscribers = []
window.addEventListener('message', function(e){
if(e.data.fao == 'messaging')
subscribers.forEach(function(s){
s(e.data)
})
}, false)
// subscribe to an input channel

cojs.co libraries

Debug script conversion

document.currentScript.className = 'visible'

util

BOOYA July 2016

This month we'll be having a BOOYA (Bring yOur Own hYperlink Along). In this session, we'll go through a list of links that people have submitted and chat about why we find them interesting.

To submit a link - add a comment below with the url, and your twitter handle (so we can /via you when we tweet the link later).

It doesn’t matter if you don’t know anything about the project/post/thing, just anything that you find interesting or cool!

@benfoxall
benfoxall / show+ask.md
Last active June 17, 2016 13:39
Stuff from my show and ask show and tell
// http://colorbrewer2.org/
var colours = [[158,1,66], [213,62,79], [244,109,67],
[253,174,97], [254,224,139], [230,245,152],
[171,221,164], [102,194,165], [50,136,189],
[94,79,162]]
function rgba(color, alpha) {
return 'rgba(' + color.concat(alpha).join(', ') + ')'
}
@benfoxall
benfoxall / sw.js
Created April 7, 2016 16:52
Service Worker page refresh thing
importScripts('pusher-iso-worker.js')
var pusher = new Pusher('key-here', {disableStats: true})
pusher
.subscribe('live_load')
.bind('uploaded', (data) => {
self.clients.matchAll()
.then((clients) => {
if('registerElement' in document) {
var BenTime = Object.create(HTMLElement.prototype);
BenTime.createdCallback = function() {
var stamp = parseInt(this.getAttribute('stamp'),10)
var delta = Math.abs(stamp - new Date)
var s = ~~(delta / 1000)
this.innerHTML = s + 's'
};
@benfoxall
benfoxall / 0_reuse_code.js
Created December 8, 2015 12:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>iframe inject test</title>
</head>
<body>
<script type="text/javascript">
var f = document.createElement('iframe');
f.src = 'data:text/html;charset=utf-8,%3Ch1%3Ehello%3C%2Fh1%3E';