Skip to content

Instantly share code, notes, and snippets.

View alberto-morales's full-sized avatar

Alberto Morales alberto-morales

View GitHub Profile
@alberto-morales
alberto-morales / lru_cache.py
Created October 13, 2019 09:33 — forked from wmayner/lru_cache.py
[Python] Memory-aware LRU cache decorator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Memory-aware LRU Cache function decorator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A modification of the builtin ``functools.lru_cache`` decorator that takes an
additional keyword argument, ``use_memory_up_to``. The cache is considered full
if there are fewer than ``use_memory_up_to`` bytes of memory available.
@alberto-morales
alberto-morales / rmvpc.py
Last active February 18, 2022 19:13 — forked from vernhart/rmvpc.py
Deleting an AWS VPC with python's boto3
#!/usr/bin/env python
"""I was trying to programatically remove a Virtual Private Cloud (VPC) in
AWS and the error message was not helpful:
botocore.exceptions.ClientError: An error occurred (DependencyViolation)
when calling the DeleteVpc operation: The vpc 'vpc-c12029b9' has
dependencies and cannot be deleted.
Searching for a quick solution was not fruitful but I was able to glean some
knowledge from Neil Swinton's gist: