This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A graphical implementation of Hero's algorithm for derivation of square roots. | |
| * Assumes existence of a <div id="p246620-hero"></div> | |
| * | |
| * Author: Dan Q <https://danq.me/> | |
| * Explanation: https://danq.me/2024/10/31/hero-of-alexandria/ | |
| * License: Public Domain / CC0 / The Unlicense (your choice) | |
| */ | |
| (function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('PODCAST_TAG', 'dancast'); | |
| define('PODCAST_DEFAULT_IMAGE', 'https://danq.me/wp-content/uploads/2024/05/podcast-art.jpg'); | |
| define('PODCAST_SUMMARY', "A podcast nobody asked for about things only Dan cares about. A spin-off of the blog of Dan Q, who's been making random stuff on the Internet since the 1990s."); | |
| define('PODCAST_URL', 'https://danq.me/tag/dancast/'); | |
| define('PODCAST_TITLE', 'Dan Q - The Podcast'); | |
| /** | |
| * If the 'podcast_link' postmeta is filled, advertise it appropriately in RSS: | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name WCCOM Production Highlight | |
| // @namespace prodhighlight.wccom.danq.me | |
| // @match https://woocommerce.com/* | |
| // @grant GM_addStyle | |
| // @version 1.0 | |
| // @author Dan Q | |
| // @description Don't break production WCCOM, Dan! Remind yourself when you're on it with a highlight. | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # rubocop:disable Security/Open | |
| # | |
| # Version History | |
| # 1.0.0 - Initial version | |
| # Constants | |
| SHOWCASE_ROOT = 'https://woocommerce.com/showcase/' | |
| SHOWCASE_LIST_PAGE = 'https://woocommerce.com/showcase/page/%d/' | |
| PROGRESSBAR_FORMAT = '%t | %B | %e' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Given an array of points, returns the convex hull over those points. | |
| */ | |
| function convex_hull_over( array $points ): array { | |
| $cross = function($o, $a, $b) { | |
| return ($a[0] - $o[0]) * ($b[1] - $o[1]) - ($a[1] - $o[1]) * ($b[0] - $o[0]); | |
| }; | |
| $pointCount = count($points); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name WooCom Component Enumerator | |
| // @namespace woo.com.danq.me | |
| // @match https://woo.com/* | |
| // @match https://woocommerce.test/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author - | |
| // @description Lists detected WooCom PHP/React components in the console.log as-you-browse. | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SITE = 'https://danq.me/'; | |
| NEW_SIZE = 234; | |
| me = document.querySelector(`a[href="${SITE}"]`).closest('li'); | |
| before = me.querySelector('.before'); | |
| after = me.querySelector('.after'); | |
| i = parseInt(after.innerText); | |
| ticker = function(){ | |
| i += (i > NEW_SIZE ? -1 : 1); | |
| before.style.setProperty('--data-size', i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Footnotes | |
| */ | |
| function footnote($atts, $content = '') { | |
| global $footnote_number, $footnote_contents; | |
| $footnote_number ??= 0; | |
| $footnote_contents ??= []; | |
| $footnote_number++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Foundry + Nginx install script for Debian 12 | |
| # -------------------------------------------- | |
| # Perequisites: | |
| # - unzip - used to decompress Foundry once downloaded | |
| # - nodejs - required to run Foundry | |
| # - nvm - used to install pm2 | |
| # - ufw - firewall: used to ensure that connections can only be made to Foundry via Nginx, among other benefits | |
| # - nginx - provides HTTPS frontend to Foundry | |
| # - certbot - gets free SSL certificate, used by Nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Download JSON cachelogs | |
| // @namespace dllogs.geocaching.danq.me | |
| // @match https://www.geocaching.com/geocache/* | |
| // @grant GM_registerMenuCommand | |
| // @version 1.0 | |
| // @author Dan Q | |
| // @description Download all logs against a particular Geocaching.com geocache as a JSON file | |
| // ==/UserScript== |