Skip to content

Instantly share code, notes, and snippets.

@jhallard
Created June 1, 2017 20:34
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 jhallard/cc0d3a2d25ee9b354b89d67697630899 to your computer and use it in GitHub Desktop.
Save jhallard/cc0d3a2d25ee9b354b89d67697630899 to your computer and use it in GitHub Desktop.
A simple python script to "mockify" a series of words given either through sys.argv or stdin.
#!/usr/bin/env python
import sys
import os
import random
def mockify_word(word):
last_cap = False
letters = list(word)
for index in range(0, len(letters)):
upper_chance = 1
if not letters[index].isalpha():
continue
if last_cap:
upper_chance = 2
cap = (random.randint(0, upper_chance) == 0)
if cap:
letters[index] = letters[index].upper()
last_cap = True
else:
letters[index] = letters[index].lower()
last_cap = False
return ''.join(letters)
SPONGEBOB_MEME = """\
........,,:``:::,,::::::::::::::,,:::::::::;.;::::,
.,.....,,,:.`:::,::::::::::::.;,,:::::::::::.::::,,
......,,,,,..::::::::::::::;.:::::::::::::::::::,,,
,,...,,,,,,..::;+,;:::::::;,,::::::::::::::::;.;,,:
,....,,,,,,..,:` ,.;:::::;;.::::;;,:;::::::::;:,:::
.....,,,,,,..,:` :;::;::;:::::;::,;;:;::::::::,,::
...,.,,,,,,.`,:,, `.;:::;.;:::::::::;:;:::::::::,::
.....,,...,..,:;,: :;;:;:::::;:;:,,:;:::::::::::;,;
.....,,,..,..,;;;:``,;;;;;::;;;;:;::;:::::::::::;;.
....,,,,..,..:,:,.. ,;,:,,,:':,,;:::;::::;:::::::;,
....,,,,..,.,,;'''``+#,;:,,,,,,,,:,,,,,,,,.,,,,,,,;
..,,,,,.,.,,,.,:,.:#''.'++',,.;,,:,,,,,,,,,,,,,,,,,
,,,,,,,.,:,,,,,,,::,,',,,:,,,;,,,,:,,,,,,...,,,,,.,
,,,,,,,,,.,:,,,:+,,,;,,:,,,,,:,:';,................
,,,,,,,,,:::,,,,:::'..,.;,,:.,,'+;,.......,........
,,,,,,,,,,;,,,,,.,,.,,,..::.,,,'',,......;,........
,,,,,,,,,:::,.:.,,,,,,.',..,.,,,,,,:,,,,,:,;;;;;;;;
,,,,,,,,,;,,. `;,,,,,,,````.:.:,,;::'.`::':;;;;;;';
,,,,,,,,,,,+, ,.,,,,,: `;:..,:,',,,` #;':.######
,,,,,,,,,,.:: ;.,,,,,: `:;;..;,,,:` `#,':;+#####
,,,,,,,,,,;` `:.::,,,,,;``.;...;,,;;` `##.',.+#+++#
,,,,,,,,,,:#;:.:.,,,,,,.:,,;.,:,:.'' :;;;.:.;######
,,,,,,,,,,:##;..:.,,,,,,.,,,,,,,:,'',.,;:;,;#######
,,,,,,,,,,:+,,,,,,,,,,,..,,,,,,,,,,,,;,:`+#++######
,,,,,,,,,,:#,.:,,:,,.,'+++:,,,,,,:,,,',:`+#++######
,,,,,,,,,,;###,,,,,.'++#':,,,,::,,,,,,,:`:#++######
,,,,,,,,,,;+##.,,,.+#',..:;,,::;:,,:,,,:`.+########
,,,,,:,:::;+##,,,.+;,.;,,..,,,,,,:,,,:,,.;+######++
,:,:::::;'+##+',.:+:++:..,,,,,,,,,,.,,:'###########
'''''++++++++++..+++++++':,,...,,::''+++####+++++##
++++++++++###+++,++++++#+++++++++++#+++++++++++++++
+++++++++++++++++++++++,'+#'+++++'',+##+++++##+####
+++++++++#++++++++++'',+'''++++++++,+''++++++++++++
''''''''''''''++++++++'';''''''''++:+'+'+++++++++++
"""
description = """\
Use this program to spongebob-mockify a series of text. Simply feed in a series of words
in the argv (also can pipe words to this, but not enter them interactively through the TTY).
This is done using a random number generator to determine what letters we should capitalize,
with some logic to know that if the last letter was capitalized the previous letter should have
a lower probability of being capitalized.
Also prints ASCII-art of the meme just for posterity and to appease the normies.
"""
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-n', '--normie', action='store_true', help='go full on normie and print ASCII art of the spongebob meme')
parser.add_argument('words', type=str, nargs='*', help='a series of words to mockify')
args = parser.parse_args()
for word in sys.argv[1:]:
sys.stdout.write(mockify_word(word) + ' ')
if not sys.stdin.isatty():
input_str = sys.stdin.read()
for word in input_str.split(' '):
sys.stdout.write(mockify_word(word) + ' ')
if args.normie:
print '\n\n'
print SPONGEBOB_MEME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment