text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.wcm.qa</groupId>
    <artifactId>io.wcm.qa.galenium.integration.ui-tests</artifactId>
    <version>${version}</version>
    <relativePath />
  </parent>

  <groupId>\${groupId}</groupId>
  <artifactId>\${artifactId}</artifactId>
  <version>\${version}</version>
  <packaging>pom</packaging>

  <properties>
    <!-- Selenium configuration -->
    <selenium.runmode>local</selenium.runmode>

    <!-- TestNG configuration -->
    <!-- workaround for -Dgroups=xyz conflicting javadoc plugin with testNG
      http://stackoverflow.com/questions/24441210/maven-3-javadoc-plugin-conflicts-with-testng-groups -->
    <testNG.groups />

    <!-- needed by the maven-failsafe-plugin -->
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- Galenium -->
    <galenium.browser>chrome</galenium.browser>
    <galenium.browsermob.proxy>true</galenium.browsermob.proxy>
    <galenium.generated.artifactIds>${rootArtifactId}.specs</galenium.generated.artifactIds>
    <galenium.headless>true</galenium.headless>
    <galenium.ignoreVerification>false</galenium.ignoreVerification>
    <galenium.mediaquery.width.min>320</galenium.mediaquery.width.min>
    <galenium.mediaquery.height>1000</galenium.mediaquery.height>
    <galenium.mediaquery.properties>\${project.build.directory}/test-classes/mediaqueries.properties</galenium.mediaquery.properties>
    <galenium.mediaquery.extentCategory>MQ_</galenium.mediaquery.extentCategory>
    <galenium.report.rootPath>\${project.build.directory}/glnm-reports</galenium.report.rootPath>
    <galenium.retryMax>0</galenium.retryMax>
    <galenium.skipTests>true</galenium.skipTests>
    <galenium.suppressAutoAdjustBrowserSize>false</galenium.suppressAutoAdjustBrowserSize>

    <!-- compiler settings -->
    <build.compiler.source>1.8</build.compiler.source>
    <build.compiler.target>1.8</build.compiler.target>

  </properties>

    <dependencies>

      <!-- Galenium -->
      <dependency>
        <groupId>io.wcm.qa</groupId>
        <artifactId>io.wcm.qa.galenium.integration.ui-tests</artifactId>
        <type>pom</type>
        <version>${version}</version>
      </dependency>
    </dependencies>

  <dependencyManagement>
    <dependencies>

      <!-- Galenium -->
      <dependency>
        <groupId>io.wcm.qa</groupId>
        <artifactId>io.wcm.qa.galenium.integration.ui-tests</artifactId>
        <type>pom</type>
        <version>${version}</version>
      </dependency>

      <!-- CSV parsing -->
      <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-csv</artifactId>
        <version>2.8.8</version>
      </dependency>

      <!-- Jsoup for html parsing -->
      <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.14.3</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>

    <plugins>

      <!-- Project specific configuration of UI tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <!-- activated in profiles -->
          <skip>true</skip>
        </configuration>
      </plugin>

    </plugins>

    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

  </build>

  <profiles>

    <!-- for use in local development build -->
    <profile>
      <id>local-dev</id>
      <build>
        <plugins>

          <!-- Run UI tests -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <skip>false</skip>
            </configuration>
          </plugin>

        </plugins>
      </build>
    </profile>

  </profiles>
</project>

redpajama_set_name: RedPajamaGithub


text:
define(function(require) {
    'use strict';

    var EasingFunctions = require('wf-js-uicomponents/awesome_map/EasingFunctions');

    describe('EasingFunctions', function() {

        var startValue = 0;
        var delta = 1;
        var duration = 100;

        function expectStartValueWhenNoTimeElapses(fn) {
            var value = fn(startValue, delta, duration, 0);

            expect(value).toBe(startValue);
        }

        function expectEndValueWhenDurationElapses(fn) {
            var value = fn(startValue, delta, duration, 100);

            expect(value).toBe(startValue + delta);
        }

        describe('easeOutCubic', function() {

            describe('css', function() {
                it('should be the ease out cubic CSS string', function() {
                    expect(EasingFunctions.easeOutCubic.css)
                        .toBe('cubic-bezier(0.215, 0.61, 0.355, 1)');
                });
            });

            describe('js', function() {
                it('should return start value when no time elapses', function() {
                    expectStartValueWhenNoTimeElapses(EasingFunctions.easeOutCubic.js);
                });

                it('should return target value when duration elapses', function() {
                    expectEndValueWhenDurationElapses(EasingFunctions.easeOutCubic.js);
                });
            });
        });

        describe('easeOutQuart', function() {

            describe('css', function() {
                it('should be the ease out cubic CSS string', function() {
                    expect(EasingFunctions.easeOutQuart.css)
                        .toBe('cubic-bezier(0.165, 0.84, 0.44, 1)');
                });
            });

            describe('js', function() {
                it('should return start value when no time elapses', function() {
                    expectStartValueWhenNoTimeElapses(EasingFunctions.easeOutQuart.js);
                });

                it('should return target value when duration elapses', function() {
                    expectEndValueWhenDurationElapses(EasingFunctions.easeOutQuart.js);
                });
            });
        });
    });
});


text:
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace google.maps
{
    /// <summary>
    /// The representation of a panorama returned from the provider defined using registerPanoProvider.
    /// </summary>
    [ScriptName("Object")]
    [IgnoreNamespace]
    [Imported]
    public sealed partial class StreetViewPanoramaData
    {
        /// <summary>
        /// Specifies the copyright text for this panorama.
        /// </summary>
        [IntrinsicProperty]
        public string Copyright
        {
            get { throw new NotImplementedException(); }
            set { }
        }

        /// <summary>
        /// Specifies the navigational links to adjacent panoramas.
        /// </summary>
        [IntrinsicProperty]
        public List<StreetViewLink> Links
        {
            get { throw new NotImplementedException(); }
            set { }
        }

        /// <summary>
        /// Specifies the location meta-data for this panorama.
        /// </summary>
        [IntrinsicProperty]
        public StreetViewLocation Location
        {
            get { throw new NotImplementedException(); }
            set { }
        }

        /// <summary>
        /// Specifies the custom tiles for this panorama.
        /// </summary>
        [IntrinsicProperty]
        public StreetViewTileData Tiles
        {
            get { throw new NotImplementedException(); }
            set { }
        }
    }
}


text:
package com.atinternet.tracker;

import java.util.LinkedHashMap;

/**
 * Abstract class to manage screen tracking
 */
public abstract class AbstractScreen extends BusinessObject {

    enum Action {
        View("view");

        private final String str;

        Action(String val) {
            str = val;
        }

        public String stringValue() {
            return str;
        }
    }

    protected String name;
    protected String chapter1;
    protected String chapter2;
    protected String chapter3;

    protected Action action;
    boolean isBasketScreen;
    String level2;

    private LinkedHashMap<String, CustomObject> customObjectsMap;
    private LinkedHashMap<String, CustomVar> customVarsMap;
    private LinkedHashMap<String, SelfPromotionImpression> selfPromotionImpressionsMap;
    private LinkedHashMap<String, PublisherImpression> publisherImpressionsMap;

    private Location location;
    private Aisle aisle;
    private CustomTreeStructure customTreeStructure;
    private InternalSearch internalSearch;
    private Cart cart;
    private Campaign campaign;
    private Order order;
    private CustomVars customVars;
    private CustomObjects customObjects;
    private PublisherImpressions publisherImpressions;
    private SelfPromotionImpressions selfPromotionImpressions;

    AbstractScreen() {
        action = Action.View;
        level2 = null;
        name = "";
    }

    AbstractScreen(Tracker tracker) {
        super(tracker);
        action = Action.View;
        level2 = null;
        name = "";
    }

    LinkedHashMap<String, CustomObject> getCustomObjectsMap() {
        if (customObjectsMap == null) {
            customObjectsMap = new LinkedHashMap<>();
        }
        return customObjectsMap;
    }

    LinkedHashMap<String, CustomVar> getCustomVarsMap() {
        if (customVarsMap == null) {
            customVarsMap = new LinkedHashMap<>();
        }
        return customVarsMap;
    }

    LinkedHashMap<String, SelfPromotionImpression> getSelfPromotionImpressionsMap() {
        if (selfPromotionImpressionsMap == null) {
            selfPromotionImpressionsMap = new LinkedHashMap<>();
        }
        return selfPromotionImpressionsMap;
    }

    LinkedHashMap<String, PublisherImpression> getPublisherImpressionsMap() {
        if (publisherImpressionsMap == null) {
            publisherImpressionsMap = new LinkedHashMap<>();
        }
        return publisherImpressionsMap;
    }

    /**
     * Get the screen name
     *
     * @return the screen name
     */
    public String getName() {
        return name;
    }

    /**
     * Get the action type
     *
     * @return the action type
     */
    public Action getAction() {
        return action;
    }

    /**
     * Get the level 2
     *
     * @return the level 2
     */
    public int getLevel2() {
        return Utility.parseInt(level2, -1);
    }

    /**
     * Get the level 2 string
     *
     * @return the level 2
     */
    public String getLevel2String() {
        return level2;
    }

    /**
     * Get the first chapter
     *
     * @return the first chapter
     */
    public String getChapter1() {
        return chapter1;
    }

    /**
     * Get the second chapter
     *
     * @return the second chapter
     */
    public String getChapter2() {
        return chapter2;
    }

    /**
     * Get the third chapter
     *
     * @return the third chapter
     */
    public String getChapter3() {
        return chapter3;
    }

    /**
     * Get "isBasketScreen" value
     *
     * @return true is screen is basket screen
     */
    public boolean isBasketScreen() {
        return isBasketScreen;
    }

    /**
     * Attach a cart to screen
     *
     * @param cart the cart instance
     */
    public void setCart(Cart cart) {
        this.cart = cart;
        isBasketScreen = this.cart != null;
    }

    /**
     * Attach location information to screen
     *
     * @param latitude  latitude x value
     * @param longitude longitude y value
     * @return the Location instance
     */
    public Location Location(double latitude, double longitude) {
        if (location == null) {
            location = new Location(tracker).setLatitude(latitude).setLongitude(longitude);
        }
        return location;
    }

    /**
     * Attach visited aisle information to screen
     *
     * @param level1 first aisle level
     * @return the Aisle instance
     */
    public Aisle Aisle(String level1) {
        if (aisle == null) {
            aisle = new Aisle(tracker).setLevel1(level1);
        }
        return aisle;
    }

    /**
     * Attach a custom tree structure to screen
     *
     * @param category1 first custom tree structure category
     * @return the CustomTreeStructure instance
     */
    public CustomTreeStructure CustomTreeStructure(int category1) {
        if (customTreeStructure == null) {
            customTreeStructure = new CustomTreeStructure(tracker).setCategory1(category1);
        }
        return customTreeStructure;
    }

    /**
     * Attach campaign information to screen
     *
     * @param campaignId campaign identifier
     * @return the Campaign identifier
     */
    public Campaign Campaign(String campaignId) {
        if (campaign == null) {
            campaign = new Campaign(tracker).setCampaignId(campaignId);
        }
        return campaign;
    }

    /**
     * Attach an order to screen
     *
     * @param orderId  order identifier
     * @param turnover order turnover
     * @return the Order instance
     * @deprecated Since 2.3.4, bug was revealed when this method is used. Use Orders tracker property instead.
     */
    @Deprecated
    public Order Order(String orderId, double turnover) {
        if (order == null) {
            order = new Order(tracker).setOrderId(orderId).setTurnover(turnover);
        }
        return order;
    }

    /**
     * Attach internal search information to screen
     *
     * @param keywordLabel       keyword has been searched
     * @param resultScreenNumber screen result number
     * @return the InternalSearch instance
     */
    public InternalSearch InternalSearch(String keywordLabel, int resultScreenNumber) {
        if (internalSearch == null) {
            internalSearch = new InternalSearch(tracker)
                    .setKeyword(keywordLabel)
                    .setResultScreenNumber(resultScreenNumber);
        }
        return internalSearch;
    }

    /**
     * Get a wrapper for CustomVar management
     *
     * @return CustomVars instance
     */
    public CustomVars CustomVars() {
        if (customVars == null) {
            customVars = new CustomVars(this);
        }
        return customVars;
    }

    /**
     * Get a wrapper for CustomObject management
     *
     * @return CustomObjects instance
     */
    public CustomObjects CustomObjects() {
        if (customObjects == null) {
            customObjects = new CustomObjects(this);
        }
        return customObjects;
    }

    /**
     * Get a wrapper for PublisherImpression management
     *
     * @return PublisherImpressions instance
     */
    public PublisherImpressions Publishers() {
        if (publisherImpressions == null) {
            publisherImpressions = new PublisherImpressions(this);
        }
        return publisherImpressions;
    }

    /**
     * Get a wrapper for SelfPromotionImpression management
     *
     * @return SelfPromotionImpressions instance
     */
    public SelfPromotionImpressions SelfPromotions() {
        if (selfPromotionImpressions == null) {
            selfPromotionImpressions = new SelfPromotionImpressions(this);
        }
        return selfPromotionImpressions;
    }

    /**
     * Send the screen view event
     */
    public void sendView() {
        action = Action.View;
        tracker.getDispatcher().dispatch(this);
    }

    @Override
    void setParams() {
        if (level2 != null) {
            tracker.setParam(Hit.HitParam.Level2.stringValue(), level2);
        }

        if (isBasketScreen) {
            tracker.setParam(Hit.HitParam.Tp.stringValue(), "cart");
        }

        if (location != null) {
            location.setParams();
        }

        if (campaign != null) {
            campaign.setParams();
        }

        if (internalSearch != null) {
            internalSearch.setParams();
        }

        if (aisle != null) {
            aisle.setParams();
        }

        if (cart != null) {
            cart.setParams();
        }

        if (order != null) {
            order.setParams();
        }

        if (customTreeStructure != null) {
            customTreeStructure.setParams();
        }

        if (customObjectsMap != null) {
            for (CustomObject co : customObjectsMap.values()) {
                co.setParams();
            }
        }

        if (customVarsMap != null) {
            for (CustomVar cv : customVarsMap.values()) {
                cv.setParams();
            }
        }

        if (selfPromotionImpressionsMap != null) {
            for (SelfPromotionImpression spi : selfPromotionImpressionsMap.values()) {
                spi.setParams();
            }
        }

        if (publisherImpressionsMap != null) {
            for (PublisherImpression pi : publisherImpressionsMap.values()) {
                pi.setParams();
            }
        }
    }
}


text: Tavern - elegant, feature rich forum app based on Laravel


text:
template <class T,
          class Object,
          T (Object::*real_getter)(),
          T (Object::*real_setter)(T const &)>
class RWProperty {
  Object * my_object;
public:
  RWProperty() : my_object(0) {}
  RWProperty(Object * me)
               : my_object(me) {}

  // this function must be called by the
  // containing class, normally in a
  // constructor, to initialize the
  // ROProperty so it knows where its
  // real implementation code can be
  // found
  void operator()(Object * obj) {
    my_object = obj;
  }

  // function call syntax
  T operator()() const {
    return (my_object->*real_getter)();
  }
  T operator()(T const & value) {
    return (my_object->*real_setter)(value);
  }

  // get/set syntax
  T get() const {
    return (my_object->*real_getter)();
  }
  T set(T const & value) {
    return (my_object->*real_setter)(value);
  }
  // access with '=' sign
  operator T() const {
    return (my_object->*real_getter)();
  }
  T operator=(T const & value) {
    return (my_object->*real_setter)(value);
  }

  typedef T value_type;
            // might be useful for template
            // deductions
};


text:
<?php
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Yaml.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Escaper.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Inline.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Parser.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Unescaper.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Exception/ExceptionInterface.php";
require_once __DIR__ . "/../symfony/src/Symfony/Component/Yaml/Exception/ParseException.php";

use Symfony\Component\Yaml\Yaml;

abstract class BundlesAutoloader
{
    private $autoloaders;
    private $autoloadersPaths;

    abstract public function configure();

    public function __construct()
    {
        $this->autoloadersPaths = $this->configure();
        $this->setupAutoloaders();
    }

    public function getNamespaces($dir)
    {
        $res = array();

        $namespaces = $this->processAutoloaders('namespace');
        foreach($namespaces as $bundleNamespaces)
        {
            foreach($bundleNamespaces as $bundleNamespace)
            {
                $res[$bundleNamespace['alias']] = $dir . $bundleNamespace['path'];
            }
        }

        return $res;
    }

    public function getBundles($environment = null)
    {
        $res = array();
        $bundles = $this->processAutoloaders('bundle');
        foreach($bundles as $bundle)
        {
            if(empty($bundle['environment']) || (in_array($environment, $bundle['environment'])))
            {
                $class = $bundle['class'];
                $res[] = new $class();
            }
        }

        return $res;
    }

    protected function setupAutoloaders()
    {
        foreach($this->autoloadersPaths as $autoloaderPath)
        {
            preg_match('/[\/|\\\][\w]+Bundle$/', $autoloaderPath, $match);
            if(empty($match))
            {
                if ($handle = opendir($autoloaderPath))
                {
                    while (false !== ($file = readdir($handle)))
                    {
                        $fileName = $autoloaderPath . '/' . $file;
                        if ($file != '.' && $file != '..' && is_dir($fileName))
                        {
                            preg_match('/[\w+]Bundle$/', $file, $match);
                            if(!empty ($match)) $this->parseAutoloader($fileName);
                        }
                    }
                }
                closedir($handle);
            }
            else
            {
                $this->parseAutoloader($autoloaderPath);
            }
        }
    }

    private function parseAutoloader($autoloaderPath)
    {
        $file = $autoloaderPath . '/Resources/config/autoloader.yml';
        if(is_file($file))
        {
            $this->autoloaders[] = Yaml::parse($file);
        }
        else
        {
            $bundleName = basename($autoloaderPath);
            $file = $autoloaderPath . "/" . $bundleName . '.php';
            if(is_file($file))
            {
                $class = file_get_contents($file);
                preg_match('/namespace\s(.*?);/', $class, $match);
                $this->autoloaders[] = array($bundleName  => array('bundle' => array('class' => $match[1] . '\\' . $bundleName)));
            }
        }
    }

    protected function processAutoloaders($type)
    {
        $res = array();
        foreach($this->autoloaders as $autoloader)
        {
            foreach($autoloader as $bundleName => $value)
            {
                if(array_key_exists($type, $value)) $res[$bundleName] = $value[$type];
            }
        }

        return $res;
    }
}


text:
    <form id="form1" method="post">

                原密码:
                <input type="password"  class="easyui-validatebox" name="oldPasswd"  required="true" />

                新密码:
                <input type="password" name="newPasswd" class="easyui-validatebox" required="true"  validType="length[5,10]" />

                确认新密码:
                <input type="password" name="confirmPasswd" class="easyui-validatebox" required="true"  validType="eque" />

                提交

    </form>


text:
layout: "docs"
page_title: "Multi-Machine"
sidebar_current: "multimachine"
description: |-
  Vagrant is able to define and control multiple guest machines per
  Vagrantfile. This is known as a "multi-machine" environment.
---

# Multi-Machine

Vagrant is able to define and control multiple guest machines per
Vagrantfile. This is known as a "multi-machine" environment.

These machines are generally able to work together or are somehow associated
with each other. Here are some use-cases people are using multi-machine
environments for today:

* Accurately modeling a multi-server production topology, such as separating
  a web and database server.
* Modeling a distributed system and how they interact with each other.
* Testing an interface, such as an API to a service component.
* Disaster-case testing: machines dying, network partitions, slow networks,
  inconsistent world views, etc.

Historically, running complex environments such as these was done by
flattening them onto a single machine. The problem with that is that it is
an inaccurate model of the production setup, which can behave far differently.

Using the multi-machine feature of Vagrant, these environments can be modeled
in the context of a single Vagrant environment without losing any of the
benefits of Vagrant.

## Defining Multiple Machines

Multiple machines are defined within the same project [Vagrantfile](/docs/vagrantfile/)
using the `config.vm.define` method call. This configuration directive
is a little funny, because it creates a Vagrant configuration within a
configuration. An example shows this best:

```ruby
Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: "echo Hello"

  config.vm.define "web" do |web|
    web.vm.box = "apache"
  end

  config.vm.define "db" do |db|
    db.vm.box = "mysql"
  end
end
```

As you can see, `config.vm.define` takes a block with another variable. This
variable, such as `web` above, is the _exact_ same as the `config` variable,
except any configuration of the inner variable applies only to the machine
being defined. Therefore, any configuration on `web` will only affect the
`web` machine.

And importantly, you can continue to use the `config` object as well. The
configuration object is loaded and merged before the machine-specific configuration,
just like other Vagrantfiles within the
[Vagrantfile load order](/docs/vagrantfile/#load-order).

If you are familiar with programming, this is similar to how languages have
different variable scopes.

When using these scopes, order of execution for things such as
provisioners becomes important. Vagrant enforces ordering outside-in, in
the order listed in the Vagrantfile. For example, with the Vagrantfile
below:

```ruby
Vagrant.configure("2") do |config|
  config.vm.provision :shell, inline: "echo A"

  config.vm.define :testing do |test|
    test.vm.provision :shell, inline: "echo B"
  end

  config.vm.provision :shell, inline: "echo C"
end
```

The provisioners in this case will output "A", then "C", then "B". Notice
that "B" is last. That is because the ordering is outside-in, in
the order of the file.

If you want to apply a slightly different configuration to multiple machines,
see [this tip](/docs/vagrantfile/tips.html#loop-over-vm-definitions).

## Controlling Multiple Machines

The moment more than one machine is defined within a Vagrantfile, the
usage of the various `vagrant` commands changes slightly. The change should
be mostly intuitive.

Commands that only make sense to target a single machine, such as
`vagrant ssh`, now _require_ the name of the machine to control. Using
the example above, you would say `vagrant ssh web` or `vagrant ssh db`.

Other commands, such as `vagrant up`, operate on _every_ machine by
default. So if you ran `vagrant up`, Vagrant would bring up both the
web and DB machine. You could also optionally be specific and say
`vagrant up web` or `vagrant up db`.

Additionally, you can specify a regular expression for matching only
certain machines. This is useful in some cases where you specify many similar
machines, for example if you are testing a distributed service you may have
a `leader` machine as well as a `follower0`, `follower1`, `follower2`, etc. If you
want to bring up all the followers but not the leader, you can just do
`vagrant up /follower[0-9]/`. If Vagrant sees a machine name within forward
slashes, it assumes you are using a regular expression.

## Communication Between Machines

In order to facilitate communication within machines in a multi-machine setup,
the various [networking](/docs/networking/) options should be used.
In particular, the [private network](/docs/networking/private_network.html) can
be used to make a private network between multiple machines and the host.

## Specifying a Primary Machine

You can also specify a _primary machine_. The primary machine will be the
default machine used when a specific machine in a multi-machine environment
is not specified.

To specify a default machine, just mark it primary when defining it. Only
one primary machine may be specified.

```ruby
config.vm.define "web", primary: true do |web|
  # ...
end
```

## Autostart Machines

By default in a multi-machine environment, `vagrant up` will start
all of the defined machines. The `autostart` setting allows you to tell
Vagrant to _not_ start specific machines. Example:

```ruby
config.vm.define "web"
config.vm.define "db"
config.vm.define "db_follower", autostart: false
```

When running `vagrant up` with the settings above, Vagrant will automatically
start the "web" and "db" machines, but will not start the "db\_follower" machine.
You can manually force the "db\_follower" machine to start by running
`vagrant up db_follower`.


text:
/* request an invalid column from a non-existent table */
select dsjfkl dsjf
go
select db_name()
go


text: a instagram clone using rails


text:
import { connect } from "react-redux";
import _ from "lodash";
import { updateCurrentUser } from "../../../shared/ducks/config";
import Sugggestions from "../components/suggestions";
import {
  setDetailTaxon,
  updateQuery,
  fetchSuggestions,
  fetchDetailTaxon
} from "../ducks/suggestions";

function mapStateToProps( state ) {
  let nextTaxon;
  let prevTaxon;
  if ( state.suggestions.detailTaxon ) {
    const detailTaxonIndex = _.findIndex( state.suggestions.response.results,
      r => r.taxon.id === state.suggestions.detailTaxon.id );
    const prevResult = state.suggestions.response.results[detailTaxonIndex - 1];
    prevTaxon = prevResult ? prevResult.taxon : null;
    const nextResult = state.suggestions.response.results[detailTaxonIndex + 1];
    nextTaxon = nextResult ? nextResult.taxon : null;
  }
  return Object.assign( {}, state.suggestions, {
    observation: Object.assign( {}, state.currentObservation.observation ),
    prevTaxon,
    nextTaxon,
    config: state.config
  } );
}

function mapDispatchToProps( dispatch ) {
  return {
    setDetailTaxon: ( taxon, options = {} ) => {
      dispatch( setDetailTaxon( taxon, options ) );
      dispatch( fetchDetailTaxon( ) );
    },
    setQuery: query => {
      dispatch( updateQuery( query ) );
      dispatch( fetchSuggestions( ) );
    },
    updateCurrentUser: updates => dispatch( updateCurrentUser( updates ) )
  };
}

const SuggestionsContainer = connect(
  mapStateToProps,
  mapDispatchToProps
)( Sugggestions );

export default SuggestionsContainer;


text:
/********************************************************************************************
* Supersingular Isogeny Key Encapsulation Library
*
* Abstract: configuration file and platform-dependent macros
*********************************************************************************************/

#ifndef __CONFIG_H__
#define __CONFIG_H__

#include "sike_r1_namespace.h"
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

// Definition of compiler

#define COMPILER_GCC     1
#define COMPILER_CLANG   2

#if defined(__GNUC__)           // GNU GCC compiler
    #define COMPILER COMPILER_GCC
#elif defined(__clang__)        // Clang compiler
    #define COMPILER COMPILER_CLANG
#else
    #error -- "Unsupported COMPILER"
#endif

#define _AMD64_

// Definition of the targeted architecture and basic data types

#define TARGET_AMD64        1
#define TARGET_x86          2
#define TARGET_ARM          3
#define TARGET_ARM64        4

#if defined(_AMD64_)
    #define TARGET TARGET_AMD64
    #define RADIX           64
    #define LOG2RADIX       6
    typedef uint64_t        digit_t;        // Unsigned 64-bit digit
#elif defined(_X86_)
    #define TARGET TARGET_x86
    #define RADIX           32
    #define LOG2RADIX       5
    typedef uint32_t        digit_t;        // Unsigned 32-bit digit
#elif defined(_ARM_)
    #define TARGET TARGET_ARM
    #define RADIX           32
    #define LOG2RADIX       5
    typedef uint32_t        digit_t;        // Unsigned 32-bit digit
#elif defined(_ARM64_)
    #define TARGET TARGET_ARM64
    #define RADIX           64
    #define LOG2RADIX       6
    typedef uint64_t        digit_t;        // Unsigned 64-bit digit
#else
    #error -- "Unsupported ARCHITECTURE"
#endif

#define RADIX64             64

// Selection of implementation: optimized_generic

#if defined(_OPTIMIZED_GENERIC_)
    #define OPTIMIZED_GENERIC_IMPLEMENTATION
#endif

// Extended datatype support

typedef uint64_t uint128_t[2];

// Macro definitions

#define NBITS_TO_NBYTES(nbits)      (((nbits)+7)/8)                                          // Conversion macro from number of bits to number of bytes
#define NBITS_TO_NWORDS(nbits)      (((nbits)+(sizeof(digit_t)*8)-1)/(sizeof(digit_t)*8))    // Conversion macro from number of bits to number of computer words
#define NBYTES_TO_NWORDS(nbytes)    (((nbytes)+sizeof(digit_t)-1)/sizeof(digit_t))           // Conversion macro from number of bytes to number of computer words

// Macro to avoid compiler warnings when detecting unreferenced parameters
#define UNREFERENCED_PARAMETER(PAR) ((void)(PAR))

/********************** Constant-time unsigned comparisons ***********************/

// The following functions return 1 (TRUE) if condition is true, 0 (FALSE) otherwise

static __inline unsigned int is_digit_nonzero_ct(digit_t x)
{ // Is x != 0?
    return (unsigned int)((x | (0-x)) >> (RADIX-1));
}

static __inline unsigned int is_digit_zero_ct(digit_t x)
{ // Is x = 0?
    return (unsigned int)(1 ^ is_digit_nonzero_ct(x));
}

static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y)
{ // Is x < y?
    return (unsigned int)((x ^ ((x ^ y) | ((x - y) ^ y))) >> (RADIX-1));
}

/********************** Macros for platform-dependent operations **********************/

// Digit multiplication
#define MUL(multiplier, multiplicand, hi, lo)                                                     \
    digit_x_digit((multiplier), (multiplicand), &(lo));

// Digit addition with carry
#define ADDC(carryIn, addend1, addend2, carryOut, sumOut)                                         \
    { digit_t tempReg = (addend1) + (digit_t)(carryIn);                                           \
    (sumOut) = (addend2) + tempReg;                                                               \
    (carryOut) = (is_digit_lessthan_ct(tempReg, (digit_t)(carryIn)) | is_digit_lessthan_ct((sumOut), tempReg)); }

// Digit subtraction with borrow
#define SUBC(borrowIn, minuend, subtrahend, borrowOut, differenceOut)                             \
    { digit_t tempReg = (minuend) - (subtrahend);                                                 \
    unsigned int borrowReg = (is_digit_lessthan_ct((minuend), (subtrahend)) | ((borrowIn) & is_digit_zero_ct(tempReg)));  \
    (differenceOut) = tempReg - (digit_t)(borrowIn);                                              \
    (borrowOut) = borrowReg; }

// Shift right with flexible datatype
#define SHIFTR(highIn, lowIn, shift, shiftOut, DigitSize)                                         \
    (shiftOut) = ((lowIn) >> (shift)) ^ ((highIn) << (DigitSize - (shift)));

// Shift left with flexible datatype
#define SHIFTL(highIn, lowIn, shift, shiftOut, DigitSize)                                         \
    (shiftOut) = ((highIn) << (shift)) ^ ((lowIn) >> (DigitSize - (shift)));

// 64x64-bit multiplication
#define MUL128(multiplier, multiplicand, product)                                                 \
    mp_mul((digit_t*)&(multiplier), (digit_t*)&(multiplicand), (digit_t*)&(product), NWORDS_FIELD/2);

// 128-bit addition, inputs < 2^127
#define ADD128(addend1, addend2, addition)                                                        \
    mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD);

// 128-bit addition with output carry
#define ADC128(addend1, addend2, carry, addition)                                                 \
    (carry) = mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD);

#endif


text:
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

define(['chaplin'], function(Chaplin) {
  var Model;
  return Model = (function(superClass) {
    extend(Model, superClass);

    function Model() {
      return Model.__super__.constructor.apply(this, arguments);
    }

    return Model;

  })(Chaplin.Model);
});

//# sourceMappingURL=../../maps/models/base/model.js.map


text:
module AWS
  module S3
    class Connection #:nodoc:
      class << self
        def connect(options = {})
          new(options)
        end

        def prepare_path(path)
          path = path.remove_extended unless path.valid_utf8?
          AWS::S3.escape_uri(path)
        end
      end

      attr_reader :access_key_id, :secret_access_key, :http, :options

      # Creates a new connection. Connections make the actual requests to S3, though these requests are usually
      # called from subclasses of Base.
      #
      # For details on establishing connections, check the Connection::Management::ClassMethods.
      def initialize(options = {})
        @options = Options.new(options)
        connect
      end

      def request(verb, path, headers = {}, body = nil, attempts = 0, &block)
        body.rewind if body.respond_to?(:rewind) unless attempts.zero?

        requester = Proc.new do
          path    = self.class.prepare_path(path) if attempts.zero? # Only escape the path once
          request = request_method(verb).new(path, headers)
          ensure_content_type!(request)
          add_user_agent!(request)
          authenticate!(request)
          if body
            if body.respond_to?(:read)
              request.body_stream = body
            else
              request.body = body
            end
            request.content_length = body.respond_to?(:lstat) ? body.stat.size : body.size
          else
            request.content_length = 0
          end
          http.request(request, &block)
        end

        if persistent?
          http.start unless http.started?
          requester.call
        else
          http.start(&requester)
        end
      rescue Errno::EPIPE, Timeout::Error, Errno::EINVAL, EOFError, Errno::ECONNRESET
        @http = create_connection
        attempts == 3 ? raise : (attempts += 1; retry)
      end

      def url_for(path, options = {})
        authenticate = options.delete(:authenticated)
        # Default to true unless explicitly false
        authenticate = true if authenticate.nil?
        path         = path.valid_utf8? ? path : path.remove_extended
        request      = request_method(:get).new(path, {})
        query_string = query_string_authentication(request, options)
        "#{protocol(options)}#{http.address}#{port_string}#{path}".tap do |url|
          (url << (path[/\?/] ? '&' : '?') << "#{query_string}") if authenticate
        end
      end

      def subdomain
        http.address[/^([^.]+).#{DEFAULT_HOST}$/, 1]
      end

      def persistent?
        options[:persistent]
      end

      def protocol(options = {})
        # This always trumps http.use_ssl?
        if options[:use_ssl] == false
          'http://'
        elsif options[:use_ssl] || http.use_ssl?
          'https://'
        else
          'http://'
        end
      end

      private
        def extract_keys!
          missing_keys = []
          extract_key = Proc.new {|key| options[key] || (missing_keys.push(key); nil)}
          @access_key_id     = extract_key[:access_key_id]
          @secret_access_key = extract_key[:secret_access_key]
          raise MissingAccessKey.new(missing_keys) unless missing_keys.empty?
        end

        def create_connection
          http             = http_class.new(options[:server], options[:port])
          http.use_ssl     = options[:use_ssl] || options[:port] == 443
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
          http
        end

        def http_class
          if options.connecting_through_proxy?
            Net::HTTP::Proxy(*options.proxy_settings)
          else
            Net::HTTP
          end
        end

        def connect
          extract_keys!
          @http = create_connection
        end

        def port_string
          default_port = options[:use_ssl] ? 443 : 80
          http.port == default_port ? '' : ":#{http.port}"
        end

        def ensure_content_type!(request)
          request['Content-Type'] ||= 'binary/octet-stream'
        end

        # Just do Header authentication for now
        def authenticate!(request)
          request['Authorization'] = Authentication::Header.new(request, access_key_id, secret_access_key)
        end

        def add_user_agent!(request)
          request['User-Agent'] ||= "AWS::S3/#{Version}"
        end

        def query_string_authentication(request, options = {})
          Authentication::QueryString.new(request, access_key_id, secret_access_key, options)
        end

        def request_method(verb)
          Net::HTTP.const_get(verb.to_s.capitalize)
        end

        def method_missing(method, *args, &block)
          options[method] || super
        end

      module Management #:nodoc:
        def self.included(base)
          base.cattr_accessor :connections
          base.connections = {}
          base.extend ClassMethods
        end

        # Manage the creation and destruction of connections for AWS::S3::Base and its subclasses. Connections are
        # created with establish_connection!.
        module ClassMethods
          # Creates a new connection with which to make requests to the S3 servers for the calling class.
          #
          #   AWS::S3::Base.establish_connection!(:access_key_id => '...', :secret_access_key => '...')
          #
          # You can set connections for every subclass of AWS::S3::Base. Once the initial connection is made on
          # Base, all subsequent connections will inherit whatever values you don't specify explictly. This allows you to
          # customize details of the connection, such as what server the requests are made to, by just specifying one
          # option.
          #
          #   AWS::S3::Bucket.established_connection!(:use_ssl => true)
          #
          # The Bucket connection would inherit the <tt>:access_key_id</tt> and the <tt>:secret_access_key</tt> from
          # Base's connection. Unlike the Base connection, all Bucket requests would be made over SSL.
          #
          # == Required arguments
          #
          # * <tt>:access_key_id</tt> - The access key id for your S3 account. Provided by Amazon.
          # * <tt>:secret_access_key</tt> - The secret access key for your S3 account. Provided by Amazon.
          #
          # If any of these required arguments is missing, a MissingAccessKey exception will be raised.
          #
          # == Optional arguments
          #
          # * <tt>:server</tt> - The server to make requests to. You can use this to specify your bucket in the subdomain,
          # or your own domain's cname if you are using virtual hosted buckets. Defaults to <tt>s3.amazonaws.com</tt>.
          # * <tt>:port</tt> - The port to the requests should be made on. Defaults to 80 or 443 if the <tt>:use_ssl</tt>
          # argument is set.
          # * <tt>:use_ssl</tt> - Whether requests should be made over SSL. If set to true, the <tt>:port</tt> argument
          # will be implicitly set to 443, unless specified otherwise. Defaults to false.
          # * <tt>:persistent</tt> - Whether to use a persistent connection to the server. Having this on provides around a two fold
          # performance increase but for long running processes some firewalls may find the long lived connection suspicious and close the connection.
          # If you run into connection errors, try setting <tt>:persistent</tt> to false. Defaults to false.
          # * <tt>:proxy</tt> - If you need to connect through a proxy, you can specify your proxy settings by specifying a <tt>:host</tt>, <tt>:port</tt>, <tt>:user</tt>, and <tt>:password</tt>
          # with the <tt>:proxy</tt> option.
          # The <tt>:host</tt> setting is required if specifying a <tt>:proxy</tt>.
          #
          #   AWS::S3::Bucket.established_connection!(:proxy => {
          #     :host => '...', :port => 8080, :user => 'marcel', :password => 'secret'
          #   })
          def establish_connection!(options = {})
            # After you've already established the default connection, just specify
            # the difference for subsequent connections
            options = default_connection.options.merge(options) if connected?
            connections[connection_name] = Connection.connect(options)
          end

          # Returns the connection for the current class, or Base's default connection if the current class does not
          # have its own connection.
          #
          # If not connection has been established yet, NoConnectionEstablished will be raised.
          def connection
            if connected?
              connections[connection_name] || default_connection
            else
              raise NoConnectionEstablished
            end
          end

          # Returns true if a connection has been made yet.
          def connected?
            !connections.empty?
          end

          # Removes the connection for the current class. If there is no connection for the current class, the default
          # connection will be removed.
          def disconnect(name = connection_name)
            name       = default_connection unless connections.has_key?(name)
            connection = connections[name]
            connection.http.finish if connection.persistent?
            connections.delete(name)
          end

          # Clears *all* connections, from all classes, with prejudice.
          def disconnect!
            connections.each_key {|connection| disconnect(connection)}
          end

          private
            def connection_name
              name
            end

            def default_connection_name
              'AWS::S3::Base'
            end

            def default_connection
              connections[default_connection_name]
            end
        end
      end

      class Options < Hash #:nodoc:
        VALID_OPTIONS = [:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy].freeze

        def initialize(options = {})
          super()
          validate(options)
          replace(:server => DEFAULT_HOST, :port => (options[:use_ssl] ? 443 : 80))
          merge!(options)
        end

        def connecting_through_proxy?
          !self[:proxy].nil?
        end

        def proxy_settings
          self[:proxy].values_at(:host, :port, :user, :password)
        end

        private
          def validate(options)
            invalid_options = options.keys - VALID_OPTIONS
            raise InvalidConnectionOption.new(invalid_options) unless invalid_options.empty?
            raise ArgumentError, "Missing proxy settings. Must specify at least :host." if options[:proxy] && !options[:proxy][:host]
          end
      end
    end
  end
end


text:
@interface TBXML (Private)
- (void) decodeData:(NSData*)data;
- (void) decodeBytes;
- (TBXMLElement*) nextAvailableElement;
- (TBXMLAttribute*) nextAvailableAttribute;
@end

// ================================================================================================
// Public Implementation
// ================================================================================================
@implementation TBXML

@synthesize rootXMLElement;

+ (id)tbxmlWithURL:(NSURL*)aURL {
	return [[[TBXML alloc] initWithURL:aURL] autorelease];
}

+ (id)tbxmlWithXMLString:(NSString*)aXMLString {
	return [[[TBXML alloc] initWithXMLString:aXMLString] autorelease];
}

+ (id)tbxmlWithXMLData:(NSData*)aData {
	return [[[TBXML alloc] initWithXMLData:aData] autorelease];
}

+ (id)tbxmlWithXMLFile:(NSString*)aXMLFile {
	return [[[TBXML alloc] initWithXMLFile:aXMLFile] autorelease];
}

+ (id)tbxmlWithXMLFile:(NSString*)aXMLFile fileExtension:(NSString*)aFileExtension {
	return [[[TBXML alloc] initWithXMLFile:aXMLFile fileExtension:aFileExtension] autorelease];
}

- (id)init {
	self = [super init];
	if (self != nil) {
		rootXMLElement = nil;

		currentElementBuffer = 0;
		currentAttributeBuffer = 0;

		currentElement = 0;
		currentAttribute = 0;

		bytes = 0;
		bytesLength = 0;
	}
	return self;
}

- (id)initWithURL:(NSURL*)aURL {
	self = [self initWithXMLString:[NSString stringWithContentsOfURL:aURL encoding:NSUTF8StringEncoding error:nil]];
	if (self != nil) {
	}
	return self;
}

- (id)initWithXMLString:(NSString*)aXMLString {
	self = [self init];
	if (self != nil) {

		// copy string to byte array
		bytesLength = [aXMLString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
		bytes = malloc(bytesLength+1);
		[aXMLString getBytes:bytes maxLength:bytesLength usedLength:0 encoding:NSUTF8StringEncoding options:NSStringEncodingConversionAllowLossy range:NSMakeRange(0, bytesLength) remainingRange:nil];

		// set null terminator at end of byte array
		bytes[bytesLength] = 0;

		// decode xml data
		[self decodeBytes];
	}
	return self;
}

- (id)initWithXMLData:(NSData*)aData {
    self = [self init];
    if (self != nil) {
		// decode aData
		[self decodeData:aData];
    }

    return self;
}

- (id)initWithXMLFile:(NSString*)aXMLFile fileExtension:(NSString*)aFileExtension {
	self = [self init];
	if (self != nil) {
		// Get uncompressed file contents
		NSData * data = [NSData dataWithUncompressedContentsOfFile:[[NSBundle mainBundle] pathForResource:aXMLFile ofType:aFileExtension]];

		// decode data
		[self decodeData:data];
	}
	return self;
}

- (id)initWithXMLFile:(NSString*)aXMLFile {
	self = [self init];
	if (self != nil) {
		NSString * filename = [aXMLFile stringByDeletingPathExtension];
		NSString * extension = [aXMLFile pathExtension];

		// Get uncompressed file contents
		NSData * data = [NSData dataWithUncompressedContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:extension]];

		// decode data
		[self decodeData:data];
	}
	return self;
}

@end

// ================================================================================================
// Static Functions Implementation
// ================================================================================================

#pragma mark -
#pragma mark Static Functions implementation

@implementation TBXML (StaticFunctions)

+ (NSString*) elementName:(TBXMLElement*)aXMLElement {
	if (nil == aXMLElement->name) return @"";
	return [NSString stringWithCString:&aXMLElement->name[0] encoding:NSUTF8StringEncoding];
}

+ (NSString*) attributeName:(TBXMLAttribute*)aXMLAttribute {
	if (nil == aXMLAttribute->name) return @"";
	return [NSString stringWithCString:&aXMLAttribute->name[0] encoding:NSUTF8StringEncoding];
}

+ (NSString*) attributeValue:(TBXMLAttribute*)aXMLAttribute {
	if (nil == aXMLAttribute->value) return @"";
	return [NSString stringWithCString:&aXMLAttribute->value[0] encoding:NSUTF8StringEncoding];
}

+ (NSString*) textForElement:(TBXMLElement*)aXMLElement {
	if (nil == aXMLElement->text) return @"";
	return [NSString stringWithCString:&aXMLElement->text[0] encoding:NSUTF8StringEncoding];
}

+ (NSString*) valueOfAttributeNamed:(NSString *)aName forElement:(TBXMLElement*)aXMLElement {
	const char * name = [aName cStringUsingEncoding:NSUTF8StringEncoding];
	NSString * value = nil;
	TBXMLAttribute * attribute = aXMLElement->firstAttribute;
	while (attribute) {
		if (strlen(attribute->name) == strlen(name) && memcmp(attribute->name,name,strlen(name)) == 0) {
			value = [NSString stringWithCString:&attribute->value[0] encoding:NSUTF8StringEncoding];
			break;
		}
		attribute = attribute->next;
	}
	return value;
}

+ (TBXMLElement*) childElementNamed:(NSString*)aName parentElement:(TBXMLElement*)aParentXMLElement{
	TBXMLElement * xmlElement = aParentXMLElement->firstChild;
	const char * name = [aName cStringUsingEncoding:NSUTF8StringEncoding];
	while (xmlElement) {
		if (strlen(xmlElement->name) == strlen(name) && memcmp(xmlElement->name,name,strlen(name)) == 0) {
			return xmlElement;
		}
		xmlElement = xmlElement->nextSibling;
	}
	return nil;
}

+ (TBXMLElement*) nextSiblingNamed:(NSString*)aName searchFromElement:(TBXMLElement*)aXMLElement{
	TBXMLElement * xmlElement = aXMLElement->nextSibling;
	const char * name = [aName cStringUsingEncoding:NSUTF8StringEncoding];
	while (xmlElement) {
		if (strlen(xmlElement->name) == strlen(name) && memcmp(xmlElement->name,name,strlen(name)) == 0) {
			return xmlElement;
		}
		xmlElement = xmlElement->nextSibling;
	}
	return nil;
}

@end

// ================================================================================================
// Private Implementation
// ================================================================================================

#pragma mark -
#pragma mark Private implementation

@implementation TBXML (Private)

- (void)decodeData:(NSData*)data {
	// copy data to byte array
	bytesLength = [data length];
	bytes = malloc(bytesLength+1);
	[data getBytes:bytes length:bytesLength];

	// set null terminator at end of byte array
	bytes[bytesLength] = 0;

	// decode xml data
	[self decodeBytes];
}

- (void) decodeBytes{

	// -----------------------------------------------------------------------------
	// Process xml
	// -----------------------------------------------------------------------------

	// set elementStart pointer to the start of our xml
	char * elementStart=bytes;

	// set parent element to nil
	TBXMLElement * parentXMLElement = nil;

	// find next element start
	while ((elementStart = strstr(elementStart,"<")) != nil) {

		// detect comment section
		if (strncmp(elementStart,"<!--",4) == 0) {
			elementStart = strstr(elementStart,"-->") + 3;
			continue;
		}

		// detect cdata section within element text
		int isCDATA = strncmp(elementStart,"<![CDATA[",9);

		// if cdata section found, skip data within cdata section and remove cdata tags
		if (isCDATA==0) {

			// find end of cdata section
			char * CDATAEnd = strstr(elementStart,"]]>");

			// find start of next element skipping any cdata sections within text
			char * elementEnd = CDATAEnd;

			// find next open tag
			elementEnd = strstr(elementEnd,"<");
			// if open tag is a cdata section
			while (strncmp(elementEnd,"<![CDATA[",9) == 0) {
				// find end of cdata section
				elementEnd = strstr(elementEnd,"]]>");
				// find next open tag
				elementEnd = strstr(elementEnd,"<");
			}

			// calculate length of cdata content
			long CDATALength = CDATAEnd-elementStart;

			// calculate total length of text
			long textLength = elementEnd-elementStart;

			// remove begining cdata section tag
			memcpy(elementStart, elementStart+9, CDATAEnd-elementStart-9);

			// remove ending cdata section tag
			memcpy(CDATAEnd-9, CDATAEnd+3, textLength-CDATALength-3);

			// blank out end of text
			memset(elementStart+textLength-12,' ',12);

			// set new search start position
			elementStart = CDATAEnd-9;
			continue;
		}

		// find element end, skipping any cdata sections within attributes
		char * elementEnd = elementStart+1;
		while ((elementEnd = strpbrk(elementEnd, "<>")) != nil) {
			if (strncmp(elementEnd,"<![CDATA[",9) == 0) {
				elementEnd = strstr(elementEnd,"]]>")+3;
			} else {
				break;
			}
		}

		// null terminate element end
		if (elementEnd) *elementEnd = 0;

		// null terminate element start so previous element text doesnt overrun
		*elementStart = 0;

		// get element name start
		char * elementNameStart = elementStart+1;

		// ignore tags that start with ? or ! unless cdata "<![CDATA"
		if (*elementNameStart == '?' || (*elementNameStart == '!' && isCDATA != 0)) {
			elementStart = elementEnd+1;
			continue;
		}

		// ignore attributes/text if this is a closing element
		if (*elementNameStart == '/') {
			elementStart = elementEnd+1;
			if (parentXMLElement) {

				if (parentXMLElement->text) {
					// trim whitespace from start of text
					while (isspace(*parentXMLElement->text))
						parentXMLElement->text++;

					// trim whitespace from end of text
					char * end = parentXMLElement->text + strlen(parentXMLElement->text)-1;
					while (end > parentXMLElement->text && isspace(*end))
						*end--=0;
				}

				parentXMLElement = parentXMLElement->parentElement;

				// if parent element has children clear text
				if (parentXMLElement && parentXMLElement->firstChild)
					parentXMLElement->text = 0;

			}
			continue;
		}

		// is this element opening and closing
		BOOL selfClosingElement = NO;
		if (elementEnd && *(elementEnd-1) == '/') {
			selfClosingElement = YES;
		}

		// create new xmlElement struct
		TBXMLElement * xmlElement = [self nextAvailableElement];

		// set element name
		xmlElement->name = elementNameStart;

		// if there is a parent element
		if (parentXMLElement) {

			// if this is first child of parent element
			if (parentXMLElement->currentChild) {
				// set next child element in list
				parentXMLElement->currentChild->nextSibling = xmlElement;
				xmlElement->previousSibling = parentXMLElement->currentChild;

				parentXMLElement->currentChild = xmlElement;

			} else {
				// set first child element
				parentXMLElement->currentChild = xmlElement;
				parentXMLElement->firstChild = xmlElement;
			}

			xmlElement->parentElement = parentXMLElement;
		}

		// in the following xml the ">" is replaced with \0 by elementEnd.
		// element may contain no atributes and would return nil while looking for element name end
		// <tile>
		// find end of element name
		char * elementNameEnd = strpbrk(xmlElement->name," /");

		// if end was found check for attributes
		if (elementNameEnd) {

			// null terminate end of elemenet name
			*elementNameEnd = 0;

			char * chr = elementNameEnd;
			char * name = nil;
			char * value = nil;
			char * CDATAStart = nil;
			char * CDATAEnd = nil;
			TBXMLAttribute * lastXMLAttribute = nil;
			TBXMLAttribute * xmlAttribute = nil;
			BOOL singleQuote = NO;

			int mode = TBXML_ATTRIBUTE_NAME_START;

			// loop through all characters within element
			while (chr++ < elementEnd) {

				switch (mode) {
					// look for start of attribute name
					case TBXML_ATTRIBUTE_NAME_START:
						if (isspace(*chr)) continue;
						name = chr;
						mode = TBXML_ATTRIBUTE_NAME_END;
						break;
					// look for end of attribute name
					case TBXML_ATTRIBUTE_NAME_END:
						if (isspace(*chr) || *chr == '=') {
							*chr = 0;
							mode = TBXML_ATTRIBUTE_VALUE_START;
						}
						break;
					// look for start of attribute value
					case TBXML_ATTRIBUTE_VALUE_START:
						if (isspace(*chr)) continue;
						if (*chr == '"' || *chr == '\'') {
							value = chr+1;
							mode = TBXML_ATTRIBUTE_VALUE_END;
							if (*chr == '\'')
								singleQuote = YES;
							else
								singleQuote = NO;
						}
						break;
					// look for end of attribute value
					case TBXML_ATTRIBUTE_VALUE_END:
						if (*chr == '<' && strncmp(chr, "<![CDATA[", 9) == 0) {
							mode = TBXML_ATTRIBUTE_CDATA_END;
						}else if ((*chr == '"' && singleQuote == NO) || (*chr == '\'' && singleQuote)) {
							*chr = 0;

							// remove cdata section tags
							while ((CDATAStart = strstr(value, "<![CDATA[")) != nil) {

								// remove begin cdata tag
								memcpy(CDATAStart, CDATAStart+9, strlen(CDATAStart)-8);

								// search for end cdata
								CDATAEnd = strstr(CDATAStart,"]]>");

								// remove end cdata tag
								memcpy(CDATAEnd, CDATAEnd+3, strlen(CDATAEnd)-2);
							}

							// create new attribute
							xmlAttribute = [self nextAvailableAttribute];

							// if this is the first attribute found, set pointer to this attribute on element
							if (!xmlElement->firstAttribute) xmlElement->firstAttribute = xmlAttribute;
							// if previous attribute found, link this attribute to previous one
							if (lastXMLAttribute) lastXMLAttribute->next = xmlAttribute;
							// set last attribute to this attribute
							lastXMLAttribute = xmlAttribute;

							// set attribute name & value
							xmlAttribute->name = name;
							xmlAttribute->value = value;

							// clear name and value pointers
							name = nil;
							value = nil;

							// start looking for next attribute
							mode = TBXML_ATTRIBUTE_NAME_START;
						}
						break;
						// look for end of cdata
					case TBXML_ATTRIBUTE_CDATA_END:
						if (*chr == ']') {
							if (strncmp(chr, "]]>", 3) == 0) {
								mode = TBXML_ATTRIBUTE_VALUE_END;
							}
						}
						break;
					default:
						break;
				}
			}
		}

		// if tag is not self closing, set parent to current element
		if (!selfClosingElement) {
			// set text on element to element end+1
			if (elementEnd && *(elementEnd+1) != '>')
				xmlElement->text = elementEnd+1;

			parentXMLElement = xmlElement;
		}

		// start looking for next element after end of current element
		elementStart = elementEnd+1;
	}
}

// Deallocate used memory
- (void) dealloc {

	if (bytes) {
		free(bytes);
		bytes = nil;
	}

	while (currentElementBuffer) {
		if (currentElementBuffer->elements)
			free(currentElementBuffer->elements);

		if (currentElementBuffer->previous) {
			currentElementBuffer = currentElementBuffer->previous;
			free(currentElementBuffer->next);
		} else {
			free(currentElementBuffer);
			currentElementBuffer = 0;
		}
	}

	while (currentAttributeBuffer) {
		if (currentAttributeBuffer->attributes)
			free(currentAttributeBuffer->attributes);

		if (currentAttributeBuffer->previous) {
			currentAttributeBuffer = currentAttributeBuffer->previous;
			free(currentAttributeBuffer->next);
		} else {
			free(currentAttributeBuffer);
			currentAttributeBuffer = 0;
		}
	}

	[super dealloc];
}

- (TBXMLElement*) nextAvailableElement {
	currentElement++;

	if (!currentElementBuffer) {
		currentElementBuffer = calloc(1, sizeof(TBXMLElementBuffer));
		currentElementBuffer->elements = (TBXMLElement*)calloc(1,sizeof(TBXMLElement)*MAX_ELEMENTS);
		currentElement = 0;
		rootXMLElement = &currentElementBuffer->elements[currentElement];
	} else if (currentElement >= MAX_ELEMENTS) {
		currentElementBuffer->next = calloc(1, sizeof(TBXMLElementBuffer));
		currentElementBuffer->next->previous = currentElementBuffer;
		currentElementBuffer = currentElementBuffer->next;
		currentElementBuffer->elements = (TBXMLElement*)calloc(1,sizeof(TBXMLElement)*MAX_ELEMENTS);
		currentElement = 0;
	}

	return &currentElementBuffer->elements[currentElement];
}

- (TBXMLAttribute*) nextAvailableAttribute {
	currentAttribute++;

	if (!currentAttributeBuffer) {
		currentAttributeBuffer = calloc(1, sizeof(TBXMLAttributeBuffer));
		currentAttributeBuffer->attributes = (TBXMLAttribute*)calloc(MAX_ATTRIBUTES,sizeof(TBXMLAttribute));
		currentAttribute = 0;
	} else if (currentAttribute >= MAX_ATTRIBUTES) {
		currentAttributeBuffer->next = calloc(1, sizeof(TBXMLAttributeBuffer));
		currentAttributeBuffer->next->previous = currentAttributeBuffer;
		currentAttributeBuffer = currentAttributeBuffer->next;
		currentAttributeBuffer->attributes = (TBXMLAttribute*)calloc(MAX_ATTRIBUTES,sizeof(TBXMLAttribute));
		currentAttribute = 0;
	}

	return &currentAttributeBuffer->attributes[currentAttribute];
}

@end


text:
package org.finos.waltz.data.measurable.search;

import org.finos.waltz.data.DatabaseVendorSpecific;
import org.finos.waltz.data.FullTextSearch;
import org.finos.waltz.data.JooqUtilities;
import org.finos.waltz.data.SearchUtilities;
import org.finos.waltz.data.measurable.MeasurableDao;
import org.finos.waltz.model.entity_search.EntitySearchOptions;
import org.finos.waltz.model.measurable.Measurable;
import org.jooq.Condition;
import org.jooq.DSLContext;

import java.util.List;

import static org.finos.waltz.schema.tables.Measurable.MEASURABLE;
import static org.finos.waltz.common.StringUtilities.lower;

public class SqlServerMeasurableSearch implements FullTextSearch<Measurable>, DatabaseVendorSpecific {

    @Override
    public List<Measurable> searchFullText(DSLContext dsl, EntitySearchOptions options) {
        List<String> terms = SearchUtilities.mkTerms(lower(options.searchQuery()));
        Condition entityLifecycleCondition = MEASURABLE.ENTITY_LIFECYCLE_STATUS.in(options.entityLifecycleStatuses());

        return dsl
                .selectFrom(MEASURABLE)
                .where(JooqUtilities.MSSQL.mkContainsPrefix(terms))
                .and(entityLifecycleCondition)
                .limit(options.limit())
                .fetch(MeasurableDao.TO_DOMAIN_MAPPER);
    }

}