Skip to content

Instantly share code, notes, and snippets.

Daronspence / nvmrc.zsh
Created Feb 22, 2021
Automagic .nvmrc
View nvmrc.zsh
# Put this in your .zshrc
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
Daronspence / example.js
Created May 20, 2020
Contentful debug example
View example.js
* Essentially, the `onValueChanged` callback used to provide an object/array that was `===` during comparisons.
* In the last few days though, something changed and === was not working anymore.
* My solution is to serialize the values and compare those strings to ensure things are
not triggering unnecessary re-renders.
The external change handler is triggered even when the current editor updates the field value,
so we need to check it's equality to what is already in state,
otherwise the current editor will be in an endless loop of updating their own UI.
View a.js
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import { TextInput } from '@contentful/forma-36-react-components';
import { init } from 'contentful-ui-extensions-sdk';
import '@contentful/forma-36-react-components/dist/styles.css';
import './dist.css';
import { createApolloFetch } from 'apollo-fetch';
import { debounce, union, keyBy } from 'lodash-es';
Daronspence / config.json
Created Oct 11, 2019
Tailwind Config -
View config.json
"variants": {
"borderColor": ["responsive", "hover", "focus", "focus-within"]
Daronspence / acf-copy-repeater-field-to-singular.php
Created May 2, 2019
Copy last row of ACF field to hidden custom fields on save
View acf-copy-repeater-field-to-singular.php
* Plugin Name: ACF Copy Repeater Field to Singular - docs_list_renew
* Version: 0.1
* Description: Copies the values of the last row of a repeater field to separate custom fields to be used with Admin Columns
// Rename the second argument if you're going to copy the plugin to work with another repeater.
add_action('wp_insert_post', 'reddit_acf_copy_repeater_field_to_singular', 10);
Daronspence / webpack.mix.js
Created Apr 27, 2019
Laravel Mix with Sass and Tailwind 1.0 Configuration
View webpack.mix.js
const mix = require('laravel-mix');
| Mix Asset Management
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
Daronspence / acf-ajax.php
Created Oct 30, 2018
ACF AJAX for Mike
View acf-ajax.php
add_action('admin_head', function(){
<script type="text/javascript">
updated JS file for use with ACF >= 5.7.0
View acfw-repeater-example.php
<?php if( have_rows('partners_logos', $acfw) ): ?>
<?php while( have_rows('partners_logos', $acfw) ): the_row(); ?>
<div class="col-md-6">
<img src="<?php the_sub_field('logo', $acfw); ?>" alt="" class="img-responsive">
<?php endwhile; ?>
<?php endif; ?>
Daronspence /
Last active Apr 11, 2017
Documentation for basic WordPress Usage

Posts (Blog)

Editing a Post

  • Click on Posts in the left hand menu.
  • Click the title of the post you would like to edit.
  • Make your edits.
  • Click the "Update" button near the top right hand corner.

Update Button

Daronspence / count-podcasts.php
Last active Dec 12, 2016
Podcast Count Shortcode
View count-podcasts.php
* Plugin Name: Podcast Shortcode
* Description: Adds a shortcode to display your podcast count. <code>[podcast-count]</code>
* Version: 1.0
* Author: Daron Spence
* Author URI:
* A simple shortcode to display the number of published podcasts on your site. Uses the `podcast` post type.