Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
8ctopotamus / repair-mysql-data.ps1
Created September 12, 2024 02:23 — forked from josemmo/repair-mysql-data.ps1
Repair MySQL data directory (for XAMPP)
# Based on this answer: https://stackoverflow.com/a/61859561/1956278
# Backup old data
Rename-Item -Path "./data" -NewName "./data_old"
# Create new data directory
Copy-Item -Path "./backup" -Destination "./data" -Recurse
Remove-Item "./data/test" -Recurse
$dbPaths = Get-ChildItem -Path "./data_old" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse
@8ctopotamus
8ctopotamus / order-by-acf-like-count.php
Created July 10, 2024 20:22 — forked from jasonbahl/order-by-acf-like-count.php
Shows how to add a custom order value to a connection to order by a custom field.
add_filter( 'graphql_PostObjectsConnectionOrderbyEnum_values', function( $values ) {
$values['LIKE_COUNT'] = [
'value' => 'like_count',
'description' => __( 'The number of likes on the post', 'wp-graphql' ),
];
return $values;
} );
@8ctopotamus
8ctopotamus / nvmCommands.js
Created January 29, 2024 15:20 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@8ctopotamus
8ctopotamus / docker-compose.yaml
Last active December 4, 2023 04:49
WordPress Docker Compose YAML
# source: https://www.youtube.com/watch?v=gEceSAJI_3s
# create a .env file for db creds
version: '3.1'
services:
database:
mem_limit: 2048m
image: mariadb:10.6.4-focal
restart: unless-stopped
@8ctopotamus
8ctopotamus / .vimrc
Created November 21, 2023 23:01 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
// https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB
if (!window.indexedDB) {
console.log('Your browser does not support indexedDB!')
}
const customerData = [
{ ssn: "444-44-4444", name: "Bill", age: 35, email: "bill@company.com" },
{ ssn: "555-55-5555", name: "Donna", age: 32, email: "donna@home.org" },
{ ssn: "344-44-4444", name: "Bill", age: 31, email: "billl@company.com" },
@8ctopotamus
8ctopotamus / stale-timestamp-detector.js
Created July 28, 2023 14:13
Detecting if data is stale after a certain time period.
// const savedTimestamp = 1690509844000 // saved over 12 hours ago in localStorage
const savedTimestamp = 1690553044000 // saved under 12 hours ago in localStorage
const twelveHoursDifference = 43200000 // 12 hours in milliseconds
const now = new Date().getTime() // current timestamp
const isDataStale = (now, timestamp, difference) => now > timestamp + difference
const shouldRefresh = isDataStale(now, savedTimestamp, twelveHoursDifference)
console.log(shouldRefresh)
@8ctopotamus
8ctopotamus / gist:ab9113bc05e45405b551608277f7e399
Created June 5, 2023 00:54 — forked from shreyans94/gist:05b10194cf2f57cf054a5cf3da3fd931
Display ACF for woocommerce variations in backend
// Render fields at the bottom of variations - does not account for field group order or placement.
add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
global $abcdefgh_i; // Custom global variable to monitor index
$abcdefgh_i = $loop;
// Add filter to update field name
add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
// Loop through all field groups
$acf_field_groups = acf_get_field_groups();
foreach( $acf_field_groups as $acf_field_group ) {
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by craig@123marbella.com on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
@8ctopotamus
8ctopotamus / gist:b7474c6e027ae4c6cabb1c15f9fb03aa
Created November 13, 2022 16:04
Update a WP User's nicename/login through mysql
UPDATE wp_users SET user_nicename = "new_username", user_login = "new_username" WHERE user_login = "old_username";
SELECT * FROM wp_users WHERE user_login = "new_username";