Skip to content

Instantly share code, notes, and snippets.

View Belphemur's full-sized avatar

Antoine Aflalo Belphemur

View GitHub Profile
#!/usr/bin/env fish
# =============================================================================
# setup-zswap.fish
# Disables zram and switches to zswap on CachyOS (Limine + LUKS btrfs)
# - Backs up files before changes
# - Verifies each step
# - Rolls back everything on failure
# =============================================================================
# ── Configuration ─────────────────────────────────────────────────────────────
@Belphemur
Belphemur / night_light.yaml
Last active February 5, 2026 15:25
Night Light Home Assistant
blueprint:
name: "Third Reality Light - Occupancy, Lux & Color Control"
description: |
**Occupancy and Light Level Automation for Third Reality Lights with Color Control**
This blueprint automatically controls a Third Reality light based on:
- **Occupancy detection**: Light turns on when motion/occupancy is detected
- **Light level**: Only turns on when ambient light is below the threshold
- **Color selection**: Choose your preferred color via color picker
- **Timeout**: Turns off after a configurable period of no occupancy
@Belphemur
Belphemur / sandbox-winget.ps1
Last active January 29, 2026 02:14
Use Windows Sandboxing to be able to install your WinGet manifest. Source: https://megamorf.gitlab.io/2020/07/19/automating-the-windows-sandbox/
# Parse Arguments
Param(
[Parameter(Mandatory, HelpMessage = "The path for the Manifest.")]
[String] $Manifest
)
if (-not (Test-Path -Path $Manifest -PathType Leaf)) {
throw 'The Manifest file does not exist.'
}
@Belphemur
Belphemur / DefaultKeyBinding.dict
Created September 2, 2022 19:28
DefaultKeyBinding.dict for MacOS to work like windows for Home/End and CTRL+Arrow functions
//source: https://damieng.com/blog/2015/04/24/make-home-end-keys-behave-like-windows-on-mac-os-x/
//Move DefaultKeyBinding.dict in your ~/Library/KeyBindings folder
//Log out log back in
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
@Belphemur
Belphemur / heating_cable.yaml
Last active December 6, 2025 18:01
Home Assistant: Automatically controls roof heating cables based on temperature and weather conditions.
blueprint:
name: "Smart Roof Heating - Restart-Proof Duty Cycle"
description: |
Redesigned heating cable controller with complete restart recovery.
Automatically detects and recovers duty cycle state after Home Assistant restart.
**Restart Recovery Features:**
• Detects if duty cycle was active before restart
• Automatically restarts timer with appropriate duration
• Maintains cable state consistency
blueprint:
name: Button Light Control with Brightness Stepping
description: |
Control lights with a button that supports single press (toggle), double press (scene),
and brightness stepping (hold up/down). Perfect for buttons that emit brightness_step
events with direction attributes.
**Features:**
- Single press: Toggle light on/off
- Double press: Set warm scene (50% brightness, 2700K)
@Belphemur
Belphemur / circadian_light.yaml
Last active October 31, 2025 20:35
Circadian Light Home Assistant
blueprint:
name: "Circadian Motion Lighting - Smart Motion Logic"
description: >
**Version: 2.5.6 - Smart Motion Logic**
Motion/Occupancy/Presence-activated lighting with **smart conditional logic** and complete light therapy.
**NEW in 2.5.6: Smart Motion Detection**
@Belphemur
Belphemur / transmission-ssl
Last active April 16, 2025 05:05
Configuration to use nginx as reverse proxy for Transmission BT with SSL/HTTP2 protected with auth
upstream transmission {
server 127.0.0.1:9091; #Transmission
}
server {
listen 443 ssl http2;
server_name example.com;
auth_basic "Server Restricted";
auth_basic_user_file /var/www/myWebSite/web/.htpasswd;
# Path to the root of your installation
# This script work on any system using systemd as the init process.
# It works on Debian/Raspbian Jessie.
# If you have Debian/Rapbian Wheezy and want to use this script with systemd
# follow the information here : https://wiki.debian.org/systemd
# To easily download, install and set at startup:
# wget -O /tmp/download https://gist.github.com/Belphemur/3f6d3bf211b0e8a18d93/download && sudo tar -zxf /tmp/download --strip-components 1 -C /etc/systemd/system/ && sudo systemctl --reload-daemon && sudo systemctl enable Node-RED
# To consult the log : journalctl -u Node-RED
[Unit]
@Belphemur
Belphemur / converter.php
Created June 14, 2017 18:13
Salesforce ID 15 chars to 18 chars converter PHP
<?php
function to18char(string $inputId) {
$suffix = '';
for ($i = 0; $i < 3; $i++) {
$flags = 0;
for ($j = 0; $j < 5; $j++) {
$start = $i * 5 + $j;
$end = ($i * 5 + $j + 1) - $start;
$c = substr($inputId, $start, $end);
if (ctype_upper($c) && $c >= 'A' && $c <= 'Z') {