Skip to content

Instantly share code, notes, and snippets.

@willasaywhat
Created March 15, 2018 03:11
Show Gist options
  • Save willasaywhat/34abcf8b5b7770df76f1fda1f3f7bd61 to your computer and use it in GitHub Desktop.
Save willasaywhat/34abcf8b5b7770df76f1fda1f3f7bd61 to your computer and use it in GitHub Desktop.
###
# Written on a plane using Pythonista and a gratiutious use of copy and paste, as well as in flight wifi.
###
import requests
import urllib
from HTMLParser import HTMLParser
#### HE COMES (courtesy of: https://github.com/mjgiarlo/pyzalgo/blob/master/bin/zalgo) ####
# coding: utf-8
from random import randint, choice
def zalgo(text, intensity=50):
zalgo_threshold = intensity
zalgo_chars = [unichr(i) for i in range(0x0300, 0x036F + 1)]
zalgo_chars.extend([u'\u0488', u'\u0489'])
source = text.decode('utf8').upper()
if not _is_narrow_build:
source = _insert_randoms(source)
zalgoized = []
for letter in source:
zalgoized.append(letter)
zalgo_num = randint(0, zalgo_threshold) + 1
for _ in range(zalgo_num):
zalgoized.append(choice(zalgo_chars))
response = choice(zalgo_chars).join(zalgoized)
return response.encode('utf8', 'ignore')
def _insert_randoms(text):
random_extras = [unichr(i) for i in range(0x1D023, 0x1D045 + 1)]
newtext = []
for char in text:
newtext.append(char)
if randint(1, 5) == 1:
newtext.append(choice(random_extras))
return u''.join(newtext)
def _is_narrow_build():
try:
unichr(0x10000)
except ValueError:
return True
return False
####
# get input
req = requests.get("http://www.bash.org/?random1")
quote = req.text.split('<p class="qt">')[1]
quote = quote.split('</p>')[0]
h = HTMLParser()
quote = h.unescape(quote)
quote = quote.replace("<br />", '\n')
# HE COMES AGAIN
print zalgo(quote, 2)
@willasaywhat
Copy link
Author

willasaywhat commented Mar 15, 2018

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