Skip to content

Instantly share code, notes, and snippets.

View bkardell's full-sized avatar

Brian Kardell bkardell

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Standard HTML5 test</title>
<!-- Dependencies -->
</head>
<body>
<!-- use the following markup for each media element -->
var oldPut = IDBObjectStore.prototype.put,
oldGet = IDBObjectStore.prototype.get;
IDBObjectStore.prototype.put = function (o) {
// create a debuggable point...
return oldPut.call(this, o);
}
IDBObjectStore.prototype.get = function (o) {
// create a debuggable point...
return oldGet.call(this, o);
@bkardell
bkardell / gist:3eebe21db148716d081f
Last active February 11, 2016 22:55
1) Open https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest (I dont know why this particular url matters, but others are doing something else for me so use this one -- 2) Run this in the console on an HTTPs page in various versions of chrome, 47/48 appear to swallow the error with nothing logged - 41 appears to l…
var oReq;
try{
oReq = new XMLHttpRequest();
oReq.addEventListener("load", function () { console.log("success event"); });
oReq.addEventListener("error", function () { console.error("error event"); });
oReq.open("GET", "http://www.example.org/example.txt");
oReq.send();
} catch (e) {
console.error("error thrown");

Imagine that we define a function that can do a unit of work some time later called doSomeAsyncWork. You pass it how long you want to wait before doing the work and a 'work' function which receives both resolve and reject...

var doSomeAsyncWork = function (timeMs, work) {
   return new Promise(function (resolve, reject) {
       setTimeout(function () {
        work(resolve, reject);
 }, timeMs);
@bkardell
bkardell / test
Last active October 15, 2015 23:01
<BODY>
<HEADER>
<TITLE>The World Wide Web project</TITLE>
<NEXTID N="55">
</HEADER>
<BODY>
<H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
NAME=0 HREF="WhatIs.html">
hypermedia</A> information retrieval
initiative aiming to give universal
@bkardell
bkardell / index.html
Created October 7, 2015 01:28
describes an idea...
<!DOCTYPE html>
<html>
<head>
<title>Online Art Project</title>
<style>
.gameboard {
clear: both;
display: block;
border: 1px solid red;
background-color: #cfcffc;
@bkardell
bkardell / index.html
Created September 18, 2015 22:19
vNGPwP
<section>
<h1>What's this?</h1>
<p>"Actionable" elements (ie, elements like <code>&lt;a&gt;,&lt;button&gt;,&lt;input type="button"&gt;</code>) have no ideal patterns around how you manage tooltips in a way that it simultaneously accessible and touch friendly. It's easy enough to add <code>aria-describedby</code> and some CSS involving <code>:hover, :focus</code> to most elements, but these elements are different: clicking them doesn't just set focus, it activates some behavior. This means that there is no way for users of touch-based devices to get the same sort of information. You can add a help button but this easily leaves blind users in the lurch because the button itself isn't described and they likely have no idea that the _next_ element contains help for this one. In a word, this situation kind of sucks. A user might needs to know what that button does before they want to click it, but we cannot dedicated a major portion of the UI to always showing a descrition of it. Figuring out an ap
@bkardell
bkardell / random-jenn-palette.js
Last active September 11, 2015 03:01
A series of functions to auto-generate some interesting paletes for use with http://make8bitart.com/. Call `getRandomPalette(?size,?base)` both arguments are optional and default to 24 colors and a random base color. To provide your own base color, do it like `{red: 42, green: 13, blue: 69 }` You can log these to the console, paste them into a c…
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(color) {
return componentToHex(color.red) + componentToHex(color.green) + componentToHex(color.blue);
}
@bkardell
bkardell / random-jenn-palette.js
Created September 11, 2015 03:00
A series of functions to auto-generate some interesting paletes for use with http://make8bitart.com/. Call `getRandomPalette(?size,?base)` both arguments are optional and default to 24 colors and a random base color. To provide your own base color, do it like `{}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(color) {
return componentToHex(color.red) + componentToHex(color.green) + componentToHex(color.blue);
}
@bkardell
bkardell / random-jenn-palette.js
Created September 11, 2015 02:58
A series of functions to auto-generate some interesting paletes for use with http://make8bitart.com/.
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(color) {
return componentToHex(color.red) + componentToHex(color.green) + componentToHex(color.blue);
}