Skip to content

Instantly share code, notes, and snippets.


Dan Q Dan-Q

View GitHub Profile
Dan-Q / jigidi-helper.js
Last active January 22, 2023 14:12
Experimental under-development code to streamline Jigidi solving.
View jigidi-helper.js
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];
Dan-Q / _no_code_page_.php
Last active January 28, 2023 13:43
Hacky PHP to produce a "blank" web page which somehow has content when viewed in Firefox. Sample page at, explanation at
View _no_code_page_.php
// half-hearted CSS minification
$css = preg_replace(
array('$1{ ','$1$3;',"",'} '),
// embed as a data: uri
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '=');
Dan-Q / wp-mastodon-sync.rb
Created November 30, 2022 11:28
Script to push posts to via the Mastodon API and get back replies (mentions), favourites (likes), and reblogs (reposts)
View wp-mastodon-sync.rb
define('Q23_WP_DIR', '/www/');
define('Q23_MASTODON_SERVER', '');
define('Q23_MASTODON_META_KEY', 'q23_mastodon_sync');
define('Q23_MASTODON_META_SYNDICATION_LINKS', 'mf2_syndication');
define('Q23_MASTODON_COMMENT_USER_AGENT', 'Q23 Mastodon Comment Backfeeder');
Dan-Q / referer-faker.php
Last active January 16, 2023 20:08
This PHP script can be used to "proxy" content from third-party sites that block or modify their responses based on the Referer: header.
View referer-faker.php
if($_GET['pw'] != SECRET_PASSWORD) http_response_code(403) && die();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['url']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, $_GET['referer']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
View finger-to-wordpress.rb
#!/usr/bin/env ruby
# This program gets executed (by /etc/efingerd/luser) when somebody runs finger
# The output is returned directly to them
# For more information, see
require 'mysql2'
require 'word_wrap'
require 'word_wrap/core_ext'
View browser-basic-auth-test.rb
#!/usr/bin/env ruby
require 'bundler'
require 'sinatra'
set :bind, ''
set :port, 80
def show_credentials(request)
Dan-Q / get-twitter-avatar.js
Created June 2, 2021 08:33
Uses Puppeteer to get the current URL of any user's Twitter avatar by screen-scraping, for times when you're just too lazy to get some OAuth tokens and implement the Twitter API v2. Pass twitter usernames as command-line arguments.
View get-twitter-avatar.js
/* Copyright (c) 2021 Dan Q; released under the MIT License. */
const Puppeteer = require('puppeteer');
getAvatar = async (twitterUsername) => {
const browser = await Puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();
await page.goto(`${twitterUsername}`);
await page.waitForSelector('a[href$="/photo"] img[src]');
const url = await page.evaluate(()=>document.querySelector('a[href$="/photo"] img').src);
Dan-Q / clicker.rbw
Created August 25, 2020 12:46
Runs in the background, makes an (inaudible?) sound every so often to keep your soundbar awake.
View clicker.rbw
# Dependencies
require 'bundler/inline'
gemfile(true) do
source ''
gem 'win32-sound', require: 'win32/sound'
include Win32
FREQUENCY = 37 # Hz; 37-32767 - what pitch sound?
DURATION = 1 # Ms - how long to play for?
Dan-Q / loader-modern-browsers.js
Last active August 9, 2020 17:50
Lazy-loading CSS without introducing a mandatory JS dependency; see for more or for discussion
View loader-modern-browsers.js
// This version works with modern browsers
function lazyLoadCSS(){
(document.readyState != 'loading') ? lazyLoadCSS() : document.addEventListener('DOMContentLoaded', lazyLoadCSS);
Dan-Q / wp-post-kinds-prefix-kind-in-rss.php
Last active March 1, 2020 11:23
Add Post Kinds for Wordpress kinds as a prefix to titles in RSS.
View wp-post-kinds-prefix-kind-in-rss.php
// Make titles in RSS feed be prefixed by the Kind of the post.
function add_kind_to_rss_post_title(){
$kinds = wp_get_post_terms( get_the_ID(), 'kind' );
if( ! isset( $kinds ) || empty( $kinds ) ) return get_the_title(); // sanity-check.
$kind = $kinds[0]->name;
$title = get_the_title();
return trim( "[{$kind}] {$title}" );