text:
title: Storage Engine

menu:
  influxdb_011:
    weight: 90
    parent: concepts
---

The 0.9 line of InfluxDB used BoltDB as the underlying storage engine.
This writeup is about the experimental version of the Time Structured Merge Tree storage engine that was released in 0.9.5.
There may be small discrepancies between the current implementation of TSM and this document.

See the blog post announcement about the storage engine here.

## The new InfluxDB storage engine: from LSM Tree to B+Tree and back again to create the Time Structured Merge Tree

The properties of the time series data use case make it challenging for many existing storage engines.
Over the course of InfluxDB's development we've tried a few of the more popular options.
We started with LevelDB, an engine based on LSM Trees, which are optimized for write throughput.
After that we tried BoltDB, an engine based on a memory mapped B+Tree, which is optimized for reads.
Finally, we ended up building our own storage engine that is similar in many ways to LSM Trees.

With our new storage engine we were able to achieve up to a 45x reduction in disk space usage from our B+Tree setup with even greater write throughput and compression than what we saw with LevelDB and its variants.
Using batched writes, we were able to insert more than 300,000 points per second on a c3.8xlarge instance in AWS.
This post will cover the details of that evolution and end with an in-depth look at our new storage engine and its inner workings.

### Properties of Time Series Data

The workload of time series data is quite different from normal database workloads.
There are a number of factors that conspire to make it very difficult to get it to scale and perform well:

* Billions of individual data points
* High write throughput
* High read throughput
* Large deletes to free up disk space
* Mostly an insert/append workload, very few updates

The first and most obvious problem is one of scale.
In DevOps, for instance, you can collect hundreds of millions or billions of unique data points every day.

To prove out the numbers, let's say we have 200 VMs or servers running, with each server collecting an average of 100 measurements every 10 seconds.
Given there are 86,400 seconds in a day, a single measurement will generate 8,640 points in a day, per server.
That gives us a total of 200 * 100 * 8,640 = 172,800,000 individual data points per day.
We find similar or larger numbers in sensor data use cases.

The volume of data means that the write throughput can be very high.
We regularly get requests for setups than can handle hundreds of thousands of writes per second.
I've talked to some larger companies that will only consider systems that can handle millions of writes per second.

At the same time, time series data can be a high read throughput use case.
It's true that if you're tracking 700,000 unique metrics or time series, you can't hope to visualize all of them, which is what leads many people to think that you don't actually read most of the data that goes into the database.
However, other than dashboards that people have up on their screens, there are automated systems for monitoring or combining the large volume of time series data with other types of data.

Inside InfluxDB, we have aggregates that can get calculated on the fly that can combine tens of thousands of time series into a single view.
Each one of those queries does a read on each data point, which means that for InfluxDB, the read throughput is often many times higher than the write throughput.

Given that time series is a mostly an append only workload, you might think that it's possible to get great performance on a B+Tree.
Appends in the keyspace are efficient and you can achieve greater than 100,000 per second.
However, we have those appends happening in individual time series.
So the inserts end up looking more like random inserts than append only inserts.

One of the biggest problems we found with time series data is that it's very common to delete all data after it gets past a certain age.
The common pattern here is that you'll have high precision data that is kept for a short period of time like a few hours or a few weeks.
You'll then downsample and aggregate that data into lower precision, which you'll keep around for much longer.

The naive implementation would be to simply delete each record once it gets past its expiration time.
However, that means that once you're up to your window of retention, you'll be doing just as many deletes as you do writes, which is something most storage engines aren't designed for.

Let's dig into the details of the two types of storage engines we tried and how these properties had a significant impact on our performance.

### LevelDB and Log Structured Merge Trees

Two years ago when we started InfluxDB, we picked LevelDB as the storage engine because it was what we used for time series data storage for the product that was the precursor to InfluxDB.
We knew that it had great properties for write throughput and everything seemed to just work.

LevelDB is an implementation of a Log Structured Merge Tree (or LSM Tree) that was built as an open source project at Google.
It exposes an API for a key/value store where the key space is sorted.
This last part is important for time series data as it would allow us to quickly go through ranges of time as long as the timestamp was in the key.

LSM Trees are based on a log that takes writes and two structures known as Mem Tables and SSTables.
These tables represent the sorted keyspace.
SSTables are read only files that continuously get replaced by other SSTables that merge inserts and updates into the keyspace.

The two biggest advantages that LevelDB had for us were high write throughput and built in compression.
However, as we learned more about what people needed with time series data, we encountered a few insurmountable challenges.

The first problem we had was that LevelDB doesn't support hot backups.
If you want to do a safe backup of the database, you have to close it and then copy it.
The LevelDB variants RocksDB and HyperLevelDB fix this problem so we could have moved to them, but there was another problem that was more pressing that we didn't think could be solved with either of them.

We needed to give our users a way to automatically manage the data retention of their time series data.
That meant that we'd have to do very large scale deletes.
In LSM Trees a delete is as expensive, if not more so, than a write.
A delete will write a new record known as a tombstone.
After that queries will merge the result set with any tombstones to clear out the deletes.
Later, a compaction will run that will remove the tombstone and the underlying record from the SSTable file.

To get around doing deletes, we split data across what we call shards, which are contiguous blocks of time.
Shards would typically hold either a day or 7 days worth of data.
Each shard mapped to an underlying LevelDB.
This meant that we could drop an entire day of data by just closing out the database and removing the underlying files.

Users of RocksDB may at this point bring up a feature called ColumnFamilies.
When putting time series data into Rocks, it's common to split blocks of time into column families and then drop those when their time is up.
It's the same general idea that you create a separate area where you can just drop files instead of updating any indexes when you delete a large block of old data.
Dropping a column family is a very efficient operation.
However, column families are a fairly new feature and we had another use case for shards.

Organizing data into shards meant that it could be moved within a cluster without having to examine billions of keys.
At the time of this writing I don't think it's possible to move a column family in one RocksDB to another.
Old shards are typically cold for writes so moving them around would be cheap and easy and we'd have the added benefit of having a spot in the keyspace that is cold for writes so it would be easier to do consistency checks later.

The organization of data into shards worked great for a little while until a large amount of data went into InfluxDB.
For our users that had 6 months or a year of data in large databases, they would run out of file handles.
LevelDB splits the data out over many small files.
Having dozens or hundreds of these databases open in a single process ended up creating a big problem.
It's not something we found with a large number of users, but for anyone that was stressing the database to its limits, they were hitting this problem and we had no fix for it.
There were simply too many file handles open.

### BoltDB and mmap B+Trees

After struggling with LevelDB and its variants for a year we decided to move over to BoltDB, a pure Golang database heavily inspired by LMDB, a mmap B+Tree database written in C.
It has the same API semantics as LevelDB: a key value store where the keyspace is ordered.
Many of our users were surprised about this move after we posted some early testing results of the LevelDB variants vs.
LMDB (a mmap B+Tree) that showed RocksDB as the best performer.

However, there were other considerations that went into this decision outside of the pure write performance.
At this point our most important goal was to get to something stable that could be run in production and backed up.
BoltDB also had the advantage of being written in pure Go, which simplified our build chain immensely and made it easy to build for other OSes and platforms like Windows and ARM.

The biggest win for us was that BoltDB used a single file as the database.
At this point our most common source of bug reports were from people running out of file handles.
Bolt solved the hot backup problem, made it easy to move a shard from one server to another, and the file limit problems all at the same time.

We were willing to take a hit on write throughput if it meant that we'd have a system that was more reliable and stable that we could build on.
Our reasoning was that for anyone pushing really big write loads, they'd be running a cluster anyway.

We released versions 0.9.0 to 0.9.2 based on BoltDB.
From a development perspective it was delightful.
Clean API, fast and easy to build in our Go project, and reliable.
However, after running for a while we found a big problem with write throughput falling over.
After the database got to a certain size (over a few GB) writes would start spiking IOPS.

Some of our users were able to get past this by putting it on big hardware with near unlimited IOPS.
However, most of our users are on VMs with limited resources in the cloud.
We had to figure out a way to reduce the impact of writing a bunch of points into hundreds of thousands of series at a time.

With the 0.9.3 and 0.9.4 releases our plan was to put a write ahead log in front of Bolt.
That way we could reduce the number of random insertions into the keyspace.
Instead, we'd buffer up multiple writes at once that were next to each other and then flush them.
However, that only served to delay the problem.
High IOPS still became an issue and it showed up very quickly for anyone operating at even moderate work loads.

However, my experience building the first WAL implementation in front of Bolt gave me the confidence I needed that the write problem could be solved.
The performance of the WAL itself was fantastic, the index simply couldn't keep up.
At this point I started thinking again about how we could create something similar to an LSM Tree that could keep up with our write load.

### The new InfluxDB storage engine and LSM refined

The new InfluxDB storage engine looks very similar to a LSM Tree.
It has a write ahead log, a collection of data files which are read-only indexes similar in structure to SSTables in an LSM Tree, and a few other files that keep compressed metadata.

InfluxDB will create a shard for each block of time.
For example, if you have a retention policy with an unlimited duration, shards will get created for each 7 day block of time.
Each of these shards maps to an underlying storage engine database.
Each of these databases has its own WAL, compressed metadata that describe which series are in the index, and the index data files.

We'll dig into each of these parts of the storage engine.

#### The Write Ahead Log

The WAL is organized as a bunch of files that look like _000001.wal.
The file numbers are monotonically increasing.
When a file reaches 2MB in size, it is closed and a new one is opened.
There is a single write lock into the WAL that keeps many goroutines from trying to write to the file at once.
The lock is only obtained to write the already serialized and compressed bytes to the file.

When a write comes in with points and optionally new series and fields defined, they are serialized, compressed using Snappy, and written to a WAL file.
The file is fsync'd and the data added to an in memory index before a success is returned.
This means that batching points together will be required to achieve high throughput performance.

Each entry in the WAL follows a TLV standard with a single byte representing what the type of entry it is (points, new fields, new series, or delete), a 4 byte uint32 for the length of the compressed block, and then the compressed block.

It's possible to disable the persistence of the WAL, instead relying on a regular flush to the index.
This would result in the best possible performance at the cost of opening up a window of data loss for unflushed writes.

The WAL keeps an in memory cache of all data points that are written to it.
The points are organized by the key, which is the measurement, tagset, and unique field.
Each field is kept as its own time ordered range.
The data isn't compressed while in memory.

Queries to the storage engine will merge data from the WAL with data from the index.
The cache uses a read-write lock to enable many goroutines to access the cache.
When a query happens a copy of the data is made from the cache to be processed by the query engine.
This way writes that come in while a query is happening won't change the result.

Deletes sent to the WAL will clear out the cache for the given key, persist in the WAL file and tell the index to keep a tombstone in memory.

The WAL exposes a few controls for flush behavior.
The two most important controls are the memory limits.
There is a lower bound, which will trigger a flush to the index.
There is also an upper bound limit at which the WAL will start rejecting writes.
This is useful if the index gets backed up flushing and we need to apply back pressure to clients writing data.
It also ensures that we can keep from running out of memory if the WAL gets too big.
The checks for memory thresholds occur on every write.

The other flush controls are time based.
The idle flush will have the WAL flush to the index if it hasn't received a write within a given amount of time.
The second control is to have the WAL periodically flush even when taking writes.
For instance if you disabled persistence and set this to 30 seconds, you would have a 30 second window of potential data loss.

Finally, the WAL is fully flushed on startup.
If it was particularly backed up this could cause the startup time to take a bit.

#### Data Files (like SSTables)

The storage index is a collection of read-only index files that get memory mapped.
The structure of these files looks very similar to an SSTable in LevelDB or other LSM Tree variants.
Each file has  a structure that looks like this:

![data file](/img/influxdb/tsm/data_file.png)

The magic number at the beginning identifies the file as a data file for the PD1 storage engine.
We'll go into the details of the data and index blocks in a bit.
The min time and max time are nanosecond epochs of the minimum and maximum timestamps of the points in any of the data blocks of the file.
Finally, the file ends with a uint32 of the number of series contained in the data file.

The structure of each data block looks like this:

![data block](/img/influxdb/tsm/data_block.png)

The ID is the identifier for the series and field.
IDs are generated by taking the fnv64-a hash of the series key (measurement name + tagset) and the field name.
We'll discuss how we handle ID hash collisions later in this doc.

The compressed block uses a compression scheme depending on the type of the field.
Details on compression are covered later, but for now it's important to know that the first 8 bytes of every compressed block has the minimum timestamp for all values in the block.
By default, up to 1000 values are encoded in a block.

The data blocks are always arranged in sorted order by the IDs and if there are multiple blocks for a given ID in a single file, those blocks will be arranged by time.
The timestamps for values in the blocks for the same ID are increasing and non-overlapping.

The index block in a data file looks like this:

![index block](/img/influxdb/tsm/index_block.png)

The index block contains all the IDs that have data blocks in the file and the position of their first block.
All IDs are in sorted order, which is important later for finding the starting position of an ID's block.
Note that the starting position is a uint32 value, which means that data files are limited in size to a maximum of 4GB.

#### Writes to the Index

The storage index keeps a collection of data files.
These files have non-overlapping time ranges.
The index keeps a mapping in memory of the memory mapped data files that exist and their min and max times.
The files are kept in a sorted array by their time.

The first thing that happens when the WAL flushes a block of writes to the index is mapping the keys of the series and fields that have values to their unique ID.
Most IDs should simply be the fnv64-a hash of the series key and the field name.
However, we need to ensure that we keep track of any collisions.

The index keeps a file called "names" that keeps a compressed JSON map of key to ID.
When a flush happens we ensure that any of the keys coming in have an ID in the map that is equal to the fnv64-a hash.
If it is present in the map and the same we move on.
If it isn't present in the map, we add it.
If the ID is taken already, we keep track of the collision.

If there are any new keys, we marshall, compress and write a new names file.
The old file is removed once the new one has been written and closed.
If there are any collisions, we write those into a collisions file.
This is read on startup of the index so collisions can be kept in memory.
We'll talk more about how collisions are handled later.

This name decoding scheme is fairly inefficient since we're marshaling this entire map on every WAL flush.
The alternative is to keep it in memory, but that is also expensive as there are many indexes (one per shard) in a running InfluxDB process.
We could also just keep the map in memory while a given shard is hot for writes (i.e.
its time range is current for now).

In testing the cost of decoding and rewriting the names file hasn't been a big problem and the simplicity of the scheme makes it a bit easier to work with.
We've been testing up to 500k unique keys at this point.

After the ID resolution is done the write will be broken up by the time of the individual data points.
If no data file exists for any of the time ranges, a new one will be created and written.
If a data file already exists for the given time range and it is less than a configurable size (5MB by default), then the data file will be read in and the new values merged with it and a new data file will be created.

While this new file is getting written, all queries will hit the old data file and continue to use the WAL cache, which won't be cleared until the write to the index is confirmed.
Once the new file is written, the engine will obtain a write lock to replace the old data file with the new data file in the in memory index, remove the old file from the filesystem and then return success back to the WAL.
We'll talk about how recovery is handled in a later section of this document.

Because of this structure, multiple ranges of time can be written simultaneously, which enables us to perform compactions on old time ranges while still accepting writes for current time ranges.
We'll cover the details of compaction in a later section.
Writes will only block reads during the window of time that the in-memory sorted list of data files is modified (an operation that takes less than a few microseconds).

The index is optimized for the append only workload that is most common in InfluxDB usage.
It's possible to update old data points, but that operation can be expensive because data files will need to be rewritten.
However, historical backfill when initially setting up a database is very efficient and has a workload that looks like filling in new data as long as the backfill is done in time ascending order.

Even during normal operation, data files continually get rewritten as the WAL flushes to the index.
However, the data files are generally small at that point so the cost of rewriting them is negligible.
Later, compactions will combine older data files into larger ones.

#### Compaction

In the background the index continually checks for old data files that can be combined together.
By default, any files with a time older than 30 minutes will be combined together.
The process is the same as during a write, a new file is created, the two data files are read in together and the merged stream of sorted IDs and blocks are written out as they are read from the two files.

Once the new file is written, the index obtains the write lock to modify the collection of data files and removes the older two files.
The compaction process will only attempt to compact data files that are less than a configurable size (500MB by default and up to a max of 1GB).

#### Updates

Updates are held first in the WAL.
If there are a number of updates to the same range, ideally the WAL will buffer them together before it gets flushed to the index.
The index will simply rewrite the data file that contains the updated data.
If the updates are to a recent block of time, the updates will be relatively inexpensive.

#### Deletes

Deletes are handled in two phases.
First, when the WAL gets a delete it will persist it in the log, clear its cache of that series, and tell the index to keep an in-memory tombstone of the delete.
When a query comes into the index, it will check it against any of the in-memory tombstones and act accordingly.

Later, when the WAL flushes to the index, it will include the delete and any data points that came into the series after the delete.
The index will handle the delete first by rewriting any data files that contain that series to remove them.
Then it will persist any new data (for this series or any others), remove the tombstone from memory and return success to the WAL.

#### Metadata

Metadata for all the series and fields in the shard are kept in 2 files named "names" and "fields".
These two files contain a single Snappy compressed block of the serialized JSON of any names or fields in the shard.

This means that any flush from the WAL that contains either new fields or series, will force the old file to be read in, decompressed, marshalled, merged with the new series and a new file to be written.
Because the WAL buffers these new definitions, the cost is generally negligible.
However, as the number of series in a shard gets very high it can become expensive.
We've tested up to 500k unique series and this scheme still works well.

#### Seeking and Reading a Series

When a seek comes into the storage engine, it is a seek to a given time associated with a specific series key and field.
First, we do a binary search on the data files to find the file that has a time range that matches the time we're seeking to.

Once we have the data file we need to find the position in the file for the block that contains the given time.
First, we check the collisions map to see if this seek is to an ID that doesn't match up with the hash ID.
If it's not there, we do a fnv64-a hash against the series key and field name to get its ID.

Now that we have the ID we check the end of the file for the series count.
Remember that it's memory mapped so this should be fast.
Now that we know the count of the series, we know which byte positions in the file contain the index of IDs to starting position.

We'll now do a binary search against the section of the index to find the ID and its position.
Remember that the index is sorted by increasing IDs.
This operation is very efficient and the index for a data file is in the memory map.

Now that we have the starting position we can look at the first block's timestamp and the next block's timestamp.
We traverse the blocks until we find the one that matches up with the timestamp we're seeking to.
This means we're making jumps in the file by the length of the compressed blocks.

In practice, a shard will have the data for a day or 7 days.
For people with regular time series that sample every 10 seconds, they'll have data files that contain either 8,640 data points (1 day) for each series or that times 7.
That means that at most we'll end up making 56 jumps to the last block.
In practice it's likely that 7 days of data would be split across multiple data files, reducing the number of blocks for a given series in a file.

Once we've found the matching block, we decompress it and go to the specific point.
As the query engine traverses the series by getting subsequent points, we go through that block, then decompress the next one, then jump to the next data file, until we ultimately reach the end of the shard.

#### Compression

Each block is compressed to reduce storage space and disk IO when querying.
A block contains the timestamps and values for a given series and field.
Each block has one byte header, followed by the compressed timestamps and then the compressed values.
The timestamps and values are stored separately as two compressed parts using different encodings depending on the data type and its shape.
Storing them independently allows timestamp encoding to be used with different field types more easily.
It also allows for different encodings to be used depending on the type of the data.
For example, some points may be able to use run-length encoding whereas other may not.
Each value type also contains a 1 byte header indicating the type of compression for the remaining bytes.
The four high bits store the compression type and the four low bits are used by the encoder if needed.

![compressed block](/img/influxdb/tsm/compressed_block.png)

Timestamp encoding is adaptive and based on the structure of the timestamps that are encoded.
It uses a combination of delta encoding, scaling and compression using simple8b, run-length encoding as well as falling back to no compression if needed.

Timestamp resolution can be as granular as a nanosecond and, uncompressed, require 8 bytes to store.
During encoding, the values are first delta-encoded.
The first value is the starting timestamp and subsequent values are the differences from the prior value.
This usually converts the values into much smaller integers that are easier to compress.
Many timestamps are also monotonically increasing and fall on even boundaries of time such as every 10s.
When timestamps have this structure, they are scaled by the largest common divisor that Zis also a factor of 10.
This has the effect of converting very large integer deltas into smaller ones that compress even better.

Using these adjusted values, if all the deltas are the same, the time range is stored using run-length encoding.
If run-length encoding is not possible and all values are less than 1 << 60 - 1 (~36.5 yrs in nanosecond resolution), then the timestamps are encoded using the simple8b encoding which is a 64bit word-aligned integer encoding.
This encoding packs up multiple integers into a single 64bit word.
If any value exceeds the maximum values, the deltas are stored uncompressed using 8 bytes each for the block.
Future encodings will use a patched scheme such as Patched Frame-Of-Reference (PFOR) to handle outlier more effectively.

Floats are encoded using an implementation of the Facebook Gorilla paper.
This encoding XORs consecutive values together which produces a small result when the values are close together.
The delta is then stored using control bits to indicate how many leading and trailing zero are in the XOR value.
Our version removes the timestamp encoding, as described in paper, and only encodes the float values.

Integer encoding uses two different strategies depending on the range of values in the uncompressed data.
Encoded values are first encoded using zig zag encoding which is also used for signed integers in Google Protocol Buffers.
This interleaves positive and negative integers across a range of positive integers.

For example, [-2,-1,0,1] becomes [3,1,0,2].
See https://developers.google.com/protocol-buffers/docs/encoding#signed-integers for more information.

If all the zig zag encoded values less than 1 << 60 - 1, they are compressed using the simple8b encoding.
If any values is larger than the maximum value, then values are stored uncompressed in the block.

Booleans are encoded using a simple bit packing strategy where each boolean uses 1 bit.
The number of booleans encoded is stored using variable-byte encoding at the beginning of the block.

Strings are encoding using Snappy compression.
Each string is packed next each other in order and compressed as one larger block.


text:
. `dirname $0`/setenv.sh
# Capture user's working dir before changing directory
CWD="$PWD"
cd ${AIRAVATA_HOME}/bin
LOGO_FILE="logo.txt"

JAVA_OPTS="-Dairavata.config.dir=${AIRAVATA_HOME}/conf -Dairavata.home=${AIRAVATA_HOME} -Dlog4j.configurationFile=file:${AIRAVATA_HOME}/conf/log4j2.xml"
AIRAVATA_COMMAND=""
EXTRA_ARGS=""
SERVERS=""
LOGO=true
IS_SUBSET=false
SUBSET=""
DEFAULT_LOG_FILE="${AIRAVATA_HOME}/logs/airavata-daemon.out"
LOG_FILE=$DEFAULT_LOG_FILE

SERVICE_NAME="Email Monitor"
PID_PATH_NAME="${AIRAVATA_HOME}/bin/service-pid"

case $1 in
    start)
        echo "Starting $SERVICE_NAME ..."
        if [ ! -f $PID_PATH_NAME ]; then
            nohup java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \
            org.apache.airavata.monitor.email.EmailBasedMonitor ${AIRAVATA_COMMAND} $* > $LOG_FILE 2>&1 &
            echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is already running ..."
        fi
    ;;
    stop)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stoping ..."
            kill $PID;
            RETRY=0
            while kill -0 $PID 2> /dev/null; do
                echo "Waiting for the process $PID to be stopped"
                RETRY=`expr ${RETRY} + 1`
                if [ "${RETRY}" -gt "20" ]
                then
                    echo "Forcefully killing the process as it is not responding ..."
                    kill -9 $PID
                fi
                sleep 1
            done
            echo "$SERVICE_NAME stopped ..."
            rm $PID_PATH_NAME
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
    restart)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stopping ...";
            kill $PID;
            RETRY=0
            while kill -0 $PID 2> /dev/null; do
                echo "Waiting for the process $PID to be stopped"
                RETRY=`expr ${RETRY} + 1`
                if [ "${RETRY}" -gt "20" ]
                then
                    echo "Forcefully killing the process as it is not responding ..."
                    kill -9 $PID
                fi
                sleep 1
            done
            echo "$SERVICE_NAME stopped ...";
            rm $PID_PATH_NAME
            echo "$SERVICE_NAME starting ..."
            nohup java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \
            org.apache.airavata.monitor.email.EmailBasedMonitor ${AIRAVATA_COMMAND} $* > $LOG_FILE 2>&1 &
            echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
    -h)
        echo "Usage: email-monitor-daemon.sh"

        echo "command options:"
        echo "  start               Start server in daemon mode"
        echo "  stop                Stop server running in daemon mode"
        echo "  restart             Restart server in daemon mode"
	    echo "  -log <LOG_FILE>     Where to redirect stdout/stderr (defaults to $DEFAULT_LOG_FILE)"
        echo "  -h                  Display this help and exit"
        shift
        exit 0
    ;;
esac

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
org.apache.jmeter.timers (Apache JMeter API)
</TITLE>

<META NAME="date" CONTENT="2013-12-31">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

org.apache.jmeter.timers

Interfaces

Timer

Classes

BeanShellTimer

BeanShellTimerBeanInfo

BSFTimer

BSFTimerBeanInfo

ConstantThroughputTimer

ConstantThroughputTimerBeanInfo

ConstantTimer

GaussianRandomTimer

JSR223Timer

JSR223TimerBeanInfo

PoissonRandomTimer

RandomTimer

SyncTimer

SyncTimerBeanInfo

UniformRandomTimer

Enums

ConstantThroughputTimer.Mode


text:
@(questions: List[models.Question])
@questions.map { question =>

@Messages("tags.renderComment.postedBy") @question.author on @library.FormatDate.ellapsed(question.eventDate)

@defining(question.msg.replaceAll("script", ".script").replaceAll("\n", "
")) { message: String =>
    @Html(message)
}

}


text:
package net.liftweb.widgets.menu

import _root_.scala.xml.{NodeSeq, Node, Elem, PCData, Text, Unparsed}
import _root_.net.liftweb.http.{LiftRules, S}
import _root_.net.liftweb.http.js._
import _root_.net.liftweb.sitemap._
import JsCmds._
import JE._
import _root_.net.liftweb.util._
import Helpers._

object MenuStyle extends Enumeration("sf-menu", "sf-menu sf-vertical", "sf-menu sf-navbar") {
  val HORIZONTAL, VERTICAL, NAVBAR = Value
}

object MenuWidget {

  def apply() = new MenuWidget(LiftRules.siteMap open_!, MenuStyle.HORIZONTAL, JsObj()) render

  def apply(style: MenuStyle.Value) = new MenuWidget(LiftRules.siteMap open_!, style, JsObj()) render

  def apply(siteMap: SiteMap) = new MenuWidget(siteMap, MenuStyle.HORIZONTAL, JsObj()) render

  def apply(siteMap: SiteMap, style: MenuStyle.Value) = new MenuWidget(siteMap, style, JsObj()) render

  def apply(jsObj: JsObj) = new MenuWidget(LiftRules.siteMap open_!, MenuStyle.HORIZONTAL, jsObj) render

  def apply(style: MenuStyle.Value, jsObj: JsObj) = new MenuWidget(LiftRules.siteMap open_!, style, jsObj) render

  def apply(siteMap: SiteMap, jsObj: JsObj) = new MenuWidget(siteMap, MenuStyle.HORIZONTAL, jsObj) render

  def apply(siteMap: SiteMap, style: MenuStyle.Value, jsObj: JsObj) = new MenuWidget(siteMap, style, jsObj) render

   /**
    * register the resources with lift (typically in boot)
    */
  def init() {
    import net.liftweb.http.ResourceServer

    ResourceServer.allow({
        case "menu" :: _ => true
     })
  }

}

/**
 * Builds a Menu widget based on a give SiteMap
 */
class MenuWidget(siteMap: SiteMap, style: MenuStyle.Value, jsObj: JsObj) {
  def head: NodeSeq = <head>
      <link rel="stylesheet" href={"/" + LiftRules.resourceServerPath + "/menu/superfish.css"} type="text/css"/>{
        style match {
	      case MenuStyle.VERTICAL =>  <link rel="stylesheet" href={"/" + LiftRules.resourceServerPath + "/menu/superfish-vertical.css"} type="text/css"/>
	      case MenuStyle.NAVBAR =>  <link rel="stylesheet" href={"/" + LiftRules.resourceServerPath + "/menu/superfish-navbar.css"} type="text/css"/>
          case _ => NodeSeq.Empty
	    }
      }
      <script type="text/javascript" src={"/" + LiftRules.resourceServerPath + "/menu/superfish.js"}></script>
      <script type="text/javascript" src={"/" + LiftRules.resourceServerPath + "/menu/jquery.hoverIntent.js"}></script>
      <script type="text/javascript" charset="utf-8">{
        Unparsed("""
         jQuery(document).ready(function() {
            jQuery('ul.sf-menu').superfish(""" + jsObj.toJsCmd + """);
          })
         """)
       }
      </script>
    </head>

  def render : NodeSeq = {
    head ++ <lift:Menu.builder expandAll="true" top:class={style.toString} />
  }

}


text:
package com.giyeok.jparser.study.grammarmodification

import com.giyeok.jparser.study.CfgSymbols._
import com.giyeok.jparser.study.ContextFreeGrammar
import com.giyeok.jparser.study.ContextFreeGrammarModification

class LeftRecursionElimination {
    def eliminateDirectLeftRecursion(grammar: ContextFreeGrammar, symbol: Nonterminal): (ContextFreeGrammar, ContextFreeGrammarModification) = {
        ???
    }

    def eliminateLeftRecursion(grammar: ContextFreeGrammar): (ContextFreeGrammar, ContextFreeGrammarModification) = {
        ???
    }
}


text:
#pragma once
#include <aws/connect/Connect_EXPORTS.h>
#include <aws/connect/ConnectRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/connect/model/MediaConcurrency.h>
#include <utility>

namespace Aws
{
namespace Connect
{
namespace Model
{

  /**
   */
  class AWS_CONNECT_API UpdateRoutingProfileConcurrencyRequest : public ConnectRequest
  {
  public:
    UpdateRoutingProfileConcurrencyRequest();

    // Service request name is the Operation name which will send this request out,
    // each operation should has unique request name, so that we can get operation's name from this request.
    // Note: this is not true for response, multiple operations may have the same response name,
    // so we can not get operation's name from response.
    inline virtual const char* GetServiceRequestName() const override { return "UpdateRoutingProfileConcurrency"; }

    Aws::String SerializePayload() const override;

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline const Aws::String& GetInstanceId() const{ return m_instanceId; }

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline bool InstanceIdHasBeenSet() const { return m_instanceIdHasBeenSet; }

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline void SetInstanceId(const Aws::String& value) { m_instanceIdHasBeenSet = true; m_instanceId = value; }

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline void SetInstanceId(Aws::String&& value) { m_instanceIdHasBeenSet = true; m_instanceId = std::move(value); }

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline void SetInstanceId(const char* value) { m_instanceIdHasBeenSet = true; m_instanceId.assign(value); }

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithInstanceId(const Aws::String& value) { SetInstanceId(value); return *this;}

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithInstanceId(Aws::String&& value) { SetInstanceId(std::move(value)); return *this;}

    /**
     *
The identifier of the Amazon Connect instance. You can find the instanceId in
     * the ARN of the instance.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithInstanceId(const char* value) { SetInstanceId(value); return *this;}

    /**
     *
The identifier of the routing profile.

     */
    inline const Aws::String& GetRoutingProfileId() const{ return m_routingProfileId; }

    /**
     *
The identifier of the routing profile.

     */
    inline bool RoutingProfileIdHasBeenSet() const { return m_routingProfileIdHasBeenSet; }

    /**
     *
The identifier of the routing profile.

     */
    inline void SetRoutingProfileId(const Aws::String& value) { m_routingProfileIdHasBeenSet = true; m_routingProfileId = value; }

    /**
     *
The identifier of the routing profile.

     */
    inline void SetRoutingProfileId(Aws::String&& value) { m_routingProfileIdHasBeenSet = true; m_routingProfileId = std::move(value); }

    /**
     *
The identifier of the routing profile.

     */
    inline void SetRoutingProfileId(const char* value) { m_routingProfileIdHasBeenSet = true; m_routingProfileId.assign(value); }

    /**
     *
The identifier of the routing profile.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithRoutingProfileId(const Aws::String& value) { SetRoutingProfileId(value); return *this;}

    /**
     *
The identifier of the routing profile.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithRoutingProfileId(Aws::String&& value) { SetRoutingProfileId(std::move(value)); return *this;}

    /**
     *
The identifier of the routing profile.

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithRoutingProfileId(const char* value) { SetRoutingProfileId(value); return *this;}

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline const Aws::Vector<MediaConcurrency>& GetMediaConcurrencies() const{ return m_mediaConcurrencies; }

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline bool MediaConcurrenciesHasBeenSet() const { return m_mediaConcurrenciesHasBeenSet; }

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline void SetMediaConcurrencies(const Aws::Vector<MediaConcurrency>& value) { m_mediaConcurrenciesHasBeenSet = true; m_mediaConcurrencies = value; }

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline void SetMediaConcurrencies(Aws::Vector<MediaConcurrency>&& value) { m_mediaConcurrenciesHasBeenSet = true; m_mediaConcurrencies = std::move(value); }

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithMediaConcurrencies(const Aws::Vector<MediaConcurrency>& value) { SetMediaConcurrencies(value); return *this;}

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline UpdateRoutingProfileConcurrencyRequest& WithMediaConcurrencies(Aws::Vector<MediaConcurrency>&& value) { SetMediaConcurrencies(std::move(value)); return *this;}

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline UpdateRoutingProfileConcurrencyRequest& AddMediaConcurrencies(const MediaConcurrency& value) { m_mediaConcurrenciesHasBeenSet = true; m_mediaConcurrencies.push_back(value); return *this; }

    /**
     *
The channels that agents can handle in the Contact Control Panel (CCP).

     */
    inline UpdateRoutingProfileConcurrencyRequest& AddMediaConcurrencies(MediaConcurrency&& value) { m_mediaConcurrenciesHasBeenSet = true; m_mediaConcurrencies.push_back(std::move(value)); return *this; }

  private:

    Aws::String m_instanceId;
    bool m_instanceIdHasBeenSet = false;

    Aws::String m_routingProfileId;
    bool m_routingProfileIdHasBeenSet = false;

    Aws::Vector<MediaConcurrency> m_mediaConcurrencies;
    bool m_mediaConcurrenciesHasBeenSet = false;
  };

} // namespace Model
} // namespace Connect
} // namespace Aws


text:
from oslo_config import cfg
from oslo_log import log as logging
from pecan import rest
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan

from mistral.api.controllers import resource
from mistral.api.controllers.v2 import types
from mistral.db.v2 import api as db_api
from mistral.engine import rpc
from mistral import exceptions as exc
from mistral.utils import rest_utils
from mistral.workflow import states
from mistral.workflow import utils as wf_utils

LOG = logging.getLogger(__name__)

class ActionExecution(resource.Resource):
    """ActionExecution resource."""

    id = wtypes.text

    workflow_name = wtypes.text
    task_name = wtypes.text
    task_execution_id = wtypes.text

    state = wtypes.text

    state_info = wtypes.text
    tags = [wtypes.text]
    name = wtypes.text
    description = wtypes.text
    accepted = bool
    input = types.jsontype
    output = types.jsontype
    created_at = wtypes.text
    updated_at = wtypes.text
    params = types.jsontype

    @classmethod
    def sample(cls):
        return cls(
            id='123e4567-e89b-12d3-a456-426655440000',
            workflow_name='flow',
            task_name='task1',
            workflow_execution_id='653e4127-e89b-12d3-a456-426655440076',
            task_execution_id='343e45623-e89b-12d3-a456-426655440090',
            state=states.SUCCESS,
            state_info=states.SUCCESS,
            tags=['foo', 'fee'],
            name='std.echo',
            description='My running action',
            accepted=True,
            input={'first_name': 'John', 'last_name': 'Doe'},
            output={'some_output': 'Hello, John Doe!'},
            created_at='1970-01-01T00:00:00.000000',
            updated_at='1970-01-01T00:00:00.000000',
            params={'save_result': True}
        )

class ActionExecutions(resource.Resource):
    """A collection of action_executions."""

    action_executions = [ActionExecution]

    @classmethod
    def sample(cls):
        return cls(action_executions=[ActionExecution.sample()])

def _load_deferred_output_field(action_ex):
    # We need to refer to this lazy-load field explicitly in
    # order to make sure that it is correctly loaded.
    hasattr(action_ex, 'output')

def _get_action_execution(id):
    action_ex = db_api.get_action_execution(id)

    return _get_action_execution_resource(action_ex)

def _get_action_execution_resource(action_ex):
    _load_deferred_output_field(action_ex)

    # TODO(nmakhotkin): Get rid of using dicts for constructing resources.
    # TODO(nmakhotkin): Use db_model for this instead.
    res = ActionExecution.from_dict(action_ex.to_dict())

    task_name = (action_ex.task_execution.name
                 if action_ex.task_execution else None)
    setattr(res, 'task_name', task_name)

    return res

def _get_action_executions(task_execution_id=None):
    kwargs = {'type': 'action_execution'}

    if task_execution_id:
        kwargs['task_execution_id'] = task_execution_id

    action_execs = [
        _get_action_execution_resource(a_ex)
        for a_ex in db_api.get_action_executions(**kwargs)
    ]

    return ActionExecutions(action_executions=action_execs)

class ActionExecutionsController(rest.RestController):
    @rest_utils.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(ActionExecution, wtypes.text)
    def get(self, id):
        """Return the specified action_execution."""
        LOG.info("Fetch action_execution [id=%s]" % id)

        return _get_action_execution(id)

    @rest_utils.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(ActionExecution,
                         body=ActionExecution, status_code=201)
    def post(self, action_ex):
        """Create new action_execution."""
        LOG.info("Create action_execution [action_execution=%s]" % action_ex)

        name = action_ex.name
        description = action_ex.description or None
        action_input = action_ex.input or {}
        params = action_ex.params or {}

        if not name:
            raise exc.InputException(
                "Please provide at least action name to run action."
            )

        action_ex = rpc.get_engine_client().start_action(
            name,
            action_input,
            description=description,
            **params
        )

        return ActionExecution.from_dict(action_ex)

    @rest_utils.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(ActionExecution, wtypes.text, body=ActionExecution)
    def put(self, id, action_ex):
        """Update the specified action_execution."""
        LOG.info(
            "Update action_execution [id=%s, action_execution=%s]"
            % (id, action_ex)
        )

        if action_ex.state == states.SUCCESS:
            result = wf_utils.Result(data=action_ex.output)
        elif action_ex.state == states.ERROR:
            result = wf_utils.Result(error=action_ex.output)
        else:
            raise exc.InvalidResultException(
                "Error. Expected on of %s, actual: %s" %
                ([states.SUCCESS, states.ERROR], action_ex.state)
            )

        values = rpc.get_engine_client().on_action_complete(id, result)

        return ActionExecution.from_dict(values)

    @wsme_pecan.wsexpose(ActionExecutions)
    def get_all(self):
        """Return all action_executions within the execution."""
        LOG.info("Fetch action_executions")

        return _get_action_executions()

    @rest_utils.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
    def delete(self, id):
        """Delete the specified action_execution."""

        LOG.info("Delete action_execution [id=%s]" % id)

        if not cfg.CONF.api.allow_action_execution_deletion:
            raise exc.NotAllowedException("Action execution deletion is not "
                                          "allowed.")

        action_ex = db_api.get_action_execution(id)

        if action_ex.task_execution_id:
            raise exc.NotAllowedException("Only ad-hoc action execution can "
                                          "be deleted.")

        if not states.is_completed(action_ex.state):
            raise exc.NotAllowedException("Only completed action execution "
                                          "can be deleted.")

        return db_api.delete_action_execution(id)

class TasksActionExecutionController(rest.RestController):
    @wsme_pecan.wsexpose(ActionExecutions, wtypes.text)
    def get_all(self, task_execution_id):
        """Return all action executions within the task execution."""
        LOG.info("Fetch action executions")

        return _get_action_executions(task_execution_id=task_execution_id)

    @rest_utils.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(ActionExecution, wtypes.text, wtypes.text)
    def get(self, task_execution_id, action_ex_id):
        """Return the specified action_execution."""
        LOG.info("Fetch action_execution [id=%s]" % action_ex_id)

        return _get_action_execution(action_ex_id)


text:
class DataSource(object):
  '''
  Defines an abstraction for all DataSources.

  DataSources must have two public methods, get and Cron. A DataSource is
  initialized with a ServerInstance and a Request (defined in servlet.py).
  Anything in the ServerInstance can be used by the DataSource. Request is None
  when DataSources are created for Cron.

  DataSources are used to provide templates with access to data. DataSources may
  not access other DataSources and any logic or data that is useful to other
  DataSources must be moved to a different class.
  '''
  def __init__(self, server_instance, request):
    pass

  def Cron(self):
    '''Must cache all files needed by |get| to persist them. Called on a live
    file system and can access files not in cache. |request| will be None.
    '''
    raise NotImplementedError(self.__class__)

  def get(self, key):
    '''Returns a dictionary or list that can be consumed by a template. Called
    on an offline file system and can only access files in the cache.
    '''
    raise NotImplementedError(self.__class__)


text:
FindJBIG
--------

Find the native JBIG includes and library.

IMPORTED Targets
^^^^^^^^^^^^^^^^

This module defines :prop_tgt:`IMPORTED` target ``JBIG::JBIG``, if
JBIG has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

::

  JBIG_INCLUDE_DIRS   - where to find jbig.h, etc.
  JBIG_LIBRARIES      - List of libraries when using jbig.
  JBIG_FOUND          - True if jbig found.

::

  JBIG_VERSION_STRING - The version of jbig found (x.y.z)
  JBIG_VERSION_MAJOR  - The major version of jbig
  JBIG_VERSION_MINOR  - The minor version of jbig

  Debug and Release variants are found separately.
#]=======================================================================]

# Standard names to search for
set(JBIG_NAMES jbig)
set(JBIG_NAMES_DEBUG jbigd)

find_path(JBIG_INCLUDE_DIR
          NAMES jbig.h
          PATH_SUFFIXES include)

set(JBIG_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# Library has a "lib" prefix even on Windows.
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")

# Allow JBIG_LIBRARY to be set manually, as the location of the jbig library
if(NOT JBIG_LIBRARY)
  find_library(JBIG_LIBRARY_RELEASE
               NAMES ${JBIG_NAMES}
               PATH_SUFFIXES lib)
  find_library(JBIG_LIBRARY_DEBUG
               NAMES ${JBIG_NAMES_DEBUG}
               PATH_SUFFIXES lib)

  include(SelectLibraryConfigurations)
  select_library_configurations(JBIG)
endif()

set(CMAKE_FIND_LIBRARY_PREFIXES "${JBIG_OLD_FIND_LIBRARY_PREFIXES}")

unset(JBIG_NAMES)
unset(JBIG_NAMES_DEBUG)
unset(JBIG_OLD_FIND_LIBRARY_PREFIXES)

mark_as_advanced(JBIG_INCLUDE_DIR)

if(JBIG_INCLUDE_DIR AND EXISTS "${JBIG_INCLUDE_DIR}/jbig.h")
    file(STRINGS "${JBIG_INCLUDE_DIR}/jbig.h" JBIG_H REGEX "^#define JBG_VERSION  *\"[^\"]*\"$")

    string(REGEX REPLACE "^.*JBG_VERSION  *\"([0-9]+).*$" "\\1" JBIG_MAJOR_VERSION "${JBIG_H}")
    string(REGEX REPLACE "^.*JBG_VERSION  *\"[0-9]+\\.([0-9]+).*$" "\\1" JBIG_MINOR_VERSION  "${JBIG_H}")
    set(JBIG_VERSION_STRING "${JBIG_MAJOR_VERSION}.${JBIG_MINOR_VERSION}")

    set(JBIG_MAJOR_VERSION "${JBIG_VERSION_MAJOR}")
    set(JBIG_MINOR_VERSION "${JBIG_VERSION_MINOR}")
endif()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JBIG
        REQUIRED_VARS JBIG_LIBRARY JBIG_INCLUDE_DIR
        VERSION_VAR JBIG_VERSION_STRING)

if(JBIG_FOUND)
    set(JBIG_INCLUDE_DIRS ${JBIG_INCLUDE_DIR})

    if(NOT JBIG_LIBRARIES)
        set(JBIG_LIBRARIES ${JBIG_LIBRARY})
    endif()

    if(NOT TARGET JBIG::JBIG)
        add_library(JBIG::JBIG UNKNOWN IMPORTED)
        set_target_properties(JBIG::JBIG PROPERTIES
                INTERFACE_INCLUDE_DIRECTORIES "${JBIG_INCLUDE_DIRS}")

        if(JBIG_LIBRARY_RELEASE)
            set_property(TARGET JBIG::JBIG APPEND PROPERTY
                    IMPORTED_CONFIGURATIONS RELEASE)
            set_target_properties(JBIG::JBIG PROPERTIES
                    IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY_RELEASE}")
        endif()

        if(JBIG_LIBRARY_DEBUG)
            set_property(TARGET JBIG::JBIG APPEND PROPERTY
                    IMPORTED_CONFIGURATIONS DEBUG)
            set_target_properties(JBIG::JBIG PROPERTIES
                    IMPORTED_LOCATION_DEBUG "${JBIG_LIBRARY_DEBUG}")
        endif()

        if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG)
            set_target_properties(JBIG::JBIG PROPERTIES
                    IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY}")
        endif()
    endif()
endif()


text:
var assert = require('assert'),
    error = require('../../../lib/error/index'),
    math = require('../../../index'),
    permutations = math.permutations;

describe('permutations', function() {

  it('should calculate the permutations of a number', function() {
    assert.equal(permutations(0), 1);
    assert.equal(permutations(1), 1);
    assert.equal(permutations(2), 2);
    assert.equal(permutations(3), 6);
    assert.equal(permutations(4), 24);
    assert.equal(permutations(5), 120);
  });

  it('should calculate the permutations of a BigNumber', function() {
    assert.deepEqual(permutations(math.bignumber(4)), math.bignumber(24));
    assert.deepEqual(permutations(math.bignumber(5)), math.bignumber(120));
    assert.deepEqual(permutations(math.bignumber(8)), math.bignumber(40320));
  });

  it('should calculate the permutations of a BigNumber, taking k at a time', function() {
    assert.deepEqual(permutations(math.bignumber(5), math.bignumber(4)), math.bignumber(120));
    assert.deepEqual(permutations(math.bignumber(6), math.bignumber(3)), math.bignumber(120));
    assert.deepEqual(permutations(math.bignumber(9), math.bignumber(8)), math.bignumber(362880));
  });

  it('should calculate the permutations of a number, taking k at a time', function() {
    assert.equal(permutations(5, 4), 120);
    assert.equal(permutations(9, 8), 362880);
    assert.equal(permutations(7, 5), 2520);
  });

  it('should fail loudly when k is larger than x', function() {
      assert.throws(function(){permutations(5, 6);}, TypeError);
      assert.throws(function(){permutations(math.bignumber(5), math.bignumber(6));}, TypeError);
  });

  it('should not accept negative or non-integer arguments', function() {
      assert.throws(function(){permutations(12, -6);}, TypeError);
      assert.throws(function(){permutations(-12, -6);}, TypeError);
      assert.throws(function(){permutations(math.bignumber(-12), -6);}, TypeError);
      assert.throws(function(){permutations(math.bignumber(12.5), math.bignumber(6));}, TypeError);
      assert.throws(function(){permutations(math.bignumber(12.5), math.pi);}, TypeError);
  });

  it('should not accept more than two arguments', function() {
      assert.throws(function(){permutations(12, 6, 13);});
      assert.throws(function(){permutations(-12, 6, 13);});
  });

  it('should not accept arguments of the wrong type', function() {
      assert.throws(function(){permutations("baa baa black sheep", true);});
      assert.throws(function(){permutations(new Array(12));});
  });

  it('should LaTeX permutations', function () {
    var expression = math.parse('permutations(2)');
    assert.equal(expression.toTex(), '\\mathrm{permutations}\\left(2\\right)');
  });

});


text:
layout: feature
title: 'Definite'
shortdef: 'definiteness or state'
udver: '2'
---

## Definite

Definiteness is typically a feature of nouns, adjectives and articles. Its value distinguishes whether we are talking
about something known and concrete, or something general or unknown. It can be marked on definite and indefinite
[articles](../../u/pos/DET), or directly on [nouns](../../u/pos/NOUN), [adjectives](../../u/pos/ADJ) etc.

The Pomak definite article gives only enclitic forms; as an affix of the word on which
it depends syntactically, it forms a single morphological unit with it. Definiteness is realised with three different forms
(-s/-t/-n) depending on the [Deixis]() denoted(see ).

In an NP, the enclitic attaches to either the noun or the first adjective (if adjectives exist).
---please  provide two or three examples and a detailed description of the examples-->
e.g. *kámatnyjen červén trendráfel je zøl da véne* "the nice red roses are wilting".

The Pomak adjective _adín / anná / annó_ "a" is used as the indefinite article and is assigned the tag [DET]().
However, lack of an article is also understood as indefiniteness.

### `Ind`: indefinite

#### Examples

- *srǿšnah annó déte na pótene* "I came across a child in the street"
- *srǿšnah déte na pótene* "I came across a child in the street"

### `Def`: definite

#### Examples

- srǿšnah déteso na pótene da igró_ "I met the boy (who now is close to me or equally close to me and to the addressee)in the street and he was playing"

- srǿšnah déteto na pótene da igró_ "I met the boy (who now is close to the addressee)in the street and he was playing"
- srǿšnah déteno na pótene da igró_ "I met the boy (who now is away from both the speaker and the addressee) in the street and he was playing"


text:
namespace autofill_assistant {

class MockUserModel : public UserModel {
 public:
  MockUserModel();
  ~MockUserModel() override;

  MOCK_METHOD(void,
              SetSelectedCreditCard,
              (std::unique_ptr<autofill::CreditCard> card, UserData* user_data),
              (override));

  MOCK_METHOD(void,
              SetSelectedAutofillProfile,
              (const std::string& profile_name,
               std::unique_ptr<autofill::AutofillProfile> profile,
               UserData* user_data),
              (override));
};

}  // namespace autofill_assistant

#endif  // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_MOCK_USER_MODEL_H_


text:
This is the ansible set up for the podbaby project hosted at https://podbaby.me.

Code for site is at https://github.com/danjac/podbaby.

Setup requires an env.yml file under the "vars" subdirectory. The env.yml file should be installed locally and has the following settings:

```

DB_URL=postgres://postgres:*****@localhost:5432/my_db_name?sslmode=disable
GOOGLE_ANALYTICS_ID=UA-******
MAIL_ADDR=smtp.gmail.com:465
MAIL_HOST=smtp.gmail.com
MAIL_USER=**********
MAIL_PASSWORD=**********
SECRET_KEY=s0m3Seekr1t!
SECURE_COOKIE_KEY=****************

```


text:
export DEBIAN_FRONTEND noninteractive

## Update source
sudo apt-get -y update

## Install dependencies
sudo apt-get install -y build-essential software-properties-common git \
  virtualenv pandoc python-setuptools python-dev locales locales-all
sudo easy_install pip
sudo pip install --upgrade setuptools virtualenv mock ipython_genutils \
  pytest traitlets tox

## Clone code
git clone https://github.com/Pylons/pyramid_debugtoolbar

## Build and Install
cd pyramid_debugtoolbar
sudo python setup.py install
export TOXENV=py27
virtualenv -p python2 --system-site-packages env2
/bin/bash -c "source env2/bin/activate"
sudo  pip install tox
sudo tox


text:
function onMapClick(e) {
    popup
        .setLatLng(e.latlng)
        .setContent("LatLon : " + e.latlng.lat + ", "+e.latlng.lng)
        .openOn(map);
}

function init_date(sdate, sheure){
    r_date=""
    d= new Date()
    if (!sdate || sdate==""){
        if (d.getDate()<10) { r_date+= "0"}
        r_date+= d.getDate()+"/";
        if (d.getMonth()<9) { r_date+= "0"}
        r_date+= (d.getMonth()+1)+"/";
        r_date+= d.getFullYear()
    } else {r_date=sdate;}
    document.getElementById("date").value=r_date;

    r_heure=""
    if (!sheure || sheure==""){
        h=d.getHours();
        m=d.getMinutes();
        r_heure+= (h<10)?"0"+h:h;
        r_heure+= "h";
        r_heure+= (m<10)?"0"+m:m;
        //r_heure+= "00";
    } else {r_heure=sheure;}
    document.getElementById("heure").value=r_heure;
}

function getNetworkSelect(){
    callNavitiaJS(ws_name, 'coverage/'+t["coverage"]+'/networks/?count=1000', '', function(response){
        first_id = "";
        selected_exists = false;
        var str="<select name='network_id' id='network_id' onchange='document.forms[0].submit()'>"
        for (var n in response.networks) {
            var network = response.networks[n];
            if (first_id == "") {first_id = network.id;}
            selected = "";
            if ((t["network_id"]) && (t["network_id"]==network.id)) {
                selected_exists = true;
                selected = " selected ";
            }
            str+= "<option " + selected+ " value='"+network.id+"'>" + network.name + "</option>";
        }
        str+="</select>";
        document.getElementById("network_div").innerHTML=str;
        if ( (!t["network_id"]) || (!selected_exists) ){
            //si aucun réseau selectionné : on prend le 1er et on relance la selection de la ligne
            t["network_id"] = first_id;
        }
        getLineSelect();
    });
}

function getLineSelect(){
    if (t["network_id"]) {
        first_id = "";
        selected_exists = false;
        callNavitiaJS(ws_name, 'coverage/'+t["coverage"]+'/networks/'+t["network_id"]+'/lines/?count=1000', '',
            function(response){
                var str="<select name='line_id' id='line_id' onchange='document.forms[0].submit()'>"
                for (var n in response.lines) {
                    var line = response.lines[n];
                    if (first_id == "") {first_id = line.id;}
                    selected = "";
                    if ((t["line_id"]) && (t["line_id"]==line.id)) {
                        selected_exists = true;
                        selected = " selected ";
                    }
                    str+= "<option " + selected+ " value='"+line.id+"'>" + line.code + ' - ' + line.name + "</option>";
                }
                str+="</select>";
                document.getElementById("line_div").innerHTML=str;
                if ( (!t["line_id"]) || (!selected_exists) ){
                    //si aucune ligne selectionné : on prend la 1ere et on relance la selection de la route
                    t["line_id"] = first_id;
                }
                getRouteSelect();
            }
        );
    }
}

function getRouteSelect(){
    if (t["line_id"]) {
        first_id = ""
        selected_exists = false;
        callNavitiaJS(ws_name, 'coverage/'+t["coverage"]+'/networks/'+t["network_id"]+'/lines/' + t["line_id"] + '/routes/?count=1000', '',
            function(response){
                var str="<select name='route_id' id='route_id' onchange='document.forms[0].submit()'>"
                for (var n in response.routes) {
                    var route = response.routes[n];
                    if (first_id == "") {first_id = route.id;}
                    selected = "";
                    if ((t["route_id"]) && (t["route_id"]==route.id)) {
                        selected_exists = true;
                        selected = " selected ";
                    }
                    str+= "<option " + selected+ " value='"+route.id+"'>" + route.name + "</option>";
                }
                str+="</select>";
                document.getElementById("route_div").innerHTML=str;
                if ( (!t["route_id"]) || (!selected_exists) ){
                    //si aucun parcours selectionné : on prend le 1er et on relance l'affichage de la grille
                    t["route_id"] = first_id;
                }
                getRouteSchedule();
            }
        );
    }
}

function getRouteSchedule(){
    url="coverage/"+coverage+"/routes/"+t["route_id"]+"/route_schedules/";
    url+="?from_datetime=" + natural_str_to_iso(
        document.getElementById("date").value,
        document.getElementById("heure").value);
    callNavitiaJS(ws_name, url, '', function(response){
        if (response.route_schedules) {
            schedule = response.route_schedules[0]; //1 seule grille sur un parcours
            show_schedule_html();
        }
    });
}

function show_schedule_html(){
    str="
";
    str+="
";
    str+="
 	";
    for (var i in schedule.table.headers){
        item=schedule.table.headers[i];
        for (var li in item.links){
            link=item.links[li];
            if (link.type=="vehicle_journey") {
                item.vehicle_journey_id=link.id;
            }
        }
        str+="";
        //str+=item.vehicle_journey_id+"
";
        //str+=item.display_informations.direction+"
";
        str+="	";
    }
    str+="
"
    str+="
";
    str+="
";
    for (var i in schedule.table.rows){
        row=schedule.table.rows[i];
        str+="
";
        str+=""+row.stop_point.label.replace(/ /g, " ")+"	";
        for (var j in row.date_times){
            dt=row.date_times[j];
            if (dt.date_time) {
                var myDate = IsoToJsDate(dt.date_time);
                str+=""+formatDate(myDate, "hh:nn:ss")+"	";
            } else {
                str+=" 	"
            }
        }
        str+="
"
    }
    str+="
";
    str+="
";
    document.getElementById("route_schedules_div").innerHTML=str;
}

function route_schedule_onLoad(){
    menu.show_menu("menu_div");
    t=extractUrlParams();

    init_date();

    if (t["date"]) { document.getElementById("date").value=decodeURIComponent(t["date"]);}
    if (t["heure"]) { document.getElementById("heure").value=decodeURIComponent(t["heure"]);}

    getNetworkSelect();

    map = L.map('map-canvas').setView([48.837212, 2.413], 8);
    // add an OpenStreetMap tile layer
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '© OpenStreetMap contributors'
    }).addTo(map);
    map.on('click', onMapClick);

}

var selected = null;
var map;
var popup = L.popup();
var t;
var schedule;


text:
/**
 * This package contains all the unit tests for basic CRUD operations
 * functionality of the Aerospike dataStore.
 */
package org.apache.gora.aerospike.store;


text:
<m-periodpicker v-bind="periodPickerProps"
                @input="updateValue"
                ref="periodpicker"
                :disabled="disabled"
                :convert-to-iso="convertToIso"
                :waiting="waiting"
                :error="error"
                :valid="valid"
                :readonly="readonly"
                :max-width="maxWidth"
                :error-message="errorMessage"
                :valid-message="validMessage"
                :helper-message="helperMessage">
    <m-datepicker :label="labelFrom"
                  :max-width="maxWidth"
                  :hide-internal-error-message="hideInternalErrorMessage"
                  :skip-input-validation="skipInputValidation"
                  :required-marker="requiredMarker"
                  slot="first"
                  slot-scope="{ props, handlers }"
                  v-on="handlers"
                  v-bind="props"></m-datepicker>
    <m-datepicker :label="labelTo"
                  :max-width="maxWidth"
                  :hide-internal-error-message="hideInternalErrorMessage"
                  :skip-input-validation="skipInputValidation"
                  :required-marker="requiredMarker"
                  slot="second"
                  slot-scope="{ props, handlers }"
                  v-on="handlers"
                  v-bind="props"></m-datepicker>
</m-periodpicker>


text:
package net.ros.client.gui;

import net.ros.common.card.FilterCard;
import net.voxelindustry.brokkgui.element.GuiButton;
import net.voxelindustry.brokkgui.event.ActionEvent;
import net.voxelindustry.brokkgui.panel.GuiAbsolutePane;
import net.voxelindustry.brokkgui.wrapper.elements.ItemStackView;
import net.voxelindustry.hermod.EventHandler;

public class FilterViewPane extends GuiAbsolutePane
{
    private GuiButton       whitelist;
    private ItemStackView[] views;

    public FilterViewPane(EventHandler<ActionEvent> buttonAction)
    {
        this.setWidth(56);
        this.setHeight(70);

        this.whitelist = new GuiButton("WHITELIST");
        whitelist.setOnActionEvent(buttonAction);
        whitelist.setWidth(56);
        whitelist.setHeight(15);
        this.addChild(whitelist, 0, 55);

        this.views = new ItemStackView[9];
    }

    public void setWhitelist(boolean whitelist)
    {
        if (whitelist)
        {
            this.whitelist.getLabel().setText("WHITELIST");
            this.getStyleClass().replace("blacklist", "whitelist");
        }
        else
        {
            this.whitelist.getLabel().setText("BLACKLIST");
            this.getStyleClass().replace("whitelist", "blacklist");
        }
    }

    public void refreshSlots(FilterCard card)
    {
        for (int i = 0; i < 9; i++)
        {
            if (this.views[i] == null)
            {
                ItemStackView view = new ItemStackView(card.getFilters()[i]);
                view.setWidth(18);
                view.setHeight(18);
                view.setItemTooltip(true);
                this.views[i] = view;
                this.addChild(view, 1 + 18 * (i % 3), 1 + 18 * (i / 3));
            }
            this.views[i].setItemStack(card.getFilters()[i]);
        }
    }
}


text:
(function() {
  var app;

  app = angular.module('gymsym');

  app.directive('gymTime', function() {
    return {
      restrict: 'E',
      replace: true,
      template: '
Time: {{getTime()}}
',
      controller: 'GymTimeController',
      scope: {
        time: '='
      },
      link: function(scope, iElement, iAttrs, controller) {}
    };
  });

  app.controller('GymTimeController', function($scope) {
    $scope.startString = '2000-01-01T00:00:00Z';
    $scope.lastComputedTime = null;
    $scope.getTime = function() {
      if (!$scope.displayIsUpToDate()) {
        $scope.displayString = moment($scope.startString).add($scope.time, 's').zone('+0').format('HH:mm:ss');
        $scope.lastComputedTime = $scope.time;
      }
      return $scope.displayString;
    };
    return $scope.displayIsUpToDate = function() {
      return $scope.lastComputedTime && $scope.lastComputedTime === $scope.time;
    };
  });

}).call(this);


text:
using System;

namespace FlappyBlog.Domain.Models
{
    public partial class User : DomainObject
    {
        public virtual bool Active { get; set; }

        public virtual string Email { get; set; }

        public virtual string NickName { get; set; }

        public virtual string Password { get; set; }

        public virtual string HomePage { get; set; }

        public virtual string PictrueUrl { get; set; }

        public virtual string Description { get; set; }
    }

    public partial class User
    {
        public virtual Role Role { get; set; }

        public virtual int PostCount { get; set; }

        public virtual int CommentCount { get; set; }
    }
}


text:
using Util.Ui.Angular;
using Util.Ui.Angular.Renders;
using Util.Ui.Builders;
using Util.Ui.Configs;
using Util.Ui.Material.Icons.Builders;
using Util.Ui.Material.Tabs.Builders;

namespace Util.Ui.Material.Tabs.Renders {
    /// <summary>
    /// 链接选项卡渲染器
    /// </summary>
    public class TabLinkRender : AngularRenderBase {
        /// <summary>
        /// 配置
        /// </summary>
        private readonly IConfig _config;

        /// <summary>
        /// 初始化链接选项卡渲染器
        /// </summary>
        /// <param name="config">配置</param>
        public TabLinkRender( IConfig config ) : base( config ) {
            _config = config;
        }

        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder() {
            var builder = new TabLinkBuilder();
            Config( builder );
            return builder;
        }

        /// <summary>
        /// 配置
        /// </summary>
        protected void Config( TabLinkBuilder builder ) {
            ConfigId( builder );
            builder.ConfigRouterLink( _config );
            ConfigLink( builder );
            ConfigCaption( builder );
            ConfigDisabled( builder );
        }

        /// <summary>
        /// 配置路由链接
        /// </summary>
        private void ConfigLink( TagBuilder builder ) {
            builder.AddAttribute( "routerLink", _config.GetValue( UiConst.Link ) );
            builder.AddAttribute( "[routerLink]", _config.GetValue( AngularConst.BindLink ) );
        }

        /// <summary>
        /// 配置标题
        /// </summary>
        private void ConfigCaption( TagBuilder builder ) {
            ConfigMaterialIcon( builder );
            ConfigFontAwesomeIcon( builder );
            ConfigLabel( builder );
        }

        /// <summary>
        /// 配置Material图标
        /// </summary>
        private void ConfigMaterialIcon( TagBuilder builder ) {
            if( _config.Contains( UiConst.MaterialIcon ) == false )
                return;
            var iconBuilder = new MaterialIconBuilder();
            iconBuilder.SetIcon( _config );
            builder.AppendContent( iconBuilder );
        }

        /// <summary>
        /// 配置FontAwesome图标
        /// </summary>
        private void ConfigFontAwesomeIcon( TagBuilder builder ) {
            if( _config.Contains( UiConst.FontAwesomeIcon ) == false )
                return;
            var iconBuilder = new FontAwesomeIconBuilder();
            iconBuilder.SetIcon( _config );
            builder.AppendContent( iconBuilder );
        }

        /// <summary>
        /// 配置标签
        /// </summary>
        private void ConfigLabel( TagBuilder builder ) {
            if( _config.Contains( UiConst.Label ) == false )
                return;
            builder.AppendContent( _config.GetValue( UiConst.Label ) );
        }

        /// <summary>
        /// 配置禁用
        /// </summary>
        private void ConfigDisabled( TagBuilder builder ) {
            builder.AddAttribute( "[disabled]", _config.GetBoolValue( UiConst.Disabled ) );
        }
    }
}


text:
// Chemfiles, a modern library for chemistry file reading and writing
// Copyright (C) Guillaume Fraux and contributors -- BSD license

#include <chemfiles.h>
#include <stdlib.h>

int main() {
    // [example]
    CHFL_CELL* cell = chfl_cell((chfl_vector_t){10, 10, 10});

    if (cell == NULL) {
        /* handle error */
    }

    chfl_cell_free(cell);
    // [example]
    return 0;
}


text:
package app

import (
	"fmt"
	"reflect"
	"testing"

	kapi "k8s.io/kubernetes/pkg/api"
	"k8s.io/kubernetes/pkg/runtime"
	"k8s.io/kubernetes/pkg/util/diff"
	"k8s.io/kubernetes/pkg/util/intstr"

	deployapi "github.com/openshift/origin/pkg/deploy/api"
	imageapi "github.com/openshift/origin/pkg/image/api"
)

type portDesc struct {
	port     int
	protocol string
}

type containerDesc struct {
	name  string
	ports []portDesc
}

func fakeDeploymentConfig(name string, containers ...containerDesc) *deployapi.DeploymentConfig {
	specContainers := []kapi.Container{}
	for _, c := range containers {
		container := kapi.Container{
			Name: c.name,
		}

		container.Ports = []kapi.ContainerPort{}
		for _, p := range c.ports {
			container.Ports = append(container.Ports, kapi.ContainerPort{
				Name:          fmt.Sprintf("port-%d-%s", p.port, p.protocol),
				ContainerPort: int32(p.port),
				Protocol:      kapi.Protocol(p.protocol),
			})
		}

		specContainers = append(specContainers, container)
	}
	return &deployapi.DeploymentConfig{
		ObjectMeta: kapi.ObjectMeta{
			Name: name,
		},
		Spec: deployapi.DeploymentConfigSpec{
			Replicas: 1,
			Selector: map[string]string{"name": "test"},
			Template: &kapi.PodTemplateSpec{
				Spec: kapi.PodSpec{
					Containers: specContainers,
				},
			},
		},
	}
}

func expectedService(name string, ports ...portDesc) *kapi.Service {
	servicePorts := []kapi.ServicePort{}
	for _, p := range ports {
		servicePorts = append(servicePorts, kapi.ServicePort{
			// Name is derived purely from the port and protocol, ignoring the container port name
			Name:       fmt.Sprintf("%d-%s", p.port, p.protocol),
			Port:       int32(p.port),
			Protocol:   kapi.Protocol(p.protocol),
			TargetPort: intstr.FromInt(p.port),
		})
	}

	return &kapi.Service{
		ObjectMeta: kapi.ObjectMeta{
			Name: name,
		},
		Spec: kapi.ServiceSpec{
			Selector: map[string]string{"name": "test"},
			Ports:    servicePorts,
		},
	}
}

func getServices(objects Objects) Objects {
	result := Objects{}
	for _, obj := range objects {
		if _, isSvc := obj.(*kapi.Service); isSvc {
			result = append(result, obj)
		}
	}
	return result
}

func objsToString(objs Objects) string {
	result := "Objects{"
	for _, obj := range objs {
		result += fmt.Sprintf("\t%#v\n", obj)

	}
	result += "}"
	return result
}

func TestAcceptUnique(t *testing.T) {
	is := func(name, ns string) *imageapi.ImageStream {
		obj := &imageapi.ImageStream{}
		obj.Name = name
		obj.Namespace = ns
		return obj
	}
	dc := func(name, ns string) *deployapi.DeploymentConfig {
		obj := &deployapi.DeploymentConfig{}
		obj.Name = name
		obj.Namespace = ns
		return obj
	}
	objs := func(list ...runtime.Object) []runtime.Object {
		return list
	}
	tests := []struct {
		name   string
		objs   []runtime.Object
		expect int
	}{
		{
			name:   "same name, different kind, different ns",
			objs:   objs(is("aaa", "ns1"), is("aaa", "ns2"), dc("aaa", "ns1")),
			expect: 3,
		},
		{
			name:   "dup name, empty ns",
			objs:   objs(is("aaa", ""), is("aaa", "")),
			expect: 1,
		},
		{
			name:   "different name, empty ns",
			objs:   objs(is("aaa", ""), is("bbb", ""), dc("aaa", "")),
			expect: 3,
		},
	}
	for _, tc := range tests {
		au := NewAcceptUnique(kapi.Scheme)
		cnt := 0
		for _, obj := range tc.objs {
			if au.Accept(obj) {
				cnt++
			}
		}
		if cnt != tc.expect {
			t.Errorf("%s: did not get expected number of objects. Expected: %d, Got: %d", tc.name, tc.expect, cnt)
		}
	}
}

func TestAddServices(t *testing.T) {
	tests := []struct {
		name             string
		input            Objects
		firstOnly        bool
		expectedServices Objects
	}{
		{
			name: "single port",
			input: Objects{
				fakeDeploymentConfig("singleport", containerDesc{"test", []portDesc{{100, "tcp"}}}),
			},
			expectedServices: Objects{
				expectedService("singleport", portDesc{100, "tcp"}),
			},
		},
		{
			name: "multiple containers",
			input: Objects{
				fakeDeploymentConfig("multicontainer",
					containerDesc{"test1", []portDesc{{100, "tcp"}}},
					containerDesc{"test2", []portDesc{{200, "udp"}}},
				),
			},
			expectedServices: Objects{
				expectedService("multicontainer", portDesc{100, "tcp"}, portDesc{200, "udp"}),
			},
		},
		{
			name: "duplicate ports",
			input: Objects{
				fakeDeploymentConfig("dupports",
					containerDesc{"test1", []portDesc{{80, "tcp"}, {25, "tcp"}}},
					containerDesc{"test2", []portDesc{{80, "tcp"}}},
				),
			},
			expectedServices: Objects{
				expectedService("dupports", portDesc{25, "tcp"}, portDesc{80, "tcp"}),
			},
		},
		{
			name: "multiple deployment configs",
			input: Objects{
				fakeDeploymentConfig("multidc1",
					containerDesc{"test1", []portDesc{{100, "tcp"}, {200, "udp"}}},
					containerDesc{"test2", []portDesc{{300, "tcp"}}},
				),
				fakeDeploymentConfig("multidc2",
					containerDesc{"dc2_test1", []portDesc{{300, "tcp"}}},
					containerDesc{"dc2_test2", []portDesc{{200, "udp"}, {300, "tcp"}}},
				),
			},
			expectedServices: Objects{
				expectedService("multidc1", portDesc{100, "tcp"}, portDesc{200, "udp"}, portDesc{300, "tcp"}),
				expectedService("multidc2", portDesc{200, "udp"}, portDesc{300, "tcp"}),
			},
		},
		{
			name: "first only",
			input: Objects{
				fakeDeploymentConfig("firstonly",
					containerDesc{"test1", []portDesc{{80, "tcp"}, {25, "tcp"}, {100, "udp"}}},
				),
			},
			expectedServices: Objects{
				expectedService("firstonly", portDesc{25, "tcp"}),
			},
			firstOnly: true,
		},
	}

	for _, test := range tests {
		output := AddServices(test.input, test.firstOnly)
		services := getServices(output)
		if !reflect.DeepEqual(services, test.expectedServices) {
			t.Errorf("%s: did not get expected output: %s",
				test.name, diff.ObjectGoPrintDiff(test.expectedServices, services))
		}
	}
}


text:
package cmd

import (
	"log"

	"github.com/heraware/cryptodev/clients"
	"github.com/spf13/cobra"
)

// zenCmd represents the bitcoin command
var zenCmd = &cobra.Command{
	Use:   "zen",
	Short: "Run RPC command over ZenCash Node (getinfo, getnewaddress, listaccounts)",
	Run: func(cmd *cobra.Command, args []string) {
		bitcoinClient := clients.NewBitcoinClient(26001)

		if len(args) == 0 {
			log.Fatalln(`Action not provided.
Actions list:
 - getinfo
 - getnewaddress <ACCOUNT>
 - listaccounts
 - newblocks <AMOUNT OF NEW BLOCKS>
 - send <ADDRESS> <AMOUNT OF BTC>`)
		}
		runAction(&args, bitcoinClient)
	},
}

func init() {
	RootCmd.AddCommand(zenCmd)
}


text:
'use strict';

const siteUtils = require('../site-utils');
const logger = require('../logger')();

class <%= upperCaseSite %>Site {
  constructor(uri) {
    if (!<%= upperCaseSite %>Site.isSite(uri)) {
      throw new Error('invalid uri for <%= upperCaseSite %>: %s', uri);
    }

    this._uri = uri;
  }

  getURIForPageData() {
    return this._uri;
  }

  isJSON() {
    return <%= isJSON %>;
  }

  findPriceOnPage($) {
    // the various ways we can find the price
    const selectors = [
      '',
    ];

    // find the price on the page
    const priceString = siteUtils.findContentOnPage($, selectors);

    // were we successful?
    if (!priceString) {
      logger.error('price not found on <%= upperCaseSite %> page, uri: %s', this._uri);
      return -1;
    }

    // process the price string
    const price = siteUtils.processPrice(priceString);

    return price;
  }

  findCategoryOnPage($) {
    // TODO find the category
    const category = siteUtils.categories.OTHER;

    logger.log('category: %s', category);

    return category;
  }

  findNameOnPage($, category) {
    // the various ways we can find the name
    const selectors = [
      '',
    ];

    // use the selectors to find the name on the page
    const name = siteUtils.findContentOnPage($, selectors);

    // were we successful?
    if (!name) {
      logger.error('name not found on <%= upperCaseSite %> page, uri: %s', this._uri);
      return null;
    }

    logger.log('name: %s', name);

    return name;
  }

  static isSite(uri) {
    if (uri.indexOf('<%= siteURI %>') > -1) {
      return true;
    } else {
      return false;
    }
  }
}

module.exports = <%= upperCaseSite %>Site;


text:
from direct.distributed.DistributedObject import DistributedObject
from toontown.catalog.CatalogItemList import CatalogItemList
import time

class CatalogManager(DistributedObject):
    notify = directNotify.newCategory('CatalogManager')
    neverDisable = 1

    def __init__(self, cr):
        DistributedObject.__init__(self, cr)

        self.popularItems = None

    def generate(self):
        if base.cr.catalogManager != None:
            base.cr.catalogManager.delete()
        base.cr.catalogManager = self
        DistributedObject.generate(self)
        if hasattr(base.localAvatar, 'catalogScheduleNextTime') and base.localAvatar.catalogScheduleNextTime == 0:
            self.d_startCatalog()

    def disable(self):
        base.cr.catalogManager = None
        DistributedObject.disable(self)

    def delete(self):
        base.cr.catalogManager = None
        DistributedObject.delete(self)

    def d_startCatalog(self):
        self.sendUpdate('startCatalog')

    def fetchPopularItems(self):
        self.sendUpdate('fetchPopularItems')

    def setPopularItems(self, popularItems):
        self.popularItems = CatalogItemList(popularItems)
        messenger.send('PopularItemsSet')


text:
<#

.SYNOPSIS
This script deletes all Activities with status "Pending"

.DESCRIPTION
The script gets all Activities with status "Pending" and deletes them after promting the user. Be careful when using this script!

.EXAMPLE
.\Delete-PendingActivities.ps1 -ComputerName 'SM02' -Verbose

.NOTES
SMLets have to be available on the computer where the script is run.

.LINK
https://blog.jhnr.ch

#>

[CmdletBinding()]

Param
(
    [Parameter(Mandatory=$false)]
    [String]$ComputerName = 'localhost'
)

#region Import modules

Write-Verbose "Loading SMLets module"

Try
{
    if (!(Get-Module SMLets))
    {
        Import-Module SMLets
    }
}
Catch
{
    Throw "Loading SMLets module failed"
}

#endregion

Try
{
    #region Get objects

    $EnumGuid = (Get-SCSMEnumeration -Name ActivityStatusEnum.Ready -ComputerName $ComputerName).Id

    $ActivityArray = @()
    $ActivityArray = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Activity$ -ComputerName $ComputerName) -Filter "Status -eq '$EnumGuid'" -ComputerName $ComputerName

    #endregion

    #region Prompt user to continue
    if($($ActivityArray.Count) -gt 0)
    {
        $ActivityArray

        $Title = "Found $($ActivityArray.Count) activite(s) with status 'Pending' to be deleted"
        $Prompt = 'Should I [A]bort or [C]ontinue?'
        $Abort = New-Object System.Management.Automation.Host.ChoiceDescription '&Abort','Aborts the operation'
        $Continue = New-Object System.Management.Automation.Host.ChoiceDescription '&Continue','Continues the operation'
        $Options = [System.Management.Automation.Host.ChoiceDescription[]] ($Abort,$Continue)

        $Choice = $Host.UI.PromptForChoice($Title,$Prompt,$Options,0)

        #endregion

        if($Choice -eq 1)
        {
            Write-Output "Deleting $($ActivityArray.Count) activitie(s). This could take some time..."
            Foreach($Activity in $ActivityArray)
            {
                Remove-SCSMObject -SMObject $Activity –Force  -ComputerName $ComputerName
                Write-Verbose "Deleted Activity $($Activity.DisplayName)"
            }
            Write-Output "*** Finished deleting $($ActivityArray.Count) activitie(s) ***"
        }
        else
        {
            Write-Warning "Operation aborted, no activities deleted"
        }
    }
    else
    {
        Write-Warning "No activities found with status 'Pending'"
    }
}

Catch
{
    Write-Error "$($_.Exception.Message)"
}

Finally
{
    # Remove SMLets module
    Write-Verbose "Removing SMLets module"

    if ((Get-Module SMLets))
    {
        Remove-Module SMLets
    }
}


text:
from starlette.applications import Starlette
from starlette.routing import Mount
from starlette.staticfiles import StaticFiles

ROUTES = [
    Mount("/", app=StaticFiles(directory="static"), name="static"),
]

APP = Starlette(routes=ROUTES)


text:
This template allows you to extend an existing single VNET environment to a Multi-VNET environment that extends across two datacenter regions using VNET-to-VNET gateways

This template extends an existing single VNET environment to a Multi-VNET environment by deploying these Azure resources:

+ Second VNET in a different Azure datacenter region
+ VNET gateways on existing and second VNET
+ VNET gateway connections to establish a routable VNET-to-VNET connection between existing and second VNET

## Special Notes

To be successful in extending to a Multi-VNET configuration using this template, pay particular attention to these special items:

+ Use the resource group of the existing VNET for this template deployment
+ Prior to running this template deployment, create a subnet named "GatewaySubnet" on the existing VNET with a minimum /29 address prefix

## Template Parameters

Modify parameters file to change default values.


text:
package androidx.camera.core.internal;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.camera.core.impl.ReadableConfig;

import java.util.concurrent.Executor;

/**
 * Configuration containing options pertaining to threads used by the configured object.
 */
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public interface ThreadConfig extends ReadableConfig {

    // Option Declarations:
    // *********************************************************************************************

    /**
     * Option: camerax.core.thread.backgroundExecutor
     */
    Option<Executor> OPTION_BACKGROUND_EXECUTOR =
            Option.create("camerax.core.thread.backgroundExecutor", Executor.class);

    // *********************************************************************************************

    /**
     * Returns the executor that will be used for background tasks.
     *
     * @param valueIfMissing The value to return if this configuration option has not been set.
     * @return The stored value or valueIfMissing if the value does not exist in this
     * configuration.
     */
    @Nullable
    default Executor getBackgroundExecutor(@Nullable Executor valueIfMissing) {
        return retrieveOption(OPTION_BACKGROUND_EXECUTOR, valueIfMissing);
    }

    /**
     * Returns the executor that will be used for background tasks.
     *
     * @return The stored value, if it exists in this configuration.
     * @throws IllegalArgumentException if the option does not exist in this configuration.
     */
    @NonNull
    default Executor getBackgroundExecutor() {
        return retrieveOption(OPTION_BACKGROUND_EXECUTOR);
    }

    /**
     * Builder for a {@link ThreadConfig}.
     *
     * @param  The top level builder type for which this builder is composed with.
     */
    interface Builder {

        /**
         * Sets the default executor that will be used for background tasks.
         *
         * @param executor The executor which will be used for background tasks.
         * @return the current Builder.
         */
        @NonNull
        B setBackgroundExecutor(@NonNull Executor executor);
    }
}


text:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
SERVICE="Xvfb"

DIRECTORY="/opt/dockseldon/"

function start_mitm()
{
    # Start the MITM process

    if [ -z "$HTTP_PROXY" ]
    then
        echo "mitmdump -q -s './script_mitm.py -browser $1 -url $2 -server $3' &"
        mitmdump -q -s "./script_mitm.py -browser $1 -url $2 -server $3" &
    else
        echo "mitmdump -U $HTTP_PROXY -q -s './script_mitm.py -browser $1 -url $2 -server $3' &"
        mitmdump -U $HTTP_PROXY -q -s "./script_mitm.py -browser $1 -url $2 -server $3" &
    fi

    export mitmpid=$!

    echo "mitmpid: $mitmpid"
}

function stop_mitm()
{
    # Stop the MITM process
    echo "kill $mitmpid"
    kill $mitmpid
    # kill Xvfb if
    if P=$(pgrep $SERVICE)
    then
        echo "$SERVICE is running, PID is $P"
        kill `pgrep $SERVICE`
    fi
}

function getlocal_ipaddress()
{
    IP_address=$(ip route |awk '$1 !~/default/ { print $NF}')
    echo $IP_address
}

function getpublic_ipaddress()
{
    if [ -z "$HTTP_PROXY" ]
    then
        IP_address=$(curl -s ipinfo.io/ip)
    else
        IP_address=$(curl -s -x $HTTP_PROXY ipinfo.io/ip)
    fi

    echo $IP_address
}

function get_ipdns()
{
    list_ipdns=$(cat /etc/resolv.conf | awk '
    BEGIN { result="" }
    $1 ~ /nameserver/ {
    if ( result !="" ){
        result = result ";" $2;
    } else {
        result = $2;
    }
    }
    END { print result }')

    echo $list_ipdns
}

function get_timestamp()
{
    timestamp=$(date +%s)
    echo $timestamp
}

function get_uptime()
{
    uptime=$(stat -c %Z /proc/)
    echo $uptime
}

function get_macaddress()
{
    interface=$(ip route show default | awk '/default/ {print $5}')
    macaddress=$(cat /sys/class/net/$interface/address)
    echo $macaddress
}

function read_file()
{
    # echo "$curl_result"
    # echo "IFS=';' read -r -a array <<< \"$1\""
    # IFS=';' read -r -a array <<< "$1"

    # urls="${array[0]}";
    # browser="${array[1]}";

    while IFS= read -r url &&
        IFS= read -r browser; do
        # echo "$url"
        # echo "$browser"

        # Start the MITM process
        server="$SERVER/cdpweather/addhar.php"
        start_mitm $browser $url $server

        # if P=$(pgrep $SERVICE)
        # then
            # echo "$SERVICE is running, PID is $P"
        # else
            # echo "$SERVICE is not running"
            # Xvfb :99 &
            # export DISPLAY=:99
        # fi

        # Start the Selenium process
        # Xvfb -a python3 ./browser.py $browser $url #without display
        python3 ./browser.py $browser $url #without display

        # Wait the send process of Selenium
        sleep 10

        # Stop the MITM process
        stop_mitm

        # Wait the send process of Selenium
        sleep 10
    done < <( jq -r '.[] | (.url, .browser)' <<< $curl_result)

}

function run()
{
    cd $DIRECTORY

    data="name=$HOSTNAME"
    data="$data&intip=$(getlocal_ipaddress)"
    data="$data&extip=$(getpublic_ipaddress)"
    data="$data&dns=$(get_ipdns)"
    data="$data&timestamp=$(get_timestamp)"
    data="$data&uptime=$(get_uptime)"
    data="$data&macaddress=$(get_macaddress)"
    data="$data&version=1.0"

    export curl_result=""
    # echo "curl --silent --data $data $SERVER/cdpweatherapi/geturls.php"
    if [ -z "$HTTP_PROXY" ]
    then
        curl_result=$(curl --silent --insecure --data $data  $SERVER/cdpweather/geturls.php)
    else
        curl_result=$(curl --silent --insecure --proxy $HTTP_PROXY --data $data  $SERVER/cdpweather/geturls.php)
    fi

    curl_result=$(echo $curl_result | sed "s/\\\//g"| python3 -mjson.tool)

    # echo $curl_result
    # [ { "url": "https://github.com", "browser": "chrome" } ]

    if [ "$curl_result" != "" ]
    then
        read_file
    fi
}

# Start the Main Process

run


text:
package types

type GroupType int

const (
	// Group type where any role can be selected, and multiple can be selected
	GroupTypeAny = 1
	// Group type where only one role can be selected
	GroupTypeExclusive = 2
	// Same as the exclusive group, but can't be removed
	GroupTypeExclusiveNoRemove = 3
	// Same as the exclusive group, but will prevent changing if one of the roles is present
	GroupTypeNoMultiples = 4

	OptionsForGroupType = "ANY, EXC, ENR, NOM"
)

type RoleGroup struct {
	Id       int
	ServerId int
	Name     string
	Type     GroupType
}


text:
ACE-Research
============

[The ADAPTIVE Communication Environment (ACE(TM))] (http://www.cs.wustl.edu/~schmidt/ACE.html) research

Build
-
<pre>
cmake .
make
</pre>