text:
package net.spy.memcached.bulkoperation;

import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import junit.framework.Assert;
import net.spy.memcached.collection.BaseIntegrationTest;
import net.spy.memcached.collection.CollectionAttributes;
import net.spy.memcached.ops.CollectionOperationStatus;

public class SopInsertBulkTest extends BaseIntegrationTest {

  private String KEY = SopInsertBulkTest.class.getSimpleName();

  public void testInsertAndGet() {
    String value = "MyValue";
    int keySize = 500;
    String[] keys = new String[keySize];
    for (int i = 0; i < keys.length; i++) {
      keys[i] = KEY + i;
    }

    try {
      // REMOVE
      for (String key : keys) {
        mc.asyncSopDelete(key, value, true).get();
      }

      // SET
      Future<Map<String, CollectionOperationStatus>> future = mc
              .asyncSopInsertBulk(Arrays.asList(keys), value,
                      new CollectionAttributes());
      try {
        Map<String, CollectionOperationStatus> errorList = future.get(
                100L, TimeUnit.MILLISECONDS);
        Assert.assertTrue("Error list is not empty.",
                errorList.isEmpty());
      } catch (TimeoutException e) {
        future.cancel(true);
        e.printStackTrace();
        Assert.fail(e.getMessage());
      }

      // GET
      int errorCount = 0;
      for (String key : keys) {
        Future<Set<Object>> f = mc.asyncSopGet(key, 1, false, false);
        Set<Object> cachedList = null;
        try {
          cachedList = f.get();
        } catch (Exception e) {
          f.cancel(true);
          e.printStackTrace();
          Assert.fail(e.getMessage());
        }

        Assert.assertTrue("Cached list is empty.",
                !cachedList.isEmpty());

        for (Object o : cachedList) {
          if (!value.equals(o)) {
            errorCount++;
          }
        }
      }
      Assert.assertEquals("Error count is greater than 0.", 0, errorCount);

      // REMOVE
      for (String key : keys) {
        mc.asyncSopDelete(key, value, true).get();
      }
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }
  }

  public void testErrorCount() {
    String value = "MyValue";
    int keySize = 1200;

    String[] keys = new String[keySize];

    try {
      for (int i = 0; i < keys.length; i++) {
        keys[i] = KEY + i;
        mc.delete(keys[i]).get();
      }

      // SET
      Future<Map<String, CollectionOperationStatus>> future = mc
              .asyncSopInsertBulk(Arrays.asList(keys), value, null);

      Map<String, CollectionOperationStatus> map = future.get(1000L,
              TimeUnit.MILLISECONDS);
      assertEquals(keySize, map.size());

    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail("ERROR");
    }
  }
}


text:
const IncomingWebhook = require('@slack/client').IncomingWebhook;
const SLACK_WEBHOOK_URL = "https://hooks.slack.com/services/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"

const webhook = new IncomingWebhook(SLACK_WEBHOOK_URL);

// subscribe is the main function called by Cloud Functions.
module.exports.subscribe = (event, callback) => {
 const build = eventToBuild(event.data.data);

// Skip if the current status is not in the status list.
// Add additional statues to list if you'd like:
// QUEUED, WORKING, SUCCESS, FAILURE,
// INTERNAL_ERROR, TIMEOUT, CANCELLED
  const status = ['SUCCESS', 'FAILURE', 'INTERNAL_ERROR', 'TIMEOUT'];
  if (status.indexOf(build.status) === -1) {
    return callback();
  }

  // Send message to Slack.
  const message = createSlackMessage(build);
  webhook.send(message, callback);
};

// eventToBuild transforms pubsub event message to a build object.
const eventToBuild = (data) => {
  return JSON.parse(new Buffer(data, 'base64').toString());
}

// createSlackMessage create a message from a build object.
const createSlackMessage = (build) => {
  let message = {
   text: 'Build `' + build.id + '`',
    mrkdwn: true,
    attachments: [
      {
        title: 'Build logs',
        title_link: build.logUrl,
        fields: [{
          title: 'Status',
          value: build.status
        }]
      }
    ]
  };
  return message
}

redpajama_set_name: RedPajamaGithub


text:
from openmdao.main.api import Component
from openmdao.lib.datatypes.api import Float, Array, Bool
from fusedwind.interface import base

@base
class TowerFromCSProps(Component):

    # cross-sectional data along tower.
    z = Array(iotype='in', units='m', desc='location along tower.  start at bottom at go to top.')
    Az = Array(iotype='in', units='m**2', desc='cross-sectional area')
    Asx = Array(iotype='in', units='m**2', desc='x shear area')
    Asy = Array(iotype='in', units='m**2', desc='y shear area')
    Jz = Array(iotype='in', units='m**4', desc='polar moment of inertia')
    Ixx = Array(iotype='in', units='m**4', desc='area moment of inertia about x-axis')
    Iyy = Array(iotype='in', units='m**4', desc='area moment of inertia about y-axis')

    # material properties along tower.
    E = Array(iotype='in', units='N/m**2', desc='modulus of elasticity')
    G = Array(iotype='in', units='N/m**2', desc='shear modulus')
    rho = Array(iotype='in', units='kg/m**3', desc='material density')
    sigma_y = Array(iotype='in', units='N/m**2', desc='yield stress')

    # locations where stress should be evaluated
    theta_stress = Array(iotype='in', units='deg', desc='location along azimuth where stress should be evaluated.  0 corresponds to +x axis.  follows unit circle direction and c.s.')

    # spring reaction data.  Use float('inf') for rigid constraints.
    kidx = Array(iotype='in', desc='indices of z where external stiffness reactions should be applied.')
    kx = Array(iotype='in', units='m', desc='spring stiffness in x-direction')
    ky = Array(iotype='in', units='m', desc='spring stiffness in y-direction')
    kz = Array(iotype='in', units='m', desc='spring stiffness in z-direction')
    ktx = Array(iotype='in', units='m', desc='spring stiffness in theta_x-rotation')
    kty = Array(iotype='in', units='m', desc='spring stiffness in theta_y-rotation')
    ktz = Array(iotype='in', units='m', desc='spring stiffness in theta_z-rotation')

    # extra mass
    midx = Array(iotype='in', desc='indices where added mass should be applied.')
    m = Array(iotype='in', units='kg', desc='added mass')
    mIxx = Array(iotype='in', units='kg*m**2', desc='x mass moment of inertia about some point p')
    mIyy = Array(iotype='in', units='kg*m**2', desc='y mass moment of inertia about some point p')
    mIzz = Array(iotype='in', units='kg*m**2', desc='z mass moment of inertia about some point p')
    mIxy = Array(iotype='in', units='kg*m**2', desc='xy mass moment of inertia about some point p')
    mIxz = Array(iotype='in', units='kg*m**2', desc='xz mass moment of inertia about some point p')
    mIyz = Array(iotype='in', units='kg*m**2', desc='yz mass moment of inertia about some point p')
    mrhox = Array(iotype='in', units='m', desc='x-location of p relative to node')
    mrhoy = Array(iotype='in', units='m', desc='y-location of p relative to node')
    mrhoz = Array(iotype='in', units='m', desc='z-location of p relative to node')
    addGravityLoadForExtraMass = Bool(True, iotype='in', desc='add gravitational load')

    # gravitational load
    g = Float(9.81, iotype='in', units='m/s**2', desc='acceleration of gravity (magnitude)')

    # point loads (if addGravityLoadForExtraMass=True be sure not to double count by adding those force here also)
    plidx = Array(iotype='in', desc='indices where point loads should be applied.')
    Fx = Array(iotype='in', units='N', desc='point force in x-direction')
    Fy = Array(iotype='in', units='N', desc='point force in y-direction')
    Fz = Array(iotype='in', units='N', desc='point force in z-direction')
    Mxx = Array(iotype='in', units='N*m', desc='point moment about x-axis')
    Myy = Array(iotype='in', units='N*m', desc='point moment about y-axis')
    Mzz = Array(iotype='in', units='N*m', desc='point moment about z-axis')

    # distributed loads
    Px   = Array(iotype='in', units='N/m', desc='force per unit length in x-direction')
    Py   = Array(iotype='in', units='N/m', desc='force per unit length in y-direction')
    Pz   = Array(iotype='in', units='N/m', desc='force per unit length in z-direction')
    qdyn = Array(iotype='in', units='N/m**2', desc='dynamic pressure')

    # safety factors
    gamma_f = Float(1.35, iotype='in', desc='safety factor on loads')
    gamma_m = Float(1.1, iotype='in', desc='safety factor on materials')
    gamma_n = Float(1.0, iotype='in', desc='safety factor on consequence of failure')

    # outputs
    mass = Float(iotype='out')
    f1 = Float(iotype='out', units='Hz', desc='First natural frequency')
    f2 = Float(iotype='out', units='Hz', desc='Second natural frequency')
    top_deflection = Float(iotype='out', units='m', desc='Deflection of tower top in yaw-aligned +x direction')
    stress = Array(iotype='out', units='N/m**2', desc='Von Mises stress utilization along tower at specified locations.  incudes safety factor.')


text:
require "helper"

module Nokogiri
  module XML
    class TestDocumentFragment < Nokogiri::TestCase
      def setup
        super
        @xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
      end

      def test_replace_text_node
        html = "foo"
        doc = Nokogiri::XML::DocumentFragment.parse(html)
        doc.children[0].replace "bar"
        assert_equal 'bar', doc.children[0].content
      end

      def test_fragment_is_relative
        doc      = Nokogiri::XML('<root></root>')
        ctx      = doc.root.child
        fragment = Nokogiri::XML::DocumentFragment.new(doc, '<hello />', ctx)
        hello    = fragment.child

        assert_equal 'hello', hello.name
        assert_equal doc.root.child.namespace, hello.namespace
      end

      def test_node_fragment_is_relative
        doc      = Nokogiri::XML('<root></root>')
        assert doc.root.child
        fragment = doc.root.child.fragment('<hello />')
        hello    = fragment.child

        assert_equal 'hello', hello.name
        assert_equal doc.root.child.namespace, hello.namespace
      end

      def test_new
        assert Nokogiri::XML::DocumentFragment.new(@xml)
      end

      def test_fragment_should_have_document
        fragment = Nokogiri::XML::DocumentFragment.new(@xml)
        assert_equal @xml, fragment.document
      end

      def test_name
        fragment = Nokogiri::XML::DocumentFragment.new(@xml)
        assert_equal '#document-fragment', fragment.name
      end

      def test_static_method
        fragment = Nokogiri::XML::DocumentFragment.parse("
a
")
        assert_instance_of Nokogiri::XML::DocumentFragment, fragment
      end

      def test_static_method_with_namespaces
        # follows different path in FragmentHandler#start_element which blew up after 597195ff
        fragment = Nokogiri::XML::DocumentFragment.parse("<o:div>a</o:div>")
        assert_instance_of Nokogiri::XML::DocumentFragment, fragment
      end

      def test_many_fragments
        100.times { Nokogiri::XML::DocumentFragment.new(@xml) }
      end

      def test_subclass
        klass = Class.new(Nokogiri::XML::DocumentFragment)
        fragment = klass.new(@xml, "
a
")
        assert_instance_of klass, fragment
      end

      def test_subclass_parse
        klass = Class.new(Nokogiri::XML::DocumentFragment)
        doc = klass.parse("
a
")
        assert_instance_of klass, doc
      end

      def test_unparented_text_node_parse
        fragment = Nokogiri::XML::DocumentFragment.parse("foo")
        fragment.children.after("<bar/>")
      end

      def test_xml_fragment
        fragment = Nokogiri::XML.fragment("
a
")
        assert_equal "
a
", fragment.to_s
      end

      def test_xml_fragment_has_multiple_toplevel_children
        doc = "
b

e
"
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "
b

e
", fragment.to_s
      end

      def test_xml_fragment_has_outer_text
        # this test is descriptive, not prescriptive.
        doc = "a
b
"
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "a
b
", fragment.to_s

        doc = "
b
c"
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "
b
c", fragment.to_s
      end

      def test_xml_fragment_case_sensitivity
        doc = "<crazyDiv>b</crazyDiv>"
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "<crazyDiv>b</crazyDiv>", fragment.to_s
      end

      def test_xml_fragment_with_leading_whitespace
        doc = "
b
  "
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "
b
  ", fragment.to_s
      end

      def test_xml_fragment_with_leading_whitespace_and_newline
        doc = "     \n
b
  "
        fragment = Nokogiri::XML::Document.new.fragment(doc)
        assert_equal "     \n
b
  ", fragment.to_s
      end

      def test_fragment_children_search
        fragment = Nokogiri::XML::Document.new.fragment(
          '

hi

'
        )
        expected = fragment.children.xpath('.//p')
        assert_equal 1, expected.length

        css          = fragment.children.css('p')
        search_css   = fragment.children.search('p')
        search_xpath = fragment.children.search('.//p')
        assert_equal expected, css
        assert_equal expected, search_css
        assert_equal expected, search_xpath
      end

      def test_fragment_css_search_with_whitespace_and_node_removal
        # The same xml without leading whitespace in front of the first line
        # does not expose the error. Putting both nodes on the same line
        # instead also fixes the crash.
        fragment = Nokogiri::XML::DocumentFragment.parse <<-EOXML

hi
 x
another paragraph

        EOXML
        children = fragment.css('p')
        assert_equal 2, children.length
        # removing the last node instead does not yield the error. Probably the
        # node removal leaves around two consecutive text nodes which make the
        # css search crash?
        children.first.remove
        assert_equal 1, fragment.xpath('.//p | self::p').length
        assert_equal 1, fragment.css('p').length
      end

      def test_fragment_search_three_ways
        frag = Nokogiri::XML::Document.new.fragment '
foo

bar
'
        expected = frag.xpath('./*[@id = "content"]')
        assert_equal 2, expected.length

        [
          [:css, '#content'],
          [:search, '#content'],
          [:search, './*[@id = \'content\']'],
        ].each do |method, query|
          result = frag.send(method, query)
          assert_equal(expected, result,
            "fragment search with :#{method} using '#{query}' expected '#{expected}' got '#{result}'")
        end
      end

      def test_fragment_search_with_multiple_queries
        xml = '<thing>

important thing

               </thing>
               <thing>

stuff

               </thing>
               <thing>

more stuff

               </thing>'
        fragment = Nokogiri::XML.fragment(xml)
        assert_kind_of Nokogiri::XML::DocumentFragment, fragment

        assert_equal 3, fragment.xpath('.//div', './/p').length
        assert_equal 3, fragment.css('.title', '.content', 'p').length
        assert_equal 3, fragment.search('.//div', 'p.blah').length
      end

      def test_fragment_without_a_namespace_does_not_get_a_namespace
        doc = Nokogiri::XML <<-EOX
          <root xmlns="http://tenderlovemaking.com/" xmlns:foo="http://flavorjon.es/" xmlns:bar="http://google.com/">
            <foo:existing></foo:existing>
          </root>
        EOX
        frag = doc.fragment "<newnode></newnode>"
        assert_nil frag.namespace
      end

      def test_fragment_namespace_resolves_against_document_root
        doc = Nokogiri::XML <<-EOX
          <root xmlns:foo="http://flavorjon.es/" xmlns:bar="http://google.com/">
            <foo:existing></foo:existing>
          </root>
        EOX
        ns = doc.root.namespace_definitions.detect { |x| x.prefix == "bar" }

        frag = doc.fragment "<bar:newnode></bar:newnode>"
        assert frag.children.first.namespace
        assert_equal ns, frag.children.first.namespace
      end

      def test_fragment_invalid_namespace_is_silently_ignored
        doc = Nokogiri::XML <<-EOX
          <root xmlns:foo="http://flavorjon.es/" xmlns:bar="http://google.com/">
            <foo:existing></foo:existing>
          </root>
        EOX
        frag = doc.fragment "<baz:newnode></baz:newnode>"
        assert_nil frag.children.first.namespace
      end

      def test_decorator_is_applied
        x = Module.new do
          def awesome!
          end
        end
        util_decorate(@xml, x)
        fragment = Nokogiri::XML::DocumentFragment.new(@xml, "
a

b
")

        assert node_set = fragment.css('div')
        assert node_set.respond_to?(:awesome!)
        node_set.each do |node|
          assert node.respond_to?(:awesome!), node.class
        end
        assert fragment.children.respond_to?(:awesome!), fragment.children.class
      end

      def test_decorator_is_applied_to_empty_set
        x = Module.new do
          def awesome!
          end
        end
        util_decorate(@xml, x)
        fragment = Nokogiri::XML::DocumentFragment.new(@xml, "")
        assert fragment.children.respond_to?(:awesome!), fragment.children.class
      end

      def test_add_node_to_doc_fragment_segfault
        frag = Nokogiri::XML::DocumentFragment.new(@xml, '
hello world
')
        Nokogiri::XML::Comment.new(frag,'moo')
      end

      def test_issue_1077_parsing_of_frozen_strings
        input = <<-EOS
<?xml version="1.0" encoding="utf-8"?>
<library>
  <book title="I like turtles"/>
</library>
EOS
        input.freeze

        Nokogiri::XML::DocumentFragment.parse(input) # assert_nothing_raised
      end

      if Nokogiri.uses_libxml?
        def test_for_libxml_in_context_fragment_parsing_bug_workaround
          10.times do
            begin
              fragment = Nokogiri::XML.fragment("

")
              parent = fragment.children.first
              child = parent.parse("

").first
              parent.add_child child
            end
            GC.start
          end
        end

        def test_for_libxml_in_context_memory_badness_when_encountering_encoding_errors
          # see issue #643 for background
          # this test exists solely to raise an error during valgrind test runs.
          html = <<-EOHTML

    <meta http-equiv="Content-Type" content="text/html; charset=shizzle" />

Foo

EOHTML
          doc = Nokogiri::HTML html
          doc.at_css("div").replace("Bar")
        end
      end
    end
  end
end


text:
Docker Workshop - Demo 3
========================

Docker workshop - Second Nerd Floripa meetup!


text:
begin
  Capistrano::Configuration.instance.load do
    namespace :monit do
      desc "Installing monit"
      task :install do
        chelpers.apt_install 'monit'
      end
    end
  end
rescue
end


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>JSDoc: Source: lib/test-helpers.js</title>

    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">

Source: lib/test-helpers.js

/**
 * ### Test helpers
 *
 * This module hosts everything needed for tests.
 * Abstraction over the expection engine, abstraction over the basic functions,
 * this module is the Test Toolbelt.
 * Little to no test framework logic should be in unit tests to keep them
 * focused on code documentation.
 *
 * @module Library/Test-Helpers
 */
"use strict";

const path = require("path");

const lodash = require("lodash/fp");
const BPromise = require("bluebird");

const tape = require("blue-tape");
const sinon = require("sinon");
const proxyquire = require("proxyquire").noPreserveCache().noCallThru();

/**
 * @name unitTest
 * @function
 * @description Returns a curried function that will execute a test with
 * a description pre fed by the parent test block
 * @curried
 * @private
 * @param {Function} testFn - Test engine
 * @param {String} blockDescription - Parent block description
 * @param {String} testDescription - This Test description
 * @param {Function} cb - Callback called with test engine object
 * @return {Function} Atomic test handler
 */
exports.unitTest = lodash.curry(
    function unitTest(testFn, blockDescription, testDescription, cb) {
        return testFn(`${blockDescription} : ${testDescription}`, cb);
    });

/**
 * Returns a function that will execute several tests with a concatenated
 * description
 * @public
 * @param {String} parentBlockDescription - Parent block description
 * @param {String} [blockDescription] - This test block description
 * @param {Function} cb - Callback
 * @return {Function} Test block handler
 */
exports.t = function t(parentBlockDescription, blockDescription, cb) {
    let cb2;
    let msg;
    if (lodash.isFunction(blockDescription)) {
        cb2 = blockDescription;
        msg = parentBlockDescription;
    } else {
        cb2 = cb;
        msg = `${parentBlockDescription} - ${blockDescription}`;
    }
    const newTestBlock = (b, c) => exports.t(msg, b, c);
    newTestBlock.test = exports.unitTest(tape, msg);
    newTestBlock.skip = exports.unitTest(tape.skip, msg);
    newTestBlock.only = exports.unitTest(tape.only, msg);
    return cb2(newTestBlock);
};

/**
 * Identity function
 * @param {Mixed} input - Value to be returned
 * @return {Mixed} Same as input
 */
exports.idFn = function idFn(input) {
    return input;
};

/**
 * Returns null
 * @return {Null} Null
 */
exports.nullFn = function nullFn() {
    return null;
};

/**
 * Returns a function that returns null
 * @return {Function} Function that returns null
 */
exports.nullFnHO = function nullFnHO() {
    return () => exports.nullFn();
};

/**
 * Throws an Error
 * @param {String} error - Error message
 * @return {Error} Error thrown
 */
exports.throwFn = function throwFn(error) {
    throw new Error(error);
};

/**
 * Returns a function that throws an Error
 * @param {String} error - Error message
 * @return {Function} Function that throws an error
 */
exports.throwFnHO = function throwFnHO(error) {
    return () => exports.throwFn(error);
};

/**
 * Returns a resolved Promise
 * @param {String} value - Resolved value
 * @return {Promise<Mixed>} Promise resoved with given value
 */
exports.resolveFn = function resolveFn(value) {
    return BPromise.resolve(value);
};

/**
 * Returns a function that return a resolved Promise with given value
 * @param  {String} value - Resolved value
 * @return {Function} Function that returns a resolved Promise with given value
 */
exports.resolveFnHO = function resolveFnHO(value) {
    return () => exports.resolveFn(value);
};

/**
 * Returns a rejected Promise
 * @param  {String} reason - Rejection reason
 * @return {Promise<Mixed>} Promise rejected with given reason
 */
exports.rejectFn = function rejectFn(reason) {
    return BPromise.reject(reason);
};

/*
 * Returns a function that return a rejected Promise with given reason
 * @param  {String} reason - Rejection reason
 * @return {Function} Function that return a rejected Promise with given reason
 */
//exports.rejectFnHO = function rejectFnHO(reason) {
//return () => exports.rejectFn(reason);
//};

// Module names, based on project root, to ensure consistency across tests
exports.config = path.resolve("src/config");
exports.utils = path.resolve("src/lib/utils");
exports.middlewareLoader = path.resolve("src/lib/middlewares");
exports.swaggerUI = "swagger-tools/middleware/swagger-ui";

// Default stubs that will be used across tests
// Mixed new dependency must be added here to be stubbed
const defaultStubs = {

    // External dependencies
    path: path,
    lodash: lodash,
    tape: {
        "@noCallThru": true
    },
    proxyquire: proxyquire,
    express: {
        "@noCallThru": true
    }
};
// Internal dependencies
defaultStubs[exports.config] = {
    "@noCallThru": true
};
defaultStubs[exports.utils] = {
    "@noCallThru": true
};
defaultStubs[exports.middlewareLoader] = {
    "@noCallThru": true
};
defaultStubs[exports.swaggerUI] = {
    "@noCallThru": true
};

/**
 * @name prepareStubs
 * @function
 * @description Require a proxified module with defaultStubs,
 * eventually overloaded with custom stubs
 * @curried
 * @param {String} moduleName - Proxified module name
 * @param {Object} customStubs - Custom stubs for the proxified module
 * @return {Mixed} Required proxified module
 */
exports.prepareStubs = lodash.curry(
    function prepareStubs(moduleName, customStubs) {
        return proxyquire(moduleName, lodash.flow(
            lodash.merge(exports.convertIntoComputedProperties(customStubs)),
            lodash.merge(defaultStubs)
        )({}));
    });

// Default that will be used for factories
// Mixed new dependency must be added here to be stubbed
const defaultContext = {
    utils: {
        getLogger: exports.nullFnHO
    }
};

/**
 * Convert an object into another object with computed properties by using the given
 * object properties names as variables declared in this module
 * For example, given an object { a: "foo", b: "bar" }
 * this function will return an object { [a]: "foo", [b]: "bar" } with a and b
 * eventually defined as variables in this module.
 * If they are not defined, this function will assume that they refer to node
 * modules instead of local ones.
 *
 * @param  {Object} object - Input object
 * @return {Object} Converted object
 */
exports.convertIntoComputedProperties = function convertIntoComputedProperties(object) {
    const newObj = {};
    const keys = lodash.keys(object);
    lodash.map(function(property) {
            if (exports[property]) {
                newObj[exports[property]] = object[property];
            } else {
                newObj[property] = object[property];
            }
        },
        keys
    );
    return newObj;
};

/**
 * @name prepareInstance
 * @function
 * @description Require a module and create an instance with defaultStubs,
 * eventually overloaded wit custom context
 * @curried
 * @param {String} moduleName - Module name
 * @param {Object} customContext - Custom context for the module factory
 * @return {Mixed} Required module instance
 */
exports.prepareInstance = lodash.curry(
    function prepareInstance(moduleName, customContext) {
        return require(moduleName).factory(lodash.flow(
            lodash.merge(customContext),
            lodash.merge(defaultContext)
        )({}));
    });

// Abstract Sinon.js in tests
exports.stub = sinon.stub;
exports.spy = sinon.spy;

/**
 * Create an Express-like response mock
 * @return {Object} Response mock
 */
exports.createResponseMock = function createResponseMock() {
    const response = {};
    response.status = function(status) {
        response.status = status;
        return response;
    };
    response.json = function(body) {
        response.body = body;
        return response;
    };
    return response;
};

Home

Modules

API/Controllers/Entities

Configuration/Default

Configuration/Environment

Configuration/Loader

Library/Test-Helpers

Library/Utilities

Main

Middlewares/404

Middlewares/Error

Middlewares/Loader

Middlewares/Swagger-UI

    Documentation generated by JSDoc 3.4.0 on Wed Jun 08 2016 17:44:54 GMT+0200 (CEST)


text:
package org.apache.spark.broadcast

import java.io._
import java.net._
import java.util.Random

import scala.collection.mutable.Map

import org.apache.spark._
import org.apache.spark.util.Utils

private object MultiTracker
extends Logging {

  // Tracker Messages
  val REGISTER_BROADCAST_TRACKER = 0
  val UNREGISTER_BROADCAST_TRACKER = 1
  val FIND_BROADCAST_TRACKER = 2

  // Map to keep track of guides of ongoing broadcasts
  var valueToGuideMap = Map[Long, SourceInfo]()

  // Random number generator
  var ranGen = new Random

  private var initialized = false
  private var _isDriver = false

  private var stopBroadcast = false

  private var trackMV: TrackMultipleValues = null

  def initialize(__isDriver: Boolean) {
    synchronized {
      if (!initialized) {
        _isDriver = __isDriver

        if (isDriver) {
          trackMV = new TrackMultipleValues
          trackMV.setDaemon(true)
          trackMV.start()

          // Set DriverHostAddress to the driver's IP address for the slaves to read
          System.setProperty("spark.MultiTracker.DriverHostAddress", Utils.localIpAddress)
        }

        initialized = true
      }
    }
  }

  def stop() {
    stopBroadcast = true
  }

  // Load common parameters
  private var DriverHostAddress_ = System.getProperty(
    "spark.MultiTracker.DriverHostAddress", "")
  private var DriverTrackerPort_ = System.getProperty(
    "spark.broadcast.driverTrackerPort", "11111").toInt
  private var BlockSize_ = System.getProperty(
    "spark.broadcast.blockSize", "4096").toInt * 1024
  private var MaxRetryCount_ = System.getProperty(
    "spark.broadcast.maxRetryCount", "2").toInt

  private var TrackerSocketTimeout_ = System.getProperty(
    "spark.broadcast.trackerSocketTimeout", "50000").toInt
  private var ServerSocketTimeout_ = System.getProperty(
    "spark.broadcast.serverSocketTimeout", "10000").toInt

  private var MinKnockInterval_ = System.getProperty(
    "spark.broadcast.minKnockInterval", "500").toInt
  private var MaxKnockInterval_ = System.getProperty(
    "spark.broadcast.maxKnockInterval", "999").toInt

  // Load TreeBroadcast config params
  private var MaxDegree_ = System.getProperty(
    "spark.broadcast.maxDegree", "2").toInt

  // Load BitTorrentBroadcast config params
  private var MaxPeersInGuideResponse_ = System.getProperty(
    "spark.broadcast.maxPeersInGuideResponse", "4").toInt

  private var MaxChatSlots_ = System.getProperty(
    "spark.broadcast.maxChatSlots", "4").toInt
  private var MaxChatTime_ = System.getProperty(
    "spark.broadcast.maxChatTime", "500").toInt
  private var MaxChatBlocks_ = System.getProperty(
    "spark.broadcast.maxChatBlocks", "1024").toInt

  private var EndGameFraction_ = System.getProperty(
      "spark.broadcast.endGameFraction", "0.95").toDouble

  def isDriver = _isDriver

  // Common config params
  def DriverHostAddress = DriverHostAddress_
  def DriverTrackerPort = DriverTrackerPort_
  def BlockSize = BlockSize_
  def MaxRetryCount = MaxRetryCount_

  def TrackerSocketTimeout = TrackerSocketTimeout_
  def ServerSocketTimeout = ServerSocketTimeout_

  def MinKnockInterval = MinKnockInterval_
  def MaxKnockInterval = MaxKnockInterval_

  // TreeBroadcast configs
  def MaxDegree = MaxDegree_

  // BitTorrentBroadcast configs
  def MaxPeersInGuideResponse = MaxPeersInGuideResponse_

  def MaxChatSlots = MaxChatSlots_
  def MaxChatTime = MaxChatTime_
  def MaxChatBlocks = MaxChatBlocks_

  def EndGameFraction = EndGameFraction_

  class TrackMultipleValues
  extends Thread with Logging {
    override def run() {
      var threadPool = Utils.newDaemonCachedThreadPool("Track multiple values")
      var serverSocket: ServerSocket = null

      serverSocket = new ServerSocket(DriverTrackerPort)
      logInfo("TrackMultipleValues started at " + serverSocket)

      try {
        while (!stopBroadcast) {
          var clientSocket: Socket = null
          try {
            serverSocket.setSoTimeout(TrackerSocketTimeout)
            clientSocket = serverSocket.accept()
          } catch {
            case e: Exception => {
              if (stopBroadcast) {
                logInfo("Stopping TrackMultipleValues...")
              }
            }
          }

          if (clientSocket != null) {
            try {
              threadPool.execute(new Thread {
                override def run() {
                  val oos = new ObjectOutputStream(clientSocket.getOutputStream)
                  oos.flush()
                  val ois = new ObjectInputStream(clientSocket.getInputStream)

                  try {
                    // First, read message type
                    val messageType = ois.readObject.asInstanceOf[Int]

                    if (messageType == REGISTER_BROADCAST_TRACKER) {
                      // Receive Long
                      val id = ois.readObject.asInstanceOf[Long]
                      // Receive hostAddress and listenPort
                      val gInfo = ois.readObject.asInstanceOf[SourceInfo]

                      // Add to the map
                      valueToGuideMap.synchronized {
                        valueToGuideMap += (id -> gInfo)
                      }

                      logInfo ("New broadcast " + id + " registered with TrackMultipleValues. Ongoing ones: " + valueToGuideMap)

                      // Send dummy ACK
                      oos.writeObject(-1)
                      oos.flush()
                    } else if (messageType == UNREGISTER_BROADCAST_TRACKER) {
                      // Receive Long
                      val id = ois.readObject.asInstanceOf[Long]

                      // Remove from the map
                      valueToGuideMap.synchronized {
                        valueToGuideMap(id) = SourceInfo("", SourceInfo.TxOverGoToDefault)
                      }

                      logInfo ("Broadcast " + id + " unregistered from TrackMultipleValues. Ongoing ones: " + valueToGuideMap)

                      // Send dummy ACK
                      oos.writeObject(-1)
                      oos.flush()
                    } else if (messageType == FIND_BROADCAST_TRACKER) {
                      // Receive Long
                      val id = ois.readObject.asInstanceOf[Long]

                      var gInfo =
                        if (valueToGuideMap.contains(id)) valueToGuideMap(id)
                        else SourceInfo("", SourceInfo.TxNotStartedRetry)

                      logDebug("Got new request: " + clientSocket + " for " + id + " : " + gInfo.listenPort)

                      // Send reply back
                      oos.writeObject(gInfo)
                      oos.flush()
                    } else {
                      throw new SparkException("Undefined messageType at TrackMultipleValues")
                    }
                  } catch {
                    case e: Exception => {
                      logError("TrackMultipleValues had a " + e)
                    }
                  } finally {
                    ois.close()
                    oos.close()
                    clientSocket.close()
                  }
                }
              })
            } catch {
              // In failure, close socket here; else, client thread will close
              case ioe: IOException => clientSocket.close()
            }
          }
        }
      } finally {
        serverSocket.close()
      }
      // Shutdown the thread pool
      threadPool.shutdown()
    }
  }

  def getGuideInfo(variableLong: Long): SourceInfo = {
    var clientSocketToTracker: Socket = null
    var oosTracker: ObjectOutputStream = null
    var oisTracker: ObjectInputStream = null

    var gInfo: SourceInfo = SourceInfo("", SourceInfo.TxNotStartedRetry)

    var retriesLeft = MultiTracker.MaxRetryCount
    do {
      try {
        // Connect to the tracker to find out GuideInfo
        clientSocketToTracker =
          new Socket(MultiTracker.DriverHostAddress, MultiTracker.DriverTrackerPort)
        oosTracker =
          new ObjectOutputStream(clientSocketToTracker.getOutputStream)
        oosTracker.flush()
        oisTracker =
          new ObjectInputStream(clientSocketToTracker.getInputStream)

        // Send messageType/intention
        oosTracker.writeObject(MultiTracker.FIND_BROADCAST_TRACKER)
        oosTracker.flush()

        // Send Long and receive GuideInfo
        oosTracker.writeObject(variableLong)
        oosTracker.flush()
        gInfo = oisTracker.readObject.asInstanceOf[SourceInfo]
      } catch {
        case e: Exception => logError("getGuideInfo had a " + e)
      } finally {
        if (oisTracker != null) {
          oisTracker.close()
        }
        if (oosTracker != null) {
          oosTracker.close()
        }
        if (clientSocketToTracker != null) {
          clientSocketToTracker.close()
        }
      }

      Thread.sleep(MultiTracker.ranGen.nextInt(
        MultiTracker.MaxKnockInterval - MultiTracker.MinKnockInterval) +
        MultiTracker.MinKnockInterval)

      retriesLeft -= 1
    } while (retriesLeft > 0 && gInfo.listenPort == SourceInfo.TxNotStartedRetry)

    logDebug("Got this guidePort from Tracker: " + gInfo.listenPort)
    return gInfo
  }

  def registerBroadcast(id: Long, gInfo: SourceInfo) {
    val socket = new Socket(MultiTracker.DriverHostAddress, DriverTrackerPort)
    val oosST = new ObjectOutputStream(socket.getOutputStream)
    oosST.flush()
    val oisST = new ObjectInputStream(socket.getInputStream)

    // Send messageType/intention
    oosST.writeObject(REGISTER_BROADCAST_TRACKER)
    oosST.flush()

    // Send Long of this broadcast
    oosST.writeObject(id)
    oosST.flush()

    // Send this tracker's information
    oosST.writeObject(gInfo)
    oosST.flush()

    // Receive ACK and throw it away
    oisST.readObject.asInstanceOf[Int]

    // Shut stuff down
    oisST.close()
    oosST.close()
    socket.close()
  }

  def unregisterBroadcast(id: Long) {
    val socket = new Socket(MultiTracker.DriverHostAddress, DriverTrackerPort)
    val oosST = new ObjectOutputStream(socket.getOutputStream)
    oosST.flush()
    val oisST = new ObjectInputStream(socket.getInputStream)

    // Send messageType/intention
    oosST.writeObject(UNREGISTER_BROADCAST_TRACKER)
    oosST.flush()

    // Send Long of this broadcast
    oosST.writeObject(id)
    oosST.flush()

    // Receive ACK and throw it away
    oisST.readObject.asInstanceOf[Int]

    // Shut stuff down
    oisST.close()
    oosST.close()
    socket.close()
  }

  // Helper method to convert an object to Array[BroadcastBlock]
  def blockifyObject[IN](obj: IN): VariableInfo = {
    val baos = new ByteArrayOutputStream
    val oos = new ObjectOutputStream(baos)
    oos.writeObject(obj)
    oos.close()
    baos.close()
    val byteArray = baos.toByteArray
    val bais = new ByteArrayInputStream(byteArray)

    var blockNum = (byteArray.length / BlockSize)
    if (byteArray.length % BlockSize != 0)
      blockNum += 1

    var retVal = new Array[BroadcastBlock](blockNum)
    var blockID = 0

    for (i <- 0 until (byteArray.length, BlockSize)) {
      val thisBlockSize = math.min(BlockSize, byteArray.length - i)
      var tempByteArray = new Array[Byte](thisBlockSize)
      val hasRead = bais.read(tempByteArray, 0, thisBlockSize)

      retVal(blockID) = new BroadcastBlock(blockID, tempByteArray)
      blockID += 1
    }
    bais.close()

    var variableInfo = VariableInfo(retVal, blockNum, byteArray.length)
    variableInfo.hasBlocks = blockNum

    return variableInfo
  }

  // Helper method to convert Array[BroadcastBlock] to object
  def unBlockifyObject[OUT](arrayOfBlocks: Array[BroadcastBlock],
                            totalBytes: Int,
                            totalBlocks: Int): OUT = {

    var retByteArray = new Array[Byte](totalBytes)
    for (i <- 0 until totalBlocks) {
      System.arraycopy(arrayOfBlocks(i).byteArray, 0, retByteArray,
        i * BlockSize, arrayOfBlocks(i).byteArray.length)
    }
    byteArrayToObject(retByteArray)
  }

  private def byteArrayToObject[OUT](bytes: Array[Byte]): OUT = {
    val in = new ObjectInputStream (new ByteArrayInputStream (bytes)){
      override def resolveClass(desc: ObjectStreamClass) =
        Class.forName(desc.getName, false, Thread.currentThread.getContextClassLoader)
    }
    val retVal = in.readObject.asInstanceOf[OUT]
    in.close()
    return retVal
  }
}

private[spark] case class BroadcastBlock(blockID: Int, byteArray: Array[Byte])
extends Serializable

private[spark] case class VariableInfo(@transient arrayOfBlocks : Array[BroadcastBlock],
                        totalBlocks: Int,
                        totalBytes: Int)
extends Serializable {
 @transient var hasBlocks = 0
}


text:
<!doctype html>

    <meta charset="utf-8">

This is a heading

This is a paragraph.

Test body.


text:
using System.Web.UI.WebControls;

namespace Uncas.EBS.UI.Controls
{
    /// <summary>
    /// Represents a button for updating.
    /// </summary>
    public class UpdateButton : LinkButton
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateButton"/> class.
        /// </summary>
        public UpdateButton()
        {
            this.CommandName = "Update";

            this.Text = Resources.Phrases.Update;
        }
    }
}


text:
exports.names = ['!lastplayed'];
exports.hidden = false;
exports.enabled = false;
exports.matchStart = false;
exports.handler = function (data) {
    //db.get('SELECT username, started, upvotes, downvotes, snags FROM (SELECT userid, started, upvotes, downvotes, snags FROM PLAYS WHERE songid = ? AND strftime("%s", datetime("now")) - strftime("%s", started) > 600 ORDER BY started DESC LIMIT 1) a INNER JOIN USERS ON a.userid = USERS.userid', [bot.getMedia().id], function (error, row) {
    //    if (row != null) {
    //        bot.sendChat('This song was last played ' + timeSince(row['started']) + ' by ' + row['username'] + ' (+' + row['upvotes'] + '/' + row['snags'] + '/-' + row['downvotes'] + ')');
    //    } else {
    //        bot.sendChat('This is the first time this song has been played in here.');
    //    }
    //});
};


text:
date: "2017-01-01T16:00:00+02:00"
title: "Usage: Command Line"
slug: "command-line"
weight: 10
toc: true
draft: false
menu:
  sidebar:
    parent: "usage"
    name: "Command Line"
    weight: 10
    identifier: "command-line"
---

## Command Line

### Usage

`gitea [global options] command [command options] [arguments...]`

### Global options
 - `--help`, `-h`: Show help text and exit. Optional. This can be used with any of the
   subcommands to see help text for it.
 - `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version
   1.1.0+218-g7b907ed built with: bindata, sqlite`).

### Commands

#### web

Starts the server:

- Options:
    - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
    - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
    - `--pid path`, `-P path`: Pidfile path. Optional.
- Examples:
    - `gitea web`
    - `gitea web --port 80`
    - `gitea web --config /etc/gitea.ini --pid /var/run/gitea.pid`
- Notes:
    - Gitea should not be run as root. To bind to a port below 1000, you can use setcap on
      Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be
      redone every time you update Gitea.

#### admin

Admin operations:

- Commands:
    - `create-user`
        - Options:
            - `--name value`: Username. Required.
            - `--password value`: Password. Required.
            - `--email value`: Email. Required.
            - `--admin`: If provided, this makes the user an admin. Optional.
            - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
        - Examples:
            - `gitea admin create-user --name myname --password asecurepassword --email me@example.com`
    - `change-password`
        - Options:
            - `--username value`, `-u value`: Username. Required.
            - `--password value`, `-p value`: New password. Required.
            - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
        - Examples:
            - `gitea admin change-password --username myname --password asecurepassword`
    - `regenerate`
        - Options:
            - `hooks`: Regenerate git-hooks for all repositories
            - `keys`: Regenerate authorized_keys file
        - Examples:
            - `gitea admin regenerate hooks`
            - `gitea admin regenerate keys`
    - `auth`:
        - `list`:
            - Description: lists all external authentication sources that exist
            - Options:
                - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
            - Examples:
                - `gitea auth list`
        - `delete`:
            - Options:
                - `--id`: ID of source to be deleted. Required.
                - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
            - Examples:
                - `gitea auth delete --id 1`
        - `add-oauth`:
            - Options:
                - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
                - `--name`: Application Name.
                - `--provider`: OAuth2 Provider.
                - `--key`: Client ID (Key).
                - `--secret`: Client Secret.
                - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
                - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
                - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
                - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
                - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
                - `--custom-email-url`: Use a custom Email URL (option for GitHub).
            - Examples:
                - `gitea auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
        - `update-oauth`:
            - Options:
                - `--id`: ID of source to be updated. Required.
                - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
                - `--name`: Application Name.
                - `--provider`: OAuth2 Provider.
                - `--key`: Client ID (Key).
                - `--secret`: Client Secret.
                - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
                - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
                - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
                - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
                - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
                - `--custom-email-url`: Use a custom Email URL (option for GitHub).
            - Examples:
                - `gitea auth update-oauth --id 1 --name external-github-updated`

#### cert

Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
directory and will overwrite any existing files.

- Options:
    - `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
      Wildcards are supported. Required.
    - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
      are P224, P256, P384, P521.
    - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
      set. (default: 2048).
    - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
    - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
    - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
- Examples:
    - `gitea cert --host git.example.com,example.com,www.example.com --ca`

#### dump

Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
in the current directory.

- Options:
    - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
    - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
    - `--verbose`, `-v`: If provided, shows additional details. Optional.
- Examples:
    - `gitea dump`
    - `gitea dump --verbose`

#### generate

Generates random values and tokens for usage in configuration file. Useful for generating values
for automatic deployments.

- Commands:
    - `secret`:
        - Options:
            - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
            - `LFS_JWT_SECRET`: LFS authentication secret.
            - `SECRET_KEY`: Global secret key.
        - Examples:
            - `gitea generate secret INTERNAL_TOKEN`
            - `gitea generate secret LFS_JWT_SECRET`
            - `gitea generate secret SECRET_KEY`

#### keys

Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:

```ini
...
# The value of -e and the AuthorizedKeysCommandUser should match the
# username running gitea
AuthorizedKeysCommandUser git
AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
```

The command will return the appropriate authorized_keys line for the
provided key. You should also set the value
`SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
`app.ini`.

NB: opensshd requires the gitea program to be owned by root and not
writable by group or others. The program must be specified by an absolute
path.


text:
define(['models/user.model', 'setting', 'util/const'], function(_User, _Set, _Const) {
  return new (function () {
    this.reg = function(_opt) {
      if (!_opt.email || !_opt.password) {
        return false;
      }
      var default_opt = {
        if_username_already_exists: _Const.blank_function,
        if_error: _Const.blank_function
      };
      var option = $.extend({}, default_opt, _opt);
      var u = new _User({
        email: option.email,
        password: option.password,
        nick_name: option.nick_name
      });
      u.reg(function(res) {
        if (res.result_id == _Set.sso_result_id.result_ok) {
          window.location = res.callbackpage; return;
        }
        else if (res.result_id == _Set.sso_result_id.result_username_already_exists) {
          option.if_username_already_exists(); return;
        }
        else {
          option.if_error(); return;
        }
      }, this);
    };

    this.login = function(_opt) {
      if (!_opt.email || !_opt.password) {
        return false;
      }
      var default_opt = {
        if_username_not_exists: _Const.blank_function,
        if_password_not_correct: _Const.blank_function,
        if_error: _Const.blank_function
      };
      var option = $.extend({}, default_opt, _opt);
      var u = new _User({
        email: option.email,
        password: option.password
      });
      u.login(function(res) {
        if (res.result_id == _Set.sso_result_id.result_ok) {
          window.location = res.callbackpage; return;
        }
        else if (res.result_id == _Set.sso_result_id.result_username_not_exists) {
          option.if_username_not_exists(); return;
        }
        else if (res.result_id == _Set.sso_result_id.result_password_not_correct) {
          option.if_password_not_correct(); return;
        }
        else {
          option.if_error(); return;
        }
      }, this);
    }

    this.check_user_exists = function(_opt) {
      var default_opt = {
        email: '',
        if_exists: _Const.blank_function,
        if_not_exists: _Const.blank_function,
        if_error: _Const.blank_function
      };

      var _this = this;
      var u = new _User();
      var option = $.extend({}, default_opt, _opt);
      u.get(option.email, function(res) {
        if (res.result_id == _Set.sso_result_id.result_ok) {
          if (res.user) {
            option.if_exists(); return;
          }
          option.if_not_exists(); return;
        }
        option.if_error(); return;
      }, _this);
    };
  })();
});


text:
export interface MinimizeOptions {
  precisionTime: number;
  precisionValue: number;
}


text:
#include <glog/logging.h>
#include <google/protobuf/text_format.h>
#include <lmdb.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fstream>
#include <string>
#include "caffeine/proto/caffe.pb.h"

using namespace caffe;
using namespace std;

string data_path = "/home/zhxfl/purine2/data/mnist/";
/*reverse the int*/
int reverseInt(int i) {
    unsigned char ch1, ch2, ch3, ch4;
    ch1 = i & 255;
    ch2 = (i >> 8) & 255;
    ch3 = (i >> 16) & 255;
    ch4 = (i >> 24) & 255;
    return ((int) ch1 << 24) | ((int) ch2 << 16) | ((int) ch3 << 8) | ch4;
}

int main(int argc, char** argv){
    google::InitGoogleLogging(argv[0]);

    // lmdb
    MDB_env *mdb_env;
    MDB_dbi mdb_dbi;
    MDB_val mdb_key, mdb_data;
    MDB_txn *mdb_txn;

    string db_path = data_path + string("mnist-train-lmdb");

    LOG(INFO) << "Opening lmdb " << db_path;
    CHECK_EQ(mkdir(db_path.c_str(), 0744), 0)  << "mkdir " << db_path << "failed";
    CHECK_EQ(mdb_env_create(&mdb_env), MDB_SUCCESS) << "mdb_env_create failed";
    CHECK_EQ(mdb_env_set_mapsize(mdb_env, 1099511627776), MDB_SUCCESS) << "mdb_env_set_mapsize failed";
    CHECK_EQ(mdb_env_open(mdb_env, db_path.c_str(), 0, 0664), MDB_SUCCESS)<< "mdb_env_open failed";
    CHECK_EQ(mdb_txn_begin(mdb_env, NULL, 0, &mdb_txn), MDB_SUCCESS)<< "mdb_txn_begin failed";
    CHECK_EQ(mdb_open(mdb_txn, NULL, 0, &mdb_dbi), MDB_SUCCESS)<< "mdb_open failed. Does the lmdb already exist? ";
    //CHECK_EQ(mdb_cursor_open(mdb_txn, mdb_dbi, &mdb_cursor), MDB_SUCCESS) << "mdb_cursor_open failed";
    //CHECK_EQ(mdb_cursor_get(mdb_cursor, &mdb_key, &mdb_value, MDB_FIRST), MDB_SUCCESS) << "mdb_cursor_get failed";
    /*dbsize*/
    // Storing to db
    char label;
    const int kMaxKeyLength = 10;
    char key_cstr[kMaxKeyLength];
    string value;
    int channels = 1;
    int width    = 28;
    int height   = 28;
    int image_pixes_size = channels * width * height;

    unsigned char* pixels = (unsigned char*) malloc(image_pixes_size);

    Datum datum;
    datum.set_channels(1);
    datum.set_height(height);
    datum.set_width(width);

    {
        string train_data_name  = data_path + "/train-images-idx3-ubyte";
        string train_label_name = data_path + "/train-labels-idx1-ubyte";

        ifstream file_data(train_data_name.c_str(), ios::binary);
        ifstream file_label(train_label_name.c_str(), ios::binary);

        int number_of_images = 60000;
        if(file_data.is_open() && file_label.is_open()){
            file_data.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            file_data.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            printf("number_of_images %d\n", number_of_images);
            file_data.read((char*)&height, sizeof(height));
            height = reverseInt(height);
            printf("height %d\n", height);

            file_data.read((char*)&width, sizeof(width));
            width = reverseInt(width);
            printf("width %d\n", width);

            file_label.read((char*)&number_of_images, sizeof(number_of_images));
            file_label.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            printf("number_of_images %d\n", number_of_images);

            for(int i = 0; i < number_of_images; i++){
                printf("width, height, channels %d %d %d\n", width, height, channels);
                file_data.read((char*)pixels, sizeof(char) * width * height * channels);
                file_label.read((char*)&label, sizeof(char) * 1);

                datum.set_label(label);
                datum.set_data(pixels, sizeof(char) * width * height * channels);
                int item_id = i;
                snprintf(key_cstr, kMaxKeyLength, "%08d", item_id);

                /*to serialize*/
                datum.SerializeToString(&value);
                string keystr(key_cstr);

                /*write db*/
                mdb_data.mv_size = value.size();
                mdb_data.mv_data = reinterpret_cast<void*>(&value[0]);
                mdb_key.mv_size = keystr.size();
                mdb_key.mv_data = reinterpret_cast<void*>(&keystr[0]);
                CHECK_EQ(mdb_put(mdb_txn, mdb_dbi, &mdb_key, &mdb_data, 0), MDB_SUCCESS)<< "mdb_put failed";
            }
        }

        CHECK_EQ(mdb_txn_commit(mdb_txn), MDB_SUCCESS) << "mdb_txn_commit failed";
        mdb_close(mdb_env, mdb_dbi);
        mdb_env_close(mdb_env);
    }
    {
        string db_path = data_path + string("mnist-test-lmdb");

        LOG(INFO) << "Opening lmdb " << db_path;
        CHECK_EQ(mkdir(db_path.c_str(), 0744), 0)  << "mkdir " << db_path << "failed";
        CHECK_EQ(mdb_env_create(&mdb_env), MDB_SUCCESS) << "mdb_env_create failed";
        CHECK_EQ(mdb_env_set_mapsize(mdb_env, 1099511627776), MDB_SUCCESS) << "mdb_env_set_mapsize failed";
        CHECK_EQ(mdb_env_open(mdb_env, db_path.c_str(), 0, 0664), MDB_SUCCESS)<< "mdb_env_open failed";
        CHECK_EQ(mdb_txn_begin(mdb_env, NULL, 0, &mdb_txn), MDB_SUCCESS)<< "mdb_txn_begin failed";
        string test_data_name  = data_path + "/test-images-idx3-ubyte";
        string test_label_name = data_path + "/test-labels-idx1-ubyte";

        ifstream file_data(test_data_name.c_str(), ios::binary);
        ifstream file_label(test_label_name.c_str(), ios::binary);

        int number_of_images = 10000;
        if(file_data.is_open() && file_label.is_open()){
            file_data.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            file_data.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            printf("number_of_images %d\n", number_of_images);
            file_data.read((char*)&height, sizeof(height));
            height = reverseInt(height);
            printf("height %d\n", height);

            file_data.read((char*)&width, sizeof(width));
            width = reverseInt(width);
            printf("width %d\n", width);

            file_label.read((char*)&number_of_images, sizeof(number_of_images));
            file_label.read((char*)&number_of_images, sizeof(number_of_images));
            number_of_images = reverseInt(number_of_images);
            printf("number_of_images %d\n", number_of_images);

            for(int i = 0; i < number_of_images; i++){
                file_data.read((char*)pixels, sizeof(char) * width * height * channels);
                file_label.read((char*)&label, sizeof(char) * 1);
                datum.set_data(pixels, sizeof(char) * width * height * channels);
                datum.set_label(label);
                int item_id = i;
                snprintf(key_cstr, kMaxKeyLength, "%08d", item_id);
                printf("label %d\n", static_cast<int>(label));

                /*to serialize*/
                datum.SerializeToString(&value);
                string keystr(key_cstr);

                /*write db*/
                mdb_data.mv_size = value.size();
                mdb_data.mv_data = reinterpret_cast<void*>(&value[0]);
                mdb_key.mv_size = keystr.size();
                mdb_key.mv_data = reinterpret_cast<void*>(&keystr[0]);
                CHECK_EQ(mdb_put(mdb_txn, mdb_dbi, &mdb_key, &mdb_data, 0), MDB_SUCCESS)<< "mdb_put failed";
            }
        }

        CHECK_EQ(mdb_txn_commit(mdb_txn), MDB_SUCCESS) << "mdb_txn_commit failed";
        mdb_close(mdb_env, mdb_dbi);
        mdb_env_close(mdb_env);
    }
    return 0;
}


text:
<?php

namespace WebinoAppLib\Response\Content;

/**
 * Class SourcePreview
 */
class SourcePreview
{
    /**
     * @var string
     */
    private $path;

    /**
     * SourcePreview constructor.
     *
     * @param string $path
     */
    public function __construct($path)
    {
        $this->path = $path;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return sprintf(
            file_get_contents(__DIR__ . '/resources/source-preview.html'),
            highlight_file($this->path, true)
        );
    }
}


text:
/*	$OpenBSD: rf_shutdown.c,v 1.2 1999/02/16 00:03:26 niklas Exp $	*/
/*	$NetBSD: rf_shutdown.c,v 1.4 1999/02/05 00:06:17 oster Exp $	*/
/*
 * rf_shutdown.c
 */
/*
 * Copyright (c) 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Jim Zelenka
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */
/*
 * Maintain lists of cleanup functions. Also, mechanisms for coordinating
 * thread startup and shutdown.
 */

#include "rf_types.h"
#include "rf_threadstuff.h"
#include "rf_shutdown.h"
#include "rf_debugMem.h"
#include "rf_freelist.h"
#include "rf_threadid.h"

static void
rf_FreeShutdownEnt(RF_ShutdownList_t * ent)
{
	FREE(ent, M_RAIDFRAME);
}

int
_rf_ShutdownCreate(
    RF_ShutdownList_t ** listp,
    void (*cleanup) (void *arg),
    void *arg,
    char *file,
    int line)
{
	RF_ShutdownList_t *ent;

	/*
         * Have to directly allocate memory here, since we start up before
         * and shutdown after RAIDframe internal allocation system.
         */
	ent = (RF_ShutdownList_t *) malloc(sizeof(RF_ShutdownList_t), M_RAIDFRAME, M_WAITOK);
	if (ent == NULL)
		return (ENOMEM);
	ent->cleanup = cleanup;
	ent->arg = arg;
	ent->file = file;
	ent->line = line;
	ent->next = *listp;
	*listp = ent;
	return (0);
}

int
rf_ShutdownList(RF_ShutdownList_t ** list)
{
	RF_ShutdownList_t *r, *next;
	char   *file;
	int     line;

	for (r = *list; r; r = next) {
		next = r->next;
		file = r->file;
		line = r->line;

		if (rf_shutdownDebug) {
			int     tid;
			rf_get_threadid(tid);
			printf("[%d] call shutdown, created %s:%d\n", tid, file, line);
		}
		r->cleanup(r->arg);

		if (rf_shutdownDebug) {
			int     tid;
			rf_get_threadid(tid);
			printf("[%d] completed shutdown, created %s:%d\n", tid, file, line);
		}
		rf_FreeShutdownEnt(r);
	}
	*list = NULL;
	return (0);
}


text:
module Slack
  module RealTime
    module Stores
      # Only stores initial information.
      class Starter < Base
        attr_reader :self, :team

        def initialize(attrs)
          @team = Models::Team.new(attrs.team)
          @self = Models::Team.new(attrs.self)
        end

        ### RealTime Events

        # A shared channel invite was sent to a Slack user.
        # @see https://api.slack.com/events/shared_channel_invite_received
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/shared_channel_invite_received.json
        # on :shared_channel_invite_received do |data|

        # An enterprise grid migration has started on an external workspace..
        # @see https://api.slack.com/events/external_org_migration_started
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_started.json
        # on :external_org_migration_started do |data|

        # An enterprise grid migration has finished on an external workspace..
        # @see https://api.slack.com/events/external_org_migration_finished
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_finished.json
        # on :external_org_migration_finished do |data|

        # A private channel was deleted.
        # @see https://api.slack.com/events/group_deleted
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_deleted.json
        # on :group_deleted do |data|

        # Determine the current presence status for a list of users.
        # @see https://api.slack.com/events/presence_query
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_query.json
        # on :presence_query do |data|

        # The membership of an existing User Group has changed.
        # @see https://api.slack.com/events/subteam_members_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_members_changed.json
        # on :subteam_members_changed do |data|

        # Subscribe to presence events for the specified users.
        # @see https://api.slack.com/events/presence_sub
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_sub.json
        # on :presence_sub do |data|

        # A user left a public or private channel.
        # @see https://api.slack.com/events/member_left_channel
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_left_channel.json
        # on :member_left_channel do |data|

        # A user joined a public or private channel.
        # @see https://api.slack.com/events/member_joined_channel
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_joined_channel.json
        # on :member_joined_channel do |data|

        # The server intends to close the connection soon..
        # @see https://api.slack.com/events/goodbye
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/goodbye.json
        # on :goodbye do |data|

        # Verifies ownership of an Events API Request URL.
        # @see https://api.slack.com/events/url_verification
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/url_verification.json
        # on :url_verification do |data|

        # A message was posted in a multiparty direct message channel.
        # @see https://api.slack.com/events/message.mpim
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.mpim.json
        # on :message.mpim do |data|

        # A message was posted in a direct message channel.
        # @see https://api.slack.com/events/message.im
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.im.json
        # on :message.im do |data|

        # A message was posted to a private channel.
        # @see https://api.slack.com/events/message.groups
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.groups.json
        # on :message.groups do |data|

        # A message was posted to a channel.
        # @see https://api.slack.com/events/message.channels
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.channels.json
        # on :message.channels do |data|

        # A channel member is typing a message.
        # @see https://api.slack.com/events/user_typing
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_typing.json
        # on :user_typing do |data|

        # A team member's data has changed.
        # @see https://api.slack.com/events/user_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_change.json
        # on :user_change do |data|

        # A new team member has joined.
        # @see https://api.slack.com/events/team_join
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_join.json
        # on :team_join do |data|

        # An existing user group has been updated or its members changed.
        # @see https://api.slack.com/events/subteam_updated
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_updated.json
        # on :subteam_updated do |data|

        # You have been removed from a user group.
        # @see https://api.slack.com/events/subteam_self_removed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_self_removed.json
        # on :subteam_self_removed do |data|

        # You have been added to a user group.
        # @see https://api.slack.com/events/subteam_self_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_self_added.json
        # on :subteam_self_added do |data|

        # A user group has been added to the team.
        # @see https://api.slack.com/events/subteam_created
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_created.json
        # on :subteam_created do |data|

        # A team member removed a star.
        # @see https://api.slack.com/events/star_removed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/star_removed.json
        # on :star_removed do |data|

        # A team member has starred an item.
        # @see https://api.slack.com/events/star_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/star_added.json
        # on :star_added do |data|

        # Experimental.
        # @see https://api.slack.com/events/reconnect_url
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reconnect_url.json
        # on :reconnect_url do |data|

        # A team member removed an emoji reaction.
        # @see https://api.slack.com/events/reaction_removed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reaction_removed.json
        # on :reaction_removed do |data|

        # A team member has added an emoji reaction to an item.
        # @see https://api.slack.com/events/reaction_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reaction_added.json
        # on :reaction_added do |data|

        # A team member's presence changed.
        # @see https://api.slack.com/events/presence_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_change.json
        # on :presence_change do |data|

        # You have updated your preferences.
        # @see https://api.slack.com/events/pref_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/pref_change.json
        # on :pref_change do |data|

        # A pin was removed from a channel.
        # @see https://api.slack.com/events/pin_removed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/pin_removed.json
        # on :pin_removed do |data|

        # A pin was added to a channel.
        # @see https://api.slack.com/events/pin_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/pin_added.json
        # on :pin_added do |data|

        # You manually updated your presence.
        # @see https://api.slack.com/events/manual_presence_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/manual_presence_change.json
        # on :manual_presence_change do |data|

        # You opened a direct message channel.
        # @see https://api.slack.com/events/im_open
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_open.json
        # on :im_open do |data|

        # A direct message read marker was updated.
        # @see https://api.slack.com/events/im_marked
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_marked.json
        # on :im_marked do |data|

        # Bulk updates were made to a DM channel's history.
        # @see https://api.slack.com/events/im_history_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_history_changed.json
        # on :im_history_changed do |data|

        # A direct message channel was created.
        # @see https://api.slack.com/events/im_created
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_created.json
        # on :im_created do |data|

        # You closed a direct message channel.
        # @see https://api.slack.com/events/im_close
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_close.json
        # on :im_close do |data|

        # A private group was unarchived.
        # @see https://api.slack.com/events/group_unarchive
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_unarchive.json
        # on :group_unarchive do |data|

        # A private group was renamed.
        # @see https://api.slack.com/events/group_rename
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_rename.json
        # on :group_rename do |data|

        # You opened a group channel.
        # @see https://api.slack.com/events/group_open
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_open.json
        # on :group_open do |data|

        # A private group read marker was updated.
        # @see https://api.slack.com/events/group_marked
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_marked.json
        # on :group_marked do |data|

        # You left a private group.
        # @see https://api.slack.com/events/group_left
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_left.json
        # on :group_left do |data|

        # You joined a private group.
        # @see https://api.slack.com/events/group_joined
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_joined.json
        # on :group_joined do |data|

        # Bulk updates were made to a group's history.
        # @see https://api.slack.com/events/group_history_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_history_changed.json
        # on :group_history_changed do |data|

        # You closed a group channel.
        # @see https://api.slack.com/events/group_close
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_close.json
        # on :group_close do |data|

        # A private group was archived.
        # @see https://api.slack.com/events/group_archive
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_archive.json
        # on :group_archive do |data|

        # A file was unshared.
        # @see https://api.slack.com/events/file_unshared
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_unshared.json
        # on :file_unshared do |data|

        # A file was shared.
        # @see https://api.slack.com/events/file_shared
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_shared.json
        # on :file_shared do |data|

        # A file was made public.
        # @see https://api.slack.com/events/file_public
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_public.json
        # on :file_public do |data|

        # A file was made private.
        # @see https://api.slack.com/events/file_private
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_private.json
        # on :file_private do |data|

        # A file was deleted.
        # @see https://api.slack.com/events/file_deleted
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_deleted.json
        # on :file_deleted do |data|

        # A file was created.
        # @see https://api.slack.com/events/file_created
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_created.json
        # on :file_created do |data|

        # A file comment was edited.
        # @see https://api.slack.com/events/file_comment_edited
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_comment_edited.json
        # on :file_comment_edited do |data|

        # A file comment was deleted.
        # @see https://api.slack.com/events/file_comment_deleted
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_comment_deleted.json
        # on :file_comment_deleted do |data|

        # A file comment was added.
        # @see https://api.slack.com/events/file_comment_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_comment_added.json
        # on :file_comment_added do |data|

        # A file was changed.
        # @see https://api.slack.com/events/file_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_change.json
        # on :file_change do |data|

        # A team custom emoji has been added or changed.
        # @see https://api.slack.com/events/emoji_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/emoji_changed.json
        # on :emoji_changed do |data|

        # Do not Disturb settings changed for a team member.
        # @see https://api.slack.com/events/dnd_updated_user
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/dnd_updated_user.json
        # on :dnd_updated_user do |data|

        # Do not Disturb settings changed for the current user.
        # @see https://api.slack.com/events/dnd_updated
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/dnd_updated.json
        # on :dnd_updated do |data|

        # A team slash command has been added or changed.
        # @see https://api.slack.com/events/commands_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/commands_changed.json
        # on :commands_changed do |data|

        # A team channel was unarchived.
        # @see https://api.slack.com/events/channel_unarchive
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_unarchive.json
        # on :channel_unarchive do |data|

        # A team channel was renamed.
        # @see https://api.slack.com/events/channel_rename
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_rename.json
        # on :channel_rename do |data|

        # Your channel read marker was updated.
        # @see https://api.slack.com/events/channel_marked
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_marked.json
        # on :channel_marked do |data|

        # You left a channel.
        # @see https://api.slack.com/events/channel_left
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_left.json
        # on :channel_left do |data|

        # You joined a channel.
        # @see https://api.slack.com/events/channel_joined
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_joined.json
        # on :channel_joined do |data|

        # Bulk updates were made to a channel's history.
        # @see https://api.slack.com/events/channel_history_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_history_changed.json
        # on :channel_history_changed do |data|

        # A team channel was deleted.
        # @see https://api.slack.com/events/channel_deleted
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_deleted.json
        # on :channel_deleted do |data|

        # A team channel was created.
        # @see https://api.slack.com/events/channel_created
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_created.json
        # on :channel_created do |data|

        # A team channel was archived.
        # @see https://api.slack.com/events/channel_archive
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_archive.json
        # on :channel_archive do |data|

        # An integration bot was changed.
        # @see https://api.slack.com/events/bot_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/bot_changed.json
        # on :bot_changed do |data|

        # An integration bot was added.
        # @see https://api.slack.com/events/bot_added
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/bot_added.json
        # on :bot_added do |data|

        # The list of accounts a user is signed into has changed.
        # @see https://api.slack.com/events/accounts_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/accounts_changed.json
        # on :accounts_changed do |data|

        # The team domain has changed.
        # @see https://api.slack.com/events/team_domain_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_domain_change.json
        on :team_domain_change do |data|
          team.url = data.url
          team.domain = data.domain
        end

        # The team is being migrated between servers.
        # @see https://api.slack.com/events/team_migration_started
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_migration_started.json
        # on :team_migration_started do |data|

        # The team billing plan has changed.
        # @see https://api.slack.com/events/team_plan_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_plan_change.json
        on :team_plan_change do |data|
          team.plan = data.plan
        end

        # A team preference has been updated.
        # @see https://api.slack.com/events/team_pref_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_pref_change.json
        on :team_pref_change do |data|
          team.prefs ||= {}
          team.prefs[data.name] = data.value
        end

        # Team profile fields have been updated.
        # @see https://api.slack.com/events/team_profile_change
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_change.json
        # on :team_profile_change do |data|

        # Team profile fields have been deleted.
        # @see https://api.slack.com/events/team_profile_delete
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_delete.json
        # on :team_profile_delete do |data|

        # Team profile fields have been reordered.
        # @see https://api.slack.com/events/team_profile_reorder
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_reorder.json
        # on :team_profile_reorder do |data|

        # The team name has changed.
        # @see https://api.slack.com/events/team_rename
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_rename.json
        on :team_rename do |data|
          team.name = data.name
        end

        # The team email domain has changed.
        # @see https://api.slack.com/events/email_domain_changed
        # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/email_domain_changed.json
        on :email_domain_changed do |data|
          team.email_domain = data.email_domain
        end
      end
    end
  end
end