Skip to content

Instantly share code, notes, and snippets.

View rhowe's full-sized avatar
💭
Just being

Russell Howe rhowe

💭
Just being
View GitHub Profile
@rhowe
rhowe / summarise-aws-sdk-changelog
Last active July 21, 2023 14:44
Generate a digest of the AWS Java SDK changelog
curl -sf https://raw.githubusercontent.com/aws/aws-sdk-java/master/CHANGELOG.md |\
sed \
-e 's/Amazon Simple Storage Service/Amazon S3/' \
-e 's/^# /- /' \
-e 's/^## / - ## /' \
-e "s/#.*/'&'/" \
-e 's/: / - /g' \
-e 's/^ \(.*\)/ \1/' \
-e 's/^ -/ -/' \
-e 's/^ -/ -/' \
@rhowe
rhowe / aoc2020day01part1
Last active December 12, 2020 10:39
Advent of Code 2020
- hosts: localhost
tasks:
- name: Read input
set_fact:
input: "{{ lookup('file', 'input').splitlines() | map('int') | list }}"
- name: Prune impossible values from input
set_fact:
pruned_input: "{{ input | map('int') | reject('gt', 2020 - input | min | int) | reject('lt', 2020 - input | max | int) | list }}"
- name: Find items which sum to 2020
set_fact:
@rhowe
rhowe / aoc2019day1part1-ansible
Created November 29, 2020 20:07
Advent of Code 2019 (ansible)
- hosts: localhost
tasks:
- name: Calculate fuel per item
debug: msg="{{ ((item | int) / 3) | int - 2 }}"
loop: "{{ lookup('file', 'input').splitlines() }}"
register: output_things
- name: Calculate total fuel
debug: msg="{{ output_things.results | map(attribute='msg') | map('int') | sum }}"
@rhowe
rhowe / user-data
Created February 29, 2020 20:39
Cloudinit nocloud userdata
#cloud-config
bootcmd:
- echo this is very unsafe >> /root/helloworld
@rhowe
rhowe / 4-2.sh
Created February 20, 2020 17:15
AOC2019day4part2
#!/bin/bash
set -eu
set -o pipefail
thisisfine=$(seq 0 9 | sed 's/.*/^&&[^&]|[^&]&&[^&]|[^&]&&$/' | xargs | tr \ \|)
seq "${1%-*}" "${1#*-}" \
| grep -Ev '10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8]' \
| grep -cE "$thisisfine"
@rhowe
rhowe / 4.sh
Created February 20, 2020 17:15
AOC2019day4
#!/bin/bash
set -eu
seq ${1%-*} ${1#*-} \
| grep -E '(00|11|22|33|44|55|66|77|88|99)' \
| grep -cEv '(10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8])'
@rhowe
rhowe / 2.sh
Created February 20, 2020 17:14
AOC2019day2
#!/bin/bash
set -eu
IFS=, read -r -a program
for noun in $(seq 0 99); do
for verb in $(seq 0 99); do
program[1]=$noun
program[2]=$verb
@rhowe
rhowe / 1-2.sh
Created February 20, 2020 17:14
AOC2019day1part2
#!/bin/sh
set -eu
total=0
while read -r val; do
xtra=$((val / 3 - 2))
while [ "$xtra" -gt 0 ]; do
total=$((total + xtra))
@rhowe
rhowe / 1.sh
Created February 20, 2020 17:14
AOC2019day1
#!/bin/bash
sed -e 's#$#/3-2#' |xargs |tr \ +| bc
@rhowe
rhowe / 19.sh
Created January 27, 2020 02:43
AOC2019day19part1
#!/bin/bash
set -eu
declare -ai ram
declare -i addrmode1 addrmode2 arg1 arg2 pc=0 rb=0
IFS=, read -r -a program < input
shift
ops=(x '+' '*' x x '-eq' '-ne' '<' '==')