Skip to content

Instantly share code, notes, and snippets.

View SomajitDey's full-sized avatar

Somajit SomajitDey

View GitHub Profile
@SomajitDey
SomajitDey / Heroku How-To Host Bash or anything for free.md
Created May 3, 2021 10:43
How to host anything on heroku.com in their free-tier 550 hrs/month. Web-apps mostly sleep so very low consumption.

Heroku Bash How-to

Heroku offers PaaS with a generous free-tier of 550 hours/month without requiring any credit-card validation. Official support is for Node.js, Python, Go, Ruby etc. But what if you just need to run a bash script, may be a netcat based server? Or you simply need to serve a webpage over http or https, and all you know is bash? (Of course you can also use the free services of x10hosting.com for the latter.)

Here are some simple steps to deploy a bash-script at Heroku.

  1. Open a Heroku account
  2. Download the Heroku CLI
  3. git init the directory that contains your bash script
  4. heroku login
@SomajitDey
SomajitDey / UUID-GUID.bash
Last active September 26, 2021 16:08
Bash script to generate 128-bit Universally/Globally Unique Identifiers in GNU/Linux
#!/usr/bin/env bash
# Description: A simple way to generate 128-bit Universally/Globally Unique Identifiers in GNU/Linux
# Usage: ./UUID-GUID.bash ["Any text you wanna put in"]
# Remark: Perhaps the use of so many variables is overkill, but Hey! It's fun ;-)
# Author: Somajit Dey <[email protected]> 2021
user_element="${1}" # Passed by the user as parameter (optional)
device_element="$(cat /sys/class/net/eth0/address)" # MAC address
@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 / 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 / sshd_wsl2.md
Created July 5, 2021 18:56
Making SSH server work in WSL2
@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 / 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 / .gitattributes
Created October 1, 2021 12:14
Convert any IPFS / Libp2p CID to Base36
base36 linguist-language=bash