Skip to content

Instantly share code, notes, and snippets.

@frankcleary
frankcleary / boundedexecutor.py
Last active June 28, 2023 10:56
Python ThreadPoolExecutor with bounded queue
from concurrent.futures import ThreadPoolExecutor
from threading import BoundedSemaphore
class BoundedExecutor:
"""BoundedExecutor behaves as a ThreadPoolExecutor which will block on
calls to submit() once the limit given as "bound" work items are queued for
execution.
:param bound: Integer - the maximum number of items in the work queue
sshemr(){
jobid=`/path/to/elastic-mapreduce --list --active | awk '{ print $1 }' | head -n1`
/path/to/elastic-mapreduce --ssh $jobid
}
@frankcleary
frankcleary / figure_rename.py
Created April 23, 2014 04:28
Rename figure files (figure 3.jpg -> figure 4.jpg)
"""Rename a list of figures, making space for a new figure
Ex: Figure 1, Figure 2, Figure 3 -> Figure 1, Figure 3, Figure 4
"""
import sys
import os
import re