Skip to content

Instantly share code, notes, and snippets.

View oclero's full-sized avatar

Olivier Cléro oclero

View GitHub Profile
@oclero
oclero / macos_python_venv.sh
Created January 7, 2025 11:02
MacOS Python Virtual Environment
python3 -m venv .venv
source .venv/bin/activate
@oclero
oclero / make_bitset.cpp
Created November 22, 2024 14:38
Create a std::bitset from an initializer_list<bool>
// NB: The first value in the list is the smallest bit (a.k.a "little endian").
template<int Size>
constexpr auto make_bitset(const std::initializer_list<bool> &boolean_list) {
auto bits = 0ul;
auto mask = 1ul;
for (auto boolean : boolean_list) {
bits |= boolean ? mask : 0ul;
mask <<= 1;
}
return std::bitset<Size>{bits};
@oclero
oclero / windows_python_venv.ps
Created October 12, 2024 18:06
Windows Python Virtual Environment
python3 -m venv .venv
.\venv\Scripts\activate.bat
@oclero
oclero / waterwark_pdf.py
Created May 7, 2024 17:18
Add watermark to a PDF file with Python
import os
import sys
import getopt
import glob
import os.path
import fnmatch
from os import listdir
from os.path import isfile, join
from PyPDF2 import PdfFileReader, PdfFileWriter
@oclero
oclero / zip-macos.sh
Created February 7, 2024 21:44
MacOS - Create a ZIP archive without .DS_Store and __MACOSX files
zip -r output.zip path/to/input_folder -x ".DS_Store" -x "__MACOSX"
@oclero
oclero / remove-git-branch.sh
Created November 12, 2023 18:33
Remove a Git branch, local and/or remote
# Remove a remote branch.
git push <remote> --delete <branch>
# Remove a local branch.
git branch --delete <branch>
git branch --delete --force <branch>
# Remove a local tracking branch.
git branch --delete --remotes <remote>/<branch>
git fetch <remote> --prune
@oclero
oclero / push-to-https-repo.sh
Last active March 29, 2024 20:10
Push to Git repository with https on Gitlab/Github
# Gitlab
git push https://gitlab-ci-token:<YOUR_TOKEN>@gitlab.com/<GROUP_NAME>/<REPO_NAME>.git <BRANCH_NAME> [--force]
# Github
git push https://<USERNAME>:<YOUR_TOKEN>@github.com/<USERNAME>/<REPO_NAME> <BRANCH_NAME> [--force]
@oclero
oclero / jpegoptim-recursive.sh
Created October 23, 2023 10:43
Run jpegoptim recursively
find . \( -iname \*.jpg -or -iname \*.jpeg \) -print0 | xargs -P 4 -n 1 -0 jpegoptim
@oclero
oclero / prettier-config-vscode.md
Last active October 1, 2023 10:50
Prettier configuration for VS Code and Hugo

Standard Way

  1. At the root of the repository, create a .prettierrc file:

    {
      "plugins": ["prettier-plugin-go-template"],
      "overrides": [
        {
          "files": ["*.html"],
@oclero
oclero / get-commits-from-other-remote.sh
Created September 7, 2023 17:11
Get commits from another Git remote
git fetch other-remote
git merge other-remote/some-branch