Skip to content

Instantly share code, notes, and snippets.

@Dan-Q
Created November 2, 2016 21:28
Show Gist options
  • Save Dan-Q/09800edbd524633d656cd68c00fe19fb to your computer and use it in GitHub Desktop.
Save Dan-Q/09800edbd524633d656cd68c00fe19fb to your computer and use it in GitHub Desktop.
Ugly Ruby code to split a message into two messages with alternate words escaped.
msg = "Your message goes here."
[true, false].each{|x|puts msg.split(' ').map{|w|(x = !x) ? w : ('_'*w.length)}.join(' ')}
# Result:
# ____ message ____ here.
# Your _______ goes _____
@Dan-Q
Copy link
Author

Dan-Q commented Nov 2, 2016

Quickly thrown together in IRB when I wanted to send a long message to two people over Slack who claimed to be in the same place. Not perfect, certainly not secure, also damn ugly code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment