isitchristmas.com source code on github
github.com
github.com
Lastly it's a really bad idea to determine language based on IP, a much safer way is to use the browser's language (ACCEPT_LANGUAGE header).
<html>
<body>
<h1> yes </h1>
</body>
</html>On the other hand, I have dealt with far too many programmers who think romanizing Japanese is an acceptable alternative because all dem squigglies are hard.
This isn't a pedantic distinction: 'HAI' is not an acceptable localized message. It's just not. It would be funny except it happens in systems that got contracted out for six figures.
If, for example, you are producing the display logic for a printer it may not make economic sense to give it the necessary capability to write 用紙がありません。 so instead you write ヨウシガアリマセン。 in half-width characters. (Incidentally, that means "out of paper". I hate printer error messages because they are typically scrolling and I can't read scrolling solid blocks of katakana as fast as Japanese people. Funnily enough, my coworkers have the same complaint.)
If you are using a general purpose operating system, putting everything in kana/romaji is not acceptable. My bosses have the quite sensible notion that we are paying for a 100% job not a 100%-of-the-convenient-to-you job.
http://github.com/isit/christmas/tree/master/iic.js
132 "CN": "BÙ SHÌ", // China (Mandarin)
require 'sinatra'
get '/' do
%{<html><body>
<h1>#{Time.now.mday == 25 && Time.now.month == 12 ? "YES" : "NO"}</h1>
</body></html>}
end
Sure, no internationalization or adaptation to local time, but I'd arrogantly assume most Internet users can understand YES and NO as well as I understand JA and NEIN or OUI and NON (apologies to speakers of non-Latin derived languages.. :))This will return the wrong answer if the first expression is evaluated on, say, November 25th and the second half of the expression isn't evaluated until December 1st. Very buggy ;)
Sure, it is a short code snippet that works some of the time, but the original was trying to solve a more difficult problem. This code doesn't even try.
What good is pretty code if it only runs on localhost?
Oh, and if you really do only care about localhost, there isn't much difference between the Sinatra/Ruby code and PHP:
<?php $date = getdate(); ?>
<html><body>
<h1><?php echo $date[mday] == 25 && $date[mon] == 12 ? "YES" : "NO" ?></h1>
</body></html>In any case, I was being flippant because I thought the original was a joke of sorts. It was amusingly overengineered, so I thought I'd go too far in the opposite direction to play devil's advocate, as it were.
print "NO"
It's missing some internationalization and it'll probably fail every now and then (but less than 0.03% of the time) but you'll have to agree it is very concise.Sorry, I'll shut up now :p