Skip to content

Instantly share code, notes, and snippets.

View bryant1410's full-sized avatar

Santiago Castro bryant1410

View GitHub Profile
#!/usr/bin/env python
import argparse
import heapq
def parse_args():
parser = argparse.ArgumentParser(description="Analyze bashstart log for speed.")
parser.add_argument('filename', help="often /tmp/bashstart.<PID>.log")
parser.add_argument('-n', default=20, help="number of results to show")
return parser.parse_args()
@bryant1410
bryant1410 / find_commits.sh
Created February 20, 2020 01:54
Find any commit from any repo for a given author and between given dates
#!/usr/bin/env bash
for d in ~/repos/*; do
pushd "$d" > /dev/null
if [ -d .git ]; then
echo $d
echo "branch $(git rev-parse --abbrev-ref HEAD)"
git --no-pager log --color=always --all --oneline --graph --decorate --after 2019-04-20 --before 2019-05-15 --author='Santiago Castro'
fi
popd > /dev/null
@bryant1410
bryant1410 / set_terminal_width.py
Created April 13, 2020 04:54
Script to change the terminal width (passed by arg) from Python.
#!/usr/bin/env python
"""Script to change the terminal width (passed by arg) from Python."""
import argparse
import fcntl
import struct
import sys
import termios
from array import array
from typing import IO
@bryant1410
bryant1410 / change_terminal_width.py
Last active April 26, 2022 06:31
Quick workaround to change PyCharm's remote terminal width
# See https://youtrack.jetbrains.com/issue/PY-40900#focus=streamItem-27-4082296.0-0
width = 215; print("Terminal width:", width)
if sys.stdout.isatty():
import fcntl, struct, sys, termios; fcntl.ioctl(sys.stdin, termios.TIOCSWINSZ, struct.pack("HHHH", 0, width, 0, 0))
else: # In case it's not remote.
import os; os.environ["COLUMNS"] = str(width) # It doesn't work everywhere, but it's something.
os.environ["LINES"] = "21" # Some programs need both env vars set for any to work.
@bryant1410
bryant1410 / main.py
Created March 13, 2022 18:14
LaTeX style for Matplotlib in Google Colab
# First: sudo apt install cm-super dvipng texlive-latex-extra texlive-latex-recommended texlive-science
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.rcParams["text.usetex"] = False # True # It looks better with the default font.
mpl.rcParams["text.latex.preamble"] = (r"\usepackage{siunitx}"
r" \sisetup{detect-all}"
r" \usepackage{helvet}"
r" \usepackage{sansmath}"
@bryant1410
bryant1410 / etserver
Created May 8, 2023 17:47
System V init script for an EternalTerminal server (place under `/etc/init.d`)
#!/usr/bin/env bash
#
# chkconfig: 35 90 12
# description: EternalTerminal server
#
# Get function from functions library
. /etc/init.d/functions
start() {