Skip to content

Instantly share code, notes, and snippets.

View geoffdavis92's full-sized avatar

Geoff Davis geoffdavis92

View GitHub Profile
~/Projects/test-eleventy-plugin-sass $ yarn add -D @11ty/eleventy eleventy-plugin-sass
yarn add v1.22.4
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning @11ty/eleventy > browser-sync > socket.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
warning @11ty/eleventy > browser-sync > socket.io > engine.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
warning @11ty/eleventy > browser-sync > socket.io > socket.io-parser > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/iss
@mixin set($name) {
%#{$name} {
@content;
}
}
@mixin get($name) {
@extend %#{$name};
}
function applySpaces(textElements) {
const tweetText = [...textElements];
tweetText.map((text,i,arr) => {
if (!text.length) {
const lastText = arr[i-1];
arr[i-1] = `${lastText} `;
}
return text;

Overview

I started using this switch(true) { ... } pattern after reading this tweet in 2019.

export function capitalize(str) {
return str.replace(/(^|\s)[a-z]/g, capturedText => capturedText.toUpperCase());
}
import React from "react";
const persistedCache = {};
function usePersistedCache(key,initial) {
persistedCache[key] = persistedCache[key] || initial;
const [state, setState] = React.useState(persistedCache[key]);
return [state, value => {
persistedCache[key] = value;
React.setState(value)
@geoffdavis92
geoffdavis92 / debounce.js
Last active May 31, 2019 14:25
Easily debounce event callbacks using setTimeout/clearTimeout.
/**
* @param {Function} callback
* @param {undefined|number} timeoutHandler
* @param {number=300} time
*/
export default function debounce(
callback,
time = 300,
timeoutHandler = window.DEBOUNCE_TIMEOUT_HANDLER
) {
@geoffdavis92
geoffdavis92 / push-new-branch-to-origin.sh
Last active March 1, 2019 22:04
Push up a new branch to origin in one line
BRANCH=$(git branch | grep \* | sed -E 's/\*[ ]//g') && git push -u origin $BRANCH;
javascript:var t=document.createElement('textarea');t.id='t';document.body.appendChild(t);t.innerHTML=document.querySelector('.image-container .screenshot-image').src;t.select();document.execCommand('copy');
$blue--dark: #002a5c;
$blue--light: #1ab6e9;
$red: #d11145;
$yellow: #fee619;
$blue--light--darkened: #0C5D78;