<commit_before>var menubar = require('menubar')
var ipc = require('ipc')
var config = require('./config.json')
var forecastApiKey = config.forecast.api_key

var Forecast = require('./forecast')
var weather = new Forecast(forecastApiKey)

var DEFAULT_NUMBER_OF_RESULTS = 7

var globalCoords
var lookupInterval

var mb = menubar({
  icon: './icons/icon@1x.png',
  height: 175,
  width: 550,
  preloadWindow: true
})

ipc.on('coords', function (ev, coords) {
  globalCoords = coords
  queryWeatherData()
})

mb.on('ready', function () {
  lookupInterval = setInterval(queryWeatherData, 90000)
})

mb.app.on('window-all-closed', function () {
  clearInterval(lookupInterval)
  mb.app.quit()
})

function queryWeatherData () {
  return weather.get(globalCoords[0], globalCoords[1], function (err, data) {
    if (err) return [] /* i dunno, do something */

    var dataset = getDataset(config.datafield, data)
    return mb.window.webContents.send('weather-data', dataset)
  })
}

function getDataset (field, limit, data) {
  var validFields = ['minutely', 'hourly', 'daily']
  if (validFields.indexOf(field) === -1) return out

  if (typeof limit === 'object') {
    data = limit
    limit = DEFAULT_NUMBER_OF_RESULTS
  }

  var everything = data[field]
  var clone = {}

  for (var k in everything) {
    if (k === 'data') clone[k] = []
    else clone[k] = everything[k]
  }

  for (var i = 0; i < limit; i++) {
    clone.data.push(everything.data[i])
  }

  return clone
}<commit_msg>use absolute path for icon<commit_after>var menubar = require('menubar')
var ipc = require('ipc')
var path = require('path')
var config = require('./config.json')
var forecastApiKey = config.forecast.api_key

var Forecast = require('./forecast')
var weather = new Forecast(forecastApiKey)

var DEFAULT_NUMBER_OF_RESULTS = 7

var globalCoords
var lookupInterval

var mb = menubar({
  icon: path.join(__dirname, 'icons', 'icon@1x.png'),
  height: 175,
  width: 550,
  preloadWindow: true
})

ipc.on('coords', function (ev, coords) {
  globalCoords = coords
  queryWeatherData()
})

mb.on('ready', function () {
  lookupInterval = setInterval(queryWeatherData, 90000)
})

mb.app.on('window-all-closed', function () {
  clearInterval(lookupInterval)
  mb.app.quit()
})

function queryWeatherData () {
  return weather.get(globalCoords[0], globalCoords[1], function (err, data) {
    if (err) return [] /* i dunno, do something */

    var dataset = getDataset(config.datafield, data)
    return mb.window.webContents.send('weather-data', dataset)
  })
}

function getDataset (field, limit, data) {
  var validFields = ['minutely', 'hourly', 'daily']
  if (validFields.indexOf(field) === -1) return out

  if (typeof limit === 'object') {
    data = limit
    limit = DEFAULT_NUMBER_OF_RESULTS
  }

  var everything = data[field]
  var clone = {}

  for (var k in everything) {
    if (k === 'data') clone[k] = []
    else clone[k] = everything[k]
  }

  for (var i = 0; i < limit; i++) {
    clone.data.push(everything.data[i])
  }

  return clone
}
{'fraction_non_alphanumeric': 0.1503138420878758, 'fraction_numerical': 0.011232243145028081, 'mean_word_length': 4.021558872305141, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1800391', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1026, 'n_words': 259}