Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / generate_audio_article.py
Created June 21, 2025 20:50
AI creates MP3 where it reads WordPress article
#!/usr/bin/env python3
import os
import re
import sys
import json
import httpx
import tempfile
import configparser
from langdetect import detect
@eksiscloud
eksiscloud / generate-snapshot.py
Created June 22, 2025 19:48
Creates copy of wanted sites for emergencies
#!/bin/bash
# Nicknames, urls and snapshot directories
case "$1" in
example)
DOMAIN="www.example.com"
TARGET_DIR="/var/www/emergency/example"
;;
try)
DOMAIN="try.example.tld"
@eksiscloud
eksiscloud / wordpress_add_xkey_header.php
Last active June 23, 2025 13:43
Adds X-Cache-Keys header to Wordpress posts, uses few xkey-tags
// Add Xkey-based X-Cache-Tags headers
add_action('send_headers', function () {
if (is_admin() || is_user_logged_in()) {
return;
}
$tags = [];
// Frontpage
if (is_front_page()) {
@eksiscloud
eksiscloud / wordpress_auto_purge.php
Last active June 23, 2025 13:45
Sends a request to Varnish for bans after a WordPress post is edited and re-published
// Use snippets plugin or functions.php
// Adds xkey tags: frontpage, sidebar (right), article-ID, category and tag
// Remember to change url
add_action('save_post', function ($post_id) {
// Don't do anything is this isn't an article or is autosaving
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (get_post_type($post_id) !== 'post') return;
$tags = [];
@eksiscloud
eksiscloud / varnish_manual_purge.sh
Created June 23, 2025 13:49
Makes manually purge in Varnish using xkeys, can used with several hosts
#!/bin/bash
# chmod +x purge.sh
# DEFAULT
DEFAULT_DOMAIN="1.example.tld"
# MANUAL
function usage() {
echo "Use:"