Skip to content

Instantly share code, notes, and snippets.


Alan Yee alanyee

View GitHub Profile
alanyee /
Last active Jan 7, 2021
Boto3 Tail AWS Cloudwatch Logs
"""Using boto3, instead of awscli, to tail logs. Based on"""
from collections import defaultdict
import sys
import time
import boto3
from botocore.exceptions import ClientError, ParamValidationError
alanyee /
Created Oct 5, 2020
Find the current Kali Linux AMI
aws ec2 describe-images \
--owners 679593333241 \
--filters 'Name=name,Values=Kali*' 'Name=state,Values=available' \
--query 'reverse(sort_by(Images, &CreationDate))[:1].ImageId' \
--output text
alanyee /
Last active Mar 3, 2020
Maxheap version of for safe keeping
def _siftdown_max(heap, startpos, pos):
'Maxheap variant of _siftdown'
newitem = heap[pos]
# Follow the path to the root, moving parents down until finding a place
# newitem fits.
while pos > startpos:
parentpos = (pos - 1) >> 1
parent = heap[parentpos]
if parent < newitem:
heap[pos] = parent
alanyee /
Created Oct 21, 2019
Suppress help from usage statement
import argparse
parser = argparse.ArgumentParser(prog='PROG', add_help=False)
parser.add_argument('--help', '-h', action='help', help=argparse.SUPPRESS)
from functools import partial
def iseven(n, d=2):
return n % d == 0
def groupby(key, seq):
"""Based on toolz groupby"""
result = defaultdict(list)
for item in seq:
alanyee /
Created Jan 11, 2016
Proving my GitHub identity for Keybase

Keybase proof

I hereby claim:

  • I am alanyee on github.
  • I am alyee ( on keybase.
  • I have a public key whose fingerprint is 9F7E F201 F155 949E 91CF C0F9 8567 AADE BD3D 9319

To claim this, I am signing this object: