Skip to content

Instantly share code, notes, and snippets.

from collections.abc import Sequence
from typing import Protocol, Sequence, TypedDict, TypeVar, cast
class LiteralProtocol(Protocol):
__args__: Sequence[str]
class TypedDictProtocol(Protocol):
__annotations__: dict[str, LiteralProtocol]
@Tatsh
Tatsh / oktaverify2totp.md
Created July 9, 2024 09:34 — forked from kamilhism/oktaverify2totp.md
Get TOTP secret key for Okta Verify
  1. Get the content of the QR for Okta Verify app setup. It looks like this: oktaverify://[email protected]/?t=XXXXX&f=YYYYY&s=https://DOMAIN.okta.com&issuer=DOMAIN.okta.com&isIdxEnabled=true
  2. Replace XXXXX, YYYYY and DOMAIN to your values in curl below:
curl --request POST \
  --url https://DOMAIN.okta.com/idp/authenticators \
  --header 'Accept: application/json; charset=UTF-8' \
  --header 'Accept-Encoding: gzip, deflate' \
  --header 'Authorization: OTDT XXXXX' \
  --header 'Content-Type: application/json; charset=UTF-8' \
@Tatsh
Tatsh / proxy.py
Created April 3, 2024 22:47 — forked from brianglass/proxy.py
Django Channels Websocket Proxy
import asyncio
import logging
import websockets
from channels.exceptions import DenyConnection
from channels.generic.websocket import AsyncWebsocketConsumer
from django.utils.functional import cached_property
logger = logging.getLogger(__name__)
@Tatsh
Tatsh / merge-dependabot-prs.sh
Last active October 25, 2023 11:24
merge-dependabot-prs
#!/usr/bin/env bash
get-repos() {
gh repo list --limit 9999 --jq '.[].nameWithOwner' --json nameWithOwner --no-archived &&
while IFS=$'\n' read -r org; do
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/orgs/${org}/repos" --jq '.[].full_name'
done < <(gh org list)
from struct import pack
from typing import Literal
def make_font_entry(
field: Literal['CaptionFont', 'IconFont', 'MenuFont', 'MessageFont',
'SmCaptionFont', 'StatusFont'],
name: str,
*,
char_set: Literal[0, 1, 2, 0x4d, 0x80, 0x81, 0x82, 0x86, 0x88, 0xa1,
import itertools
args = ('-march=rocketlake -mabm --param=l1-cache-line-size=64 '
'--param=l1-cache-size=48 --param=l2-cache-size=16384').split(' ')
def mabm(o: str):
if o.startswith('-mabm'):
return 'maz'
return o.replace('-', '')
@Tatsh
Tatsh / README.md
Last active February 10, 2023 04:47

NOTE: Requires a backup of your old Chrome configuration directory.

The intent of this script is to save time by not having to reconfigure your extensions when you sign in with a clean Chrome config, and to transfer general things like cookies so you do not have to sign into everything again. This also copies flags you have enabled in chrome://flags.

After deleting your old configuration from the normal location (e.g. ~/.config/google-chrome-beta), open Chrome and sign in. Do this for every profile as necessary. You need to determine which profile directory ('Default' or 'Profile X') belongs to whom in both the old config and the new. Then you can use this script.

Example usages:

./reconstruct-chrome-profile.sh ./old-chrome-config-backup Default Default
@Tatsh
Tatsh / Full Bass + Treble.json
Created August 4, 2022 10:57
Full Bass + Treble based on Clementine's preset
{
"output": {
"blocklist": [],
"equalizer": {
"bypass": false,
"input-gain": 0.0,
"left": {
"band0": {
"frequency": 60.0,
"gain": 4.2,
@Tatsh
Tatsh / step1.sh
Last active May 24, 2022 02:49
Dual boot with secure boot enabled. Install app-crypt/efitools
#!/usr/bin/env bash
set -e
rm -fR ~/keystuff/{esl,key,crt,auth,der}
mkdir -p ~/keystuff/{esl,key,crt,auth,der}
cd ~/keystuff
for i in PK KEK db dbx; do
efi-readvar -v "$i" -o "esl/old_${i}.esl"
done
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$(hostname) platform key/" -keyout key/PK.key -out crt/PK.crt -days 36500 -nodes -sha256
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$(hostname) key-exchange-key/" -keyout key/KEK.key -out crt/KEK.crt -days 36500 -nodes -sha256
@echo off
diskpart /s make-partitions.txt
dism /Apply-Image /ImageFile:E:\sources\install.wim /Index:1 /ApplyDir:W:\
bcdboot W:\Windows /s S: /f UEFI