Skip to content

Instantly share code, notes, and snippets.

View gitaarik's full-sized avatar

Rik gitaarik

View GitHub Profile
@gitaarik
gitaarik / django_silk_check.py
Created October 16, 2022 17:20
Django system check for checking whether Silk is enabled
from django.conf import settings
from django.core.checks import Info, register
from django.urls import reverse
@register()
def django_silk(app_configs, **kwargs):
"""
Checks whether Django Silk is enabled in settings and shows a message if
it is.
#!/bin/bash
# Script that sends an alert email when any disk's used space is over a certain
# limit.
# The first parameter to this script is the min disk space usage percentage for
# when the alerts kicks in.
# The second parameter is the email address the alert message should be sent
# to.
#
# Can be configured in a crontab like this:
@gitaarik
gitaarik / restore_floating_clients.lua
Last active March 24, 2024 09:22
Awesome WM script that restores floating clients geometry (width / height / position) when switching layouts or unmaximizing
-- Restore last used floating client geometry (with / height / position) when
-- switching layouts and unmaximizing clients.
--
-- When unmaximizing a never-before floating client, it will nicely center the
-- client in the middle of the screen.
--
-- To use, just `require('restore_floating_clients')` in your `awesome/lua.rc`
-- Somewhere where you have your other signal callbacks.
local awful = require("awful")
@gitaarik
gitaarik / +server.js
Last active May 1, 2024 09:27
SvelteKit serve file from filesystem with ETag header for efficient client caching, useful for private static / uploaded files
import { isAuthenticatedForCookie } from "$lib/core/auth";
import { readAsset } from "$lib/helpers/read-asset";
/**
* @type {Object.<string, string>}
*/
const fileImports = import.meta.glob(
"$lib/files/**/**.{jpg,jpeg,png,gif,webp,avif,svg,pdf}",
{
eager: true,