This file contains 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 | |
""" | |
How to use pdfbox's PDFTextStripper class in Python. | |
""" | |
import pathlib | |
import pkg_resources | |
import re | |
import urllib.request |
This file contains 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 | |
""" | |
How to call pdfbox's API with JPype. | |
""" | |
import pathlib | |
import pkg_resources | |
import re | |
import urllib.request |
This file contains 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 | |
""" | |
Compute total memory consumed by PyTorch tensors. | |
""" | |
import gc | |
import torch |
This file contains 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
#!/bin/bash | |
# Add the following lines to .bashrc to enable tab completion of available conda | |
# environment names when using conda activate. Assumes conda and jq are in one's PATH: | |
export CONDA_ENV_LIST=`conda env list --json | jq -r '[ .envs[1:][] | split("/")[-1] ] | join(" ")'` | |
complete -W "$CONDA_ENV_LIST" conda activate |
This file contains 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 python | |
""" | |
Add syntax highlighting to nbshow output. | |
""" | |
import argparse | |
import re | |
import pygments |
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 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 | |
""" | |
Recursively convert rpy2 objects to nested Python data structures. | |
""" | |
import numpy as np | |
from rpy2.robjects import default_converter, globalenv, \ | |
NULL, numpy2ri, pandas2ri, ListVector, r |
This file contains 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 | |
""" | |
Class that provides an ImageIO-like interface to a sequence of videos treated as a single video. | |
""" | |
import bisect | |
import copy | |
import itertools |
This file contains 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 bisect | |
import itertools | |
def find_lub_cumsum_index(a, x): | |
a_cumsum = list(itertools.accumulate(a)) | |
i = bisect.bisect_right(a_cumsum, x) | |
if i != len(a): | |
return i | |
raise ValueError |
This file contains 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 | |
""" | |
Display movie file with support for browsing forward and backward through frames | |
with a slider or arrow keys. | |
""" | |
import argparse | |
import datetime | |
import os |
NewerOlder