Skip to content

Instantly share code, notes, and snippets.

View iAnanich's full-sized avatar

Illia Ananich iAnanich

  • Ukraine
View GitHub Profile
@iAnanich
iAnanich / gauth.py
Created October 22, 2020 07:11
Google's ID token verification module
"""
https://developers.google.com/identity/sign-in/android/backend-auth#verify-the-integrity-of-the-id-token
"""
import json
from typing import Optional, List
import yarl
from google.oauth2 import id_token
from google.auth.transport import requests as google_requests
@iAnanich
iAnanich / dataclass_from_dict.py
Created May 23, 2021 21:50 — forked from gatopeich/dataclass_from_dict.py
Python 3.7 dataclass to/from dict/json
from dataclasses import dataclass, fields as datafields
from ujson import dumps, loads
# Note: ujson seamlessly serializes dataclasses, unlike stdlib's json
@dataclass
class Point:
x: float
y: float
# Shallow dataclass can be rebuilt from dict/json:
@iAnanich
iAnanich / do.sh
Last active April 2, 2023 08:30
Shell script that helps to simplify Docker Compose usage
#!/bin/bash
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
### Generated with the help of ChatGPT ###
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
# Usage:
# ./do.sh dc ps
# ./do.sh dc down
# ./do.sh dc up -d service
@iAnanich
iAnanich / swarmpit_api.py
Created April 15, 2023 18:12
Simple SwarmPit API adapter example
from dataclasses import dataclass, field
from typing import Optional
from urllib.parse import urljoin
import httpx
@dataclass
class Swarmpit:
"""
@iAnanich
iAnanich / set-bash-history-time-format.sh
Last active June 15, 2023 09:19
Enable recording datetime in bash history
#!/bin/bash
# This bash script configures the bash history to include timestamps in a human-readable format.
# It first checks if the user's .bashrc file exists and contains the HISTTIMEFORMAT configuration.
# If the .bashrc file doesn't exist, it creates it and adds the HISTTIMEFORMAT configuration.
# If the .bashrc file exists but doesn't contain the HISTTIMEFORMAT configuration, it adds the configuration.
# It then applies the changes immediately by sourcing the .bashrc file.
# Define the time format for ease of modification and reuse
TIME_FORMAT="%y-%m-%d %T | "
@iAnanich
iAnanich / install-ubuntu-luks-lvm.md
Last active May 26, 2024 13:57 — forked from superjamie/install-ubuntu-luks-lvm.md
How to install Ubuntu with LUKS Encryption on LVM

How to install Ubuntu with LUKS Encryption on LVM

My work requires us to have full-disk encryption, so these are the steps I use.

The basic idea is to create a LUKS-encrypted partition which is used as an LVM Physical Volume.

The GRUB boot partition isn't encrypted, but everything else is.

These steps tested and working on 22.04 (jammy).