This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python3 | |
| # Usage: img2ascii <img_file> <col_width> | |
| from PIL import Image | |
| import numpy as np | |
| ASCII_CHARS = np.array(list( | |
| " .:-=+*#%@" | |
| )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Instead of having to figure out how many steps or how many epochs I want to wait, | |
| # (e.g. `if epochs % viz_every == 0:` or `if steps % ckpt_every == 0`) | |
| # sometimes I'd rather have something wall-clock-time-based and easy to call. | |
| # Hence this. | |
| # Sample usage: `if do_every('15min'):`, or with optional id: `if do_every('1h', 'viz'):` etc. | |
| import time | |
| import inspect | |
| import re | |
| _timers = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Bluesky advanced search: filter by following, mentions, likes. | |
| Usage: | |
| export BLUESKY_HANDLE="yourusername.bsky.social" | |
| export BLUESKY_SCRAPER_PASSWORD="your-app-password" | |
| python bsky_search.py "transformer" # search own posts | |
| python bsky_search.py "climate from:following" # posts from people you follow | |
| python bsky_search.py "neural in:likes" # in posts you've liked | |
| python bsky_search.py "interesting from:following in:mentions" # mentions from people you follow | |
| Author: Scott H. Hawley, @drscotthawley.bsky.social |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Get .tex source for talking to LLMs about papers w/o them mangling PDFs | |
| import os, re, tarfile, subprocess, tempfile | |
| import arxiv | |
| from fastcore.script import call_parse | |
| def extract_arxiv_id(text: str) -> str|None: | |
| """Extract arxiv ID from text (URL or PDF content).""" | |
| patterns = [ | |
| r'arxiv\.org/abs/(\d+\.\d+)', # URL format |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| from torch import nn | |
| import matplotlib.pyplot as plt | |
| import torch.nn.functional as F | |
| import wandb | |
| class ResidualBlock(nn.Module): | |
| def __init__(self, channels, use_skip=True, use_bn=True, act=nn.GELU): | |
| super().__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usage: python fix_notebook.py <.ipynb file> | |
| # WARNING: this overwrites the file, so save a backup first | |
| # To execute on a whole folder of files, run this bash command: | |
| # find . -name "*.ipynb" -exec python fix_notebook.py {} \; | |
| import json | |
| import sys | |
| def fix_notebook(filename): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # syncs python files in dir and subdirs so you don't have to run resource-hogging VSCode Remote | |
| # usage: pysync /path/to/local/directory/ user@remote:/path/to/remote/directory/ | |
| # UPDATED version: more code than before, but now it follows symbolic links on the remote server instead of just overwriting them | |
| pysync() { | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: pysync <source> <destination>" | |
| return 1 | |
| fi | |
| fswatch -o "$1" | while read f; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import json | |
| import subprocess | |
| import argparse | |
| import sys | |
| import os | |
| def parse_override_args(args): | |
| """Parse CLI arguments that start with '--' into a dict.""" | |
| overrides = {} |
NewerOlder