Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Code...

Shane R. Spencer whardier

🎯
Code...
View GitHub Profile
View monkey_inflection.py
#!/usr/bin/env python3.8
import sys
from collections import Counter
import inflect
root = sys.modules[__name__]
inflector = inflect.engine()
View monkeys_love_dynamic_code.py
#!/usr/bin/env python3.8
import sys
from collections import Counter
root = sys.modules[__name__]
events = [
{"monkey": "Sam", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "flinging", "kind": "grass" },
View monkeys_love_bananas.py
#!/usr/bin/env python3.8
from collections import Counter
events = [
{"monkey": "Sam", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "flinging", "kind": "grass" },
{"monkey": "Sam", "state": "flinging", "kind": "grass" },
{"monkey": "Sam", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "hungry", "kind": "banana" },
View monkey_what_ifs.py
#!/usr/bin/env python3.8
events = [
{"monkey": "Sam", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "flinging", "kind": "grass" },
{"monkey": "Sam", "state": "flinging", "kind": "grass" },
{"monkey": "Sam", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "hungry", "kind": "banana" },
{"monkey": "Chet", "state": "flinging", "kind": "feces" },
{"monkey": "Sam", "state": "flinging", "kind": "grass" },
View loop.py
import time
counter = 0
def something():
global counter
counter += 1
print(time.time(), counter)
while True:
View check_contents.py
import time
import json
import pathlib
configurable_path = pathlib.Path('/tmp/configurable.json')
configurable = {}
counter = 0
View check_mtime.py
import time
import json
import pathlib
configurable_mtime = 0
configurable_path = pathlib.Path('/tmp/configurable.json')
configurable = {}
counter = 0
View gist:7e3623b2d340b7abe7bfd46ec41a511a
>>> from enum import Flag, auto
>>> class Thing(Flag):
... left = auto()
... right = auto()
... middle = left | right
...
>>> Thing.middle
<Thing.middle: 3>
>>> Thing(3)
<Thing.middle: 3>
View traceback.txt
2020-03-30 19:24:42,318 [salt.minion :1057][CRITICAL][1010] Unexpected error while connecting to salt
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/minion.py", line 1036, in _connect_minion
yield minion.connect_master(failed=failed)
File "/usr/lib/python3/dist-packages/salt/ext/tornado/gen.py", line 1056, in run
value = future.result()
File "/usr/lib/python3/dist-packages/salt/ext/tornado/concurrent.py", line 239, in result
raise_exc_info(self._exc_info)
File "<string>", line 4, in raise_exc_info
File "/usr/lib/python3/dist-packages/salt/ext/tornado/gen.py", line 1064, in run