Skip to content

Instantly share code, notes, and snippets.

View TutorialDoctor's full-sized avatar

RaphaelSmith TutorialDoctor

View GitHub Profile
@jsbain
jsbain / editor_buttons.py
Created January 1, 2018 15:42
editor_buttons.py
import sys,os
# if you place objc_hacks in site packages, this line is not needed
sys.path.append(os.path.expanduser('~/Documents'))
from objc_hacks import apphack
#alternatively, just place apphack.py in site_packages, and import apphack
#little workaround to persistent button locations. needs fixing in apphack
if hasattr(apphack,'__persistent_views'):
__builtins__.__persistent_views=apphack.__persistent_views
@benhoyt
benhoyt / markov.py
Created November 11, 2023 15:45
Generate text from an input using a simple Markov chain generator
import collections, random, sys, textwrap
# Build possibles table indexed by pair of prefix words (w1, w2)
w1 = w2 = ''
possibles = collections.defaultdict(list)
for line in sys.stdin:
for word in line.split():
possibles[w1, w2].append(word)
w1, w2 = w2, word