Skip to content

Instantly share code, notes, and snippets.

@gurchik
gurchik / README.md
Created March 21, 2024 18:13
Search AWS IP list for a specific IP
@gurchik
gurchik / README.md
Last active March 8, 2024 20:00
Get all ECR images with more than 900 tags

Get all ECR images with more than 900 tags.

AWS has a hard limit of 1000 tags on any single image.

Attempting to push another tag on that image will result in an error like the following:

ERROR: failed commit on ref "index-sha256:......": unexpected status from PUT request to https://ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/v2/REPOSITORY/manifests/TAG_NAME: 403 Forbidden

In CloudTrail the error looks like:

@gurchik
gurchik / backup.sh
Created October 22, 2023 04:36
Backup iCloud directory to USB drive
#!/bin/bash
7zip_installed() {
builtin type -P "7zz" &> /dev/null
}
prompt_with_default() {
read -p "$1 ($2):" INPUT
if [ -z "$INPUT" ]; then
echo "$2"
@gurchik
gurchik / README.md
Last active June 2, 2023 02:59
Analyze S3 Usage Report

Analyze S3 Usage Report

Format an AWS Usage Report for S3 charges to make it simpler to compare your usage to the public S3 Pricing page.

For example, the pricing page lists Tier 1 (i.e. PUT, COPY, POST, and LIST) requests at one cost and Tier 2 (GET, SELECT, and all others) requests at a different cost. However, the Usage Report lists requests by API call (e.g. GetObject, ListBucket, etc). This is a bit annoying, so this script parses them into their respective billing tiers.

Instructions

  1. Navigate to AWS Billing. Select "Cost & usage reports" then "Create a usage report"
  2. Enter "Amazon Simple Storage Service" as the Service, "All usage types" for the Usage Type, "All Operations" for the Operations. Then select a time period and granularity.
@gurchik
gurchik / README.md
Last active May 11, 2023 14:26
Get AMIs used by all EC2s in an account

Get AMIs used by all EC2s in an account

Example output:

{
    "ami-123redacted": {
        "id": "ami-123redacted",
        "name": "The name of the AMI",
 "instances": {
@gurchik
gurchik / list_all_route53_records.py
Created April 5, 2023 15:29
List all AWS Route 53 Records in all Hosted Zones
import boto3
client = boto3.client('route53')
def get_zones():
paginator = client.get_paginator("list_hosted_zones")
for page in paginator.paginate():
yield from page["HostedZones"]
def get_records(zone_id):
@gurchik
gurchik / run.js
Created March 1, 2023 06:25
Convert Spotify Playlist to JSON
/*
1. Open the playlist in Spotify Web (logged in if it's a private playlist)
2. Paste this in the browser's Developer Tools
For playlists longer than a handful of tracks, the entire track list won't be loaded in the DOM.
Scrolling down the page will rows from the top and vice versa. Therefore you will need to run this,
scroll down on the page to the last track outputted, run it again, etc until you get them all, then
combine the results together.
*/

Keybase proof

I hereby claim:

  • I am gurchik on github.
  • I am gurchik (https://keybase.io/gurchik) on keybase.
  • I have a public key ASC5ck8vPIzBuufV6z_77jz1rt3Wc5r9QKF72JxMkgwXKQo

To claim this, I am signing this object:

@gurchik
gurchik / calc.asm
Last active September 14, 2018 12:34
A heavily-documented RPN calculator written in pure x86 assembly
; Allow the linker to find the _start symbol. The linker will begin program execution
; there.
global _start
; Start the .data section of the executable, which stores constants (read-only data)
; It doesn't matter which order your sections are in, I just like putting .data first
section .rodata
; Declare some bytes at a symbol called error_msg. NASM's db pseudo-instruction
; allows either a single byte value, a constant string, or a combination of the two
; as seen here. 0xA = new line, and 0x0 = string-terminating null
@gurchik
gurchik / calc.asm
Last active January 8, 2020 16:45
A heavily-documented Hello World in x86 assembly
; Allow the linker to find the _start symbol. The linker will begin program execution
; there.
global _start
; Start the .data section of the executable, which stores constants (read-only data)
; It doesn't matter which order your sections are in, I just like putting .data first
section .rodata
; Declare some bytes at a symbol called hello_world. NASM's db pseudo-instruction
; allows either a single byte value, a constant string, or a combination of the two
; as seen here. 0xA = new line, and 0x0 = string-terminating null