Skip to content

Instantly share code, notes, and snippets.

@sleepygarden
Last active August 29, 2015 14:01
Show Gist options
  • Save sleepygarden/f39c00e8446c9e3c8dfc to your computer and use it in GitHub Desktop.
Save sleepygarden/f39c00e8446c9e3c8dfc to your computer and use it in GitHub Desktop.
Supermoji - make your Hipchat emojis super!
# all forms must be the same height. each line in a form must be the same width, but each form's width may differ. blank lines are permitted at the top and bottom of each form.
A = """
XXXX
X X
XXXX
X X
X X
"""
B = """
XXX
X X
XXX
X X
XXX
"""
C = """
XXXX
X
X
X
XXXX
"""
D = """
XXX
X X
X X
X X
XXX
"""
E = """
XXXX
X
XXXX
X
XXXX
"""
F = """
XXXX
X
XXXX
X
X
"""
G = """
XXXX
X
X XX
X X
XXXX
"""
H = """
X X
X X
XXXX
X X
X X
"""
I = """
XXX
X
X
X
XXX
"""
J = """
X
X
X
X X
XXXX
"""
K = """
X X
X X
XX
X X
X X
"""
L = """
X
X
X
X
XXXX
"""
M = """
X X
XX XX
X X X
X X
X X
"""
N = """
X X
XX X
X X X
X XX
X X
"""
O = """
XXXX
X X
X X
X X
XXXX
"""
P = """
XXXX
X X
XXXX
X
X
"""
Q = """
XXXXX
X X
X X
X XX
XXX X
"""
R = """
XXXX
X X
XXX
X X
X X
"""
S = """
XXXX
X
XXXX
X
XXXX
"""
T = """
XXXXX
X
X
X
X
"""
U = """
X X
X X
X X
X X
XXXX
"""
V = """
X X
X X
X X
X X
X
"""
W = """
X X
X X
X X X
X X X
XXXXX
"""
X = """
X X
X X
X
X X
X X
"""
Y = """
X X
X X
X
X
X
"""
Z = """
XXXXX
X
X
X
XXXXX
"""
ONE = """
XXX
X
X
X
XXXX
"""
TWO = """
XXX
X
XXX
X
XXXX
"""
THREE = """
XXXX
X
XXX
X
XXXX
"""
FOUR = """
X X
X X
XXXX
X
X
"""
FIVE = """
XXXX
X
XXX
X
XXX
"""
SIX = """
XXXX
X
XXXX
X X
XXXX
"""
SEVEN = """
XXXX
X
X
X
X
"""
EIGHT = """
XXXX
X X
XXXX
X X
XXXX
"""
NINE = """
XXXX
X X
XXXX
X
XXXX
"""
ZERO = """
XXX
X X
X X
X X
XXX
"""
SPACE = """
"""
PERIOD = """
X
"""
EXCLAIMATION = """
X
X
X
X
"""
QUESTION = """
XXX
X
XX
X
X
"""
COMMA = """
X
X
"""
APOSTROPHE = """
X
"""
QUOTE = """
XX
"""
letter_forms = {
"A":A,
"B":B,
"C":C,
"D":D,
"E":E,
"F":F,
"G":G,
"H":H,
"I":I,
"J":J,
"K":K,
"L":L,
"M":M,
"N":N,
"O":O,
"P":P,
"Q":Q,
"R":R,
"S":S,
"T":T,
"U":U,
"V":V,
"W":W,
"X":X,
"Y":Y,
"Z":Z,
"1":ONE,
"2":TWO,
"3":THREE,
"4":FOUR,
"5":FIVE,
"6":SIX,
"7":SEVEN,
"8":EIGHT,
"9":NINE,
"0":ZERO,
" ":SPACE,
".":PERIOD,
"!":EXCLAIMATION,
"?":QUESTION,
",":COMMA,
"'":APOSTROPHE,
"\"":QUOTE
}
LETTER_FORM_HEIGHT = 7
def validateLetterForm(letter_form):
lines = letter_form.split('\n')
if len(lines) != LETTER_FORM_HEIGHT:
print "wrong amount of lines: "+str(len(lines))
return False
line_size = -1
for line in lines:
if line == "": # skip empty lines at top and bottom
continue
if line_size == -1: # still unset
line_size = len(line)
continue
if len(line) != line_size:
print "out of balance line length: "+str(len(line))
return False
return True
def buildLine(phrase,emoji,line):
line_str = str()
for char in phrase:
try:
letter_form = letter_forms[char]
form_slice = letter_form.split('\n')
layer = form_slice[line]+" "
except KeyError:
layer = "???? "
layer = layer.replace(" "," ") # len(emoji)*spaces looks good in terminal // beer == 5, wings = 7~8
layer = layer.replace("X",emoji)
line_str += layer
return line_str
def supermoji():
# validate all your letter forms
for key in letter_forms:
print key +" is valid? " + str(validateLetterForm(letter_forms[key]))
try:
while True:
phrase = raw_input("What text do you want to supermoji? ")
emoji = raw_input("Paste an emoji! ")
if len(phrase) * len(emoji) > 55:
print "Your phrase is really long! It might not work."
for i in xrange(LETTER_FORM_HEIGHT):
print buildLine(phrase.upper(),emoji,i)
except (KeyboardInterrupt, SystemExit):
print "\n"
if __name__ == "__main__":
supermoji()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment