Skip to content

Instantly share code, notes, and snippets.

@vitchyr
vitchyr / git_info.py
Created May 14, 2021 23:15
Save Git Info in Python for Reproducible Experiments
"""
Helper functions to save git information every time you
Requirements:
- GitPython==2.1.12
(Probably works on other GitPython versions, but this is the version I've tested.)
Usage:
```
@why-not
why-not / stop-idle-azure-aws.py
Last active March 4, 2024 19:49
Automatically Shutting Down and Deallocating an AZURE or AWS VM (when idle AND no one is logged in via SSH)
#!/usr/bin/env python
# shell commands being automated.
# w
# aws ec2 stop-instances --instance-id INSTANCE_ID
# az vm deallocate --name NAME --resource-group RESOURCE_GROUP
"""
The script is the easy part, installing it into the unfriendly(imo) cron system and
@pv8
pv8 / fix-venv.sh
Last active September 1, 2022 03:33
Fix virtualenv symlinks after upgrading python with Homebrew and running brew cleanup
#!/usr/bin/env bash
#
# Fix virtualenv symlinks after upgrading python with Homebrew and then running
# `cleanup`.
#
# After upgrading Python using Homebrew and then running `brew cleanup` one can
# get this message while trying to run python:
# dyld: Library not loaded: @executable_path/../.Python
# Referenced from: /Users/pablo/.venv/my-app/bin/python
# Reason: image not found
def debug_pickle(instance):
"""
:return: Which attribute from this object can't be pickled?
"""
attribute = None
for k, v in instance.__dict__.iteritems():
try:
cPickle.dumps(v)
except:
@fish2000
fish2000 / venv-fixer.sh
Created November 13, 2013 11:20
Fix virtualenvs that are broken after Homebrew upgrade of python
#!/usr/bin/env bash
#set -x
ORIG_PREFIX_FILE="lib/python2.7/orig-prefix.txt"
ORIG_PREFIX=$(cat ${ORIG_PREFIX_FILE})
OLD_VERSION=$(echo $ORIG_PREFIX | awk -F/ '{ print $6 }')
PY_VERSION=$(/usr/local/bin/python -c 'import sys; print sys.version.split(" ")[0]')
NEW_PREFIX=$(echo $ORIG_PREFIX | sed "s#${OLD_VERSION}#${PY_VERSION}#g")
echo "ORIG PREFIX: ${ORIG_PREFIX}"
@kogakure
kogakure / .gitignore
Last active November 10, 2025 10:58
Git: .gitignore file for LaTeX projects
*.acn
*.acr
*.alg
*.aux
*.bak
*.bbl
*.bcf
*.blg
*.brf
*.bst