Skip to content

Instantly share code, notes, and snippets.

@Tobiaqs
Tobiaqs / heroicons.ts
Last active March 1, 2024 09:14
Heroicons lookup utility for Vue 3
// Needs "@heroicons/vue": "2.x"
import * as heroiconsSolid16 from '@heroicons/vue/16/solid'
import * as heroiconsSolid20 from '@heroicons/vue/20/solid'
import * as heroiconsOutline24 from '@heroicons/vue/24/outline'
import * as heroiconsSolid24 from '@heroicons/vue/24/solid'
function getHeroicon<T extends keyof typeof heroiconsSolid16>(size: 'solid16', name: keyof typeof heroiconsSolid16): (typeof heroiconsSolid16)[T]
function getHeroicon<T extends keyof typeof heroiconsSolid20>(size: 'solid20', name: keyof typeof heroiconsSolid20): (typeof heroiconsSolid20)[T]
function getHeroicon<T extends keyof typeof heroiconsSolid24>(size: 'solid24', name: keyof typeof heroiconsSolid24): (typeof heroiconsSolid24)[T]
@Tobiaqs
Tobiaqs / store.ts
Last active September 22, 2023 08:49
Vuex 4 store with fully typed mapState (supports modules and actions)
/// store.ts
import { InjectionKey } from 'vue'
import { createStore, mapState as baseMapState, Store, useStore as baseUseStore } from 'vuex'
const modules = {
appDataModule,
}
const state = {
settings: <Settings | null>null,
@Tobiaqs
Tobiaqs / gamma
Created May 27, 2022 08:26
Manual screen dimmer for xrandr with color temperature setting
#!/bin/bash
r=255
g=255
b=255
function apply () {
echo -n "Enter brightness [0, 1]: "
read brightness
while read display; do
@Tobiaqs
Tobiaqs / dhashes
Last active March 25, 2024 10:34
Version pinning for docker-compose
#!/usr/bin/env python3
import json
import os
import subprocess
import sys
import yaml
if len(sys.argv) <= 1:
@Tobiaqs
Tobiaqs / consumer.py
Last active March 17, 2022 11:19
Django-channels, deal with accept-language
def connect(self):
class dummy_request:
COOKIES = {}
META = {'HTTP_ACCEPT_LANGUAGE': dict(self.scope['headers']).get('accept-language'.encode('utf-8'), bytes()).decode('utf-8')}
translation.activate(translation.get_language_from_request(dummy_request))
@Tobiaqs
Tobiaqs / circular_serializers.py
Last active March 9, 2022 12:23
Solution for circular Serializer imports in larger Django projects
"""
DRF circular serializer import helper
"""
from rest_framework.serializers import ModelSerializer
from rest_framework.fields import Field
# Add more serializers here
RequestSerializer: ModelSerializer = None
OrderSerializer: ModelSerializer = None
@Tobiaqs
Tobiaqs / create_gif.sh
Last active July 19, 2021 15:30
Script for creating GIFs from files created by Pop_OS!'s screen recording functionality
#!/bin/bash
# Requirements:
# - ffmpeg
# - xdotool
MAX_W=720
read -p "Press a key to select top left corner of region"
topleft_x=$(xdotool getmouselocation | awk '{print $1}' | cut -d':' -f 2)
@Tobiaqs
Tobiaqs / build_nkit_linux.sh
Created March 6, 2021 09:24
Script that builds a working NKit on Linux-based systems using Docker
#!/bin/bash
# use @Ryan-Myers .NET Core 3.1 version of the project
git clone https://github.com/Ryan-Myers/NKit.git
# patch for fixing the recovery data finding issue
wget -O - https://gist.githubusercontent.com/Tobiaqs/b7c25136a713fe68de47f4ad76376c89/raw/fd33482226818fd99b84a0f2302895a898c2aab4/0001-Fix-recovery-data-finding-for-Ryan-Myers-NKit.patch 2>/dev/null | git -C NKit apply
# patch to remove windows apps from the solution
wget -O - https://gist.githubusercontent.com/Tobiaqs/d25daf70ac7455dc7c3cf01071002c03/raw/8d983568f5137ab39d4cab759f8ea519e8bcd33c/0002-Remove-Windows-apps-from-the-solution.patch 2>/dev/null | git -C NKit apply
# build using dotnet sdk 3.1 docker image
docker run --rm -v $PWD/NKit:/NKit -it mcr.microsoft.com/dotnet/sdk:3.1 bash -c 'cd /NKit; dotnet build'
From 8dbd31f10fdab5aee76ee81171da3855d5f0bfaa Mon Sep 17 00:00:00 2001
From: Tobias Sytsma <tobias@tobiass.nl>
Date: Sat, 6 Mar 2021 10:07:43 +0100
Subject: [PATCH] Remove Windows apps from the solution
---
NKit.sln | 4 ----
1 file changed, 4 deletions(-)
diff --git a/NKit.sln b/NKit.sln
@Tobiaqs
Tobiaqs / 0001-Fix-recovery-data-finding-for-Ryan-Myers-NKit.patch
Created March 6, 2021 09:01
Patch that fixes discovery of recovery partition data in Ryan-Myers/NKit
From ec683a95700d922d0f574abaefaaf5773c4d8425 Mon Sep 17 00:00:00 2001
From: Tobias Sytsma <tobias@tobiass.nl>
Date: Sat, 6 Mar 2021 09:59:09 +0100
Subject: [PATCH] Fix recovery data finding for Ryan-Myers/NKit
---
NKit/Settings/RecoveryData.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/NKit/Settings/RecoveryData.cs b/NKit/Settings/RecoveryData.cs