Skip to content

Instantly share code, notes, and snippets.

@Gerardwx
Gerardwx / lrucache.py
Last active February 17, 2023 02:39
Least recently used dictionary
#!/usr/bin/env python3
import collections
import random
from typing import Hashable, Any, Optional, Dict, Tuple
class LruCache:
"""Dictionary like storage of most recently inserted values"""
def __init__(self, size: int = 1000):
@Gerardwx
Gerardwx / setfsuid.py
Last active July 17, 2019 15:43 — forked from atdt/setfsuid.py
Python wrapper for setfsuid
# based on https://gist.github.com/atdt/ebafa299e843a767139b
# Copyright (c) 2019 Ori Livneh
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.