Skip to content

Instantly share code, notes, and snippets.

@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
#
@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 / 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 / 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 / PostStatus.php
Last active October 10, 2019 17:23 — forked from JasonTheAdams/PostStatus.php
Enumeration example of the Object Value Design Pattern
<?php
class PostStatus
{
const PRIVATE = 'private';
const DRAFT = 'draft';
const PUBLISHED = 'published';
const TRASHED = 'trash';
/**
@salcode
salcode / .editorconfig
Last active January 16, 2020 01:47
PHP PSR-2 EditorConfig
# EditorConfig helps keep your project formatting consistent.
# See https://EditorConfig.org
#
# PHP PSR-2 Coding Standards
# http://www.php-fig.org/psr/psr-2/
#
# Author: Sal Ferrarello (@salcode)
#
# You can download this file directly
# to your project from the command-line with
@salcode
salcode / .editorconfig
Last active October 15, 2022 21:22
WordPress .editorconfig - modified version of the WordPress coding standards
# EditorConfig helps keep your project formatting consistent.
# See https://EditorConfig.org
#
# This is a modified version of the WordPress coding standards.
#
# Author: Sal Ferrarello (@salcode)
# https://salferrarello.com/wordpress-editorconfig/
#
# You can download this file directly
# to your project from the command-line with
@salcode
salcode / wp-cli-test-stop-emails.php
Created May 2, 2018 03:14
WordPress plugin proof of concept for disabling the Stop Emails plugin from logging emails when run from the command line. See https://github.com/salcode/stop-emails/issues/15
<?php
/**
* Plugin Name: WP CLI Test Stop Emails
* Plugin URI: https://github.com/salcode/stop-emails/issues/15
* Description: Test plugin for <a href="https://github.com/salcode/stop-emails/issues/15">Issue 15</a>
* Author: Sal Ferrarello
* Author URI: https://salferrarello.com/
* Text Domain: wp-cli-test-stop-emails
* Domain Path: /languages
* Version: 0.1.0

Keybase proof

I hereby claim:

  • I am salcode on github.
  • I am salcode (https://keybase.io/salcode) on keybase.
  • I have a public key ASBSYDWGe_itOiSiI6BnWuSnvvlLjok8KPK_E5OrUDofnAo

To claim this, I am signing this object:

@salcode
salcode / beaver.php
Last active September 21, 2017 09:50 — forked from craigsimps/beaver.php
<?php
/**
* Modify theme to support Beaver Builder better.
*
* - Set the theme layout to full width.
* - Remove the `site-inner` markup.
* - Remove the `content-sidebar-wrap` markup.
* - Remove the entry header and page/ post title.
*
* @package Generico\Core