Skip to content

Instantly share code, notes, and snippets.

Avatar

Miko Deal mudcube

View GitHub Profile
@mudcube
mudcube / W3Contrast.scss
Created Oct 22, 2016
Determine whether the difference between two colors meets the W3 standards for contrast.
View W3Contrast.scss
@function isW3Contrast($rgb1, $rgb2) {
$rgb1: red($rgb1), green($rgb1), blue($rgb1);
$rgb2: red($rgb2), green($rgb2), blue($rgb2);
$brightness: W3Brightness($rgb1, $rgb2) <= 125;
$difference: W3Difference($rgb1, $rgb2) <= 500;
@if ($brightness and $difference) {
@return false;
} @else {
@return true;
}
@mudcube
mudcube / AudioBufferTimer
Created Aug 8, 2015
Compare window.setTimeout() vs. using Audio BufferSource shim
View AudioBufferTimer
var timeout = .50;
///
var channels = 1;
var audioCtx = new AudioContext;
var sampleRate = audioCtx.sampleRate;
var audioDuration = 0.01;
var audioBufferSize = sampleRate * audioDuration;
var audioBuffer = audioCtx.createBuffer(channels, audioBufferSize, sampleRate);
var date = Date.now();
var source = audioCtx.createBufferSource();