Last active
March 26, 2025 10:46
-
-
Save matchaxnb/e1b3e899f0fbe9a3264089f2181cea37 to your computer and use it in GitHub Desktop.
A set of utilities for drones of all kinds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
zero = '⬡' | |
one = '⬢' | |
dronemap = { | |
'0': zero, | |
'1': one, | |
} | |
dronemap_rev = { | |
zero: '0', | |
one: '1', | |
} | |
printed = False | |
c = 0 | |
r = '' | |
data = ''.join(dronemap_rev[a] for a in sys.stdin.read(-1) if a in dronemap_rev) | |
rem = len(data) % 8 | |
if rem != 0: | |
print("truncated signal... recovering.") | |
data = data[0:len(data) - rem] | |
assert len(data) % 8 == 0 | |
bts = len(data) // 8 | |
s = '' | |
for bit in range(bts): | |
part = data[bit * 8:bit * 8 + 8] | |
assert len(part) == 8 | |
n = chr(int(part, 2)) | |
s += n | |
print(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
zero = '⬡' | |
one = '⬢' | |
dronemap = { | |
'0': zero, | |
'1': one, | |
} | |
printed = False | |
c = 0 | |
r = '' | |
while c is not None: | |
c = None | |
try: | |
c = sys.stdin.read(1) | |
except EOFError: | |
break | |
if c is None or len(c) == 0: | |
break | |
printed = False | |
b = bin(ord(c))[2:].zfill(8) | |
d = ''.join(dronemap[a] for a in b) | |
d = f'{d[:4]} {d[4:]} ' | |
r = f'{r}{d}' | |
if c == '\n': | |
r += '\n' | |
print(r) | |
r = '' | |
printed = True | |
if not printed: | |
print(r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
timeout 3600s watch -t -n 1 "date +'%H%M%S' | python hexspeak.py" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment