Skip to content

Instantly share code, notes, and snippets.

View MatthewScholefield's full-sized avatar

Matthew D. Scholefield MatthewScholefield

View GitHub Profile
@MatthewScholefield
MatthewScholefield / README.md
Last active December 13, 2020 02:13
PDF Searcher

Interactive PDF Searcher

Use this tool to quickly search PDFs:

asciicast

It continuously asks for a search query and then asks you for a search result to open in a PDF reader.

Installation

@MatthewScholefield
MatthewScholefield / ipython_exporter.py
Last active December 31, 2023 10:53
Script to Efficiently Extract and Organize IPython Session History: A tool for seamlessly transitioning your prototype code, including import statements and function definitions, from an IPython environment to a structured Python script
# Define functions with underscore so they aren't included in output
def _print_import_statements():
from IPython import get_ipython
ipython = get_ipython()
if not ipython:
print("This function only works in an IPython environment.")
return
history = list(ipython.history_manager.get_range(output=False))
@MatthewScholefield
MatthewScholefield / prune_zsh_history.py
Last active January 5, 2024 22:09
ZSH history truncator
import argparse
def process_history(input_file, output_file, char_limit):
prune_count = 0
with open(input_file, 'rb') as infile, open(output_file, 'wb') as outfile:
current_entry = b''
for line in infile:
current_entry += line
if not line.endswith(b'\\\n'): # End of an entry