Skip to content

Instantly share code, notes, and snippets.

Dan Q Dan-Q

Block or report user

Report or block Dan-Q

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Dan-Q / wp-post-kinds-prefix-kind-in-rss.php
Last active Mar 1, 2020
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}" );
Dan-Q / countdown.html
Last active Sep 3, 2019
Workday countdown timer
View countdown.html
<!DOCTYPE html>
<meta charset="utf-8" />
<style type="text/css">
body {
margin: 0;
font-family: sans-serif;
font-size: 8vh;
Dan-Q / bbc-news-rss-filter-sport-out.rb
Last active May 13, 2019
Filter the Sport section out of the BBC News RSS feed and put the result into a Backblaze B2 bucket
View bbc-news-rss-filter-sport-out.rb
#!/usr/bin/env ruby
# # Sample crontab:
# # At 41 minutes past each hour, run the script and log the results
# 41 * * * * ~/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
# * b2 - command line tools, described below
Dan-Q / consolepic.rb
Created Dec 12, 2018
Convert a (small!) PNG image into JS/CSS that 'draws' the image in a Firefox/Chrome debug console.
View consolepic.rb
#!/usr/bin/env ruby
# Bundler/Gemfile (inline mode)
require 'bundler/inline'
gemfile do
source ''
gem 'chunky_png'
# Check for PNG file passed at command line or error out
Dan-Q / google-authenticator.rb
Last active Mar 8, 2019
Command-line Google Authenticator (TOTP)
View google-authenticator.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# encoding: utf-8
require 'bundler/inline'
gemfile do
source ''
gem 'rotp'
gem 'thor'
View Basic Reddit Content Exporter.js
// Basic Reddit Content Exporter
// Author: Dan Q <>
// License: The Unlicense <> / Public Domain
// 1. Go to and log in (logging in means that we don't have to worry about a modhash)
// 2. Edit this script to include YOUR username and the content you want to download
// 3. Paste this script into your browser console
const username = 'avapoet'; // <-- your username goes here (be sure to be logged in as it, too!)
const content = 'submitted'; // <-- valid options: overview (everything), submitted (posts), comments,
Dan-Q /
Created Sep 4, 2018
Experiment to use OpenSSL to establish an EV-capable CA and issue illigitimate certificates which will be accepted and displayed as full valid EV certificates by Microsoft Internet Explorer and Edge on appropriately-configured Windows computers.
# The following steps, which were tested on Ubuntu 18.04 LTS and on the Ubuntu-powered Linux for Windows Subsystem on Windows,
# will:
# * Compile a recent version of OpenSSL (you can skip this step and use your package maintainer's version if you prefer, but you
# might have to tweak a few bits)
# * Create a separate set of configuration files suitable for configuring a basic CA capable of signing EV certificates
# * Create such a CA (hackerca.local / HackerCA EV Root CA)
# * Create a certificate request for a site, hackersite.local, belonging to company "Barclays PLC [GB]"
Dan-Q / geohash-pcwater.js
Last active Aug 22, 2018
Perform pixel-analysis on OpenStreetMap tiles to estimate water coverage of a graticule. More info:
View geohash-pcwater.js
* More details can be found at:
* Given a graticule (e.g. 51 -1), returns the percentage water cover
* of that graticule based on pixel colour sampling of OpenStreetMap
* tile data. Change the zoomLevel to sample with more (higher) or less
* (lower) granularity: this also affects the run duration. Higher
* granularity improves accuracy both by working with a greater amount
* of data AND by minimising the impact that artefacts (e.g. text,
Dan-Q / README.txt
Created May 4, 2018
GC591VV "You Can't Do It Alone!" geocache source code
View README.txt
This is the source code the the Arduinos powering my GC591VV "You Can't Do It Alone!" cache:
further details can be found at
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 / jack-fm-logger.rb
Last active Sep 25, 2017
Polls the Jack FM website every 60 seconds to see what song they're playing, and records it to an SQLite database. More details at
View jack-fm-logger.rb
require 'open-uri'
require 'sqlite3'
require 'nokogiri'
# Load DB, create schema if absent
db = 'log.db'
db.execute "CREATE TABLE IF NOT EXISTS plays (time INTEGER, artist TEXT, song TEXT);"
# Utility functions
You can’t perform that action at this time.