text:
SJ-Platform Deployment on Cluster
=====================================

.. Contents::

The section provides a detailed step-by-step instruction on Stream Juggler Platform deployment on cluster.

Currently, the deployment on **Mesos** is supported for SJ-Platform that allows running the system at scale and to support different types of workloads.

A complete list of requirements and the deployment procedure description can be found below. We will deploy and start all the services. Then you will need to add entities - providers, services, streams, modules and instances - to build a pipeline that corresponds to your aims. The steps on creating platform entities are provided in the :ref:`UI-Guide`.

Overall Deployment Infrastructure
--------------------------------------------

The Stream Juggler platform works on the base of the following services:

- Resource management is fulfilled via `Apache Mesos <http://mesos.apache.org/>`_.

- To start applicable services in the Mesos we use `Docker <http://mesos.apache.org/documentation/latest/docker-containerizer/>`_.

- `Marathon <https://mesosphere.github.io/marathon/>`_ allows running long-life tasks on Mesos.

- To perform leader election in case the currently leading Marathon instance fails `Apache Zookeeper <https://zookeeper.apache.org/>`_ is used. Zookeeper is also responsible for instance task synchronization for a Batch module.

- Data sources for the platform are `Netty <https://netty.io/>`_ and `T-streams <https://t-streams.com>`_ libraries and `Apache Kafka <https://kafka.apache.org/>`_.

- We use `MongoDB <https://www.mongodb.com/>`_ as a document database that provides high performance and availability. All created platform entities (Providers, Services, Streams, Instances, etc.), as well as configurations, are stored here.

- Elasticsearch 5.5.2, SQL database or a system which provides the RESTful interface are external storages the output data is stored to.

SJ-Platform's backend is written in Scala. The UI is based on Angular 4.0. REST API is written in Akka HTTP.

The section covers the steps on deployment of necessary services and configurations. The system is set up with no entities. You can create them depending on your aims and tasks. The steps on creating platform entities are provided in the :ref:`UI-Guide`.

Now we will perform the deployment via REST API.

.. _Mesos_deployment:

Deployment of Required Services on Mesos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the first step, deploy Mesos and other required services.

1. Deploy Mesos, Marathon, Zookeeper. You can follow the instructions in the official `instalation guide <http://www.bogotobogo.com/DevOps/DevOps_Mesos_Install.php>`_ .

   If you are planning to launch an instance with greater value of the ``parallelizm`` parameter, i.e. to run tasks on more than 1 nodes, you need to increase the ``executor_registration_timeout`` parameter for Mesos-slave.

   The requirements to Mesos-slave:

    - 2 CPUs;
    - 4096 memory;
    - Docker installed (see the official `installation guide <https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce>`_);
    - Java installed (see  the official `installation guide <https://tecadmin.net/install-oracle-java-8-ubuntu-via-ppa/>`_).

   Mesos-slave should support Docker containerizer.

   Now make sure you have access to Mesos interface, Marathon interface. Apache Zookeeper should be active.

2. Create a configuration file (config.properties) and JSON files for the physical services - MongoDB, SJ-rest, tts. Please, name them as it is specified here.

**mongo.json**

Replace <mongo_port> with the port of MongoDB. It should be one of the available Mesos-slave ports.

::

 {
   "id":"mongo",
   "container":{
      "type":"DOCKER",
      "docker":{
         "image":"mongo:3.4.7",
         "network":"BRIDGE",
         "portMappings":[
            {
               "containerPort":27017,
               "hostPort":"<mongo_port>",
               "protocol":"tcp"
            }
         ],
         "parameters":[
            {
               "key":"restart",
               "value":"always"
            }
         ]
      }
   },
   "instances":1,
   "cpus":0.1,
   "mem":512
 }

**sj-rest.json**

Please, replace:

- <slave_advertise_ip> with a valid Mesos-slave IP;
- <zk_ip> and <zk_port> with the Zookeeper address;
- <rest_port> with the port for the SJ-rest service. It should be one of the available Mesos-slave ports.
- <mongo_port> with the port of MongoDB. Use the one you specified in **mongo.json**.

::

 {
   "id":"sj-rest",
   "container":{
      "type":"DOCKER",
      "docker":{
         "image":"bwsw/sj-rest:dev",
         "network":"BRIDGE",
         "portMappings":[
            {
               "containerPort":8080,
               "hostPort":"<rest_port>",
               "protocol":"tcp"
            }
         ],
         "parameters":[
            {
               "key":"restart",
               "value":"always"
            }
         ]
      }
   },
   "instances":1,
   "cpus":0.1,
   "mem":1024,
   "env":{
      "MONGO_HOSTS":"<slave_advertise_ip>:<mongo_port>",
      "ZOOKEEPER_HOST":"<zk_ip>",
      "ZOOKEEPER_PORT":"<zk_port>"
   }
 }

For sj-rest.json it is better to upload the docker image separately::

 sudo docker pull bwsw/sj-rest:dev

**config.properties**

This is a file with configurations for the tts service (used for T-streams).

Please, replace:

- <zk_ip> according to the Zookeeper address;
- <token> and <prefix-name> with valid token and prefix (description is provided in the :ref:`T-streams-service`). These token and prefix should be specified then in the T-streams service JSON (see below).

::

 key=<token>
 active.tokens.number=100
 token.ttl=120

 host=0.0.0.0
 port=8080
 thread.pool=4

 path=/tmp
 data.directory=transaction_data
 metadata.directory=transaction_metadata
 commit.log.directory=commit_log
 commit.log.rocks.directory=commit_log_rocks

 berkeley.read.thread.pool = 2

 counter.path.file.id.gen=/server_counter/file_id_gen

 auth.key=dummy
 endpoints=127.0.0.1:31071
 name=server
 group=group

 write.thread.pool=4
 read.thread.pool=2
 ttl.add-ms=50
 create.if.missing=true
 max.background.compactions=1
 allow.os.buffer=true
 compression=LZ4_COMPRESSION
 use.fsync=true

 zk.endpoints=<zk_ip>
 zk.prefix=<prefix_name>
 zk.session.timeout-ms=10000
 zk.retry.delay-ms=500
 zk.connection.timeout-ms=10000

 max.metadata.package.size=100000000
 max.data.package.size=100000000
 transaction.cache.size=300

 commit.log.write.sync.value = 1
 commit.log.write.sync.policy = every-nth
 incomplete.commit.log.read.policy = skip-log
 commit.log.close.delay-ms = 200
 commit.log.file.ttl-sec = 86400
 stream.zookeeper.directory=/tts/tstreams

 ordered.execution.pool.size=2
 transaction-database.transaction-keeptime-min=70000
 subscribers.update.period-ms=500

Specify the same token and prefix in the T-streams service JSON::

 {
  "name": "tstream-ps-service",
  "description": "Example of T-streams service",
  "type": "service.t-streams",
  "provider": "zookeeper-ps-provider",
  "prefix": "<prefix-name>",
  "token" : "<token>"
 }

**tts.json**

This is a JSON file for T-streams. Please, replace:

- <path_to_conf_directory> with an appropriate path to the configuration file directory on your computer;
- <slave_advertise_ip> with the Mesos-slave IP;
- <tts_port> with the port for the tts service. It should be one of the available Mesos-slave ports.

::

 {
    "id": "tts",
    "container": {
        "type": "DOCKER",
        "volumes": [
            {
                "containerPath": "/etc/conf/config.properties",
                "hostPath": "<path_to_conf_directory>",
                "mode": "RO"
            }
        ],
        "docker": {
            "image": "bwsw/tstreams-transaction-server",
            "network": "BRIDGE",
            "portMappings": [
                {
                    "containerPort": 8080,
                    "hostPort": "<tts_port>",
                    "protocol": "tcp"
                }
            ],
            "parameters": [
                {
                    "key": "restart",
                    "value": "always"
                }
            ]
        }
    },
    "instances": 1,
    "cpus": 0.1,
    "mem": 512,
    "env": {
      "HOST":"<slave_advertise_ip>",
      "PORT0":"<tts_port>"
    }
 }

6. Run the services on Marathon.

Replace <marathon_address> with a valid Marathon address.

**Mongo**::

 curl -X POST http://<marathon_address>/v2/apps -H "Content-type: application/json" -d @mongo.json

**SJ-rest**::

 curl -X POST http://<marathon_address>/v2/apps -H "Content-type: application/json" -d @sj-rest.json

**tts**::

 curl -X POST http://<marathon_address>/v2/apps -H "Content-type: application/json" -d @tts.json

Via the Marathon interface make sure the services are deployed.

Now look and make sure you have access to the Web UI. You will see the platform but it is not completed with any entities yet.

In the next section we will show you how to upload modules as well as engines for them, configurations for engines and module validators.

Engine Uploading
""""""""""""""""""""""""""
Before uploading modules, upload the engine jars for them.

1. You should download the engine jars for each module types (input-streaming, regular-streaming, batch-streaming, output-streaming) and a Mesos framework::

    wget http://c1-ftp1.netpoint-dc.com/sj/1.0-SNAPSHOT/sj-input-streaming-engine.jar
    wget http://c1-ftp1.netpoint-dc.com/sj/1.0-SNAPSHOT/sj-regular-streaming-engine.jar
    wget http://c1-ftp1.netpoint-dc.com/sj/1.0-SNAPSHOT/sj-batch-streaming-engine.jar
    wget http://c1-ftp1.netpoint-dc.com/sj/1.0-SNAPSHOT/sj-output-streaming-engine.jar
    wget http://c1-ftp1.netpoint-dc.com/sj/1.0-SNAPSHOT/sj-mesos-framework.jar

   Now upload the engine jars into the platform. Please, replace <slave_advertise_ip> with the Mesos-slave IP and <rest-port> with the SJ-rest service port::

    cd sj-platform
    address=<slave_advertise_ip>:<rest-port>

    curl --form jar=@sj-mesos-framework.jar http://$address/v1/custom/jars
    curl --form jar=@sj-input-streaming-engine.jar http://$address/v1/custom/jars
    curl --form jar=@sj-regular-streaming-engine.jar http://$address/v1/custom/jars
    curl --form jar=@sj-batch-streaming-engine.jar http://$address/v1/custom/jars
    curl --form jar=@sj-output-streaming-engine.jar http://$address/v1/custom/jars

   When creating a module you should use correct name and version of the engine:

==========================  =======================================  ==============================================
Module type                 Engine name                              Engine version
==========================  =======================================  ==============================================
*Input-streaming*           com.bwsw.input.streaming.engine          1.0

*Regular-streaming*         com.bwsw.regular.streaming.engine        1.0

*Batch-streaming*           com.bwsw.batch.streaming.engine          1.0

*Output-streaming*          com.bwsw.output.streaming.engine         1.0

==========================  =======================================  ==============================================

    Specify them in the module specification JSON for ``engine-name`` and ``engine-version`` fields, for example::

     {...
     "module-type": "regular-streaming",
     "engine-name": "com.bwsw.regular.streaming.engine",
     "engine-version": "1.0",
     ...}

2. Setup configurations for engines.

   The range of configurations includes required and optional ones.

   The list of all configurations can be viewed at the :ref:`Configuration` page.

   To set up required configurations for the engines, run the following commands. Please, replace:

    - <slave_advertise_ip> with the Mesos-slave IP;
    - <marathon_address> with the address of Marathon;
    - <rest-port> with the SJ-rest service port.

   ::

    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"session-timeout\",\"value\": \"7000\",\"domain\": \"configuration.apache-zookeeper\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"current-framework\",\"value\": \"com.bwsw.fw-1.0\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"crud-rest-host\",\"value\": \"<slave_advertise_ip>\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"crud-rest-port\",\"value\": \"<rest-port>\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"marathon-connect\",\"value\": \"http://<marathon_address>\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"marathon-connect-timeout\",\"value\": \"60000\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"kafka-subscriber-timeout\",\"value\": \"100\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"low-watermark\",\"value\": \"100\",\"domain\": \"configuration.system\"}"

3. Send the next POST requests to upload configurations for module validators::

    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"input-streaming-validator-class\",\"value\": \"com.bwsw.sj.crud.rest.instance.validator.InputInstanceValidator\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"regular-streaming-validator-class\",\"value\": \"com.bwsw.sj.crud.rest.instance.validator.RegularInstanceValidator\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"batch-streaming-validator-class\",\"value\": \"com.bwsw.sj.crud.rest.instance.validator.BatchInstanceValidator\",\"domain\": \"configuration.system\"}"
    curl --request POST "http://$address/v1/config/settings" -H 'Content-Type: application/json' --data "{\"name\": \"output-streaming-validator-class\",\"value\": \"com.bwsw.sj.crud.rest.instance.validator.OutputInstanceValidator\",\"domain\": \"configuration.system\"}"

4. You can add the following optional configuraions if necessary. They have default values in the system but can be overriden. Find the full list of optional configurations at the :ref:`table-optional` table.

Creating Platform Entities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Under this section you will find the information on platform entities creation.

We will not provide you with specific instructions as this part is custom and the set of platform entities you need for your tasks may differ. Step-by-step instructions on creating platform entities are provided in the :ref:`fping-example-task` section.

The following entities should be uploaded or created in the system:

1) Modules - input-streaming, regular-streaming or batch-streaming, output-streaming types;
2) Providers;
3) Services;
4) Streams;
5) Instances for each module types.

Modules
""""""""""

You should create your own modules. Please, use instructions on module creation at :ref:`Custom_Module`.

Then upload modules following the instruction in :ref:`Module_Uploading` of the Tutorial. Use REST API requests to  upload each module (see :ref:`Modules_REST_API`). Replace <module_jar_name> with the name of the module JAR file::

 curl --form jar=@<module_jar_name>.jar http://$address/v1/modules

Or module uploading can be performed via the UI (see :ref:`UI_Modules`).

Providers
""""""""""
Providers are a part of the streaming infrastructure. They can be created using REST API (replace <provider_name> with the name of the provider JSON file)::

 curl --request POST "http://$address/v1/providers" -H 'Content-Type: application/json' --data "@api-json/providers/<provider_name>.json"

For more details see :ref:`REST_Providers`.

Or providers can be created via the UI (see :ref:`UI_Providers`).

Services
""""""""""
Services are a part of the streaming infrastructure. They can be created using REST API (replace <service_name> with the name of the service JSON file)::

 curl --request POST "http://$address/v1/services" -H 'Content-Type: application/json' --data "@api-json/services/<service_name>.json"

For more details see :ref:`REST_Services`.

Or services can be created via the UI (see :ref:`UI_Services`).

Streams
""""""""""
Streams provide data exchange between modules. They can be created using REST API (replace <stream_name> with the name of the stream JSON file)::

 curl --request POST "http://$address/v1/streams" -H 'Content-Type: application/json' --data "@api-json/streams/<stream_name>.json"

For more details see :ref:`REST_Streams`.

Or streams can be created via the UI (see :ref:`UI_Streams`).

Instances
""""""""""

Instances are used with engines to determine their collaborative work with modules. Each module needs an individual instance for it. Its type corresponds to the module type (input-streaming, regular-streaming or batch-streaming, output-streaming).

Instances can be created using REST API (replace <instance_name> with the name of the instance JSON file)::

 curl --request POST "http://$address/v1/modules/input-streaming/pingstation-input/1.0/instance" -H 'Content-Type: application/json' --data "@api-json/instances/<instance_name>.json"

For more details see :ref:`REST_API_Instance`.

Or instances can be created via the UI (see :ref:`UI_Instances`).

To start processing you should launch instances one by one.


text:
package edu.uah.rsesc.aadlsimulator;

import org.osate.aadl2.instance.SystemInstance;

import edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.InputConstraint;

public interface SimulationEngine {
	/**
	 * Called by the simulation service to release resources owned by the simulation engine. Should only be called by the owner of the simulation engine.
	 * Under most circumstances this is the simulation service.
	 * Methods should not be called after a simulation engine is disposed.
	 */
	void dispose();

	/**
	 * Creates a copy of the simulation engine which is owned by the caller.
	 * The copy is expected to share constants, state elements, and property objects.
	 * The new simulation engine must retain the same state as this simulation engine.
	 * The new simulation engine will be detached from the simulation service and must be disposed() by the owner.
	 * The simulation engine will not have any event listeners registered.
	 * @return the new simulation engine
	 */
	SimulationEngine fork();

	/**
	 * Returns a reference to the component instance being simulated.
	 * @return
	 */
	SystemInstance getSystemInstance();

	/**
	 * Returns a description of the type of simulation the engine is executing.
	 * @return
	 */
	String getSimulationType();

	void stepForward();
	void stepBackward();

	/**
	 * Queues a requests that the simulation engine notify the specified handler when it reaches that point in the simulation. The notification handler will be called in the simulation thread
	 * so the simulation will not continue until the notification handler returns. The simulation engine will notify event listeners of a state change once the notification handler has returned.
	 * @param handler
	 */
	void queueNotification(NotificationHandler handler);
	void clearPendingCommands();

	void addEventListener(final SimulationEngineEventListener listener);
	void removeEventListener(final SimulationEngineEventListener listener);

	SimulationEngineState getCurrentState();

	/**
	 * Sets the input constraint used to constrain the value of the element for the next frame.
	 * @param element
	 * @param constraint may be null.
	 */
	void setInputConstraint(final Object element, final InputConstraint constraint);

	/**
	 * Resets input constraints while will be used for subsequent frames
	 */
	void resetInputConstraints();
}

redpajama_set_name: RedPajamaGithub


text:
package store

import (
	"strconv"
	"strings"

	"github.com/mattermost/platform/model"
)

type SqlComplianceStore struct {
	SqlStore
}

func NewSqlComplianceStore(sqlStore SqlStore) ComplianceStore {
	s := &SqlComplianceStore{sqlStore}

	for _, db := range sqlStore.GetAllConns() {
		table := db.AddTableWithName(model.Compliance{}, "Compliances").SetKeys(false, "Id")
		table.ColMap("Id").SetMaxSize(26)
		table.ColMap("UserId").SetMaxSize(26)
		table.ColMap("Status").SetMaxSize(64)
		table.ColMap("Desc").SetMaxSize(512)
		table.ColMap("Type").SetMaxSize(64)
		table.ColMap("Keywords").SetMaxSize(512)
		table.ColMap("Emails").SetMaxSize(1024)
	}

	return s
}

func (s SqlComplianceStore) CreateIndexesIfNotExists() {
}

func (s SqlComplianceStore) Save(compliance *model.Compliance) StoreChannel {

	storeChannel := make(StoreChannel, 1)

	go func() {
		result := StoreResult{}

		compliance.PreSave()
		if result.Err = compliance.IsValid(); result.Err != nil {
			storeChannel <- result
			close(storeChannel)
			return
		}

		if err := s.GetMaster().Insert(compliance); err != nil {
			result.Err = model.NewLocAppError("SqlComplianceStore.Save", "store.sql_compliance.save.saving.app_error", nil, err.Error())
		} else {
			result.Data = compliance
		}

		storeChannel <- result
		close(storeChannel)
	}()

	return storeChannel
}

func (us SqlComplianceStore) Update(compliance *model.Compliance) StoreChannel {

	storeChannel := make(StoreChannel, 1)

	go func() {
		result := StoreResult{}

		if result.Err = compliance.IsValid(); result.Err != nil {
			storeChannel <- result
			close(storeChannel)
			return
		}

		if _, err := us.GetMaster().Update(compliance); err != nil {
			result.Err = model.NewLocAppError("SqlComplianceStore.Update", "store.sql_compliance.save.saving.app_error", nil, err.Error())
		} else {
			result.Data = compliance
		}

		storeChannel <- result
		close(storeChannel)
	}()

	return storeChannel
}

func (s SqlComplianceStore) GetAll(offset, limit int) StoreChannel {

	storeChannel := make(StoreChannel, 1)

	go func() {
		result := StoreResult{}

		query := "SELECT * FROM Compliances ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset"

		var compliances model.Compliances
		if _, err := s.GetReplica().Select(&compliances, query, map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil {
			result.Err = model.NewLocAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, err.Error())
		} else {
			result.Data = compliances
		}

		storeChannel <- result
		close(storeChannel)
	}()

	return storeChannel
}

func (us SqlComplianceStore) Get(id string) StoreChannel {

	storeChannel := make(StoreChannel, 1)

	go func() {
		result := StoreResult{}

		if obj, err := us.GetReplica().Get(model.Compliance{}, id); err != nil {
			result.Err = model.NewLocAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, err.Error())
		} else if obj == nil {
			result.Err = model.NewLocAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, err.Error())
		} else {
			result.Data = obj.(*model.Compliance)
		}

		storeChannel <- result
		close(storeChannel)

	}()

	return storeChannel
}

func (s SqlComplianceStore) ComplianceExport(job *model.Compliance) StoreChannel {
	storeChannel := make(StoreChannel, 1)

	go func() {
		result := StoreResult{}

		props := map[string]interface{}{"StartTime": job.StartAt, "EndTime": job.EndAt}

		keywordQuery := ""
		keywords := strings.Fields(strings.TrimSpace(strings.ToLower(strings.Replace(job.Keywords, ",", " ", -1))))
		if len(keywords) > 0 {

			keywordQuery = "AND ("

			for index, keyword := range keywords {
				if index >= 1 {
					keywordQuery += " OR LOWER(Posts.Message) LIKE :Keyword" + strconv.Itoa(index)
				} else {
					keywordQuery += "LOWER(Posts.Message) LIKE :Keyword" + strconv.Itoa(index)
				}

				props["Keyword"+strconv.Itoa(index)] = "%" + keyword + "%"
			}

			keywordQuery += ")"
		}

		emailQuery := ""
		emails := strings.Fields(strings.TrimSpace(strings.ToLower(strings.Replace(job.Emails, ",", " ", -1))))
		if len(emails) > 0 {

			emailQuery = "AND ("

			for index, email := range emails {
				if index >= 1 {
					emailQuery += " OR Users.Email = :Email" + strconv.Itoa(index)
				} else {
					emailQuery += "Users.Email = :Email" + strconv.Itoa(index)
				}

				props["Email"+strconv.Itoa(index)] = email
			}

			emailQuery += ")"
		}

		query :=
			`SELECT
			    Teams.Name AS TeamName,
			    Teams.DisplayName AS TeamDisplayName,
			    Channels.Name AS ChannelName,
			    Channels.DisplayName AS ChannelDisplayName,
			    Users.Username AS UserUsername,
			    Users.Email AS UserEmail,
			    Users.Nickname AS UserNickname,
			    Posts.Id AS PostId,
			    Posts.CreateAt AS PostCreateAt,
			    Posts.UpdateAt AS PostUpdateAt,
			    Posts.DeleteAt AS PostDeleteAt,
			    Posts.RootId AS PostRootId,
			    Posts.ParentId AS PostParentId,
			    Posts.OriginalId AS PostOriginalId,
			    Posts.Message AS PostMessage,
			    Posts.Type AS PostType,
			    Posts.Props AS PostProps,
			    Posts.Hashtags AS PostHashtags,
			    Posts.FileIds AS PostFileIds
			FROM
			    Teams,
			    Channels,
			    Users,
			    Posts
			WHERE
			    Teams.Id = Channels.TeamId
			        AND Posts.ChannelId = Channels.Id
			        AND Posts.UserId = Users.Id
			        AND Posts.CreateAt > :StartTime
			        AND Posts.CreateAt <= :EndTime
			        ` + emailQuery + `
			        ` + keywordQuery + `
			ORDER BY Posts.CreateAt
			LIMIT 30000`

		var cposts []*model.CompliancePost

		if _, err := s.GetReplica().Select(&cposts, query, props); err != nil {
			result.Err = model.NewLocAppError("SqlPostStore.ComplianceExport", "store.sql_post.compliance_export.app_error", nil, err.Error())
		} else {
			result.Data = cposts
		}

		storeChannel <- result
		close(storeChannel)
	}()

	return storeChannel
}


text:
from search.utils import logUtils
from search.datasource import session, amqp_client

def get_class( kls ):
    '''
    Given a fully qualified class name will return the class so that it can be instantiated.
    '''
    parts = kls.split('.')
    module = ".".join(parts[:-1])
    m = __import__( module )
    for comp in parts[1:]:
        m = getattr(m, comp)
    return m

def run(config, section_name):
    import eventlet
    # Apply monkey_patch at the earliest
    eventlet.monkey_patch(thread=False)
    '''
    Sets up logging for the entire process and then starts the corresponding handler.
    - config : Configuration of the application.
    - section_name : Name of the section in the config.
    '''
    logUtils.setup_logging(config)
    logger = logUtils.get_logger(__name__)
    solr_url = config['DEFAULT']['solr_url']
    db_info = session.DBInfo(config['DEFAULT']['nova_db_server'], config['DEFAULT']['nova_db_port'], config['DEFAULT']['nova_db_creds'])
    amqp_info = amqp_client.AmqpInfo(config['DEFAULT']['amqp_server'], config['DEFAULT']['amqp_port'], config['DEFAULT']['amqp_creds'])

    # pull out name of the handler for the specific core
    section = config[section_name]
    handlerName = section["handlerName"]
    interval = int(section["interval"])

    try :
        # instantiate the handler
        handlerKls = get_class(handlerName)
        handler = handlerKls(solr_url, db_info, amqp_info, interval)
        logger.info(str(handler) + ' instantiated to perform work.')
        # handler is expected to have an on_start & setup_amqp() method to do the real work.
        # run on_start on a green thread.
        eventlet.spawn_n(handler.on_start)
        # call setup_amqp on the main thread so that it keeps the main thread busy.
        handler.setup_amqp()
        return handler
    except Exception as inst:
        logger.exception(inst)


text:
package org.iotp.server.service.security.auth.jwt;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.iotp.server.service.security.auth.JwtAuthenticationToken;
import org.iotp.server.service.security.auth.jwt.extractor.TokenExtractor;
import org.iotp.server.service.security.model.token.RawAccessJwtToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.util.matcher.RequestMatcher;

public class JwtTokenAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter {
  private final AuthenticationFailureHandler failureHandler;
  private final TokenExtractor tokenExtractor;

  @Autowired
  public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler,
      TokenExtractor tokenExtractor, RequestMatcher matcher) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
  }

  @Override
  public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
      throws AuthenticationException, IOException, ServletException {
    RawAccessJwtToken token = new RawAccessJwtToken(tokenExtractor.extract(request));
    return getAuthenticationManager().authenticate(new JwtAuthenticationToken(token));
  }

  @Override
  protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
      Authentication authResult) throws IOException, ServletException {
    SecurityContext context = SecurityContextHolder.createEmptyContext();
    context.setAuthentication(authResult);
    SecurityContextHolder.setContext(context);
    chain.doFilter(request, response);
  }

  @Override
  protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
      AuthenticationException failed) throws IOException, ServletException {
    SecurityContextHolder.clearContext();
    failureHandler.onAuthenticationFailure(request, response, failed);
  }
}


text:
require 'mida/vocabulary'

module Mida
  module SchemaOrg

    autoload :Thing, 'mida/vocabularies/schemaorg/thing'
    autoload :Organization, 'mida/vocabularies/schemaorg/organization'

    # A theater group or company - for example, the Royal Shakespeare Company or Druid Theatre.
    class TheaterGroup < Mida::Vocabulary
      itemtype %r{http://schema.org/TheaterGroup}i
      include_vocabulary Mida::SchemaOrg::Thing
      include_vocabulary Mida::SchemaOrg::Organization
    end

  end
end


text:
package iso20022

// Value given to a price.
type PriceValue5 struct {

	// Price expressed as a currency and value.
	Amount *ActiveOrHistoricCurrencyAnd13DecimalAmount `xml:"Amt"`
}

func (p *PriceValue5) SetAmount(value, currency string) {
	p.Amount = NewActiveOrHistoricCurrencyAnd13DecimalAmount(value, currency)
}


text:
/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.aurora.scheduler.discovery;

import java.net.InetSocketAddress;
import java.util.List;
import java.util.function.Predicate;

import javax.inject.Singleton;

import com.google.common.base.Joiner;
import com.google.common.collect.FluentIterable;
import com.google.inject.Exposed;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;

import org.apache.aurora.common.application.ShutdownRegistry;
import org.apache.aurora.common.base.MorePreconditions;
import org.apache.aurora.common.io.Codec;
import org.apache.aurora.common.net.InetSocketAddressHelper;
import org.apache.aurora.common.quantity.Amount;
import org.apache.aurora.common.quantity.Time;
import org.apache.aurora.common.thrift.ServiceInstance;
import org.apache.aurora.common.zookeeper.Credentials;
import org.apache.aurora.common.zookeeper.ServerSet;
import org.apache.aurora.common.zookeeper.SingletonService;
import org.apache.aurora.scheduler.app.ServiceGroupMonitor;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.ACLProvider;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.retry.BoundedExponentialBackoffRetry;
import org.apache.curator.utils.PathUtils;
import org.apache.zookeeper.data.ACL;

import static java.util.Objects.requireNonNull;

/**
 * Binding module for utilities to advertise the network presence of the scheduler.
 *
 * Uses Apache Curator.
 */
class CuratorServiceDiscoveryModule extends PrivateModule {

  private final String discoveryPath;
  private final ZooKeeperConfig zooKeeperConfig;

  CuratorServiceDiscoveryModule(String discoveryPath, ZooKeeperConfig zooKeeperConfig) {
    this.discoveryPath = PathUtils.validatePath(discoveryPath);
    this.zooKeeperConfig = requireNonNull(zooKeeperConfig);
  }

  @Override
  protected void configure() {
    requireBinding(ServiceDiscoveryBindings.ZOO_KEEPER_CLUSTER_KEY);
    requireBinding(ServiceDiscoveryBindings.ZOO_KEEPER_ACL_KEY);

    bind(new TypeLiteral<Codec<ServiceInstance>>() { }).toInstance(ServerSet.JSON_CODEC);
  }

  @Provides
  @Singleton
  CuratorFramework provideCuratorFramework(
      ShutdownRegistry shutdownRegistry,
      @ServiceDiscoveryBindings.ZooKeeper Iterable<InetSocketAddress> zooKeeperCluster,
      ACLProvider aclProvider) {

    String connectString =
        FluentIterable.from(zooKeeperCluster)
            .transform(InetSocketAddressHelper::toString)
            .join(Joiner.on(','));

    if (zooKeeperConfig.getChrootPath().isPresent()) {
      connectString = connectString + zooKeeperConfig.getChrootPath().get();
    }

    // This emulates the default BackoffHelper configuration used by the legacy commons/zookeeper
    // stack. BackoffHelper is unbounded, this dies after around 5 minutes using the 10 retries.
    // NB: BoundedExponentialBackoffRetry caps max retries at 29 if you send it a larger value.
    RetryPolicy retryPolicy =
        new BoundedExponentialBackoffRetry(
            Amount.of(1, Time.SECONDS).as(Time.MILLISECONDS),
            Amount.of(1, Time.MINUTES).as(Time.MILLISECONDS),
            10);

    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .dontUseContainerParents() // Container nodes are only available in ZK 3.5+.
        .connectString(connectString)
        .canBeReadOnly(false) // We must be able to write to perform leader election.
        .sessionTimeoutMs(zooKeeperConfig.getSessionTimeout().as(Time.MILLISECONDS))
        .retryPolicy(retryPolicy)
        .aclProvider(aclProvider);

    if (zooKeeperConfig.getCredentials().isPresent()) {
      Credentials credentials = zooKeeperConfig.getCredentials().get();
      builder.authorization(credentials.scheme(), credentials.authToken());
    }

    CuratorFramework curatorFramework = builder.build();

    // TODO(John Sirois): It would be nice to use a Service to control the lifecycle here, but other
    // services (org.apache.aurora.scheduler.http.JettyServerModule.RedirectMonitor) rely on this
    // service being started 1st which is not deterministic as things stand.  Find a way to leverage
    // the Service system for services with Service dependencies.
    curatorFramework.start();
    shutdownRegistry.addAction(curatorFramework::close);

    return curatorFramework;
  }

  static class SingleACLProvider implements ACLProvider {
    private final List<ACL> acl;

    SingleACLProvider(List<ACL> acl) {
      this.acl = MorePreconditions.checkNotBlank(acl);
    }

    @Override
    public List<ACL> getDefaultAcl() {
      return acl;
    }

    @Override
    public List<ACL> getAclForPath(String path) {
      return acl;
    }
  }

  @Provides
  @Singleton
  ACLProvider provideACLProvider(@ServiceDiscoveryBindings.ZooKeeper List<ACL> acl) {
    return new SingleACLProvider(acl);
  }

  // These values are compatible with the Java and Python common/zookeeper service discovery
  // protocol. If GUID protection is enabled for Curator, the MEMBER_SELECTOR will need to be
  // modified to handle GUID prefixes of MEMBER_TOKEN.
  private static final String MEMBER_TOKEN = "member_";
  private static final Predicate<String> MEMBER_SELECTOR = name -> name.startsWith(MEMBER_TOKEN);

  @Provides
  @Singleton
  @Exposed
  ServiceGroupMonitor provideServiceGroupMonitor(
      CuratorFramework client,
      Codec<ServiceInstance> codec) {

    PathChildrenCache groupCache =
        new PathChildrenCache(client, discoveryPath, true /* cacheData */);
    return new CuratorServiceGroupMonitor(groupCache, MEMBER_SELECTOR, codec);
  }

  @Provides
  @Singleton
  @Exposed
  SingletonService provideSingletonService(CuratorFramework client, Codec<ServiceInstance> codec) {
    return new CuratorSingletonService(client, discoveryPath, MEMBER_TOKEN, codec);
  }
}


text:
<?php

namespace Office365\Runtime\Auth;

class ClientCredential
{

    /**
     * @param string $clientId
     * @param string $clientSecret
     */
    public function __construct($clientId, $clientSecret)
    {
        $this->ClientId = $clientId;
        $this->ClientSecret = $clientSecret;
    }

    /**
     * @var string $ClientId
     */
    public $ClientId;

    /**
     * @var string $ClientSecret
     */
    public $ClientSecret;

}


text:
(function() {
  $(function() {
    $('#input').linenumbers({
      col_width: '50px'
    });
    ({
      createMessage: function(title, message) {
        var div, messageHeight;
        div = $(document.createElement('div')).addClass('error message').append("
" + title + "
").append("
" + message + "
");
        $('body').append(div);
        messageHeight = div.outerHeight();
        div.css('top', "-" + messageHeight);
        div.click(removeMessages);
        return div.animate({
          top: '0'
        }, 500);
      }
    });
    return $('.go-button button').on('click', (function(_this) {
      return function() {
        var button;
        button = $(_this);
        button.text("Wait a second...");
        return $.ajax({
          url: '/api/processor',
          data: {
            css: $('#input').val()
          },
          dataType: 'json',
          type: 'POST',
          removeMessages: function() {
            return $(".message").animate({
              top: -500
            }, 300, function() {
              return $(this).remove();
            });
          },
          createMessage: function(title, message) {
            var div, messageHeight;
            div = $(document.createElement('div')).addClass('error message').append("
" + title + "
").append("
" + message + "
");
            $('body').append(div);
            messageHeight = div.outerHeight();
            div.css('top', "-" + messageHeight + "px");
            div.click(this.removeMessages);
            return div.animate({
              top: '0'
            }, 300);
          },
          success: function(data) {
            if (data.status === 'success') {
              this.removeMessages();
              $("#output").text(data.result);
            } else {
              this.removeMessages();
              this.createMessage('Whoa there!', "An error ocurred while prefixing your css: " + data.result);
            }
            return button.text("Prefix it!");
          },
          error: function() {
            this.removeMessages();
            this.createMessage('Oops!', 'Error prefixing your code. Try again.');
            return button.text("Prefix it!");
          }
        });
      };
    })(this));
  });

}).call(this);


text:
=====
Usage
=====

To use gus_analysis_code in a project::

	import gus_analysis_code


text:
=======
Credits
=======

Development Lead
----------------

* the01 <jungflor@gmail.com>

Contributors
------------

None yet.


text:
package marcin_szyszka.mobileseconndhand.activities;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.support.v7.app.AppCompatActivity;

import android.os.AsyncTask;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import marcin_szyszka.mobileseconndhand.R;
import marcin_szyszka.mobileseconndhand.common.IJsonObjectReceiveDelegate;
import marcin_szyszka.mobileseconndhand.models.ErrorResponse;
import marcin_szyszka.mobileseconndhand.models.LoginModel;
import marcin_szyszka.mobileseconndhand.models.TokenModel;
import marcin_szyszka.mobileseconndhand.services.SignInService;

/**
 * A login screen that offers login via email/password.
 */
public class LoginActivity extends AppCompatActivity implements IJsonObjectReceiveDelegate {

    // UI references.
    private EditText mEmailTextView;
    private EditText mPasswordTextView;
    private View mProgressBar;
    private View focusView;
    private CallbackManager callbackManager;
    private AccessToken accessToken;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        callbackManager = CallbackManager.Factory.create();
        setContentView(R.layout.activity_login);

        mEmailTextView = (EditText) findViewById(R.id.inputEmail);
        mPasswordTextView = (EditText) findViewById(R.id.inputPassword);
        mProgressBar = findViewById(R.id.progressBar);

        mProgressBar.setVisibility(View.INVISIBLE);

        Button mEmailSignInButton = (Button) findViewById(R.id.loginFormSubmit);
        mEmailSignInButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                attemptLogin();
            }
        });

        Button mLoginRegisterButton = (Button) findViewById(R.id.login_register_button);
        mLoginRegisterButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                goToRegister();
            }
        });

        LoginButton loginButton = (LoginButton) findViewById(R.id.login_facebook_button);
        loginButton.setReadPermissions("public_profile", "email");
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                accessToken = loginResult.getAccessToken();
                if (accessToken != null) {
                    ShowMessage("OK");
                    loginWithFacebook();
                } else {
                    ShowMessage("Token pusty");
                }
            }

            @Override
            public void onCancel() {
                ShowMessage("Przerwano");
            }

            @Override
            public void onError(FacebookException exception) {
                ShowMessage("Błąd: " + exception.getMessage());
            }
        });
    }

    private void loginWithFacebook() {
        SignInService.getInstance().checkIsUserLogged(getBaseContext(), this);
    }

    private void goToRegister() {
        Intent registerActivity = new Intent(this, RegisterUserActivity.class);
        startActivity(registerActivity);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setContentView(R.layout.activity_login);
        TextView text = (TextView) findViewById(R.id.otherFacebookInfo);
        if (newConfig.screenHeightDp > 350) {
            text.setVisibility(View.VISIBLE);
        } else {
            text.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }

    private void ShowMessage(String message) {
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    }

    /**
     * Attempts to sign in or register the account specified by the login form.
     * If there are form errors (invalid email, missing fields, etc.), the
     * errors are presented and no actual login attempt is made.
     */
    private void attemptLogin() {
        boolean loginFormIsValid = validateRegisterForm();

        if (!loginFormIsValid) {
            focusView.requestFocus();
        } else {
            mProgressBar.setVisibility(View.VISIBLE);
            String email = mEmailTextView.getText().toString();
            String password = mPasswordTextView.getText().toString();
            LoginModel loginModel = new LoginModel();
            loginModel.Email = email;
            loginModel.Password = password;

            try {
                SignInService.getInstance().loginUser(this, loginModel, getBaseContext(), this);
            } catch (Exception exc) {
                String message = exc.getMessage();
            }
        }
    }

    private boolean validateRegisterForm() {
        String email = mEmailTextView.getText().toString();
        String password = mPasswordTextView.getText().toString();

        if (TextUtils.isEmpty(email)) {
            mEmailTextView.setError(getString(R.string.error_field_required));
            focusView = mEmailTextView;
            return false;
        } else if (!isEmailValid(email)) {
            mEmailTextView.setError(getString(R.string.error_invalid_email));
            focusView = mEmailTextView;
            return false;
        } else if (TextUtils.isEmpty(password)) {
            mPasswordTextView.setError(getString(R.string.error_field_required));
            focusView = mPasswordTextView;
            return false;
        } else if (!isPasswordValid(password)) {
            mPasswordTextView.setError(getString(R.string.error_invalid_password));
            focusView = mPasswordTextView;
            return false;
        } else {
            return true;
        }
    }

    private boolean isEmailValid(String email) {
        Matcher matcher = Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE).matcher(email);
        return matcher.find();
    }

    private boolean isPasswordValid(String password) {
        if (password.length() < 6) return false;
        Matcher bigCaseMatcher = Pattern.compile("[A-Z]+").matcher(password);
        Matcher digitMatcher = Pattern.compile("\\d+").matcher(password);
        Matcher nonLetterOrDigitMatcher = Pattern.compile("\\W+").matcher(password);
        if (!bigCaseMatcher.find()) return false;
        if (!digitMatcher.find()) return false;
        if (!nonLetterOrDigitMatcher.find()) return false;

        return true;
    }

    @Override
    public void onDataReceived(int statusCode, JSONObject response) {
        mProgressBar.setVisibility(View.INVISIBLE);
        if (statusCode == 200) {
            TokenModel tokenModel = new Gson().fromJson(response.toString(), TokenModel.class);

            SharedPreferences preferences = this.getBaseContext().getSharedPreferences(getString(R.string.app_shared_preferences), Context.MODE_PRIVATE);
            SharedPreferences.Editor editor  = preferences.edit();
            editor.putString(getString(R.string.authentication_token), tokenModel.Token);
            editor.commit();

            Toast.makeText(this, "Token jest ok", Toast.LENGTH_LONG).show();
            this.finish();
            Intent mainActivity = new Intent(this, MainActivity.class);
            startActivity(mainActivity);
        } else {
            if (response != null) {
                ErrorResponse errorResponse = new Gson().fromJson(response.toString(), ErrorResponse.class);
                String errorMessage = errorResponse != null ? errorResponse.ErrorMessage : "Wystąpił błąd";
                Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
            }
            else{
                Toast.makeText(this, "Wystąił nieoczekiwany błąd", Toast.LENGTH_LONG).show();
            }
        }
    }

    @Override
    public void onDataReceived(int statusCode, JSONArray response) {

    }

}


text:
int main()
{
   return boost::has_nothrow_copy<incomplete_type>::value;
}


text:
/* jshint -W097 */
/* jshint node:true */

'use strict';

var request = require('request');

module.exports = function(grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);

    // load all grunt tasks
    require('load-grunt-tasks')(grunt, {
        pattern: ['grunt-*']
    });

    // Live relead port for watch.
    var reloadPort = 35729,
        files;

    grunt.initConfig({
        watch: {
            files: [
                '<%= jshint.files %>',
                'src/**/*.js',
                'specs/**/*.js'
            ],
            tasks: ['jshint', 'jasmine_node'],

            server: {
                files: ['<%= jshint.files %>']
            }
        },

        shell: {
            pkg: {
                command: './package.sh'
            },
            createCerts: {
                command: 'cd certs; ./create.sh; cd ..'
            },
            removeCerts: {
                command: 'cd certs; ./remove.sh; cd ..'
            },
            install: {
                command: 'npm install; bower install'
            },
            start: {
                command: 'npm start'
            }
        },

        jasmine_node: {
            src: 'src/**/*.js',
            spacNameMatcher: 'test',
            projectRoot: '.',
            requirejs: false,
            forceExit: true,
            verbose: false,
            jUnit: {
                report: false,
                savePath: 'reports/jasmine/',
                useDotNotation: true,
                consolidate: true
            }
        },

        jshint: {
            files: [
                'Gruntfile.js',
                'src/**/*.js',
                '!release/**',
                '!node_modules/**/*.js',
                'specs/**/*Spec.js'
            ],
            options: {
                curly: true,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                undef: true,
                boss: true,
                eqnull: true,
                browser: true
            }
        }
    });

    grunt.config.requires('watch.server.files');
    files = grunt.config('watch.server.files');
    files = grunt.file.expand(files);

    // Live reload for watch task.
    grunt.registerTask('delayed-livereload', 'Live reload after the node server has restarted.', function() {
        var done = this.async();
        setTimeout(function() {
            request.get('http://localhost:' + reloadPort + '/changed?files=' + files.join(','), function(err, res) {
                var reloaded = !err && res.statusCode === 200;
                if (reloaded) {
                    grunt.log.ok('Delayed live reload successful.');
                } else {
                    grunt.log.error('Unable to make a delayed live reload.');
                }
                done(reloaded);
            });
        }, 500);
    });

    // Register the tasks.
    grunt.loadNpmTasks('grunt-jasmine-node');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-notify');

    // Default tasks, runs testing harness.
    grunt.registerTask('default', ['jshint', 'jasmine_node']);

    // Utility tasks.
    grunt.registerTask('pkg', ['shell:pkg']);
    grunt.registerTask('start', ['shell:start']);
    grunt.registerTask('install', ['shell:install']);
    grunt.registerTask('createCerts', ['shell:createCerts']);
    grunt.registerTask('removeCerts', ['shell:removeCerts']);
};


text:
title: "Post: Image (with Link)"
layout: singlepost
categories:
  - Portfolio
tags:
  - image
  - Post Formats
gallery:
  - url: unsplash-gallery-image-1.jpg
    image_path: unsplash-gallery-image-1-th.jpg
    alt: "placeholder image 1"
    title: "Image 1 title caption"
  - url: unsplash-gallery-image-2.jpg
    image_path: unsplash-gallery-image-2-th.jpg
    alt: "placeholder image 2"
    title: "Image 2 title caption"
  - url: unsplash-gallery-image-3.jpg
    image_path: unsplash-gallery-image-3-th.jpg
    alt: "placeholder image 3"
    title: "Image 3 title caption"
  - url: unsplash-gallery-image-1.jpg
    image_path: unsplash-gallery-image-1-th.jpg
    alt: "placeholder image 4"
    title: "Image 4 title caption"
  - url: unsplash-gallery-image-2.jpg
    image_path: unsplash-gallery-image-2-th.jpg
    alt: "placeholder image 5"
    title: "Image 5 title caption"
  - url: unsplash-gallery-image-3.jpg
    image_path: unsplash-gallery-image-3-th.jpg
    alt: "placeholder image 6"
    title: "Image 6 title caption"
gallery3:
  - image_path: unsplash-gallery-image-2-th.jpg
    alt: "placeholder image 2"
  - image_path: unsplash-gallery-image-4-th.jpg
    alt: "placeholder image 4"
---

[![foo](https://farm5.staticflickr.com/4073/4939853213_33ffc0290b_b.jpg)](https://flic.kr/p/8ww3fZ)

{% include gallery id="gallery" caption="This is a second gallery example with images hosted externally." %}

And for giggles one more gallery just to make sure this works. To fill page content container add `class="full"`.

{% include gallery id="gallery3" class="full" caption="This is a third gallery example with two images and fills the entire content container." %}