Skip to content

Instantly share code, notes, and snippets.

View benoit-dubreuil's full-sized avatar

Benoît Dubreuil benoit-dubreuil

View GitHub Profile
@benoit-dubreuil
benoit-dubreuil / auto-dos2unix.sh
Last active August 3, 2022 19:03
Converts CRLF to LF line endings
#!/usr/bin/env bash
# This script must be executed in a directory which belongs to a Git repository.
git ls-files '**.sh' | xargs dos2unix
git ls-files '**.py' | xargs dos2unix
git ls-files '**.pyc' | xargs dos2unix
git ls-files '**.python-version' | xargs dos2unix
git ls-files '**.c' | xargs dos2unix
git ls-files '**.h' | xargs dos2unix
@benoit-dubreuil
benoit-dubreuil / remove-lfs.sh
Last active July 25, 2022 21:45
Remove Git LFS from repo
#!/usr/bin/env bash
# See https://stackoverflow.com/a/35064134/2924010
# TODO : Rewrite history
# You must `cd` in your local repository beforehand.
LFS_FILES_EXTENSIONS="""*.7z
*.br
*.gz
@benoit-dubreuil
benoit-dubreuil / dub-fetch-latest-dev-tools.sh
Last active August 31, 2021 20:18
dub fetch / update the latest development tools
#!/usr/bin/env sh
# Use the DMD compiler in order to get the latest features.
# https://github.com/dlang-community/dfmt
dub fetch dfmt --cache=user && dub build dfmt --build=release --compiler=dmd --cache=user
# https://github.com/dlang-community/dfix
dub fetch dfix --cache=user && dub build dfix --build=release --compiler=dmd --cache=user
@benoit-dubreuil
benoit-dubreuil / main_utils.py
Last active March 14, 2021 20:50
Python3 Function to Detect if the Caller Is the Main Source
import inspect
from types import FrameType
from typing import cast
def is_caller_main() -> bool:
# See https://stackoverflow.com/a/57712700/
caller_frame = cast(FrameType, cast(FrameType, inspect.currentframe()).f_back)
caller_script_name = caller_frame.f_locals['__name__']
@benoit-dubreuil
benoit-dubreuil / add-or-remove-git-bash-from-explorer.md
Last active November 25, 2020 22:17
Manually Add or Remove Git-Bash From Scoop in the Right-Click "Open With Git Bash" Context Menu on Windows 10

Manually Add or Remove Git-Bash From Scoop in the Right-Click "Open With Git Bash" Context Menu on Windows 10

add-git-bash-to-explorer.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\git_bash]
@="Open with Git Ba&sh"
"Icon"="\"%%HOMEDRIVE%%%%HOMEPATH%%\\scoop\\apps\\git-with-openssh\\current\\git-bash.exe\",0"