<commit_before>require.config({
  paths: {
    jquery: 'libs/jquery-1.11.0.min',
    "jquery.bootstrap": "libs/bootstrap.min",
    underscore: 'libs/underscore-min',
    backbone: 'libs/backbone-min',
    promises: 'libs/bluebird.min',
    text: 'libs/text'
  }
});

require([
  'promises',
  // Load our app module and pass it to our definition function
  'app'
], function (P, App) {

  // Hack !!
  P.defer =  function () {
    var resolve, reject;
    var promise = new P(function() {
      resolve = arguments[0];
      reject = arguments[1];
    });
    return {
      resolve: resolve,
      reject: reject,
      promise: promise
    };
  }

  // The "app" dependency is passed in as "App"
  App.initialize();
});<commit_msg>Added convenience functions to Backbone to store objects in localStorage (uses JSON) Added jwt token to sync Backbone function<commit_after>require.config({
  paths: {
    jquery: 'libs/jquery-1.11.0.min',
    "jquery.bootstrap": "libs/bootstrap.min",
    underscore: 'libs/underscore-min',
    backbone: 'libs/backbone-min',
    promises: 'libs/bluebird.min',
    text: 'libs/text'
  }
});

require([
  'promises',
  // Load our app module and pass it to our definition function
  'app'
], function (P, App) {

  // Hack !!
  P.defer = function () {
    var resolve, reject;
    var promise = new P(function () {
      resolve = arguments[0];
      reject = arguments[1];
    });
    return {
      resolve: resolve,
      reject: reject,
      promise: promise
    };
  }

  // Add convenience JSON parse/stringigy functions to Backbone
  Backbone.localStorage = {};
  Backbone.localStorage.setItem = function (key, obj) {
    window.localStorage.setItem(key, JSON.stringify(obj));
  }
  Backbone.localStorage.getItem = function (key) {
    var str = window.localStorage.getItem(key);
    if (str) {
      return JSON.parse(str);
    }
  }

  // WARNING: this should not go in production !!!!
  window.localStorage.removeItem('user');

  // Add JWT token to each Backbone sync call
  var backboneSync = Backbone.sync;
  Backbone.sync = function (method, model, options) {
    var user = Backbone.localStorage.getItem('user');
    var token = user && user.jwt;

    if (token) {
      options.headers = {
        'Authorization': 'Bearer ' + token
      }
    }

    // call the original function
    backboneSync(method, model, options);
  };


  // The "app" dependency is passed in as "App"
  App.initialize();
});
{'fraction_non_alphanumeric': 0.13953488372093023, 'fraction_numerical': 0.004895960832313341, 'mean_word_length': 2.7897990726429676, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6400694', 'n_tokens_mistral': 797, 'n_tokens_neox': 771, 'n_words': 208}