Skip to content

Instantly share code, notes, and snippets.

@pcdavid
Created July 18, 2009 12:57
Show Gist options
  • Save pcdavid/149548 to your computer and use it in GitHub Desktop.
Save pcdavid/149548 to your computer and use it in GitHub Desktop.
scrmable.rb
#!/usr/bin/env ruby
class String
def scrmable
return self if not self =~ /\w/m
first, *letters = self.split(//)
last = letters.pop
if last
order = Hash.new
letters.each do |l|
begin
o = rand(2 * letters.length)
end while order.has_key?(o)
order[o] = l
end
letters = order.keys.sort.collect { |i| order[i] }
return first + letters.join + last
else
return first
end
end
end
ARGF.each do |line|
line.split(/([^[:alnum:]]*[\s[:punct:]]+)/).each do |word|
print word.scrmable
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment