text:
local M, module = {}, ...
_G[module] = M

local _conn
local _drv
local _buf
local _lower_thresh = 2
local _upper_thresh = 5
local _play_cb

-- ****************************************************************************
-- PCM
local function stop_stream(cb)
  _drv:stop()
  if _conn then
    _conn:close()
    _conn = nil
  end
  _buf = nil
  if cb then cb()
  elseif _play_cb then _play_cb()
  end
  _play_cb = nil
end

local function cb_drained()
  print("drained "..node.heap())
  stop_stream()
end

local function cb_data()
  if #_buf > 0 then
    local data = table.remove(_buf, 1)

    if #_buf <= _lower_thresh then
      -- unthrottle server to get further data into the buffer
      _conn:unhold()
    end
    return data
  end
end

local _rate
local function start_play()
  print("starting playback")

  -- start playback
  _drv:play(_rate)
end

-- ****************************************************************************
-- Networking functions
--
local _skip_headers
local _chunk
local _buffering
local function data_received(c, data)

  if _skip_headers then
    -- simple logic to filter the HTTP headers
    _chunk = _chunk..data
    local i, j = string.find(_chunk, '\r\n\r\n')
    if i then
      _skip_headers = false
      data = string.sub(_chunk, j+1, -1)
      _chunk = nil
    end
  end

  if not _skip_headers then
    _buf[#_buf+1] = data

    if #_buf > _upper_thresh then
      -- throttle server to avoid buffer overrun
      c:hold()
      if _buffering then
        -- buffer got filled, start playback
        start_play()
        _buffering = false
      end
    end
  end

end

local function cb_disconnected()
  if _buffering then
    -- trigger playback when disconnected but we're still buffering
    start_play()
    _buffering = false
  end
end

local _path
local function cb_connected(c)
  c:send("GET ".._path.." HTTP/1.0\r\nHost: iot.nix.nix\r\n".."Connection: close\r\nAccept: /\r\n\r\n")
  _path = nil
end

function M.play(rate, ip, port, path, cb)
  _skip_headers = true
  _chunk = ""
  _buffering = true
  _buf = {}
  _rate = rate
  _path = path
  _play_cb = cb

  _conn = net.createConnection(net.TCP, false)
  _conn:on("receive", data_received)
  _conn:on("disconnection", cb_disconnected)
  _conn:connect(port, ip, cb_connected)
end

function M.stop(cb)
  stop_stream(cb)
end

function M.init(pin)
  _drv = pcm.new(pcm.SD, pin)

  -- get called back when all samples were read from stream
  _drv:on("drained", cb_drained)
  _drv:on("data", cb_data)

  --_drv:on("stopped", cb_stopped)
end

function M.vu(cb, freq)
 _drv:on("vu", cb, freq)
end

function M.close()
  stop_stream()
  _drv:close()
  _drv = nil
end

return M


text:
package shiver.me.timbers.waiting.factory;

import shiver.me.timbers.waiting.execution.WaitingInclude;

import java.util.List;
import java.util.concurrent.TimeUnit;

import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static shiver.me.timbers.waiting.random.RandomExceptions.SOME_OTHER_THROWABLES;
import static shiver.me.timbers.waiting.random.RandomExceptions.SOME_THROWABLES;
import static shiver.me.timbers.waiting.util.Classes.toClasses;

public class WaitingIncludesWithExcludesFactory {

    private final LookupFactory<WaitingInclude> lookupFactory;

    public WaitingIncludesWithExcludesFactory(WaitingInclude canIgnoreIncludeExcludeWaitingInclude) {
        this(new MapLookupFactory<WaitingInclude>());
        add(
            canIgnoreIncludeExcludeWaitingInclude,
            500L, MILLISECONDS, asList(SOME_THROWABLES), asList(SOME_OTHER_THROWABLES)
        );
    }

    public WaitingIncludesWithExcludesFactory(LookupFactory<WaitingInclude> lookupFactory) {
        this.lookupFactory = lookupFactory;
    }

    public WaitingInclude create(long duration, TimeUnit unit, List<Throwable> includes, List<Throwable> excludes) {
        return lookupFactory.find(duration, unit, toClasses(includes), toClasses(excludes));
    }

    public void add(
        WaitingInclude waitingInclude,
        Long duration,
        TimeUnit unit,
        List<Throwable> includes,
        List<Throwable> excludes
    ) {
        lookupFactory.add(waitingInclude, duration, unit, toClasses(includes), toClasses(excludes));
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php
namespace Everyman\Neo4j\Command;
use Everyman\Neo4j\Command,
	Everyman\Neo4j\Client,
	Everyman\Neo4j\Exception,
	Everyman\Neo4j\Node;

/**
 * Delete a node
 */
class DeleteNode extends Command
{
	protected $node = null;

	/**
	 * Set the node to drive the command
	 *
	 * @param Client $client
	 * @param Node $node
	 */
	public function __construct(Client $client, Node $node)
	{
		parent::__construct($client);
		$this->node = $node;
	}

	/**
	 * Return the data to pass
	 *
	 * @return mixed
	 */
	protected function getData()
	{
		return null;
	}

	/**
	 * Return the transport method to call
	 *
	 * @return string
	 */
	protected function getMethod()
	{
		return 'delete';
	}

	/**
	 * Return the path to use
	 *
	 * @return string
	 */
	protected function getPath()
	{
		if (!$this->node->hasId()) {
			throw new Exception('No node id specified for delete');
		}
		return '/node/'.$this->node->getId();
	}

	/**
	 * Use the results
	 *
	 * @param integer $code
	 * @param array   $headers
	 * @param array   $data
	 * @return boolean true on success
	 * @throws Exception on failure
	 */
	protected function handleResult($code, $headers, $data)
	{
		if ((int)($code / 100) == 2) {
			$this->getEntityCache()->deleteCachedEntity($this->node);
			return true;
		} else {
			$this->throwException('Unable to delete node', $code, $headers, $data);
		}
	}
}


text:
/**
 * PrimeUI Datatable Widget
 */
$(function() {

    $.widget("primeui.puidatatable", {

        options: {
            columns: null,
            datasource: null,
            paginator: null,
            selectionMode: null,
            rowSelect: null,
            rowUnselect: null,
            caption: null,
            sortField: null,
            sortOrder: null,
            keepSelectionInLazyMode: false,
            scrollable: false,
            scrollHeight: null,
            scrollWidth: null,
            responsive: false
        },

        _create: function() {
            this.id = this.element.attr('id');
            if(!this.id) {
                this.id = this.element.uniqueId().attr('id');
            }

            this.element.addClass('pui-datatable ui-widget');
            if(this.options.responsive) {
                this.element.addClass('pui-datatable-reflow');
            }

            if(this.options.scrollable) {
                this._createScrollableDatatable();
            }
            else {
                this._createRegularDatatable();
            }

            if(this.options.datasource) {
                if($.isArray(this.options.datasource)) {
                    this._onDataInit(this.options.datasource);
                }
                else if($.type(this.options.datasource) === 'function') {
                    if(this.options.lazy)
                        this.options.datasource.call(this, this._onDataInit, {first:0, sortField:this.options.sortField, sortOrder:this.options.sortOrder});
                    else
                        this.options.datasource.call(this, this._onDataInit);
                }
            }
        },

        _createRegularDatatable: function() {
            this.tableWrapper = $('
').appendTo(this.element);
            this.table = $('

').appendTo(this.tableWrapper);
            this.thead = this.table.children('thead');
            this.tbody = this.table.children('tbody').addClass('pui-datatable-data');
        },

        _createScrollableDatatable: function() {
            this.element.append('

')
                        .append('

');

            this.thead = this.element.find('> .pui-datatable-scrollable-header > .pui-datatable-scrollable-header-box > table > thead');
            this.tbody = this.element.find('> .pui-datatable-scrollable-body > table > tbody');
        },

        _initialize: function() {
            var $this = this;

            if(this.options.columns) {
                var headerRow = $('

').appendTo($this.thead);
                $.each(this.options.columns, function(i, col) {
                    var header = $('	').data('field', col.field).uniqueId().appendTo(headerRow);

                    if(col.headerClass) {
                        header.addClass(col.headerClass);
                    }

                    if(col.headerStyle) {
                        header.attr('style', col.headerStyle);
                    }

                    if(col.headerText) {
                        header.children('.pui-column-title').text(col.headerText);
                    } else if(col.headerContent) {
                        header.children('.pui-column-title').append(col.headerContent.call(this, col));
                    }

                    if(col.sortable) {
                        header.addClass('pui-sortable-column')
                                .data('order', 0)
                                .append('');
                    }
                });
            }

            if(this.options.caption) {
                this.element.prepend('
' + this.options.caption + '
');
            }

            if(this.options.paginator) {
                this.options.paginator.paginate = function(event, state) {
                    $this.paginate();
                };

                this.options.paginator.totalRecords = this.options.lazy ? this.options.paginator.totalRecords : this.data.length;
                this.paginator = $('

').insertAfter(this.tableWrapper).puipaginator(this.options.paginator);
            }

            if(this._isSortingEnabled()) {
                this._initSorting();
            }

            if(this.options.selectionMode) {
                this._initSelection();
            }

            if (this.options.sortField && this.options.sortOrder) {
                this._indicateInitialSortColumn();
                this.sort(this.options.sortField, this.options.sortOrder);
            } else {
                this._renderData();
            }

            if(this.options.scrollable) {
                this._initScrolling();
            }
        },

        _indicateInitialSortColumn: function() {
            this.sortableColumns = this.thead.find('> tr > th.pui-sortable-column');
            var $this = this;

            $.each(this.sortableColumns, function(i, column) {
                var $column = $(column),
                    data = $column.data();
                if ($this.options.sortField === data.field) {
                    var sortIcon = $column.children('.pui-sortable-column-icon');
                    $column.data('order', $this.options.sortOrder).removeClass('ui-state-hover').addClass('ui-state-active');
                    if($this.options.sortOrder === -1)
                        sortIcon.removeClass('fa-sort fa-sort-asc').addClass('fa-sort-desc');
                    else if($this.options.sortOrder === 1)
                        sortIcon.removeClass('fa-sort fa-sort-desc').addClass('fa-sort-asc');
                }
            });

        },

        _onDataInit: function(data) {
            this.data = data;
            if(!this.data) {
                this.data = [];
            }

            this._initialize();
        },

        _onDataUpdate: function(data) {
            this.data = data;
            if(!this.data) {
                this.data = [];
            }

            this.reset();

            this._renderData();
        },

        _onLazyLoad: function(data) {
            this.data = data;
            if(!this.data) {
                this.data = [];
            }

            this._renderData();
        },

        reset: function() {
            if(this.options.selectionMode) {
                this.selection = [];
            }

            if(this.paginator) {
                this.paginator.puipaginator('setState', {
                    page: 0,
                    totalRecords: this.data.length
                });
            }

            this.thead.children('th.pui-sortable-column').data('order', 0).filter('.ui-state-active').removeClass('ui-state-active')
                                .children('span.pui-sortable-column-icon').removeClass('fa-sort-asc fa-sort-desc').addClass('fa-sort');
        },

        _initSorting: function() {
            var $this = this,
            sortableColumns = this.thead.find('> tr > th.pui-sortable-column');

            sortableColumns.on('mouseover.puidatatable', function() {
                var column = $(this);

                if(!column.hasClass('ui-state-active'))
                    column.addClass('ui-state-hover');
            })
            .on('mouseout.puidatatable', function() {
                var column = $(this);

                if(!column.hasClass('ui-state-active'))
                    column.removeClass('ui-state-hover');
            })
            .on('click.puidatatable', function() {
                var column = $(this),
                sortField = column.data('field'),
                order = column.data('order'),
                sortOrder = (order === 0) ? 1 : (order * -1),
                sortIcon = column.children('.pui-sortable-column-icon');

                //clean previous sort state
                column.siblings().filter('.ui-state-active').data('order', 0).removeClass('ui-state-active').children('span.pui-sortable-column-icon')
                                                            .removeClass('fa-sort-asc fa-sort-desc').addClass('fa-sort');

                //update state
                $this.options.sortField = sortField;
                $this.options.sortOrder = sortOrder;

                $this.sort(sortField, sortOrder);

                column.data('order', sortOrder).removeClass('ui-state-hover').addClass('ui-state-active');
                if(sortOrder === -1)
                    sortIcon.removeClass('fa-sort fa-sort-asc').addClass('fa-sort-desc');
                else if(sortOrder === 1)
                    sortIcon.removeClass('fa-sort fa-sort-desc').addClass('fa-sort-asc');
            });
        },

        paginate: function() {
            if(this.options.lazy) {
                if(this.options.selectionMode && ! this.options.keepSelectionInLazyMode) {
                    this.selection = [];
                }
                this.options.datasource.call(this, this._onLazyLoad, this._createStateMeta());
            }
            else {
               this._renderData();
            }
        },

        sort: function(field, order) {
            if(this.options.selectionMode) {
                this.selection = [];
            }

            if(this.options.lazy) {
                this.options.datasource.call(this, this._onLazyLoad, this._createStateMeta());
            }
            else {
                this.data.sort(function(data1, data2) {
                    var value1 = data1[field],
                    value2 = data2[field],
                    result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;

                    return (order * result);
                });

                if(this.options.selectionMode) {
                    this.selection = [];
                }

                if(this.paginator) {
                    this.paginator.puipaginator('option', 'page', 0);
                }

                this._renderData();
            }
        },

        sortByField: function(a, b) {
            var aName = a.name.toLowerCase();
            var bName = b.name.toLowerCase();
            return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
        },

        _renderData: function() {
            if(this.data) {
                this.tbody.html('');

                var firstNonLazy = this._getFirst(),
                first = this.options.lazy ? 0 : firstNonLazy,
                rows = this._getRows();

                for(var i = first; i < (first + rows); i++) {
                    var rowData = this.data[i];

                    if(rowData) {
                        var row = $('
').appendTo(this.tbody),
                            zebraStyle = (i%2 === 0) ? 'pui-datatable-even' : 'pui-datatable-odd',
                            rowIndex = i;

                        row.addClass(zebraStyle);
                        if(this.options.lazy) {
                            rowIndex += firstNonLazy; // Selection is kept as it is non lazy data
                        }
                        if(this.options.selectionMode && PUI.inArray(this.selection, rowIndex)) {
                            row.addClass("ui-state-highlight");
                        }

                        for(var j = 0; j < this.options.columns.length; j++) {
                            var column = $('').appendTo(row),
                            columnOptions = this.options.columns[j];

                            if(columnOptions.bodyClass) {
                                column.addClass(columnOptions.bodyClass);
                            }

                            if(columnOptions.bodyStyle) {
                                column.attr('style', columnOptions.bodyStyle);
                            }

                            if(columnOptions.content) {
                                var content = columnOptions.content.call(this, rowData);
                                if($.type(content) === 'string')
                                    column.html(content);
                                else
                                    column.append(content);
                            }
                            else {
                                column.text(rowData[columnOptions.field]);
                            }

                            if(this.options.responsive && columnOptions.headerText) {
                                column.prepend('' + columnOptions.headerText + '');
                            }
                        }
                    }
                }
            }
        },

        _getFirst: function() {
            if(this.paginator) {
                var page = this.paginator.puipaginator('option', 'page'),
                rows = this.paginator.puipaginator('option', 'rows');

                return (page * rows);
            }
            else {
                return 0;
            }
        },

        _getRows: function() {
            return this.paginator ? this.paginator.puipaginator('option', 'rows') : this.data.length;
        },

        _isSortingEnabled: function() {
            var cols = this.options.columns;
            if(cols) {
                for(var i = 0; i < cols.length; i++) {
                    if(cols[i].sortable) {
                        return true;
                    }
                }
            }

            return false;
        },

        _initSelection: function() {
            var $this = this;
            this.selection = [];
            this.rowSelector = '#' + this.id + ' tbody.pui-datatable-data > tr.ui-widget-content:not(.ui-datatable-empty-message)';

            //shift key based range selection
            if(this._isMultipleSelection()) {
                this.originRowIndex = 0;
                this.cursorIndex = null;
            }

            $(document).off('mouseover.puidatatable mouseout.puidatatable click.puidatatable', this.rowSelector)
                    .on('mouseover.datatable', this.rowSelector, null, function() {
                        var element = $(this);

                        if(!element.hasClass('ui-state-highlight')) {
                            element.addClass('ui-state-hover');
                        }
                    })
                    .on('mouseout.datatable', this.rowSelector, null, function() {
                        var element = $(this);

                        if(!element.hasClass('ui-state-highlight')) {
                            element.removeClass('ui-state-hover');
                        }
                    })
                    .on('click.datatable', this.rowSelector, null, function(e) {
                        $this._onRowClick(e, this);
                    });
        },

        _onRowClick: function(event, rowElement) {
            if(!$(event.target).is(':input,:button,a')) {
                var row = $(rowElement),
                selected = row.hasClass('ui-state-highlight'),
                metaKey = event.metaKey||event.ctrlKey,
                shiftKey = event.shiftKey;

                //unselect a selected row if metakey is on
                if(selected && metaKey) {
                    this.unselectRow(row);
                }
                else {
                    //unselect previous selection if this is single selection or multiple one with no keys
                    if(this._isSingleSelection() || (this._isMultipleSelection() && !metaKey && !shiftKey)) {
                        if (this._isMultipleSelection()) {
                            var selections = this.getSelection();
                            for (var i = 0; i < selections.length; i++) {
                                this._trigger('rowUnselect', null, selections[i]);
                            }
                        }

                        this.unselectAllRows();
                    }

                    this.selectRow(row, false, event);
                }

                PUI.clearSelection();
            }
        },

        _isSingleSelection: function() {
            return this.options.selectionMode === 'single';
        },

        _isMultipleSelection: function() {
            return this.options.selectionMode === 'multiple';
        },

        unselectAllRows: function() {
            this.tbody.children('tr.ui-state-highlight').removeClass('ui-state-highlight').attr('aria-selected', false);
            this.selection = [];
        },

        unselectRow: function(row, silent) {
            var rowIndex = this._getRowIndex(row);
            row.removeClass('ui-state-highlight').attr('aria-selected', false);

            this._removeSelection(rowIndex);

            if(!silent) {
                this._trigger('rowUnselect', null, this.data[rowIndex]);
            }
        },

        selectRow: function(row, silent, event) {
            var rowIndex = this._getRowIndex(row),
                selectedData = this.data[rowIndex];
            row.removeClass('ui-state-hover').addClass('ui-state-highlight').attr('aria-selected', true);

            this._addSelection(rowIndex);

            if(!silent) {
                if (this.options.lazy) {
                    selectedData = this.data[rowIndex - this._getFirst()];
                }
                this._trigger('rowSelect', event, selectedData);
            }
        },

        getSelection: function() {
            var first = this.options.lazy ? this._getFirst() : 0,
                selections = [];
            for(var i = 0; i < this.selection.length; i++) {
                if(this.data.length > this.selection[i]-first && this.selection[i]-first >= 0) {
                    selections.push(this.data[this.selection[i]-first]);
                }
            }
            return selections;
        },

        _removeSelection: function(rowIndex) {
            this.selection = $.grep(this.selection, function(value) {
                return value !== rowIndex;
            });
        },

        _addSelection: function(rowIndex) {
            if(!this._isSelected(rowIndex)) {
                this.selection.push(rowIndex);
            }
        },

        _isSelected: function(rowIndex) {
            return PUI.inArray(this.selection, rowIndex);
        },

        _getRowIndex: function(row) {
            var index = row.index();

            return this.options.paginator ? this._getFirst() + index : index;
        },

        _createStateMeta: function() {
            var state = {
                first: this._getFirst(),
                rows: this._getRows(),
                sortField: this.options.sortField,
                sortOrder: this.options.sortOrder
            };

            return state;
        },

        _updateDatasource: function(datasource) {
            this.options.datasource = datasource;

            if($.isArray(this.options.datasource)) {
                this._onDataUpdate(this.options.datasource);
            }
            else if($.type(this.options.datasource) === 'function') {
                if(this.options.lazy)
                    this.options.datasource.call(this, this._onDataUpdate, {first:0, sortField:this.options.sortField, sortorder:this.options.sortOrder});
                else
                    this.options.datasource.call(this, this._onDataUpdate);
            }
        },

        _setOption: function(key, value) {
            if(key === 'datasource') {
                this._updateDatasource(value);
            }
            else {
                $.Widget.prototype._setOption.apply(this, arguments);
            }
        },

        _initScrolling: function() {
            this.scrollHeader = this.element.children('.pui-datatable-scrollable-header');
            this.scrollBody = this.element.children('.pui-datatable-scrollable-body');
            this.scrollHeaderBox = this.scrollHeader.children('.pui-datatable-scrollable-header-box');
            this.headerTable = this.scrollHeaderBox.children('table');
            this.bodyTable = this.scrollBody.children('table');
            this.percentageScrollHeight = this.options.scrollHeight && (this.options.scrollHeight.indexOf('%') !== -1);
            this.percentageScrollWidth = this.options.scrollWidth && (this.options.scrollWidth.indexOf('%') !== -1);
            var $this = this,
            scrollBarWidth = this.getScrollbarWidth() + 'px';

            if(this.options.scrollHeight) {
                if(this.percentageScrollHeight)
                    this.adjustScrollHeight();
                else
                    this.scrollBody.css('max-height', this.options.scrollHeight + 'px');

                if(this.hasVerticalOverflow()) {
                    this.scrollHeaderBox.css('margin-right', scrollBarWidth);
                }
            }

            this.fixColumnWidths();

            if(this.options.scrollWidth) {
                if(this.percentageScrollWidth)
                    this.adjustScrollWidth();
                else
                    this.setScrollWidth(parseInt(this.cfg.scrollWidth));
            }

            this.cloneHead();

            this.scrollBody.on('scroll.dataTable', function() {
                var scrollLeft = $this.scrollBody.scrollLeft();
                $this.scrollHeaderBox.css('margin-left', -scrollLeft);
            });

            this.scrollHeader.on('scroll.dataTable', function() {
                $this.scrollHeader.scrollLeft(0);
            });

            var resizeNS = 'resize.' + this.id;
            $(window).off(resizeNS).on(resizeNS, function() {
                if($this.element.is(':visible')) {
                    if($this.percentageScrollHeight)
                        $this.adjustScrollHeight();

                    if($this.percentageScrollWidth)
                        $this.adjustScrollWidth();
                }
            });
        },

        cloneHead: function() {
            this.theadClone = this.thead.clone();
            this.theadClone.find('th').each(function() {
                var header = $(this);
                header.attr('id', header.attr('id') + '_clone');
                $(this).children().not('.pui-column-title').remove();
            });
            this.theadClone.removeAttr('id').addClass('pui-datatable-scrollable-theadclone').height(0).prependTo(this.bodyTable);

            //align horizontal scroller on keyboard tab
            if(this.options.scrollWidth) {
                var clonedSortableColumns = this.theadClone.find('> tr > th.pui-sortable-column');
                clonedSortableColumns.each(function() {
                    $(this).data('original', $(this).attr('id').split('_clone')[0]);
                });

                clonedSortableColumns.on('blur.dataTable', function() {
                    $(PrimeFaces.escapeClientId($(this).data('original'))).removeClass('ui-state-focus');
                })
                .on('focus.dataTable', function() {
                    $(PrimeFaces.escapeClientId($(this).data('original'))).addClass('ui-state-focus');
                })
                .on('keydown.dataTable', function(e) {
                    var key = e.which,
                    keyCode = $.ui.keyCode;

                    if((key === keyCode.ENTER||key === keyCode.NUMPAD_ENTER) && $(e.target).is(':not(:input)')) {
                        $(PrimeFaces.escapeClientId($(this).data('original'))).trigger('click.dataTable', (e.metaKey||e.ctrlKey));
                        e.preventDefault();
                    }
                });
            }
        },

        adjustScrollHeight: function() {
            var relativeHeight = this.element.parent().innerHeight() * (parseInt(this.cfg.scrollHeight) / 100),
            tableHeaderHeight = this.element.children('.pui-datatable-header').outerHeight(true),
            tableFooterHeight = this.element.children('.pui-datatable-footer').outerHeight(true),
            scrollersHeight = (this.scrollHeader.outerHeight(true) + this.scrollFooter.outerHeight(true)),
            paginatorsHeight = this.paginator ? this.paginator.getContainerHeight(true) : 0,
            height = (relativeHeight - (scrollersHeight + paginatorsHeight + tableHeaderHeight + tableFooterHeight));

            this.scrollBody.css('max-height', height + 'px');
        },

        adjustScrollWidth: function() {
            var width = parseInt((this.element.parent().innerWidth() * (parseInt(this.options.scrollWidth) / 100)));
            this.setScrollWidth(width);
        },

        setOuterWidth: function(element, width) {
            var diff = element.outerWidth() - element.width();
            element.width(width - diff);
        },

        setScrollWidth: function(width) {
            var $this = this;
            this.element.children('.ui-widget-header').each(function() {
                $this.setOuterWidth($(this), width);
            });
            this.scrollHeader.width(width);
            this.scrollBody.css('margin-right', 0).width(width);
        },

        alignScrollBody: function() {
            var marginRight = this.hasVerticalOverflow() ? this.getScrollbarWidth() + 'px' : '0px';

            this.scrollHeaderBox.css('margin-right', marginRight);
        },

        getScrollbarWidth: function() {
            if(!this.scrollbarWidth) {
                this.scrollbarWidth = PUI.browser.webkit ? '15' : PUI.calculateScrollbarWidth();
            }

            return this.scrollbarWidth;
        },

        hasVerticalOverflow: function() {
            return (this.options.scrollHeight && this.bodyTable.outerHeight() > this.scrollBody.outerHeight())
        },

        restoreScrollState: function() {
            var scrollState = this.scrollStateHolder.val(),
            scrollValues = scrollState.split(',');

            this.scrollBody.scrollLeft(scrollValues[0]);
            this.scrollBody.scrollTop(scrollValues[1]);
        },

        saveScrollState: function() {
            var scrollState = this.scrollBody.scrollLeft() + ',' + this.scrollBody.scrollTop();

            this.scrollStateHolder.val(scrollState);
        },

        clearScrollState: function() {
            this.scrollStateHolder.val('0,0');
        },

        fixColumnWidths: function() {
            if(!this.columnWidthsFixed) {
                if(this.options.scrollable) {
                    this.scrollHeaderBox.find('> table > thead > tr > th').each(function() {
                        var headerCol = $(this),
                        width = headerCol.width();
                        headerCol.width(width);
                    });
                }
                else {
                    this.options.find('> .pui-datatable-tablewrapper > table > thead > tr > th').each(function() {
                        var col = $(this);
                        col.width(col.width());
                    });
                }

                this.columnWidthsFixed = true;
            }
        }

    });
});


text:
package org.codehaus.groovy.grails.plugins.support.aware;

import groovy.lang.GroovyObject;
import org.codehaus.groovy.grails.commons.GrailsApplication;
import org.codehaus.groovy.grails.commons.spring.RuntimeSpringConfiguration;
import org.codehaus.groovy.grails.plugins.AbstractGrailsPlugin;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;

import java.util.Collections;
import java.util.Map;

/**
 *
Grails plugin that registers *Aware {@link org.springframework.beans.factory.config.BeanPostProcessor}s.

 *
 * @author Steven Devijver
 * @since 0.2
 */
public class AwarePlugin extends AbstractGrailsPlugin {

    public AwarePlugin(Class pluginClass, GrailsApplication application) {
		super(pluginClass, application);
	}

	public void doWithApplicationContext(ApplicationContext applicationContext) {
        registerGrailsApplicationAwareBeanPostProcessor(applicationContext, application);
        registerClassLoaderAwareBeanPostProcessor(applicationContext, application.getClassLoader());
    }

    protected void registerGrailsApplicationAwareBeanPostProcessor(ApplicationContext applicationContext, GrailsApplication grailsApplication) {
    	if(applicationContext instanceof GenericApplicationContext) {
    		GenericApplicationContext ctx = (GenericApplicationContext)applicationContext;
            ctx.getBeanFactory().addBeanPostProcessor(new GrailsApplicationAwareBeanPostProcessor(grailsApplication));
            ctx.getBeanFactory().ignoreDependencyInterface(GrailsApplicationAware.class);

    	}
    }

    protected void registerClassLoaderAwareBeanPostProcessor(ApplicationContext applicationContext, ClassLoader classLoader) {
    	if(applicationContext instanceof GenericApplicationContext) {
    		GenericApplicationContext ctx = (GenericApplicationContext)applicationContext;
    		ctx.getBeanFactory().addBeanPostProcessor(new ClassLoaderAwareBeanPostProcessor(classLoader));
    		ctx.getBeanFactory().ignoreDependencyInterface(ClassLoaderAware.class);
    	}
    }

	public void doWithRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
		// nothing

	}

    public GroovyObject getInstance() {
        throw new UnsupportedOperationException("Method [getInstance] not supported on AwarePlugin");
    }

    public void doWithDynamicMethods(ApplicationContext applicationContext) {
		// do nothing
	}

    public boolean isEnabled() {
        return true;
    }

    public String[] getObservedPluginNames() {
        return new String[0];
    }

    public void notifyOfEvent(Map event) {
        // do nothing
    }

    public Map notifyOfEvent(int eventKind, Object source) {
        return Collections.EMPTY_MAP;
    }

    public void doArtefactConfiguration() {
		// do nothing
	}

    public Class[] getProvidedArtefacts() {
        return new Class[0];
    }

}


text:
cd ./../../source/ ; runc
if [ $? -eq 0 ]; then
	echo "[YES]        Linuxspec.Spec.Version == "pre_draft"   passed"
else
	echo "[NO]        Linuxspec.Spec.Version == "pre_draft"   failed"
fi


text:
/*
 * ESP32Explorer.cpp
 *
 *  Created on: May 22, 2017
 *      Author: kolban
 */
#include <string>
#include <GPIO.h>
#include "ESP32Explorer.h"
#include "sdkconfig.h"
#include <esp_log.h>
#include <FATFS_VFS.h>
#include <FileSystem.h>
#include <FreeRTOS.h>
#include <Task.h>
#include <HttpServer.h>
#include <TFTP.h>
#include <JSON.h>
#include <WiFi.h>
#include <stdio.h>
#include <driver/i2c.h>
#include "BLEExplorer.h"
#include "GeneralUtils.h"
#include "Memory.h"
#include <esp_wifi.h>

static const char* LOG_TAG = "ESP32Explorer";

static BLEExplorer* g_pBLEExplorer;

extern JsonObject I2S_JSON();
extern JsonObject GPIO_JSON();
extern JsonObject WIFI_JSON();
extern JsonObject SYSTEM_JSON();
extern JsonObject FILESYSTEM_GET_JSON_DIRECTORY(std::string path, bool isRecursive);
extern JsonObject FILESYSTEM_GET_JSON_CONTENT(std::string path);
extern JsonObject I2C_READ(std::map<std::string, std::string> parts);
extern JsonObject I2C_WRITE(std::map<std::string, std::string> parts);
extern JsonObject I2C_SCAN_JSON();

static void handleTest(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handleTest called");
	ESP_LOGD(LOG_TAG, "Path: %s" ,pRequest->getPath().c_str());
	ESP_LOGD(LOG_TAG, "Method: %s", pRequest->getMethod().c_str());
	ESP_LOGD(LOG_TAG, "Query:");
	std::map<std::string, std::string> queryMap = pRequest->getQuery();
	std::map<std::string, std::string>::iterator itr;
	for (itr=queryMap.begin(); itr != queryMap.end(); itr++) {
		ESP_LOGD(LOG_TAG, "name: %s, value: %s", itr->first.c_str(), itr->second.c_str());
	}
	ESP_LOGD(LOG_TAG, "Body: %s", pRequest->getBody().c_str());
	pResponse->sendData("hello!");
} // handleTest

static void handle_REST_SYSTEM(HttpRequest* pRequest, HttpResponse* pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_SYSTEM");

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = SYSTEM_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
  	ESP_LOGE(LOG_TAG, "%d, largest: %d", xPortGetFreeHeapSize(), xPortGetMinimumEverFreeHeapSize());
} // handle_REST_GPIO

static void handle_REST_I2S(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_I2S");

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = I2S_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_I2S

static void handle_REST_GPIO(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_GPIO");

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = GPIO_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_GPIO

static void handle_REST_GPIO_SET(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_GPIO_SET");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		int gpio = atoi(parts.at("gpio").c_str());
		gpio_set_level((gpio_num_t)gpio, 1);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = GPIO_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_GPIO_SET

static void handle_REST_GPIO_CLEAR(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_GPIO_CLEAR");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		int gpio = atoi(parts.at("gpio").c_str());
		gpio_set_level((gpio_num_t)gpio, 0);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = GPIO_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_GPIO_CLEAR

static void handle_REST_GPIO_DIRECTION_INPUT(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_GPIO_DIRECTION_INPUT");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		int gpio = atoi(parts.at("gpio").c_str());
		gpio_set_direction((gpio_num_t)gpio, GPIO_MODE_INPUT);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = GPIO_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_GPIO_DIRECTION_INPUT

static void handle_REST_GPIO_DIRECTION_OUTPUT(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_GPIO_DIRECTION_OUTPUT");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		int gpio = atoi(parts.at("gpio").c_str());
		gpio_set_direction((gpio_num_t)gpio, GPIO_MODE_OUTPUT);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = GPIO_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_GPIO_DIRECTION_OUTPUT

static void handle_REST_WiFi(HttpRequest* pRequest, HttpResponse* pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_WIFI");

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = WIFI_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_WiFi

static void handle_REST_LOG_SET(HttpRequest* pRequest, HttpResponse* pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_LOG_SET");
	int logLevel = 5;
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		logLevel = atoi(parts.at("level").c_str());
		::esp_log_level_set("*", (esp_log_level_t)logLevel);
	}
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = SYSTEM_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_LOG_SET

static void handle_REST_FILE_GET(HttpRequest *pRequest, HttpResponse *pResponse) { //FIXME
	ESP_LOGD(LOG_TAG, "handle_REST_FILE_GET");
	pResponse->addHeader("access-control-allow-origin", "*");
	std::vector<std::string> parts = pRequest->pathSplit();
	std::string path = "";
	for (int i=3; i<parts.size(); i++) {
		path += "/" + parts[i];
	}
	File file(path);
	JsonObject obj = JSON::createObject();
	if (file.isDirectory()) {
		obj = FILESYSTEM_GET_JSON_DIRECTORY(path.c_str(), true);
	} else {
		ESP_LOGD(LOG_TAG, "Getting content of file, length: %d", file.length());
		obj = FILESYSTEM_GET_JSON_CONTENT(path.c_str());
	}

	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_FILE_GET

static void handle_REST_FILE_DELETE(HttpRequest *pRequest, HttpResponse *pResponse) { //FIXME
	ESP_LOGD(LOG_TAG, "handle_REST_FILE_DELETE");
	pResponse->addHeader("access-control-allow-origin", "*");
	std::vector<std::string> parts = pRequest->pathSplit();
	std::string path = "";
	for (int i=3; i<parts.size(); i++) {
		path += "/" + parts[i];
	}
	int rc = FileSystem::remove(path);
	JsonObject obj = JSON::createObject();
	obj.setInt("rc", rc);
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_FILE_GET

static void handle_REST_FILE_POST(HttpRequest* pRequest, HttpResponse* pResponse) {  //FIXME
	ESP_LOGD(LOG_TAG, "handle_REST_FILE_POST");
	pResponse->addHeader("access-control-allow-origin", "*");
	std::vector<std::string> parts = pRequest->pathSplit();
	std::string path = "";
	for (int i=3; i<parts.size(); i++) {
		path += "/" + parts[i];
	}
	std::map<std::string, std::string> queryParams = pRequest->getQuery();
	std::string directory = queryParams["directory"];
	if (directory == "true") {
		ESP_LOGD(LOG_TAG, "Create a directory: %s", path.c_str());
	}
	//JsonObject obj = FILESYSTEM_GET_JSON(path.c_str());
	int rc = FileSystem::mkdir(path);
	JsonObject obj = JSON::createObject();
	obj.setInt("rc", rc);
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_FILE_POST

/*
class MyMultiPart : public WebServer::HTTPMultiPart {
public:
	void begin(std::string varName,	std::string fileName) {
		ESP_LOGD(LOG_TAG, "MyMultiPart begin(): varName=%s, fileName=%s",
			varName.c_str(), fileName.c_str());
		m_currentVar = varName;
		if (varName == "path") {
			m_path = "";
		} else if (varName == "myfile") {
			m_fileData = "";
			m_fileName = fileName;
		}
	} // begin

	void end() {
		ESP_LOGD(LOG_TAG, "MyMultiPart end()");
		if (m_currentVar == "myfile") {
			std::string fileName = m_path + "/" + m_fileName;
			ESP_LOGD(LOG_TAG, "Write to file: %s ... data: %s", fileName.c_str(), m_fileData.c_str());

			//std::ofstream myfile;
			//myfile.open(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
			//myfile << m_fileData;
			//myfile.close();

			FILE *ffile = fopen(fileName.c_str(), "w");
			fwrite(m_fileData.data(), m_fileData.length(), 1, ffile);
			fclose(ffile);
		}
	} // end

	void data(std::string data) {
		ESP_LOGD(LOG_TAG, "MyMultiPart data(): length=%d", data.length());
		if (m_currentVar == "path") {
			m_path += data;
		}
		else if (m_currentVar == "myfile") {
			m_fileData += data;
		}
	} // data

	void multipartEnd() {
		ESP_LOGD(LOG_TAG, "MyMultiPart multipartEnd()");
	} // multipartEnd

	void multipartStart() {
		ESP_LOGD(LOG_TAG, "MyMultiPart multipartStart()");
	} // multipartStart

private:
	std::string m_fileName;
	std::string m_path;
	std::string m_currentVar;
	std::string m_fileData;
};

class MyMultiPartFactory : public WebServer::HTTPMultiPartFactory {
	WebServer::HTTPMultiPart* newInstance() {
		return new MyMultiPart();
	}
};
*/
/*
class MyWebSocketHandler : public WebServer::WebSocketHandler {
	void onMessage(std::string message) {
		ESP_LOGD(LOG_TAG, "MyWebSocketHandler: Data length: %s", message.c_str());
		JsonObject obj = JSON::parseObject(message);
		std::string command = obj.getString("command");
		ESP_LOGD(LOG_TAG, "Command: %s", command.c_str());
		if (command == "getfile") {
			std::string path = obj.getString("path");
			ESP_LOGD(LOG_TAG, "   path: %s", path.c_str());
			File f(path);
			std::string fileContent = f.getContent(0, 1000);
			ESP_LOGD(LOG_TAG, "Length of file content is %d", fileContent.length());
			// send response
			sendData(fileContent);
		}
	} // onMessage
}; // MyWebSocketHandler

class MyWebSocketHandlerFactory : public WebServer::WebSocketHandlerFactory {
	WebServer::WebSocketHandler* newInstance() {
		return new MyWebSocketHandler();
	}
};
*/

static void handle_REST_I2C_INIT(HttpRequest *pRequest, HttpResponse *pResponse) { //TODO implement slave mode
	ESP_LOGD(LOG_TAG, ">> init_I2C");
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		uint8_t SDA, SCL, I2C_NUM, SPEED, I2C_MODE;
		I2C_NUM = atoi(parts.at("port").c_str());
		SDA = atoi(parts.at("sda").c_str());
		SCL = atoi(parts.at("scl").c_str());
		SPEED = atoi(parts.at("speed").c_str());
		I2C_MODE = atoi(parts.at("mode").c_str());

		i2c_config_t conf;
		conf.mode = I2C_MODE_MASTER;
		conf.sda_io_num = (gpio_num_t)SDA;
		conf.scl_io_num = (gpio_num_t)SCL;
		conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
		conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
		conf.master.clk_speed = SPEED;
		::i2c_param_config((i2c_port_t)I2C_NUM, &conf);
		::i2c_driver_install((i2c_port_t)I2C_NUM, (i2c_mode_t)I2C_MODE, 0, 0, 0);
	}
	ESP_LOGI(LOG_TAG, "<< init_i2c");

	JsonObject obj = I2C_SCAN_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_I2C_INIT

static void handle_REST_I2C_CLOSE(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, ">> delete_I2C");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		uint8_t I2C_NUM;
		I2C_NUM = atoi(parts.at("port").c_str());
		::i2c_driver_delete((i2c_port_t)I2C_NUM);
		ESP_LOGI(LOG_TAG, "<< delete_i2c");
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "text/plain");
	pResponse->sendData("i2c port closed");
	//JSON::deleteObject(obj);
} // handle_REST_I2C_CLOSE

static void handle_REST_I2C_SCAN(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, ">> init_I2C");
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonObject obj = I2C_SCAN_JSON();
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} // handle_REST_I2C_SCAN

static void handle_REST_I2C_COMMAND_READ(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, ">> init_I2C");
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	std::map<std::string, std::string> parts = pRequest->parseForm();
	JsonObject obj = I2C_READ(parts);
	pResponse->sendData(obj.toString());
	JSON::deleteObject(obj);
} //

static void handle_REST_I2C_COMMAND_WRITE(HttpRequest *pRequest, HttpResponse *pResponse) {
	ESP_LOGD(LOG_TAG, ">> init_I2C");
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	JsonArray obj = JSON::createArray();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	JsonObject obj2 = I2C_WRITE(parts);
	pResponse->sendData(obj2.toString());
	JSON::deleteArray(obj);
	JSON::deleteObject(obj2);
} //

static void handle_REST_BLE_CLIENT_SCAN(HttpRequest* pRequest, HttpResponse* pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_BLE_CLIENT_SCAN");
	JsonArray obj = g_pBLEExplorer->scan();
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	pResponse->sendData(obj.toString());
	JSON::deleteArray(obj);
} // handle_REST_BLE_CLIENT_SCAN

static void handle_REST_BLE_CLIENT_CONNECT(HttpRequest* pRequest, HttpResponse* pResponse) {
	ESP_LOGD(LOG_TAG, "handle_REST_BLE_CLIENT_CONNECT");
	JsonArray obj = JSON::createArray();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		obj = g_pBLEExplorer->connect(parts.at("connect").c_str());
	}
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	pResponse->sendData(obj.toString());
	JSON::deleteArray(obj);
} // handle_REST_BLE_CLIENT_SCAN

static void handle_REST_BLE_SERVER_CREATE(HttpRequest* pRequest, HttpResponse* pResponse) {
	g_pBLEExplorer->createServer("Esp32");
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "text/plain");
	pResponse->sendData("create server");
}
static void handle_REST_BLE_SERVER_DELETE(HttpRequest* pRequest, HttpResponse* pResponse) {
	g_pBLEExplorer->deleteServer();
}
static void handle_REST_BLE_SERVER_START_ADV(HttpRequest* pRequest, HttpResponse* pResponse) {
	g_pBLEExplorer->startAdvertising();
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "text/plain");
	pResponse->sendData("start adv");
}
static void handle_REST_BLE_SERVER_STOP_ADV(HttpRequest* pRequest, HttpResponse* pResponse) {
	JsonObject obj = JSON::createObject();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		uint16_t service = strtoul(parts.at("handle").c_str(), NULL, 16);
		g_pBLEExplorer->startService(service);
	}

	//g_pBLEExplorer->stopAdvertising();
	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "text/plain");
	pResponse->sendData("stop adv");
}
static void handle_REST_BLE_SERVER_ADD_SERVICE(HttpRequest* pRequest, HttpResponse* pResponse) {
	JsonObject obj = JSON::createObject();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		BLEUUID uuid = BLEUUID::fromString(parts.at("UUID").c_str());
		obj = g_pBLEExplorer->addService(uuid);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	pResponse->sendData(obj.toString());
}
static void handle_REST_BLE_SERVER_GET_SERVICES(HttpRequest* pRequest, HttpResponse* pResponse) {
}
static void handle_REST_BLE_SERVER_ADD_CHARACTERISTIC(HttpRequest* pRequest, HttpResponse* pResponse) {
	JsonObject obj = JSON::createObject();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		BLEUUID uuid = BLEUUID::fromString(parts.at("UUID").c_str());
		uint16_t service = strtoul(parts.at("serviceUUID").c_str(), NULL, 16);
		obj = g_pBLEExplorer->addCharacteristic(uuid, service);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	pResponse->sendData(obj.toString());
}

static void handle_REST_BLE_SERVER_GET_(HttpRequest* pRequest, HttpResponse* pResponse) {
}
static void handle_REST_BLE_SERVER_ADD_DESCRIPTOR(HttpRequest* pRequest, HttpResponse* pResponse) {
	JsonObject obj = JSON::createObject();
	std::map<std::string, std::string> parts = pRequest->parseForm();
	if(atoi(pRequest->getHeader(pRequest->HTTP_HEADER_CONTENT_LENGTH).c_str())>0){
		BLEUUID uuid = BLEUUID::fromString(parts.at("UUID").c_str());
		uint16_t characteristic = strtoul(parts.at("characteristicUUID").c_str(), NULL, 16);
		obj = g_pBLEExplorer->addDescriptor(uuid, characteristic);
	}

	pResponse->addHeader("access-control-allow-origin", "*");
	pResponse->addHeader("Content-Type", "application/json");
	pResponse->sendData(obj.toString());
}

static void handle_REST_BLE_SERVER_GET_DESCRIPTOR(HttpRequest* pRequest, HttpResponse* pResponse) {
}

class TFTPTask : public Task {
   void run(void *data) {
  	 TFTP tftp;
  	 tftp.setBaseDir("/spiflash");
  	 tftp.start();
   }
};

ESP32_Explorer::ESP32_Explorer() {
	//m_pBLEExplorer = new BLEExplorer();
	//g_pBLEExplorer = new BLEExplorer();
} // ESP32_Explorer

ESP32_Explorer::~ESP32_Explorer() {
}

void ESP32_Explorer::start() {
	FATFS_VFS* fs = new FATFS_VFS("/spiflash", "storage");
	fs->mount();

	//TFTPTask* pTFTPTask = new TFTPTask();
	//pTFTPTask->setStackSize(8000);
	//pTFTPTask->start();
	ESP32CPP::GPIO::setOutput(GPIO_NUM_25);
	ESP32CPP::GPIO::setOutput(GPIO_NUM_26);
	ESP32CPP::GPIO::high(GPIO_NUM_25);
	ESP32CPP::GPIO::low(GPIO_NUM_26);

	 /*
	  * Create a WebServer and register handlers for REST requests.
	  */
	 HttpServer* pHttpServer = new HttpServer();
	 pHttpServer->setRootPath("/spiflash");
	 pHttpServer->addPathHandler("GET",    "/hello",      		           handleTest);
	 pHttpServer->addPathHandler("GET",    "/ESP32/WIFI",                  handle_REST_WiFi);
	 pHttpServer->addPathHandler("GET",    "/ESP32/I2S",                   handle_REST_I2S);
	 pHttpServer->addPathHandler("GET",    "/ESP32/GPIO",                  handle_REST_GPIO);
	 pHttpServer->addPathHandler("POST",   "/ESP32/GPIO/SET",              handle_REST_GPIO_SET);
	 pHttpServer->addPathHandler("POST",   "/ESP32/GPIO/CLEAR",            handle_REST_GPIO_CLEAR);
	 pHttpServer->addPathHandler("POST",   "/ESP32/GPIO/DIRECTION/INPUT",  handle_REST_GPIO_DIRECTION_INPUT);
	 pHttpServer->addPathHandler("POST",   "/ESP32/GPIO/DIRECTION/OUTPUT", handle_REST_GPIO_DIRECTION_OUTPUT);
	 pHttpServer->addPathHandler("POST",   "/ESP32/LOG/SET",               handle_REST_LOG_SET);
	 pHttpServer->addPathHandler("GET",    "/ESP32/FILE",                  handle_REST_FILE_GET);
	 pHttpServer->addPathHandler("POST",   "/ESP32/FILE",                  handle_REST_FILE_POST);
	 pHttpServer->addPathHandler("DELETE", "/ESP32/FILE",                  handle_REST_FILE_DELETE);
	 pHttpServer->addPathHandler("GET",    "/ESP32/SYSTEM",                handle_REST_SYSTEM);
	 // I2C
	 pHttpServer->addPathHandler("POST",   "/ESP32/I2C/COMMAND/READ",      handle_REST_I2C_COMMAND_READ);
	 pHttpServer->addPathHandler("POST",   "/ESP32/I2C/COMMAND/WRITE",     handle_REST_I2C_COMMAND_WRITE);
	 pHttpServer->addPathHandler("POST",   "/ESP32/I2C/INIT",              handle_REST_I2C_INIT);
	 pHttpServer->addPathHandler("GET",    "/ESP32/I2C/SCAN",              handle_REST_I2C_SCAN);
	 pHttpServer->addPathHandler("POST",   "/ESP32/I2C/DEINIT",            handle_REST_I2C_CLOSE);
	 // BLE CLIENT
	 pHttpServer->addPathHandler("GET",    "/ESP32/BLE/CLIENT/SCAN",       handle_REST_BLE_CLIENT_SCAN);
	 pHttpServer->addPathHandler("POST",   "/ESP32/BLE/CLIENT/CONNECT",    handle_REST_BLE_CLIENT_CONNECT);
	 // BLE SERVER
	 pHttpServer->addPathHandler("POST",   "/ESP32/BLE/SERVER",   		   handle_REST_BLE_SERVER_CREATE);
	 //pHttpServer->addPathHandler("DELETE", "/ESP32/BLE/SERVER",   		   handle_REST_BLE_SERVER_DELETE);
	 pHttpServer->addPathHandler("POST",   "/ESP32/BLE/SERVER/SERVICE",    handle_REST_BLE_SERVER_ADD_SERVICE);
	 pHttpServer->addPathHandler("DELETE", "/ESP32/BLE/SERVER/SERVICE",    handle_REST_BLE_SERVER_ADD_SERVICE);
	 pHttpServer->addPathHandler("GET",    "/ESP32/BLE/SERVER/SERVICES",   handle_REST_BLE_SERVER_GET_SERVICES);
	 pHttpServer->addPathHandler("POST",   "/ESP32/BLE/SERVER/CHARACTERISTIC",    handle_REST_BLE_SERVER_ADD_CHARACTERISTIC);
	 pHttpServer->addPathHandler("DELETE", "/ESP32/BLE/SERVER/CHARACTERISTIC",    handle_REST_BLE_SERVER_ADD_SERVICE);
	 pHttpServer->addPathHandler("GET",    "/ESP32/BLE/SERVER/CHARACTERISTICS",   handle_REST_BLE_SERVER_GET_SERVICES);
	 pHttpServer->addPathHandler("POST",   "/ESP32/BLE/SERVER/DESCRIPTOR",    handle_REST_BLE_SERVER_ADD_DESCRIPTOR);
	 pHttpServer->addPathHandler("DELETE", "/ESP32/BLE/SERVER/DESCRIPTOR",    handle_REST_BLE_SERVER_ADD_SERVICE);
	 pHttpServer->addPathHandler("GET",    "/ESP32/BLE/SERVER/DESCRIPTORS",   handle_REST_BLE_SERVER_GET_SERVICES);
	 pHttpServer->addPathHandler("GET",    "/ESP32/BLE/SERVER/START",    	handle_REST_BLE_SERVER_START_ADV);
	 pHttpServer->addPathHandler("POST",    "/ESP32/BLE/SERVER/STOP",   		handle_REST_BLE_SERVER_STOP_ADV);

	 //pHttpServer->setWebSocketHandlerFactory(new MyWebSocketHandlerFactory());
	 pHttpServer->start(80); // Start the WebServer listening on port 80.
	  	ESP_LOGE(LOG_TAG, "%d, minimum ever: %d", xPortGetFreeHeapSize(), xPortGetMinimumEverFreeHeapSize());
} // start


text:
<?php

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// Load the controller framework
jimport('joomla.application.component.controller');

if(!class_exists('VmController'))require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php');

/**
 * Shipment  Controller
 *
 * @package    VirtueMart
 * @subpackage Shipment
 * @author RickG, Max Milbers
 */
class VirtuemartControllerShipmentmethod extends VmController {

	/**
	 * Method to display the view
	 *
	 * @access	public
	 */
	function __construct() {
		VmConfig::loadJLang('com_virtuemart_orders',TRUE);
		parent::__construct();
	}

	/**
	 * We want to allow html in the descriptions.
	 *
	 * @author Max Milbers
	 */
	function save($data = 0){

		$data = vRequest::getPost();
		$user = JFactory::getUser();
		if($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart')){
			$data['shipment_name'] = vRequest::get('shipment_name','');
			$data['shipment_desc'] = vRequest::get('shipment_desc','');
			if(isset($data['params'])){
				$data['params'] = vRequest::get('params','');
			}
		} else {
			$data['payment_name'] = vRequest::getHtml('payment_name','');
			$data['payment_desc'] = vRequest::getHtml('payment_desc','');
			if(isset($data['params'])){
				$data['params'] = vRequest::getHtml('params','');
			}
		}

		parent::save($data);

	}
	/**
	 * Clone a shipment
	 *
	 * @author Valérie Isaksen
	 */
	public function CloneShipment() {
		$mainframe = Jfactory::getApplication();

		/* Load the view object */
		$view = $this->getView('shipmentmethod', 'html');

		$model = VmModel::getModel('shipmentmethod');
		$msgtype = '';

		$cids = vRequest::getVar($this->_cidName, vRequest::getInt('virtuemart_shipment_id'));

		foreach($cids as $cid){
			if ($model->createClone($cid)) $msg = vmText::_('COM_VIRTUEMART_SHIPMENT_CLONED_SUCCESSFULLY');
			else {
				$msg = vmText::_('COM_VIRTUEMART_SHIPMENT_NOT_CLONED_SUCCESSFULLY');
				$msgtype = 'error';
			}
		}

		$mainframe->redirect('index.php?option=com_virtuemart&view=shipmentmethod', $msg, $msgtype);
	}
}
// pure php no closing tag


text:
<?php

Autoloader::map(array(
	'Matahari' => __DIR__.DS.'matahari.php'
));

View::composer('matahari::board', function($view)
{
	$view->output = Matahari::spit()->to_board();
});

Filter::register('matahari_board', function()
{
	echo View::make('matahari::board');
});

Filter::register('matahari_ff', function()
{
	echo Matahari::spit()->to_ff();
});

Filter::register('matahari_chrome', function()
{
	echo Matahari::spit()->to_chrome();
});


text:
#include "libxtreemfs/uuid_cache.h"

#include <time.h>

#include <map>
#include <string>
#include <vector>

#include "util/logging.h"

using namespace std;
using namespace xtreemfs::util;

namespace xtreemfs {

void UUIDCache::update(
    const std::string& uuid,
    const std::string& address,
    const uint32_t port,
    const time_t ttls) {
  boost::mutex::scoped_lock lock(mutex_);

  if (Logging::log->loggingActive(LEVEL_DEBUG)) {
    Logging::log->getLog(LEVEL_DEBUG)  << "UUID: registering new UUID "
        << uuid << " "
        << address << ":" << port
        << endl;
  }

  UUIDMapping uuidMapping = UUIDMapping();
  uuidMapping.address = address;
  uuidMapping.uuid = uuid;
  uuidMapping.port = port;
  uuidMapping.timeout = time(NULL) + ttls;  // calc timeout in seconds

  // address contains update-time to evict old entries
  cache_[uuid] = uuidMapping;
}

/**
 * Old UUIDs are invalidated but there is no active pulling of new UUIDs.
 */
std::string UUIDCache::get(const std::string& uuid) {
  boost::mutex::scoped_lock lock(mutex_);

  std::map<string, UUIDMapping >::iterator it = cache_.find(uuid);

  // entry found?
  if (it != cache_.end()) {
    // entry timed out?
    const UUIDMapping mapping = it->second;
    if (time(NULL) < mapping.timeout) {
      // Build ip-address:port from AddressMapping.
      ostringstream s;
      s << mapping.address << ":" << mapping.port;
      return s.str();
    } else {
      // Expired => Remove from cache_.
      if (Logging::log->loggingActive(LEVEL_DEBUG)) {
        Logging::log->getLog(LEVEL_DEBUG)  << "UUID expired:" << uuid << endl;
      }
      cache_.erase(it);
    }
  }

  if (Logging::log->loggingActive(LEVEL_DEBUG)) {
    Logging::log->getLog(LEVEL_DEBUG)  << "UUID cache miss:" << uuid << endl;
  }
  return "";
}

}  // namespace xtreemfs


text:
<Type Name="XmlSchemaDatatypeVariety" FullName="System.Xml.Schema.XmlSchemaDatatypeVariety">
  <TypeSignature Language="C#" Value="public enum XmlSchemaDatatypeVariety" />
  <AssemblyInfo>
    <AssemblyName>System.Xml</AssemblyName>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>System.Enum</BaseTypeName>
  </Base>
  <Docs>
    To be added.
    <remarks>To be added.</remarks>
    <since version=".NET 2.0" />
  </Docs>
  <Members>
    <Member MemberName="Atomic">
      <MemberSignature Language="C#" Value="Atomic" />
      <MemberType>Field</MemberType>
      <ReturnValue>
        <ReturnType>System.Xml.Schema.XmlSchemaDatatypeVariety</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <since version=".NET 2.0" />
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
    <Member MemberName="List">
      <MemberSignature Language="C#" Value="List" />
      <MemberType>Field</MemberType>
      <ReturnValue>
        <ReturnType>System.Xml.Schema.XmlSchemaDatatypeVariety</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <since version=".NET 2.0" />
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
    <Member MemberName="Union">
      <MemberSignature Language="C#" Value="Union" />
      <MemberType>Field</MemberType>
      <ReturnValue>
        <ReturnType>System.Xml.Schema.XmlSchemaDatatypeVariety</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <since version=".NET 2.0" />
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
  </Members>
</Type>


text:
#include <fstream>
#include "Config.h"
#include "Crypto.h"
#include "Timestamp.h"
#include "I2NPProtocol.h"
#include "NetDb.h"
#include "FS.h"
#include "util.h"
#include "version.h"
#include "Log.h"
#include "Family.h"
#include "RouterContext.h"

namespace i2p
{
	RouterContext context;

	RouterContext::RouterContext ():
		m_LastUpdateTime (0), m_AcceptsTunnels (true), m_IsFloodfill (false),
		m_StartupTime (0), m_Status (eRouterStatusOK), m_Error (eRouterErrorNone),
		m_NetID (I2PD_NET_ID)
	{
	}

	void RouterContext::Init ()
	{
		srand (i2p::util::GetMillisecondsSinceEpoch () % 1000);
		m_StartupTime = i2p::util::GetSecondsSinceEpoch ();
		if (!Load ())
			CreateNewRouter ();
		UpdateRouterInfo ();
	}

	void RouterContext::CreateNewRouter ()
	{
#if defined(__x86_64__) || defined(__i386__) || defined(_MSC_VER)
		m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519);
#else
		m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (i2p::data::SIGNING_KEY_TYPE_DSA_SHA1);
#endif
		SaveKeys ();
		NewRouterInfo ();
	}

	void RouterContext::NewRouterInfo ()
	{
		i2p::data::RouterInfo routerInfo;
		routerInfo.SetRouterIdentity (GetIdentity ());
		uint16_t port; i2p::config::GetOption("port", port);
		if (!port)
			port = rand () % (30777 - 9111) + 9111; // I2P network ports range
		bool ipv4; i2p::config::GetOption("ipv4", ipv4);
		bool ipv6; i2p::config::GetOption("ipv6", ipv6);
		bool nat;  i2p::config::GetOption("nat", nat);
		std::string ifname; i2p::config::GetOption("ifname", ifname);
		std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
		std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
		if (ipv4)
		{
			std::string host = "127.0.0.1";
			if (!i2p::config::IsDefault("host"))
				i2p::config::GetOption("host", host);
			else if (!nat && !ifname.empty())
				/* bind to interface, we have no NAT so set external address too */
				host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4

			if(ifname4.size())
				host = i2p::util::net::GetInterfaceAddress(ifname4, false).to_string();

			routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
			routerInfo.AddNTCPAddress (host.c_str(), port);
		}
		if (ipv6)
		{
			std::string host = "::";
			if (!i2p::config::IsDefault("host") && !ipv4) // override if v6 only
				i2p::config::GetOption("host", host);
			else if (!ifname.empty())
				host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6

			if(ifname6.size())
				host = i2p::util::net::GetInterfaceAddress(ifname6, true).to_string();

			routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
			routerInfo.AddNTCPAddress (host.c_str(), port);
		}

		routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
			i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
        routerInfo.SetProperty ("netId", std::to_string (m_NetID));
		routerInfo.SetProperty ("router.version", I2P_VERSION);
		routerInfo.CreateBuffer (m_Keys);
		m_RouterInfo.SetRouterIdentity (GetIdentity ());
		m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
	}

	void RouterContext::UpdateRouterInfo ()
	{
		m_RouterInfo.CreateBuffer (m_Keys);
		m_RouterInfo.SaveToFile (i2p::fs::DataDirPath (ROUTER_INFO));
		m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch ();
	}

	void RouterContext::SetStatus (RouterStatus status)
	{
		if (status != m_Status)
		{
			m_Status = status;
			m_Error = eRouterErrorNone;
			switch (m_Status)
			{
				case eRouterStatusOK:
					SetReachable ();
				break;
				case eRouterStatusFirewalled:
					SetUnreachable ();
				break;
				default:
					;
			}
		}
	}

	void RouterContext::UpdatePort (int port)
	{
		bool updated = false;
		for (auto& address : m_RouterInfo.GetAddresses ())
		{
			if (address->port != port)
			{
				address->port = port;
				updated = true;
			}
		}
		if (updated)
			UpdateRouterInfo ();
	}

	void RouterContext::UpdateAddress (const boost::asio::ip::address& host)
	{
		bool updated = false;
		for (auto& address : m_RouterInfo.GetAddresses ())
		{
			if (address->host != host && address->IsCompatible (host))
			{
				address->host = host;
				updated = true;
			}
		}
		auto ts = i2p::util::GetSecondsSinceEpoch ();
		if (updated || ts > m_LastUpdateTime + ROUTER_INFO_UPDATE_INTERVAL)
			UpdateRouterInfo ();
	}

	bool RouterContext::AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer)
	{
		bool ret = m_RouterInfo.AddIntroducer (introducer);
		if (ret)
			UpdateRouterInfo ();
		return ret;
	}

	void RouterContext::RemoveIntroducer (const boost::asio::ip::udp::endpoint& e)
	{
		if (m_RouterInfo.RemoveIntroducer (e))
			UpdateRouterInfo ();
	}

	void RouterContext::SetFloodfill (bool floodfill)
	{
		m_IsFloodfill = floodfill;
		if (floodfill)
			m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eFloodfill);
		else
		{
			m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () & ~i2p::data::RouterInfo::eFloodfill);
			// we don't publish number of routers and leaseset for non-floodfill
			m_RouterInfo.DeleteProperty (i2p::data::ROUTER_INFO_PROPERTY_LEASESETS);
			m_RouterInfo.DeleteProperty (i2p::data::ROUTER_INFO_PROPERTY_ROUTERS);
		}
		UpdateRouterInfo ();
	}

	std::string RouterContext::GetFamily () const
	{
		return m_RouterInfo.GetProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY);
	}

	void RouterContext::SetFamily (const std::string& family)
	{
		std::string signature;
		if (family.length () > 0)
			signature = i2p::data::CreateFamilySignature (family, GetIdentHash ());
		if (signature.length () > 0)
		{
			m_RouterInfo.SetProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY, family);
			m_RouterInfo.SetProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY_SIG, signature);
		}
		else
		{
			m_RouterInfo.DeleteProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY);
			m_RouterInfo.DeleteProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY_SIG);
		}
	}

	void RouterContext::SetBandwidth (char L) {
		uint16_t limit = 0;
		enum { low, high, extra } type = high;
		/* detect parameters */
		switch (L)
		{
			case i2p::data::CAPS_FLAG_LOW_BANDWIDTH1   : limit =   12; type = low;   break;
			case i2p::data::CAPS_FLAG_LOW_BANDWIDTH2   : limit =   48; type = low;   break;
			case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH1  : limit =   64; type = high;  break;
			case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH2  : limit =  128; type = high;  break;
			case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH3  : limit =  256; type = high;  break;
			case i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH1 : limit = 2048; type = extra; break;
			case i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH2 : limit = 9999; type = extra; break;
			default:
				 limit =  48; type = low;
		}
		/* update caps & flags in RI */
		auto caps = m_RouterInfo.GetCaps ();
		caps &= ~i2p::data::RouterInfo::eHighBandwidth;
		caps &= ~i2p::data::RouterInfo::eExtraBandwidth;
		switch (type)
		{
			case low   : /* not set */; break;
			case extra : caps |= i2p::data::RouterInfo::eExtraBandwidth; //  no break here
			case high  : caps |= i2p::data::RouterInfo::eHighBandwidth;  break;
		}
		m_RouterInfo.SetCaps (caps);
		UpdateRouterInfo ();
		m_BandwidthLimit = limit;
	}

	void RouterContext::SetBandwidth (int limit)
	{
		if      (limit > 2000) { SetBandwidth('X'); }
		else if (limit >  256) { SetBandwidth('P'); }
		else if (limit >  128) { SetBandwidth('O'); }
		else if (limit >   64) { SetBandwidth('N'); }
		else if (limit >   48) { SetBandwidth('M'); }
		else if (limit >   12) { SetBandwidth('L'); }
		else                   { SetBandwidth('K'); }
	}

	bool RouterContext::IsUnreachable () const
	{
		return m_RouterInfo.GetCaps () & i2p::data::RouterInfo::eUnreachable;
	}

	void RouterContext::SetUnreachable ()
	{
		// set caps
		m_RouterInfo.SetCaps (i2p::data::RouterInfo::eUnreachable | i2p::data::RouterInfo::eSSUTesting); // LU, B
		// remove NTCP address
		auto& addresses = m_RouterInfo.GetAddresses ();
		for (auto it = addresses.begin (); it != addresses.end (); ++it)
		{
			if ((*it)->transportStyle == i2p::data::RouterInfo::eTransportNTCP &&
				(*it)->host.is_v4 ())
			{
				addresses.erase (it);
				break;
			}
		}
		// delete previous introducers
		for (auto& addr : addresses)
			addr->introducers.clear ();

		// update
		UpdateRouterInfo ();
	}

	void RouterContext::SetReachable ()
	{
		// update caps
		uint8_t caps = m_RouterInfo.GetCaps ();
		caps &= ~i2p::data::RouterInfo::eUnreachable;
		caps |= i2p::data::RouterInfo::eReachable;
		caps |= i2p::data::RouterInfo::eSSUIntroducer;
		if (m_IsFloodfill)
			caps |= i2p::data::RouterInfo::eFloodfill;
		m_RouterInfo.SetCaps (caps);

		// insert NTCP back
		auto& addresses = m_RouterInfo.GetAddresses ();
		for (const auto& addr : addresses)
		{
			if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU &&
				addr->host.is_v4 ())
			{
				// insert NTCP address with host/port from SSU
				m_RouterInfo.AddNTCPAddress (addr->host.to_string ().c_str (), addr->port);
				break;
			}
		}
		// delete previous introducers
		for (auto& addr : addresses)
			addr->introducers.clear ();

		// update
		UpdateRouterInfo ();
	}

	void RouterContext::SetSupportsV6 (bool supportsV6)
	{
		if (supportsV6)
			m_RouterInfo.EnableV6 ();
		else
			m_RouterInfo.DisableV6 ();
		UpdateRouterInfo ();
	}

	void RouterContext::SetSupportsV4 (bool supportsV4)
	{
		if (supportsV4)
			m_RouterInfo.EnableV4 ();
		else
			m_RouterInfo.DisableV4 ();
		UpdateRouterInfo ();
	}

	void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host)
	{
		bool updated = false, found = false;
		int port = 0;
		auto& addresses = m_RouterInfo.GetAddresses ();
		for (auto& addr: addresses)
		{
			if (addr->host.is_v6 () && addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP)
			{
				if (addr->host != host)
				{
					addr->host = host;
					updated = true;
				}
				found = true;
			}
			else
				port = addr->port;
		}
		if (!found)
		{
			// create new address
			m_RouterInfo.AddNTCPAddress (host.to_string ().c_str (), port);
			auto mtu = i2p::util::net::GetMTU (host);
			if (mtu)
			{
				LogPrint (eLogDebug, "Router: Our v6 MTU=", mtu);
				if (mtu > 1472) { // TODO: magic constant
					mtu = 1472;
					LogPrint(eLogWarning, "Router: MTU dropped to upper limit of 1472 bytes");
				}
			}
			m_RouterInfo.AddSSUAddress (host.to_string ().c_str (), port, GetIdentHash (), mtu ? mtu : 1472); // TODO
			updated = true;
		}
		if (updated)
			UpdateRouterInfo ();
	}

	void RouterContext::UpdateStats ()
	{
		if (m_IsFloodfill)
		{
			// update routers and leasesets
			m_RouterInfo.SetProperty (i2p::data::ROUTER_INFO_PROPERTY_LEASESETS, std::to_string(i2p::data::netdb.GetNumLeaseSets ()));
			m_RouterInfo.SetProperty (i2p::data::ROUTER_INFO_PROPERTY_ROUTERS,   std::to_string(i2p::data::netdb.GetNumRouters ()));
			UpdateRouterInfo ();
		}
	}

	bool RouterContext::Load ()
	{
		std::ifstream fk (i2p::fs::DataDirPath (ROUTER_KEYS), std::ifstream::in | std::ifstream::binary);
		if (!fk.is_open ())	return false;
		fk.seekg (0, std::ios::end);
		size_t len = fk.tellg();
		fk.seekg (0, std::ios::beg);

		if (len == sizeof (i2p::data::Keys)) // old keys file format
		{
			i2p::data::Keys keys;
			fk.read ((char *)&keys, sizeof (keys));
			m_Keys = keys;
		}
		else // new keys file format
		{
			uint8_t * buf = new uint8_t[len];
			fk.read ((char *)buf, len);
			m_Keys.FromBuffer (buf, len);
			delete[] buf;
		}

		m_RouterInfo.SetRouterIdentity (GetIdentity ());
		i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO));
		if (!routerInfo.IsUnreachable ()) // router.info looks good
		{
			m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
			m_RouterInfo.SetProperty ("coreVersion", I2P_VERSION);
			m_RouterInfo.SetProperty ("router.version", I2P_VERSION);

			// Migration to 0.9.24. TODO: remove later
			m_RouterInfo.DeleteProperty ("coreVersion");
			m_RouterInfo.DeleteProperty ("stat_uptime");
		}
		else
		{
			LogPrint (eLogError, ROUTER_INFO, " is malformed. Creating new");
			NewRouterInfo ();
		}

		if (IsUnreachable ())
			SetReachable (); // we assume reachable until we discover firewall through peer tests

		return true;
	}

	void RouterContext::SaveKeys ()
	{
		// save in the same format as .dat files
		std::ofstream fk (i2p::fs::DataDirPath (ROUTER_KEYS), std::ofstream::binary | std::ofstream::out);
		size_t len = m_Keys.GetFullLen ();
		uint8_t * buf = new uint8_t[len];
		m_Keys.ToBuffer (buf, len);
		fk.write ((char *)buf, len);
		delete[] buf;
	}

	std::shared_ptr<i2p::tunnel::TunnelPool> RouterContext::GetTunnelPool () const
	{
		return i2p::tunnel::tunnels.GetExploratoryPool ();
	}

	void RouterContext::HandleI2NPMessage (const uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from)
	{
		i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from));
	}

	void RouterContext::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg)
	{
		std::unique_lock<std::mutex> l(m_GarlicMutex);
		i2p::garlic::GarlicDestination::ProcessGarlicMessage (msg);
	}

	void RouterContext::ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg)
	{
		std::unique_lock<std::mutex> l(m_GarlicMutex);
		i2p::garlic::GarlicDestination::ProcessDeliveryStatusMessage (msg);
	}

	void RouterContext::CleanupDestination ()
	{
		std::unique_lock<std::mutex> l(m_GarlicMutex);
		i2p::garlic::GarlicDestination::CleanupExpiredTags ();
	}

	uint32_t RouterContext::GetUptime () const
	{
		return i2p::util::GetSecondsSinceEpoch () - m_StartupTime;
	}
}


text:
require 'test_helper'
require 'db_helper'

class Information::ChartControllerTest < ActionController::TestCase
  include DBHelper

  def test_register_address
    authorize_request(request)
    post :register, address: 'some_address'
    assert_response :success
    assert_equal 'ok', JSON.parse(response.body)['status']

    get :list
    assert_response :success
    assert_includes JSON.parse(response.body), 'some_address'
  end

  def test_register_address_unauthorized
    authorize_request(request)
    get :list
    assert_response :success
    assert_not_includes JSON.parse(response.body), 'some_address'

    clear_authorization(request)
    post :register, address: 'some_address'
    assert_response 401
    authorize_request(request)
  end

  add_test_get_list
  add_test_register_address
  add_test_register_address_unauthorized
  add_test_deregister_address

end


text:
import React from 'react'
import agent from '../../shared/agent'

const Tags = props => {
  const tags = props.tags
  if (tags) {
    return (

        {tags.map(tag => {
          const handleClick = ev => {
            ev.preventDefault()
            props.onClickTag(tag, agent.Articles.byTag(tag))
          }

          return (

              {tag}

          )
        })}

    )
  } else {
    return
Loading Tags...

  }
}

export default Tags


text:
require 'spec_helper'

RSpec.describe ActiveJob::Retry::VariableOptionsValidator do
  let(:validator) { described_class.new(options) }
  subject(:validate!) { -> { validator.validate! } }

  context 'valid options' do
    context 'empty delays' do
      let(:options) { { delays: [] } }
      it { is_expected.to_not raise_error }
    end

    context 'with delays' do
      let(:options) { { delays: [0, 3, 6, 10_000] } }
      it { is_expected.to_not raise_error }
    end

    context 'min and max delay multipliers' do
      let(:options) do
        { delays: [0, 10, 60], min_delay_multiplier: 0.8, max_delay_multiplier: 1.2 }
      end
      it { is_expected.to_not raise_error }
    end

    context 'fatal exceptions' do
      let(:options) { { delays: [0, 10, 60], fatal_exceptions: [RuntimeError] } }
      it { is_expected.to_not raise_error }
    end

    context 'retryable_exceptions' do
      let(:options) do
        { delays: [], retryable_exceptions: [StandardError, NoMethodError] }
      end
      it { is_expected.to_not raise_error }
    end

    context 'multiple options' do
      let(:options) { { delays: [0, 10, 60], retryable_exceptions: [RuntimeError] } }

      it { is_expected.to_not raise_error }
    end
  end

  context 'invalid options' do
    context 'without delays' do
      let(:options) { {} }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'with limit' do
      let(:options) { { limit: 5 } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'with delay' do
      let(:options) { { delay: 5 } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'min delay multiplier only' do
      let(:options) { { min_delay_multiplier: 0.8 } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'max delay multiplier only' do
      let(:options) { { max_delay_multiplier: 0.8 } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'bad fatal exceptions' do
      let(:options) { { fatal_exceptions: ['StandardError'] } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'bad retryable_exceptions' do
      let(:options) { { retryable_exceptions: [:runtime] } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end

    context 'retry and fatal exceptions together' do
      let(:options) { { fatal_exceptions: [StandardError], retryable_exceptions: [] } }
      it { is_expected.to raise_error(ActiveJob::Retry::InvalidConfigurationError) }
    end
  end
end


text:
export GOOGLE_APPLICATION_CREDENTIALS=$KOKORO_KEYSTORE_DIR/72523_go_integration_service_account
# Removing the GCLOUD_TESTS_GOLANG_PROJECT_ID setting may make some integration
# tests (like profiler's) silently skipped, so make sure you know what you are
# doing when changing / removing the next line.
export GCLOUD_TESTS_GOLANG_PROJECT_ID=dulcet-port-762
export GCLOUD_TESTS_GOLANG_KEY=$GOOGLE_APPLICATION_CREDENTIALS
export GCLOUD_TESTS_GOLANG_FIRESTORE_PROJECT_ID=gcloud-golang-firestore-tests
export GCLOUD_TESTS_GOLANG_FIRESTORE_KEY=$KOKORO_KEYSTORE_DIR/72523_go_firestore_integration_service_account
export GCLOUD_TESTS_API_KEY=`cat $KOKORO_KEYSTORE_DIR/72523_go_gcloud_tests_api_key`
export GCLOUD_TESTS_GOLANG_KEYRING=projects/dulcet-port-762/locations/global/keyRings/go-integration-test
export GCLOUD_TESTS_GOLANG_PROFILER_ZONE="us-west1-b"

# Fail on any error
set -eo pipefail

# Display commands being run
set -x

# cd to project dir on Kokoro instance
cd git/gocloud

go version

# Set $GOPATH
export GOPATH="$HOME/go"
export GOCLOUD_HOME=$GOPATH/src/cloud.google.com/go/
export PATH="$GOPATH/bin:$PATH"

# Move code into $GOPATH and get dependencies
mkdir -p $GOCLOUD_HOME
git clone . $GOCLOUD_HOME
cd $GOCLOUD_HOME

try3() { eval "$*" || eval "$*" || eval "$*"; }

download_deps() {
    if [[ `go version` == *"go1.11"* ]] || [[ `go version` == *"go1.12"* ]]; then
        export GO111MODULE=on
        # All packages, including +build tools, are fetched.
        try3 go mod download
    else
        # Because we don't provide -tags tools, the +build tools
        # dependencies aren't fetched.
        try3 go get -v -t ./...

        go get github.com/jstemmer/go-junit-report
    fi
}

download_deps
go install github.com/jstemmer/go-junit-report
./internal/kokoro/vet.sh

mkdir $KOKORO_ARTIFACTS_DIR/tests

# Takes the kokoro output log (raw stdout) and creates a machine-parseable xml
# file (xUnit). Then it exits with whatever exit code the last command had.
create_junit_xml() {
  last_status_code=$?

  cat $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt \
    | go-junit-report > $KOKORO_ARTIFACTS_DIR/tests/sponge_log.xml

  exit $last_status_code
}

trap create_junit_xml EXIT ERR

# Run tests and tee output to log file, to be pushed to GCS as artifact.
go test -race -v -timeout 30m ./... 2>&1 \
  | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt


text:
{{#items}}

	{{text}}

{{/items}}


text:
'use strict';

const expect = require('chai').expect;
const extractName = require('../../../name/name-source-spec-helper');
const NgModelNameSource = require('../../../../lib/angular/angular-js/name/ng-model-name-source');

describe('NgModelNameSource', () => {
  let source = new NgModelNameSource();

  it('should extract name', () => {
    expect(extractName('

', source)).to.equal('text');
    expect(extractName('

', source)).to.equal('text');
    expect(extractName('

', source)).to.equal('text');
  });
});


text:
import { connect } from 'react-redux';
import Editor from './Editor';
import { playerAction } from './EditorModule';

const mapStateToProps = (state) => {
  return {
    deckAction: state.editor.deckAction
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    buttonAction: (action) => dispatch(playerAction(action)),
  };
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(Editor);


text:
Ext.Loader.setConfig({
	enabled : true
});

Ext.application({
	name : "acesure.initialization",
	appFolder : '/page/initialization/script',
	layout : "fit",
	controllers : ['InitializationController'],
	// 当前页面加载完成执行的函数
	launch : function() {
		// 页面加载完成之后执行
		Ext.create("acesure.initialization.view.MainPanel");
	}
});

Ext.define('acesure.initialization.view.MainPanel', {
	extend : 'Ext.panel.Panel',
	height : 650,
	width : 960,
	border : false,
	renderTo : 'content',
	layout:"fit",
	initComponent : function() {
		var me = this;
		me.items = [{
			xtype : 'panel',
			region : 'center',
			id: 'initializationPanel',
			border:false,
			items : [{
				xtype : 'InitializationList'
			}]
		}];

		me.callParent(arguments);
	}
});


text:
import sys, os
import wx

class AppEventManager:
    ui_events = [
                    wx.ID_NEW, wx.ID_OPEN, wx.ID_CLOSE_ALL, wx.ID_CLOSE,
                    wx.ID_REVERT, wx.ID_SAVE, wx.ID_SAVEAS, wx.ID_UNDO,
                    wx.ID_REDO, wx.ID_PRINT, wx.ID_PRINT_SETUP, wx.ID_PREVIEW,
                    wx.ID_EXIT
                ]

    def __init__(self):
        pass

    def RegisterEvents(self):
        app = wx.GetApp()
        #app.AddHandlerForID(wx.ID_EXIT, self.OnExit)
        #app.AddHandlerForID(wx.ID_ABOUT, self.OnAbout)

        for eventID in self.ui_events:
            app.AddHandlerForID(eventID, self.ProcessEvent)
            app.AddUIHandlerForID(eventID, self.ProcessUpdateUIEvent)

class AppEventHandlerMixin:
    """
    The purpose of the AppEventHandlerMixin is to provide a centralized
    location to manage menu and toolbar events. In an IDE which may have
    any number of file editors and services open that may want to respond
    to certain menu and toolbar events (e.g. copy, paste, select all),
    we need this to efficiently make sure that the right handler is handling
    the event.

    To work with this system, views must call
            Add(UI)HandlerForID(ID, handlerFunc)
    in their EVT_SET_FOCUS handler, and call Remove(UI)HandlerForID(ID) in their
    EVT_KILL_FOCUS handler.
    """

    def __init__(self):
        self.handlers = {}
        self.uihandlers = {}

        # When a view changes the handler, move the old one here.
        # Then "pop" the handler when the view loses the focus
        self.pushed_handlers = {}
        self.pushed_uihandlers = {}

    def AddHandlerForIDs(self, eventID_list, handlerFunc):
        for eventID in eventID_list:
            self.AddHandlerForID(eventID, handlerFunc)

    def AddHandlerForID(self, eventID, handlerFunc):
        self.Bind(wx.EVT_MENU, self.HandleEvent, id=eventID)

        if eventID in self.handlers:
            self.pushed_handlers[eventID] = self.handlers[eventID]

        self.handlers[eventID] = handlerFunc

    def AddUIHandlerForID(self, eventID, handlerFunc):
        self.Bind(wx.EVT_UPDATE_UI, self.HandleUpdateUIEvent, id=eventID)

        if eventID in self.uihandlers:
            self.pushed_uihandlers[eventID] = self.uihandlers[eventID]

        self.uihandlers[eventID] = handlerFunc

    def RemoveHandlerForIDs(self, eventID_list):
        for eventID in eventID_list:
            self.RemoveHandlerForID(eventID)

    def RemoveHandlerForID(self, eventID):
        self.Unbind(wx.EVT_MENU, id=eventID)
        self.handlers[eventID] = None

        if eventID in self.pushed_handlers:
            self.handlers[eventID] = self.pushed_handlers[eventID]

    def RemoveUIHandlerForID(self, eventID):
        self.Unbind(wx.EVT_UPDATE_UI, id=eventID)
        self.uihandlers[eventID] = None

        if eventID in self.pushed_uihandlers:
            self.uihandlers[eventID] = self.pushed_uihandlers[eventID]

    def HandleEvent(self, event):
        e_id = event.GetId()
        if e_id in self.handlers:
            handler = self.handlers[e_id]
            try:
                if handler:
                    return handler(event)
            except wx.PyDeadObjectError:
                self.RemoveHandlerForID(e_id)
        else:
            event.Skip()

        return False

    def HandleUpdateUIEvent(self, event):
        e_id = event.GetId()
        if e_id in self.uihandlers:
            handler = self.uihandlers[e_id]
            try:
                if handler:
                    return handler(event)
            except wx.PyDeadObjectError:
                self.RemoveUIHandlerForID(e_id)
        else:
            event.Skip()

        return False