Skip to content

Instantly share code, notes, and snippets.

View Dan-Q's full-sized avatar
🦆

Dan Q Dan-Q

🦆
View GitHub Profile
@Dan-Q
Dan-Q / README.txt
Created May 4, 2018 07:33
GC591VV "You Can't Do It Alone!" geocache source code
This is the source code the the Arduinos powering my GC591VV "You Can't Do It Alone!" cache:
further details can be found at https://danq.me/2014/08/13/gc591vv/
synchronise_clocks.ino - this program sets the clock on the device to the date and time of
compilation: run it at the same time on both boxes to synchronise them
it_takes_two_cache.ino - this is the program that runs on both boxes when they're to be
deployed to the field; some constants need setting:
* SALT - needs to be set to a random number (the same for both boxes); this helps to prevent
@Dan-Q
Dan-Q / jigidi-helper.js
Last active September 7, 2024 05:30
Experimental under-development code to streamline Jigidi solving.
window.jColors = ['red', 'blue', 'brown', 'orange', 'yellow', 'pink', 'lightblue', 'lightgreen', 'lightgray'];
window.lColors = ['white', 'black', 'purple', 'darkgray', '#009'];
window.lWidths = [5, 10, 20];
window.jCols = parseInt(document.getElementById('info-creator').innerText.match(/(\d+)×/)[1]);
window.jC = 0;
CanvasRenderingContext2D.prototype.putImageData = function(imageData, dx, dy){
const col = window.jC % window.jCols;
const row = Math.floor(window.jC / window.jCols);
this.fillStyle = window.jColors[col % window.jColors.length];
this.fillRect(-1000,-1000,2000,2000);
@Dan-Q
Dan-Q / q23-podcasting-extensions.php
Created August 22, 2024 08:58
Subset of the code included in DanQ.me's theme, providing podcasting functionality into an RSS feed. See https://danq.me/dan-q-the-podcast for further explanation.
<?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:
*/
@Dan-Q
Dan-Q / wccom-production-highlight.user.js
Created July 22, 2024 16:47
Highlight when you're on WCCOM Production so you don't break it by accident. I'm talking to you, Future Dan!
// ==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==
@Dan-Q
Dan-Q / _no_code_page_.php
Last active July 3, 2024 22:38
Hacky PHP to produce a "blank" web page which somehow has content when viewed in Firefox. Sample page at https://danq.me/wp-content/no-code-webpage/, explanation at https://danq.me/nocode
<?php
// half-hearted CSS minification
$css = preg_replace(
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'),
array('$1{ ','$1$3;',"",'} '),
file_get_contents('linked.css')
);
// embed as a data: uri
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '=');
@Dan-Q
Dan-Q / wccom-showcase-checker.rb
Last active June 10, 2024 12:40
Extract all sites listed on https://woocommerce.com/showcase/ and check each, reporting to CSV if it (apparently) isn't running WooCommerce
#!/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'
@Dan-Q
Dan-Q / bbc-news-rss-filter-sport-out.rb
Last active April 28, 2024 17:48
Improve the BBC News RSS feed by (a) filtering out sport, iplayer links, and BBC sounds links; and (b) stripping the anchor (#0, #1, #2 etc.) off <guid>s so "republished to front page" stories don't re-appear in your feed reader
#!/usr/bin/env ruby
require 'bundler/inline'
# # Sample crontab:
# # Every twenty minutes, run the script and log the results
# */20 * * * * ~/bbc-news-rss-filter-sport-out.rb > ~/bbc-news-rss-filter-sport-out.log 2>>&1
# Dependencies:
# * open-uri - load remote URL content easily
# * nokogiri - parse/filter XML
@Dan-Q
Dan-Q / geocaching-extent.php
Created April 3, 2024 15:44
Draws the smallest possible convex polygon that surrounds a set of successful geocaching finds/geohashpoint expeditions. See: https://danq.me/geo-limits
<?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);
@Dan-Q
Dan-Q / list-detected-woocom-components.user.js
Created April 2, 2024 21:04
Userscript to report WooCom components detected on each visited page, by logging to console.log
// ==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==
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);