Skip to content

Instantly share code, notes, and snippets.

View Groverkss's full-sized avatar
🐣

Kunwar Grover Groverkss

🐣
View GitHub Profile
@Groverkss
Groverkss / cas.sh
Created December 11, 2020 14:30
Scripting CAS login on IIIT sites
#!/bin/bash
# Usage: cas-get.sh {url} {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST="$1"
ENCODED_DEST=`echo "$DEST" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg' | sed 's/%2E/./g' | sed 's/%0A//g'`
#IP Addresses or hostnames are fine here
CAS_HOSTNAME="login.iiit.ac.in"
@Groverkss
Groverkss / parse_net.py
Created December 23, 2020 08:38
Parser for network data
#!/bin/python3
import re
from pprint import pprint
# Parameters
in_file = "nw-metrics"
out_file = "nw-parsed"
delimiters = '["\n ]'
@Groverkss
Groverkss / connect_vpn.sh
Last active October 19, 2021 11:05
Script to connect to openvpn server
#!/bin/bash
# Change file names here
PRIMARY=primary.ovpn
BACKUP=backup.ovpn
# Trap signal handler
trap_end() {
sudo rm .tmp-pass
exit
@Groverkss
Groverkss / kill_ssh.sh
Last active October 19, 2021 11:41
Kill all ssh user sessions other than the current one
#!/bin/bash
# Credit: https://unix.stackexchange.com/a/397914/469786
# https://askubuntu.com/questions/902998/how-to-check-which-tty-im-currently-using
#
# This command is useful when ssh connection drops and the ssh sessions still presist.
function kssh {
allshs=$(w | tail -n+3 | awk '{print $2}')
curshs=$(who am i | head -n1 | awk '{print $2}')

How to write MLA as MHA

Terminology:

@ := Matrix Multiplication

Example: A @ B = matmul(A, B)

.T := Transpose