Skip to content

Instantly share code, notes, and snippets.

View dgrebb's full-sized avatar

Dan Grebb dgrebb

View GitHub Profile
@dgrebb
dgrebb / copy-text.js
Last active December 27, 2023 05:08
DOM element `innerHTML` copy on click or keyboard
/**
* Copies text inside the clicked DOM node
*
* @param {Event} e The event which triggered the copy.
* @returns {Clipboard.writeText} Text is written to the system clipboard.
*
* @async
*
* ## Example:
* ```javascript
@dgrebb
dgrebb / package.json
Last active December 27, 2023 03:55
npm scripts - typescript tsc-watch, build, and (re)start app
"scripts": {
"dev": "npx tsc-watch --onSuccess \"node build/app.js\""
}
@dgrebb
dgrebb / index.js
Created December 23, 2023 00:25 — forked from tforster/index.js
Naked Redirector CloudFront Function
/**
* @description: Handler entry point.
* - Note AWS CloudFront Functions use a modified ECMAScript 5.1 compatible runtime and NOT NodeJS.
* - Use var, not const or let
* - Use string concatenation and not template literals
* - Beware that the CloudFront Functions Console editor and test environment do NOT mimic CloudFront 100%
* @date 2022-01-26
* @param {object} event: A CloudFront Function event (expecting a Viewer Request event)
* @return {object}: A CloudFront response or request object (depends whether conditions allow pass through or 301 redirect)
*/
@dgrebb
dgrebb / README.md
Last active April 12, 2024 02:49
Strapi CMS Custom Dashboard (Almost) Replacement Plugin

For brevity, filenames include parent directory(s). - substitutes /.

If installing Strapi fresh, and you're a filthy, untyped rotten scoundrel, remember to add compilerOptions.jsx = "react" as shown below in jsconfig.json to avoid the IDE SquiggleMonster.

  1. npx create-strapi-app@latest --quickstart --no-run strapi-dashbored
  2. npm run strapi generate
  3. choose "middleware"
  4. choose "Add middleware to root of project"
  5. edit src/middlewares/redirect.js
  6. edit config/middlewares.js
@dgrebb
dgrebb / base.css
Created November 2, 2023 01:10
tailwind base.css
/*! tailwindcss v2.2.19 | MIT License | https://tailwindcss.com */
/*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
/*
Document
========
*/
/**
@dgrebb
dgrebb / .cz.json
Last active September 20, 2023 19:51
Commitizen (tools) config defaults
{
"_______________________________comment": "# this is what works for me, personally."
"commitizen": {
"name": "cz_customize",
"version": "2.5.1",
"tag_format": "$major.$minor.$patch$prerelease",
"version_type": "semver",
"bump_message": "release $current_version \u2192 $new_version",
"customize": {
"info": "This is customized info",
@dgrebb
dgrebb / yabai-keys.sh
Last active September 22, 2023 21:01
yabai commands
# use these in Keyboard Maestro with an "Execute Shell Script" Action
# cycle forward through spaces on the focused display
id="$(yabai -m query --spaces --display | jq 'sort_by(.index) | reverse | .[map(."has-focus") | index(true) - 1].index')" && yabai -m space --focus "${id}"
# cycle backward through spaces on the focused display
id="$(yabai -m query --spaces --display | jq 'sort_by(.index) | .[map(."has-focus") | index(true) - 1].index')" && yabai -m space --focus "${id}"
# cycle forward to next space across all displays (circularly)
yabai -m space --focus next || yabai -m space --focus first
@dgrebb
dgrebb / .cprc
Created August 31, 2023 19:42
A Configuration for vscode-commit-prompt that more closely aligns with Commitizen-Tools vs. npm commitizen.
{
"config": {
"commit-prompt": {
"questions": [
{
"name": "type",
"placeHolder": "Select the type of change you are committing (type)",
"type": "oneOf",
"scopes": [
{
@dgrebb
dgrebb / styles.css
Last active September 11, 2023 20:16
Tabliss GitHub Calendar / Weather Customization
.GitHub {
width: 100%;
display: flex;
justify-content: center;
margin-bottom: -69px;
}
.sr-only {
display: none;
}
@dgrebb
dgrebb / theme.css
Last active October 15, 2023 17:12
CSS Theme Generator Maths
:root {
--base-color: #444484;
--highlight-base-color: #FA6E23;
--base-color-h: var(--base-color); /* Extract hue from the base color */
--base-color-l: var(--base-color); /* Extract lightness from the base color */
--base-color-s: var(--base-color); /* Extract saturation from the base color */
/* Adjust the step for lighter and darker shades */
--lightness-step: 15;