Skip to content

Instantly share code, notes, and snippets.

@neemzy neemzy/flipt
Last active Dec 14, 2017

Embed
What would you like to do?
Fliptable text script
#!/usr/bin/env node
/*
Usage: flipt my text with spaces
Result: Puts "(╯°□°)╯︵ sǝɔɐds ɥʇıʍ ʇxǝʇ ʎɯ" in your clipboard
Source: http://www.typeupsidedown.com
Put this in your .*rc:
flip-table() {
/path/to/flipt $@ | tr -d '\n' | c2c
}
alias c2c='xsel --clipboard' # or pbcopy
alias flipt='flip-table'
*/
function flipString(aString) {
var last = aString.length - 1,
result = new Array(aString.length),
i;
for (i = last; i >= 0; --i) {
var c = aString.charAt(i),
r = flipTable[c];
result[last - i] = r != undefined ? r : c;
}
return result.join('');
}
var i,
j,
flipTable = {
a: '\u0250',
b: 'q',
c: '\u0254',
d: 'p',
e: '\u01DD',
f: '\u025F',
g: '\u0183',
h: '\u0265',
i: '\u0131',
j: '\u027E',
k: '\u029E',
//l: '\u0283',
m: '\u026F',
n: 'u',
r: '\u0279',
t: '\u0287',
v: '\u028C',
w: '\u028D',
y: '\u028E',
'.': '\u02D9',
'[': ']',
'(': ')',
'{': '}',
'?': '\u00BF',
'!': '\u00A1',
"\'": ',',
'<': '>',
'_': '\u203E',
';': '\u061B',
'\u203F': '\u2040',
'\u2045': '\u2046',
'\u2234': '\u2235'
};
for (i in flipTable) {
flipTable[flipTable[i]] = i;
}
console.log('(╯°□°)╯︵ ' + flipString(process.argv.slice(2).join(' ').toLowerCase()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.