Skip to content

Instantly share code, notes, and snippets.

View Pebaz's full-sized avatar
🐝
Typing Rapidly

Samuel Wilder Pebaz

🐝
Typing Rapidly
View GitHub Profile
"""
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.
"""
"""
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:
@Pebaz
Pebaz / check_setup_method.py
Created February 12, 2020 20:30
Python: Know whether package is being installed via Pip or an archive is being built (sdist, bdist, bdist_wheel)
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)
@Pebaz
Pebaz / json_to_pyobj.py
Created April 12, 2019 15:08
Turn JSON into Python Object
"""
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))