Skip to content

Instantly share code, notes, and snippets.

View bradmontgomery's full-sized avatar
🩶
Robo-coding snarky little tools like a boss!

Brad Montgomery bradmontgomery

🩶
Robo-coding snarky little tools like a boss!
View GitHub Profile
@bradmontgomery
bradmontgomery / README.md
Last active May 12, 2026 19:56
gitls — like ls, but for git repos.

gitls — like ls, but for git repos.

Install

Quick install (system-wide):

curl -fsSL https://gist.githubusercontent.com/11c9bc92e22505dfc2513e24791892d1/raw/gitls -o gitls && chmod +x gitls && sudo mv gitls /usr/local/bin/gitls

Or install to your user bin (no sudo required):

@bradmontgomery
bradmontgomery / streak.py
Created June 30, 2013 02:41
Streak.com api snafu.
import requests # version 1.2.3
import ssl
from requests.adapters import HTTPAdapter, DEFAULT_POOLBLOCK
from requests.packages.urllib3.poolmanager import PoolManager
STREAK_API_KEY = 'USE-YOUR-API-KEY-HERE'
# A Function to list all the python classes in a file
function listclasses()
{
if [ -z "$1" ]; then
F="models.py"
else
F="$1"
fi
cat $F | grep "^class " | sed "s/class //" | sed "s/(.*$//" | sort
}
@bradmontgomery
bradmontgomery / process_pool_executor_example.py
Created March 3, 2017 20:06
Simple example of using ProcessPoolExecutor vs. serial execution in python.
import hashlib
import sys
from concurrent.futures import ProcessPoolExecutor
from time import sleep, time
def t1(n):
"""Silly function whose time increases as n does."""
for i in range(n):
@bradmontgomery
bradmontgomery / main.py
Last active April 18, 2026 19:36
Hack to get the uncompressed size of a gzip file without reading the whole thing.
#!/usr/bin/env python
"""
Test if we can reliably figure out the uncompressed size of .gz file...
"""
import gzip
import os
import subprocess
@bradmontgomery
bradmontgomery / example.py
Created January 29, 2019 16:55
Illustrating sys.argv in python
"""
This script illustrates how to use sys.argv to
capture command-line arguments.
Dowload & run this file like so:
python example.py
OR like this:
@bradmontgomery
bradmontgomery / list_gists.py
Last active April 18, 2026 19:35
Quick & dirty hack to list a user's gists, sorted by stars
#!/usr/bin/env python
"""
A quick & dirty hack to list all of your Gists sorted by stars.
This script lists your gists, the number of stars, the number of comments,
a truncated description, and the url for the gist.
NOTE: This only returns public gists. If you want to see (your own) private gists,
you can provide a personal access token.
@bradmontgomery
bradmontgomery / main.py
Created August 21, 2018 02:38
Examples of using concurrent.futures with Threads & Processes and the joblib library to read data from a bunch of files & do some simple parallell processing.
#!/usr/bin/env python
"""
process some data
"""
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
from joblib import Parallel, delayed
import os
import statistics
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active April 14, 2026 18:30
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@bradmontgomery
bradmontgomery / git-cheat-sheet.md
Last active March 27, 2026 06:36
a little git cheat sheet.

git cheat sheet

Interactively stage changes in a file

git add -ip <file>

Create a new, remote tracking branch (without branching from a local branch)

git co -b somebranch upstream/somebranch