Skip to content

Instantly share code, notes, and snippets.

View Andy-set-studio's full-sized avatar

Andy Bell Andy-set-studio

View GitHub Profile
@Andy-set-studio
Andy-set-studio / visually-hidden.css
Created November 18, 2019 10:28
Visually hidden utility class
/**
* VISUALLY HIDDEN
* Hides element visually and removes it from the flow,
* but importantly, allows assitive technology to access it
*/
.visually-hidden {
border: 0;
clip: rect(0 0 0 0);
height: auto;
margin: 0;
@Andy-set-studio
Andy-set-studio / index.html
Created November 1, 2019 14:28
Button with visually hidden text
<button>
<span class="visually-hidden">Some text to announce</span>
<!-- your icon or whatever -->
</button>
@Andy-set-studio
Andy-set-studio / feed.njk
Created June 18, 2019 09:58
RSS template
---
permalink: '/feed.html'
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.name }}</title>
<subtitle></subtitle>
<link href="{{ site.url }}{{ permalink }}" rel="self"/>
<link href="{{ site.url }}/"/>
<updated>{{ collections.posts | rssLastUpdatedDate }}</updated>
@Andy-set-studio
Andy-set-studio / global.js
Created June 11, 2019 19:43
Cache busting with 11ty (stick global.js in _data folder)
module.exports = {
random() {
const segment = () => {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return `${segment()}-${segment()}-${segment()}`;
}
};
@Andy-set-studio
Andy-set-studio / html.js
Last active May 4, 2019 14:59
HTML tagged template literal for syntax highlighting
const html = input => input;
/**
* Pass in an element and its CSS Custom Property that you want the value of.
* Optionally, you can determine what datatype you get back.
*
* @param {String} propKey
* @param {HTMLELement} element=document.documentElement
* @param {String} castAs='string'
* @returns {*}
*/
const getCSSCustomProp = (propKey, element = document.documentElement, castAs = 'string') => {
@Andy-set-studio
Andy-set-studio / reset.css
Last active September 21, 2020 15:19
Minimal CSS reset
/* Box sizing rules */
* {
box-sizing: border-box;
}
*:before,
*:after {
box-sizing: inherit;
}
@Andy-set-studio
Andy-set-studio / letter.txt
Created March 23, 2019 12:15
People’s March Letter
Dear Andrea Leadsom MP,
I won’t be able to travel to London today, but I would like to make it known that I support the People’s Vote March.
The “will of the people” has changed since 2016 and I hope this event will make this clear to you and your Government colleagues.
Sincerely,
Andrew Bell
@Andy-set-studio
Andy-set-studio / index.php
Created January 11, 2019 12:20
Basic PHP example
<?php
$name = 'Andy';
$age = 31;
$favouriteTakeaways = ['Indian', 'Italian', 'Thai'];
$favouriteCodeLanguages = ['HTML', 'CSS', 'JavaScript', 'PHP'];
?>
<!doctype HTML>
<html>
<head>
@Andy-set-studio
Andy-set-studio / modify-unix-time.js
Last active January 6, 2019 14:11
🔥 A little JavaScript snippet here for if you want to modify a `Date` object and get back a Unix timestamp in seconds based on that modification.
/**
* Take a base date, modify it with passed options and return back the number of seconds since Epoch time
*
* @param {Object} [options={}] Options for what you want to modify, follows the following format: { hours: 0, minutes: 0, seconds: 0 }
* @returns {Number}
*/
const modifyUnixTime = (options = {}) => {
// Create our modifications object by merging a static base with the passed options
const modifications = Object.assign(
{ hours: 0, minutes: 0, seconds: 0 },