Created
February 1, 2020 00:03
-
-
Save dhnaranjo/5ab753f47064395d1956c10a3f1c3929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
time = random.choice([ | |
"In the year 2020", | |
"In the year 3000", | |
"In the year 6969", | |
"In the year 42069", | |
"When you get your dream job", | |
"When your father comes back from the milk and cigarette store", | |
"This year", | |
"In july", | |
"In the year of the Whisper-Quiet Maytag Dishwasher", | |
"After you die", | |
"Once you have finally found true love", | |
"In a moment of ecstasy", | |
"When you most expect it", | |
"On your cat's 4th birthday", | |
"When you least expect it", | |
"The day after tomorrow", | |
"Tuesday", | |
"At 11:11", | |
"Tomorrow", | |
"Soon", | |
"Eventually" | |
]) | |
place = random.choice([ | |
"the world", | |
"the solar system", | |
"The United States of America", | |
"your house", | |
"Columbia, MO", | |
"this street", | |
"your favorite coffee shop", | |
"all of California", | |
"the sun", | |
"Amazon.com", | |
"the ice caps", | |
"the ozone layer", | |
"True/False Film Festival", | |
"everyone you know", | |
"every mall", | |
"country roads", | |
"public transit systems", | |
"everything over 5 feet", | |
"every minor league baseball stadium", | |
"all things you love", | |
"all things you feel indifferent about", | |
"most green things", | |
"the sea", | |
]) | |
verb = random.choice([ | |
"destroyed", | |
"obliterated", | |
"pulverized", | |
"squooshed", | |
"dunked on", | |
"dragged", | |
"on fired", | |
"short circuited", | |
"killed then reanimated", | |
"gently rocked to sleep", | |
"Final Destinationed", | |
"screamed at", | |
"swarmed", | |
"smothered", | |
"cancered", | |
"infected", | |
"raptured", | |
"nyquilled", | |
"hotly breathed on", | |
"uncomfortably touched", | |
]) | |
noun = random.choice([ | |
"Bees", | |
"hurricanes", | |
"Steven Tyler", | |
"Meteors", | |
"Aliens", | |
"Juul Pods", | |
"fidget spinners", | |
"flying cars", | |
"Plastic Straws", | |
"Elon Musk", | |
"cancer", | |
"UNLIMITED SOUP SALAD AND BREADSTICKS", | |
"3 of your favorite ceramic mugs", | |
"high quality orange juice", | |
"the cast of Friends", | |
]) | |
signoff = random.choice([ | |
"Good Luck.", | |
"Good Game.", | |
"G2G TTYL", | |
"Love,", | |
"Thanks!", | |
"Bye.", | |
"¯\_(ツ)_/¯", | |
"xoxo", | |
"Like, Comment, Subscribe,", | |
"regards,", | |
"oof,", | |
"ope,", | |
"Happy Honda Days,", | |
"Anyway...", | |
"So it goes.", | |
"Welp.", | |
"Aint that somethin.", | |
";)", | |
]) | |
import usb.core | |
import usb.util | |
"""Demo program to print to the POS58 USB thermal receipt printer. This is | |
labeled under different companies, but is made by Zijiang. See | |
http:zijiang.com""" | |
# In Linux, you must: | |
# | |
# 1) Add your user to the Linux group "lp" (line printer), otherwise you will | |
# get a user permissions error when trying to print. | |
# | |
# 2) Add a udev rule to allow all users to use this USB device, otherwise you | |
# will get a permissions error also. Example: | |
# | |
# In /etc/udev/rules.d create a file ending in .rules, such as | |
# 33-receipt-printer.rules with the contents: | |
# | |
# # Set permissions to let anyone use the thermal receipt printer | |
# SUBSYSTEM=="usb", ATTR{idVendor}=="0416", ATTR{idProduct}=="5011", MODE="666" | |
# Find our device | |
# 0416:5011 is POS58 USB thermal receipt printer | |
dev = usb.core.find(idVendor=0x0416, idProduct=0x5011) | |
# Was it found? | |
if dev is None: | |
raise ValueError('Device not found') | |
# Disconnect it from kernel | |
needs_reattach = False | |
if dev.is_kernel_driver_active(0): | |
needs_reattach = True | |
dev.detach_kernel_driver(0) | |
# Set the active configuration. With no arguments, the first | |
# configuration will be the active one | |
dev.set_configuration() | |
# get an endpoint instance | |
cfg = dev.get_active_configuration() | |
intf = cfg[(0,0)] | |
ep = usb.util.find_descriptor( | |
intf, | |
# match the first OUT endpoint | |
custom_match = \ | |
lambda e: \ | |
usb.util.endpoint_direction(e.bEndpointAddress) == \ | |
usb.util.ENDPOINT_OUT) | |
assert ep is not None | |
# write the data | |
ep.write('\n\n') | |
ep.write('$'*32) | |
ep.write(f'{time}, {place} will be {verb} by {noun}\n\n{signoff}\n- The Trash Oracle\n') | |
ep.write('$'*32) | |
ep.write('\n\n') | |
ep.write(" `-.`'.-'\n") | |
ep.write(" `-. .-'.\n") | |
ep.write(" `-. -./\.- .-'\n") | |
ep.write(" -. /__\ .-\n") | |
ep.write(" `-. `/____\\' .-'.\n") | |
ep.write(" `-. -./.-~~-.\.- '\n") | |
ep.write(" `-. /< (()) >\ .-'\n") | |
ep.write(" - .`/__`-..-'__\\' .-\n") | |
ep.write(" ,...`-./___|____|___\.-'.,.\n") | |
ep.write(" ,-' ,` . . ', `-,\n") | |
ep.write('\n\n\n\n\n\n') | |
# Reattach if it was attached originally | |
dev.reset() | |
if needs_reattach: | |
dev.attach_kernel_driver(0) | |
print("Reattached USB device to kernel driver") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment