Skip to content

Instantly share code, notes, and snippets.

@jmachadofreitas
jmachadofreitas / Makefile
Created July 29, 2025 12:59
Project Stats
.PHONY: all
all: lines files
.PHONY: files
files:
@echo "Number of files:"
@echo $$(find . -wholename './src/*.py' | wc -l)
.PHONY: lines
@jmachadofreitas
jmachadofreitas / .gitattributes
Last active July 29, 2025 12:22
Python .gitattributes
# Source files
# ============
* text=auto
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python
@jmachadofreitas
jmachadofreitas / DeleteGitSumodule.md
Last active July 29, 2025 12:17 — forked from myusuf3/delete_git_submodule.md
How to effectively delete a git submodule.

Remove submodule:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files rm -rf path_to_submodule
@jmachadofreitas
jmachadofreitas / textlive-full-beefless.md
Created July 13, 2023 15:24 — forked from shivams/textlive-full-beefless.md
`texlive-full` without the beef

TLDR;

On an Debian/Ubuntu-based system, to install texlive-full without docs and language packs, simply do this:

sudo apt install `sudo apt --assume-no install texlive-full | \
		awk '/The following additional packages will be installed/{f=1;next} /Suggested packages/{f=0} f' | \
		tr ' ' '\n' | grep -vP 'doc$' | grep -vP 'texlive-lang' | grep -vP 'latex-cjk' | tr '\n' ' '`

After this, if you wish to install the language packs, selectively install them. E.g.:

@jmachadofreitas
jmachadofreitas / heap.py
Last active July 3, 2019 17:11
Heap from "Stop Writing Classes" by Jack Diederich
class Heap(object):
def __init__(self, data=None, key=lambda x: None):
"""
Args:
key: scoring function
"""
self.heap = data or []
heapq.heapify(self.heap)
self.key = key