Skip to content

Instantly share code, notes, and snippets.

@marckohlbrugge
Created March 10, 2018 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marckohlbrugge/12d9187489d0d859307c5b2cba160f3b to your computer and use it in GitHub Desktop.
Save marckohlbrugge/12d9187489d0d859307c5b2cba160f3b to your computer and use it in GitHub Desktop.
for pietz
text = %{This validates there's a lot of attention and real business to be made targeting the nomad and remote work space. Even if nomads have previously had an image of low-income. There's money here.}
def garble(input, intro: 0)
length = input.length
output = []
for position in 0...length
percentage = (position / length.to_f)
output << if percentage < intro ||
percentage < rand ||
input[position].chr !~ /\w+/
input[position].chr
else
('a'..'z').to_a[rand(26)]
end
end
output.join
end
# p garble(text, intro: 0.20)
def shuffler(input)
output = []
words = input.split(" ")
words.each do |word|
letters = word.scan(/\w/)
first = letters.shift
last = letters.pop || ""
output << first + letters.shuffle.join + last
end
output.join(" ")
end
p shuffler(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment