public
Last active

Hacker News Javascript program which generates the website

  • Download Gist
HN.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
var start = new Date();
 
var data = eval('(' +
"[[\"1.\",\"2107773\",\"\\\"http:\\/\\/www.crunchgear.com\\/2011\\/01\\/15\\/a-brief-explanation-of-why-minecraft-matters\\/\\\"\",\"Why Minecraft Matters\",\" (crunchgear.com) \",\"50\",\"solipsist\",\" 2 hours ago | \",\"17 comments\"],[\"2.\",\"2108021\",\"\\\"http:\\/\\/antimatter15.com\\/wp\\/2011\\/01\\/the-ambiguity-of-open-and-vp8-vs-h-264\\/\\\"\",\"The Ambiguity of Open and H.264 vs. VP8\",\" (antimatter15.com) \",\"17\",\"antimatter15\",\" 1 hour ago | \",\"discuss\"],[\"3.\",\"2107618\",\"\\\"http:\\/\\/www.jamesmolloy.co.uk\\/tutorial_html\\/index.html\\\"\",\"Roll your own toy UNIX-clone OS\",\" (jamesmolloy.co.uk) \",\"57\",\"Rusky\",\" 4 hours ago | \",\"1 comment\"],[\"4.\",\"2108034\",\"\\\"http:\\/\\/nealpoole.com\\/blog\\/2011\\/01\\/http-response-splitting-on-reddit-com\\/\\\"\",\"HTTP Response Splitting Vulnerability on reddit.com\",\" (nealpoole.com) \",\"7\",\"there\",\" 1 hour ago | \",\"3 comments\"],[\"5.\",\"2107755\",\"\\\"http:\\/\\/www.forbes.com\\/2010\\/04\\/05\\/google-facebook-twitter-technology-security-10-privacy.html\\\"\",\"Bruce Schneier: Google And Facebook's Privacy Illusion\",\" (forbes.com) \",\"19\",\"taylorbuley\",\" 3 hours ago | \",\"2 comments\"],[\"6.\",\"2107264\",\"\\\"http:\\/\\/blog.backblaze.com\\/2011\\/01\\/05\\/10-petabytes-visualized\\/\\\"\",\"10 petabytes - visualized\",\" (backblaze.com) \",\"50\",\"geekfactor\",\" 6 hours ago | \",\"30 comments\"],[\"7.\",\"2107709\",\"\\\"http:\\/\\/www.leanessays.com\\/2011\\/01\\/tale-of-two-terminals.html\\\"\",\"A Tale of Two Terminals: Beijing Terminal 3 and Heathrow Terminal 5\",\" (leanessays.com) \",\"16\",\"admp\",\" 3 hours ago | \",\"2 comments\"],[\"8.\",\"2107523\",\"\\\"http:\\/\\/www.dropbox.com\\/dropquest2011\\\"\",\"DropQuest 2011\",\" (dropbox.com) \",\"54\",\"ambiate\",\" 4 hours ago | \",\"66 comments\"],[\"9.\",\"2107367\",\"\\\"http:\\/\\/web.media.mit.edu\\/~minsky\\/OLPC-5.html\\\"\",\"Marvin Minsky on Education and Reprogramming One's Mind\",\" (mit.edu) \",\"35\",\"nopinsight\",\" 6 hours ago | \",\"3 comments\"],[\"10.\",\"2107215\",\"\\\"http:\\/\\/bostinnovation.com\\/2011\\/01\\/15\\/who-is-using-node-js-and-why-yammer-bocoup-proxlet-and-yahoo\\/\\\"\",\"Who is Using Node.js And Why? Yammer, Bocoup, Proxlet and Yahoo\",\" (bostinnovation.com) \",\"45\",\"sliggity\",\" 7 hours ago | \",\"34 comments\"],[\"11.\",\"2106927\",\"\\\"http:\\/\\/stanford-online.stanford.edu\\/seminars\\/knuth\\/101206-knuth-500.asx\\\"\",\"Why pi?\",\" (stanford.edu) \",\"89\",\"pibefision\",\" 10 hours ago | \",\"24 comments\"],[\"12.\",\"2107651\",\"\\\"http:\\/\\/glinden.blogspot.com\\/2011\\/01\\/experiment-infrastructure-at-google.html\\\"\",\"The experiment infrastructure at Google\",\" (glinden.blogspot.com) \",\"15\",\"blasdel\",\" 3 hours ago | \",\"discuss\"],[\"13.\",\"2107924\",\"\\\"http:\\/\\/www.asymco.com\\/2011\\/01\\/15\\/what-google-can-learn-from-john-sculley-how-technology-companies-fail-by-placing-their-strategy-burden-on-technology-decisions\\/\\\"\",\"What Google can learn from John Sculley\",\" (asymco.com) \",\"16\",\"ugh\",\" 1 hour ago | \",\"16 comments\"],[\"14.\",\"2108077\",\"\\\"http:\\/\\/cam.ly\\/blog\\/2011\\/01\\/one-startups-journey-into-seo\\/\\\" rel=\\\"nofollow\\\"\",\"One startup's journey into SEO\",\" (cam.ly) \",\"3\",\"danecjensen\",\" 38 minutes ago | \",\"discuss\"],[\"15.\",\"2107238\",\"\\\"http:\\/\\/arvindn.livejournal.com\\/129555.html\\\"\",\"Is Chess with Queen Odds a Provable Win?\",\" (arvindn.livejournal.com) \",\"31\",\"randomwalker\",\" 6 hours ago | \",\"19 comments\"],[\"16.\",\"2107380\",\"\\\"http:\\/\\/tmsh.posterous.com\\/ipython-as-a-replacement-for-bash-on-a-mac\\\"\",\"IPython as a Replacement for Bash (on a Mac)\",\" (tmsh.posterous.com) \",\"23\",\"tmsh\",\" 5 hours ago | \",\"3 comments\"],[\"17.\",\"2107275\",\"\\\"http:\\/\\/www.osdever.net\\/bkerndev\\/\\\"\",\"Build Your Own OS (from scratch)\",\" (osdever.net) \",\"27\",\"iwwr\",\" 6 hours ago | \",\"3 comments\"],[\"18.\",\"2107491\",\"\\\"http:\\/\\/www.economist.com\\/node\\/17797794?story_id=17797794&CFID=153404171&CFTOKEN=88391942\\\"\",\"Tanks in the Cloud\",\" (economist.com) \",\"17\",\"zwilliamson\",\" 5 hours ago | \",\"5 comments\"],[\"19.\",\"2108044\",\"\\\"http:\\/\\/www.npr.org\\/blogs\\/money\\/2011\\/01\\/14\\/132906135\\/ranking-cute-animals-a-stock-market-experiment\\\" rel=\\\"nofollow\\\"\",\"Ranking Cute Animals: A Stock Market Experiment\",\" (npr.org) \",\"3\",\"timr\",\" 55 minutes ago | \",\"discuss\"],[\"20.\",\"2107066\",\"\\\"http:\\/\\/blog.wattvision.com\\/the-tale-of-the-mystery-load-what-happens-aft\\\"\",\"Wattvision (YC W09): The Tale of the Mystery Load\",\" (wattvision.com) \",\"38\",\"savrajsingh\",\" 8 hours ago | \",\"14 comments\"],[\"21.\",\"2107182\",\"\\\"http:\\/\\/sharing-nicely.net\\/2011\\/01\\/mit-and-the-future-of-open-courseware\\/\\\"\",\"MIT and the future of open courseware\",\" (sharing-nicely.net) \",\"29\",\"ph0rque\",\" 7 hours ago | \",\"6 comments\"],[\"22.\",\"2107461\",\"\\\"http:\\/\\/www.byzantinereality.com\\/?p=868\\\"\",\"First thoughts on Erlang\",\" (byzantinereality.com) \",\"15\",\"nkurz\",\" 5 hours ago | \",\"3 comments\"],[\"23.\",\"2107385\",\"\\\"http:\\/\\/github.com\\/dsimard\\/ready.js\\/tree\\/v1.0.0\\\"\",\"My first 'successful' open-source project (js continuous integration) hits 1.0.0\",\" (github.com) \",\"17\",\"dan_sim\",\" 5 hours ago | \",\"10 comments\"],[\"24.\",\"2106553\",\"\\\"http:\\/\\/www.slideshare.net\\/captology\\/stanford-6401325\\\"\",\"Top Mistakes in Behavior Change\",\" (slideshare.net) \",\"131\",\"benreyes\",\" 17 hours ago | \",\"25 comments\"],[\"25.\",\"2107393\",\"\\\"http:\\/\\/www.nytimes.com\\/books\\/97\\/05\\/18\\/reviews\\/pynchon-luddite.html?_r=1\\\"\",\"Is it OK to be a Luddite? (1984)\",\" (nytimes.com) \",\"16\",\"cincinnatus\",\" 5 hours ago | \",\"5 comments\"],[\"26.\",\"2106111\",\"\\\"http:\\/\\/garry.posterous.com\\/moving-on-and-thanks\\\"\",\"Garry Tan moving on from Posterous and joining YC\",\" (garry.posterous.com) \",\"191\",\"j_baker\",\" 22 hours ago | \",\"33 comments\"],[\"27.\",\"2107607\",\"\\\"http:\\/\\/www.marketing-startups.com\\/?p=294\\\"\",\"Debunking The Startup Myth: Finding The Right Team\",\" (marketing-startups.com) \",\"9\",\"goose77\",\" 4 hours ago | \",\"2 comments\"],[\"28.\",\"2105038\",\"\\\"http:\\/\\/tpdsaa.tumblr.com\\/\\\"\",\"Things Real People Don't Say About Advertising\",\" (tpdsaa.tumblr.com) \",\"282\",\"Byliner\",\" 1 day ago | \",\"54 comments\"],[\"29.\",\"2106677\",\"\\\"http:\\/\\/www.boingboing.net\\/2011\\/01\\/14\\/paranoia-and-deletio.html\\\"\",\"Paranoia and deletion: the wipe man page\",\" (boingboing.net) \",\"86\",\"julian37\",\" 15 hours ago | \",\"63 comments\"],[\"30.\",\"2107302\",\"\\\"http:\\/\\/dewbot.blogspot.com\\/2011\\/01\\/how-developing-changed-my-life.html\\\"\",\"How developing changed my life\",\" (dewbot.blogspot.com) \",\"16\",\"dewbot\",\" 6 hours ago | \",\"4 comments\"]]"
+ ')');
 
var s = '<html>\n'+
'<head>\n'+
'<link rel="stylesheet" type="text/css"\n'+
' href="http://ycombinator.com/news.css">\n'+
'<link rel="shortcut icon" href="http://ycombinator.com/favicon.ico">\n'+
'<script>\n'+
' function byId(id) {\n'+
' return document.getElementById(id);\n'+
' }\n'+
'\n'+
' function vote(node) {\n'+
' var v = node.id.split(/_/); // {\'up\', \'123\'}\n'+
' var item = v[1];\n'+
'\n'+
' // adjust score\n'+
' var score = byId(\'score_\' + item);\n'+
' var newscore = parseInt(score.innerHTML) + (v[0] == \'up\' ? 1 : -1);\n'+
' score.innerHTML = newscore + (newscore == 1 ? \' point\' : \' points\');\n'+
'\n'+
' // hide arrows\n'+
' byId(\'up_\' + item).style.visibility = \'hidden\';\n'+
' byId(\'down_\' + item).style.visibility = \'hidden\';\n'+
'\n'+
' // ping server\n'+
' var ping = new Image();\n'+
' ping.src = node.href;\n'+
'\n'+
' return false; // cancel browser nav\n'+
' }\n'+
'</script>\n'+
'<title>Hacker News</title>\n'+
'</head>\n'+
'<body>\n'+
'<center>\n'+
'<table border=0 cellpadding=0 cellspacing=0 width="85%" bgcolor=#f6f6ef>\n'+
' <tr>\n'+
' <td bgcolor=#ff6600>\n'+
' <table border=0 cellpadding=0 cellspacing=0 width="100%"\n'+
' style="padding: 2px">\n'+
' <tr>\n'+
' <td style="width: 18px; padding-right: 4px"><a\n'+
' href="http://ycombinator.com"><img\n'+
' src="http://ycombinator.com/images/y18.gif" width=18 height=18\n'+
' style="border: 1px #ffffff solid;"></img></a></td>\n'+
' <td style="line-height: 12pt; height: 10px;"><span\n'+
' class="pagetop"><b><a href="news">Hacker News</a></b><img\n'+
' src="http://ycombinator.com/images/s.gif" height=1 width=10><a\n'+
' href="newest">new</a> | <a href="newcomments">comments</a> | <a\n'+
' href="ask">ask</a> | <a href="jobs">jobs</a> | <a href="submit">submit</a></span></td>\n'+
' <td style="text-align: right; padding-right: 4px;"><span\n'+
' class="pagetop"><a href="/x?fnid=kGd6x9ybD4">login</a></span></td>\n'+
' </tr>\n'+
' </table>\n'+
' </td>\n'+
' </tr>\n'+
' <tr style="height: 10px"></tr>\n'+
' <tr>\n'+
' <td>\n'+
' <table border=0 cellpadding=0 cellspacing=0>\n';
for (idx in data){
entry=data[idx];
s +=
' <tr>\n'+
' <td align=right valign=top class="title">'+entry[0]+'</td>\n'+
' <td>\n'+
' <center><a id=up_' + entry[1] +'\n'+
' href="vote?for='+entry[1]+'&dir=up&whence=%6e%65%77%73"><img\n'+
' src="http://ycombinator.com/images/grayarrow.gif" border=0 vspace=3\n'+
' hspace=2></a><span id=down_'+entry[1]+'></span></center>\n'+
' </td>\n'+
' <td class="title"><a\n'+
' href="'+entry[2]+'">'+entry[3]+'</a><span class="comhead"> '+entry[4]+' </span></td>\n'+
' </tr>\n'+
' <tr>\n'+
' <td colspan=2></td>\n'+
' <td class="subtext"><span id=score_'+entry[1]+'>'+entry[5]+'</span> by\n'+
' <a href="user?id='+entry[6]+'">'+entry[6]+'</a> '+entry[7]+'<a\n'+
' href="item?id='+entry[1]+'">'+entry[8]+'</a></td>\n'+
' </tr>\n'+
' <tr style="height: 5px"></tr>\n';
}
 
s+=
' <tr style="height: 10px"></tr>\n'+
' <tr>\n'+
' <td colspan=2></td>\n'+
' <td class="title"><a href="/x?fnid=Gr8cos6OpA" rel="nofollow">More</a></td>\n'+
' </tr> \n'+
'</table>\n'+
'</td>\n'+
' </tr>\n'+
' <tr>\n'+
' <td><img src="http://ycombinator.com/images/s.gif" height=10\n'+
' width=0>\n'+
' <table width="100%" cellspacing=0 cellpadding=1>\n'+
' <tr>\n'+
' <td bgcolor=#ff6600></td>\n'+
' </tr>\n'+
' </table>\n'+
' <br>\n'+
' <center><span class="yclinks"><a href="lists">Lists</a>\n'+
' | <a href="rss">RSS</a> | <a\n'+
' href="http://google.com/search?q=site%3Anews.ycombinator.com">Search</a>\n'+
' | <a href="http://ycombinator.com/bookmarklet.html">Bookmarklet</a> |\n'+
' <a href="http://ycombinator.com/newsguidelines.html">Guidelines</a> |\n'+
' <a href="http://ycombinator.com/newsfaq.html">FAQ</a> | <a\n'+
' href="http://ycombinator.com/newsnews.html">News News</a> | <a\n'+
' href="item?id=363">Feature Requests</a> | <a\n'+
' href="http://ycombinator.com">Y Combinator</a> | <a\n'+
' href="http://ycombinator.com/apply.html">Apply</a> | <a\n'+
' href="http://ycombinator.com/lib.html">Library</a></span><br>\n'+
' <br>\n'+
' <script type="text/javascript"\n'+
' src="http://www.co2stats.com/propres.php?s=1138"></script><img\n'+
' src="http://ycombinator.com/images/s.gif" height=1 width=15><a\n'+
' href="http://www.webmynd.com/html/hackernews.html"><img\n'+
' src="http://ycombinator.com/images/hnsearch.png" border=0\n'+
' style="padding-bottom: 12px"></a><img\n'+
' src="http://ycombinator.com/images/s.gif" height=1 width=25><a\n'+
' href="http://mixpanel.com/?from=yc"><img border=0\n'+
' src="http://mixpanel.com/site_media/images/mixpanel_partner_logo_borderless.gif"\n'+
' alt="Analytics by Mixpanel" style="padding-bottom: 8px" /></a><br>\n'+
' </center>\n'+
' </td>\n'+
' </tr>\n'+
'</table>\n'+
'</center>\n'+
'</body>\n'+
'</html>';
 
var end = new Date();
 
console.log(s);
 
//console.log(end.getMilliseconds()-start.getMilliseconds());

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.