Skip to content

Instantly share code, notes, and snippets.

View gitaarik's full-sized avatar

Rik gitaarik

View GitHub Profile
@gitaarik
gitaarik / +server.js
Last active July 5, 2025 12:17
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,
@gitaarik
gitaarik / restore_floating_clients.lua
Last active January 21, 2025 00:32
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")
#!/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 / 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.
@gitaarik
gitaarik / fzf_preview_include
Last active October 16, 2022 22:09
fzf_preview_include - include normally ignored paths in fzf-preview
#!/usr/bin/zsh
#
# fzf_preview_include - include normally ignored paths in fzf-preview
#
# Dependencies: zsh and ripgrep
#
# This command enables you to include extra dirs and files in fzf-preview, that
# would normally be ignored by git or ripgrep. This can be handy for when you
# use another git repository inside a parent one, or if you regularly edit
# files that are ignored by git / ripgrep.

Keybase proof

I hereby claim:

  • I am gitaarik on github.
  • I am gitaarik (https://keybase.io/gitaarik) on keybase.
  • I have a public key ASAVXM6EJFVl6_nSDIWUPR5hg3oEnXWPhmWWGgRQo6xYZQo

To claim this, I am signing this object:

@gitaarik
gitaarik / npmbin.sh
Created March 1, 2016 11:58
Alias to add the `node_modules/.bin/` directory to `$PATH` variable so that you can use executables from node modules.
alias npmbin='echo -e "Setting up npmbin with path:\n$(npm bin)"; export PATH=$(npm bin):$PATH'
@gitaarik
gitaarik / gitprompt.sh
Last active October 1, 2016 00:34
native gitprompt
gitprompt() {
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWSTASHSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=true
export PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
. /usr/lib/git-core/git-sh-prompt
@gitaarik
gitaarik / git_submodules.md
Last active August 5, 2025 20:51
Git Submodules basic explanation

Git Submodules - Basic Explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@gitaarik
gitaarik / git_cheat_sheet.md
Last active December 10, 2021 16:35
Git cheatsheet

Git cheatsheet

Checkout remote branch:
git checkout -t remote_name/remote_branch_name
Delete a branch at the origin:
git push origin --delete <branchName>
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy