Skip to content

Instantly share code, notes, and snippets.

View MikeNGarrett's full-sized avatar
✍️
It's been a long time

Mike Garrett MikeNGarrett

✍️
It's been a long time
View GitHub Profile
@MikeNGarrett
MikeNGarrett / phpcs-compatibility.sh
Last active January 28, 2019 20:31
Test site compatibility with a specific version of PHP
# Test site compatibility with a specific version of PHP.
# Requires phpcs and PHPCompatibility config installed.
phpcs --standard=PHPCompatibility --runtime-set testVersion 7.2 ./
# Configuration I use most:
phpcs -p ./ --standard=PHPCompatibility --runtime-set testVersion 7.2 --report-full=~/petitions-7.2.txt --ignore="*.js|css"
@MikeNGarrett
MikeNGarrett / post-list.sql
Created June 18, 2019 20:02
Mysql query to list all WordPress posts with categories and tags
SELECT
cat_posts.ID as ID,
cat_posts.post_title as Title,
cat_posts.post_date as Published,
CASE
WHEN cat_term_taxonomy.taxonomy = 'category' THEN GROUP_CONCAT(DISTINCT cat_terms.name SEPARATOR ', ')
ELSE ""
END
as Categories,
CASE
@MikeNGarrett
MikeNGarrett / mysql(wp)-commands.txt
Created October 31, 2022 16:48 — forked from vishalkakadiya/mysql(wp)-commands.txt
WordPress(or any mysql database) - Convert special characters(eg. Latin-1) to UTF-8 in mysql database
The actual step-by-step WordPress / MySQL fix…
1. Back up all your stuff first (likely using phpMyAdmin / CPANEL)
Before doing any of the following it strongly encouraged to back up all your data and files. Just to be safe. At the very least, your full database and the WordPress config file: wp-config.php
2. Note the settings that your WordPress is currently using (from wp-config.php)
Specifically, your MySQL database configuration, including DB_NAME, DB_USER, DB_PASSWORD, and also DB_CHARSET and DB_COLLATE
// ** MySQL settings - You can get this info from your web host ** //
@MikeNGarrett
MikeNGarrett / module.module.php
Last active November 2, 2022 10:04
Drupal curated autocomplete field
<?php
use Drupal\Core\Form\FormStateInterface;
function hook_field_widget_complete_entity_reference_autocomplete_form_alter(&$field_widget_complete_form, $form_state, $context)
{
if($field_widget_complete_form['widget']['#field_name'] !== 'field_test') {
return;
}
$storage = Drupal::getContainer()->get('entity_type.manager')->getStorage('node');
@MikeNGarrett
MikeNGarrett / kbe.py
Created November 22, 2022 17:08
Export Keybase teams messages and download attachments
# Forked: https://git.zapashcanon.fr/zapashcanon/kbe/
#To export a chat from the ZorkInc team, run:
# ./kbe.py ZorkInc
# It will create a folder ZorkInc in which you'll find a JSON file containing raw logs, a .log file containing human-readable export of the chat. It'll also download all attachments of the chat and put them in that same folder.
# Note: defaults to "general" channel in your team. Change references to this channel below under "topic_name" (3).
#!/usr/bin/python3
import json
import sys
import os
@MikeNGarrett
MikeNGarrett / index.html
Created February 28, 2023 16:49
Conditionally changing script src
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
<script type="module">
const condition = window.location.host == 'apexofacircle.github.io';