dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit 47a8d6c31a134c45cd76a8e80b6c8a94a35b8169
parent 8a271e653d3fb6484535a682b335eb18ed0e00af
Author: Paco Esteban <paco@onna.be>
Date:   Sat, 23 Jun 2018 19:38:37 +0200

naming ...

Diffstat:
bin/bin | 32--------------------------------
bin/hex_print | 32++++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/bin/bin b/bin/bin @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import fileinput -import sys - -line = "" - -# nasty trick to either take stdin or param 1 -if len(sys.argv) < 2: - for l in fileinput.input(): - line += l -else: - line = sys.argv[1] - -chunk_size = 16 - -# split line in chunks of 16 bytes -for i in range(0, len(line), chunk_size): - chunk = line[i:i + chunk_size] - # transform to list, as strings are inmutable in python - chunk_list = list(chunk) - # iterate and substitute any non-printable char - for i, c in enumerate(chunk_list): - if ord(c) < 0x20 or ord(c) > 0x7e: - chunk_list[i] = '¤' - # back to string - chunk_filtered = ''.join(chunk_list) - # clever way to transform the original string to hex bytes - chunk_hex = " ".join("{:02x}".format(ord(c)) for c in chunk) - # print it all, similar to hexdump output - print("{:47} {}".format(chunk_hex, chunk_filtered)) diff --git a/bin/hex_print b/bin/hex_print @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import fileinput +import sys + +line = "" + +# nasty trick to either take stdin or param 1 +if len(sys.argv) < 2: + for l in fileinput.input(): + line += l +else: + line = sys.argv[1] + +chunk_size = 16 + +# split line in chunks of 16 bytes +for i in range(0, len(line), chunk_size): + chunk = line[i:i + chunk_size] + # transform to list, as strings are inmutable in python + chunk_list = list(chunk) + # iterate and substitute any non-printable char + for i, c in enumerate(chunk_list): + if ord(c) < 0x20 or ord(c) > 0x7e: + chunk_list[i] = '¤' + # back to string + chunk_filtered = ''.join(chunk_list) + # clever way to transform the original string to hex bytes + chunk_hex = " ".join("{:02x}".format(ord(c)) for c in chunk) + # print it all, similar to hexdump output + print("{:47} {}".format(chunk_hex, chunk_filtered))