Skip to content

Instantly share code, notes, and snippets.

View GreenFootballs's full-sized avatar

Charles Johnson GreenFootballs

View GitHub Profile
@GreenFootballs
GreenFootballs / mastodon-embed.js
Last active June 13, 2023 18:37
Revised Mastodon embed script, handles dynamically added oembed iframes
/**
* Revised by Charles Johnson - https://github.com/GreenFootballs
*
* Runs automatically at window.onload(), searches document for iframes with a class of "mastodon-embed"
* and resizes them to fit the content, using window.postMessage() to get the content height from the
* embedded page.
*
* Adds an object named "_mastodonTools" to the window element, with an "embed" method.
*
* To resize dynamically added Mastodon iframes, call "_mastodonTools.embed(container, callback)"
@GreenFootballs
GreenFootballs / amazon_regex.md
Last active August 31, 2022 11:12
A PHP regular expression to match Amazon links and extract the ASIN identifier
~
    (?:(smile\.|www\.))?    # optionally starts with smile. or www.
    ama?zo?n\.              # also allow shortened amzn.com URLs
    (?:
        com                 # match all Amazon domains
        |
        ca
        |
        co\.uk
@GreenFootballs
GreenFootballs / as_addslashes.md
Last active April 1, 2017 17:41
An Applescript subroutine that mimics PHP's addslashes() to escape single/double quotes
on addslashes(s)
	return (do shell script "sed 's/[\"\\\\'\\'']/\\\\&/g' <<<" & quoted form of s)
end addslashes