text:
/**

  Font.js v2012.01.25
  (c) Mike "Pomax" Kamermans, 2012
  Licensed under MIT ("expat" flavour) license.
  Hosted on http://github.com/Pomax/Font.js

  This library adds Font objects to the general pool
  of available JavaScript objects, so that you can load
  fonts through a JavaScript object similar to loading
  images through a new Image() object.

  Font.js is compatible with all browsers that support
  <canvas> and Object.defineProperty - This includes
  all versions of Firefox, Chrome, Opera, IE and Safari
  that were 'current' (Firefox 9, Chrome 16, Opera 11.6,
  IE10, Safari 5.1) at the time Font.js was released.

  Font.js will not work on IE8 or below due to the lack
  of Object.defineProperty - I recommend using the
  solution outlined in http://ie6update.com/ for websites
  that are not corporate intranet sites, because as a home
  user you have no excuse not to have upgraded to Internet
  Explorer 9 yet, or simply not using Internet Explorer if
  you're still using Windows XP. If you have friends or
  family that still use IE8 or below: intervene.

  You may remove every line in this header except for
  the first block of four lines, for the purposes of
  saving space and minification. If minification strips
  the header, you'll have to paste that paragraph back in.

  Issue tracker: https://github.com/Pomax/Font.js/issues

**/
;
var window = global.window || {};
(function (window) {
  // init Font
  function Font() {
    // if this is not specified, a random name is used
    this.fontFamily = "fjs" + (999999 * Math.random() | 0);
  }

  // judge whether server
  if (!global.document) {
    return;
  }

  // 1) Do we have a mechanism for binding implicit get/set?
  if (!Object.defineProperty) {
    throw ("Font.js requires Object.defineProperty, which this browser does not support.");
  }

  // 2) Do we have Canvas2D available?
  if (!document.createElement("canvas").getContext) {
    throw ("Font.js requires <canvas> and the Canvas2D API, which this browser does not support.");
  }

  // Also make sure XHR understands typing.
  // Code based on pdf.js (https://gist.github.com/1057924)
  (function (window) {
    // shortcut for Opera - it's already fine
    if (window.opera) return;
    // shortcuts for browsers that already implement XHR minetyping
    if ("response" in XMLHttpRequest.prototype ||
      "mozResponseArrayBuffer" in XMLHttpRequest.prototype ||
      "mozResponse" in XMLHttpRequest.prototype ||
      "responseArrayBuffer" in XMLHttpRequest.prototype) {
      return;
    }
    var getter;
    // If we have access to the VBArray (i.e., we're in IE), use that
    if (window.VBArray) {
      getter = function () {
        return new Uint8Array(new VBArray(this.responseBody).toArray());
      }
    }
    // Okay... umm.. untyped arrays? This may break completely.
    // (Android browser 2.3 and 3 don't do typed arrays)
    else {
      getter = function () {
        this.responseBody;
      }
    }
    Object.defineProperty(XMLHttpRequest.prototype, "response", {
      get: getter
    });
  }(window));

  // IE9 does not have binary-to-ascii built in O_O
  if (!window.btoa) {
    // Code borrowed from PHP.js (http://phpjs.org/functions/base64_encode:358)
    window.btoa = function (data) {
      var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
      var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
        ac = 0,
        enc = "",
        tmp_arr = [];
      if (!data) {
        return data;
      }
      do { // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);
        bits = o1 << 16 | o2 << 8 | o3;
        h1 = bits >> 18 & 0x3f;
        h2 = bits >> 12 & 0x3f;
        h3 = bits >> 6 & 0x3f;
        h4 = bits & 0x3f;
        // use hexets to index into b64, and append result to encoded string
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
      } while (i < data.length);
      enc = tmp_arr.join('');
      var r = data.length % 3;
      return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
    };
  }

  // the font resource URL
  Font.prototype.url = "";

  // the font's format ('truetype' for TT-OTF or 'opentype' for CFF-OTF)
  Font.prototype.format = "";

  // the font's byte code
  Font.prototype.data = "";

  // custom font, implementing the letter 'A' as zero-width letter.
  Font.prototype.base64 = "AAEAAAAKAIAAAwAgT1MvMgAAAAAAAACsAAAAWGNtYXAA" +
    "AAAAAAABBAAAACxnbHlmAAAAAAAAATAAAAAQaGVhZAAAA" +
    "AAAAAFAAAAAOGhoZWEAAAAAAAABeAAAACRobXR4AAAAAA" +
    "AAAZwAAAAIbG9jYQAAAAAAAAGkAAAACG1heHAAAAAAAAA" +
    "BrAAAACBuYW1lAAAAAAAAAcwAAAAgcG9zdAAAAAAAAAHs" +
    "AAAAEAAEAAEAZAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
    "AAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAABAAMAAQA" +
    "AAAwABAAgAAAABAAEAAEAAABB//8AAABB////wAABAAAA" +
    "AAABAAAAAAAAAAAAAAAAMQAAAQAAAAAAAAAAAABfDzz1A" +
    "AAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAEAAg" +
    "AAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAA" +
    "AAAAAAAAAAQAAAAAAAAAAAAAAAAAIAAAAAQAAAAIAAQAB" +
    "AAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAIAHgADAAEEC" +
    "QABAAAAAAADAAEECQACAAIAAAAAAAEAAAAAAAAAAAAAAA" +
    "AAAA==";

  // these metrics represent the font-indicated values,
  // not the values pertaining to text as it is rendered
  // on the page (use fontmetrics.js for this instead).
  Font.prototype.metrics = {
    quadsize: 0,
    leading: 0,
    ascent: 0,
    descent: 0,
    weightclass: 400
  };

  // Will this be a remote font, or a system font?
  Font.prototype.systemfont = false;

  // internal indicator that the font is done loading
  Font.prototype.loaded = false;

  /**
   * This function gets called once the font is done
   * loading, its metrics have been determined, and it
   * has been parsed for use on-page. By default, this
   * function does nothing, and users can bind their
   * own handler function.
   */
  Font.prototype.onload = function () {};

  /**
   * This function gets called when there is a problem
   * loading the font.
   */
  Font.prototype.onerror = function () {};

  // preassigned quad × quad context, for measurements
  Font.prototype.canvas = false;
  Font.prototype.context = false;

  /**
   * validation function to see if the zero-width styled
   * text is no longer zero-width. If this is true, the
   * font is properly done loading. If this is false, the
   * function calls itself via a timeout
   */
  Font.prototype.validate = function (target, zero, mark, font, timeout) {
    if (timeout !== false && timeout < 0) {
      this.onerror("Requested system font " + this.fontFamily + " could not be loaded (it may not be installed).");
      return;
    }
    var width = getComputedStyle(target, null).getPropertyValue("width").replace("px", '');
    // font has finished loading - remove the zero-width and
    // validation paragraph, but leave the actual font stylesheet (mark);
    if (width > 0) {
      document.head.removeChild(zero);
      document.body.removeChild(target);
      this.loaded = true;
      this.onload();
    }
    // font has not finished loading - wait 50ms and try again
    else {
      console.log("timing out");
      setTimeout(function () {
          font.validate(target, zero, mark, font, timeout === false ? false : timeout - 50);
        },
        1000);
    }
  };

  /**
   * This gets called when the file is done downloading.
   */
  Font.prototype.ondownloaded = function () {
    var instance = this;

    // decimal to character
    var chr = function (val) {
      return String.fromCharCode(val);
    };

    // decimal to ushort
    var chr16 = function (val) {
      if (val < 256) {
        return chr(0) + chr(val);
      }
      var b1 = val >> 8;
      var b2 = val & 0xFF;
      return chr(b1) + chr(b2);
    };

    // decimal to hexadecimal
    // var dechex = function (val) {
    //   if (val < 0) {
    //     val = 0xFFFFFFFF + val + 1;
    //   }
    //   return parseInt(val, 10).toString(16);
    // };

    // unsigned short to decimal
    var ushort = function (b1, b2) {
      return 256 * b1 + b2;
    };

    // signed short to decimal
    var fword = function (b1, b2) {
      var negative = b1 >> 7 === 1,
        val;
      b1 = b1 & 0x7F;
      val = 256 * b1 + b2;
      // positive numbers are already done
      if (!negative) {
        return val;
      }
      // negative numbers need the two's complement treatment
      return val - 0x8000;
    };

    // unsigned long to decimal
    var ulong = function (b1, b2, b3, b4) {
      return 16777216 * b1 + 65536 * b2 + 256 * b3 + b4;
    };

    // unified error handling
    var error = function (msg) {
      instance.onerror(msg);
    };

    // we know about TTF (0x00010000) and CFF ('OTTO') fonts
    var ttf = chr(0) + chr(1) + chr(0) + chr(0);
    var cff = "OTTO";

    // so what kind of font is this?
    var data = this.data;
    var version = chr(data[0]) + chr(data[1]) + chr(data[2]) + chr(data[3]);
    var isTTF = (version === ttf);
    var isCFF = (isTTF ? false : version === cff);
    if (isTTF) {
      this.format = "truetype";
    } else if (isCFF) {
      this.format = "opentype";
    }
    // terminal error: stop running code
    else {
      error("Error: file at " + this.url + " cannot be interpreted as OpenType font.");
      return;
    }

    // ================================================================
    // if we get here, this is a legal font. Extract some font metrics,
    // and then wait for the font to be available for on-page styling.
    // ================================================================

    // first, we parse the SFNT header data
    var numTables = ushort(data[4], data[5]),
      tagStart = 12,
      ptr, end = tagStart + 16 * numTables,
      tags = {},
      tag;
    for (ptr = tagStart; ptr < end; ptr += 16) {
      tag = chr(data[ptr]) + chr(data[ptr + 1]) + chr(data[ptr + 2]) + chr(data[ptr + 3]);
      tags[tag] = {
        name: tag,
        checksum: ulong(data[ptr + 4], data[ptr + 5], data[ptr + 6], data[ptr + 7]),
        offset: ulong(data[ptr + 8], data[ptr + 9], data[ptr + 10], data[ptr + 11]),
        length: ulong(data[ptr + 12], data[ptr + 13], data[ptr + 14], data[ptr + 15])
      };
    }

    // first we define a quick error shortcut function:
    var checkTableError = function (tag) {
      if (!tags[tag]) {
        error("Error: font is missing the required OpenType '" + tag + "' table.");
        // return false, so that the result of this function can be used to stop running code
        return false;
      }
      return tag;
    };

    // Then we access the HEAD table for the "font units per EM" value.
    tag = checkTableError("head");
    if (tag === false) {
      return;
    }
    ptr = tags[tag].offset;
    tags[tag].version = "" + data[ptr] + data[ptr + 1] + data[ptr + 2] + data[ptr + 3];
    var unitsPerEm = ushort(data[ptr + 18], data[ptr + 19]);
    this.metrics.quadsize = unitsPerEm;

    // We follow up by checking the HHEA table for ascent, descent, and leading values.
    tag = checkTableError("hhea");
    if (tag === false) {
      return;
    }
    ptr = tags[tag].offset;
    tags[tag].version = "" + data[ptr] + data[ptr + 1] + data[ptr + 2] + data[ptr + 3];
    this.metrics.ascent = fword(data[ptr + 4], data[ptr + 5]) / unitsPerEm;
    this.metrics.descent = fword(data[ptr + 6], data[ptr + 7]) / unitsPerEm;
    this.metrics.leading = fword(data[ptr + 8], data[ptr + 9]) / unitsPerEm;

    // And then finally we check the OS/2 table for the font-indicated weight class.
    tag = checkTableError("OS/2");
    if (tag === false) {
      return;
    }
    ptr = tags[tag].offset;
    tags[tag].version = "" + data[ptr] + data[ptr + 1];
    this.metrics.weightclass = ushort(data[ptr + 4], data[ptr + 5]);

    // ==================================================================
    // Then the mechanism for determining whether the font is not
    // just done downloading, but also fully parsed and ready for
    // use on the page for typesetting: we pick a letter that we know
    // is supported by the font, and generate a font that implements
    // only that letter, as a zero-width glyph. We can then test
    // whether the font is available by checking whether a paragraph
    // consisting of just that letter, styled with "desiredfont, zwfont"
    // has zero width, or a real width. As long as it's zero width, the
    // font has not finished loading yet.
    // ==================================================================

    // To find a letter, we must consult the character map ("cmap") table
    tag = checkTableError("cmap");
    if (tag === false) {
      return;
    }
    ptr = tags[tag].offset;
    tags[tag].version = "" + data[ptr] + data[ptr + 1];
    numTables = ushort(data[ptr + 2], data[ptr + 3]);

    // For the moment, we only look for windows/unicode records, with
    // a cmap subtable format 4 because OTS (the sanitiser used in
    // Chrome and Firefox) does not actually support anything else
    // at the moment.
    //
    // When http://code.google.com/p/chromium/issues/detail?id=110175
    // is resolved, remember to stab me to add support for the other
    // maps, too.
    //
    var encodingRecord, rptr, platformID, encodingID, offset, cmap314 = false;
    for (var encodingRecord = 0; encodingRecord < numTables; encodingRecord++) {
      rptr = ptr + 4 + encodingRecord * 8;
      platformID = ushort(data[rptr], data[rptr + 1]);
      encodingID = ushort(data[rptr + 2], data[rptr + 3]);
      offset = ulong(data[rptr + 4], data[rptr + 5], data[rptr + 6], data[rptr + 7]);
      if (platformID === 3 && encodingID === 1) {
        cmap314 = offset;
      }
    }

    // This is our fallback font - a minimal font that implements
    // the letter "A". We can transform this font to implementing
    // any character between 0x0000 and 0xFFFF by altering a
    // handful of letters.
    var printChar = "A";

    // Now, if we found a format 4 {windows/unicode} cmap subtable,
    // we can find a suitable glyph and modify the 'base64' content.
    if (cmap314 !== false) {

      ptr += cmap314;
      version = ushort(data[ptr], data[ptr + 1]);
      if (version === 4) {
        // First find the number of segments in this map
        var segCount = ushort(data[ptr + 6], data[ptr + 7]) / 2;

        // Then, find the segment end characters. We'll use
        // whichever of those isn't a whitespace character
        // for our verification font, which we check based
        // on the list of Unicode 6.0 whitespace code points:
        var printable = function (chr) {
          return [ // ascii range:
            0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x0020,
            // ansi range:
            0x007F, 0x0080, 0x0081, 0x008D, 0x008E, 0x008F, 0x0090,
            0x0095, 0x009D, 0x009E, 0x00A0,
            // general punctuation :
            0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,
            0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D,
            0x200E, 0x200F, 0x2028, 0x2029, 0x202A, 0x202B, 0x202B,
            0x202C, 0x202D, 0x202E, 0x202F, 0x205F, 0x2060, 0x2061,
            0x2062, 0x2063, 0x2064, 0x3000
          ].indexOf(chr) === -1;
        }

        // Loop through the segments in search of a usable character code:
        var i = ptr + 14,
          e = ptr + 14 + 2 * segCount,
          endChar = false;
        for (; i < e; i += 2) {
          endChar = ushort(data[i], data[i + 1]);
          if (printable(endChar)) {
            break;
          }
          endChar = false;
        }

        if (endChar != false) {
          // We now have a printable character to validate with!
          // We need to make sure to encode the correct "idDelta"
          // value for this character, because our "glyph" will
          // always be at index 1 (index 0 is reserved for .notdef).
          // As such, we need to set up a delta value such that:
          //
          //   [character code] + [delta value] == 1
          //
          printChar = String.fromCharCode(endChar);

          var delta = (-(endChar - 1) + 65536) % 65536;

          // Now we need to substitute the values in our
          // base64 font template. The CMAP modification
          // consists of generating a new base64 string
          // for the bit that indicates the encoded char.
          // In our 'A'-encoding font, this is:
          //
          //   0x00 0x41 0xFF 0xFF 0x00 0x00
          //   0x00 0x41 0xFF 0xFF 0xFF 0xC0
          //
          // which is the 20 letter base64 string at [380]:
          //
          //   AABB//8AAABB////wAAB
          //
          // We replace this with our new character:
          //
          //   [hexchar] 0xFF 0xFF 0x00 0x00
          //   [hexchar] 0xFF 0xFF [ delta ]
          //
          // Note: in order to do so properly, we need to
          // make sure that the bytes are base64 aligned, so
          // we have to add a leading 0x00:
          var newcode = chr(0) + // base64 padding byte
            chr16(endChar) + chr16(0xFFFF) + // "endCount" array
            chr16(0) + // cmap required padding
            chr16(endChar) + chr16(0xFFFF) + // "startCount" array
            chr16(delta) + // delta value
            chr16(1); // delta terminator
          var newhex = btoa(newcode);

          // And now we replace the text in 'base64' at
          // position 380 with this new base64 string:
          this.base64 = this.base64.substring(0, 380) + newhex +
            this.base64.substring(380 + newhex.length);
        }
      }
    }

    this.bootstrapValidation(printChar, false);
  }

  Font.prototype.bootstrapValidation = function (printChar, timeout) {
    // Create a stylesheet for using the zero-width font:
    var tfName = this.fontFamily + " testfont";
    var zerowidth = document.createElement("style");
    zerowidth.setAttribute("type", "text/css");
    zerowidth.innerHTML = "@font-face {\n" +
      "  font-family: '" + tfName + "';\n" +
      "  src: url('data:application/x-font-ttf;base64," + this.base64 + "')\n" +
      "       format('truetype');}";
    document.head.appendChild(zerowidth);

    // Create a validation stylesheet for the requested font, if it's a remote font:
    var realfont = false;
    if (!this.systemfont) {
      realfont = this.toStyleNode();
      document.head.appendChild(realfont);
    }

    // Create a validation paragraph, consisting of the zero-width character
    var para = document.createElement("p");
    para.style.cssText = "position: absolute; top: 0; left: 0; opacity: 0;";
    para.style.fontFamily = this.fontFamily + ", '" + tfName + "'";
    para.innerHTML = printChar + printChar + printChar + printChar + printChar +
      printChar + printChar + printChar + printChar + printChar;
    document.body.appendChild(para);

    // Quasi-error: if there is no getComputedStyle, claim loading is done.
    if (typeof getComputedStyle === "undefined") {
      this.onload();
      error("Error: getComputedStyle is not supported by this browser.\n" +
        "Consequently, Font.onload() cannot be trusted.");
    }

    // If there is getComputedStyle, we do proper load completion verification.
    else {
      // If this is a remote font, we rely on the indicated quad size
      // for measurements. If it's a system font there will be no known
      // quad size, so we simply fix it at 1000 pixels.
      var quad = this.systemfont ? 1000 : this.metrics.quadsize;

      // Because we need to 'preload' a canvas with this
      // font, we have no idea how much surface area
      // we'll need for text measurements later on. So
      // be safe, we assign a surface that is quad² big,
      // and then when measureText is called, we'll
      // actually build a quick <span> to see how much
      // of that surface we don't need to look at.
      var canvas = document.createElement("canvas");
      canvas.width = quad;
      canvas.height = quad;
      this.canvas = canvas;

      // The reason we preload is because some browsers
      // will also take a few milliseconds to assign a font
      // to a Canvas2D context, so if measureText is called
      // later, without this preloaded context, there is no
      // time for JavaScript to "pause" long enough for the
      // context to properly load the font, and metrics may
      // be completely wrong. The solution is normally to
      // add in a setTimeout call, to give the browser a bit
      // of a breather, but then we can't do synchronous
      // data returns, and we need a callback just to get
      // string metrics, which is about as far from desired
      // as is possible.
      var context = canvas.getContext("2d");
      context.font = "1em " + this.fontFamily + "";
      context.fillStyle = "white";
      context.fillRect(-1, -1, quad + 2, quad + 2);
      context.fillStyle = "black";
      context.fillText("test text", 50, quad / 2);
      this.context = context;

      // ===================================================
      // Thanks to Opera and Firefox, we need to add in more
      // "you can do your thing, browser" moments. If we
      // call validate() as a straight function call, the
      // browser doesn't get the breathing space to perform
      // page styling. This is a bit mad, but until there's
      // a JS function for "make the browser update the page
      // RIGHT NOW", we're stuck with this.
      // ===================================================

      // We need to alias "this" because the keyword "this"
      // becomes the global context after the timeout.
      var local = this;
      var delayedValidate = function () {
        local.validate(para, zerowidth, realfont, local, timeout);
      };
      setTimeout(delayedValidate, 50);
    }
  };

  /**
   * We take a different path for System fonts, because
   * we cannot inspect the actual byte code.
   */
  Font.prototype.processSystemFont = function () {
    // Mark system font use-case
    this.systemfont = true;
    // There are font-declared metrics to work with.
    this.metrics = false;
    // However, we do need to check whether the font
    // is actually installed.
    this.bootstrapValidation("A", 1000);
  }

  /**
   * This gets called when font.src is set, (the binding
   * for which is at the end of this file).
   */
  Font.prototype.loadFont = function () {
    var font = this;

    // System font?
    if (this.url.indexOf(".") === -1) {
      setTimeout(function () {
        font.processSystemFont();
      }, 10);
      return;
    }

    // Remote font.
    var xhr = new XMLHttpRequest();
    xhr.open('GET', font.url, true);
    xhr.responseType = "arraybuffer";
    xhr.onload = function () {
      var arrayBuffer = xhr.response;
      if (arrayBuffer) {
        font.data = new Uint8Array(arrayBuffer);
        font.ondownloaded();
      } else {
        font.onerror("Error downloading font resource from " + font.url);
      }
    };
    xhr.onerror = function () {
      font.onerror("Error downloading font resource from " + font.url);
    };
    xhr.send(null);
  };

  // The stylenode can be added to the document head
  // to make the font available for on-page styling,
  // but it should be requested with .toStyleNode()
  Font.prototype.styleNode = false;

  /**
   * Get the DOM node associated with this Font
   * object, for page-injection.
   */
  Font.prototype.toStyleNode = function () {
    // If we already built it, pass that reference.
    if (this.styleNode) {
      return this.styleNode;
    }
    // If not, build a style element
    this.styleNode = document.createElement("style");
    this.styleNode.type = "text/css";
    // fixed IE load Font
    var fixedIEUrl = this.url.replace('.ttf', '.eot');
    var styletext = "@font-face {\n";
    styletext += "  font-family: " + this.fontFamily + ";\n";
    styletext += "  src: url('" + fixedIEUrl + "') format(eot), url('" + this.url + "') format('" + this.format + "');\n";
    styletext += "}";
    this.styleNode.innerHTML = styletext;
    return this.styleNode;
  }

  /**
   * Measure a specific string of text, given this font.
   * If the text is too wide for our preallocated canvas,
   * it will be chopped up and the segments measured
   * separately.
   */
  Font.prototype.measureText = function (textString, fontSize, fontWeight) {
    if (!this.loaded) {
      this.onerror("measureText() was called while the font was not yet loaded");
      return false;
    }
    fontWeight = fontWeight || '';

    // Set up the right font size.
    this.context.font = fontSize + "px " + fontWeight + " " + this.fontFamily + "";

    // Get the initial string width through our preloaded Canvas2D context
    var metrics = this.context.measureText(textString);

    // Assign the remaining default values, because the
    // TextMetrics object is horribly deficient.
    metrics.fontsize = fontSize;
    metrics.ascent = 0;
    metrics.descent = 0;
    metrics.bounds = {
      minx: 0,
      maxx: metrics.width,
      miny: 0,
      maxy: 0
    };
    metrics.height = 0;

    // Does the text fit on the canvas? If not, we have to
    // chop it up and measure each segment separately.
    var segments = [],
      minSegments = metrics.width / this.metrics.quadsize;
    if (minSegments <= 1) {
      segments.push(textString);
    } else {
      // TODO: add the chopping code here. For now this
      // code acts as placeholder
      segments.push(textString);
    }

    // run through all segments, updating the metrics as we go.
    var segmentLength = segments.length,
      i;
    for (i = 0; i < segmentLength; i++) {
      this.measureSegment(segments[i], fontSize, metrics);
    }
    return metrics;
  };

  /**
   * Measure a section of text, given this font, that is
   * guaranteed to fit on our preallocated canvas.
   */
  Font.prototype.measureSegment = function (textSegment, fontSize, metrics) {
    // Shortcut function for getting computed CSS values
    var getCSSValue = function (element, property) {
      return document.defaultView.getComputedStyle(element, null).getPropertyValue(property);
    };

    // We are going to be using you ALL over the place, little variable.
    var i;

    // For text leading values, we measure a multiline
    // text container as built by the browser.
    var leadDiv = document.createElement("div");
    leadDiv.style.position = "absolute";
    leadDiv.style.opacity = 0;
    leadDiv.style.font = fontSize + "px " + this.fontFamily + "";
    var numLines = 10;
    leadDiv.innerHTML = textSegment;
    for (i = 1; i < numLines; i++) {
      leadDiv.innerHTML += "<br/>" + textSegment;
    }
    document.body.appendChild(leadDiv);

    // First we guess at the leading value, using the standard TeX ratio.
    metrics.leading = 1.2 * fontSize;

    // We then try to get the real value based on how
    // the browser renders the text.
    var leadDivHeight = getCSSValue(leadDiv, "height");
    leadDivHeight = leadDivHeight.replace("px", "");
    if (leadDivHeight >= fontSize * numLines) {
      metrics.leading = (leadDivHeight / numLines) | 0;
    }
    document.body.removeChild(leadDiv);

    // If we're not with a white-space-only string,
    // this is all we will be able to do.
    if (/^\s*$/.test(textSegment)) {
      return metrics;
    }

    // If we're not, let's try some more things.
    var ctx = this.context,
      quad = this.systemfont ? 1000 : this.metrics.quadsize,
      w = quad,
      h = quad,
      baseline = quad / 2,
      padding = 50,
      xpos = (quad - metrics.width) / 2;

    // SUPER IMPORTANT, HARDCORE NECESSARY STEP:
    // xpos may be a fractional number at this point, and
    // that will *complete* screw up line scanning, because
    // cropping a canvas on fractional coordiantes does
    // really funky edge interpolation. As such, we force
    // it to an integer.
    if (xpos !== (xpos | 0)) {
      xpos = xpos | 0;
    }

    // Set all canvas pixeldata values to 255, with all the content
    // data being 0. This lets us scan for data[i] != 255.
    ctx.fillStyle = "white";
    ctx.fillRect(-padding, -padding, w + 2 * padding, h + 2 * padding);
    // Then render the text centered on the canvas surface.
    ctx.fillStyle = "black";
    ctx.fillText(textSegment, xpos, baseline);

    // Rather than getting all four million+ subpixels, we
    // instead get a (much smaller) subset that we know
    // contains our text. Canvas pixel data is w*4 by h*4,
    // because {R,G,B,A} is stored as separate channels in
    // the array. Hence the factor 4.
    var scanwidth = (metrics.width + padding) | 0,
      scanheight = 4 * fontSize,
      x_offset = xpos - padding / 2,
      y_offset = baseline - scanheight / 2,
      pixelData = ctx.getImageData(x_offset, y_offset, scanwidth, scanheight).data;

    // Set up our scanline variables
    var i = 0,
      j = 0,
      w4 = scanwidth * 4,
      len = pixelData.length,
      mid = scanheight / 2;

    // Scan 1: find the ascent using a normal, forward scan
    while (++i < len && pixelData[i] === 255) {}
    var ascent = (i / w4) | 0;

    // Scan 2: find the descent using a reverse scan
    i = len - 1;
    while (--i > 0 && pixelData[i] === 255) {}
    var descent = (i / w4) | 0;

    // Scan 3: find the min-x value, using a forward column scan
    for (i = 0, j = 0; j < scanwidth && pixelData[i] === 255;) {
      i += w4;
      if (i >= len) {
        j++;
        i = (i - len) + 4;
      }
    }
    var minx = j;

    // Scan 3: find the max-x value, using a reverse column scan
    var step = 1;
    for (i = len - 3, j = 0; j < scanwidth && pixelData[i] === 255;) {
      i -= w4;
      if (i < 0) {
        j++;
        i = (len - 3) - (step++) * 4;
      }
    }
    var maxx = scanwidth - j;

    // We have all our metrics now, so fill in the
    // metrics object and return it to the user.
    metrics.ascent = (mid - ascent);
    metrics.descent = (descent - mid);
    metrics.bounds = {
      minx: minx - (padding / 2),
      maxx: maxx - (padding / 2),
      miny: -metrics.descent,
      maxy: metrics.ascent
    };
    metrics.height = 1 + (descent - ascent);
    return metrics;
  };

  /**
   * we want Font to do the same thing Image does when
   * we set the "src" property value, so we use the
   * Object.defineProperty function to bind a setter
   * that does more than just bind values.
   */
  Object.defineProperty(Font.prototype, "src", {
    set: function (url) {
      this.url = url;
      this.loadFont();
    }
  });

  /**
   * Bind to global scope
   */
  if (typeof define !== "undefined") {
    define(function () {
      return Font;
    });
  }
  window.Font = Font;
}(window));
module.exports = window.Font;


text:
package org.apache.camel.component.stream.springboot;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * The stream: component provides access to the system-in system-out and
 * system-err streams as well as allowing streaming of file and URL.
 *
 * Generated by camel-package-maven-plugin - do not edit this file!
 */
@ConfigurationProperties(prefix = "camel.component.stream")
public class StreamComponentConfiguration {

    /**
     * Whether the component should resolve property placeholders on itself when
     * starting. Only properties which are of String type can use property
     * placeholders.
     */
    private Boolean resolvePropertyPlaceholders = true;

    public Boolean getResolvePropertyPlaceholders() {
        return resolvePropertyPlaceholders;
    }

    public void setResolvePropertyPlaceholders(
            Boolean resolvePropertyPlaceholders) {
        this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.jhotdraw.samples.teddy.regex;

/**
 * Typesafe Enumeration of Syntaxes for the Parser.
 *
 * @author  Werner Randelshofer
 * @version $Id: MatchType.java 527 2009-06-07 14:28:19Z rawcoder $
 */
public class MatchType  /*implements Comparable*/ {
    private MatchType() {
    }

    public static final MatchType CONTAINS = new MatchType();
    public static final MatchType STARTS_WITH = new MatchType();
    public static final MatchType FULL_WORD = new MatchType();
}


text:
import utils from 'osg/utils';
import Object from 'osg/Object';
import { mat4 } from 'osg/glMatrix';
import { vec3 } from 'osg/glMatrix';
import Target from 'osgAnimation/target';

var StackedScale = function(name, scale) {
    Object.call(this);
    this._target = Target.createVec3Target(scale || vec3.ONE);
    if (name) this.setName(name);
};

utils.createPrototypeObject(
    StackedScale,
    utils.objectInherit(Object.prototype, {
        init: function(scale) {
            this.setScale(scale);
            vec3.copy(this._target.defaultValue, scale);
        },

        setScale: function(scale) {
            vec3.copy(this._target.value, scale);
        },

        getTarget: function() {
            return this._target;
        },

        resetToDefaultValue: function() {
            this.setScale(this._target.defaultValue);
        },

        // must be optimized
        applyToMatrix: function(m) {
            var scale = this._target.value;
            mat4.scale(m, m, scale);
        }
    }),
    'osgAnimation',
    'StackedScale'
);

export default StackedScale;


text:
using System;

namespace Paramore.Brighter.Tests.CommandProcessors.TestDoubles
{
    public class FakeErroringMessageProducer : IAmAMessageProducer
    {
        public int SentCalledCount { get; set; }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose() { }

        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>Task.</returns>
        public void Send(Message message)
        {
            SentCalledCount++;
            throw new Exception();
        }
    }
}


text:
from keras.datasets import cifar10
from keras.models import Model
from keras.layers import Dense, Dropout, SpatialDropout2D, Activation, Flatten
from keras.layers import Input, Convolution2D
from keras.layers.advanced_activations import LeakyReLU
from keras.regularizers import l2
from keras.layers.pooling import MaxPooling2D
from keras.optimizers import Adadelta
from keras.utils.np_utils import to_categorical
import numpy as np
from six.moves import cPickle as pickle
import os
import time

# Helper functions
def accuracy(preds, ys):
	pred_class = np.argmax(preds, axis=1)
	true_class = np.argmax(ys, axis=1)
	difference = true_class - pred_class
	acc = (difference==0).sum()
	return 1. * acc / len(preds)

def saveRecords(pickle_file):
	try:
		f = open(pickle_file, 'wb')
		pickle.dump(record, f, pickle.HIGHEST_PROTOCOL)
		f.close()
	except Exception as e:
		print 'Unable to save data to', pickle_file, ':', e
		raise

# Training parameters
disc_optimizer = Adadelta()
disc_regularizer = l2(1e-4)

disc_batch_size = 100
acc_check_size = 100
nb_epoch = 500

display_interval = 1
save_interval = 10

# Fetch data
(X_train, y_train), (X_test, y_test) = cifar10.load_data()

# Convert uint8 pixel values to float32 in the range [0, 1] (for sigmoid)
X_train = X_train.astype('float32')
X_train /= 255

# Convert target values to categorical representation
y_train = to_categorical(y_train, 10)

# Discriminator Model
# Based on https://github.com/fchollet/keras/blob/master/examples/cifar10_cnn.py

d_input = Input(shape=X_train.shape[1:])

d_layer = Convolution2D(32, 3, 3, border_mode='same', W_regularizer=disc_regularizer)(d_input)
d_layer = LeakyReLU()(d_layer)

d_layer = Convolution2D(32, 3, 3, border_mode='same')(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = MaxPooling2D(pool_size=(2, 2))(d_layer) # 32 -> 16
d_layer = SpatialDropout2D(0.25)(d_layer)

d_layer = Convolution2D(64, 3, 3, border_mode='same', W_regularizer=disc_regularizer)(d_layer)
d_layer = LeakyReLU()(d_layer)

d_layer = Convolution2D(64, 3, 3, border_mode='same')(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = MaxPooling2D(pool_size=(2, 2))(d_layer) # 16 -> 8
d_layer = SpatialDropout2D(0.25)(d_layer)

d_layer = Convolution2D(96, 3, 3, border_mode='same', W_regularizer=disc_regularizer)(d_layer)
d_layer = LeakyReLU()(d_layer)

d_layer = Convolution2D(96, 3, 3, border_mode='same')(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = MaxPooling2D(pool_size=(2, 2))(d_layer) # 8 -> 4
d_layer = SpatialDropout2D(0.25)(d_layer)

d_layer = Convolution2D(128, 3, 3, border_mode='same', W_regularizer=disc_regularizer)(d_layer)
d_layer = LeakyReLU()(d_layer)

d_layer = Convolution2D(128, 3, 3, border_mode='same')(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = MaxPooling2D(pool_size=(2, 2))(d_layer) # 4 -> 2
d_layer = SpatialDropout2D(0.25)(d_layer)

d_layer = Flatten()(d_layer) # 2 x 2 x 128 -> 512

d_layer = Dense(256)(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = Dropout(0.5)(d_layer)

d_layer = Dense(256)(d_layer)
d_layer = LeakyReLU()(d_layer)
d_layer = Dropout(0.5)(d_layer)

d_layer = Dense(10)(d_layer)
d_output = Activation('softmax')(d_layer)

discriminator = Model(d_input, d_output)
discriminator.compile(loss='categorical_crossentropy', optimizer=disc_optimizer)
# discriminator.summary()

# Train discriminator
record = {"disc": [], "gen": [], "acc_real": [], "acc_other": []}
print "Starting training."

start = time.time()
batches_per_epoch = X_train.shape[0] / disc_batch_size
for epoch in range(nb_epoch):

	d_loss = 0

	# Create random batches of data to loop through all samples each epoch
	new_indices = range(X_train.shape[0])
	np.random.shuffle(new_indices)

	for batch_number in range(batches_per_epoch):

		# Section of training data to use
		batch_start = batch_number * disc_batch_size
		batch_end = (batch_number + 1) * disc_batch_size

		# Train discriminator
		X_batch = X_train[new_indices[batch_start:batch_end]]
		y_batch = y_train[new_indices[batch_start:batch_end]]

		d_loss  += discriminator.train_on_batch(X_batch, y_batch)

	# Average loss across batches
	d_loss /= batches_per_epoch

	# Checking convergence on a random subset of the data to save time
	# Check convergence of discriminator on real images
	acc_check_indices = np.random.randint(0, X_train.shape[0], size=acc_check_size)
	preds = discriminator.predict(X_train[acc_check_indices])
	acc_real = accuracy(preds, y_train[acc_check_indices])

	# Log progress
	record["disc"].append(d_loss)
	record['acc_real'].append(acc_real)

	# Display progress:
	if epoch % display_interval == 0:
		msg = ""
		msg += "Epoch: {:d}, d_loss: {:.2f}".format(epoch, d_loss)
		msg += ", real: {:.2f}".format(acc_real)
		print msg
		msg = ""
		msg += "Time elapsed: {:.2f} minutes".format((time.time() - start) / 60)
		print msg

	# Save progress to file
	if (epoch + 1) % save_interval == 0 and (epoch + 1) != nb_epoch:
		disc_file = "networks/disc-" + str(epoch + 1) + ".h5"
		discriminator.save(disc_file)
		print "\nDiscriminator model saved to", disc_file
		pickle_file = "records/record-" + str(epoch + 1) + ".pickle"
		saveRecords(pickle_file)
		print "Loss records saved to", pickle_file, "\n"

print "Training completed in", (time.time() - start) / 60., "minutes."

print "Discriminator loss:", record["disc"][-1]
print "Accuracy on real images:", np.mean(record["acc_real"][-int(0.1 * nb_epoch):])

disc_file = "networks/disc-" + str(nb_epoch) + ".h5"
discriminator.save(disc_file)

pickle_file = "records/record-" + str(nb_epoch) + ".pickle"
saveRecords(pickle_file)
statinfo = os.stat(pickle_file)
print 'Compressed pickle size:', statinfo.st_size


text:
/*******************************************************************************
    DESCRIPTION
*******************************************************************************/
/**
@brief  VSCP class 1 type Measurezone events
@file   vscp_measurezone.h
@author Andreas Merkle, http://www.blue-andi.de

@section desc Description
Measurements with zone information.

This file is automatically generated. Don't change it manually.

@section svn Subversion
$Rev:  $
$Date:  $
*******************************************************************************/

#ifndef __VSCP_MEASUREZONE_H__
#define __VSCP_MEASUREZONE_H__

/*******************************************************************************
    INCLUDES
*******************************************************************************/
#include <stdint.h>
#include "vscp_types.h"

/*******************************************************************************
    COMPILER SWITCHES
*******************************************************************************/

/*******************************************************************************
    CONSTANTS
*******************************************************************************/

/*******************************************************************************
    MACROS
*******************************************************************************/

/*******************************************************************************
    TYPES AND STRUCTURES
*******************************************************************************/

/*******************************************************************************
    VARIABLES
*******************************************************************************/

/*******************************************************************************
    FUNCTIONS
*******************************************************************************/

/**
 * Undefined measurement value.
 *
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendUndefinedEvent(void);

/**
 * This is a discrete value typical for a count. There is no unit for this measurement just a discrete
 * value.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendCountEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Meter.
 *
 * This is a measurement of a length or a distance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendLengthDistanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Kilogram.
 *
 * This is a measurement of a mass.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendMassEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Seconds.
 *
 * Opt. unit: (1) Millisecond . Absolute: (2) y-y-m-d-h-m-s (binary). String: (3) "HHMMSS" time since
 * epoch (00:00:00 UTC, January 1, 1970).
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendTimeEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Ampere.
 *
 * This is a measurement of an electric current.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricCurrentEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Kelvin.
 *
 * Opt. unit: Degree Celsius (1), Fahrenheit (2)
 *
 * This is a measurement of a temperature.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendTemperatureEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Mole.
 *
 * This is a measurement of an amount of a substance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendAmountOfSubstanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Candela.
 *
 * This is a measurement of luminous intensity.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendLuminousIntensityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Hertz.
 *
 * This is a measurement of regular events during a second.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendFrequencyEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Becquerel.
 *
 * This is a measurement of rates of things, which happen randomly, or are unpredictable.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRadioactivityAndOtherRandomEventsEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Newton.
 *
 * This is a measurement of force.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendForceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Pascal.
 *
 * Opt. unit: bar (1), psi (2)
 *
 * This is a measurement of pressure.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendPressureEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Joule.
 *
 * This is a measurement of energy.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendEnergyEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Watt.
 *
 * This is a measurement of power.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendPowerEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Coulomb.
 *
 * This is a measurement electrical charge.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricalChargeEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Volt.
 *
 * This is a measurement of electrical potential.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricalPotentialEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Farad.
 *
 * This is a measurement of electric capacitance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricalCapacitanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Ohm.
 *
 * This is a measurement of resistance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricalResistanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Siemens.
 *
 * This is a measurement of electrical conductance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricalConductanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Ampere meters.
 *
 * This is a measurement of magnetic field strength.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendMagneticFieldStrengthEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Weber.
 *
 * This is a measurement of magnetic flux.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendMagneticFluxEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Tesla.
 *
 * This is a measurement of flux density or field strength for magnetic fields (also called the
 * magnetic induction).
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendMagneticFluxDensityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Henry.
 *
 * This is a measurement of inductance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendInductanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Lumen (lm= cd * sr)
 *
 * This is a measurement of luminous Flux.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendLuminousFluxEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Lux ( lx = lm / m² )
 *
 * This is used to express both Illuminance (incidence of light) and Luminous Emittance (emission of
 * light).
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendIlluminanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Gray. Opt unit: Sievert.
 *
 * This is a measurement of a radiation dose (Absorbed dose of ionizing radiation).
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRadiationDoseEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Katal.
 *
 * This is a measurement of catalytic activity used in biochemistry.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendCatalyticActivityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: cubic meter
 *
 * Opt. unit: Liter (dm³) (1).
 *
 * This is a measurement of volume.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendVolumeEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Bel.
 *
 * Opt Unit: Neper (1), dB (2).
 *
 * This is a measurement of sound intensity.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSoundIntensityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Radian (Plane angles). Opt Unit: Degree (1) Opt Unit: Arcminute (2) Opt Unit:
 * Arcseconds (3)
 *
 * This is a measurement of an angle.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendAngleEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Longitude.
 *
 * Opt. unit: Latitude.
 *
 * This is a measurement of a position.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendPositionEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Meters per second.
 *
 * This is a measurement of a speed.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSpeedEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Meters per second/second.
 *
 * This is a measurement of acceleration.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendAccelerationEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: N/m.
 *
 * This is a measurement of tension.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendTensionEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Relative percentage 0-100%.
 *
 * This is a measurement of relative moistness (Humidity).
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendDampMoistEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Cubic meters/second. Opt Unit: Liter/Second.
 *
 * This is a measurement of flow.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendFlowEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Thermal ohm K/W.
 *
 * This is a measurement of thermal resistance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendThermalResistanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Dioptre (dpt) m-1.
 *
 * This is a measurement of refractive power.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRefractivePowerEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Poiseuille (Pl) Pa . s.
 *
 * This is a measurement of dynamic viscosity.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendDynamicViscosityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Rayal Pa . s/m.
 *
 * This is a measurement of sound impedance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSoundImpedanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Acoustic ohm Pa . s/ m³.
 *
 * This is a measurement of refractive power.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSoundResistanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Darag F-1.
 *
 * This is a measurement of electric elasticity.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendElectricElastanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Talbot ( tb = lm * s)
 *
 * This is a measurement of luminous energy.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendLuminousEnergyEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Nit (nt = cd / m²)
 *
 * This is a measurement of luminance.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendLuminanceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Molal mol/kg.
 *
 * This is a measurement of chemical concentration.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendChemicalConcentrationEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Sievert J/Kg.
 *
 * This is a measurement of dose equivalent.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendDoseEquivalentEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Kelvin.
 *
 * Opt. unit: Degree Celsius (1), Fahrenheit (2)
 *
 * This is a measurement of the Dew Point.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendDewPointEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Relative value.
 *
 * This is a relative value for a level measurement without a unit. It is just relative to the min/max
 * value for the selected data representation.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRelativeLevelEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: Meter.
 *
 * Opt. unit: Feet(1), inches (2)
 *
 * Altitude in meters.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendAltitude(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: square meter (m²)
 *
 * Area in square meter.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendAreaEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: watt per steradian ( W / sr )
 *
 * Radiated power per room angle.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRadiantIntensityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: att per steradian per square metre ( W / (sr * m²) )
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendRadianceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: watt per square metre ( W / m² )
 *
 * Power emitted from or striking onto a surface or area.
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendIrradianceExitanceRadiosityEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: watt per steradian per square metre per nm (W·sr-1·m-2·nm-1)
 *
 * Opt. unit: watt per steradian per metre3 (W·sr-1·m-3) watt per steradian per square metre per hertz
 * (W·sr-1·m-3)
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSpectralRadianceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

/**
 * Default unit: watt per square metre per nm (W·m-2·nm-1)
 *
 * Opt. unit: watt per metre3 (W·m-3) watt per square metre per hertz (W·m-2·Hz-1)
 *
 * @param[in] index Index for sensor.
 * @param[in] zone Zone for which event applies to (0-255). 255 is all zones.
 * @param[in] subZone Sub-zone for which event applies to (0-255). 255 is all sub-zones.
 * @param[in] data The data as signed integer.
 * @param[in] exp The exponent of the data (10^exponent).
 * @return Status
 * @retval FALSE Failed to send the event
 * @retval TRUE  Event successul sent
 *
 */
extern BOOL vscp_measurezone_sendSpectralIrradianceEvent(uint8_t index, uint8_t zone, uint8_t subZone, int32_t data, int8_t exp);

#endif /* __VSCP_MEASUREZONE_H__ */


text:
title: Socket.IO 1.3.5
slug: /socket-io-1-3-5/
authors: rauchg
---

Socket.IO **1.3.5** addresses a parser issue. Upgrade recommended. Completely backwards-compatible.

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script>
```


text:
export default class Utils {

  static getRandomColor (prefix = '#') {
    var letters = '0123456789ABCDEF'.split('')
    var color = prefix
    for (var i = 0; i < 6; i++) {
      color += letters[Math.floor(Math.random() * 16)]
    }
    return color
  }

  static randomIntFromInterval (min, max, decimalPlaces) {
    var number = Math.random() * (max - min) + min
    if (decimalPlaces === null || decimalPlaces === undefined) {
      return number
    } else {
      return Number(number.toFixed(decimalPlaces))
    }
  }

  static toRadians (deg) {
    return deg * (Math.PI/180)
  }

  static toDegrees (rad) {
    return rad * (180/Math.PI)
  }

  static lerp(a, b, t) {
    return a*(1-t)+b*t
  }

}

window.Utils = Utils


text:
<OdeAsn1Data>
	<metadata>
		<payloadType>us.dot.its.jpo.ode.model.OdeAsn1Payload</payloadType>
		<serialId>
			<streamId>4e7ac616-31d2-4fdf-ac7d-bf24aff3b6bb</streamId>
			<bundleSize>1</bundleSize>
			<bundleId>4</bundleId>
			<recordId>2</recordId>
			<serialNumber>0</serialNumber>
		</serialId>
		<odeReceivedAt>2017-11-09T13:33:34.252Z[UTC]</odeReceivedAt>
		<schemaVersion>3</schemaVersion>
		<recordGeneratedAt>2017-09-11T22:59:23.525Z[UTC]</recordGeneratedAt>
		<recordGeneratedBy>OBU</recordGeneratedBy>
		<validSignature>false</validSignature>
		<sanitized>false</sanitized>
		<logFileName>rxMsg_TIM.bin</logFileName>
		<recordType>rxMsg</recordType>
		<encodings>
			<encodings>
				<elementName>root</elementName>
				<elementType>Ieee1609Dot2Data</elementType>
				<encodingRule>COER</encodingRule>
			</encodings>
			<encodings>
				<elementName>unsecuredData</elementName>
				<elementType>MessageFrame</elementType>
				<encodingRule>UPER</encodingRule>
			</encodings>
		</encodings>
		<receivedMessageDetails>
			<locationData>
				<latitude>40.4740245</latitude>
				<longitude>-104.9692776</longitude>
				<elevation>1501.0</elevation>
				<speed>0.20</speed>
				<heading>0.0000</heading>
			</locationData>
			<rxSource>RSU</rxSource>
		</receivedMessageDetails>
	</metadata>
	<payload>
		<dataType>us.dot.its.jpo.ode.model.OdeHexByteArray</dataType>
		<data>
			<bytes>03804B001F4820100000000003616371F082729B8B24A2597293664001FFFE2FC2AF8AE9D830407E537164944B2E526CC80003206FFFF00018B2E3765A6E2C9A498B2E6B4DA6E2CA010420004C54</bytes>
		</data>
	</payload>
</OdeAsn1Data>


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test 1 Prep</title>

Question 7

    <button id="btn">Click Me!</button>

It's not that bad


text:
extern "C" {
#endif

struct Metadata;
struct WebPPicture;

//------------------------------------------------------------------------------
// WebP decoding

// Prints an informative error message regarding decode failure of 'in_file'.
// 'status' is treated as a VP8StatusCode and if valid will be printed as a
// text string.
void PrintWebPError(const char* const in_file, int status);

// Reads a WebP from 'in_file', returning the contents and size in 'data' and
// 'data_size'. If not NULL, 'bitstream' is populated using WebPGetFeatures().
// Returns true on success.
int LoadWebP(const char* const in_file,
             const uint8_t** data, size_t* data_size,
             WebPBitstreamFeatures* bitstream);

// Decodes the WebP contained in 'data'.
// 'config' is a structure previously initialized by WebPInitDecoderConfig().
// 'config->output' should have the desired colorspace selected. 'verbose' will
// cause decode timing to be reported.
// Returns the decoder status. On success 'config->output' will contain the
// decoded picture.
VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size,
                         int verbose, WebPDecoderConfig* const config);

// Same as DecodeWebP(), but using the incremental decoder.
VP8StatusCode DecodeWebPIncremental(
    const uint8_t* const data, size_t data_size,
    int verbose, WebPDecoderConfig* const config);

//------------------------------------------------------------------------------

// Reads a WebP from 'in_file', returning the decoded output in 'pic'.
// Output is RGBA or YUVA, depending on pic->use_argb value.
// If 'keep_alpha' is true and the WebP has an alpha channel, the output is RGBA
// or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV.
// Returns true on success.
int ReadWebP(const uint8_t* const data, size_t data_size,
             struct WebPPicture* const pic,
             int keep_alpha, struct Metadata* const metadata);

#ifdef __cplusplus
}    // extern "C"
#endif

#endif  // WEBP_IMAGEIO_WEBPDEC_H_


text:
'use strict';
angular.module('ggDiary').service('replayUpload', ['$http', function ($http) {
	this.uploadFileToUrl = function(file, name,description,uploadUrl,success,starting,error){
		if(file){
			var maxFileSize = 307200; //300kb
			var maxFileSizePretty = '300Kb';
			var allowedFileExtension = /.SC2Replay$/i;

			if(file.name.match(allowedFileExtension)){
				//check if the selected file has an appropriated size
				if(file.size <= maxFileSize){
					//creating the form data
					var fd = new FormData();
					fd.append('file', file);
					if(name){
						fd.append('name', angular.toJson(name));
					}
					if(description){
						fd.append('description', description);
					}
					//Starting callback
					starting(file);

					//Send using the http service
					$http.post(uploadUrl, fd, {
						headers: {'Content-Type': undefined },
						transformRequest: angular.identity,
					})
					.success(function(){ success();	})
						.error(function(e){ error(e); });
				}
				else {
					//File was too big
					error(new Error(file.name + ': replay file is too large. The maximum allowed filesize is ' + maxFileSizePretty));
				}
			}
			else {
				error(new Error('Invalid filetype. Please upload a *.SC2Replay file'));
			}
		}
		else{
			//No file selected
			error(new Error('No replay file selected'));
		}
	};
}]);


text:
package com.mentor.nucleus.bp.io.mdl.test.pkgcm.restore;

import java.util.Vector;

import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;

import com.mentor.nucleus.bp.core.CorePlugin;
import com.mentor.nucleus.bp.core.common.PersistableModelComponent;
import com.mentor.nucleus.bp.core.common.PersistenceManager;
import com.mentor.nucleus.bp.io.mdl.test.pkgcm.EditorTestUtilities;
import com.mentor.nucleus.bp.io.mdl.test.pkgcm.PkgCMModifyContentsTest;

public class PkgCMRestoreModifyContentsTest extends PkgCMModifyContentsTest {

    public PkgCMRestoreModifyContentsTest(String name) {
        super(projectName, name);
    }

    protected void setupProjectAndTestModel() throws CoreException {

        firstTime_modCont = getProperty("firstTime_modCont", firstTime_modCont);
        super.setupProjectAndTestModel();
    }

    protected void tearDown() throws Exception {
        setProperty("firstTime_modCont", firstTime_modCont);
        super.tearDown();
    }

    private void saveTestVariables() {
        setProperty("expectedEditorCount", expectedEditorCount);
        setProperty("editorToTest", editorToTest);
        setProperty("componentName", componentName);
        setProperty("oldFile", oldFile.getFullPath().toString());
        int edCount = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                .getActivePage().getEditorReferences().length;

        setProperty("editorCount", new Integer(edCount).toString());

        if (editorToTest == EditorTestUtilities.EDITOR_TYPE_NONE)
            removeProperty("focusEditorTitle");
        else
            setProperty("focusEditorTitle", PlatformUI.getWorkbench()
                    .getActiveWorkbenchWindow().getActivePage()
                    .getActiveEditor().getTitle());

        for (int i = 0; i < openEditors.length; i++) {
            IEditorPart editor = (IEditorPart) openEditors[i];
            setProperty("title" + i, editor.getTitle());
        }
        for (int i = 0; i < oldEditorContents.length; i++) {
            if (oldEditorContents[i] != null)
                setProperty("oldEditorContents" + i, oldEditorContents[i]);
        }

    }

    private void initTestVariables() {
        componentName = getProperty("componentName");
        expectedEditorCount = getProperty("expectedEditorCount", 0);
        editorToTest = getProperty("editorToTest", -1);
        String path = getProperty("oldFile");
        oldFile = PersistenceManager.findComponent(new Path(path)).getFile();
        String title = null;
        openEditors = new Object[expectedEditorCount];
        editorTitles = new String[expectedEditorCount];
        for (int i = 0; i < expectedEditorCount; i++) {
            title = getProperty("title" + i);

            if (title == null)
                continue;
            editorTitles[i] = title;
            openEditors[i] = EditorTestUtilities.findEditor(title,true);
            while(Display.getCurrent().readAndDispatch());
            m_wp.activate((IEditorPart)openEditors[i]);
        }

        title=getProperty("focusEditorTitle");
        if (title != null) {
            m_wp.activate(EditorTestUtilities.findEditor(title));
        }

        oldEditorContents = new String[expectedEditorCount];
        for (int i = 0; i < expectedEditorCount; i++) {
            oldEditorContents[i] = getProperty("oldEditorContents" + i);
        }
    }

    protected void initTest(String compType, String compName,
            int focusedEditor, int expectedEditorCount) throws Exception {
        if (toSetupWorkspace()) {
            super.initTest(compType, compName, focusedEditor,
                    expectedEditorCount);
            saveTestVariables();
        } else {
            initTestVariables();
        }
    }

}


text:
<?php
use FintechFab\MPSP\Services\Gates\AcquiringEmulatorGate;
use FintechFab\MPSP\Services\Interfaces\AcquiringInterface;

class AcquiringInterfaceInstanceTest extends TestCase
{

	/**
	 * при запросе из IoC AcquiringInterface - получается объект заданный в конфиге
	 */
	public function test()
	{
		$acquiring = App::make(AcquiringInterface::class);

		$this->assertInstanceOf(AcquiringEmulatorGate::class, $acquiring);
	}

}


text:
first repository

I will create the official Camasia repository soon


text:
package com.sugaronrest.restapicalls.methodcalls;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.sugaronrest.ErrorResponse;
import com.sugaronrest.restapicalls.responses.ReadLinkedEntryResponse;
import com.sugaronrest.utils.JsonObjectMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class GetLinkedEntry {

    /**
     * Gets linked entry[SugarCRM REST method - get_entry].
     *
     * @param url REST API Url.
     * @param sessionId Session identifier.
     * @param moduleName SugarCRM module name.
     * @param identifier The entity identifier.
     * @param selectFields Selected field list.
     * @param linkedSelectFields Linked field info.
     * @return ReadLinkedEntryResponse object
     */
    public static ReadLinkedEntryResponse run(String url, String sessionId, String moduleName, String identifier, List<String> selectFields, List<Object> linkedSelectFields)  {

        ReadLinkedEntryResponse readLinkedEntryResponse = null;
        ErrorResponse errorResponse = null;

        String jsonRequest = new String();
        String jsonResponse = new String();

        ObjectMapper mapper = JsonObjectMapper.getMapper();

        try {
            Map<String, Object> requestData = new LinkedHashMap<String, Object>();
            requestData.put("session", sessionId);
            requestData.put("module_name", moduleName);
            requestData.put("id", identifier);
            requestData.put("select_fields", selectFields);
            boolean linkedInfoNotSet = ((linkedSelectFields == null) || (linkedSelectFields.size() == 0));
            requestData.put("link_name_to_fields_array",  linkedInfoNotSet ? StringUtils.EMPTY : linkedSelectFields);
            requestData.put("track_view", false);

            String jsonRequestData = mapper.writeValueAsString(requestData);

            Map<String, Object> request = new LinkedHashMap<String, Object>();
            request.put("method", "get_entry");
            request.put("input_type", "json");
            request.put("response_type", "json");
            request.put("rest_data", requestData);

            jsonRequest = mapper.writeValueAsString(request);

            request.put("rest_data", jsonRequestData);

            HttpResponse response = Unirest.post(url)
                    .fields(request)
                    .asString();

            if (response == null) {
                readLinkedEntryResponse = new ReadLinkedEntryResponse();
                errorResponse = ErrorResponse.format("An error has occurred!", "No data returned.");
                readLinkedEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
                readLinkedEntryResponse.setError(errorResponse);
            } else {

                jsonResponse = response.getBody().toString();

                if (StringUtils.isNotBlank(jsonResponse)) {
                    // First check if we have an error
                    errorResponse = ErrorResponse.fromJson(jsonResponse);
                    if (errorResponse == null) {
                        readLinkedEntryResponse = mapper.readValue(jsonResponse, ReadLinkedEntryResponse.class);
                    }
                }

                if (readLinkedEntryResponse == null) {
                    readLinkedEntryResponse = new ReadLinkedEntryResponse();
                    readLinkedEntryResponse.setError(errorResponse);

                    readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK);
                    if (errorResponse != null) {
                        readLinkedEntryResponse.setStatusCode(errorResponse.getStatusCode());
                    }
                } else {
                    readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK);
                }
            }
        }
        catch (Exception exception) {
            readLinkedEntryResponse = new ReadLinkedEntryResponse();
            errorResponse = ErrorResponse.format(exception, exception.getMessage());
            readLinkedEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
            errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
            readLinkedEntryResponse.setError(errorResponse);
        }

        readLinkedEntryResponse.setJsonRawRequest(jsonRequest);
        readLinkedEntryResponse.setJsonRawResponse(jsonResponse);

        return readLinkedEntryResponse;
    }
}


text:
'use strict';
const mame2json = require('./');

console.log("Playground");

mame2json.listFull()
    .then((result) => {

        console.log(result);

    }, (error) => {

        console.error(error);

    });


text:
module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Chronopay
        autoload :Return, 'active_merchant/billing/integrations/chronopay/return.rb'
        autoload :Helper, 'active_merchant/billing/integrations/chronopay/helper.rb'
        autoload :Notification, 'active_merchant/billing/integrations/chronopay/notification.rb'

        mattr_accessor :service_url
        self.service_url = 'https://secure.chronopay.com/index_shop.cgi'

        def self.notification(post)
          Notification.new(post)
        end

        def self.return(query_string, options = {})
          Return.new(query_string)
        end
      end
    end
  end
end


text:
package com.anrikuwen.videoplayer.View;

import android.os.Bundle;

/**
 * Created by 10393 on 2017/5/19.
 */

public interface IPlayActivity {
    void seekBarAndTimeUpdate(int currentTime,int duration,String time,String name);
    void playOrPauseUpdate(boolean isPlaying);
    void hide();
    void appear();
}