Skip to content

Instantly share code, notes, and snippets.

@robmiller
robmiller / ssl-expiry.rb
Created Oct 23, 2017
ssl-expiry: displays the expiry date of SSL certificates associated with any domains passed on the command line
View ssl-expiry.rb
#!/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:
@robmiller
robmiller / sitemap.rb
Created Sep 22, 2017
Fetch a sitemaps.org-compatible sitemap file and output all of its URLs on the command-line
View sitemap.rb
#!/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.
#
@robmiller
robmiller / ssl-check.rb
Last active Aug 16, 2017
ssl-check: checks for expiring SSL certificates. Useful for piping into Slack on a cron
View ssl-check.rb
#!/usr/bin/env ruby
#
# ssl-check
#
# Checks for expiring SSL certificates, specified on the command line.
#
# Usage:
#
# $ ssl-check hosts.txt
#
@robmiller
robmiller / urls.sh
Last active Sep 26, 2017
Find all unique URLs on a website. Sort them. Output them in nginx rewrite format. Useful when replacing an old website to make sure there are as few 404s as possible
View urls.sh
# 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;"'
View euro2016.rb
#!/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"]
@robmiller
robmiller / wait-rs-server.rb
Last active May 10, 2016
Wait for a Rackspace cloud server to build
View wait-rs-server.rb
#!/usr/bin/env ruby
require "fog"
hostname = ARGV.fetch(0)
compute = Fog::Compute.new(
provider: "Rackspace",
rackspace_api_key: ENV.fetch("RACKSPACE_API_KEY"),
rackspace_username: ENV.fetch("RACKSPACE_USERNAME"),
@robmiller
robmiller / enable-rs-db-root.rb
Created Feb 4, 2016
A script for easily enabling the root account on a Rackspace cloud database instance, something that's inexplicably impossible to do via the GUI
View enable-rs-db-root.rb
#!/usr/bin/env ruby
#
# enable-rs-db-root
#
# Enables the root account on a Rackspace cloud database instance.
#
# Usage:
#
# enable-rs-db-root name.of.your.instance.example.com
#
@robmiller
robmiller / childish.sh
Last active Dec 11, 2015
childish fun
View childish.sh
#!/bin/bash
# Uses text to speech to say MESSAGE 1,000 times, ensuring that sound
# is unmuted and the audio device is set to the internal speakers
#
# Usage: childish MESSAGE
#
# Requires audiodevice:
# http://whoshacks.blogspot.co.uk/2009/01/change-audio-devices-via-shell-script.html
for i in `seq 1 1000`
@robmiller
robmiller / archive-github.rb
Created Oct 27, 2015
Clones a GitHub repository locally, and then deletes it from GitHub. Useful for cleaning up no-longer-needed private repos. Usage: archive-github OWNER REPO_NAME
View archive-github.rb
#!/usr/bin/env ruby
#
# archive-github
#
# Author: Rob Miller <r@robm.me.uk>
#
# Clones a GitHub repository locally, and then deletes it from GitHub.
# Useful for cleaning up no-longer-needed private repos.
#
# Assumes you have an OAuth token stored in an environment variable
View system_profiler.rs
extern crate plist;
use std::process::Command;
use std::io::{Read,Seek,SeekFrom,Cursor};
use plist::StreamingParser;
fn main() {
println!("Profiling system.");
let profiler = Command::new("system_profiler")