Skip to content

Instantly share code, notes, and snippets.

View SomajitDey's full-sized avatar

Somajit SomajitDey

View GitHub Profile
@SomajitDey
SomajitDey / WSL2-Windows_port-forward.md
Last active July 1, 2024 15:11
How to forward WSL2 port to Windows port and vice versa
@4wk-
4wk- / README.md
Last active July 1, 2024 21:55
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
@SomajitDey
SomajitDey / git-todo.bash
Last active September 26, 2021 15:51
TODO list for any git branch. Read file header for installation and usage.
#!/usr/bin/env bash
# Brief: TODO list specific to git branches. No effect on commits, staged or worktree
# Installation:
# chmod +x ./git-todo
# sudo mv ./git-todo /usr/local/bin
# git config --global alias.todo '!git-todo'
# Help: git todo -h
# Author: Somajit Dey <dey.somajit@gmail.com> 2021 [https://github.com/SomajitDey]
# Source: https://gist.github.com/SomajitDey
# GitHubGist Search Terms: username:SomajitDey filename:git-todo.bash
@SomajitDey
SomajitDey / relayed-low-power-ipfs-config.json
Last active September 26, 2021 15:51
Replace peer-id in `Addresses.Announce` and `Identity`. To connect manually to this peer, do `ipfs swarm connect ${Addresses.Announce[]}` for all 3 relays until connection succeeds.
{
"API": {
"HTTPHeaders": {}
},
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Announce": [
"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y/p2p-circuit/p2p/12D3KooWDZBXcHq6t4XFqRFN9pk8nW3VsUmXnvPGV9uL29aeUZmd",
"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei/p2p-circuit/p2p/12D3KooWDZBXcHq6t4XFqRFN9pk8nW3VsUmXnvPGV9uL29aeUZmd",
"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh/p2p-circuit/p2p/12D3KooWDZBXcHq6t4XFqRFN9pk8nW3VsUmXnvPGV9uL29aeUZmd"
@SomajitDey
SomajitDey / passgen.bash
Last active September 26, 2021 16:01
Generate strong password of any given width from any given text or master password
#!/usr/bin/env bash
# Creates strong password of any given width from any given text or master password
# Usage: echo <a line of text> | [SALT=<salt>] ./passgen [-p] [<width>]
# Option: -p generates PIN instead of password
# Default: width=8; SALT=somesalt
# Author: Somajit Dey <dey.somajit@gmail.com>
# License: GNU GPLv2
set -o noglob
@SomajitDey
SomajitDey / pow.bash
Created May 18, 2021 21:06
Basic PoW with deterministic output
#!/usr/bin/env bash
# Brief: Basic Proof-of-Work (PoW) with deterministic output for input string passed as parameter.
# Usage: ./pow <text>
# Ctrl+'\' (SIGQUIT) to check current nonce anytime
# Output: Nonce and 00* SHA256-Hash
#===================================================
hash_of(){
sha256sum <(echo "${1}") | awk '{print $1}'