Twitcode
Writing Twitter-size code is fun. It all started with Razvan’s tweet-size program that crashes Mac OS, and Adam Dunkels’ twIP, a tiny IP stack implementation (responds to ping correctly!).
After a qsort and bsearch implementation I wrote a tiny web server in Python. It’s only 128 bytes. The html files served must be in the same directory where the script is running:
s=socket.socket();s.bind(('',80));s.listen(9)
while(1):c,a=s.accept();c.send(open(c.recv(99)[5:].split()
[0]).read());c.close()
And here’s an 136-byte email sender implementation, also in Python. This time it was a bit tough to make it fit in a tweet :). As in the web server, I left out the import line (from socket import socket;from sys import argv).
Usage: <server> <from> <to> <content>, where the subject must be on the first line of the content:
s=socket();v=argv;s.connect((v[1],25)) for i in['MAIL FROM:'+v[2],'RCPT TO:'+v[3],'DATA','Subject: %s\n.'%v[4]]:s.recv(99);s.send(i+'\n')
You can check out more tweet-size code using the #twitcode hashtag on Twitter. Have fun! :)





