Using JavaScript in strange ways
Hi, I'm Chris Dawson a dad and writer from Portland, OR, now living in Florida. My book is Building Tools with GitHub from O'Reilly. I'm an inventor, have started several companies and worked for several non-startups like Apple and eBay. I am sometimes available for hire as a consultant or part time contributor.

AppFog had a competition a few years ago to make an app which printed “Happy Birthday, OpenStack.” I submitted an entry, but did not win. The winner was someone that used AsciiArt. Oh well. I still think my entry deserved notice, as it uses a few subtle features of JavaScript. Here is the code:

What this does:

  • Reads in its own source code and retrieves the poem from the head
  • Uses text in the poem to reference functions stored in objects returned from require calls.
  • Uses bit shifting; did you know JS had bit shifting?
  • Heavy usage of the l33t hacker number 1337

If you run this app and visit /, it will print “Happy Birthday, OpenStack”. You can see the src at /src. Changing the poem in the comments of the JavaScript code will break the application.

Subscribe to RSS by tags if you only want certain types of posts. Or, subscribe to all posts.
View source to this post
Other interesting things:
<
>
Webiphany.com
https://webiphany.com
1
2
3
4
5
6
7
8
9