Skip to content

Instantly share code, notes, and snippets.

@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")
@matdave
matdave / waka2clockify.py
Last active June 23, 2023 16:04
Clockify Python Scripts
# Script rewritten for PipeDream.com
import requests
import datetime
import base64
import os
# Wakatime API endpoint for getting time entries
WAKATIME_API_ENDPOINT = "https://wakatime.com/api/v1/users/current/summaries"
# Your Wakatime API Key
@matdave
matdave / wp_posts-to-modx_site_content.sql
Last active March 27, 2023 14:24
WordPress to MODX MySQL Base Scripts
SELECT
ID id,
'document' type,
post_title pagetitle,
post_excerpt description,
post_name alias,
1 published,
0 isfolder,
REGEXP_REPLACE(post_content, '<!-- (.*) -->', '') content,
1 richtext,
@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 / gitifysetup.md
Last active September 1, 2022 21:15
Hooking up a staging environment to gitify

Hooking up a staging environment to a Gitify Project

Install Gitify

Use composer to install Gitify on your environment

composer global require modmore/gitify:^2

Install a clean MODX environment

@matdave
matdave / logid.cfg
Created May 4, 2022 14:22
LogiOps MX Master 2S
devices: (
{
name: "Wireless Mouse MX Master 2S";
smartshift:
{
# Do not enable free scroll
on: true;
threshold: 15; # 7 is ideal for work
};
hiresscroll:
@matdave
matdave / FredPreview.plugin.php
Created April 20, 2022 19:07
Make Fred play nice w/ Preview
<?php
//** On WebPage Pre-Render **//
$corePath = $modx->getOption('preview.core_path', null, $modx->getOption('core_path') . 'components/preview/');
require_once $corePath . '/model/preview/preview.class.php';
$preview = new Preview($modx);
if(!$modx->user->hasSessionContext('mgr')) return; // currently forcing manager context
if(!$modx->getOption('preview.frontendEnabled')) return; // currently forcing manager context
$qsItem = $modx->getOption('preview.previewKey');
$compareItem = $modx->getOption('preview.compareKey');
@matdave
matdave / index.php
Created November 5, 2021 17:41
PHP to HTML
<?php
$base_path = dirname(__FILE__) . '/content/';
if($_GET['q']) {
$q = explode('?', $_GET['q']);
$file_check = $base_path.preg_replace('"\.html$"', '.php', $q[0]);
if (substr($file_check, -1) == "/") {
$file_check .= "index.php";
}
@matdave
matdave / showrandom.js
Created October 8, 2021 15:32
simple JS randomizer commands
const showrandom = document.querySelectorAll("[showrandom]");
showrandom.forEach(el=>{
const count = el.getAttribute('showrandom') ? el.getAttribute('showrandom') : 1;
const children = el.children;
while(children.length > count){
const random = Math.floor(Math.random() * children.length);
children[random].remove();
}
});
@matdave
matdave / ogimage.snippet.php
Created September 30, 2021 16:20
Simple OG Image- MODX output modifier
<?php
if(empty($input)) return;
$url = rtrim($modx->getOption('site_url'), '/').'/'.ltrim($input,'/');
echo "<meta name=\"image\" property=\"og:image\" content=\"$url\" />";
$path = rtrim($modx->getOption('base_path'), '/').'/'.ltrim($input,'/');
$size = @getimagesize($path);
if ($size) {
$width = $size[0];