Skip to content

Instantly share code, notes, and snippets.

View bulletinmybeard's full-sized avatar
🤘

Robin Schulz bulletinmybeard

🤘
View GitHub Profile
@bulletinmybeard
bulletinmybeard / nginx_lua_logging.md
Last active April 11, 2024 01:06
Lua logging module for NGINX

This Lua logging module facilitates colorized log messages to visually distinguish between different log levels such as DEBUG, INFO, WARN, ERR, and CRIT. It integrates with NGINX through the ngx.log method to log directly to NGINX's error log and a custom lua log file at appropriate levels, in addition to writing to specified log files (default: /var/log/lua/default.log). It supports conditional logging based on a maximum log level setting and can serialize table messages to JSON format. It is suitable for both development and production environments, with recommendations to adjust log levels appropriately.

Prerequisites

lua-cjson (>= 2.1.0.10-1) -> https://luarocks.org/modules/openresty/lua-cjson

Lua Module (lua_logging.lua)

local cjson = require "cjson.safe"
@bulletinmybeard
bulletinmybeard / auto-test-and-reload-nginx-configuration.md
Last active April 9, 2024 18:49
Detect NGINX configuration changes, test them, and reload NGINX automatically

This bash script monitors directories and files for changes, runs nginx -t to test the configuration, and reloads NGINX by executing nginx -s reload. All actions are being logged in /var/log/monitor.log and /var/log/monitor-errors.log.

Prerequisites

inotify-tools -> https://github.com/inotify-tools/inotify-tools

The Script

#!/bin/bash
@bulletinmybeard
bulletinmybeard / youtube-likes-dislikes-export.md
Created March 18, 2024 08:29
Export your YouTube liked and disliked videos (.csv)

Create a bash script with the code below as export-yt-liked-and-disliked-videos.sh, give it execution rights with chmod +x export-yt-liked-and-disliked-videos.sh, and run it with your Google access token like so:

./export-yt-liked-and-disliked-videos.sh ya29.a0Ad52N39hmTcEjI1QoL...

The Bash Script

#!/bin/bash
@bulletinmybeard
bulletinmybeard / selfservice.officient.io-my-team-filter-button.md
Last active March 18, 2024 04:56
Extend the team calendar on "selfservice.officient.io" with a button to filter by YOUR TEAM

This browser userscript will programmatically add a button to the team calendar at "selfservice.officient.io", allowing you to filter the list of employees to only your team under .../daysOff/coworkers => week-calendar. Simply add the names of your team members to TEAM_CONTACTS and you good.

Before

image

After

image
@bulletinmybeard
bulletinmybeard / chill-institute-update-button-auto-clicker.md
Created March 9, 2024 22:50
Chill Institute - Update Button Auto Clicker (Browser Userscript)
// ==UserScript==
// @name         Chill Institute - Update Button Auto Clicker
// @namespace    https://rschu.me/
// @homepage     https://rschu.me/
// @version      1.0.0
// @encoding     utf-8
// @description  Chill Institute - Update Button Auto Clicker
// @author       Robin Schulz
// @match        *://chill.institute/*
@bulletinmybeard
bulletinmybeard / poetry-tooling.md
Last active March 12, 2024 19:57
Zsh function to extend the `poetry` command

Extend the poetry command...

function poetry() {
    function ensure_virtual_environment() {
        local venv_path=".venv"

        if [[ ! -d $venv_path ]]; then
            echo -e "Virtual environment not found."
            python3 -m venv $venv_path            
@bulletinmybeard
bulletinmybeard / zsh-shell-env-tooling.md
Last active March 6, 2024 09:30
Zsh Shell Functions to `export` and `unset` all variables from environment files in the current shell session

Zsh Shell Functions to export and unset all variables from env files located in the active working directory from which the commands are being executed.

Usage

Copy the two functions into your ~/.zshrc, ~/.bashrc, etc. and run source ~/.zshrc etc. to refresh your shell configuration, use source ~/.zshrc, etc.

You can now call set-env to export all variables from the given filename (e.g., set-env .env) and unset-env (e.g., unset-env .env) to unset the environment variables.

set-env() {
    if [[ -f $1 ]]; then
@bulletinmybeard
bulletinmybeard / obsidian-plugin-sync-script.md
Last active February 28, 2024 18:04
Bash script to sync local Obsidian Plugin files and directories (Tested on macOS!)

https://github.com/bulletinmybeard/obsidian-plugin-dev-sync

Overview

This Bash script helps synchronize local Obsidian plugins. It leverages rsync for the transfer, including the ability to handle deletions, and fswatch to monitor the files and directories for changes.

The script will synchronize all Obsidian-related and mandatory main.js and manifest.json files required for the plugin to be enabled and executed in both Obsidian's native and mobile versions (iCloud!).

Prerequisites

  • Ensure that rsync and fswatch are installed on your system.
@bulletinmybeard
bulletinmybeard / custom-zsh-prompt.md
Last active February 24, 2024 11:58
Customize Oh My Zsh (zsh-syntax-highlighting) prompt
@bulletinmybeard
bulletinmybeard / terminate-unresponsive-macos-apps-using-a-terminal-command.md
Created February 2, 2024 10:21
Terminate unresponsive macOS apps using a terminal command

To terminate unresponsive apps, open your terminal and execute the command pkill -x followed by the app's name (e.g., pkill -x Alfred).