This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! prefetch.js v1.0.1 - Speed up webpage loading by prefetching links hovered upon. | |
(c) Romein van Buren - 2024 - MIT license */ | |
document.addEventListener('DOMContentLoaded', () => { | |
for (const link of document.querySelectorAll('a:not([data-noprefetch])')) { | |
const url = new URL(link.href, 'https://'+window.location.hostname); | |
if (url.hostname !== window.location.hostname || | |
window.location.pathname === url.pathname) continue; | |
const callback = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import json | |
import re | |
from django.conf import settings | |
from django.contrib.admindocs.views import simplify_regex | |
from django.core.exceptions import ViewDoesNotExist | |
from django.core.management.base import BaseCommand, CommandError | |
from django.utils import translation | |
from django.urls import URLPattern, URLResolver # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const server = 'https://tile.openstreetmap.org'; | |
const lon = 4.76114 * Math.PI / 180; | |
const lat = 51.57947 * Math.PI / 180; | |
const z = 18; | |
const n = 2**z; | |
// docs: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Zero-downtime deployment script for Docker Compose and Nginx (+ Django) | |
# Inspired by https://www.tines.com/blog/simple-zero-downtime-deploys-with-nginx-and-docker-compose | |
# | |
# (c) Romein van Buren 2024 | |
# SPDX-License-Identifier: WTFPL | |
# | |
reload_nginx() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
gzip on; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; | |
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/java> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find all 777 files: | |
sudo find / -type d -perm 777 | |
# Find all world-writable files: | |
sudo find / -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print | |
# Find all files without owner: | |
sudo find / -xdev \( -nouser -o -nogroup \) -print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update apt repositories | |
sudo apt update -y | |
sudo apt upgrade -y | |
# Install nginx & PHP | |
sudo apt install -y nginx php8.2 | |
sudo apt-get install -y php8.2-{fpm,cgi,mysql,curl,xsl,gd,common,xml,zip,xsl,soap,bcmath,mbstring,gettext,imagick,sqlite3,intl} | |
sudo nano /etc/nginx/sites-available/default | |
# Add the following / update the file to contain it: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# This script keeps all Git repositories within a specified directory up to date. | |
# | |
# Consider the following example. The linux and curl repositories will be updated | |
# when you run this in the gitforks directory. | |
# | |
# gitforks/ | |
# linux/.git/ linux Git repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --shortstat --author "Romein van Buren" \ | |
| egrep "file[s] changed" \ | |
| sed 's/changed, \([0-9]\+ deletions\)/changed, 0 insertions(+), \1/g' \ | |
| awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed:", files, "- lines inserted:", inserted, "- lines deleted:", deleted}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { page } from '$app/stores'; | |
export let type = 'website'; // or article, or music.album etc. See https://ogp.me/#types | |
export let title = ''; | |
export let description = ''; | |
export let image = '/img/social/preview.jpg'; | |
export let path = $page.url.pathname; |
NewerOlder