Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / javascript.js
Last active August 18, 2022 17:52
Alternative implementation of LoggedInBanner.
// Alternative code, from my tweet:
// Generic, reusable Banner component
function Banner({ type, children }) {
const bg = type === 'success' ? 'green' : 'red';
return (
<div
className={styles.banner}
style={{ backgroundColor: bg }}
@salcode
salcode / add-mastodon-link.php
Created November 7, 2022 11:50
Add Mastodon "me" link to the header of the homepage on a WordPress website.
@salcode
salcode / index.test.js
Created December 23, 2022 19:37
Example Jest Test
import titleCase from '.';
const data = [
{
value: 'lord of the flies',
expected: 'Lord of the Flies',
},
{
value: 'once upon a time',
expected: 'Once Upon a Time',
@salcode
salcode / zsh
Created January 12, 2023 10:45
Add this code to `$HOME/.zshrc` to automatically set the node version to match the version in `package.json`. See https://salferrarello.com/automatic-switch-node-version-zsh-package-json
# Add this code to .zshrc after nvm initialization code.
#
# Check the current directory for a package.json file
# If the node version is defined (at .engines.node)
# run "nvm use" for the node version.
#
# If there is not a node version defined with package.json,
# run "nvm use default"
# Version: 20230112
#