Skip to content

Instantly share code, notes, and snippets.

View colin-nolan's full-sized avatar

Colin Nolan colin-nolan

View GitHub Profile
@colin-nolan
colin-nolan / notes.txt
Created September 20, 2022 20:30
TV CEC Investigation
# CEC Byte lookup: https://www.cec-o-matic.com/
# HDMI 2 (Firestick)
echo "tx 4F:82:20:00" | cec-client -s -d 1
# HDMI 3 (rpi)
echo "tx 4F:82:30:00" | cec-client -s -d 1
# On TV (device 0)
echo "on 0" | cec-client -d 1 -s
@colin-nolan
colin-nolan / install-rpi-userland.sh
Last active March 16, 2019 18:15
Compiles and installs userland libraries for rpi (intended as a Docker build step)
# Copyright 2019 Colin Nolan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@colin-nolan
colin-nolan / key_value_string_parser.py
Last active October 21, 2018 15:53
Parses `xxx:yyy` or a stringified JSON map as a dictionary (for use with CLI `ArgumentParser`)
# Copyright (c) 2018 Genome Research Limited
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
@colin-nolan
colin-nolan / verbosity-argument-parser.py
Last active October 16, 2018 23:20
Argument parser for verbosity, where more `-v` is to be used to increase the logging level
# Copyright (c) 2018 Genome Research Limited
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
@colin-nolan
colin-nolan / get-openstack-instance-hosts.sh
Created August 16, 2018 09:39
Gets the host IDs running OpenStack instances
openstack server list -f json | jq -r '.[].ID' | xargs -I {} -P 8 openstack server show -f json {} | jq '{hostId,name}'
@colin-nolan
colin-nolan / get-contributed-github-repos.sh
Created June 25, 2018 11:37
Gets a list of GitHub repositories that a user has contributed to within the last 90 days
#!/usr/bin/env bash
#
# Note: there is a 300 event/90 day limit (https://developer.github.com/v3/activity/events/).
#
# Requires: jq curl sed grep
#
set -euf -o pipefail
GIT_USER=$1
@colin-nolan
colin-nolan / passenger-memory-over-time.py
Created June 18, 2018 11:11
Very quick plot of passenger instance memory usage over time
# Requires install of packages:
# - delta
# - leather
#
# Working with data written periodically to a file:
# `passenger-status --show=xml | python <(echo -e "import xmltodict\nimport json\nimport sys\nprint(json.dumps(xmltodict.parse(sys.stdin.read())))")`
import json
from collections import defaultdict
import leather
inputFile="$1"
function classifyFailure {
objectLocation="$1"
objectName="$(basename ${objectLocation})"
mc cat "${objectLocation}" &> /dev/null
if [[ $? -ne 0 ]]; then
echo "${objectLocation} = UNREADABLE"
else
@colin-nolan
colin-nolan / verify-blocks.sh
Created June 13, 2018 10:11
Verifies content addressed blocks in S3
s3Location="$1"
function verifyMd5 {
objectLocation="$1"
objectName="$(basename ${objectLocation})"
mc cat "${objectLocation}" \
| md5sum -c <(echo "${objectName} -") --status \
&& echo "${objectLocation} = OK" \
|| echo "${objectLocation} = BAD"
exit 0
@colin-nolan
colin-nolan / bottle_wrapper.py
Last active March 7, 2018 09:57
Wrapper for creating Python Bottle server applications
# Copyright (c) 2018 Genome Research Limited
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#