2019-09-10

GIT - How to remove history for already deleted files

# Mirror the repository and get inside its directory
cd ~/Documents/mirrored_repository_name_here.git

# Display the biggest files, which might help figure out what to remove
git ls-tree -r -t -l --full-name HEAD | sort -n -k 4 | tail -n 10

# Get outside of the folder
cd ..

# Run BFG (in the desktop in this example) to delta files of a certain extension 
java -jar ~/Desktop/bfg.jar --delete-files *.zip  --no-blob-protection mirrored_repository_name_here.git

# Run BFG to delete folders
java -jar ~/Desktop/bfg.jar --delete-folders data  --no-blob-protection mirrored_repository_name_here.git

# Remove those files
git reflog expire --expire=now --all && git gc --prune=now --aggressive

# Check on the size of the repository
git count-objects -v

# Push it

git push --force



2019-09-08

Python - Get string in between two other sub-strings

import re
s = 'STRING_PART_1This is the text you will getSTRING_PART_2'
result = re.search('STRING_PART_1(.*)STRING_PART_2', s)
print result.group(1)

MongoDB - Shutdown from the command line

mongo --eval "db.getSiblingDB('admin').shutdownServer()"