Skip to content

Instantly share code, notes, and snippets.

View johnfmorton's full-sized avatar
⌨️
Making stuff

John F Morton johnfmorton

⌨️
Making stuff
View GitHub Profile
@johnfmorton
johnfmorton / dontiframeme.html
Last active November 27, 2023 19:35
Don't allow your page to be rendered in an iframe.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Don't iFrame Me, Bro.</title>
<style type="text/css">
body {
background: white;
font-size: 2rem;
@johnfmorton
johnfmorton / better-img-tag-reset.css
Last active November 8, 2023 12:22
A better img reset for CSS
/*
References for this reset
Video explanation:
https://youtu.be/345V2MU3E_w?si=DCYNR9sQjp-cirs9
The Ultimate Low-Quality Image Placeholder Technique:
https://csswizardry.com/2023/09/the-ultimate-lqip-lcp-technique/
@johnfmorton
johnfmorton / doxter-cp-sticky-header-position.js
Created August 2, 2023 15:29
Doxter CP sticky header position tweak for Craft CMS
// This is a small fix for the sticky header position for Doxter, https://github.com/verbb/doxter
// I've included it in the Craft CMS control panel with another plugin, https://github.com/doublesecretagency/craft-cpjs
// but it could also be included in a custom module.
let resizeTimeout
let styleTag
let ruleIndex
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout)
@johnfmorton
johnfmorton / docker-compose-traefik.yml
Last active July 17, 2023 20:39
Traefik Docker Compose file - used on Laravel Forge
# In my deployment script, I create the 'proxy' network that Traefik uses
# # Check for the network 'proxy', and, if it does not already exist, create it
# docker network ls | grep proxy || docker network create proxy
version: "3.7"
networks:
proxy:
external: true
services:
@johnfmorton
johnfmorton / docker-compose-plausible-analytics.yml
Created July 17, 2023 20:16
Plausible Analytics Docker Compose file for Laravel Forge using Traefik for routing traffic
version: "3.3"
services:
mail:
image: bytemark/smtp
networks:
- default
restart: always
plausible_db:
# supported versions are 12, 13, and 14
@johnfmorton
johnfmorton / proxy-for-partytown.php
Last active June 15, 2023 10:57
Simple proxy with php for use with Partytown
<?php
/**
* About this script:
* This proxy was built with PartyTown.js in mind. https://github.com/BuilderIO/partytown
* Partytown is a lazy-loaded library to help relocate resource intensive scripts into a
* web worker, and off of the main thread.
* Many third-party scripts already provide the correct CORS headers, but not all do.
* For services that do not add the correct headers, then a reverse proxy to another domain must be used in order to provide the CORS headers.
* see: https://github.com/BuilderIO/partytown/wiki/Proxying-Requests
@johnfmorton
johnfmorton / TransmitOpenTerminal.txt
Last active May 30, 2023 14:42
Use Transmit 5 to open in iTerm (instead of Terminal.app) as mentioned here https://library.panic.com/transmit5/open-in-terminal/
on openTerminal(location, remoteHost, serverPort)
tell application "System Events"
-- some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
activate
set targetTab to ""
@johnfmorton
johnfmorton / fm-proxy-pdf-viewer.php
Created April 29, 2023 19:21
A proxy script to retrieve a PDF on a FileMaker server
<?php
// Referenced in blog post, Learning the FileMaker Data API by trial and error.
// https://supergeekery.com/blog/learning-the-filemaker-data-api-by-trial-and-error
// Sample URL hitting this proxy:
// https://my-proxy-server.com/api/fm-proxy-pdf-viewer.php?token=123&pdfUrl=https%3A%2F%2Fexample-filemaker-server.com%2FStreaming_SSL%2FMainDB%abc.pdf%3FRCType%3DEmbeddedRCFileProcessor
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS' && isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
// This is a preflight request, so send the CORS headers
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
@johnfmorton
johnfmorton / contract-numerical-formatting-style.css
Last active April 17, 2023 18:23
Format ordered lists in contract format. 1 > 1.1 > 1.1.a
ol {
list-style-type: none;
counter-reset: custom-counter;
}
ol li {
counter-increment: custom-counter;
}
ol li::before {
@johnfmorton
johnfmorton / keybase.md
Created February 28, 2023 12:20
Keybase proof

Keybase proof

I hereby claim:

  • I am johnfmorton on github.
  • I am johnmorton (https://keybase.io/johnmorton) on keybase.
  • I have a public key ASDu_0vG5Qiy-9cd2ilRG_Ykj1cFsrOxNLWZ5aiNYh1ZSQo

To claim this, I am signing this object: