Init - bitreich-bitmasquerade - Unnamed repository; edit this file 'description' to name the repository. DIR Log DIR Files DIR Refs --- DIR commit e3df6f27882c93a0cddb71401e7a3141dd9a56c9 HTML Author: Scarlett McAllister <no+reply@roygbyte.com> Date: Thu, 21 Dec 2023 22:00:01 -0400 Init Diffstat: A atellier.dcgi | 129 +++++++++++++++++++++++++++++++ A index.gph | 27 +++++++++++++++++++++++++++ A step_1.txt | 8 ++++++++ A step_2.txt | 5 +++++ A step_complete.txt | 7 +++++++ 5 files changed, 176 insertions(+), 0 deletions(-) --- DIR diff --git a/atellier.dcgi b/atellier.dcgi @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# coding=utf-8 + +from functools import reduce +import re +import sys + +geomyidae_host = "localhost" +geomyidae_port = "70" +bitmask_selection = [ '010101010101', '110001100011', '001110011100', + '101010101010', '100000100001', '011111111110', + '000010010000', '100010001001', '010010001000', + '100110001110', '111111101111', '011000100010'] +bitwise_selection = ['Flip', 'Set', 'Clear'] +bitwise_operations = {'Flip' : lambda a, b: a ^ b, + 'Set' : lambda a, b: a | b, + 'Clear' : lambda a, b: a & b} + +def string_to_binary(s, bits): + return ''.join([format(ord(c), '0{}b'.format(bits)) for c in s]) + +def strip_char_to_ascii_range(s, start, end): + range = [format(ord(a), 'x') for a in [start, end]] + patt = r'[^\x{}-\x{}]+'.format(*range) + return re.sub(patt, '', s) + +def strip_to_max_len(s): + return s[:16] + +def print_nick_fail(): + print("Pardon, but I'll need your name") + +def print_step_1_template(nick): + gph_menu_link = lambda s: \ + '[1|{}|/atellier.dcgi?{} {}|{}|{}]'.format(s, nick, s, + geomyidae_host, geomyidae_port) + gph_links = '\n'.join(map(gph_menu_link, bitmask_selection)) + with open('step_1.txt', 'r') as file: + print(file.read().format(nick, gph_links)) + +def print_step_2_template(nick, bitmask): + gph_menu_link = lambda s: \ + '[1|{}|/atellier.dcgi?{} {} {}|{}|{}]'.format(s, nick, bitmask, s, + geomyidae_host, geomyidae_port) + gph_links = '\n'.join(map(gph_menu_link, bitwise_selection)) + with open('step_2.txt', 'r') as file: + print(file.read().format(nick, gph_links)) + +def print_completion(nick, bitmask, bitwise, mask): + with open('step_complete.txt', 'r') as file: + print(file.read().format(nick, bitmask, bitwise, mask)) + +def make_mask(nick, bitmask, bitwise): + bits = len(nick) + binary_nick = string_to_binary(nick, bits) + # print(binary_nick) + def bit_picker(remaining, accm=""): + if len(accm) == 0: + # Recursion entry point: accumulate first element of + # the list. + return bit_picker(remaining[1:], remaining[0:1]) + if remaining == "": + # Recursion exit point: return the accumulated elements. + return accm + # Main loop: return the current element that corresponds + # with the current multiple of the remaining chars + multiple = int(len(remaining)/bits) + if (len(remaining) % bits) == multiple: + accm = accm + remaining[0:1] + # print(remaining) + return bit_picker(remaining[1:], accm) + return bit_picker(remaining[1:], accm) + selected_bits = bit_picker(binary_nick) + bitmask = bitmask[:len(selected_bits)] + bin_1 = int(selected_bits, 2) + bin_2 = int(bitmask, 2) + return bin(bitwise_operations[bitwise](bin_2, bin_1))\ + [2:].zfill(len(selected_bits)) + +def print_args_fail(): + print("Pardon, but something's not working.") + +def print_bitmask_fail(): + print("Pardon, but that bitmask isn't available.") + +def main(args): + geomyidae_search = args[1] + geomyidae_args = args[2].split(' ') # tab splitting + if geomyidae_search: + # Get the search result, which will be this + # person's nick, and ask them to pick a bitmask from + # the list printed out in the step 1 template. + nick = strip_char_to_ascii_range(geomyidae_search, '!', '~') + nick = strip_to_max_len(nick) + if nick != '': + print_step_1_template(nick) + else: + print_nick_fail() + sys.exit() + # Validate and clear up the input from the bitmask + # selection. + if len(geomyidae_args) < 2: + print_args_fail() + sys.exit() + nick = strip_char_to_ascii_range(geomyidae_args[0], '!', '~') + nick = strip_to_max_len(nick) + bitmask = geomyidae_args[1] + if nick == '': + print_nick_fail() + sys.exit() + if bitmask not in bitmask_selection: + print_bitmask_fail() + sys.exit() + if len(geomyidae_args) == 2: + # Get the prson to choose their bitwise operation. + print_step_2_template(nick, bitmask) + else: # + bitwise = geomyidae_args[2] + if bitwise not in bitwise_selection: + print_bitmask_fail() + sys.exit() + # Finish up by making combining the nick, bitmask, + # and bitwise operation. + mask = make_mask(nick, bitmask, bitwise) + print_completion(nick, bitmask[:len(nick)], bitwise, mask) + sys.exit() + +if __name__ == "__main__": + sys.exit(main(sys.argv)) DIR diff --git a/index.gph b/index.gph @@ -0,0 +1,27 @@ + +- - | + | ,'*.,_,.*', - - . + | "O. .O" | | | + + `''\_/''` - - + + rgb | + + YOU ARE INVITED + to Bitreich's FIRST ANNUAL + NEW YEARS EVE BITMASQEURADE! + + JOIN US on #bitreich-en IRC + at 12CET. COME DISGUISED behind + your BITMASK and leave everyone + wondering WHO YOU REALLY ARE! + +Don't have a BITMASK? DON'T WORRY! + Bitreich's FINEST ATTELLIER + will make you your very own + BEDAZZELED BITMASK! + + Simply tell her your NICK, + choose your MASK, and pick + to SET, CLEAR, or FLIP your + way into the NEW YEAR! + +[7| Your nick, sir?|/atellier.dcgi?|localhost|70] DIR diff --git a/step_1.txt b/step_1.txt @@ -0,0 +1,8 @@ + +Pleasure to meet you, {}. I have a +nice selection of materials available. +Please pick something you like below +and then I'll get it custom fitted +just for you. + +{} DIR diff --git a/step_2.txt b/step_2.txt @@ -0,0 +1,5 @@ +Great pick, {}. Now: do you feel more like +setting, clearing, or flipping into +the new year? + +{} DIR diff --git a/step_complete.txt b/step_complete.txt @@ -0,0 +1,7 @@ + +Alright, {}! I've got your mask ready for you. +As you wish, i used that lovely pattern you +picked out ({}) and gave it a nice {} to +suit your nick. Hope you enjoy the masqurade! + +Your mask: {}