Skip to content

Instantly share code, notes, and snippets.

@davidsargent
davidsargent / tabs.html
Created July 26, 2023 20:31
Semantic, Accessible Tabs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Semantic, accessible tabs</title>
</head>
<body>
<!-- Demo: https://jsbin.com/pobatitosa/edit?html,output -->
@davidsargent
davidsargent / auto-calendar.html
Created November 19, 2019 02:24
Auto-generate calendar table
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Auto Calendars</title>
</head>
<body>
<style>
@davidsargent
davidsargent / resize-observer.html
Created December 12, 2018 16:59
resizeObserver Test
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ResizeObserver</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@davidsargent
davidsargent / fizzbuzz.js
Last active January 7, 2018 05:48
FizzBuzz Test
console.log([...Array(100)].map((c,i)=>i+1).reduce((a,c)=>`${a}\n${c} ${c%3?'':'Fizz'}${c%5?'':'Buzz'}`))
console.log([...Array(101).keys()].slice(1).reduce((a,c)=>`${a}\n${c} ${c%3?'':'Fizz'}${c%5?'':'Buzz'}`))
[...Array(101).keys()].slice(1).forEach(i=>console.log(`${i} ${i%3?'':'Fizz'}${i%5?'':'Buzz'}`));
[...Array(100).keys()].forEach(i=>{i++;console.log(`${i} ${i%3?'':'Fizz'}${i%5?'':'Buzz'}`)});
// for (let i=1,val; i<101; i++) {
// if (i % 3 === 0 && i % 5 === 0) val='FizzBuzz';
// else if (i % 3 === 0) val='Fizz';
// else if (i % 5 === 0) val='Buzz';
@davidsargent
davidsargent / custom-console.js
Created November 10, 2016 06:01
A custom console.log that is turned off for production by default (has 'allow' flag to override)
/**
* A custom console.log that is turned off for production by default (has 'allow' flag to override)
*
* Example: log('%cThis is green text', 'color:green;');
* Example: log('%cThis is green text, %cThis is not', 'color:green;', '');
* Example: log('This has a dynamic component:', myVar);
* Example: log(myVar);
* Example: log({ type: 'info' }, 'This has a dynamic component:', myVar, 'with more text');
* Example: log({ type: 'warn' }, 'This is a console.warn!');
* Example: log({ allow: true }, 'This is allowed in Production!');
@davidsargent
davidsargent / auto-next.js
Last active November 10, 2016 06:08
Angular 1 directive to auto-focus next input when current input becomes valid
{
'use strict';
app.directive('autoNext', autoNext);
///////////////
/**
* autoNext
*