Last active
January 24, 2020 01:20
-
-
Save szero/033a3a3ce25b9395c8dea84f8e11340f to your computer and use it in GitHub Desktop.
Revisions
-
szero revised this gist
Jan 24, 2020 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,13 @@ class FilenameTooLongError(OSError): pass def list_duplicates(seq): seen = set() seen_add = seen.add return [idx for idx, item in enumerate(seq) if item in seen or seen_add(item)] room, memes = [], [] if sys.stdin.isatty(): @@ -36,8 +38,7 @@ def list_duplicates(seq): pass for m in memes: if len(m.encode("utf-8")) > 250: # 255 - 5 bytes for additional filename later raise FilenameTooLongError( "Ey boi, max length of lelnix filename is 255" "bytes, make your text shorter if you want your meme reign supreme." @@ -46,12 +47,11 @@ def list_duplicates(seq): box = re.compile(r"[\u2500-\u257F]", re.I | re.M) for i, l in enumerate(memes): memes[i] = box.sub("░", l).strip().replace(" ", "░") # remove empty lines memes = [m for m in memes if m] # remove double lines and trailing line at the bottom for i, l in enumerate(memes): if (l == len(l) * l[0]) and (memes[i + 1] == len(memes[i + 1]) * memes[i + 1][0]): memes.pop(i) if memes[-1] == len(memes[-1]) * memes[-1][0]: memes.pop() @@ -64,10 +64,18 @@ def list_duplicates(seq): invis_char = f"{invis_char}\u200C" with TemporaryDirectory() as d: meme_files = [] for i in memes[::-1]: path = d + "/" + i try: with open(path, "w") as nuthing: pass except Exception: print( "Can't make it dude, are you sure you have ASCII stuff " "consisting of box drawing characters in your clipboard/file?", file=sys.stderr, ) sys.exit(1) meme_files.append(path) run(["volaupload.sh", *room, *meme_files]) -
szero revised this gist
Oct 1, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -67,7 +67,6 @@ def list_duplicates(seq): meme_files = list() for i in memes[::-1]: path = d + "/" + i with open(path, "w") as nuthing: pass meme_files.append(path) -
szero revised this gist
Oct 1, 2019 . 2 changed files with 12 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Steps for posting your based meem 1. Go [here](http://patorjk.com/software/taag/#p=display&w=░&f=ANSI%20Shadow). You must use ANSI Shadow font. 2. Type your text and copy it. This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,25 +5,17 @@ import re from tempfile import TemporaryDirectory from subprocess import run class FilenameTooLongError(OSError): pass def list_duplicates(seq): seen = set() seen_add = seen.add return [idx for idx, item in enumerate(seq) if item in seen or seen_add(item)] room, memes = [], [] if sys.stdin.isatty(): with open(os.path.abspath(sys.argv[1]), "r") as boi: @@ -45,15 +37,17 @@ def list_duplicates(seq): for m in memes: if len(m.encode( "utf-8")) > 250: # 255 - 5 bytes for additional filename later raise FilenameTooLongError( "Ey boi, max length of lelnix filename is 255" "bytes, make your text shorter if you want your meme reign supreme." ) box = re.compile(r"[\u2500-\u257F]", re.I | re.M) for i, l in enumerate(memes): memes[i] = box.sub("░", l).strip().replace(" ", "░") #remove empty lines memes = [m for m in memes if m] #remove double lines and trailing line at the bottom for i, l in enumerate(memes): if (l == len(l) * l[0]) and ( @@ -62,17 +56,19 @@ def list_duplicates(seq): if memes[-1] == len(memes[-1]) * memes[-1][0]: memes.pop() # add some invis character to the end so we can have filenames that are the same # also dat SO doe: https://stackoverflow.com/a/23645451/8774873 invis_char = " \u200C" for idx in list_duplicates(memes): memes[idx] += invis_char invis_char = f"{invis_char}\u200C" with TemporaryDirectory() as d: meme_files = list() for i in memes[::-1]: path = d + "/" + i print(path) with open(path, "w") as nuthing: pass meme_files.append(path) run(["volaupload.sh", *room, *meme_files]) -
szero revised this gist
Aug 18, 2018 . 1 changed file with 34 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,21 +3,27 @@ import sys import os import re from tempfile import TemporaryDirectory from subprocess import run import random import string class FilenameTooLongError(OSError): pass def rand_filename(): def rand_choice(): return random.choice(string.ascii_letters + string.digits) return "." + "".join([rand_choice() for _ in range(3)]) def list_duplicates(seq): seen = set() seen_add = seen.add return [idx for idx, item in enumerate(seq) if item in seen or seen_add(item)] room, memes = list(), list() if sys.stdin.isatty(): with open(os.path.abspath(sys.argv[1]), "r") as boi: @@ -37,30 +43,36 @@ def rand_choice(): except IndexError: pass for m in memes: if len(m.encode( "utf-8")) > 251: # 255 - 4 bytes for additional filename later raise FilenameTooLongError( "Ey boi, max length of lelnix filename is 255" "bytes, make your text shorter if you want your meme reign supreme." ) box = re.compile("[\u2500-\u257F]", re.I | re.M) for i, l in enumerate(memes): memes[i] = box.sub("░", l).strip().replace(" ", "░") #remove double lines and trailing line at the bottom for i, l in enumerate(memes): if (l == len(l) * l[0]) and ( memes[i + 1] == len(memes[i + 1]) * memes[i + 1][0]): memes.pop(i) if memes[-1] == len(memes[-1]) * memes[-1][0]: memes.pop() # add random filename for duplicate lines, # also dat SO doe: https://stackoverflow.com/a/23645451/8774873 for idx in list_duplicates(memes): memes[idx] += rand_filename() with TemporaryDirectory() as d: meme_files = list() for i in memes[::-1]: path = d + "/" + i with open(path, "w") as nuthing: pass meme_files.append(path) run(["volaupload.sh", *room, *meme_files]) -
szero revised this gist
Aug 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Steps to post your based meem 1. Go [here](http://patorjk.com/software/taag/#p=display&w=░&f=ANSI%20Shadow). You must use ANSI Shadow font. 2. Type your text and copy it. 3. Save it as text file or pass the clipboard directly to script. -
szero revised this gist
Aug 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Steps to post your based meem 1. Go [here](http://patorjk.com/software/taag/#p=display&w=░&f=ANSI%20bShadow). You must use ANSI Shadow font. 2. Type your text and copy it. 3. Save it as text file or pass the clipboard directly to script. -
szero revised this gist
Aug 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Steps to post your based meem 1. Go [here]("http://patorjk.com/software/taag/#p=display&w=░&f=ANSI Shadow"). You must use ANSI Shadow font. 2. Type your text and copy it. 3. Save it as text file or pass the clipboard directly to script. -
szero revised this gist
Aug 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Steps to post your based meem 1. Go [here](http://patorjk.com/software/taag/#p=display&w=░&f=ANSI Shadow). You must use ANSI Shadow font. 2. Type your text and copy it. 3. Save it as text file or pass the clipboard directly to script. -
szero created this gist
Aug 15, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Steps to post your based meem 1. Go [here](patorjk.com/software/taag/#p=display&w=░&f=ANSI Shadow). You must use ANSI Shadow font. 2. Type your text and copy it. 3. Save it as text file or pass the clipboard directly to script. ## Dependencies - [volaupload.sh](https://github.com/Szero/volascripts.sh/blob/master/volaupload.sh) Example usage: `xsel -ob | ./volafilememe.py BEEPi` `./volafilememe.py "shit room, kys.txt" HF33Go` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ #!/usr/bin/env python3 import sys import os import re import tempfile from subprocess import run import random import string class FilenameTooLongError(OSError): pass def rand_filename(): def rand_choice(): return random.choice(string.ascii_letters + string.digits) return "." + "".join([rand_choice() for _ in range(3)]) room = list() memes = list() if sys.stdin.isatty(): with open(os.path.abspath(sys.argv[1]), "r") as boi: memes = [l for l in boi.readlines()] try: if sys.argv[2]: room.append("-r") room.append(sys.argv[2]) except IndexError: pass else: memes = [l for l in sys.stdin.readlines()] try: if sys.argv[1]: room.append("-r") room.append(sys.argv[1]) except IndexError: pass if len(memes[0].encode("utf-8")) > 251: # 255 - 4 bytes for additional filename later raise FilenameTooLongError("Ey boi, max length of lelnix filename is 255 bytes, " "make your text shorter if you want your meme reign supreme.") with tempfile.TemporaryDirectory() as d: box = re.compile("[\u2500-\u257F]", re.I | re.M) for i, l in enumerate(memes): memes[i] = box.sub("░", l).strip().replace(" ", "░") #remove double lines and trailing line at the bottom for i, l in enumerate(memes): if (l == len(l) * l[0]) and (memes[i+1] == len(memes[i+1]) * memes[i+1][0]): memes.pop(i) if memes[-1] == len(memes[-1]) * memes[-1][0]: memes.pop() #add random filename if not all filenames are unique memes_no_lines = [m for m in memes if (m != len(m) * m[0])] if len(memes_no_lines) > len(set(memes_no_lines)): for i, m in enumerate(memes): memes[i] = m + rand_filename() meme_files = list() for i in memes[::-1]: path = d + "/" + i with open(path, "w") as nuthing: pass meme_files.append(path) run(["volaupload.sh", *room, *meme_files])