Skip to content

Instantly share code, notes, and snippets.

@SomajitDey
SomajitDey / compression_cryptography_using_URL_shortener.md
Last active September 19, 2024 07:31
Any data can be compressed using URL shorteners. Two such compression can form a public-private key pair. Only one can lead to the other not the other way round.

Compression

  • take your minified JSON and turn it into a URL safe base64 string. The length of this string can be as big as this.
  • make a dummy url like http://dummy.tld/<the base64 string> and shorten it using any URL shortener.
  • save the unique path of the shortened url as your compressed data (henceforth called token). No need to store the domain of the shortened URL as the URL shortener would be hardcoded in your app.

Decompression

  1. Reconstruct the shortened URL from the token. Try to fetch (GET) the shortened URL.
  2. Parse the response for the redirect url and extract the base64 string.
  3. Decode the base64.
@SomajitDey
SomajitDey / static_site_howto.md
Last active September 20, 2024 14:47
Create and deploy static site for personal website or blog. Contains contact form, feeds and comment section.
@SomajitDey
SomajitDey / ANN_DL_deep_dive.md
Last active September 12, 2024 13:16
Transformers and Artificial Neural Networks/Deep Learning in AI/ML
@SomajitDey
SomajitDey / WSL2-Windows_port-forward.md
Last active July 24, 2024 11:44
How to forward WSL2 port to Windows port and vice versa
@4wk-
4wk- / README.md
Last active September 20, 2024 16:53
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

Background

I've been using wsl (version 2) with genie mod for years without issue, but one day, Windows 10 finally catch up on wsl Windows 11 features and gives us a way to use systemD natively.

I wanted to use the new "right way" to enable systemD on Windows Subsystem for Linux (without genie), and I also had a (probably related) infinite Windows RemoteApp error poping in.

Fixing it

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
@SomajitDey
SomajitDey / .gitattributes
Created October 1, 2021 12:14
Convert any IPFS / Libp2p CID to Base36
base36 linguist-language=bash
@SomajitDey
SomajitDey / urldecode
Last active September 7, 2021 15:10
url-encode and url-decode using bash and xxd
#!/usr/bin/env bash
# Ref: https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding
# Ref: https://github.com/sixarm/urldecode.sh
input="${@//+/ }"
echo -e "${input//%/\\x}"
@SomajitDey
SomajitDey / gpg_ecc-25519_keygen
Last active November 22, 2023 08:37
Create ECC (elliptic curve crypto) keys using curve 25519 with/for GPG
#!/usr/bin/env -S gpg --batch --expert --gen-key
# Brief: Generate ECC PGP keys for signing (primary key) & encryption (subkey)
# Run as: chmod +x gpg_ecc-25519_keygen; ./gpg_ecc-25519_keygen
# Ref: https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html
%echo "Generating ECC keys (sign & encr) with no-expiry"
%no-protection
Key-Type: EDDSA
Key-Curve: ed25519
Subkey-Type: ECDH
@SomajitDey
SomajitDey / sshd_wsl2.md
Created July 5, 2021 18:56
Making SSH server work in WSL2