Skip to content

Instantly share code, notes, and snippets.

@losvedir
losvedir / gist:661564
Created November 3, 2010 19:33
Cracker Barrel Triangle Peg Jumping Game Solver
/* Solves one of those triangle shaped peg jumping puzzles.
You begin with a board composed of n rows, where the i-th
row contains i columns. e.g.:
X
X X
X X X
The board begins with pegs in all holes but one. A peg can
jump over another peg if it can land in a hole on the other
side. The jumped peg is removed. The goal is to finish with
a single peg remaining.
@losvedir
losvedir / ecr_cleanup.md
Last active May 25, 2022 19:15
Clean up old ECR images

Cleaning up old ECR images

A process to delete old ECR images using the aws CLI tool and jq.

The general idea is to use aws ecr describe-images to enumerate the images, and aws ecr batch-delete-image to delete them. The latter command can take a --cli-input-json argument specifying a JSON file which lists the images to delete. jq is used to filter describe-images to only the old ones, and munge it into the format that batch-delete-image expects. Unfortunately, batch-delete-image supports a maximum of 100 images at a time, so the process may need to be repeated several times.

Limitations:

  • I can't find a way to do this as a neat command line pipeline. --cli-input-json seems to require that the input comes from a file, rather than STDIN. (AWS CLI tracking issue: aws/aws-cli#3209)
  • Since batch-delete-image can only handle 100 images at a time, the jq command slices to [0:100] after filtering to just the old images. This means the process may have to be re