text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.semantic.model.filter;

import com.semantic.lucene.fields.LastModifiedField;
import com.semantic.model.IQueryGenerator;
import com.semantic.model.OntologyNode;
import java.util.Calendar;
import javax.xml.bind.annotation.XmlAttribute;
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.search.Query;

/**
 *
 * @author Christian Plonka (cplonka81@gmail.com)
 */
public class OFixedFileDateFilter extends OntologyNode implements IQueryGenerator {

    public static enum DATE {

        TODAY("Today"),
        YESTERDAY("Yesterday"),
        THIS_WEEK("This week"),
        LAST_WEEK("Last week"),
        THIS_MONTH("This month"),
        LAST_MONTH("Last month"),
        THIS_YEAR("This year");

        private final String name;

        private DATE(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return name;
        }
    }

    @XmlAttribute
    private DATE date = DATE.TODAY;
    /* cache query */
    protected Query query;

    public OFixedFileDateFilter() {
        this(DATE.TODAY);
    }

    public OFixedFileDateFilter(DATE date) {
        super("OFixedFileDateFilter");
        setDate(date);
    }

    @Override
    public Query createQuery() {
        Calendar[] dates = generate(date);
        /* we dont cache query because of the dates */
        return LongPoint.newRangeQuery(
                getLuceneField(),
                dates[0].getTimeInMillis(),
                dates[1].getTimeInMillis());
    }

    static Calendar[] generate(DATE date) {
        Calendar to = Calendar.getInstance();
        Calendar from = Calendar.getInstance();
        to.set(Calendar.MINUTE, 0);
        to.set(Calendar.SECOND, 0);
        from.set(Calendar.MINUTE, 0);
        from.set(Calendar.SECOND, 0);
        //
        switch (date) {
            case TODAY:
                from.set(Calendar.HOUR_OF_DAY, 0);
                break;
            case YESTERDAY:
                from.add(Calendar.DAY_OF_MONTH, -1);
                from.set(Calendar.HOUR_OF_DAY, 0);
                to.add(Calendar.DAY_OF_MONTH, -1);
                to.set(Calendar.HOUR_OF_DAY, 24);
                break;
            case THIS_WEEK:
                from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
                from.set(Calendar.HOUR_OF_DAY, 0);
                break;
            case LAST_WEEK:
                from.add(Calendar.WEEK_OF_MONTH, -2);
                from.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
                from.set(Calendar.HOUR_OF_DAY, 24);

                to.add(Calendar.WEEK_OF_MONTH, -1);
                to.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
                to.set(Calendar.HOUR_OF_DAY, 24);
                break;
            case THIS_MONTH:
                from.set(Calendar.DAY_OF_MONTH, 1);
                from.set(Calendar.HOUR_OF_DAY, 0);
                break;
            case LAST_MONTH:
                from.add(Calendar.MONTH, -1);
                from.set(Calendar.DAY_OF_MONTH, 1);
                from.set(Calendar.HOUR_OF_DAY, 0);

                to.set(Calendar.DAY_OF_MONTH, 1);
                to.set(Calendar.HOUR_OF_DAY, 0);
                break;
            case THIS_YEAR:
                from.set(Calendar.MONTH, 0);
                from.set(Calendar.DAY_OF_MONTH, 1);
                from.set(Calendar.HOUR_OF_DAY, 0);
                break;
        }
        return new Calendar[]{from, to};
    }

    @Override
    public String getName() {
        return date.toString();
    }

    @Override
    public String getLuceneField() {
        return LastModifiedField.NAME;
    }

    public void setDate(DATE date) {
        if (!this.date.equals(date)) {
            firePropertyChange("property_date", this.date, this.date = date);
        }
    }

    public DATE getDate() {
        return date;
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Propolomyces versicolor var. betulae

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

include SpecInfra::Helper::RedHat

describe process("memcached") do
  let(:stdout) { " 1407\n" }
  its(:pid) { should eq 1407 }
  its(:command) { should eq "ps -C memcached -o pid= | head -1" }
end

describe process("memcached") do
  let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" }
  its(:args) { should match /-c 30000\b/ }
  its(:command) { should eq "ps -C memcached -o args= | head -1" }
end

describe process("memcached") do
  let(:stdout) { "nobody\n" }
  its(:user)  { should eq "nobody" }
  its(:command) { should eq "ps -C memcached -o user= | head -1" }
end

describe process("memcached") do
  let(:stdout) { "nobody\n" }
  its(:group)  { should eq "nobody" }
  its(:command) { should eq "ps -C memcached -o group= | head -1" }
end

describe process("memcached") do
  context "when running" do
    let(:stdout) { " 1407\n" }
    it { should be_running }
    its(:command) { should eq "ps -C memcached -o pid= | head -1" }
  end

  context "when not running" do
    let(:stdout) { " 1407\n" }
    it { should be_running }
    its(:command) { should eq "ps -C memcached -o pid= | head -1" }
  end
end


text:
package com.codecompiler.configuration;

import org.junit.Assert;
import org.junit.Test;

/**
 * Created by Manohar Prabhu on 6/1/2016.
 */
public class RabbitMQConfigurationTest {
    @Test
    public void testRabbitMQConfiguration() {
        RabbitMQConfiguration rabbitMQConfiguration = new RabbitMQConfiguration();
        Assert.assertEquals("queue", rabbitMQConfiguration.queue().getName());
        Assert.assertEquals("exchange", rabbitMQConfiguration.exchange().getName());
        Assert.assertEquals("receiveMessage", RabbitMQConfiguration.METHOD_NAME);
        Assert.assertEquals("exchange", rabbitMQConfiguration.binding(rabbitMQConfiguration.queue(), rabbitMQConfiguration.exchange()).getExchange());
        Assert.assertNotNull(rabbitMQConfiguration.binding(rabbitMQConfiguration.queue(), rabbitMQConfiguration.exchange()));
        Assert.assertNotNull(rabbitMQConfiguration.connectionFactory());
    }
}


text:
var _ = require('lodash');
var path = require('path');
var chalk = require('chalk');
var Liftoff = require('liftoff');
var tildify = require('tildify');
var interpret = require('interpret');

var completion = require('../lib/completion');

var logger = console;

// set env var for ORIGINAL cwd
// before anything touches it
process.env.INIT_CWD = process.cwd();

var pkg = require('../package');

// Options Definition
var od = {
    'help': {
        alias: 'h',
        flag: true,
        help: 'Display this help text.'
    },
    'base': {
        help: 'Specify an alternate base path. By default, all file paths are relative to the flitfile.'
    },
    'flitfile': {
        help: 'Specify an alternate flitfile. By default, flit looks in the ' +
            'current or parent directories for the nearest flitfile.js or flitfile.coffee file.'
    },
    'require': {
        alias: 'r',
        help: 'Modules to pre-load'
    },
    'verbose': {
        alias: 'v',
        flag: true,
        help: 'Verbose mode. A lot more information output.'
    },
    'version': {
        alias: 'V',
        flag: true,
        help: 'Print the flit version. Combine with --verbose for more info.'
    },
    'completion': {
        help: 'Output shell auto-completion rules.'
    }
};

var parser = nomnom(od);
var options = parser.parse();

// Do stuff based on CLI options.
if ('completion' in options) {
    completion(options.completion);
}

var cli = new Liftoff({
    name: 'flit',
    completions: completion,
    extensions: interpret.jsVariants
});

// wire up a few err listeners to liftoff
cli.on('require', function (name) {
    if (options.verbose) {
        logger.log('Requiring external module', chalk.magenta(name));
    }
});

cli.on('requireFail', function (name) {
    logger.error(chalk.red('Failed to load external module'), chalk.magenta(name));
});

cli.launch({
    cwd: options.base,
    configPath: options.flitfile,
    require: options.require,
    completion: options.completion
}, invoke);

function invoke(env) {
    if (options.version) {
        console.log(pkg.name, 'v' + pkg.version);
    }

    if (!env.modulePath || !env.configPath) {
        if (options.help) {
            return console.log(parser.getUsage());
        }
        if (options.version) return;
    }

    if (!env.modulePath) {
        logger.error(
            chalk.red('Local flit not found in'),
            chalk.magenta(tildify(env.cwd))
        );
        logger.log(chalk.red('Try running: npm install flit'));
        process.exit(1);
    }

    if (!env.configPath) {
        logger.error(chalk.red('No flitfile found'));
        process.exit(1);
    }

    require(env.modulePath).cli(env, nomnom.bind(null, od));
}

function nomnom() {
    var _nomnom = require('nomnom')().script('flit');
    var args = Array.prototype.slice.call(arguments, 0);
    args.unshift({});
    var options = _.assign.apply(_, args);
    _.forEach(options, function (option, key) {
        if (typeof options === 'function') {
            console.error('Command not supported now.');
        } else {
            _nomnom.option(key, parse(option))
        }
    });

    function parse(option) {
        return _.transform(option, function (result, value, key) {
            if (['shortcut', 'short', 'alias'].indexOf(key) >= 0) {
                result.abbr = value;
            } else if (['description', 'desc', 'help'].indexOf(key) >= 0) {
                result.help = value;
            } else if (['flag', 'boolean'].indexOf(key) >= 0 || (key === 'type' && value === 'boolean')) {
                result.flag = true;
            } else {
                result[key] = value;
            }
        });
    }
    return _nomnom;
}


text: `dirname $0`/run.sh org.demo.PerfTest -props config.xml $*


text:
<?php
namespace App\Model\Table;

use App\Model\Entity\Board;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
 * Boards Model
 *
 * @property \Cake\ORM\Association\BelongsTo $Users
 */
class BoardsTable extends Table
{

    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('boards');
        $this->displayField('name');
        $this->primaryKey('id');

        $this->addBehavior('Timestamp');

        $this->belongsTo('Users', [
            'foreignKey' => 'user_id',
            'joinType' => 'INNER'
        ]);
    }

    /**
     * Default validation rules.
     *
     * @param \Cake\Validation\Validator $validator Validator instance.
     * @return \Cake\Validation\Validator
     */
    public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create');

        /*$validator
            ->requirePresence('uuid', 'create')
            ->notEmpty('uuid');

        $validator
            ->requirePresence('name', 'create')
            ->notEmpty('name');

        $validator
            ->requirePresence('description', 'create')
            ->notEmpty('description');

        $validator
            ->add('status', 'valid', ['rule' => 'numeric'])
            ->requirePresence('status', 'create')
            ->notEmpty('status');*/

        return $validator;
    }

    /**
     * Returns a rules checker object that will be used for validating
     * application integrity.
     *
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
     * @return \Cake\ORM\RulesChecker
     */
    /*public function buildRules(RulesChecker $rules)
    {
        $rules->add($rules->existsIn(['user_id'], 'Users'));
        return $rules;
    }*/

    public function getIDbyUUID($uuid)
    {
        $result = $this->find()
            ->where(['Boards.uuid' => $uuid])
            ->first();

        if($result)
        {
            return $result->id;
        }
        return null;
    }
}


text:
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title>create</title>
</head>
<body>
    <?php require "header.php"; ?>
<?php

var_dump ($_POST);

if (!is_dir('posts')){
   mkdir ('posts');
}

$textzone = htmlspecialchars($_GET['contenu']);
$titre = htmlspecialchars($_GET['titre']);
$file = fopen('posts/' .$titre . ".txt", "w");
fwrite($file, "Contenu :".$textzone);
fclose($file);

?>

<script>
location.href="index.php";
        </script>

</body>
</html>


text:
using System;
using System.Xml.Serialization;

namespace EZOper.NetSiteUtilities.AopApi
{
    /// <summary>
    /// AlipayInsDataAutodamageEstimateQueryModel Data Structure.
    /// </summary>
    [Serializable]
    public class AlipayInsDataAutodamageEstimateQueryModel : AopObject
    {
        /// <summary>
        /// 保险公司定损单号,同之前调用的"提交车险图像定损请求"接口中的定损单号。
        /// </summary>
        [XmlElement("estimate_no")]
        public string EstimateNo { get; set; }
    }
}


text:
angular
    .module(HygieiaConfig.module + '.core')
    .directive('selectOnClick', function () {
    return {
        restrict: 'A',
        link: function (scope, element) {
            var focusedElement;
            element.on('click', function () {
                if (focusedElement != this) {
                    this.select();
                    focusedElement = this;
                }
            });
            element.on('blur', function () {
                focusedElement = null;
            });
        }
    };
});


text:
const createType = require('../util/createType')
const { getRarity } = require('../util/getRarity')

const unsafeNames = {
  'Common Core Crystal': true,
  'Unnamed Core Crystal': true
}

module.exports = createType({
  type: 'CoreCrystal',
  dataFile: 'ITM_CrystalList.json',
  nameFile: 'itm_crystal.json',
  getProperties: async ({ raw, name }) => {
    const rarity = await getRarity(raw.Rarity)
    const safeName = unsafeNames[name] ? `${name} (${raw.id})` : name
    return {
      name: safeName,
      display_name: name,
      rarity,
      price: raw.Price
    }
  }
})


text:
'use strict';
var fs = require('fs');
var ModuleLoader = require('../../util/moduleLoader');

var angular = require('camunda-bpm-sdk-js/vendor/angular'),
  Viewer = require('../../util/viewer'),
  template = fs.readFileSync(
    __dirname + '/cam-widget-bpmn-viewer.html',
    'utf8'
  );

module.exports = [
  '$q',
  '$document',
  '$compile',
  '$location',
  '$rootScope',
  'search',
  'debounce',
  function($q, $document, $compile, $location, $rootScope, search, debounce) {
    return {
      scope: {
        diagramData: '=',
        key: '@',
        control: '=?',
        disableNavigation: '&',
        onLoad: '&',
        onClick: '&',
        onMouseEnter: '&',
        onMouseLeave: '&',
        bpmnJsConf: '=?'
      },

      template: template,

      link: function($scope, $element) {
        var viewer = null;
        var canvas = null;
        var definitions;
        var diagramContainer = $element[0].querySelector('.diagram-holder');

        function attachDiagram() {
          diagramContainer.appendChild(viewer._container);
        }

        function detatchDiagram() {
          diagramContainer.removeChild(viewer._container);
        }

        $scope.grabbing = false;

        // parse boolean
        $scope.disableNavigation = $scope.$eval($scope.disableNavigation);

        // --- CONTROL FUNCTIONS ---
        $scope.control = $scope.control || {};

        $scope.control.highlight = function(id) {
          canvas.addMarker(id, 'highlight');

          $element.find('[data-element-id="' + id + '"]>.djs-outline').attr({
            rx: '14px',
            ry: '14px'
          });
        };

        $scope.control.clearHighlight = function(id) {
          canvas.removeMarker(id, 'highlight');
        };

        $scope.control.isHighlighted = function(id) {
          return canvas.hasMarker(id, 'highlight');
        };

        // config: text, tooltip, color, position
        $scope.control.createBadge = function(id, config) {
          var overlays = viewer.get('overlays');

          var htmlElement;
          if (config.html) {
            htmlElement = config.html;
          } else {
            htmlElement = document.createElement('span');
            if (config.color) {
              htmlElement.style['background-color'] = config.color;
            }
            if (config.tooltip) {
              htmlElement.setAttribute('tooltip', config.tooltip);
              htmlElement.setAttribute('tooltip-placement', 'top');
            }
            if (config.text) {
              htmlElement.appendChild(document.createTextNode(config.text));
            }
          }

          var overlayId = overlays.add(id, {
            position: config.position || {
              bottom: 0,
              right: 0
            },
            show: {
              minZoom: -Infinity,
              maxZoom: +Infinity
            },
            html: htmlElement
          });

          $compile(htmlElement)($scope);

          return overlayId;
        };

        // removes all badges for an element with a given id
        $scope.control.removeBadges = function(id) {
          viewer.get('overlays').remove({element: id});
        };

        // removes a single badge with a given id
        $scope.control.removeBadge = function(id) {
          viewer.get('overlays').remove(id);
        };

        $scope.control.getViewer = function() {
          return viewer;
        };

        $scope.control.scrollToElement = function(element) {
          var height, width, x, y;

          var elem = viewer.get('elementRegistry').get(element);
          var viewbox = canvas.viewbox();

          height = Math.max(viewbox.height, elem.height);
          width = Math.max(viewbox.width, elem.width);

          x = Math.min(
            Math.max(viewbox.x, elem.x - viewbox.width + elem.width),
            elem.x
          );
          y = Math.min(
            Math.max(viewbox.y, elem.y - viewbox.height + elem.height),
            elem.y
          );

          canvas.viewbox({
            x: x,
            y: y,
            width: width,
            height: height
          });
        };

        $scope.control.getElement = function(elementId) {
          return viewer.get('elementRegistry').get(elementId);
        };

        $scope.control.getElements = function(filter) {
          return viewer.get('elementRegistry').filter(filter);
        };

        $scope.loaded = false;
        $scope.control.isLoaded = function() {
          return $scope.loaded;
        };

        $scope.control.addAction = function(config) {
          var container = $element.find('.actions');
          var htmlElement = config.html;
          container.append(htmlElement);
          $compile(htmlElement)($scope);
        };

        var heatmapImage;

        $scope.control.addImage = function(image, x, y) {
          return preloadImage(image).then(
            function(preloadedElement) {
              var width = preloadedElement.offsetWidth;
              var height = preloadedElement.offsetHeight;
              var imageElement = $document[0].createElementNS(
                'http://www.w3.org/2000/svg',
                'image'
              );

              imageElement.setAttributeNS(
                'http://www.w3.org/1999/xlink',
                'xlink:href',
                image
              );
              imageElement.setAttributeNS(null, 'width', width);
              imageElement.setAttributeNS(null, 'height', height);
              imageElement.setAttributeNS(null, 'x', x);
              imageElement.setAttributeNS(null, 'y', y);

              $document[0].body.removeChild(preloadedElement);
              canvas._viewport.appendChild(imageElement);

              heatmapImage = angular.element(imageElement);
              return heatmapImage;
            },
            function(preloadedElement) {
              $document[0].body.removeChild(preloadedElement);
            }
          );
        };

        function preloadImage(img) {
          var body = $document[0].body;
          var deferred = $q.defer();
          var imageElement = angular
            .element('<img>')
            .css('position', 'absolute')
            .css('left', '-9999em')
            .css('top', '-9999em')
            .attr('src', img)[0];

          imageElement.onload = function() {
            deferred.resolve(imageElement);
          };

          imageElement.onerror = function() {
            deferred.reject(imageElement);
          };

          body.appendChild(imageElement);

          return deferred.promise;
        }

        var bpmnJsConf = $scope.bpmnJsConf;

        var bpmnJsModules = [];
        if (bpmnJsConf && bpmnJsConf.additionalModules) {
          angular.forEach(ModuleLoader.load(), function(module, name) {
            if (bpmnJsConf.additionalModules[name]) {
              bpmnJsModules.push(module);
            }
          });
        }

        viewer = Viewer.generateViewer({
          width: '100%',
          height: '100%',
          canvas: {
            deferUpdate: false
          },
          key: $scope.key,
          disableNavigation: $scope.disableNavigation,
          additionalModules: bpmnJsModules,
          moddleExtensions: window.bpmnJsModdleExtensions || {}
        });

        if (!viewer.cached) {
          // attach diagram immediately to avoid having the bpmn logo for viewers that are not cached
          attachDiagram();
        }

        // The following logic mirrors diagram-js to defer its update of the viewbox change.
        // We tell diagram-js to not defer the update (see above) and do it ourselves instead.
        // Only difference: We use a delay of 0. This causes the update to basically be propagated
        // immediately after the current execution is finished (instead of halting the execution
        // until the viewbox changes and all event listeners are executed). This results in a much
        // better performance while moving the diagram, but at a cost: In the interval between the
        // trigger of the viewbox change and the calculation of the event handlers in the debounced
        // execution, things like badges or migration arrows are at the wrong position; they feel
        // like they are "dragged behind". Therefore, we temporarily hide the overlays.

        // patch show and hide of overlays
        var originalShow = viewer
          .get('overlays')
          .show.bind(viewer.get('overlays'));
        viewer.get('overlays').show = function() {
          viewer.get('eventBus').fire('overlays.show');
          originalShow();
        };

        var originalHide = viewer
          .get('overlays')
          .hide.bind(viewer.get('overlays'));
        viewer.get('overlays').hide = function() {
          viewer.get('eventBus').fire('overlays.hide');
          originalHide();
        };

        var showAgain = debounce(function() {
          viewer.get('overlays').show();
        }, 300);

        var originalViewboxChanged = viewer
          .get('canvas')
          ._viewboxChanged.bind(viewer.get('canvas'));
        var debouncedOriginal = debounce(function() {
          originalViewboxChanged();
          viewer.get('overlays').hide();
          showAgain();
        }, 0);
        viewer.get('canvas')._viewboxChanged = function() {
          debouncedOriginal();
        };

        var diagramData = null;

        $scope.$watch('diagramData', function(newValue) {
          if (newValue) {
            diagramData = newValue;
            renderDiagram();
          }
        });

        function handleViewerLoad() {
          canvas = viewer.get('canvas');
          definitions = viewer._definitions;
          setupEventListeners();
          zoom();
          $scope.loaded = true;
        }

        function renderDiagram() {
          // if there is a cached viewer, no need to import data
          if (viewer.cached) {
            attachDiagram();
            handleViewerLoad();
            return $scope.onLoad();
          } else if (diagramData) {
            $scope.loaded = false;

            var useDefinitions = typeof diagramData === 'object';

            var importFunction = (useDefinitions
              ? viewer.open
              : viewer.importXML
            ).bind(viewer);

            var diagram = diagramData;
            if (useDefinitions) {
              viewer._setDefinitions(diagramData);
              diagram = diagramData.diagrams[0];
            }

            importFunction(diagram, function(err, warn) {
              var applyFunction = useDefinitions
                ? function(fn) {
                    fn();
                  }
                : $scope.$apply.bind($scope);

              applyFunction(function() {
                if (err) {
                  $scope.error = err;
                  return;
                }

                $scope.warn = warn;

                handleViewerLoad();
                return $scope.onLoad();
              });
            });
          }
        }

        function zoom() {
          if (canvas) {
            var viewbox = JSON.parse(
              ($location.search() || {}).viewbox || '{}'
            )[definitions.id];

            if (viewbox) {
              canvas.viewbox(viewbox);
            } else {
              canvas.zoom('fit-viewport', 'auto');
            }
          }
        }

        var mouseReleaseCallback = function() {
          $scope.grabbing = false;
          document.removeEventListener('mouseup', mouseReleaseCallback);
          $scope.$apply();
        };

        function onClick(e) {
          // e.element = the model element
          // e.gfx = the graphical element
          $scope.onClick({element: e.element, $event: e.originalEvent});
        }

        function onHover(e) {
          $scope.onMouseEnter({element: e.element, $event: e.originalEvent});
        }

        function onOut(e) {
          $scope.onMouseLeave({element: e.element, $event: e.originalEvent});
        }

        function onMousedown() {
          $scope.grabbing = true;
          document.addEventListener('mouseup', mouseReleaseCallback);
          $scope.$apply();
        }

        var onViewboxChange = debounce(function(e) {
          var viewbox = JSON.parse(($location.search() || {}).viewbox || '{}');

          viewbox[definitions.id] = {
            x: e.viewbox.x,
            y: e.viewbox.y,
            width: e.viewbox.width,
            height: e.viewbox.height
          };

          search.updateSilently({
            viewbox: JSON.stringify(viewbox)
          });

          var phase = $rootScope.$$phase;
          if (phase !== '$apply' && phase !== '$digest') {
            $scope.$apply(function() {
              $location.replace();
            });
          } else {
            $location.replace();
          }
        }, 500);

        function setupEventListeners() {
          var eventBus = viewer.get('eventBus');
          eventBus.on('element.click', onClick);
          eventBus.on('element.hover', onHover);
          eventBus.on('element.out', onOut);
          eventBus.on('element.mousedown', onMousedown);
          eventBus.on('canvas.viewbox.changed', onViewboxChange);
        }

        function clearEventListeners() {
          var eventBus = viewer.get('eventBus');
          eventBus.off('element.click', onClick);
          eventBus.off('element.hover', onHover);
          eventBus.off('element.out', onOut);
          eventBus.off('element.mousedown', onMousedown);
          eventBus.off('canvas.viewbox.changed', onViewboxChange);
        }

        $scope.zoomIn = function() {
          viewer.get('zoomScroll').zoom(1, {
            x: $element[0].offsetWidth / 2,
            y: $element[0].offsetHeight / 2
          });
        };

        $scope.zoomOut = function() {
          viewer.get('zoomScroll').zoom(-1, {
            x: $element[0].offsetWidth / 2,
            y: $element[0].offsetHeight / 2
          });
        };

        $scope.resetZoom = function() {
          canvas.resized();
          canvas.zoom('fit-viewport', 'auto');
        };

        $scope.control.resetZoom = $scope.resetZoom;

        $scope.control.refreshZoom = function() {
          canvas.resized();
          canvas.zoom(canvas.zoom(), 'auto');
        };

        $scope.$on('$destroy', function() {
          detatchDiagram();
          clearEventListeners();
          viewer.get('overlays').clear();
          Viewer.cacheViewer({key: $scope.key, viewer: viewer});
        });
      }
    };
  }
];


text:
<?php

namespace Core\Plugin;

/**
 * Plugin Base class
 *
 * @package  plugin
 * @author   Frederic Guillot
 */
abstract class Base extends \Core\Base
{
    /**
     * Method called for each request
     *
     * @abstract
     * @access public
     */
    abstract public function initialize();

    /**
     * Returns all classes that needs to be stored in the DI container
     *
     * @access public
     * @return array
     */
    public function getClasses()
    {
        return array();
    }

    /**
     * Listen on internal events
     *
     * @access public
     * @param  string   $event
     * @param  callable $callback
     */
    public function on($event, $callback)
    {
        $container = $this->container;

        $this->container['dispatcher']->addListener($event, function() use ($container, $callback) {
            call_user_func($callback, $container);
        });
    }
}


text:
cache-search
============

Top 100 sites extracted from http://s3.amazonaws.com/alexa-static/top-1m.csv.zip.

Assumes cache settings are the value in the "Cache-Control" header.

Reads and writes CSV to allow easy import into a spreadsheet.


text:
package com.commonsware.cwac.cam2;

import android.content.Context;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.util.Log;
import org.greenrobot.eventbus.EventBus;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Base class for camera engines, which abstract out camera
 * functionality for different APIs (e.g., android.hardware.Camera,
 * android.hardware.camera2.*).
 */
abstract public class CameraEngine {
  private static final int CORE_POOL_SIZE=1;
  private static final int MAX_POOL_SIZE=Runtime.getRuntime().availableProcessors();
  private static final int KEEP_ALIVE_SECONDS=60;
  private static volatile CameraEngine singletonClassic=null;
  private static volatile CameraEngine singletonTwo=null;
  private EventBus bus=AbstractCameraActivity.BUS;
  private boolean isDebug=false;
  private LinkedBlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>();
  private ThreadPoolExecutor pool;
  private File savePreviewFile=null;
  protected List<FlashMode> preferredFlashModes;
  protected ArrayList<FlashMode> eligibleFlashModes=
    new ArrayList<FlashMode>();

  public enum ID {
    CLASSIC,
    CAMERA2
  }

  private static class CrashableEvent {
    /**
     * The exception that was raised when trying to process
     * the request, or null if no such exception was raised.
     */
    public final Throwable exception;

    public CrashableEvent() {
      this(null);
    }

    public CrashableEvent(Throwable e) {
      if (e!=null) {
        Log.e("CWAC-Cam2", "Exception in camera processing", e);
      }

      this.exception=e;
    }
  }

  /**
   * Event raised when camera descriptors are ready for use.
   * Subscribe to this event if you use loadCameraDescriptors()
   * to get the results. May include an exception if there was
   * an exception accessing the camera.
   *
   * Note that the descriptors will be in a ranked order based
   * on your requested CameraSelectionCriteria, with the best
   * match as the 0th element of the list.
   */
  public static class CameraDescriptorsEvent extends CrashableEvent {
    /**
     * The camera descriptors loaded in response to a call
     * to loadCameraDescriptors()
     */
    public final List<CameraDescriptor> descriptors;

    public CameraDescriptorsEvent(List<CameraDescriptor> descriptors) {
      this.descriptors=descriptors;
    }

    public CameraDescriptorsEvent(Exception exception) {
      super(exception);
      this.descriptors=null;
    }
  }

  /**
   * Event raised when the camera has been opened.
   * Subscribe to this event if you use open()
   * to to find out when the open has succeeded.
   * May include an exception if there was
   * an exception accessing the camera.
   */
  public static class OpenedEvent extends CrashableEvent {
    public OpenedEvent() {
      super();
    }

    public OpenedEvent(Exception exception) {
      super(exception);
    }
  }

  /**
   * Event raised when the camera has been closed.
   * Subscribe to this event if you use close()
   * to to find out when the close has completed.
   * May include an exception if there was
   * an exception closing the camera.
   */
  public static class ClosedEvent extends CrashableEvent {
    public ClosedEvent() {
      super();
    }

    public ClosedEvent(Exception exception) {
      super(exception);
    }
  }

  /**
   * Used for errors happening deep in the engines or elsewhere
   * (e.g., JPEGWriter ran out of disk space)
   */
  public static class DeepImpactEvent extends CrashableEvent {
    public DeepImpactEvent(Throwable exception) {
      super(exception);
    }
  }

  public static class OrientationChangedEvent {

  }

  public static class SmoothZoomCompletedEvent {

  }

  /**
   * Event raised when picture is taken, as a result of a
   * takePicture() call. May include an exception if there was
   * an exception accessing the camera.
   */
  public static class PictureTakenEvent extends CrashableEvent {
    private ImageContext imageContext;
    private PictureTransaction xact;

    public PictureTakenEvent(PictureTransaction xact,
                             ImageContext imageContext) {
      super();
      this.xact=xact;
      this.imageContext=imageContext;
    }

    public PictureTakenEvent(Exception exception) {
      super(exception);
    }

    public ImageContext getImageContext() {
      return(imageContext);
    }

    public PictureTransaction getPictureTransaction() {
      return(xact);
    }
  }

  /**
   * Event raised when picture is taken, as a result of a
   * takePicture() call. May include an exception if there was
   * an exception accessing the camera.
   */
  public static class VideoTakenEvent extends CrashableEvent {
    private VideoTransaction xact;

    public VideoTakenEvent(VideoTransaction xact) {
      super();
      this.xact=xact;
    }

    public VideoTakenEvent(Exception exception) {
      super(exception);
    }

    public VideoTransaction getVideoTransaction() {
      return(xact);
    }
  }

  /**
   * Base class for all ¯\_(ツ)_/¯ errors triggered by camera2
   * API operations that we really should surface to callers,
   * but either are not tied to specific requests or happen
   * asynchronously with respect to the request. Usually, these
   * are bad. However, they frequently do not have useful
   * error information associated with them, because, well,
   * that would have been useful.
   */
  public static class CameraTwoGenericEvent {

  }

  /**
   * Event raised if there is a problem starting up the
   * CameraTwoEngine preview. The error field is the value passed
   * into onError() of a CameraDevice.StateCallback object and
   * probably means something to somebody.
   */
  public static class CameraTwoPreviewErrorEvent
    extends CameraTwoGenericEvent {
    public final int error;

    CameraTwoPreviewErrorEvent(int error) {
      this.error=error;
    }
  }

  /**
   * Event raised if there is a different sort of problem
   * starting up the CameraTwoEngine preview. This will be
   * triggered by a CameraCaptureSession.StateCallback,
   * and there is no error information of note.
   */
  public static class CameraTwoPreviewFailureEvent
    extends CameraTwoGenericEvent {
  }

  /**
   * Create a CameraSession.Builder to build a CameraSession
   * for a given CameraDescriptor. On the Builder is where you
   * indicate your desired preview size, picture size, and
   * so forth.
   *
   * @param ctxt an Android Context for accessing system stuff
   * @param descriptor the CameraDescriptor for which we want
   *                   a session
   * @return a Builder to build that session
   */
  abstract public CameraSession.Builder buildSession(Context ctxt,
                                                     CameraDescriptor descriptor);

  /**
   * Loads a roster of the available cameras for this engine,
   * ranked based on the supplied criteria. Subscribe
   * to the CameraDescriptorsEvent to get the results of this
   * call asynchronously.
   *
   * @param criteria preferred camera capabilities, or
   *                 null for a default ranking
   */
  abstract public void loadCameraDescriptors(CameraSelectionCriteria criteria);

  /**
   * Open the requested camera and show a preview on the supplied
   * surface. Subscribe to the OpenEvent to find out when this
   * work is completed.
   *
   * @param session the session for the camera of interest
   * @param texture the preview surface
   */
  abstract public void open(CameraSession session,
                            SurfaceTexture texture);

  /**
   * Close the open camera. Subscribe to the ClosedEvent to
   * find out when this work is completed. Note that this
   * method may be synchronous or asynchronous.
   *
   * @param session the session for the camera of interest
   */
  abstract public void close(CameraSession session);

  /**
   * Take a picture, on the supplied camera, using the picture
   * configuration from the supplied transaction. Posts a
   * PictureTakenEvent when the request is completed, successfully
   * or unsuccessfully.
   *
   * @param session the session for the camera of interest
   * @param xact the configuration of the picture to take
   */
  abstract public void takePicture(CameraSession session,
                                   PictureTransaction xact);

  abstract public void recordVideo(CameraSession session,
      VideoTransaction xact) throws Exception;

  abstract public void stopVideoRecording(CameraSession session,
                                          boolean abandon) throws Exception;

  abstract public void handleOrientationChange(CameraSession session,
                                               OrientationChangedEvent event);

  /**
   * @return true if the engine supports changing flash modes
   * on the fly, false otherwise
   */
  abstract public boolean supportsDynamicFlashModes();

  /**
   * @return true if this camera supports zoom, false otherwise
   */
  abstract public boolean supportsZoom(CameraSession session);

  /**
   * Sets the zoom level for the camera.
   *
   * @param session the session for the camera of interest
   * @param zoomLevel 0-100, 100=max zoom
   * @return true if "smooth zoom" (and should not request
   * zoom until complete), false otherwise
   */
  abstract public boolean zoomTo(CameraSession session,
                                   int zoomLevel);

  /**
   * Builds a CameraEngine instance based on the device's
   * API level.
   *
   * @param ctxt any Context will do
   * @param forcedEngineId if not null, use this engine always
   * @return a new CameraEngine instance
   */
  synchronized public static CameraEngine buildInstance(Context ctxt,
                                                        ID forcedEngineId) {
    CameraEngine result;
    boolean useCameraTwo;

    if (forcedEngineId==ID.CLASSIC) {
      useCameraTwo=false;
    }
    else if (forcedEngineId==ID.CAMERA2) {
      useCameraTwo=true;
    }
    else {
      useCameraTwo=Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP;

      CameraConstraints constraints=CameraConstraints.get();

      if (constraints!=null) {
        useCameraTwo=useCameraTwo && constraints.supportsCameraTwo();
      }
    }

    if (useCameraTwo) {
      if (singletonTwo==null) {
        singletonTwo=new CameraTwoEngine(ctxt);
      }

      result=singletonTwo;
    }
    else {
      if (singletonClassic==null) {
        singletonClassic=new ClassicCameraEngine(ctxt);
      }

      result=singletonClassic;
    }

    return(result);
  }

  /**
   * Sets the event bus to use, where the default is the
   * default event bus supplied by the EventBus class.
   *
   * @param bus the bus to use for events
   */
  public void setBus(EventBus bus) {
    this.bus=bus;
  }

  /**
   * @return the bus to use for events
   */
  public EventBus getBus() {
    return(bus);
  }

  /**
   * Sets whether or not exceptions should be logged, in addition
   * to being included in relevant events. The default is false.
   *
   * @param isDebug true if exceptions should be logged, false otherwise
   */
  public void setDebug(boolean isDebug) {
    this.isDebug=isDebug;
  }

  /**
   * @return true if exceptions should be logged, false otherwise
   */
  public boolean isDebug() {
    return(isDebug);
  }

  public void setDebugSavePreviewFile(File savePreviewFile) {
    this.savePreviewFile=savePreviewFile;
  }

  public File savePreviewFile() {
    return(savePreviewFile);
  }

  public ThreadPoolExecutor getThreadPool() {
    if (pool==null) {
      pool=new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE,
          KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, queue);
    }

    return(pool);
  }

  public void setThreadPool(ThreadPoolExecutor pool) {
    this.pool=pool;
  }

  public void setPreferredFlashModes(List<FlashMode> flashModes) {
    preferredFlashModes=flashModes;
  }

  boolean hasMoreThanOneEligibleFlashMode() {
    return(eligibleFlashModes.size()>1);
  }
}


text:
PyHamcrest Tutorial
===================

Introduction
------------

PyHamcrest is a framework for writing matcher objects, allowing you to
declaratively define "match" rules. There are a number of situations where
matchers are invaluable, such as UI validation, or data filtering, but it is in
the area of writing flexible tests that matchers are most commonly used. This
tutorial shows you how to use PyHamcrest for unit testing.

When writing tests it is sometimes difficult to get the balance right between
overspecifying the test (and making it brittle to changes), and not specifying
enough (making the test less valuable since it continues to pass even when the
thing being tested is broken). Having a tool that allows you to pick out
precisely the aspect under test and describe the values it should have, to a
controlled level of precision, helps greatly in writing tests that are "just
right." Such tests fail when the behavior of the aspect under test deviates
from the expected behavior, yet continue to pass when minor, unrelated changes
to the behaviour are made.

My first PyHamcrest test
------------------------

We'll start by writing a very simple PyUnit test, but instead of using PyUnit's
:py:meth:`~unittest.TestCase.assertEqual` method, we'll use PyHamcrest's
:py:func:`~hamcrest.core.matcher_assert.assert_that` construct and the standard
set of matchers::

    from hamcrest import *
    import unittest

    class BiscuitTest(unittest.TestCase):
        def testEquals(self):
            theBiscuit = Biscuit('Ginger')
            myBiscuit = Biscuit('Ginger')
            assert_that(theBiscuit, equal_to(myBiscuit))

    if __name__ == '__main__':
        unittest.main()

The :py:func:`~hamcrest.core.matcher_assert.assert_that` function is a stylized
sentence for making a test assertion. In this example, the subject of the
assertion is the object ``theBiscuit``, which is the first method parameter.
The second method parameter is a matcher for ``Biscuit`` objects, here a
matcher that checks one object is equal to another using the Python ``==``
operator. The test passes since the ``Biscuit`` class defines an ``__eq__``
method.

If you have more than one assertion in your test you can include an identifier
for the tested value in the assertion::

    assert_that(theBiscuit.getChocolateChipCount(), equal_to(10), 'chocolate chips')
    assert_that(theBiscuit.getHazelnutCount(), equal_to(3), 'hazelnuts')

As a convenience, :py:func:`~hamcrest.core.matcher_assert.assert_that` can also
be used to verify a boolean condition::

    assert_that(theBiscuit.isCooked(), 'cooked')

This is equivalent to the :py:meth:`~unittest.TestCase.assert_` method of
:py:class:`unittest.TestCase`, but because it's a standalone function, it
offers greater flexibility in test writing.

Asserting Exceptions
--------------------

There's a utility function and matcher available to help you test that
your code has the expected behavior in situations where it should raise
an exception.  The :py:func:`~hamcrest.core.core.raises.calling`
function wraps a callable, and then allows you to set arguments to be
used in a call to the wrapped callable.  This, together with the
:py:func:`~hamcrest.core.core.raises.raises` matcher lets you assert
that calling a method with certain arguments causes an exception to be
thrown. It is also possible to provide a regular expression pattern to
the :py:func:`~hamcrest.core.core.raises.raises` matcher allowing you
assure that the right issue was found::

    assert_that(calling(parse, bad_data), raises(ValueError))

    assert_that(calling(translate).with_(curse_words), raises(LanguageError, "\w+very naughty"))

    assert_that(broken_function, raises(Exception))

    # This will fail and complain that 23 is not callable
    # assert_that(23, raises(IOError))

Predefined matchers
-------------------

PyHamcrest comes with a library of useful matchers:

* Object

  * :py:func:`~hamcrest.core.core.isequal.equal_to` - match equal object
  * :py:func:`~hamcrest.library.object.haslength.has_length` - match
    ``len(item)``
  * :py:func:`~hamcrest.library.object.hasproperty.has_property` - match value
    of property with given name
  * :py:func:`~hamcrest.library.object.hasproperty.has_properties` - match an
     object that has all of the given properties.
  * :py:func:`~hamcrest.library.object.hasstring.has_string` - match
    ``str(item)``
  * :py:func:`~hamcrest.core.core.isinstanceof.instance_of` - match object type
  * :py:func:`~hamcrest.core.core.isnone.none`,
    :py:func:`~hamcrest.core.core.isnone.not_none` - match ``None``, or not
    ``None``
  * :py:func:`~hamcrest.core.core.issame.same_instance` - match same object
  * :py:func:`~hamcrest.core.core.raises.calling`,
    :py:func:`~hamcrest.core.core.raises.raises` - wrap a method call and assert
    that it raises an exception

* Number

  * :py:func:`~hamcrest.library.number.iscloseto.close_to` - match number close
    to a given value
  * :py:func:`~hamcrest.library.number.ordering_comparison.greater_than`,
    :py:func:`~hamcrest.library.number.ordering_comparison.greater_than_or_equal_to`,
    :py:func:`~hamcrest.library.number.ordering_comparison.less_than`,
    :py:func:`~hamcrest.library.number.ordering_comparison.less_than_or_equal_to`
    - match numeric ordering

* Text

  * :py:func:`~hamcrest.library.text.stringcontains.contains_string` - match
    part of a string
  * :py:func:`~hamcrest.library.text.stringendswith.ends_with` - match the end
    of a string
  * :py:func:`~hamcrest.library.text.isequal_ignoring_case.equal_to_ignoring_case`
    - match the complete string but ignore case
  * :py:func:`~hamcrest.library.text.isequal_ignoring_whitespace.equal_to_ignoring_whitespace`
    - match the complete string but ignore extra whitespace
  * :py:func:`~hamcrest.library.text.stringstartswith.starts_with` - match the
    beginning of a string
  * :py:func:`~hamcrest.library.text.stringcontainsinorder.string_contains_in_order`
    - match parts of a string, in relative order

* Logical

  * :py:func:`~hamcrest.core.core.allof.all_of` - ``and`` together all matchers
  * :py:func:`~hamcrest.core.core.anyof.any_of` - ``or`` together all matchers
  * :py:func:`~hamcrest.core.core.isanything.anything` - match anything, useful
    in composite matchers when you don't care about a particular value
  * :py:func:`~hamcrest.core.core.isnot.is_not` - negate the matcher

* Sequence

  * :py:func:`~hamcrest.library.collection.issequence_containinginorder.contains`
    - exactly match the entire sequence
  * :py:func:`~hamcrest.library.collection.issequence_containinginanyorder.contains_inanyorder`
    - match the entire sequence, but in any order
  * :py:func:`~hamcrest.library.collection.issequence_containing.has_item` -
    match if given item appears in the sequence
  * :py:func:`~hamcrest.library.collection.issequence_containing.has_items` -
    match if all given items appear in the list, in any order
  * :py:func:`~hamcrest.library.collection.isin.is_in` - match if item appears
    in the given sequence
  * :py:func:`~hamcrest.library.collection.issequence_onlycontaining.only_contains`
    - match if sequence's items appear in given list
  * :py:func:`~hamcrest.library.collection.is_empty.empty`
    - match if the sequence is empty

* Dictionary

  * :py:func:`~hamcrest.library.collection.isdict_containingentries.has_entries`
    - match dictionary with list of key-value pairs
  * :py:func:`~hamcrest.library.collection.isdict_containing.has_entry` - match
    dictionary containing a key-value pair
  * :py:func:`~hamcrest.library.collection.isdict_containingkey.has_key` -
    match dictionary with a key
  * :py:func:`~hamcrest.library.collection.isdict_containingvalue.has_value` -
    match dictionary with a value

* Decorator

  * :py:func:`~hamcrest.core.core.described_as.described_as` - give the matcher
    a custom failure description
  * :py:func:`~hamcrest.core.core.is_.is_` - decorator to improve readability -
    see :ref:`sugar`, below

The arguments for many of these matchers accept not just a matching value, but
another matcher, so matchers can be composed for greater flexibility. For
example, ``only_contains(less_than(5))`` will match any sequence where every
item is less than 5.

.. _sugar:

Syntactic sugar
---------------

PyHamcrest strives to make your tests as readable as possible. For example, the
:py:func:`~hamcrest.core.core.is_.is_` matcher is a wrapper that doesn't add
any extra behavior to the underlying matcher. The following assertions are all
equivalent::

    assert_that(theBiscuit, equal_to(myBiscuit))
    assert_that(theBiscuit, is_(equal_to(myBiscuit)))
    assert_that(theBiscuit, is_(myBiscuit))

The last form is allowed since ``is_(value)`` wraps most non-matcher arguments
with :py:func:`~hamcrest.core.core.isequal.equal_to`. But if the argument is a
type, it is wrapped with
:py:func:`~hamcrest.core.core.isinstanceof.instance_of`, so the following are
also equivalent::

    assert_that(theBiscuit, instance_of(Biscuit))
    assert_that(theBiscuit, is_(instance_of(Biscuit)))
    assert_that(theBiscuit, is_(Biscuit))

(Note that PyHamcrest's ``is_`` matcher is unrelated to Python's ``is``
operator. The matcher for object identity is
:py:func:`~hamcrest.core.core.issame.same_instance`.)


text:
<!DOCTYPE HTML>
<!--
  -- Copyright 2013 The Chromium Authors. All rights reserved.
  -- Use of this source code is governed by a BSD-style license that can be
  -- found in the LICENSE file.
  -->

<!--
  -- To avoid unintentionally break webui keyboard when changing extension
  -- keyboard, creates this file and uses it as index.html for webui keyboard.
  -- TODO(bshe): remove this file when dynamic layout loading is fixed
  -- (http://www.crbug.com/260278).
  -->

<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="main.css">
    <script src="constants.js"></script>
    <script src="polymer_loader.js"></script>
    <script src="api_adapter.js"></script>
    <script src="voice_input.js"></script>
    <link rel="import" href="elements/kb-altkey.html">
    <link rel="import" href="elements/kb-altkey-container.html">
    <link rel="import" href="elements/kb-altkey-data.html">
    <link rel="import" href="elements/kb-altkey-set.html">
    <link rel="import" href="elements/kb-key-codes.html">
    <link rel="import" href="elements/kb-key-base.html">
    <link rel="import" href="elements/kb-key.html">
    <link rel="import" href="elements/kb-keyboard.html">
    <link rel="import" href="elements/kb-keyset.html">
    <link rel="import" href="elements/kb-row.html">
    <link rel="import" href="elements/kb-shift-key.html">
    <link id="numeric" rel="import" href="layouts/numeric.html">
    <link id="qwerty" rel="import" href="layouts/qwerty.html">
    <!--TODO(stevet): Import 'Open Sans' font. -->
    <script src="main.js"></script>
    <script src="layouts/latin-accents.js"></script>
  </head>
  <body>
    <kb-keyboard id="keyboard" touch-action="none" layout="qwerty">
    </kb-keyboard>
  </body>
</html>


text:
Developed by Dave Shea, http://www.mezzoblue.com/

Probably the least important repo ever, this is just a way to share some of
the simple hubot scripts I've built that I find useful. Maybe you will too.

hubot requires a live server plus an integration into a chat app like Slack or
HipChat, so the barrier to entry is a bit high on this. If you're feeling
adventurous, here are a few starting points:

* https://github.com/github/hubot/blob/master/docs/deploying/heroku.md
* https://github.com/tinyspeck/hubot-slack/blob/master/README.md
* https://github.com/hipchat/hubot-hipchat


text:
package org.opengts.war.report;

import java.io.*;

import org.opengts.war.tools.*;

public interface DBDataRow
    extends CSSRowClass
{

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

    public enum RowType {
        DETAIL,
        SUBTOTAL,
        TOTAL
    };

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

    public ReportData getReportData();

    public ReportColumn[] getReportColumns();
    public DataRowTemplate getDataRowTemplate();

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

    public Object getRowObject();

    public Object getDBValue(String fldName, int rowNdx, ReportColumn rptCol);

    public RowType getRowType();

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

}


text:
/*---------------------------------------------------------
 Builder (builder.css)
-------------------------------------------------------- */
.ttfmake-titlediv {
	position: relative;
	margin-bottom: 20px;
}
.ttfmake-titlediv .ttfmake-title,
.ttfmake-configuration-overlay-input-wrap .ttfmake-configuration-title {
	width: 100%;
	height: 41px;
	margin: 0; /*reset*/
	padding: 0 8px;
	font-size: 19px;
	-webkit-box-shadow: none; /*reset*/
	box-shadow: none; /*reset*/
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-titlediv .ttfmake-title:focus {
	border: 1px solid #ddd;
	-webkit-box-shadow: none; /*reset*/
	box-shadow: none; /*reset*/
}
#ttfmake-builder .inside {
	padding: 0; /*reset*/
}
#ttfmake-builder *:focus {
	outline: none !important; /*reset*/
	box-shadow: none !important; /*reset*/
}
.ttfmake-stage {
	clear: both;
	padding-top: 10px;
}
.ttfmake-stage-closed {
	padding-top: 0; /*reset*/
}
.ttfmake-stage .sortable-placeholder {
	margin-bottom: 10px;
}
/*---------------------------------------------------------
 Common (builder.css)
-------------------------------------------------------- */
.clear {
	clear: both;
}
.ttfmake-show {
	display: block;
}
.ttfmake-hide {
	display: none; /*reset*/
}
/*---------------------------------------------------------
 Menu (builder.css)
-------------------------------------------------------- */
.ttfmake-menu {
	margin-top: -6px;
}
.ttfmake-menu-pane {
	margin-bottom: 40px;
	border-top: none; /*reset*/
	line-height: 0; /*reset*/
}
.ttfmake-menu-list {
	display: inline-block;
	width: 100%;
	margin: 0; /*reset*/
}
.ttfmake-menu-list h4 {
	margin: 0; /*reset*/
	font-size: 14px;
}
.ttfmake-menu-list a {
	text-decoration: none; /*reset*/
	color: #777777 !important;
}
.ttfmake-menu-list a:hover {
	color: #333333 !important;
}
.ttfmake-menu-list a .ttfmake-menu-list-item-link-icon {
	display: block;
	visibility: hidden;
	width: 84px;
	height: 74px;
	background: url(images/section-icons-hover.png) center center no-repeat;
	background-size: 36px 36px;
}
.ttfmake-menu-list a:hover .ttfmake-menu-list-item-link-icon {
	visibility: visible;
}
.ttfmake-menu-list-item {
	float: left;
	width: 50%;
	height: 155px;
	margin-bottom: 0; /*reset*/
	text-align: center;
	border-right: 1px solid #eeeeee;
	border-bottom: 1px solid #eeeeee;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-menu-list-item:hover .ttfmake-menu-list-item-link-icon-wrapper {
	border-color: #bbbbbb;
}
.ttfmake-menu-list-item:last-of-type {
	margin-right: 0; /*reset*/
}
.ttfmake-menu-list-item:hover {
	background-color: #fafafa;
}
@media screen and (min-width: 1160px) {
	.ttfmake-menu-list-item {
		width: 25%;
	}
	.ttfmake-menu-list-item-link:nth-child(even) .ttfmake-menu-list-item {
		border-right: 1px solid #eeeeee;
	}
	.ttfmake-menu-list-item-link:nth-child(4) .ttfmake-menu-list-item,
	.ttfmake-menu-list-item-link:nth-child(8) .ttfmake-menu-list-item,
	.ttfmake-menu-list-item-link:nth-child(12) .ttfmake-menu-list-item {
		border-right: 0; /*reset*/
	}
}
.ttfmake-menu-list-item a {
	color: #21759b;
}
.ttfmake-menu-list-item a:hover {
	color: #d54e21;
}
.ttfmake-menu-list-item-link {
	display: block;
}
.ttfmake-menu-list-item-link-icon-wrapper {
	display: inline-block;
	width: 84px;
	height: 74px;
	margin-top: 25px;
	margin-left: 25px;
	margin-right: 25px;
	background-color: #ffffff;
	background-position: center center;
	background-repeat: no-repeat;
	background-size: 70px 60px;
	border: 1px solid #dfdfdf;
}
.section-type-description {
	margin-top: 18px;
}
/*---------------------------------------------------------
 Get more (builder.css)
-------------------------------------------------------- */
#ttfmake-menu-list-item-link-plus {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-webkit-align-items: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: center;
	-webkit-justify-content: center;
	-ms-flex-pack: center;
	justify-content: center;
	padding: 10px;
}
#ttfmake-menu-list-item-link-plus p {
	display: block;
	margin-bottom: 0;
}
#ttfmake-menu-list-item-link-plus a {
	color: #0073aa !important;
	text-decoration: underline;
}
#ttfmake-menu-list-item-link-plus a:hover {
	color: #00a0d2 !important;
}
#ttfmake-menu-list-item-link-plus.ttfmake-menu-list-item:hover {
	background-color: #fff;
}
/*---------------------------------------------------------
 Sortable handle (builder.css)
-------------------------------------------------------- */
.ttfmake-sortable-handle {
	position: relative;
	width: 100%;
	height: 20px;
	border: 1px solid #d9d9d9;
	border-bottom: 0; /*reset*/
	background-color: #eee;
	cursor: move;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.sortable-background,
.ttfmp-widget-list li .sortable-background {
	display: block;
	height: 18px;
	background: url(images/sortable-background.png) center center repeat-x;
	opacity: .5;
}
.ttfmake-gallery-item:hover .sortable-background,
.ttfmake-text-column:hover .sortable-background.column-sortable-background,
.ttfmake-banner-slide:hover .sortable-background {
	opacity: 1; /*reset*/
}
/*---------------------------------------------------------
 Forms (builder.css)
-------------------------------------------------------- */
.ttfmake-section input[type=checkbox],
.ttfmake-section input[type=radio],
.ttfmake-section input[type=search],
.ttfmake-section input[type=number],
.ttfmake-section input[type=text],
.ttfmake-section textarea {
	-webkit-box-shadow: none; /*reset*/
	box-shadow: none; /*reset*/
}
.ttfmake-section input[type=text]:focus,
.ttfmake-section input[type=number]:focus {
	border-color: #ddd;
}
.ttfmake-configuration-overlay-input-wrap select {
	border: 1px solid #ddd;
}
/*---------------------------------------------------------
 Sections (builder.css)
-------------------------------------------------------- */
.ttfmake-section {
	overflow: hidden;
	width: 100%;
	margin-bottom: 10px;
	border-bottom: 0; /*reset*/
	background-color: #fff;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-section-body {
	display: none;
	float: left;
	width: 100%;
	padding: 20px 20px 40px;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-section-open {
	margin-bottom: 40px;
}
.ttfmake-section-open .ttfmake-section-body {
	display: block; /*reset*/
}
.ttfmake-section-header-title {
	max-width: 90%;
	display: inline-block;
}
.ttfmake-section h4 {
	margin: 20px 0 10px;
	font-size: 13px;
}
.ttfmake-section-header {
	cursor: move;
}
.ttfmake-section-header h3 {
	float: left;
	width: 100%;
	margin: 0;
	padding: 8px 12px;
	color: #23282d;
	font-size: 13px !important;
	font-weight: 700 !important;
	font-family: 'Open Sans', sans-serif !important;
	line-height: 1.7 !important;
	border-top: 1px solid #e5e5e5;
	border-bottom: 1px solid #e5e5e5;
	background-color: #fafafa;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	 -webkit-transition: background-color 300ms ease;
	-moz-transition: background-color 300ms ease;
	-o-transition: background-color 300ms ease;
	-ms-transition: background-color 300ms ease;
	transition: background-color 300ms ease;
}
.ttfmake-section:hover .ttfmake-section-header h3 {
	border-color: #999;
}
.ttfmake-section-open .ttfmake-section-header h3 {
	color: #fff;
	border-color: #23282d;
	background-color: #23282d;
}
.ttfmake-section-open:hover .ttfmake-section-header h3 {
	border-color: #23282d;
}
.ttfmake-section-header span {
	font-weight: bold;
	font-weight: 600;
}
.ttfmake-section-header em {
	margin-left: 10px;
	color: #777;
	font-size: 12px;
	font-weight: normal !important;
	font-style: normal !important;
}
.ttfmake-section-open .ttfmake-section-header em {
	color: #bbb;
}
.ttfmake-section-toggle:focus {
	border: none !important;
}
.ttfmake-media-link-wrap {
	margin-bottom: 8px;
}
.ttfmake-media-uploader-add {
	display: inline-block;
	cursor: pointer;
}
.ttfmake-section-open .ttfmake-builder-section-link,
.ttfmake-section:hover .ttfmake-builder-section-link {
	visibility: visible;
}
.ttfmake-builder-section-link {
	visibility: hidden;
}
/*---------------------------------------------------------
 Sections header buttons (builder.css)
-------------------------------------------------------- */
.ttf-make-section-header-button-wrapper {
	position: absolute;
	right: 45px;
}
.ttfmake-section-remove,
.ttfmake-section-configure,
.ttfmp-duplicate-section {
	display: inline-block;
	height: 100%;
	padding: 0 8px;
	color: #aaa;
	text-decoration: none;  /*reset*/
}
.ttfmake-section-open .ttfmake-section-remove,
.ttfmake-section-open .ttfmake-section-configure,
.ttfmake-section-open .ttfmp-duplicate-section {
	color: #bbb;
}
/*---------------------------------------------------------
 Hide Configure Section button when closed (builder.css)
-------------------------------------------------------- */
.ttfmake-section .ttfmake-section-configure {
	display: none;
}
.ttfmake-section-open .ttfmake-section-configure {
	display: inline-block;
}
/*---------------------------------------------------------
 Hide button labels (builder.css)
-------------------------------------------------------- */
.ttfmake-section-remove span,
.ttfmake-section-configure span,
.ttfmp-duplicate-section span {
	display: none; /*reset*/
	text-indent: -9999px;
	white-space: nowrap;
	overflow: hidden;
}
/*---------------------------------------------------------
 Section header buttons hover state (builder.css)
-------------------------------------------------------- */
.ttfmake-section-remove:hover,
.ttfmake-section-configure:hover,
.ttfmp-duplicate-section:hover {
	color: #23282d;
}
.ttfmake-section-open .ttfmake-section-remove:hover,
.ttfmake-section-open .ttfmake-section-configure:hover,
.ttfmake-section-open .ttfmp-duplicate-section:hover {
	color: #fff;
}
/*---------------------------------------------------------
 Section header icons (builder.css)
-------------------------------------------------------- */
.ttfmake-section-remove:before,
.ttfmake-section-configure:before,
.ttfmp-duplicate-section:before {
	font: 400 20px/40px dashicons;
	speak: none; /*reset*/
}
.ttfmake-section-remove:before {
	content: "\f182";
}
.ttfmake-section-configure:before {
	content: "\f111";
}
.ttfmp-duplicate-section:before {
	content: "\f105";
}
@media screen and ( max-width: 782px ) {
	.ttfmake-section-remove:before,
	.ttfmake-section-configure:before,
	.ttfmp-duplicate-section:before {
		line-height: 40px;
	}
}
/*---------------------------------------------------------
 Media placeholder (builder.css)
-------------------------------------------------------- */
.ttfmake-media-uploader-placeholder {
	position: relative;
	display: block;
	width: 100%;
	height: 220px;
	border: 1px solid #dfdfdf;
	background-color: #fafafa;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
/*---------------------------------------------------------
 Media placeholder icon (builder.css)
-------------------------------------------------------- */
.ttfmake-media-uploader-placeholder:before {
	content: "\f128";
	display: block;
	color: #d9d9d9;
	font: 60px/220px dashicons;
	text-align: center;
}
/*---------------------------------------------------------
 Media placeholder hover state (builder.css)
-------------------------------------------------------- */
.ttfmake-media-uploader-placeholder:hover:before {
	color: #c7c7c7;
}
.ttfmake-media-uploader-placeholder img {
	position: absolute;
	max-width: 100%;
	max-height: 228px;
	width: auto;
	height: auto;
	top: 0; /*reset*/
	right: 0; /*reset*/
	bottom: 0; /*reset*/
	left: 0; /*reset*/
	margin: auto;
	padding: 8px;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-section-body iframe {
	background: #fff !important;
}
/*---------------------------------------------------------
 Media placeholder if has image set (builder.css)
-------------------------------------------------------- */
.ttfmake-has-image-set {
	background-color: #fff;
}
.ttfmake-has-image-set .ttfmake-media-uploader-placeholder:before {
	content: none;
}
.ttfmake-has-image-set:hover .ttfmake-media-uploader-placeholder {
	opacity: .8;
}
/*---------------------------------------------------------
 Overlay (builder.css)
-------------------------------------------------------- */
.ttfmake-overlay {
	display: none;
	z-index: 99999;
	position: fixed;
	top: 0; /*reset*/
	left: 0; /*reset*/
	right: 0; /*reset*/
	bottom: 0; /*reset*/
	background: url(images/background.png) top left repeat;
	background: rgba(0, 0, 0, 0.7) ;
}
.ttfmake-overlay-wrapper {
	position: fixed !important;
	top: 50% !important;
	left: 50% !important;
	min-height: 150px !important;
	padding-bottom: 20px !important;
	background-color: #fff;
	-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.3);
	box-shadow: 0 3px 6px rgba(0,0,0,.3);
	/* Fix webkit bug. @link https://github.com/mgcrea/angular-strap/issues/1234#issuecomment-61913920 */
	-webkit-transform: translate3d(0,0,0);
}
.ttfmake-overlay-window-head {
	padding: 0; /*reser*/
	min-height: 36px;
	background: #fcfcfc;
}
.ttfmake-overlay-title {
	  width: 300px;
	margin: 0;
	padding: 0 36px 0 10px;
	color: #444;
	font-size: 18px;
	font-weight: 600;
	line-height: 36px;
	text-rendering: optimizelegibility;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ttfmake-overlay-close {
	display: block;
	position: absolute;
	top: 0; /*reset*/
	right: 0; /*reset*/
	padding: 0 10px;
	font-size: 15px;
	font-size: 15px;
	color: #fff;
	line-height: 37px;
	text-align: center;
	background-color: #1bc865;
	cursor: pointer;
}
.ttfmake-configuration-overlay-input-wrap  .ttfmake-uploader {
	width: 100%;
}
.ttfmake-configuration-overlay .ttfmake-overlay-wrapper {
	margin-left: -200px;
	width: 400px;
}
#ttfmake-tinymce-overlay .ttfmake-overlay-wrapper {
	width: 800px !important;
	height: 500px !important;
	margin-left: -400px !important;
	margin-top: -250px !important;
}
#ttfmake-tinymce-overlay .ttfmake-overlay-body {
	overflow-y: hidden;
}
.ttfmake-overlay-wrapper * {
	-webkit-font-smoothing: subpixel-antialiased !important;
}
.ttfmake-overlay-header {
	border-bottom: 1px solid #dfdfdf;
}
.ttfmake-overlay-header h2 {
	float: left;
}
.ttfmake-overlay-header .ttfmake-overlay-close {
	float: right;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}
.ttfmake-configuration-overlay-input-wrap {
	padding: 20px 0 !important;
	border-bottom: 1px solid #efefef !important;
}
.ttfmake-configuration-overlay-input-wrap {
	zoom: 1;
}
.ttfmake-configuration-overlay-input-wrap:before,
.ttfmake-configuration-overlay-input-wrap:after {
	display: table;
	content: "";
}
.ttfmake-configuration-overlay-input-wrap:after {
	clear: both;
}
.ttfmake-configuration-overlay-input-wrap label {
	position: relative;
	top: 2px;
	float: left;
}
.ttfmake-configuration-overlay-input-wrap select,
.ttfmake-configuration-overlay-input-wrap input {
	float: right;
}
.ttfmake-configuration-overlay-input-wrap .wp-picker-container,
.ttfmake-configuration-overlay-input-wrap  .ttfmake-uploader {
	clear: both;
	float: left;
	width: 100%;
	margin-top: 20px;
}
.ttfmake-configuration-overlay-input-wrap.monospace-wrap input {
	font-size: 12px;
	font-family: monospace;
	text-align: center;
	line-height: 16px;
}
.ttfmake-configuration-overlay-input-wrap input[type=checkbox] {
	position: relative;
	top: 5px;
}
.ttfmake-configuration-description {
	float: left;
	margin-top: 20px;
	color: #666;
	font-style: italic;
}
.ttfmake-configuration-overlay-input-wrap select,
.ttfmake-configuration-overlay-input-wrap input {
	margin-left: auto;
}
.ttfmake-overlay-body {
	padding: 20px !important;
	clear: both;
	overflow-y: scroll;
	max-height: 500px;
}
.ttfmake-overlay-body .ttfmake-configuration-overlay-input-wrap:last-of-type {
	padding-bottom: 0 !important;
	border-bottom: 0 !important;
}
.ttfmake-configuration-title {
	width: 100%;
	height: 41px;
	padding: 0 8px;
	font-size: 19px;
}
.ttfmake-configuration-overlay-input-wrap.ttfmake-configuration-title-wrap {
	padding-top: 0 !important; /*reset*/
	border-bottom: 0 !important; /*reset*/
}
.ttfmake-configuration-overlay-input-wrap.ttfmake-configuration-media-wrap {
	display: block; /*reset*/
	clear: both;
	width: 100%;
}
/*---------------------------------------------------------
 Color picker (builder.css)
-------------------------------------------------------- */
.wp-color-result.wp-picker-open:after {
	display: none;
}
.ttfmake-configuration-overlay-input-wrap .wp-picker-container .button {
	margin-left: 0; /*reset*/
	margin-right: 4px; /*reset*/
}
.ttfmake-configuration-overlay-input-wrap .wp-picker-container .wp-picker-holder {
	margin-left: -8px;
}
.ttfmake-configuration-overlay-input-wrap .wp-picker-container .iris-picker {
	border: 0; /*reset*/
}
/*---------------------------------------------------------
 iFrame (builder.css)
-------------------------------------------------------- */
.ttfmake-iframe-wrapper {
	position: relative;
	border: 1px solid #ddd;
}
.ttfmake-iframe-wrapper iframe {
	overflow: hidden;
	padding: 12px !important; /*12px+8px from body*/
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
.ttfmake-iframe-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%; /* same as iframe */
	height: 300px; /* same as iframe */
}
.ttfmake-iframe-overlay .edit-content-link {
	display: block;
	width: 100%;
	height: 100%;
}
/*---------------------------------------------------------
 Media Modal (builder.css)
-------------------------------------------------------- */
.ttfmake-remove-current-image {
	display: none;
}
.ttfmake-builder-uploader .ttfmake-remove-current-image {
	display: block;
	float: left;
}
.ttfmake-builder-uploader .ttfmake-remove-current-image a.ttfmake-remove-image-from-modal {
	color: #bc0b0b;
	text-decoration: none; /*reset*/
}
.ttfmake-builder-uploader .ttfmake-remove-current-image a.ttfmake-remove-image-from-modal:hover {
	color: red;
}
/*---------------------------------------------------------
 Section toggle (builder.css)
-------------------------------------------------------- */
.ttfmake-section-toggle__wrapper {
	position: absolute;
	height: 40px;
	right: 0;
	padding: 0 8px;
	border-left: 1px solid #e5e5e5;
	line-height: 40px;
}
.ttfmake-section:hover .ttfmake-section-toggle__wrapper {
	border-color: #999;
}
.ttfmake-section-open:hover .ttfmake-section-toggle__wrapper {
	border-color: #e5e5e5;
}
.ttfmake-section-toggle__indicator {
	color: #bbb;
}
.ttfmake-section .ttfmake-section-toggle__wrapper:hover .ttfmake-section-toggle__indicator {
	color: #23282d;
}
.ttfmake-section-open .ttfmake-section-toggle__wrapper:hover .ttfmake-section-toggle__indicator {
	color: #fff;
}
.ttfmake-section-toggle__indicator:before {
	content: '\f140';
	font: 400 20px/40px dashicons;
}
.ttfmake-section-open .ttfmake-section-toggle__indicator:before {
	content: '\f142';
}


text:
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Roslyn.Test.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using System.Collections;
using System.Collections.Immutable;
using System.Threading.Tasks;
using System.Collections.Concurrent;

namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
{
    public class CodeGenCapturing : CSharpTestBase
    {
        private class CaptureContext
        {
            // Stores a mapping from scope index (0-based count of scopes
            // from `this` to most nested scope)
            public readonly List<IList<string>> VariablesByScope = new List<IList<string>>();

            private CaptureContext() { }

            public CaptureContext(int MaxVariables)
            {
                // Fields are shared among methods, so we also share them in the
                // capture context when cloning
                var fieldsBuilder = ImmutableArray.CreateBuilder<string>(MaxVariables);
                for (int i = 0; i < MaxVariables; i++)
                {
                    fieldsBuilder.Add($"field_{i}");
                }
                VariablesByScope.Add(fieldsBuilder.MoveToImmutable());
            }

            public void Add(int depth, string varName)
            {
                if (VariablesByScope.Count <= depth ||
                    VariablesByScope[depth] == null)
                {
                    VariablesByScope.Insert(depth, new List<string>() { varName });
                }
                else
                {
                    VariablesByScope[depth].Add(varName);
                }
            }

            public CaptureContext Clone()
            {
                var fields = VariablesByScope[0];
                var newCtx = new CaptureContext();
                newCtx.VariablesByScope.Add(fields);
                newCtx.VariablesByScope.AddRange(
                    this.VariablesByScope
                    .Skip(1)
                    .Select(list => list == null ? null : new List<string>(list)));
                newCtx.CaptureNameIndex = this.CaptureNameIndex;
                return newCtx;
            }

            public int CaptureNameIndex = 0;
        }

        private static string MakeLocalFunc(int nameIndex, string captureExpression)
            => $@"int Local_{nameIndex}() => {captureExpression};";

        private static string MakeCaptureExpression(IList<int> varsToCapture, CaptureContext ctx)
        {
            var varNames = new List<string>();
            for (int varDepth = 0; varDepth < varsToCapture.Count; varDepth++)
            {
                var variablesByScope = ctx.VariablesByScope;
                // Do we have any variables in this scope depth?
                // If not, initialize an empty list
                if (variablesByScope.Count <= varDepth)
                {
                    variablesByScope.Add(new List<string>());
                }

                var varsAtCurrentDepth = variablesByScope[varDepth];

                int numToCapture = varsToCapture[varDepth];
                int numVarsAvailable = variablesByScope[varDepth].Count;
                // If we have enough variables to capture in the context
                // just add them
                if (numVarsAvailable >= numToCapture)
                {
                    // Capture the last variables added since if there are more
                    // vars in the context than the max vars to capture we'll never
                    // have code coverage of the newest vars added to the context.
                    varNames.AddRange(varsAtCurrentDepth
                        .Skip(numVarsAvailable - numToCapture)
                        .Take(numToCapture));
                }
                else
                {
                    // Not enough variables in the context -- add more
                    for (int i = 0; i < numToCapture - numVarsAvailable; i++)
                    {
                        varsAtCurrentDepth.Add($"captureVar_{ctx.CaptureNameIndex++}");
                    }

                    varNames.AddRange(varsAtCurrentDepth);
                }
            }

            return varNames.Count == 0 ? "0" : string.Join(" + ", varNames);
        }

        /// <summary>
        /// Generates all combinations of distributing a sum to a list of subsets.
        /// This is equivalent to the "stars and bars" combinatorics construction.
        /// </summary>
        private static IEnumerable<IList<int>> GenerateAllSetCombinations(int sum, int numSubsets)
        {
            Assert.True(numSubsets > 0);
            return GenerateAll(sum, 0, ImmutableList<int>.Empty);

            IEnumerable<ImmutableList<int>> GenerateAll(
                int remainingSum,
                int setIndex, // 0-based index of subset we're generating
                ImmutableList<int> setsSoFar)
            {
                for (int i = 0; i <= remainingSum; i++)
                {
                    var newSets = setsSoFar.Add(i);
                    if (setIndex == numSubsets - 1)
                    {
                        yield return newSets;
                    }
                    else
                    {
                        foreach (var captures in GenerateAll(remainingSum - i,
                                                             setIndex + 1,
                                                             newSets))
                        {
                            yield return captures;
                        }
                    }
                }
            }
        }

        [Fact]
        public void GenerateAllTest()
        {
            Assert.Equal(new[]
            {
                ImmutableList<int>.Empty.Add(0),
                ImmutableList<int>.Empty.Add(1),
                ImmutableList<int>.Empty.Add(2),
                ImmutableList<int>.Empty.Add(3)
            }, GenerateAllSetCombinations(3, 1));
            Assert.Equal(new[]
            {
                ImmutableList<int>.Empty.Add(0).Add(0),
                ImmutableList<int>.Empty.Add(0).Add(1),
                ImmutableList<int>.Empty.Add(0).Add(2),
                ImmutableList<int>.Empty.Add(0).Add(3),
                ImmutableList<int>.Empty.Add(1).Add(0),
                ImmutableList<int>.Empty.Add(1).Add(1),
                ImmutableList<int>.Empty.Add(1).Add(2),
                ImmutableList<int>.Empty.Add(2).Add(0),
                ImmutableList<int>.Empty.Add(2).Add(1),
                ImmutableList<int>.Empty.Add(3).Add(0)
            }, GenerateAllSetCombinations(3, 2));
        }

        [Fact]
        public void ExpressionGeneratorTest01()
        {
            var ctx = new CaptureContext(1);
            int[] captures = { 1 }; // Capture 1 var at the 0 depth
            var expr = MakeCaptureExpression(captures, ctx);
            Assert.Equal("field_0", expr);
            VerifyContext(new[]
            {
                new[] { "field_0"}
            }, ctx.VariablesByScope);

            ctx = new CaptureContext(3);
            captures = new[] { 3 }; // Capture 3 vars at 0 depth
            expr = MakeCaptureExpression(captures, ctx);
            Assert.Equal("field_0 + field_1 + field_2", expr);
            VerifyContext(new[]
            {
                new[] { "field_0", "field_1", "field_2" }
            }, ctx.VariablesByScope);

            ctx = new CaptureContext(3);
            captures = new[] { 1, 1, 1 }; // Capture 1 var at each of 3 depths
            expr = MakeCaptureExpression(captures, ctx);
            Assert.Equal("field_2 + captureVar_0 + captureVar_1", expr);
            VerifyContext(new[]
            {
                new[] { "field_0", "field_1", "field_2"},
                new[] { "captureVar_0"},
                new[] { "captureVar_1"}
            }, ctx.VariablesByScope);

            void VerifyContext(IList<IEnumerable<string>> expectedCtx, List<IList<string>> actualCtx)
            {
                Assert.Equal(expectedCtx.Count, ctx.VariablesByScope.Count);
                for (int depth = 0; depth < expectedCtx.Count; depth++)
                {
                    AssertEx.Equal(expectedCtx[depth], ctx.VariablesByScope[depth]);
                }
            }
        }
        private struct LayoutEnumerator : IEnumerator<(int depth, int localFuncIndex)>
        {
            private readonly IList<int> _layout;
            private (int depth, int localFuncIndex) _current;

            public LayoutEnumerator(IList<int> layout)
            {
                _layout = layout;
                _current = (-1, -1);
            }

            public (int depth, int localFuncIndex) Current => _current;

            object IEnumerator.Current => throw new NotImplementedException();

            public void Dispose() => throw new NotImplementedException();

            public bool MoveNext()
            {
                if (_current.depth < 0)
                {
                    return FindNonEmptyDepth(0, _layout, out _current);
                }
                else
                {
                    int newIndex = _current.localFuncIndex + 1;
                    if (newIndex == _layout[_current.depth])
                    {
                        return FindNonEmptyDepth(_current.depth + 1, _layout, out _current);
                    }

                    _current = (_current.depth, newIndex);
                    return true;
                }

                bool FindNonEmptyDepth(int startingDepth, IList<int> layout, out (int depth, int localFuncIndex) newCurrent)
                {
                    for (int depth = startingDepth; depth < layout.Count; depth++)
                    {
                        if (layout[depth] > 0)
                        {
                            newCurrent = (depth, 0);
                            return true;
                        }
                    }
                    newCurrent = (layout.Count, 0);
                    return false;
                }
            }

            public void Reset() => throw new NotImplementedException();
        }

        private class MethodInfo
        {
            public MethodInfo(int MaxCaptures)
            {
                LocalFuncs = new List<IList<string>>();
                CaptureContext = new CaptureContext(MaxCaptures);
            }

            private MethodInfo() { }

            public List<IList<string>> LocalFuncs { get; private set; }

            public CaptureContext CaptureContext { get; private set; }

            public int TotalLocalFuncs { get; set; }

            public MethodInfo Clone()
            {
                return new MethodInfo
                {
                    LocalFuncs = this.LocalFuncs
                        .Select(x => x == null
                                     ? null
                                     : (IList<string>)new List<string>(x)).ToList(),
                    CaptureContext = this.CaptureContext.Clone()
                };
            }
        }

        private static IEnumerable<MethodInfo> MakeMethodsWithLayout(IList<int> localFuncLayout)
        {
            const int MaxCaptures = 3;

            var enumerator = new LayoutEnumerator(localFuncLayout);
            if (!enumerator.MoveNext())
            {
                return Array.Empty<MethodInfo>();
            }

            var methods = new List<MethodInfo>();
            DfsLayout(enumerator, new MethodInfo(MaxCaptures), 0);
            return methods;

            // Note that the enumerator is a struct, so every new var
            // is a copy
            void DfsLayout(LayoutEnumerator e, MethodInfo methodSoFar, int localFuncNameIndex)
            {
                var (depth, localFuncIndex) = e.Current;

                bool isLastFunc = !e.MoveNext();

                foreach (var captureCombo in GenerateAllSetCombinations(MaxCaptures, depth + 2))
                {
                    var copy = methodSoFar.Clone();
                    var expr = MakeCaptureExpression(captureCombo, copy.CaptureContext);
                    if (depth >= copy.LocalFuncs.Count)
                    {
                        copy.LocalFuncs.AddRange(Enumerable.Repeat<List<string>>(null, depth - copy.LocalFuncs.Count));
                        copy.LocalFuncs.Insert(depth, new List<string>());
                    }
                    string localFuncName = $"Local_{localFuncNameIndex}";
                    copy.LocalFuncs[depth].Add($"int {localFuncName}() => {expr};");
                    copy.CaptureContext.Add(depth + 1, $"{localFuncName}()");

                    if (!isLastFunc)
                    {
                        DfsLayout(e, copy, localFuncNameIndex + 1);
                    }
                    else
                    {
                        copy.TotalLocalFuncs = localFuncNameIndex + 1;
                        methods.Add(copy);
                    }
                }
            }
        }

        private static IEnumerable<MethodInfo> MakeAllMethods()
        {
            const int MaxDepth = 3;
            const int MaxLocalFuncs = 3;

            // Set combinations indicate what depth we will place local functions
            // at. For instance, { 0, 1 } indicates 0 local functions at method
            // depth and 1 local function at one nested scope below method level.
            foreach (var localFuncLayout in GenerateAllSetCombinations(MaxLocalFuncs, MaxDepth))
            {
                // Given a local function map, we need to generate capture
                // expressions for each local func at each depth
                foreach (var method in MakeMethodsWithLayout(localFuncLayout))
                    yield return method;
            }
        }

        private void SerializeMethod(MethodInfo methodInfo, StringBuilder builder, int methodIndex)
        {
            int totalLocalFuncs = methodInfo.TotalLocalFuncs;

            var methodText = new StringBuilder();
            var localFuncs = methodInfo.LocalFuncs;
            for (int depth = 0; depth < localFuncs.Count; depth++)
            {
                if (depth > 0)
                {
                    methodText.Append(' ', 4 * (depth + 1));
                    methodText.AppendLine("{");
                }

                var captureVars = methodInfo.CaptureContext.VariablesByScope;
                if (captureVars.Count > (depth + 1) &&
                    captureVars[depth + 1] != null)
                {
                    foreach (var captureVar in captureVars[depth + 1])
                    {
                        if (captureVar.EndsWith("()"))
                        {
                            continue;
                        }

                        methodText.Append(' ', 4 * (depth + 2));
                        methodText.AppendLine($"int {captureVar} = 0;");
                    }
                }

                if (localFuncs[depth] != null)
                {
                    foreach (var localFunc in localFuncs[depth])
                    {
                        methodText.Append(' ', 4 * (depth + 2));
                        methodText.AppendLine(localFunc);
                    }
                }
            }

            var localFuncCalls = string.Join(" + ",
                Enumerable.Range(0, totalLocalFuncs).Select(f => $"Local_{f}()"));
            methodText.AppendLine($"Console.WriteLine({localFuncCalls});");

            for (int depth = localFuncs.Count - 1; depth > 0; depth--)
            {
                methodText.Append(' ', 4 * (depth + 1));
                methodText.AppendLine("}");
            }

            builder.Append($@"
    public void M_{methodIndex}()
    {{
{methodText.ToString()}
    }}");

        }

        /// <summary>
        /// This test exercises the C# local function capturing analysis by generating
        /// all possible combinations of capturing within a certain complexity. The
        /// generating functions use a maximum number of variables captured per local function,
        /// a maximum number of local functions, and a maximum scope depth to decide the
        /// limits of the combinations.
        /// </summary>
        [NoIOperationValidationFact]
        public void AllCaptureTests()
        {
            var methods = MakeAllMethods().ToList();

            var fields = methods.First().CaptureContext.VariablesByScope[0];

            const int PartitionSize = 500;
            const string ClassFmt = @"
using System;
public class C
{{
    {0}";
            StringBuilder GetClassStart()
                => new StringBuilder(string.Format(ClassFmt,
                    string.Join("\r\n", fields.Select(f => $"public int {f} = 0;"))));

            Parallel.ForEach(Partitioner.Create(0, methods.Count, PartitionSize), (range, state) =>
            {
                var methodsText = GetClassStart();

                for (int methodIndex = range.Item1; methodIndex < range.Item2; methodIndex++)
                {
                    var methodInfo = methods[methodIndex];

                    if (methodInfo.TotalLocalFuncs == 0)
                    {
                        continue;
                    }

                    SerializeMethod(methodInfo, methodsText, methodIndex);
                }

                methodsText.AppendLine("\r\n}");
                CreateStandardCompilation(methodsText.ToString()).VerifyEmitDiagnostics();
            });
        }
    }
}


text:
package cmd

import (
	"bufio"
	"io"
	"os"
	"os/exec"
	"path"

	log "github.com/Sirupsen/logrus"
	"github.com/spf13/cobra"
)

// testCmd represents the test command
var testCmd = &cobra.Command{
	Use:   "test",
	Short: "Execute go tests on a package",
	Long: `Test executes test on a go package
		First gets the package then executes.
		Then executs go tests on the package.
		Writes results to mount`,
	Run: func(cmd *cobra.Command, args []string) {
		log.Debug("test called")
		err := runTest()
		if err != nil {
			log.Error(err)
			cmd.Usage()
		}
	},
}

func runTest() error {
	var pwd string
	var results = "/results/test-results.xml"

	err := processRootFlags()
	if err != nil {
		return err
	}

	err = runGoGet()
	if err != nil {
		return err
	}
	pwd, err = os.Getwd()
	if err != nil {
		return err
	}
	swd := path.Join(pwd, "src", goPkg)
	os.Chdir(swd)

	log.WithFields(
		log.Fields{
			"originalPath": pwd,
			"sourcepath":   swd,
		}).Debug("Path")
	// in source folder
	//| go-junit-report > $CIRCLE_TEST_REPORTS/junit/test-results.xml
	test := exec.Command("go", "test", "-v", "./...")
	report := exec.Command("go-junit-report")

	r, w := io.Pipe()

	// pipe test out to report in
	test.Stdout = w
	report.Stdin = r

	// create the report file
	f, err := os.Create(results)
	if err != nil {
		return err
	}
	defer f.Close()

	reportwriter := bufio.NewWriter(f)
	// attach file out to report command output
	report.Stdout = reportwriter

	// run commnads and wait for completion
	test.Start()
	report.Start()
	test.Wait()
	w.Close()
	report.Wait()
	reportwriter.Flush()
	os.Chdir(pwd)
	log.WithField("Output", results).Info("Test complete")
	return err
}

func init() {
	RootCmd.AddCommand(testCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// testCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// testCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}


text:
package minium;

public interface Elements extends AsIs {
}


text:
CKEDITOR.plugins.setLang( 'specialchar', 'lt', {
	options: 'Specialaus simbolio nustatymai',
	title: 'Pasirinkite specialų simbolį',
	toolbar: 'Įterpti specialų simbolį'
} );


text:
@implementation FAITHCityButton

-(void)layoutSubviews
{
    [super layoutSubviews];

    if (self.titleLabel.x>self.imageView.x) {
        self.titleLabel.x=0;

        self.imageView.x=CGRectGetMaxX(self.titleLabel.frame);
    }

}

+(UIBarButtonItem *)butttonWithImageName:(NSString *)imageName title:(NSString *)title target:(id)target action:(SEL)action
{
    FAITHCityButton *btn=[FAITHCityButton buttonWithType:UIButtonTypeCustom];

    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];

    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    [btn sizeToFit];

    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end


text:
package ravtrix.backpackerbuddy.token;

import java.math.BigInteger;
import java.security.SecureRandom;

/**
 * Created by Ravinder on 3/26/17.
 */

public class TokenGenerator {

    private SecureRandom random = new SecureRandom();

    public String getSecureToken() {
        return new BigInteger(130, random).toString(32);
    }
}