Skip to content

Instantly share code, notes, and snippets.

View themorgantown's full-sized avatar

Daniel themorgantown

View GitHub Profile
@themorgantown
themorgantown / detect-transparency-image.js
Last active April 17, 2025 13:44
detect clicks on a non-transparent image (webp, png, avif, gif) in Hype. Multiple layered images supported. https://forums.tumult.com/t/detect-click-on-non-transparent-area-of-png/24769/
/*
* Clickable Transparency Library
* --------------------------------
* This script enables non-transparent parts of an image to be clickable.
* It works for both <img> elements and any element with a background image.
* For any element with the "clickable-transparency" class:
* - It changes the mouse cursor to 'pointer' over non-transparent areas and 'default' over transparent areas.
* - It prevents click propagation if a transparent area is clicked.
*
* Usage:
@themorgantown
themorgantown / js for head html.html
Created April 4, 2025 13:54
stop scrolling on full screen iPad documents
<script type="text/javascript">
/**
* No-Scroll Script for Hype Documents
* Prevents vertical scrolling on HYPE_document elements
* while preserving other touch gestures
*/
(function() {
// Store original touch positions
let startY;
// element - DOMHTMLElement that triggered this function being called
// event - event that triggered this function being called
function pinchablev2(hypeDocument, element, event) {
// if it's 'pinchable', let it resize outside of hype scene
// User configurable settings
var PINCHABLE_CONFIG = {
maxScale: 4, // Maximum zoom level
minScale: 1, // Minimum zoom level (enforced strictly)
@themorgantown
themorgantown / mysql_splitter_tool.py
Last active September 17, 2024 17:15
given a HUGE sql export, this script will split it up into individual tables and generate import statements for each table, like: mysql -u dbusername -p'dbpassword' database_name < table1
# usage:
# python3 splitter.py database_name dbusername dbpassword
import sys
import os
import re
import logging
def main():
@themorgantown
themorgantown / mullvadbase.mobileconfig
Created September 6, 2024 14:11
Mullvad Base DNS server mobileconfig
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>DNSSettings</key>
<dict>
<key>DNSProtocol</key>
@themorgantown
themorgantown / minify_apple_contacts_export.py
Created June 27, 2024 18:44
keeps name, tel, email, and address.
import vobject
import logging
from tqdm import tqdm
def minimize_vcf(input_file, output_file, fields_to_keep=None):
if fields_to_keep is None:
fields_to_keep = ['n', 'fn', 'tel', 'email', 'adr']
fields_to_keep = [field.lower() for field in fields_to_keep]
import http.server
import ssl
import socket
import os
import subprocess
HOST = f"{socket.gethostname()}"
PORT = 443
CERT_FILE = 'self-signed.cert'
KEY_FILE = 'self-signed.key'
@themorgantown
themorgantown / localserver.sh
Last active June 14, 2024 19:58
On a MAC: Loads an SSL server using a self-signed URL on your local machine using the URL: yourcomputershostname.local served from the folder: ~/Desktop/document/ - first run: chmod +x localserver.sh so this file is executable. Python only version: https://gist.github.com/themorgantown/ad592aad05e29d0d69394daa4342447d
#!/bin/bash
# Install mkcert if not already installed
if ! command -v mkcert &> /dev/null
then
echo "mkcert not found. Installing mkcert..."
brew install mkcert
mkcert -install
fi
@themorgantown
themorgantown / laser_pointed_from_the_moon.py
Last active April 2, 2024 01:56
You're standing on the moon, and you locked a laser into a tripod and pointed it at the Earth's equator. What shape does your laser make across the earth as the moon orbits the Earth? Taking into account the moon's wobble, libation, and eccentricities, this draws a wobbly line up and down the equator about 10% of the earth's height (I think).
# pip install matplotlib astropy jplephem
from astropy import units as u
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, get_body, EarthLocation, GeocentricTrueEcliptic
import numpy as np
import matplotlib.pyplot as plt
# Ensure astropy.units is correctly imported and used
initial_time = Time('2019-01-01 00:00:00', scale='utc')
@themorgantown
themorgantown / .htaccess
Last active February 6, 2024 16:08
Show an emoji of the Moon based on the current date (works well with Sendy on a PHP server). An example of using this in a sendy template: `https://example.com/moonphase/moonphase/[currentmonthnumber]-[currentdaynumber]-[currentyear].png` Requires png files in the moon_phases directory with these filenames: waning_crescent.png first_quarter.png …
# place this in the folder 'moonphase' at the top level directory to load
# https://example.com/moonphase/moonphase/02-03-2024.png
RewriteEngine On
# Check if mod_rewrite is enabled
<IfModule mod_rewrite.c>
# Rewrite only if the request is for a moon phase image
RewriteRule ^moonphase/([0-9]{2})-([0-9]{2})-([0-9]{4})\.png$ moonphase.php?month=$1&day=$2&year=$3 [L,QSA]
</IfModule>