Skip to content

Instantly share code, notes, and snippets.

View SomajitDey's full-sized avatar

Somajit SomajitDey

View GitHub Profile
@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}'
@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 <[email protected]>
# License: GNU GPLv2
set -o noglob
@SomajitDey
SomajitDey / IPFS-NAT-traversal-using-ngrok.md
Last active January 12, 2023 04:02
Hosting IPFS node with ngrok

Hosting IPFS from behind NAT/Firewall using a free reverse proxy (ngrok)

  1. Expose localhost's port 4001 to public internet using ngrok: ngrok tcp 4001. Tip: Use -region= flag for lower latency.
  2. Note the hostname and port returned by ngrok in the form: tcp://hostname:port -> localhost:4001
  3. Open the ipfs config json file ~/.ipfs/config
  4. Edit as follows: Addresses.Announce=["/dns4/put-the-hostname-here/tcp/put-the-port-here"]
  5. Save the config file
  6. ipfs daemon
@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 / 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 <[email protected]> 2021 [https://github.com/SomajitDey]
# Source: https://gist.github.com/SomajitDey
# GitHubGist Search Terms: username:SomajitDey filename:git-todo.bash
@SomajitDey
SomajitDey / gist:ea96825c32dbcbf08c968eb2724b1fcd
Created July 4, 2021 13:50 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@SomajitDey
SomajitDey / sshd_wsl2.md
Created July 5, 2021 18:56
Making SSH server work in WSL2
@SomajitDey
SomajitDey / mindisafe
Last active September 26, 2021 15:50
Minimal Digital Safe (for dummies). Download the file, then make it executable: chmod +x ./mindisafe
#/usr/bin/env bash
# Brief: Minimal Digital Safe (MinDiSafe)
# Usage: mindisafe <path>
trap 'eval ${reset}' exit
keygen(){
echo -n "Safe: Enter Mother's maiden name (case-insensitive): "
read -r salt || return 1
echo -n "Safe: Enter your passkey now: "
@SomajitDey
SomajitDey / linstall
Last active September 26, 2021 15:50
Install files locally. Download and install: chmod +x linstall; ./linstall linstall
#!/usr/bin/env bash
# Brief: Install locally without sudo
# Usage: install [file-path or download-link]
file="${@}"
[[ -n "${file}" ]] || read -rep'Drag-n-drop file or put download link here: ' file
file="${file/#\"/}" ; file="${file/%\"/}" # Quote (") removal, if any
if [[ "${file}" =~ ^http[s]?://.*$ ]];then
tmp=$(mktemp -d .linstallXXXXX); trap "rm -rf ${tmp}" exit
@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