This file contains 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
""" | |
Samuel Wilder 9/29/2020 | |
Obfuscates a given piece of data (in this case a string) by hiding within an ML | |
model. | |
To get that data back out, a string matching the password must be passed in. | |
All other input returns garbled text. | |
""" |
This file contains 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
""" | |
Followed tutorial from: | |
https://keleshev.com/one-pass-compiler-primer | |
python .\calc_compiler.py 1 + 2; bat calc.s; zig cc -Wno-everything calc.s -o calc.exe; ./calc.exe; Write-Host $LASTEXITCODE | |
The Program: | |
1 + 2 + 3 * 4 | |
Will Be Compiled To: |
This file contains 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
import sys | |
def is_pip_installing(): | |
return '--python-tag' in sys.argv | |
def is_building_archive(): | |
archive_cmds = 'sdist', 'bdist', 'bdist_wheel' | |
return ( | |
not pip_installing() and | |
any(cmd in sys.argv for cmd in archive_cmds) |
This file contains 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
""" | |
Building a Python object from JSON isn't as straightforward as it looks. | |
SimpleNamespace only allows you to access fields that are valid variable | |
names. This poses a problem for JSON that contains invalid characters. | |
Here is my solution: | |
``` | |
# Doesn't work: | |
>>> data = json.loads(some_str, object_hook=lambda d: SimpleNamespace(**d)) |