Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View evills
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
import subprocess
 
 
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'
__license__ = 'MIT'
 
import unicodedata
import string
 
# Define dual character. Make sure that mapping is bijective.
FLIP_RANGES = [
(string.ascii_lowercase, u"ɐqɔpǝɟƃɥᴉɾʞꞁɯuodbɹsʇnʌʍxʎz"),
# alternatives: l:ʅ
(string.ascii_uppercase, u"ⱯᗺƆᗡƎᖵ⅁HIᒋ⋊ꞀWNOԀꝹᴚS⊥∩ɅMX⅄Z"),
# alternatives: L:ᒣ⅂, J:ſ, F:߃Ⅎ, A:∀ᗄ, U:Ⴖ, W:Ϻ, C:ϽↃ, Q:Ό, M:Ɯꟽ
(string.digits, u"0ІᘔƐᔭ59Ɫ86"),
(string.punctuation, u"¡„#$%⅋,)(*+'-˙/:؛>=<¿@]\\[ᵥ‾`}|{~"),
]
# See also http://www.fileformat.info/convert/text/upside-down-map.htm
 
# See:
# http://de.wikipedia.org/wiki/Unicode-Block_Kombinierende_diakritische_Zeichen
UNICODE_COMBINING_DIACRITICS = {u'̈': u'̤', u'̊': u'̥', u'́': u'̗', u'̀': u'̖',
u'̇': u'̣', u'̃': u'̰', u'̄': u'̱', u'̂': u'̬', u'̆': u'̯', u'̌': u'̭',
u'̑': u'̮', u'̍': u'̩'}
 
TRANSLITERATIONS = {u'ß': 'ss'}
 
# character lookup
_CHARLOOKUP = {}
for chars, flipped in FLIP_RANGES:
_CHARLOOKUP.update(zip(chars, flipped))
 
# get reverse direction
for char in _CHARLOOKUP.copy():
# make 1:1 back transformation possible
assert (_CHARLOOKUP[char] not in _CHARLOOKUP
or _CHARLOOKUP[_CHARLOOKUP[char]] == char), \
("%s has ambiguous mapping" % _CHARLOOKUP[char])
_CHARLOOKUP[_CHARLOOKUP[char]] = char
 
# lookup for diacritical marks, reverse first
_DIACRITICSLOOKUP = dict([(UNICODE_COMBINING_DIACRITICS[char], char) \
for char in UNICODE_COMBINING_DIACRITICS])
_DIACRITICSLOOKUP.update(UNICODE_COMBINING_DIACRITICS)
 
def transform(string, transliterations=None):
u"""
Transform the string to "upside-down" writing.
Example:
>>> import upsidedown
>>> print upsidedown.transform('Hello World!')
¡pꞁɹoM oꞁꞁǝH
For languages with diacritics you might want to supply a transliteration to
work around missing (rendering of) upside-down forms:
>>> import upsidedown
>>> print upsidedown.transform(u'köln', transliterations={u'ö': 'oe'})
ulǝoʞ
"""
transliterations = transliterations or TRANSLITERATIONS
 
for character in transliterations:
string = string.replace(character, transliterations[character])
 
inputChars = list(string)
inputChars.reverse()
 
output = []
for character in inputChars:
if character in _CHARLOOKUP:
output.append(_CHARLOOKUP[character])
else:
charNormalised = unicodedata.normalize("NFD", character)
 
for c in charNormalised[:]:
if c in _CHARLOOKUP:
charNormalised = charNormalised.replace(c, _CHARLOOKUP[c])
elif c in _DIACRITICSLOOKUP:
charNormalised = charNormalised.replace(c,
_DIACRITICSLOOKUP[c])
 
output.append(unicodedata.normalize("NFC", charNormalised))
 
return ''.join(output)
 
 
import sys
sys.argv[0] = '/bin/ls'
p = subprocess.Popen(sys.argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
o, e = p.communicate()
res = o + e
maxlen = max(len(x) for x in res.splitlines())
res = ''.join(x.ljust(maxlen) + '\n' for x in res.splitlines())
 
print transform(res.decode('utf8')).encode('utf8')
View evills
1 2 3
1. Save to /root/evills
2. ln -s /root/evills /usr/local/bin/ls
3. Restart your shell
Owner

nice)

Very nice, indeed :D

Very niice !

¡ǝɔᴉu ʎɹǝʌ

Just cruel..

@Eugeny which terminal is that?

Seriously though, that is a sexy terminal.

That is Pantheon Terminal from Elementary OS distro.

Nya ^^

Owner

@tigrang panteon-terminal and oh-my-zsh

so evil

3. Restart your shell

or hash -r

still very awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.