Skip to content

Instantly share code, notes, and snippets.

View scarytom's full-sized avatar
💻
coding

Tom Denley scarytom

💻
coding
View GitHub Profile
@scarytom
scarytom / pull-all.sh
Created September 23, 2019 08:34
Pull all git repos
#!/bin/sh -eu
echo "pulling all projects..."
for d in "${HOME}"/projects/*; do
if [ -d "${d}/.git" ]; then
CURRENT_BRANCH="$(git -C "${d}" rev-parse --abbrev-ref HEAD)"
[ "${CURRENT_BRANCH}" = 'master' ] || echo -e "\r\033[KWARNING: ${d} is not on branch master"
if [ -z "$(git -C "${d}" status --porcelain)" ]; then
echo -en "\r\033[K ${d}"
git -C "${d}" pull --rebase --quiet
@scarytom
scarytom / README.MD
Created August 24, 2018 10:45
Flash bios on Lenovo laptop
  1. Download bios from lenovo website https://support.lenovo.com/gb/en/

  2. Convert the iso to a bootable image:

geteltorito -o bios.img g2uj18us.iso
  1. Write to usb stick and boot
@scarytom
scarytom / openfigi.sh
Created June 15, 2016 09:00
Script to call openfigi with a list of ISINs and return instrument data as JSON
#!/bin/sh -eu
BATCH_SIZE=100
debug() {
#echo "${1}" 1>&2
true
}
isin_to_json() {
#!/bin/sh -eu
while [ ${#} -gt 1 ]; do
key="${1}"
case "${key}" in
-n|--name)
NAME="${2}"
shift
;;
-a|--architecture)
@scarytom
scarytom / keebase.md
Created August 16, 2014 09:19
keebase.md

Keybase proof

I hereby claim:

  • I am scarytom on github.
  • I am scarytom (https://keybase.io/scarytom) on keybase.
  • I have a public key whose fingerprint is C819 4255 49F4 4CD5 8DCC 8BB7 E409 354C FB27 2F39

To claim this, I am signing this object:

@scarytom
scarytom / aptly-upload.sh
Last active August 29, 2015 14:01
Aptly Package Upload
#!/bin/bash -eu
LOCKFILE='/var/lock/.aptly-upload.exclusivelock'
LOCK_TIMEOUT_SECONDS='300'
PROMOTE=0
DISTRIBUTION='all'
STABLE_PREFIX='stable'
UNSTABLE_PREFIX='unstable'
@scarytom
scarytom / kvm_mem.sh
Created September 19, 2013 14:28
work out the memory usage of a kvm host
#!/bin/bash
virsh list | tail -n +3 | head -n -1 | awk -F" " '{print $2}' | sed 's/.*/\/etc\/libvirt\/qemu\/\0.xml/' | xargs grep memory
grep MemTotal /proc/meminfo
@scarytom
scarytom / instructions.md
Created September 1, 2013 11:35
wireless configuration on raspberry pi

Generating the PSK value for wpa_supplicant.conf

$ wpa_passphrase SSID

@scarytom
scarytom / 1_temper_instructions.md
Last active December 21, 2015 17:28
configuring temper sensor for non-root access

detect the device

  • start with the device unplugged
  • run udevadm monitor --udev
  • plug in the device
  • see output in udevadm_monitor.out
  • the device is recognisable on the third to last line as: /dev/usb/hiddev0

find device details

@scarytom
scarytom / mirror-github.sh
Last active March 26, 2018 13:49
Script to mirror github repos, designed to be run as a cron -- usage: $ mirror-github.sh bob/pet_proj dave/ fred/cool_proj
#!/bin/bash -eu
# Mirrors GitHub repos
# Takes a list of repos to mirror formatted as "user/reponame".
# The reponame can be omitted to mirror all repos for a user or organisation e.g. "youdevise/"
# The repos for a team can be mirrored using the syntax "team:orgname/teamname
#FIXME these might be better as arguments
MIRROR_DIR="${MIRROR_DIR:-/tmp/githubhmirror}"
GITHUB_USER="${GITHUB_USER:-}"