Skip to content

Instantly share code, notes, and snippets.

View TylerMills's full-sized avatar

Tyler Mills TylerMills

View GitHub Profile
@remy
remy / ActiveLink.js
Last active April 12, 2024 08:33
Next.js version of `activeClassName` support.
@jsheedy
jsheedy / iter_file.py
Last active February 2, 2024 06:59
Sometimes you need a file-like object when all you have is an iterator, for instance when using psycopg2's cursor.copy_from. This class will handle the impedance mismatch.
import io
import sys
class IteratorFile(io.TextIOBase):
""" given an iterator which yields strings,
return a file like object for reading those strings """
def __init__(self, it):
self._it = it
self._f = io.StringIO()