Skip to content

Instantly share code, notes, and snippets.

@huonw
Created December 12, 2012 00:15
Show Gist options
  • Save huonw/4263668 to your computer and use it in GitHub Desktop.
Save huonw/4263668 to your computer and use it in GitHub Desktop.
javascript:function convert(e){var t="",n;for(var r=0;r<e.length;r++){n=e[r].toUpperCase();if(dic.hasOwnProperty(n)&&dic[n].length>0){var i=dic[n];t+="[["+i[Math.floor(Math.random()*i.length)]+"]]"}else t+=n}return t}var dic={" ":["156142887792515"],A:["I.have.letter.A","107015582669715"],B:["146468602064836","116067591741123","515425308486884","123610221018617"],C:["53872404042","imagineifyoucouldntc"],D:["322391688648","112542438763744"],E:["91766446175","115430438474268","283780138400963","123538490993811"],F:[],G:["Google","111532845537326","234343043309512"],H:["111356865552629"],I:["124741367672248"],J:["40324932642"],K:["221460146083","56926372437"],L:[],M:["theletterM.mcr"],N:["TheLetterN"],O:["307606749307431"],P:[],Q:["333248933364176","theletterqcafe"],R:["106699962703083"],S:["19thletter"],T:["440658102627745"],U:["156366047808011"],V:["77189649729"],W:["302663476724"],X:["124482324249542"],Y:["112991612048936"],Z:["165724910215"],"?":["466839490011958","173756546013139"],"!":["IWubLiterature"]};var act=document.activeElement;if(act!==null&&act.type=="textarea"){var start=act.selectionStart,end=act.selectionEnd;if(start!=end){var prefix=act.value.substring(0,start);var middle=convert(act.value.substring(start,end));var suffix=act.value.substring(end);act.value=prefix;act.value+=middle;void (act.value+=suffix)}}
lookup = {
'A': 'I.have.letter.A',
'B': '146468602064836',
'C': '53872404042',
'D': '322391688648',
'E': '91766446175',
'F': '',
'G': 'Google',
'H': '111356865552629',
'I': '124741367672248',
'J': '40324932642',
'K': '221460146083',
'L': '',
'M': 'theletterM.mcr',
'N': 'TheLetterN',
'O': '307606749307431',
'P': '',
'Q': '333248933364176',
'R': '106699962703083',
'S': '19thletter',
'T': '440658102627745',
'U': '156366047808011',
'V': '77189649729',
'W': '302663476724',
'X': '124482324249542',
'Y': '112991612048936',
'Z': '165724910215'}
import sys
text = []
for c in ' '.join(sys.argv[1:]):
cc = lookup.get(c.upper(), None)
if cc:
text.append('[[%s]]' % cc)
else:
text.append(c)
print ''.join(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment