Skip to content

Instantly share code, notes, and snippets.

View richpeck's full-sized avatar

Richard Peck richpeck

View GitHub Profile
@amboutwe
amboutwe / yoast_seo_title_add_separators.php
Last active September 24, 2022 08:40
Add custom separators to the Yoast SEO options
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Add custom separators to the Yoast SEO options
* Credit: Yoast team
* Last Tested: September 2, 2021 using Yoast SEO 17.0 on WordPress 5.8
*/
add_filter( 'wpseo_separator_options', 'yoast_seo_title_add_separators', 10 , 1 );
@humphreyja
humphreyja / active_admin.rb
Created November 13, 2019 19:58
Include react components into active admin using React On Rails.
# config/initializers/active_admin.rb
#...
module ActiveAdmin
module Views
# Defines a `react_component` active admin component. It allows you
# to include react components into active admin using React On Rails.
# Example:
#
add_shortcode('wps_event_link', 'wps_event_link');
function wps_event_link() {
$post_id = '{{ post_data:ID }}';
}
@karen-white
karen-white / checkout.js
Last active June 2, 2020 20:23
Use Mutation Observer to listen for the Billing step of checkout
<script>
(function(win) {
'use strict';
var listeners = [],
doc = win.document,
MutationObserver = win.MutationObserver || win.WebKitMutationObserver,
observer;
function ready(selector, fn) {
package main
import (
"bytes"
"flag"
"image"
"image/color"
"image/draw"
"image/png"
"math"
@JamieMason
JamieMason / pluck-unique-values-from-array-of-javascript-objects.md
Created September 14, 2018 08:14
Pluck Unique Values from Array of Javascript Objects

Pluck Unique Values from Array of Javascript Objects

Implementation

const pluck = key => array => Array.from(new Set(array.map(obj => obj[key])));

Usage

@cameroncowden
cameroncowden / page.google-product-feed.liquid
Created August 15, 2018 15:34
Shopify Google Product Feed xml generator
{% comment %}
Instructions:
- Create a blank page called 'Google Base Product Feed'and save it
- Open that page for editing and select 'page.google-feed' from the page template selector
- Add a brief site description to the meta-shop-description snippet
- The feed url should now be available at http://www.yoursite.com/pages/google-base-product-feed
- validate your field at http://validator.w3.org/feed/
- when ready, submit your feed at http://base.google.com
@jaskiratr
jaskiratr / chmod-400.cmd
Created June 29, 2018 01:03
Set permission of file equivalent to chmod 400 on Windows.
# Source: https://stackoverflow.com/a/43317244
$path = ".\aws-ec2-key.pem"
# Reset to remove explict permissions
icacls.exe $path /reset
# Give current user explicit read-permission
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"
# Disable inheritance and remove inherited permissions
icacls.exe $path /inheritance:r
@christopher-hopper
christopher-hopper / phpenv-ubuntu-xenial.sh
Last active May 16, 2023 11:02
Install phpenv on Ubuntu 16.04 LTS (xenial)
#!/usr/bin/env bash
# vim: ai ts=2 sw=2 et sts=2 ft=sh
# Check OS.
if [[ ! "${OSTYPE}" =~ "^linux" ]] || [[ ! "$(lsb_release -c 2>/dev/null)" =~ "xenial" ]]; then
(>&2 echo "Error: This script is for Ubuntu 16.04 LTS (xenial) not '${OSTYPE}'.")
exit 1;
fi
sudo apt-get update
@djrmom
djrmom / custom-hooks.php
Created October 27, 2017 13:28
facetwp date source converted to year
<?php
/**
* reindex after adding or updating this filter
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'date_as_year' == $params['facet_name'] ) { // change date_as_year to name of your facet
$raw_value = $params['facet_value'];
$params['facet_value'] = date( 'Y', strtotime( $raw_value ) );
$params['facet_display_value'] = $params['facet_value'];