Last active
August 9, 2017 04:25
-
-
Save amake/289e047c9cc397a665da33c05feb50a3 to your computer and use it in GitHub Desktop.
macOS Services
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 characters
| # -*- coding: utf-8 -*- | |
| import re | |
| from sys import stdin, stdout | |
| wspace = re.compile(r'^(\s*)(.*?)(\s*)$') | |
| pchars = (u'ACDEFGJLMNPRTUVWY' | |
| u'abcdefghijklmnpqrstuvwy' | |
| u",.?!'()[]{}‿∴¯_ツ") | |
| fchars = (u'∀ↃᗡƎℲ⅁ᒋ⅂WᴎԀᴚ⊥∩ᴧM⅄' | |
| u'ɐqɔpǝɟƃɥıɾʞlɯudbɹsʇnʌʍʎ' | |
| u"'˙¿¡,)(][}{⁀∵_¯ᯄ") | |
| special = [(u'B', u'𐐒'), | |
| (u'K', u'𝈲'), | |
| (u'Q', u'Ό')] | |
| flipper = dict(zip(pchars, fchars) + special) | |
| def flip(s): | |
| ws_l, text, ws_r = wspace.findall(s)[0] | |
| ttext = [flipper.get(x, x) for x in text] | |
| return ws_l + ''.join(reversed(ttext)) + ws_r | |
| for line in stdin: | |
| flipped = flip(line.decode('utf-8')) | |
| stdout.write(flipped.encode('utf-8')) |
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 characters
| # Install qrencode from MacPorts | |
| qrencode -o - "$*" | open -f -a Preview |
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 characters
| # Inspired by http://www.leancrew.com/all-this/2013/09/some-simple-services/ | |
| from sys import stdin, stdout | |
| for line in stdin: | |
| struck = u'\u0336'.join(line.decode('utf-8')) | |
| stdout.write(struck.encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment