Skip to content

Instantly share code, notes, and snippets.

@matdave
matdave / teleport.modxcloud.md
Last active October 25, 2024 20:13
Using teleport in MODX Cloud

Install Composer

SSH into the primary clouds as the cXXXX user, then run the following commands:

> cd www
> sh -c "$(curl https://modx.co/scripts/install.sh)"
> source ~/.profile
@matdave
matdave / nbhyphen.js
Last active October 23, 2024 20:06
Convert all hyphens to non-breaking
// parse through each element in the document
// replace hyphens with non-breaking hyphens
var elements = document.getElementsByTagName('*');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
// ignore script and style elements
if (element.tagName === 'SCRIPT' || element.tagName === 'STYLE') {
continue;
@matdave
matdave / modx_site_structure_pretty.sql
Last active October 8, 2024 16:56
MODX count number of times a template is used
SELECT a.id AS 'ID',
CASE
WHEN a.menutitle = '' THEN a.pagetitle
ELSE a.menutitle
END AS 'Title',
a.uri AS 'URI',
c.templatename AS 'Template',
CASE
WHEN a.hidemenu = 1 THEN 'Hidden'
ELSE 'Visible'
@matdave
matdave / revo2x_to_3x_resource_select.sql
Created August 23, 2024 20:51
MODX 2.x to 3.x Resource Select
# Run on 2.x MODX
SELECT
id,
type,
pagetitle,
longtitle,
description,
alias,
link_attributes,
@matdave
matdave / elements_tvs_gallery.json
Last active June 21, 2024 16:27
Custom GPM Resolvers
# Alternative for `nvm use` on nvmrc
Function nvm-use
{
if (Test-Path -Path .\.nvmrc -PathType Leaf) {
$version = Get-Content .\.nvmrc -Raw
nvm use $version.Trim().ToLower()
}
}
@matdave
matdave / sucuri_whitelist.sh
Last active December 4, 2023 16:25
Bulk Sucuri Whitelist
#!/bin/bash
# This script will whitelist the IP address of the server in Sucuri's firewall.
# Variables
# The API key for the Sucuri API
API_KEY=""
# The API secret for the Sucuri API
API_SECRET=""
@matdave
matdave / d1
Created December 1, 2023 16:12
mxmkjvgsdzfhseightonetwoeight7
3five4s84four9rtbzllggz
75sevenzdrpkv1onetwo
3q7ctkghhqkpb5four
ccxpblrgrjxcgrhjxfmtwonine8eightzzrdn4
6lqjrhbnxxcqlpnmjsthreesixxsxcgqsxmdx7
35llbrhh
fivethreejcqpfqmcmvjlmhlbzpxlsmktzkmtmv8p
3369eightnine89
onesix4qqnlzdsevennmmrcgkndlsgm3
@matdave
matdave / imageRotate.2.x.plugin.php
Last active October 2, 2023 07:35
MODX imageRotate Plugin
<?php
// run plugin OnFileManagerUpload
switch ($modx->event->name) {
case "OnFileManagerUpload":
if(!empty($files)){
foreach($files as $file){
if ($file['type'] != "image/jpeg" && $file['type'] != "image/png")
return;
// max number of pixels wide or high
$max_image_dimension = $modx->getOption('max_image_dimension',$scriptProperties,0);
@matdave
matdave / myzendesktickets.py
Last active July 11, 2023 13:59
Pipedream Scripts
import requests
import json
import os
from pipedream.script_helpers import (steps, export)
from datetime import timedelta, datetime
from dotenv import load_dotenv
load_dotenv()
# Zendesk API credentials
ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN")