Skip to content

Instantly share code, notes, and snippets.

@Tobiaqs
Tobiaqs / tutorial.md
Last active January 15, 2020 12:34
Using Github/Bitbucket as an encrypted file backup service

Initial setup

This will get you a repository that automatically encrypts all files that you add to it and push.

  1. Get git and git-crypt and gpg
  2. Make sure you have a trusted private key in gpg
  3. Run git-crypt init in the root of your repo
  4. Run git-crypt add-gpg-user GPG_FINGERPRINT
  5. Create .gitattributes in the root of your repo
**/* filter=git-crypt diff=git-crypt
@Tobiaqs
Tobiaqs / install_woolbird_lite.sh
Last active June 12, 2020 23:39
Script that can transform a mint Raspberry Pi OS / Raspbian installation into a Bluetooth audio receiver
#!/bin/bash
# this script sets up a mint raspbian installation as follows:
# - all packages updated
# - my public ssh key is authorized
# - bluetooth audio relay through pulseaudio
# - hostname of the installation set to $NEW_HOSTNAME
#
# tested on Raspberry Pi OS on June 13, 2020
# note: you need to connect to your device with bluetoothctl, if you want the opposite to be possible, trust your device.
@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
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 / 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'
@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 / 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 / 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 / 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 / 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