This file contains 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
/* reveals koalastothemax.com without needing to move your mouse */ | |
var mm = new Event("mousemove"); | |
function rand(min, max) { return Math.ceil(Math.random() * (max - min) + min); } | |
function sorter(c1, c2) { if ( c1[0] > c2[0] ) { return -1; } if ( c1[0] < c2[0] ) { return 1; } return 0 } | |
function getBiggestCircle() { | |
var circles = [...document.querySelectorAll("#dots circle")].map(c => [c.getBBox().width, c]).sort(sorter); | |
return circles[0][1]; | |
} |
This file contains 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 | |
# | |
# Solutions to Diamond Geezer's "the digits of the year 2019 add up to twelve" puzzles: | |
# http://diamondgeezer.blogspot.com/2019/01/the-digits-of-year-2019-add-up-to-twelve.html | |
def main | |
# a) How many years ago did this last happen? | |
a = 2019 - 2018.downto(0).find { |year| sum_digits(year) == 12 } | |
# b) In what year? | |
b = 2018.downto(0).find { |year| sum_digits(year) == 12 } |
This file contains 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
#!/bin/bash | |
# | |
# spider | |
# | |
# Author: Rob Miller <rob@bigfish.co.uk> | |
# | |
# Outputs all of the HTML pages on a given domain. | |
wget -r -nd --delete-after -w 1 "$1" 2>&1 | |
This file contains 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 | |
# | |
# Sometimes you want to sort a list of hostnames/domains and want | |
# example.com to sort next to www.example.com. This does that. | |
# | |
# Author: Rob Miller <r@robm.me.uk> | |
# | |
# Usage: | |
# | |
# $ cat foo.txt | sort-domains |
This file contains 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 | |
# | |
# Calculates the SMOG (Simple Measure of Gobbledygook) score for a given | |
# piece of text. A CLI utility that could very easily be adapted into | |
# a library if I could be be bothered. | |
# | |
# More on SMOG: https://en.wikipedia.org/wiki/SMOG | |
# | |
# Author: Rob Miller <r@robm.me.uk> | |
# |
This file contains 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 | |
# | |
# ssl-expiry | |
# | |
# Author: Rob Miller <rob@bigfish.co.uk> | |
# | |
# For a given domain or domains, checks to see if an SSL certificate is | |
# present; if one is, outputs the date of its expiry. | |
# | |
# Usage: |
This file contains 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 | |
# | |
# sitemap | |
# | |
# Author: Rob Miller <rob@bigfish.co.uk> | |
# | |
# Fetches and parses a sitemaps.org-compatible sitemap file, outputting | |
# all of the URLs stored in it; useful to start a spidering process, or | |
# to generate a list of URLs to later redirect. | |
# |
This file contains 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 | |
# | |
# ssl-check | |
# | |
# Checks for expiring SSL certificates, specified on the command line. | |
# | |
# Usage: | |
# | |
# $ ssl-check hosts.txt | |
# |
This file contains 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
# Change example.com to the correct host | |
wget -r -nd --delete-after -w 0.5 'http://www.example.com/' 2>&1 | | |
grep -B3 text/html | | |
grep -B2 '200 OK' | egrep 'https?://' | | |
cut -d' ' -f3- | | |
sort | uniq | | |
ruby -ane 'puts "rewrite ^#{$_.strip.sub(%r{^https?://[^/]+/}, "/")}$ / permanent;"' |
This file contains 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 | |
require "json" | |
require "open-uri" | |
json = open("http://api.football-data.org/v1/soccerseasons/424/fixtures").read | |
fixtures = JSON.parse(json) | |
fixtures = fixtures["fixtures"] |