Useful for accessing a computer that does not have a public IP address, over the internet. The machine can be behind multiple firewalls and NATs.
# First run the following 2 lines in your interactive bash attached to a controlling terminal | |
export bashpidfile="/tmp/bashpid" # File that stores the bash pid | |
export PROMPT_COMMAND='echo $$ > $bashpidfile' # Or, replace $$ with $BASHPID | |
# From another terminal do the following | |
### TPGID gives fg proc group on the tty the process is connected to, or -1 if the process is not connected to a tty | |
fgpg=$(ps --pid $(awk NR==1 $bashpidfile) -o tpgid=) | |
# Send signal SIG to all foreground processes to emulate user Ctrl- inputs | |
# Ctrl-C: INT, Ctrl-Z: TSTP, Ctrl-\: QUIT |
### Source me | |
readline_cword(){ | |
# Gives current word of Bash readline, viz. the word where the insertion point/cursor is currently at | |
set -- ${READLINE_LINE} | |
local length=${#1} | |
while ((length < READLINE_POINT)); do | |
shift | |
length+=${#1} | |
done | |
echo -n "${1}" |
-
Sign-up (email is not verified!)
-
./ngrok authtoken
Push based workflow is more efficient than repeated pulls (polling). Thankfully, there is currently a free service for the same which is easy to use : https://streambin.pbedat.de/. There is also emitter.io and free, public MQTT brokers such as broker.hivemq.com (list).
-
Create a unique channel-key - it may be the hash of your email id or the hash of your MAC address, or may even be the fingerprint of freshly generated private-public keypair.
-
url="https://streambin.pbedat.de/streams/${channel_key}"
while num=$(read -re -p "type: "|& tee /dev/tty|fold -w "$(tput cols)"|wc -l); do tput cuu $num;tput ed; done |
Updating a Gist or file using API is much faster (almost 3 times) than git-push
Git-push takes a lot of work figuring out what files need to be pushed. The local copy also needs to query upstream about its current state before it can decide whether a pull is necessary before push.
A local commit, on the other hand, takes almost no work compared to git-push.
Because Gist / file update using the REST API is nothing but a file-ransfer over https + a local commit@upstream, it is supposed to be faster than git-push.
port=<port> # Choose your local port that your server will listen to
file=<filename> # Choose file where <subdomain.localhost.run> will be stored
# Create tunnel in background
ssh -n -R 80:localhost:$port [email protected] -- --output json --no-inject-http-proxy-headers --no-inject-proxy-protocol-header 2>/dev/null | jq --unbuffered -r '.address' > ${file} &
key=<random but unique key> # Such as the hash of your email id!
########### Server:
mkfifo pipe
bash --rcfile <(echo 'PS0="$(tput cuu1; tput ed)"') -i <pipe |&
curl -sf -N -T . https://pipeto.me/${key} >pipe
chroot
#### Jail :> Confine a command's access within given root directoryrunuser
#### Run command as another user. Comparesu
stdbuf
[-oL] command #### Line buffering in outputrlwrap
[-cr -aPassword: -p -S -P -o] command #### GNU Readline + History + TAB-Autocompletion + Colored prompt + Password hidingfold
#### Pretty line wrappingwrap
#### Pretty line wrappingpr
### Paginate text file - prettifymore
less
tty
### Print the file name of the terminal connected to standard input