Skip to content

Instantly share code, notes, and snippets.

View EricWiener's full-sized avatar

Eric Wiener EricWiener

View GitHub Profile
@EricWiener
EricWiener / save_tensors_to_pickle.py
Last active December 30, 2023 02:00
Save tensors to pickle file
def save_tensors_to_pickle(output_file: str, to_numpy: bool, **kwargs) -> None:
"""Save tensors to pickle file.
Example usage:
```
save_tensors_to_pickle(
"train_output.pkl",
to_numpy=False,
inputs=inputs,
logits=logits,
@EricWiener
EricWiener / timeout.py
Created December 22, 2023 15:48
Python context manager and decorator to timeout after a certain amount of time.
import signal
from contextlib import contextmanager
from typing import Any, Generator
class TimeoutException(Exception):
"""Raised when a timeout occurs."""
pass
@EricWiener
EricWiener / nuke_ios.bash
Created February 18, 2021 03:39
Clean out an XCode cache (React Native w/ Cocoapods)
#!/bin/bash
# This should be run from the /ios directory of your project
rm Podfile.lock
rm -rf Pods
rm -rf ~/Library/Caches/CocoaPods
rm -rf ~/Library/Developer/Xcode/DerivedData
pod cache clean --all
pod install