{"id":3494,"date":"2011-06-14T04:52:39","date_gmt":"2011-06-14T04:52:39","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=3494"},"modified":"2011-06-14T04:52:39","modified_gmt":"2011-06-14T04:52:39","slug":"sleepless-nights","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2011\/06\/14\/sleepless-nights\/","title":{"rendered":"Sleepless Nights"},"content":{"rendered":"<p>Some people can&#8217;t sleep because they&#8217;re excited or anxious about the next day. Other people can&#8217;t sleep because they&#8217;re sad or glad or guilty or proud, or because the birds outside are addicted to methamphetamines and never quit chirping. But here&#8217;s why I can&#8217;t sleep tonight:<\/p>\n<p>What do you think would be involved in getting <a title=\"NTP - Network Time Protocol\" href=\"http:\/\/www.ntp.org\/\">NTP<\/a> (or a reasonable facsimile thereof) written in JavaScript and using HTTP? And how accurate do you think it would be? Not a lame thing where you take the time from some random webpage and claim that as current time, but an implementation of <a title=\"Marzullo's Algorithm\" href=\"http:\/\/en.wikipedia.org\/wiki\/Marzullo's_algorithm\">Marzullo&#8217;s algorithm<\/a> in JavaScript for sourcing time from multiple servers, a means for calculating round-trip latency, a means for tracking clock drift between requests, and something like a little <a href=\"http:\/\/www.sinatrarb.com\/\">Sinatra<\/a> app to just serve Time.now.utc.to_f and set no-cache headers? (Actually, <a title=\"Time to_f\" href=\"http:\/\/www.ruby-doc.org\/core\/classes\/Time.html#M000340\">time.to_f<\/a> isn&#8217;t terribly precise, though I doubt you&#8217;ll be troubled by this in the real world.) How accurate could you get it? I doubt you could rival NTP, but could you get to the millisecond level? Within 10 milliseconds? Surely within 100 milliseconds?<\/p>\n<p>If you&#8217;re willing to sacrifice sub-second accuracy in favor of not needing a list of special &#8220;time webservers&#8221;, HTTP headers indicate the time, and any webserver worth its salt should be synced to NTP. Though it seems many aren&#8217;t, so I wouldn&#8217;t count on this for anything remotely important. Plus it requires you to be able to parse HTTP headers that many frameworks might not expose.<\/p>","protected":false},"excerpt":{"rendered":"<p>Some people can&#8217;t sleep because they&#8217;re excited or anxious about the next day. Other people can&#8217;t sleep because they&#8217;re sad or glad or guilty or proud, or because the birds outside are addicted to methamphetamines and never quit chirping. But &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2011\/06\/14\/sleepless-nights\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3494","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/3494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=3494"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/3494\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=3494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=3494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=3494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}