Skip to content

Instantly share code, notes, and snippets.

View andreagrandi's full-sized avatar
🏠
Working from home... permanently!

Andrea Grandi andreagrandi

🏠
Working from home... permanently!
View GitHub Profile
@andreagrandi
andreagrandi / git-add-worktree.sh
Created July 13, 2025 12:58
Script to create a git worktree and link existing virtualenv and .envrc files
#!/bin/bash
set -e
# Usage: ./git-add-worktree.sh <base-branch> <new-branch-name>
BASE_BRANCH="$1"
NEW_BRANCH="$2"
WORKTREE_PATH="../my-project-worktrees/$NEW_BRANCH"
# Create the worktree and new branch from base
git worktree add -b "$NEW_BRANCH" "$WORKTREE_PATH" "$BASE_BRANCH"
@andreagrandi
andreagrandi / settings.json
Created July 12, 2025 14:14
Claude Code notifications hooks
...
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title \"🔔 Claude Code\" -message \"Claude needs your input\""
}
from fastapi import HTTPException
from fastapi.responses import JSONResponse
from cadwyn import Cadwyn, HeadVersion, Version, VersionBundle, VersionedAPIRouter
from fastapi.testclient import TestClient
GENERIC_ERROR_CODE = "generic_error"
class CustomHTTPException(HTTPException):
error_code: str | None = None
from fastapi import FastAPI, HTTPException
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
GENERIC_ERROR_CODE = "generic_error"
class CustomHTTPException(HTTPException):
error_code: str | None = None
def __init__(self, detail: str, error_code: str = None):
@andreagrandi
andreagrandi / python-compatibility.py
Created October 8, 2024 15:38
Check Python requirements compatibility
import os
import re
import requests
import argparse
def extract_package_names(file_content):
"""Extract package names from the requirements file content."""
package_names = []
# Regular expression to match package names (excluding the version part)
@andreagrandi
andreagrandi / indie_blogs.md
Last active January 7, 2025 04:54
My curated list of indie blogs

My curated list of indie blogs I follow.

This is a curated list of indie blogs I follow. The majority of them are tech related, but not all of them are 100% technical. I've built this list from scratch, often discovering these blogs from links/articles posted on Mastodon.

If you want to suggest me a new blog to follow, you can leave a comment below (spammers will be blocked and reported).

IF I decide to follow the suggested blog, I will take care of adding it to this list.

@andreagrandi
andreagrandi / curated_list.md
Last active July 10, 2024 11:30
This is a test
#!/bin/bash
# This script is necessary to remove the annotations block from each Markdown file.
# These annotations are being written by iA Writer and are not necessary for the website.
# Define the directory to start searching from. Adjust this to your specific folder.
START_DIR="content"
# Process each Markdown file in the specified directory and its subfolders.
find "$START_DIR" -type f -name "*.md" | while read -r file; do
echo "Processing: $file"
@andreagrandi
andreagrandi / pelican2hugo.py
Last active May 16, 2025 15:02
Python script to migrate posts from Pelican to Hugo
# Migration script from Pelican to Hugo
import os, re, shutil
from pathlib import Path
INPUT_FOLDER = "content"
OUTPUT_FOLDER = "content-hugo"
# Custom sort key function
def sort_key(path):
# Extract the base filename without the extension
@andreagrandi
andreagrandi / .zshrc
Last active December 10, 2021 10:02
Configuration for .bashrc/.zshrc for pyenv and pyenv-virtualenv
# Install dependencies first:
# brew install pyenv
# brew install pyenv-virtualenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"