<commit_before>var request = require('request');
var serialport = require("serialport");
var SerialPort = serialport.SerialPort; // localize object constructor

var sp = new SerialPort("/dev/ttyACM0", {
  parser: serialport.parsers.readline("\n")
});

var privateKey = '<KEY>';
var lastTemp, lastHumidity, temp, humidity;

sp.open(function (err) {
  if (err) console.log('failed to open: '+ error);
  else {
    sp.on('data', function(data) {
      temp = Number(data.split(' ')[0]);
      humidity = Number(data.split(' ')[1]);

      if (lastTemp != temp || lastHumidity != humidity) {
        lastTemp = temp;
        lastHumidity = humidity;
        
        request('https://data.sparkfun.com/input/KJQ87RovVrUN6LzqMxLx?private_key=' + privateKey + '&humidity=' + humidity + '&temp=' + temp, function(err, res, body) {
          if (!err && res.statusCode == 200) console.log('Data sent succesfully!');
          else console.log('Error while sending data!');
        });
      }
    });
  }
});<commit_msg>hiding private key under an environnement variable<commit_after>var request = require('request');
var serialport = require("serialport");
var SerialPort = serialport.SerialPort; // localize object constructor

var sp = new SerialPort("/dev/ttyACM0", {
  parser: serialport.parsers.readline("\n")
});

var privateKey = process.env.SPARKFUN_PRIVATE_KEY;
var lastTemp, lastHumidity, temp, humidity;

sp.open(function (err) {
  if (err) console.log('failed to open: '+ error);
  else {
    sp.on('data', function(data) {
      temp = Number(data.split(' ')[0]);
      humidity = Number(data.split(' ')[1]);

      if (lastTemp != temp || lastHumidity != humidity) {
        lastTemp = temp;
        lastHumidity = humidity;
        
        request('https://data.sparkfun.com/input/xROLbJzAlMcjwlN5dolp?private_key=' + privateKey + '&humidity=' + humidity + '&temp=' + temp, function(err, res, body) {
          if (!err && res.statusCode == 200) console.log('Data sent successfully!');
          else console.log('Error while sending data!');
        });
      }
    });
  }
});
{'fraction_non_alphanumeric': 0.1638715860086248, 'fraction_numerical': 0.007666506947771922, 'mean_word_length': 3.4143763213530653, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '439048', 'n_tokens_mistral': 681, 'n_tokens_neox': 655, 'n_words': 152}