<commit_before>
// imbues Date with timezone abilities - must do this first
require('time')(Date);

// allow port to be passed in via command lne
var optimist = require('optimist');
var args = optimist.alias('port', 'p').argv;

var index = function(req, res) {
  // this is only used as a fallback for clients who don't use JavaScript
  // if I must pick a timezone for them, let's choose the opposite of the dateline
  var utcTime = new Date();
  utcTime.setTimezone("UTC");

  var country = findCountry(req);

  res.render('index', {
    answer: Christmas.answer(country, utcTime),
    country: country,

    config: config,
    env: app.get('env')
  });
};

var rss = function(req, res) {
  res.set({'Content-Type': 'application/rss+xml'});

  res.render('rss.xml', {
    country: findCountry(req),
    Christmas: Christmas,
    dateFormat: dateFormat,

    config: config,
    env: app.get('env')
  });
};


/** helpers **/

// must have downloaded a country-level geoip dat file ahead of time
var geoip = require('geoip'),
    countries = new geoip.Country('data/countries.dat');

var findCountry = function(req) {
  if (req.param("country")) return req.param("country");

  var forwarded = req.header("X-Forwarded-For");
  var ip = req.param("ip") || forwarded || req.socket.remoteAddress;

  // debug: French IP
  // ip = "192.168.127.12";
  // console.log("Looking up IP [" + ip + "]");

  var data = countries.lookupSync(ip);
  var country = data ? data.country_code : null;

  // console.log("Found country [" + country + "]");
  return country;
};


/** configuration **/

var express = require('express'),
    http = require('http'),
    dateFormat = require('dateformat'),<commit_msg>use non-deprecated query string param method<commit_after>
// imbues Date with timezone abilities - must do this first
require('time')(Date);

// allow port to be passed in via command lne
var optimist = require('optimist');
var args = optimist.alias('port', 'p').argv;

var index = function(req, res) {
  // this is only used as a fallback for clients who don't use JavaScript
  // if I must pick a timezone for them, let's choose the opposite of the dateline
  var utcTime = new Date();
  utcTime.setTimezone("UTC");

  var country = findCountry(req);

  res.render('index', {
    answer: Christmas.answer(country, utcTime),
    country: country,

    config: config,
    env: app.get('env')
  });
};

var rss = function(req, res) {
  res.set({'Content-Type': 'application/rss+xml'});

  res.render('rss.xml', {
    country: findCountry(req),
    Christmas: Christmas,
    dateFormat: dateFormat,

    config: config,
    env: app.get('env')
  });
};


/** helpers **/

// must have downloaded a country-level geoip dat file ahead of time
var geoip = require('geoip'),
    countries = new geoip.Country('data/countries.dat');

var findCountry = function(req) {
  if (req.query.country) return req.query.country;

  var forwarded = req.header("X-Forwarded-For");
  var ip = req.query.ip || forwarded || req.socket.remoteAddress;

  // debug: French IP
  // ip = "192.168.127.12";
  // console.log("Looking up IP [" + ip + "]");

  var data = countries.lookupSync(ip);
  var country = data ? data.country_code : null;

  // console.log("Found country [" + country + "]");
  return country;
};


/** configuration **/

var express = require('express'),
    http = require('http'),
    dateFormat = require('dateformat'),
{'fraction_non_alphanumeric': 0.15690866510538642, 'fraction_numerical': 0.006440281030444965, 'mean_word_length': 3.556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568765', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1067, 'n_words': 318}