01 11 / 2011
140bytes: A Community Curated Collection of Tweet Sized JS
Last May, Jed Schmidt started a fun little game of “code golfing” on Github’s Gist feature called 140bytes, in which people competed to write Tweet-sized JavaScript to accomplish specific tasks. Since then, hundreds of little scripts of varying complexity have been collected, a website and Twitter account have been created to collate these scripts, and a very nice page listing lots of byte-saving techniques has been written.
The scripts themselves range from polyfills to sudoku solvers to useful color conversion utilities. Here are some of my favorites (in no particular order):
- A Sudoku solver
- A Base64 Encoder
- HSL to RGB color converter
- HEX to RGB color converter
- RGB to HEX color converter
- HSV to RGB color converter
- A micro templating engine
- A UTF8 Encoder
- A Twitter @mention/#hashtag auto linker
- A UUUD generator
- A Google Analytics snippet in 140 bytes
- A credit card validator
- An LZW compressor
- A latitude-longitude distance calculator
- Music Soft Synth - a WAV synthesizer in 140 bytes
So as you can see, it is possible to do many impressive things in a very short amount of code. Next time you are in need of a short little snippet, check if there is a 140 bytes entry for what you are looking for. Please be careful, however, as sometimes browser support and functionality are sacrificed in order to reach the 140 byte limit.
If you’re interested in playing yourself, all you have to do is fork the master gist, edit according to the rules in the gist, save your entry and tweet it to @140bytes to let them know.
Have fun!