steal jess's hex scripts

This commit is contained in:
lickthecheese 2020-09-27 15:57:01 -04:00
parent af55c83e9d
commit 8e7667cd80
3 changed files with 34 additions and 1 deletions

2
.vimrc
View file

@ -11,7 +11,7 @@ command Tmd :r ~/Documents/templates/md.html
" run groff+refer on file
:command Groff !sh -c 'p="%"; refer -PS -e -p ~/Documents/bib ${p::-4}.mom | groff -mom -Tpdf > ${p::-4}.pdf'
:command Grofft !sh -c 'p="%"; refer -PS -e -p ~/Documents/bib ${p::-4}.mom | groff -mom -T ascii > ${p::-4}.txt'
:command Grofft !sh -c 'p="%"; refer -PS -e -p ~/Documents/bib ${p::-4}.mom | groff -mom -T ascii | sed -b "s/\x1b[^m]*m//g" > ${p::-4}.txt'
:command Man !sh -c 'p="%"; groff -man -T ascii ${p::-4}.man > ${p::-4}.txt'
:command Md !p="%"; cmark --unsafe ${p::-3}.md | h2p - ${p::-3}.pdf

15
bin/hexch Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import argparse
def _hexip(ip: str):
parts = [int(p) for p in ip.split(".")]
return ''.join("{:02x}".format(p) for p in parts)
if __name__ == "__main__":
parser = argparse.ArgumentParser("webchat IP hexlify")
parser.add_argument("ip")
args = parser.parse_args()
print(_hexip(args.ip))

18
bin/unhexch Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import argparse
def _hexip(s: str):
ip = []
for i in range(0, len(args.hex), 2):
octet = int(args.hex[i:i+2], 16)
ip.append(str(octet))
return ".".join(ip)
if __name__ == "__main__":
parser = argparse.ArgumentParser("webchat IP dehexlify")
parser.add_argument("hex")
args = parser.parse_args()
print(_hexip(args.hex))