Skip to content

Instantly share code, notes, and snippets.

View mike-at-redspace's full-sized avatar
🎧

Mike Vardy mike-at-redspace

🎧
View GitHub Profile
@mike-at-redspace
mike-at-redspace / Redis-on-mac.md
Last active September 2, 2022 17:45
Install Redis

Type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
THE RAVEN.
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore,
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
"'T is some visiter," I muttered, "tapping at my chamber door--
Only this, and nothing more."
const range = (start, end, step = 1) => {
const forLoop = fn => {
for (let x = start; x <= end; x += step) fn(x)
}
const between = (v, start, end) => v >= start && v <= end
const hasValue = v => between(v, start, end) || between(v, end, start)
const iterate = function* (mapFn) {
for (let x = start; x <= end; x += step) yield mapFn ? mapFn(x) : x
@mike-at-redspace
mike-at-redspace / ActiveLink.js
Created September 16, 2021 08:01 — forked from remy/ActiveLink.js
Next.js version of `activeClassName` support.
@mike-at-redspace
mike-at-redspace / robots.txt
Last active July 22, 2021 10:25
WordPress robots.txt
# robots.txt for wordpress
# based on https://gist.github.com/chuckreynolds/135728
User-agent: *
Disallow: /wp-admin/
Disallow: /cgi-bin/
Disallow: /trackback/
Disallow: /comment-page-*
Disallow: /?s=*
@mike-at-redspace
mike-at-redspace / seo.php
Created June 29, 2021 19:29
Add Yoast To REST API
<?php
/*
Creates and end-point that get Yoast SEO meta tags...
*/
add_action('rest_api_init', 'add_yoast_data');
function add_yoast_data()
{
// Add your post types here...
register_rest_field(array(
@mike-at-redspace
mike-at-redspace / functions.php
Created June 24, 2021 10:37
Yoast's Primary Category
<?php
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_category();
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
@mike-at-redspace
mike-at-redspace / functions.php
Created June 24, 2021 10:36 — forked from schilke/functions.php
How to load CSS files asynchronously in WordPress (using Scott Jehl's "loadCSS")
<?php
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress"
// ...
// register and enqueue loadCSS
function load_scripts_and_styles() {
// register loadCSS
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false );
@mike-at-redspace
mike-at-redspace / endpoints.php
Created June 24, 2021 10:35 — forked from joncave/endpoints.php
WP_Rewrite endpoints demo
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {
@mike-at-redspace
mike-at-redspace / yoast_seo_opengraph_change_image_size.php
Created June 24, 2021 10:35 — forked from amboutwe/yoast_seo_opengraph_change_image_size.php
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/