Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / moomin.vcl
Created July 2, 2020 11:40 — forked from katef/cloud.vcl
HTTP Moomin delivery
sub deliver_moomin {
set resp.http.x-moomin0 = "⠀⠀⠀⠀⠀⠀⠀⢠⢦⡀⠀⡰⣩⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀";
set resp.http.x-moomin1 = "⠀⠀⠀⠀⠀⠀⠀⠘⣄⠙⠍⠁⠙⠦⡀⠀⠀⠀⠀⠀⠀⠀⠀";
set resp.http.x-moomin2 = "⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠀⡠⠄⠔⠊⠉⠒⠒⠒⢄⠀⠀⠀";
set resp.http.x-moomin3 = "⠀⠀⠀⠀⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⠆⠀⠀";
set resp.http.x-moomin4 = "⠀⠀⢠⢤⠜⡆⠀⢸⠀⠰⣄⠀⠀⠀⠀⠀⠀⠀⣠⠎⠀⠀⠀";
set resp.http.x-moomin5 = "⠀⠀⠱⠤⡁⠈⠑⠇⠀⠀⠀⠉⠒⠤⠤⠄⢖⠊⠀⡐⠧⣄⣀";
set resp.http.x-moomin6 = "⠀⠀⠀⠀⠘⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡉⠀⣀⣨⡷";
set resp.http.x-moomin7 = "⠀⠀⠀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢱⠜⠁ ";
set resp.http.x-moomin8 = "⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣸⠱⡀⠀";
@eksiscloud
eksiscloud / cheshire_cat.vcl
Last active July 2, 2020 17:55
Varnish: custom header a la cheshire cat (ascii art)
sub headers_x {
## Add after vcl 4.1;
## include "/etc/varnish/ext/cheshire_cat.vcl";
##
## Add after sub vcl_deliver {
## call header_smiley;
sub header_smiley {
set resp.http.xa = "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀.'\⠀⠀⠀/`.";
set resp.http.xb = "⠀⠀⠀⠀⠀⠀⠀⠀⠀.'.-.`-'.-.`.";
set resp.http.xc = "⠀⠀⠀⠀..._:⠀⠀⠀.-.⠀.-.⠀⠀⠀:_...";
<?php
# Check: https://onexa.nl/wordpress/toolbar-link-redis-object-cache/
/**
* Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
*
* @author Hiranthi Herlaar, onexa.nl
*
* @var $wp_admin_bar > https://codex.wordpress.org/Class_Reference/WP_Admin_Bar
@eksiscloud
eksiscloud / bash_background.vbs
Created July 17, 2020 21:18 — forked from leonelsr/bash_background.vbs
Run bash (Windows Subsystem for Linux) in background, in order to keep background processes running in WSL
' Windows Devs said on the developer feedback asking for cron, deamons and background tasks:
' "This first release of Bash/WSL doesn’t support background tasks, cron jobs, daemons, etc.
' Currently, when you close your last bash shell console window, we tear-down the Linux process
' chain in order to conserve resources."
'
' That's the workaround for now.
' You can run it on boot, for example, and it'll keep a instance of bash running alone in the background
' allowing background processes to run on WSL.
Set WshShell = CreateObject("WScript.Shell")
@eksiscloud
eksiscloud / cachewarmer.sh
Created May 22, 2021 07:43
Cache Warmer using sitemap
#!/bin/bash
# CACHE WARMER script for XML Sitemaps with MULTIPLE SUB-SITEMAPS:
# from: https://gist.github.com/JPustkuchen/f185bee60c5a36211cdf6f1c8f6deebe
# chmod u+x
DOMAIN='https://www.xyz.com'
wget -q $DOMAIN/sitemap.xml --no-cache -O - | egrep -o "$DOMAIN[^<]+" | while read subsite;
do
echo --- Reading sub-sitemap: $subsite: ---
wget -q $subsite --no-cache -O - | egrep -o "$DOMAIN[^<]+" | while read line;
do
@eksiscloud
eksiscloud / mastodon-update.sh
Last active March 22, 2025 06:30 — forked from Mixaill/mastodon-update.sh
Semi-automatic Mastodon updater for nightly build
#!/usr/bin/env bash
#
# Mastodon update script
# v3 (2024.02.18)
# forked
#
# Changelog
# * v1 - initial version
# * v2 - added mastodon-bird-ui
@eksiscloud
eksiscloud / x-cache.vcl
Created May 7, 2025 21:04
Varnish hit/miss/pass counter
sub vcl_recv {
unset req.http.x-cache;
}
sub vcl_hit {
set req.http.x-cache = "hit";
if (obj.ttl <= 0s && obj.grace > 0s) {
set req.http.x-cache = "hit graced";
}
}
@eksiscloud
eksiscloud / setup_varnish_tmpfs.sh
Created June 7, 2025 15:25
Varnish is more faster when working directory is in tmpfs. And 7.6 started nagging if not.
#!/bin/bash
# Varnish working directory location in tmpfs
TMPFS_DIR="/dev/shm/varnish"
echo "Creating directory: $TMPFS_DIR"
mkdir -p "$TMPFS_DIR"
chown -R varnish:varnish "$TMPFS_DIR"
# Path to override.conf
@eksiscloud
eksiscloud / error_reporter.py
Created June 11, 2025 12:22
Flask-script to send notification to Discourse when error 502/503 happens
## Comments are in Finnish, sorry
#--- Rate-limiter muistiin ---
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
ALLOWED_ERROR_CODES = [502, 503, 504]
last_reported = {} # esim. {503: datetime_object}
RATE_LIMIT_HOURS = 4
@eksiscloud
eksiscloud / cache-warmer.py
Created June 18, 2025 05:32
Cache Warmer using Matomo API
#!/usr/bin/env python3
import requests
import subprocess
import tempfile
import datetime
import sys
import time
MATOMO_API_URL = "https://matomo/index.php"
TOKEN = "<long-api-key" # give right token