Skip to content

Instantly share code, notes, and snippets.

View austinginder's full-sized avatar

Austin Ginder austinginder

View GitHub Profile
@austinginder
austinginder / fix-xero-reconcile-page.js
Last active April 10, 2023 01:09
On Xero reconcile page, expand shortened descriptions back to full descriptions. Copy and paste into Chrome's DevTools. Solves https://productideas.xero.com/forums/939198-for-small-businesses/suggestions/45691177-reconciliation-include-more-reference-details-in
items = document.querySelectorAll('span[data-testid="notes"]')
items.forEach((item) => {
item.innerHTML = item.title
})
document.querySelector("body").addEventListener("click", evt => {
if ( event.target.classList.contains("okayButton") ) {
items = document.querySelectorAll('span[data-testid="notes"]')
items.forEach((item) => {
item.innerHTML = item.title
@austinginder
austinginder / tracker.min.js
Last active May 2, 2022 16:19
Rewritten tracker.js for Fathom Lite
/*
Rewritten tracker.js template for self hosted Fathom with bundled trackerUrl details.
Use this as a template and included directly with each website you plan on tracking.
Add the following script tag to embed.
<script src="/wp-content/mu-plugins/tracker.js" data-site="ABCDEFG" defer></script>
See unminified version here: https://gist.github.com/austinginder/50c244e64c701e1a5a1ecd8f3719273f
*/
window.fathom_lite=function(){var e={siteId:"",trackerUrl:"//your-tracker-domain.tld/collect"};function t(){return{isNewVisitor:!0,isNewSession:!0,pagesViewed:[],previousPageviewId:"",lastSeen:+new Date}}function n(){let e=new Date;e.setMinutes(e.getMinutes()-30);let n=function(e){for(var t=document.cookie?document.cookie.split("; "):[],n=0;n<t.length;n++){var i=t[n].split("=");if(decodeURIComponent(i[0])===e){var r=i.slice(1).join("=");return decodeURIComponent(r)}}return""}("_fathom_lite");if(!n)return t();try{n=JSON.parse(n)}catch(e){return console.error(e),t()}return n.lastSeen<+e&&(n.isNewSession
@austinginder
austinginder / tracker.js
Last active January 19, 2021 15:27
Rewritten tracker.js for Fathom Lite
/*
Rewritten tracker.js template for self hosted Fathom with bundled trackerUrl details.
Use this as a template and included directly with each website you plan on tracking.
Add the following script tag to embed.
<script src="/wp-content/mu-plugins/tracker.js" data-site="ABCDEFG" defer></script>
See minified version here: https://gist.github.com/austinginder/b7690cdeca1a109d9edf58f07ea1f146
*/
@austinginder
austinginder / load_default_keys_to_wp-config.sh
Last active April 4, 2020 13:23
Bash script template for deploying many keys and values to wp-config.php for WordPress sites.
keys_to_add=(
WPCOM_API_KEY
GF_LICENSE_KEY
RECOVERY_MODE_EMAIL
)
values_to_add=(
wordpress_akismet_license_goes_here
gravity_forms_license_goes_here
recovery_email_address_goes_here
)
@austinginder
austinginder / migration-captaincore-v0.9-to-v0.10-rename-dirs.php
Created February 6, 2020 21:30
One time script to migrate directories to new Site IDs. Requires `ids-sites_{$captain_id}.json` outputted from https://gist.github.com/austinginder/54c55adc2834be9c940597e3ebccd8e6
<?php
if ( count ( $args ) == 0 ) {
echo "Error: missing <captain_id> argument.";
return;
}
$json = $_SERVER['HOME'] . "/.captaincore-cli/config.json";
$config_data = json_decode ( file_get_contents( $json ) );
$system = $config_data[0]->system;
@austinginder
austinginder / migration-captaincore-v0.9-to-v0.10-alpha.php
Last active January 29, 2020 19:23
Manually migrate data between alpha versions of CaptainCore. (in progress, not yet completed).
<?php
$users = array_column( get_users ( [ 'fields' => [ 'ID' ] ] ), "ID" );
$ids_accounts_json = "ids-accounts.json";
$ids_sites_json = "ids-sites.json";
$ids_domains_json = "ids-domains.json";
$ids_processes_json = "ids-processes.json";
$ids_processlogs_json = "ids-processlogs.json";
// Generate empty .json if needed
## Pull in static configs
source ~/.bash_anchorhost
function wpengine_local_restore {
## Prompt for dynamic configs
read -p $'\e[31mWP Engine snapshot url\e[0m: ' wpengine_snapshot
read -p $'\e[31mLocal database name (will create)\e[0m: ' db_name
read -p $'\e[31mProduction site url ( ex: anchor.host )\e[0m: ' siteurl_production
read -p $'\e[31mLocal site url ( ex: anchor.dev )\e[0m: ' siteurl_local
@austinginder
austinginder / protected.php
Last active January 29, 2020 16:59 — forked from hakre/dl-file.php
Wordpress login to download uploaded files
<?php
/*
* protected.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
<?php
### PHP command line wrapper for WP Engine's web based WP-CLI
### Example command line: php wp_engine_cli.php -i wp_install_name -c "cli info"
# Grab options from command line
$options = getopt("i:c:");
# Break out into variables
$install = $options["i"];
# Adds new account
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES
(null, 'firstlastname', 'known-password-hash', 'First Last Name', 'email@example.com', '', NOW(), '', 0, 'First Last Name');
# Selects autogenerated ID
SET @autogenerated_id = LAST_INSERT_ID();
# Setups new account as a WordPress admin
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES
(null, @autogenerated_id, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}'),