Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Created August 5, 2013 17:39
Show Gist options
  • Save tbnorth/6157834 to your computer and use it in GitHub Desktop.
Save tbnorth/6157834 to your computer and use it in GitHub Desktop.
Randomize letters and digits in a Leo (http://leoeditor.com/) subtree, best installed as a @button node.
# WARNING - no undo
# randomize letters and digits in a subtree to allow sensitive
# information to be used in examples of Leo usage (http://leoeditor.com/)
from random import sample
from string import lowercase, uppercase, digits
def blur(s):
s = [sample(lowercase, 1)[0] if i in lowercase else
sample(uppercase, 1)[0] if i in uppercase else
sample(digits, 1)[0] if i in digits else i for i in s]
return ''.join(s)
for nd in p.self_and_subtree():
nd.h = blur(nd.h)
nd.b = blur(nd.b)
c.redraw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment