Skip to content

Instantly share code, notes, and snippets.

View davidrleonard's full-sized avatar

David Leonard davidrleonard

View GitHub Profile
@davidrleonard
davidrleonard / from-now.js
Last active February 18, 2024 11:23
moment.fromNow() implemented in vanilla JavaScript as a simple, standalone function. Runs in the browser. No dependencies required.
/**
* Implements all the behaviors of moment.fromNow(). Pass a
* valid JavaScript Date object and the method will return the
* time that has passed since that date in a human-readable
* format. Passes the moment test suite for `fromNow()`.
* See: https://momentjs.com/docs/#/displaying/fromnow/
*
* @example
*
* var pastDate = new Date('2017-10-01T02:30');
@davidrleonard
davidrleonard / famous-women-in-stem.json
Last active February 15, 2018 00:35
A list of famous women scientists, computer scientists, engineers, mathematicians, scholars, and more formatted as JSON
[
{
"fullName" : "Diane Greene",
"firstName" : "Diane",
"lastName" : "Greene",
"fields" : "Computer Science",
"knownFor" : "CEO of VMware, Google board member",
"born" : "1955",
"birthplace": "United States"
},
@davidrleonard
davidrleonard / material-design-colors.scss
Last active September 7, 2023 15:37
Material Design color as a single file of SASS/SCSS variables
// Material Colors: Red
$color-red-50: #ffebee;
$color-red-100: #ffcdd2;
$color-red-200: #ef9a9a;
$color-red-300: #e57373;
$color-red-400: #ef5350;
$color-red-500: #f44336;
$color-red-600: #e53935;
$color-red-700: #d32f2f;
$color-red-800: #c62828;
@davidrleonard
davidrleonard / add-team-to-repos.js
Last active May 8, 2024 15:11
Add a new team to all Github repos in an organization
/*
* Adds a team to all the repos in a Github organization. This is a tedious
* process in the UI. You'll need a newer version of node to run this (e.g 9+)
* because it uses async/await.
*
* Instructions:
*
* 1. Copy this file somewhere on your computer, e.g. ~/addteamrepos.js
* 2. Fill in the uppercase variables below with the right values
* 3. Run this file: `$ node ~/addteamrepos.js`
{
"Use Non-ASCII Font" : false,
"Tags" : [
],
"Ansi 12 Color" : {
"Green Component" : 0.50962930917739868,
"Red Component" : 0.44058024883270264,
"Blue Component" : 0.51685798168182373
},
@mixin eds-mx-text-crop($desired-line-height: $eds-global-line-height) {
$ratio: $desired-line-height / $eds-global-line-height;
&:before,
&:after {
content: '';
display: block;
width: 0;
height: 0;
}