Skip to content

Instantly share code, notes, and snippets.

View jonathanstegall's full-sized avatar

Jonathan Stegall jonathanstegall

View GitHub Profile

When a new version of PHP is installed, to keep up with the WordPress VIP Go environment locally we need to do a few things:

  1. pecl install gmagick
  2. If #1 fails with a beta warning, use pecl install channel://pecl.php.net/gmagick-2.0.6RC1 instead (replace with the correct version if necessary)
  3. pecl install memcache
  4. code /usr/local/etc/php/[version]/php.ini to open the ini file. Uncomment the lines extension="gmagick.so" and extension="memcache.so"
  5. valet restart

And to make curl stop complaining about the SSL, do this:

@adactio
adactio / saveTextarea.js
Last active December 2, 2023 06:52
Put the contents of a textarea into localStorage if the user leaves the page before submitting the form.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
// Cut the mustard.
if (!win.localStorage) return;
// You should probably use a more specific selector than this.
var textarea = doc.querySelector('textarea');
// The key for the key/value pair in localStorage is the current URL.
var key = win.location.href;
@jonathanstegall
jonathanstegall / global-mysql-sql-mode.sql
Last active July 29, 2021 18:10
this is required for MySQL to successfully import a WordPress database on Mac OS, at least as of June 2020
set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
SET SQL_MODE='ALLOW_INVALID_DATES';
@robweychert
robweychert / typographic-scale-generator.md
Last active October 26, 2021 13:21
Sass typographic scale generator

Sass typographic scale generator

Generate a typographic scale of CSS variables with any interval (fixed or proportional) and any number of sizes. Just edit $interval, $body-text, $scale-min, and $scale-max:

:root {
  $interval: 1.5;    // Unitless for proportional, unit for fixed
  $body-text: 1rem;  // Must have a unit
  $scale-min: -2;    // Unitless negative integer
  $scale-max: 2;     // Unitless positive integer
@WPprodigy
WPprodigy / wp-create
Created December 21, 2019 08:11
WP local site creation script. Made for use with https://laravel.com/docs/6.x/valet
#!/bin/bash
# Usage: wp-create sitename
if [ $# -eq 0 ]; then
echo "Need to provide the directory name to be created."
exit 1
fi
# set up new folder to house the WP install
@jonathanstegall
jonathanstegall / story-count-by-category-and-month.sql
Last active October 5, 2022 02:47
get a count of stories for each category by year/month
SELECT t.term_id, REPLACE(t.name, '&', '&') as name, COUNT(p.ID) as post_count, YEAR(post_date) as year, MONTH(post_date) as month
FROM wp_terms t
INNER JOIN wp_term_taxonomy tax ON t.term_id = tax.term_id
INNER JOIN wp_term_relationships r ON tax.term_taxonomy_id = r.term_taxonomy_id
INNER JOIN wp_posts p ON r.object_id = p.ID
WHERE tax.taxonomy = 'category' and YEAR(post_date) >= YEAR(CURDATE()) and p.post_type = 'post' and p.post_status = 'publish'
GROUP BY term_id, YEAR(post_date), MONTH(post_date)
ORDER BY YEAR(post_date) DESC, MONTH(post_date) DESC, t.name ASC;
@WPprodigy
WPprodigy / functions.php
Last active September 9, 2020 20:55
Co-Author Plus ES query fix
<?php
/**
* Co-Author Plus ES query fix.
*
* With CAP, authors are attached either with the traditional
* author field or via an "author" taxonomy. So we need to check both.
*/
add_filter( 'es_posts_request', function( $es_args, $query ) {
if ( ! $query->is_author() ) {
@achmiral
achmiral / shell.md
Created November 9, 2018 16:59 — forked from SunDi3yansyah/shell.md
MySQL / MariaDB login without SUDO
$ > sudo mysql -uroot
mysql > SELECT User, Host FROM mysql.user;
mysql > DROP USER 'root'@'localhost';
@davisshaver
davisshaver / class-jwt.php
Last active September 26, 2023 00:25
WordPress/Coral Project Talk JWT integration
<?php
use \Firebase\JWT\JWT as JWT_Wrapper;
/**
* Class wrapper for JWT tokens.
*/
class JWT {
use Singleton;
@jonjack
jonjack / add-update-refresh-github-access-token-on-mac.md
Last active May 11, 2026 18:54
Adding & Updating GitHub Access Token on Mac

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-