text:
package com.intellij.openapi.editor.impl.view;

import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.ex.PrioritizedDocumentListener;
import com.intellij.openapi.editor.impl.EditorDocumentPriorities;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/**
 * Caches information allowing faster offset<->logicalPosition conversions even for long lines.
 * Requests for conversion can be made from under read action, document changes and cache invalidation should be done in EDT.
 */
@SuppressWarnings("SynchronizeOnThis")
class LogicalPositionCache implements PrioritizedDocumentListener, Disposable, Dumpable {
  private final Document myDocument;
  private final EditorView myView;
  private ArrayList<LineData> myLines = new ArrayList<>();
  private int myTabSize = -1;
  private int myDocumentChangeOldEndLine;

  LogicalPositionCache(EditorView view) {
    myView = view;
    myDocument = view.getEditor().getDocument();
    myDocument.addDocumentListener(this, this);
  }

  @Override
  public int getPriority() {
    return EditorDocumentPriorities.LOGICAL_POSITION_CACHE;
  }

  @Override
  public void beforeDocumentChange(DocumentEvent event) {
    myDocumentChangeOldEndLine = getAdjustedLineNumber(event.getOffset() + event.getOldLength());
  }

  @Override
  public void documentChanged(DocumentEvent event) {
    int startLine = myDocument.getLineNumber(event.getOffset());
    int newEndLine = getAdjustedLineNumber(event.getOffset() + event.getNewLength());
    invalidateLines(startLine, myDocumentChangeOldEndLine, newEndLine, CharArrayUtil.indexOf(event.getNewFragment(), "\t", 0) == -1);
  }

  synchronized void reset(boolean force) {
    checkDisposed();
    int oldTabSize = myTabSize;
    myTabSize = myView.getTabSize();
    if (force || oldTabSize != myTabSize) {
      invalidateLines(0, myLines.size() - 1, myDocument.getLineCount() - 1, !force && myLines.size() == myDocument.getLineCount());
    }
  }

  @NotNull
  synchronized LogicalPosition offsetToLogicalPosition(int offset) {
    int textLength = myDocument.getTextLength();
    if (offset <= 0 || textLength == 0) {
      return new LogicalPosition(0, 0);
    }
    offset = Math.min(offset, textLength);
    int line = myDocument.getLineNumber(offset);
    LineData lineData = getLineInfo(line);
    return new LogicalPosition(line, lineData.offsetToLogicalColumn(myDocument, line, myTabSize, offset));
  }

  synchronized int offsetToLogicalColumn(int line, int intraLineOffset) {
    if (line < 0 || line >= myDocument.getLineCount()) return 0;
    LineData lineData = getLineInfo(line);
    return lineData.offsetToLogicalColumn(myDocument, line, myTabSize, myDocument.getLineStartOffset(line) + intraLineOffset);
  }

  synchronized int logicalPositionToOffset(@NotNull LogicalPosition pos) {
    int line = pos.line;
    if (line >= myDocument.getLineCount()) return myDocument.getTextLength();
    LineData lineData = getLineInfo(line);
    return lineData.logicalColumnToOffset(myDocument, line, myTabSize, pos.column);
  }

  private int getAdjustedLineNumber(int offset) {
    return myDocument.getTextLength() == 0 ? -1 : myDocument.getLineNumber(offset);
  }

  private synchronized void invalidateLines(int startLine, int oldEndLine, int newEndLine, boolean preserveTrivialLines) {
    checkDisposed();
    if (preserveTrivialLines) {
      for (int line = startLine; line <= oldEndLine; line++) {
        LineData data = myLines.get(line);
        if (data == null || data.columnCache != null) {
          preserveTrivialLines = false;
          break;
        }
      }
    }
    if (!preserveTrivialLines) {
      int endLine = Math.min(oldEndLine, newEndLine);
      for (int line = startLine; line <= endLine; line++) {
        myLines.set(line, null);
      }
    }
    if (oldEndLine < newEndLine) {
      myLines.addAll(oldEndLine + 1, Collections.nCopies(newEndLine - oldEndLine, preserveTrivialLines ? LineData.TRIVIAL : null));
    } else if (oldEndLine > newEndLine) {
      myLines.subList(newEndLine + 1, oldEndLine + 1).clear();
    }
  }

  @NotNull
  private LineData getLineInfo(int line) {
    checkDisposed();
    LineData result = myLines.get(line);
    if (result == null) {
      result = LineData.create(myDocument, line, myTabSize);
      myLines.set(line, result);
    }
    return result;
  }

  @Override
  public synchronized void dispose() {
    myLines = null;
  }

  private void checkDisposed() {
    if (myLines == null) myView.getEditor().throwDisposalError("Editor is already disposed");
  }

  synchronized void validateState() {
    int lineCount = myDocument.getLineCount();
    int cacheSize = myLines.size();
    if (cacheSize != lineCount) throw new IllegalStateException("Line count: " + lineCount + ", cache size: " + cacheSize);
    int tabSize = myView.getTabSize();
    for (int i = 0; i < cacheSize; i++) {
      LineData data = myLines.get(i);
      if (data != null) {
        LineData actual = LineData.create(myDocument, i, tabSize);
        if (!Arrays.equals(data.columnCache, actual.columnCache)) throw new IllegalStateException("Wrong cache state at line " + i);
      }
    }
  }

  @NotNull
  @Override
  public String dumpState() {
    try {
      validateState();
      return "valid";
    }
    catch (Exception e) {
      return "invalid (" + e.getMessage() + ")";
    }
  }

  private static class LineData {
    private static final LineData TRIVIAL = new LineData(null);
    private static final int CACHE_FREQUENCY = 1024; // logical column will be cached for each CACHE_FREQUENCY-th character on the line

    private final int[] columnCache;

    private LineData(int[] columnData) {
      columnCache = columnData;
    }

    private static LineData create(@NotNull Document document, int line, int tabSize) {
      int start = document.getLineStartOffset(line);
      int end = document.getLineEndOffset(line);
      int cacheSize = (end - start) / CACHE_FREQUENCY;
      int[] cache = new int[cacheSize];
      CharSequence text = document.getImmutableCharSequence();
      int column = 0;
      boolean hasTabs = false;
      for (int i = start; i < end; i++) {
        if (i > start && (i - start) % CACHE_FREQUENCY == 0) {
          cache[(i - start) / CACHE_FREQUENCY - 1] = column;
        }
        if (text.charAt(i) == '\t') {
          column = (column / tabSize + 1) * tabSize;
          hasTabs = true;
        }
        else {
          column++;
        }
      }
      return hasTabs ? new LineData(cache) : TRIVIAL;
    }

    private int offsetToLogicalColumn(@NotNull Document document, int line, int tabSize, int offset) {
      offset = Math.min(offset, document.getLineEndOffset(line));
      int lineStartOffset = document.getLineStartOffset(line);
      int relOffset = offset - lineStartOffset;
      if (columnCache == null) return relOffset;
      int cacheIndex = relOffset / CACHE_FREQUENCY;
      int startOffset = lineStartOffset + cacheIndex * CACHE_FREQUENCY;
      int column = cacheIndex == 0 ? 0 : columnCache[cacheIndex - 1];
      CharSequence text = document.getImmutableCharSequence();
      for (int i = startOffset; i < offset; i++) {
        if (text.charAt(i) == '\t') {
          column = (column / tabSize + 1) * tabSize;
        }
        else {
          column++;
        }
      }
      return column;
    }

    private int logicalColumnToOffset(@NotNull Document document, int line, int tabSize, int logicalColumn) {
      int lineStartOffset = document.getLineStartOffset(line);
      int lineEndOffset = document.getLineEndOffset(line);
      if (columnCache == null) {
        int result = lineStartOffset + logicalColumn;
        return result < 0 || // guarding over overflow
               result > lineEndOffset ? lineEndOffset : result;
      }
      int pos = Arrays.binarySearch(columnCache, logicalColumn);
      if (pos >= 0) return lineStartOffset + (pos + 1) * CACHE_FREQUENCY;
      int startOffset = lineStartOffset + (- pos - 1) * CACHE_FREQUENCY;
      int column = pos == -1 ? 0 : columnCache[- pos - 2];
      CharSequence text = document.getImmutableCharSequence();
      for (int i = startOffset; i < lineEndOffset; i++) {
        if (text.charAt(i) == '\t') {
          column = (column / tabSize + 1) * tabSize;
        }
        else {
          column++;
        }
        if (logicalColumn < column) return i;
      }
      return lineEndOffset;
    }
  }
}


text:
<?php
$servers = $console->getServers();
if (!empty($_COOKIE['filter'])) {
    $visible = explode(',', $_COOKIE['filter']);
} else {
    $visible = array(
        'current-jobs-urgent',
        'current-jobs-ready',
        'current-jobs-reserved',
        'current-jobs-delayed',
        'current-jobs-buried',
        'current-tubes',
        'current-connections',
    );
}
?>
<?php if(!empty($servers)):?>

                name
                <?php foreach($console->getServerStats(reset($servers)) as $key => $item):?>
                    <th class="<?php if(!in_array($key, $visible)) echo 'hide'?>" name="<?php echo $key?>" title="<?php echo $item['description']?>"><?php echo $key?>
                <?php endforeach?>

            <?php foreach($servers as $server):
                    $stats = $console->getServerStats($server);
            ?>

                    <?php if(empty($stats)):?>
                    <?php echo $server?>
                    <?php else:?>
                    <a href="?server=<?php echo $server?>"><?php echo $server?>
                    <?php endif?>
                    <?php foreach($stats as $key => $item):?>
                        <td class="<?php if(!in_array($key, $visible)) echo 'hide'?>" name="<?php echo $key?>"><?php echo htmlspecialchars($item['value'])?>
                    <?php endforeach?>
                    <?php if(empty($stats)):?>
                        <td colspan="<?php echo count($visible)?>" class="row-full">
                    <?php endif?>
                    <a class="btn btn-small" title="Remove from list" href="?action=serversRemove&removeServer=<?php echo $server?>">

            <?php endforeach?>

<?php else:?>

Hello!

        This is Beanstalk console, web-interface for
        simple and fast work queue

        Your servers' list is empty. You could fix it in two ways:

Click the button below to add server just for you and save it in cookies

Edit config.php file and add server for everybody

<?php endif?>

Add server

        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Add server

        <form class="form-horizontal">

                Host

                    <input type="text" id="host" value="localhost">

                Port

                    <input type="text" id="port" value="<?php echo Pheanstalk::DEFAULT_PORT?>">

        </form>

        <button class="btn btn-info">Add server</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>

        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Filter columns

        <form>

                    <?php $i=0; foreach($console->getServerStatsGroups() as $groupName => $fields): $i++;?>
                        <li <?php if($i==1) echo 'class="active"'?>><a href="#<?php echo $groupName?>" data-toggle="tab"><?php echo $groupName?>

                    <?php endforeach?>

                    <?php $i=0; foreach($console->getServerStatsGroups() as $groupName => $fields): $i++;?>
                    <div class="tab-pane <?php if($i==1) echo 'active'?>" id="<?php echo $groupName?>">
                        <?php foreach($fields as $key => $description):?>

                                        <input type="checkbox" name="<?php echo $key?>" <?php if(in_array($key, $visible)) echo 'checked="checked"'?>>
                                        <?php echo $key?>

<?php echo $description?>

                        <?php endforeach?>

                    <?php endforeach?>

        </form>

        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>

redpajama_set_name: RedPajamaGithub


text:
title: FromNode
note: Auto generated by tickdoc

menu:
  kapacitor_013:
    name: From
    identifier: from_node
    weight: 60
    parent: nodes
---

A [FromNode](/kapacitor/v0.13/nodes/from_node/) selects a subset of the data flowing through a [StreamNode.](/kapacitor/v0.13/nodes/stream_node/)
The stream node allows you to select which portion of the stream you want to process.

Example:

```javascript
    stream
        |from()
           .database('mydb')
           .retentionPolicy('myrp')
           .measurement('mymeasurement')
           .where(lambda: "host" =~ /logger\d+/)
        |window()
        ...
```

The above example selects only data points from the database `mydb`
and retention policy `myrp` and measurement `mymeasurement` where
the tag `host` matches the regex `logger\d+`

Index
-----

### Properties

-	[Database](/kapacitor/v0.13/nodes/from_node/#database)
-	[GroupBy](/kapacitor/v0.13/nodes/from_node/#groupby)
-	[Measurement](/kapacitor/v0.13/nodes/from_node/#measurement)
-	[RetentionPolicy](/kapacitor/v0.13/nodes/from_node/#retentionpolicy)
-	[Truncate](/kapacitor/v0.13/nodes/from_node/#truncate)
-	[Where](/kapacitor/v0.13/nodes/from_node/#where)

### Chaining Methods

-	[Alert](/kapacitor/v0.13/nodes/from_node/#alert)
-	[Bottom](/kapacitor/v0.13/nodes/from_node/#bottom)
-	[Count](/kapacitor/v0.13/nodes/from_node/#count)
-	[Deadman](/kapacitor/v0.13/nodes/from_node/#deadman)
-	[Default](/kapacitor/v0.13/nodes/from_node/#default)
-	[Derivative](/kapacitor/v0.13/nodes/from_node/#derivative)
-	[Distinct](/kapacitor/v0.13/nodes/from_node/#distinct)
-	[Elapsed](/kapacitor/v0.13/nodes/from_node/#elapsed)
-	[Eval](/kapacitor/v0.13/nodes/from_node/#eval)
-	[First](/kapacitor/v0.13/nodes/from_node/#first)
-	[From](/kapacitor/v0.13/nodes/from_node/#from)
-	[HttpOut](/kapacitor/v0.13/nodes/from_node/#httpout)
-	[InfluxDBOut](/kapacitor/v0.13/nodes/from_node/#influxdbout)
-	[Join](/kapacitor/v0.13/nodes/from_node/#join)
-	[Last](/kapacitor/v0.13/nodes/from_node/#last)
-	[Log](/kapacitor/v0.13/nodes/from_node/#log)
-	[Max](/kapacitor/v0.13/nodes/from_node/#max)
-	[Mean](/kapacitor/v0.13/nodes/from_node/#mean)
-	[Median](/kapacitor/v0.13/nodes/from_node/#median)
-	[Min](/kapacitor/v0.13/nodes/from_node/#min)
-	[Percentile](/kapacitor/v0.13/nodes/from_node/#percentile)
-	[Sample](/kapacitor/v0.13/nodes/from_node/#sample)
-	[Shift](/kapacitor/v0.13/nodes/from_node/#shift)
-	[Spread](/kapacitor/v0.13/nodes/from_node/#spread)
-	[Stats](/kapacitor/v0.13/nodes/from_node/#stats)
-	[Stddev](/kapacitor/v0.13/nodes/from_node/#stddev)
-	[Sum](/kapacitor/v0.13/nodes/from_node/#sum)
-	[Top](/kapacitor/v0.13/nodes/from_node/#top)
-	[Union](/kapacitor/v0.13/nodes/from_node/#union)
-	[Window](/kapacitor/v0.13/nodes/from_node/#window)

Properties
----------

Property methods modify state on the calling node.
They do not add another node to the pipeline, and always return a reference to the calling node.
Property methods are marked using the `.` operator.

### Database

The database name.
If empty any database will be used.

```javascript
node.database(value string)
```

### GroupBy

Group the data by a set of tags.

Can pass literal * to group by all dimensions.
Example:

```javascript
  stream
      |from()
          .groupBy(*)
```

```javascript
node.groupBy(tag ...interface{})
```

### Measurement

The measurement name
If empty any measurement will be used.

```javascript
node.measurement(value string)
```

### RetentionPolicy

The retention policy name
If empty any retention policy will be used.

```javascript
node.retentionPolicy(value string)
```

### Truncate

Optional duration for truncating timestamps.
Helpful to ensure data points land on specific boundaries
Example:

```javascript
    stream
       |from()
           .measurement('mydata')
           .truncate(1s)
```

All incoming data will be truncated to 1 second resolution.

```javascript
node.truncate(value time.Duration)
```

### Where

Filter the current stream using the given expression.
This expression is a Kapacitor expression. Kapacitor
expressions are a superset of InfluxQL WHERE expressions.
See the [expression](/kapacitor/v0.13/tick/expr/) docs for more information.

Multiple calls to the Where method will `AND` together each expression.

Example:

```javascript
    stream
       |from()
          .where(lambda: condition1)
          .where(lambda: condition2)
```

The above is equivalent to this
Example:

```javascript
    stream
       |from()
          .where(lambda: condition1 AND condition2)
```

NOTE: Becareful to always use `|from` if you want multiple different streams.

Example:

```javascript
  var data = stream
      |from()
          .measurement('cpu')
  var total = data
      .where(lambda: "cpu" == 'cpu-total')
  var others = data
      .where(lambda: "cpu" != 'cpu-total')
```

The example above is equivalent to the example below,
which is obviously not what was intended.

Example:

```javascript
  var data = stream
      |from()
          .measurement('cpu')
          .where(lambda: "cpu" == 'cpu-total' AND "cpu" != 'cpu-total')
  var total = data
  var others = total
```

The example below will create two different streams each selecting
a different subset of the original stream.

Example:

```javascript
  var data = stream
      |from()
          .measurement('cpu')
  var total = stream
      |from()
          .measurement('cpu')
          .where(lambda: "cpu" == 'cpu-total')
  var others = stream
      |from()
          .measurement('cpu')
          .where(lambda: "cpu" != 'cpu-total')
```

If empty then all data points are considered to match.

```javascript
node.where(expression tick.Node)
```

Chaining Methods
----------------

Chaining methods create a new node in the pipeline as a child of the calling node.
They do not modify the calling node.
Chaining methods are marked using the `|` operator.

### Alert

Create an alert node, which can trigger alerts.

```javascript
node|alert()
```

Returns: [AlertNode](/kapacitor/v0.13/nodes/alert_node/)

### Bottom

Select the bottom `num` points for `field` and sort by any extra tags or fields.

```javascript
node|bottom(num int64, field string, fieldsAndTags ...string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Count

Count the number of points.

```javascript
node|count(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Deadman

Helper function for creating an alert on low throughput, aka deadman's switch.

- Threshold -- trigger alert if throughput drops below threshold in points/interval.
- Interval -- how often to check the throughput.
- Expressions -- optional list of expressions to also evaluate. Useful for time of day alerting.

Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |deadman(100.0, 10s)
    //Do normal processing of data
    data...
```

The above is equivalent to this
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |stats(10s)
        |derivative('emitted')
            .unit(10s)
            .nonNegative()
        |alert()
            .id('node \'stream0\' in task \'{{ .TaskName }}\'')
            .message('{{ .ID }} is {{ if eq .Level "OK" }}alive{{ else }}dead{{ end }}: {{ index .Fields "emitted" | printf "%0.3f" }} points/10s.')
            .crit(lamdba: "emitted" <= 100.0)
    //Do normal processing of data
    data...
```

The `id` and `message` alert properties can be configured globally via the 'deadman' configuration section.

Since the [AlertNode](/kapacitor/v0.13/nodes/alert_node/) is the last piece it can be further modified as normal.
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 1s and checked every 10s.
    data
        |deadman(100.0, 10s)
            .slack()
            .channel('#dead_tasks')
    //Do normal processing of data
    data...
```

You can specify additional lambda expressions to further constrain when the deadman's switch is triggered.
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    // Only trigger the alert if the time of day is between 8am-5pm.
    data
        |deadman(100.0, 10s, lambda: hour("time") >= 8 AND hour("time") <= 17)
    //Do normal processing of data
    data...
```

```javascript
node|deadman(threshold float64, interval time.Duration, expr ...tick.Node)
```

Returns: [AlertNode](/kapacitor/v0.13/nodes/alert_node/)

### Default

Create a node that can set defaults for missing tags or fields.

```javascript
node|default()
```

Returns: [DefaultNode](/kapacitor/v0.13/nodes/default_node/)

### Derivative

Create a new node that computes the derivative of adjacent points.

```javascript
node|derivative(field string)
```

Returns: [DerivativeNode](/kapacitor/v0.13/nodes/derivative_node/)

### Distinct

Produce batch of only the distinct points.

```javascript
node|distinct(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Elapsed

Compute the elapsed time between points

```javascript
node|elapsed(field string, unit time.Duration)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Eval

Create an eval node that will evaluate the given transformation function to each data point.
A list of expressions may be provided and will be evaluated in the order they are given
and results of previous expressions are made available to later expressions.

```javascript
node|eval(expressions ...tick.Node)
```

Returns: [EvalNode](/kapacitor/v0.13/nodes/eval_node/)

### First

Select the first point.

```javascript
node|first(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### From

Creates a new stream node that can be further
filtered using the Database, RetentionPolicy, Measurement and Where properties.
From can be called multiple times to create multiple
independent forks of the data stream.

Example:

```javascript
    // Select the 'cpu' measurement from just the database 'mydb'
    // and retention policy 'myrp'.
    var cpu = stream
        |from()
            .database('mydb')
            .retentionPolicy('myrp')
            .measurement('cpu')
    // Select the 'load' measurement from any database and retention policy.
    var load = stream
        |from()
            .measurement('load')
    // Join cpu and load streams and do further processing.
    cpu
        |join(load)
            .as('cpu', 'load')
        ...
```

```javascript
node|from()
```

Returns: [FromNode](/kapacitor/v0.13/nodes/from_node/)

### HttpOut

Create an http output node that caches the most recent data it has received.
The cached data is available at the given endpoint.
The endpoint is the relative path from the API endpoint of the running task.
For example if the task endpoint is at "/api/v1/task/<task_name>" and endpoint is
"top10", then the data can be requested from "/api/v1/task/<task_name>/top10".

```javascript
node|httpOut(endpoint string)
```

Returns: [HTTPOutNode](/kapacitor/v0.13/nodes/http_out_node/)

### InfluxDBOut

Create an influxdb output node that will store the incoming data into InfluxDB.

```javascript
node|influxDBOut()
```

Returns: [InfluxDBOutNode](/kapacitor/v0.13/nodes/influx_d_b_out_node/)

### Join

Join this node with other nodes. The data is joined on timestamp.

```javascript
node|join(others ...Node)
```

Returns: [JoinNode](/kapacitor/v0.13/nodes/join_node/)

### Last

Select the last point.

```javascript
node|last(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Log

Create a node that logs all data it receives.

```javascript
node|log()
```

Returns: [LogNode](/kapacitor/v0.13/nodes/log_node/)

### Max

Select the maximum point.

```javascript
node|max(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Mean

Compute the mean of the data.

```javascript
node|mean(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Median

Compute the median of the data. Note, this method is not a selector,
if you want the median point use .percentile(field, 50.0).

```javascript
node|median(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Min

Select the minimum point.

```javascript
node|min(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Percentile

Select a point at the given percentile. This is a selector function, no interpolation between points is performed.

```javascript
node|percentile(field string, percentile float64)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Sample

Create a new node that samples the incoming points or batches.

One point will be emitted every count or duration specified.

```javascript
node|sample(rate interface{})
```

Returns: [SampleNode](/kapacitor/v0.13/nodes/sample_node/)

### Shift

Create a new node that shifts the incoming points or batches in time.

```javascript
node|shift(shift time.Duration)
```

Returns: [ShiftNode](/kapacitor/v0.13/nodes/shift_node/)

### Spread

Compute the difference between min and max points.

```javascript
node|spread(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Stats

Create a new stream of data that contains the internal statistics of the node.
The interval represents how often to emit the statistics based on real time.
This means the interval time is independent of the times of the data points the source node is receiving.

```javascript
node|stats(interval time.Duration)
```

Returns: [StatsNode](/kapacitor/v0.13/nodes/stats_node/)

### Stddev

Compute the standard deviation.

```javascript
node|stddev(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Sum

Compute the sum of all values.

```javascript
node|sum(field string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Top

Select the top `num` points for `field` and sort by any extra tags or fields.

```javascript
node|top(num int64, field string, fieldsAndTags ...string)
```

Returns: [InfluxQLNode](/kapacitor/v0.13/nodes/influx_q_l_node/)

### Union

Perform the union of this node and all other given nodes.

```javascript
node|union(node ...Node)
```

Returns: [UnionNode](/kapacitor/v0.13/nodes/union_node/)

### Window

Create a new node that windows the stream by time.

NOTE: Window can only be applied to stream edges.

```javascript
node|window()
```

Returns: [WindowNode](/kapacitor/v0.13/nodes/window_node/)


text:
  <META NAME="GENERATOR" CONTENT="Adobe PageMill 2.0 Win">
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <TITLE>VRML97, ISO/IEC 14772-1:1997 -- 3 Definitions</TITLE>

The Virtual Reality Modeling Language

3 Definitions

For the purposes of this part of ISO/IEC 14722, the following definitions
apply.

3.1 activate

To cause a sensor node to generate an
"isActive" event. The various types
of sensor nodes are "activated" by user
interactions, the passage of time, or other events.
Only active sensor nodes affect the user's experience.
A Script node is activated when it receives an
event. A pointing device such as a mouse is
activated when one of its buttons is depressed by a user. See 4.12.2, Script execution,
for details.

3.2 ancestor

A node which is an antecedent of another
node in the transformation hierarchy.

3.3 author

A person or agent that creates VRML files.
Authors typically use generators to assist
them.

3.4 authoring tool

See generator.

3.5 avatar

The abstract representation of the user in
a VRML world. The physical dimensions of the
avatar are used for collision detection and terrain following. See 6.29, NavigationInfo, for details.

3.6 bearing

A straight line passing through the pointer
location in the direction of the pointer. If multiple sensors' geometry
intersect this line, only the sensor nearest the viewer will be eligible
to generate events regardless of material and
texture properties (e.g., transparency).

3.7 bindable node

A node that may have many instances
in a scene graph, but only one instance
may be active at any instant of time. A node
of type Background, Fog, NavigationInfo, or Viewpoint. See 4.6.10, Bindable children nodes,
for details.

3.8 browser

A computer program that interprets VRML files,
presents their content to a user on a display device, and allows the user to interact
with worlds defined by VRML files by means of
a user interface.

3.9 browser extension

Nodes defined using the prototyping mechanism
that are understood only by certain browsers.
See 4.9.3, Browser extensions,
for details.

3.10 built-in node

A node of a type
explicitly defined in this part of ISO/IEC 14772.

3.11 callback

A function defined in a scripting language
to which events are passed. See 4.12.8, EventIn handling, for details.

3.12 candidate

One of potentially several choices. The user
or the browser will select none or one of
the choices when all candidates are identified. See 4.6.10, Bindable children nodes,
and 6.2, Anchor, for details.

3.13 child

An instance of a children node.

3.14 children node

One of a set of node types, instances
of which can be collected in a group to share specific properties dependent
on the type of the grouping node. See 4.6.5, Grouping and children nodes,
for a list of allowable children nodes.

3.15 client system

A computer system, attached to a network,
that relies on another computer (the server) for essential processing functions.
Many client systems also function as stand-alone computers.

3.16 collision proxy

A node used as a substitute for all of a Collision
node's children during collision detection. See 6.8, Collision,
for details.

3.17 colour model

Characterization of a colour space in terms of explicit parameters. ISO/IEC
14772 allows colours to be defined only with the RGB colour model. However,
colour interpolation is performed in the HSV colour space.

3.18 culling

The process of identifying objects or parts
of objects which do not need to be processed further by the browser in order to produce the desired view of a world.

3.19 descendant

A node which descends from another node in
the transformation hierarchy.
A children node.

3.20 display device

A graphics device on which VRML worlds may
be rendered.

3.21 drag sensor

A pointing device sensor that
causes events to be generated in response to
sensor-dependent pointer motions. For example, the SphereSensor generates
spherical rotation events. A node of type CylinderSensor,
PlaneSensor, or SphereSensor. See 4.6.7, Sensor nodes,
and 4.6.7.4, Drag sensors,
for details.

3.22 environmental sensor

A sensor node that generates events
based on the location of the viewpoint in the world
or in relation to objects in the world. The
TimeSensor node generates events at regular intervals in time.
A node of type Collision, ProximitySensor, TimeSensor, or VisibilitySensor.
See 4.6.7.2, Environmental sensors,
for details.

3.23 event

A message sent from one node
to another as defined by a route. Events signal external stimuli, changes to field values, and interactions between nodes. An event
consists of a timestamp and a field value.

3.24 event cascade

A sequence of events initiated by a script
or sensor event and propagated from node to node
along one or more routes. All events in an event
cascade are considered to have occurred simultaneously. See 4.10.3, Execution model,
for details.

3.25 eventIn

A logical receptor attached to a node which
receives events.

3.26 eventOut

A logical output terminal attached to a node
from which events are sent. The eventOut also
stores the event most recently sent.

3.27 execution model

The rules governing how events are processed
by browsers and scripts.

3.28 exposed field

A field that is capable of receiving events via an eventIn
to change its value(s), and generating events via an eventOut
when its value(s) change.

3.29 external prototype

A prototype defined in an external file
and referenced by a URL.

3.30 field

A property or attribute of a node. Each node type has a fixed set of fields. Fields may
contain various kinds of data and one or many values. Each field has a default
value.

3.31 field name

The identifier of a field. Field names are
unique within the scope of the node.

3.32 file

A collection of related data. A file may be stored on physical media
or may exist as a data stream or as data within a computer program.

3.33 frame

A single rendering of a world on a display device or a single time-step in a
simulation.

3.34 generator

A computer program which creates VRML files.
A generator may be used by a person or operate automatically. Synonymous
with authoring tool.

3.35 geometric property node

A node defining the properties of a specific
geometry node. A node of type Color, Coordinate, Normal, or TextureCoordinate.
See 4.6.3.2, Geometric property nodes,
for details.

3.36 geometric sensor node

A node that generates events
based on user actions, such as a mouse click or navigating close to a particular object. A node of type CylinderSensor, PlaneSensor,
ProximitySensor, SphereSensor, TouchSensor, VisibilitySensor, or Collision.
See 4.6.7.1, Introduction to sensors,
for details.

3.37 geometry node

A node containing mathematical descriptions
of three-dimensional (3D) points, lines, surfaces, text strings and solids.
A node of type Box, Cone, Cylinder, ElevationGrid, Extrusion, IndexedFaceSet,
IndexedLineSet, PointSet, Sphere, or Text. See 4.6.3, Shapes and geometry,
for details.

3.38 grab

To receive events from activated pointing
devices (e.g., mouse or wand).
A pointing device sensor becomes
the exclusive recipient of pointing device events when one or more pointing
devices are activated simultaneously.

3.39 gravity

In the context of ISO/IEC 14772, gravity may be simulated by constraining
the motion of the viewpoint to the lowest possible path (smallest Y-coordinate
in the local coordinate system of the viewpoint) consistent with following
the surface of encountered objects. See 6.29, NavigationInfo, for details.

3.40 grouping node

One of a set of node types which include
a list of nodes, referred to as its children
nodes. These children nodes are collected together to share specific
properties dependent on the type of the grouping node. Each grouping node
defines a coordinate space for its children relative to its own coordinate
space. The children may themselves be instances of grouping nodes, thus
forming a transformation hierarchy.
See 4.6.5, Grouping and children nodes,
for details.

3.41 HSV

Hue, Saturation, and Value colour model. See E.[FOLE].

3.42 HTML

HyperText Markup Language. See 2.[HTML].

3.43 hyperlink

A reference to a URL that is associated with
an Anchor node. See 6.2, Anchor,
for details.

3.44 ideal VRML implementation

An implementation of VRML that presents all objects
and simulates movement without approximation. Not realizable in practice.

3.45 IEC

International Electrotechnical Commission. See <TT>http://www.iec.ch</TT>.

3.46 IETF

Internet Engineering Task Force. The organization which develops Internet standards. See <TT>http://www.ietf.org/overview.html</TT>.

3.47 image

A two-dimensional (2D) rectangular array of pixel values. Pixel values
may have from one to four components. See 5.5, SFImage,
for details.

3.48 in-lining

The mechanism by which one VRML file is
hierarchically included in another.

3.49 Internet

The world-wide named network of computers
which communicate with each other using a common set of communication protocols
known as TCP/IP. See IETF. The World
Wide Web is implemented on the Internet.

3.50 instance

A reference to a previously defined and named node.
Nodes are named by means of the DEF syntax and reference by USE syntax (see
4.6.2, DEF/USE semantics). Instances of
nodes may be used in any context in which the defining node may be used.

3.51 interpolator node

A node that defines a piece-wise linear interpolation.
A node of type ColorInterpolator, CoordinateInterpolator, NormalInterpolator,
OrientationInterpolator, PositionInterpolator, or ScalarInterpolator. See
4.6.8, Interpolator nodes, for details.

3.52 intranet

A private network that uses the same protocols
and standards as the Internet.

3.53 ISO

International Organization for Standardization. See <TT>http://www.iso.ch/infoe/intro.html</TT>.

3.54 JPEG

Joint Photographic Experts Group. See 2.[JPEG].

3.55 JTC 1

ISO/IEC Joint Technical Committee
1. See <TT>http://www.iso.ch/meme/JTC1.html</TT>.

3.56 level of detail

The amount of detail or complexity which is displayed at any particular
time for any particular object.
The level of detail for an object is controllable as a function of the distance
of the object from the viewer. See 6.26, LOD,
for details. (Abbreviated LOD)

3.57 line terminator

A linefeed character (0x0A) or a carriage return character (0x0D).

3.58 loop

A sequence of events which would result in
a specific eventOut sending more than one
event with the same timestamp.

3.59 message

A data string sent between nodes upon the
occurrence of an event. See 4.10, Event processing,
for details.

3.60 MIDI

Musical Instrument Digital Interface. A standard for digital music representation.
See 2.[MIDI].

3.61 MIME

Multipurpose Internet Mail Extension. Used to specify filetyping rules
for Internet applications, including browsers. See 4.5.1, File extension and MIME types,
for details. See also E.[MIME].

3.62 mouse

A pointing device that moves in two dimensions and that enables a user to move a cursor on a display
device in order to point at displayed objects.
One or more push buttons on the mouse allow the user to indicate to the
computer program that some action is to be taken.

3.63 MPEG

Moving Picture Experts Group. See <TT>http://drogo.cselt.stet.it/mpeg/</TT>.

3.64 multimedia

An integrated presentation, typically on a computer, of content of various
types, such as computer graphics, audio, and video.

3.65 network

Set of interconnected computers.

3.66 node

The fundamental component of a scene graph
in ISO/IEC 14772. Nodes are abstractions of various real-world objects and
concepts. Examples include spheres, lights, and material descriptions. Nodes
contain fields and events.
Messages may be sent between nodes along routes.

3.67 node type

A characteristic of each node that describes,
in general, its particular semantics. For example, Box, Group, Sound, and
SpotLight are node types. See 4.6, Node semantics,
and 6, Node reference, for details.

3.68 now

The present time as perceived by the user.

3.69 object

A collection of data and procedures, packaged according to the rules
and syntax defined in ISO/IEC 14772. "Object" is usually synonymous
with node.

3.70 object space

The coordinate system in which an object
is defined.

3.71 panorama

A background texture that is placed behind all geometry in the scene
and in front of the ground and sky. See 6.5,
Background, for details.

3.72 parent

A node which is an instance of a grouping node.

3.73 PNG

Portable Network Graphics. A specification for representing two-dimensional
images in files. See 2.[PNG].

3.74 pointer

A location and direction in the virtual world
defined by the pointing device which
the user is currently using to interact with
the virtual world.

3.75 pointing device

A hardware device connected to the user's
computer by which the user directly controls the location and direction
of the pointer. Pointing devices may be either
two-dimensional or three-dimensional and may have one or more control buttons.
See 4.6.7.5, Activating and manipulating sensors,
for details.

3.76 pointing device sensor

A sensor node that generates events
based on user actions, such as pointing
device motions or button activations. A node of type Anchor, CylinderSensor,
PlaneSensor, SphereSensor, or TouchSensor. See 4.6.7.3, Pointing device sensors,
for details.

3.77 polyline

A sequence of straight line segments where the end point of the first
segment is coincident with the start point of the second segment, the endpoint
of the second segment is coincident with the start point of the third segment,
and so on. A piecewise linear curve.

3.78 profile

A named collection of criteria for functionality and conformance that
defines an implementable subset of a standard.

3.79 prototype

The definition of a new node type in terms
of the nodes defined in this part of ISO/IEC
14772. See 4.8, Prototype semantics,
for details.

3.80 prototyping

The mechanism for extending the set of node types
from within a VRML file.

3.81 public interface

The formal definition of a node type in
this part of ISO/IEC 14772.

3.82 RGB

The colour model used within ISO/IEC 14772 for the specification of colours.
Each colour is represented as a combination of the three primary colours
red, green, and blue. See E.[FOLE].

3.83 route

The connection between a node generating an
event and a node receiving the event. See 4.3.9, Route statement syntax,
and 4.10.2, Route semantics, for details.

3.84 route graph

The set of connections between eventOuts
and eventIns formed by ROUTE statements
or addRoute method invocations.

3.85 run-time name scope

The extent to which a name defined within a VRML file applies and is
visible. Several different run-time name scopes are recognized and are defined
in 4.4.6, Run-time name scope.

3.86 RURL

Relative Uniform Resource Locator. See 2.[RURL].

3.87 scene graph

An ordered collection of grouping nodes
and other nodes. Grouping nodes, (such as LOD, Switch, and Transform
nodes) may have children nodes. See 4.2.3, Scene graph, and 4.4.2, Scene graph hierarchy, for
details.

3.88 script

A set of procedural functions normally executed as part of an event cascade (see 6.40,
Script). A script function may also be executed asynchronously (see
4.12.6, Asynchronous scripts).

3.89 scripting

The process of creating or referring to a script.

3.90 scripting language

A system of syntactical and semantic constructs used to define and automate
procedures and processes on a computer. Typically, scripting languages are
interpreted and executed sequentially on a statement-by-statement basis
whereas programming languages are generally compiled prior to execution.

3.91 sensor node

A node that enables the user
to interact with the world in the scene graph
hierarchy. Sensor nodes respond to user interaction with geometric objects in the world, the movement of the user through
the world, or the passage of time. See 4.6.7, Sensor nodes, for details.

3.92 separator character

A UTF-8 character used to separate syntactical
entities in a VRML file. Specifically, commas,
spaces, tabs, linefeeds, and carriage-returns are separator characters wherever
they appear outside of string fields. See 4.3.1, Clear text (UTF-8) encoding,
for details.

3.93 sibling

A node which shares a parent
with other nodes.

3.94 simulation tick

The smallest time unit capable of being identified in a digital simulation
of analog time. Time in the context of ISO/IEC
14772 is conceptually analog but is realized by an implementation as a digital
simulation of abstract analog time. See 4.11, Time,
for details.

3.95 special group node

A grouping node that exhibits special
behaviour. Examples of such special behaviour include selecting one of many
children nodes to be rendered based on
a dynamically changing parameter value and dynamically loading children
nodes from an external file. A node of type Inline, LOD (level of detail),
or Switch. See 4.6.5, Grouping and children nodes,
for details.

3.96 texture

An image used in a texture
map to create visual appearance effects when applied to geometry nodes.

3.97 texture coordinates

The set of two-dimensional coordinates used by some vertex-based geometry nodes (e.g., IndexedFaceSet
and ElevationGrid) and specified in the TextureCoordinate node to map textures
to the vertices of those nodes. Texture coordinates range from 0 to 1 across
each axis of the texture image. See 4.6.11, Texture maps,
and 6.48, TextureCoordinate,
for details.

3.98 texture map

A texture plus the general parameters necessary
for mapping the texture to geometry.

3.99 time

A monotonically increasing value generated by a node. Time (0.0) starts
at 00:00:00 GMT January 1, 1970. See 4.11, Time,
for details.

3.100 timestamp

The part of a message that describes the
time the event occurred
and that caused the message to be sent. See 4.11, Time,
for details.

3.101 transformation hierarchy

The subset of the scene graph consisting
of nodes that have well-defined coordinate
systems. The transformation hierarchy excludes nodes that are not descendants of the scene graph root nodes and
nodes in SFNode or MFNode fields of Script nodes.

3.102 transparency chunk

A section of a PNG file containing transparency information (derived
from 2.[PNG]).

3.103 traverse

To process the nodes in a scene
graph in the correct order.

3.104 UCS

Universal multiple-octet coded Character Set. See 2.[UTF8].

3.105 URL

Uniform Resource Locator. See 2.[URL].

3.106 URN

Universal Resource Name. See E.[URN].

3.107 UTF-8

The character set used to encode VRML files.
The 8-bit UCS Transformation Format. See 2.[UTF8].

3.108 user

A person or agent who uses and interacts with VRML
files by means of a browser.

3.109 viewer

A location, direction, and viewing angle in a virtual
world that determines the portion of the virtual world presented
by the browser to the user.

3.110 virtual world

See world.

3.111 VRML browser

See browser.

3.112 VRML document server

A computer program that locates and transmits VRML
files and supporting files in response to requests from browsers.

3.113 VRML file

A set of VRML nodes a


text:
package de.learnlib.util;

import java.util.Collection;
import java.util.Random;

import de.learnlib.api.algorithm.LearningAlgorithm.DFALearner;
import de.learnlib.api.oracle.EquivalenceOracle.DFAEquivalenceOracle;
import de.learnlib.api.query.DefaultQuery;
import de.learnlib.util.Experiment.DFAExperiment;
import de.learnlib.util.statistics.SimpleProfiler;
import net.automatalib.automata.fsa.DFA;
import net.automatalib.automata.fsa.impl.compact.CompactDFA;
import net.automatalib.util.automata.random.RandomAutomata;
import net.automatalib.words.Alphabet;
import net.automatalib.words.Word;
import net.automatalib.words.impl.Alphabets;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * @author frohme
 */
public class ExperimentTest {

    private static final Random RANDOM = new Random(42);
    private static final int REFINEMENT_STEPS = 3;

    @Test
    public void testExperiment() {

        final Alphabet<Character> alphabet = Alphabets.characters('a', 'c');
        final CompactDFA<Character> target = RandomAutomata.randomDFA(RANDOM, 5, alphabet);
        final CompactDFA<Character> intermediateTarget = RandomAutomata.randomDFA(RANDOM, target.size() - 1, alphabet);

        final MockUpLearner<Character> learner = new MockUpLearner<>(target, intermediateTarget);
        final DFAEquivalenceOracle<Character> eq = new MockUpOracle<>(intermediateTarget);

        DFAExperiment<Character> experiment = new DFAExperiment<>(learner, eq, alphabet);
        experiment.setProfile(true);

        Assert.assertThrows(experiment::getFinalHypothesis);

        experiment.run();

        Assert.assertThrows(experiment::run);

        DFA<?, Character> finalModel = experiment.getFinalHypothesis();

        Assert.assertNotNull(experiment.getFinalHypothesis());
        Assert.assertSame(finalModel, target);

        Assert.assertTrue(learner.startLearningCalled);
        Assert.assertEquals(learner.refinementSteps, REFINEMENT_STEPS);

        Assert.assertNotNull(SimpleProfiler.cumulated(Experiment.LEARNING_PROFILE_KEY));
        Assert.assertNotNull(SimpleProfiler.cumulated(Experiment.COUNTEREXAMPLE_PROFILE_KEY));
    }

    private static final class MockUpLearner<I> implements DFALearner<I> {

        private final DFA<?, I> targetModel;
        private final DFA<?, I> intermediateModel;
        private boolean startLearningCalled;
        private int refinementSteps;

        MockUpLearner(CompactDFA<I> target, CompactDFA<I> intermediateTarget) {
            targetModel = target;
            intermediateModel = intermediateTarget;
        }

        @Override
        public void startLearning() {
            startLearningCalled = true;
        }

        @Override
        public boolean refineHypothesis(DefaultQuery<I, Boolean> ceQuery) {
            return refinementSteps++ < REFINEMENT_STEPS;
        }

        @Override
        public DFA<?, I> getHypothesisModel() {
            if (refinementSteps < REFINEMENT_STEPS) {
                return intermediateModel;
            }

            return targetModel;
        }
    }

    private static final class MockUpOracle<I> implements DFAEquivalenceOracle<I> {

        private final DFA<?, I> intermediateTarget;
        private int counterexamples;

        MockUpOracle(DFA<?, I> intermediateTarget) {
            this.intermediateTarget = intermediateTarget;
        }

        @Override
        public @Nullable DefaultQuery<I, Boolean> findCounterExample(DFA<?, I> hypothesis,
                                                                     Collection<? extends I> inputs) {
            if (counterexamples < REFINEMENT_STEPS) {
                Assert.assertSame(hypothesis, intermediateTarget);

                counterexamples++;
                return new DefaultQuery<>(Word.epsilon(), true);
            }
            return null;
        }
    }

}


text:
describe(rio.Form, {
	"with no validators": {
		beforeEach: function() {
			this.company = new (rio.Attr.create({ attrAccessors: ["name"] }))({ name: "Thinklink" });

			this.form = rio.Form.build({
				attributes: {
					name: {},
					email: { initialValue: "tilleryj@gmail.com" },
					company: { initialValue: this.company.name }
				}
			});
		},

		"should accept a set of attributes and make them available as bindable attributes": function() {
			this.form.getName().shouldEqual("");
			this.form.setName("Hello");
			this.form.getName().shouldEqual("Hello");

			(this.form.name.constructor == rio.Binding).shouldBeTrue();
		},

		"should accept custom initial values for attributes": function() {
			this.form.getEmail().shouldEqual("tilleryj@gmail.com");
		},

		"should reset values back to their initial values": function() {
			this.form.setName("Jason");
			this.form.setEmail("asdf@thinklinkr.com");
			this.form.reset();

			this.form.getName().shouldEqual("");
			this.form.getEmail().shouldEqual("tilleryj@gmail.com");
		},

		"should allow bindable initial values": function() {
			this.form.getCompany().shouldEqual("Thinklink");
			this.company.setName("Apple");
			this.form.getCompany().shouldEqual("Thinklink");
			this.form.reset();
			this.form.getCompany().shouldEqual("Apple");
		},

		"should provide a commit method that invokes the onCommit function with the forms values": function() {
			var onCommit = function(values) {
				values.email.shouldEqual("tilleryj@gmail.com");
			}.shouldBeCalled();
			var form = rio.Form.build({
				attributes: {
					email: { initialValue: "tilleryj@gmail.com" }
				},
				onCommit: onCommit
			});
			form.commit();
		},

		"should be valid": function() {
			this.form.valid().shouldBeTrue();
		}
	},

	"with validators": {
		beforeEach: function() {
			this.form = rio.Form.build({
				attributes: {
					name: {
						validates: [function(values) {
							if (values.name.length > 5) {
								return "Name cannot be longer than 5 characters.";
							}
						}]
					},
					email: {
						initialValue: "tilleryj@gmail.com",
						validates: ["email"]
					}
				}
			});
		},

		"should be valid initially": function() {
			this.form.valid().shouldBeTrue();
		},

		"should not be valid email is not a valid email address": function() {
			this.form.setEmail("");
			this.form.valid().shouldBeFalse();
			this.form.setEmail("asdf");
			this.form.valid().shouldBeFalse();
			this.form.setEmail("asdf@thinklinkr.");
			this.form.valid().shouldBeFalse();
			this.form.setEmail("asdf@thinklinkr.com");
			this.form.valid().shouldBeTrue();
		},

		"should not be valid if a validator function returns an error message": function() {
			this.form.setName("Hello World");
			this.form.valid().shouldBeFalse();
			this.form.setName("Hello");
			this.form.valid().shouldBeTrue();
		},

		"should not commit if in an invalid state": function() {
			var form = rio.Form.build({
				attributes: {
					name: {
						validates: [function(values) { return "Never valid"; }]
					}
				},
				onCommit: function() {}.shouldNotBeCalled()
			});
			form.commit();
		},

		"should expose bindable error messages": function() {
			var emailErrors = this.form.errorsFor('email');
			(emailErrors.constructor == rio.Binding).shouldBeTrue();
			emailErrors.value().shouldEqual("");
			this.form.setEmail("asdf");
			emailErrors.value().shouldEqual("not a valid email address");
		},

		"should remove erros on reset even if the form is still in a bad state": function() {
			this.form = rio.Form.build({
				attributes: {
					email: {
						initialValue: "",
						validates: ["email"]
					}
				}
			});
			this.form.validate();
			this.form.errorsFor("email").value().shouldNotEqual("");
			this.form.reset();
			this.form.errorsFor("email").value().shouldEqual("");
		}
	}
});

describe(rio.Validators, {
	"should validate email": function() {
		var emailErrorMessage = "not a valid email address";
		rio.Validators.email("").shouldEqual(emailErrorMessage);
		rio.Validators.email("asdf@").shouldEqual(emailErrorMessage);
		rio.Validators.email("asdf@thinklinkr").shouldEqual(emailErrorMessage);
		rio.Validators.email("asdf@thinklinkr.").shouldEqual(emailErrorMessage);
		rio.Validators.email("@thinklinkr.com").shouldEqual(emailErrorMessage);
		rio.Validators.email("thinklinkr.com").shouldEqual(emailErrorMessage);
		rio.Validators.email("asdf@thinklinkr.com").shouldEqual("");
		rio.Validators.email("asdf+extra@thinklinkr.com").shouldEqual("");
	},

	"should validate presence": function() {
		var errorMessage = "cannot be blank";
		rio.Validators.presence().shouldEqual(errorMessage);
		rio.Validators.presence("").shouldEqual(errorMessage);
		rio.Validators.presence(" ").shouldEqual(errorMessage);
		rio.Validators.presence("   ").shouldEqual(errorMessage);
		rio.Validators.presence("anything").shouldEqual("");
	}
});


text:
define([
  'angular',
  'scripts/howWeBuild/cover/cover',
  'scripts/howWeBuild/counter/counter',
  'scripts/howWeBuild/gameTracker/gameTracker',
  'scripts/howWeBuild/registryTracker/registryTracker',
  'scripts/howWeBuild/barge/barge',
  'scripts/howWeBuild/bellows/bellows',
  'scripts/howWeBuild/fans/fans',
  'scripts/howWeBuild/pipes/pipes',
  'scripts/howWeBuild/intonation/intonation',
  'scripts/howWeBuild/montage/montage'
], function(angular) {
  'use strict';

  return angular.module('myApp.howWeBuild', [
    'myApp.howWeBuild.cover',
    'myApp.howWeBuild.counter',
    'myApp.howWeBuild.gameTracker',
    'myApp.howWeBuild.registryTracker',
    'myApp.howWeBuild.barge',
    'myApp.howWeBuild.bellows',
    'myApp.howWeBuild.fans',
    'myApp.howWeBuild.pipes',
    'myApp.howWeBuild.intonation',
    'myApp.howWeBuild.montage'
  ])
  .config(['$stateProvider', function ($stateProvider) {
    $stateProvider.state('howWeBuild', {
      views: {
        "": {
          templateUrl: 'scripts/howWeBuild/howWeBuild.html'
        }
      },
      data: { pageTitle: 'HOW_WE_BUILD.TITLE' }
    });
  }]);
});


text:
from django.contrib import admin

from . import models

admin.site.register(models.Media)
admin.site.register(models.Album)
admin.site.register(models.Festival)
admin.site.register(models.Project)
admin.site.register(models.FestivalProject)

class ParticipationAdmin(admin.ModelAdmin):
    list_display = ['festival_project','participant',  'headshot_tag']
admin.site.register(models.Participation, ParticipationAdmin)

admin.site.register(models.Art)

class ParticipantAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
    list_display = ['name',  'headshot_tag']
admin.site.register(models.Participant, ParticipantAdmin)

class ArtistAdmin(admin.ModelAdmin):
    list_display = ['festival_project','participant',  'headshot_tag', 'art']

admin.site.register(models.Artist, ArtistAdmin)
admin.site.register(models.FilmDirector)
admin.site.register(models.Film)
admin.site.register(models.Organizer)


text:
.path-mod-lti .ltiframe {position: relative;width: 100%;height: 100%;}

/** General Styles **/
.path-mod-lti .userpicture,
.path-mod-lti .picture.user,
.path-mod-lti .picture.teacher {width:35px;height: 35px;vertical-align:top;}
.path-mod-lti .feedback .files,
.path-mod-lti .feedback .grade,
.path-mod-lti .feedback .outcome,
.path-mod-lti .feedback .finalgrade {float: right;}
.path-mod-lti .feedback .disabledfeedback {width: 500px;height: 250px;}
.path-mod-lti .feedback .from {float: left;}
.path-mod-lti .files img {margin-right: 4px;}
.path-mod-lti .files a {white-space:nowrap;}
.path-mod-lti .late {color: red;}
.path-mod-lti .message {text-align: center;}

/* Styles for admin */
.path-admin-mod-lti .mform .fitem .fitemtitle { min-width:18em;padding-right:1em } /* Prevent setting titles from wrapping */

/* Styles for instructor editing an external tool */

.path-mod-lti .mform .fitem .fitemtitle { min-width:14em;padding-right:1em } /* Prevent setting titles from wrapping */

/* Styles for instructor_edit_tool_type.php */
#page-mod-lti-instructor_edit_tool_type .mform .fitem .fitemtitle { min-width:18em;padding-right:1em } /* Prevent setting titles from wrapping */


text: mvn package && cp ./target/quiz.war /var/lib/tomcat8/webapps/binarysearch.es/


text:
use minidump_synth::*;
use std::fs::File;
use std::io::{BufReader, Read, Write};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use test_assembler::*;

// Some tests need to write files (and read them back).
// To keep this tidy and hidden, we make a new directory
// in `target`.
const TEST_TMP: &str = "../target/testdata/";

fn test_output(file_name: &str) -> PathBuf {
    let mut res = PathBuf::from(TEST_TMP);
    // Ensure the directory exists.
    // Ignore failures because we don't care if the dir already exists.
    let _ = std::fs::create_dir(&res);
    // Now create the path
    res.push(file_name);
    res
}

#[test]
fn test_dump() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--dump")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("dump", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_json() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_json_pretty() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--pretty")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json-pretty", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_json_stable_all() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--pretty")
        .arg("--features")
        .arg("stable-all")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json-stable-all", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_json_unstable_all() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--pretty")
        .arg("--features")
        .arg("unstable-all")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json-unstable-all", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_json_symbols() {
    // For a while this didn't parse right
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--pretty")
        .arg("../testdata/test.dmp")
        .arg("../testdata/symbols/")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json-pretty-symbols", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_evil_json() {
    // For a while this didn't parse right
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--pretty")
        .arg("--evil-json")
        .arg("../testdata/evil.json")
        .arg("../testdata/test.dmp")
        .arg("../testdata/symbols/")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("json-pretty-evil-symbols", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human_stable_all() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--features")
        .arg("stable-all")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-stable-all", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human_unstable_all() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--features")
        .arg("unstable-all")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-unstable-all", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human_symbols() {
    // For a while this didn't parse right
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("../testdata/test.dmp")
        .arg("../testdata/symbols/")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-symbols", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human_symbols_garbo_url() {
    // For a while this didn't parse right
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg(r#"--symbols-url="garbage.realwebsite""#)
        .arg("../testdata/test.dmp")
        .arg("../testdata/symbols/")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-symbols", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_human_brief() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--brief")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-brief", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_default() {
    // Should be the same as --human
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_cyborg() {
    let cyborg_out_path = test_output("mdsw-test-cyborg-out.json");
    // Should be the same as --human and --json
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--cyborg")
        .arg(&cyborg_out_path)
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    let json_file = File::open(cyborg_out_path).unwrap();
    let mut json_bytes = vec![];
    BufReader::new(json_file)
        .read_to_end(&mut json_bytes)
        .unwrap();
    let json_out = String::from_utf8(json_bytes).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", stdout);
    insta::assert_snapshot!("json", json_out);
    assert_eq!(stderr, "");
}

#[test]
fn test_trace() {
    // Should be the same as --human and --json
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--verbose=trace")
        .arg("../testdata/test.dmp")
        .env("NO_COLOR", "1") // disable coloured output for logs
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", stdout);
    insta::assert_snapshot!("trace", stderr);
}

#[test]
fn test_output_files() {
    let out_path = test_output("mdsw-test-ouput-files-out.txt");
    let log_path = test_output("mdsw-test-output-files-log.txt");
    // Should be the same as --human and --json
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--verbose=trace")
        .arg("--output-file")
        .arg(&out_path)
        .arg("--log-file")
        .arg(&log_path)
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    let out_file = File::open(out_path).unwrap();
    let mut out_bytes = vec![];
    BufReader::new(out_file)
        .read_to_end(&mut out_bytes)
        .unwrap();
    let out = String::from_utf8(out_bytes).unwrap();

    let log_file = File::open(log_path).unwrap();
    let mut log_bytes = vec![];
    BufReader::new(log_file)
        .read_to_end(&mut log_bytes)
        .unwrap();
    let log = String::from_utf8(log_bytes).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", out);
    insta::assert_snapshot!("trace", log);
    assert_eq!(stdout, "");
    assert_eq!(stderr, "");
}

#[test]
fn test_version() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("-V")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    assert_eq!(stderr, "");

    let (name, ver) = stdout.split_once(' ').unwrap();
    assert_eq!(name, "minidump-stackwalk");
    let mut ver_parts = ver.trim().split('.');
    ver_parts.next().unwrap().parse::<u8>().unwrap();
    ver_parts.next().unwrap().parse::<u8>().unwrap();
    ver_parts.next().unwrap().parse::<u8>().unwrap();
    assert!(ver_parts.next().is_none());
}

#[test]
fn test_long_help() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--help")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("long-help", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_short_help() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("-h")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("short-help", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_markdown_help() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--help-markdown")
        .arg("please")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("markdown-help", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_ambiguous_parse() {
    // For a while this didn't parse right
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--symbols-url")
        .arg("garbage-url.realwebsite")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human", stdout);
    assert_eq!(stderr, "");
}

#[test]
fn test_no_minidump() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(!output.status.success());
    assert_eq!(stdout, "");
    assert!(!stderr.is_empty());
}

#[test]
fn test_bad_minidump() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("not_a_real_minidump.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(!output.status.success());
    assert_eq!(stdout, "");
    assert!(!stderr.is_empty());
}

#[test]
fn test_multiple_outputs_conflict() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--json")
        .arg("--human")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(!output.status.success());
    assert_eq!(stdout, "");
    assert!(!stderr.is_empty());
}

#[test]
fn test_pretty_humans() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--pretty")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(!output.status.success());
    assert_eq!(stdout, "");
    assert!(!stderr.is_empty());
}

#[test]
fn test_brief_robots() {
    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--human")
        .arg("--pretty")
        .arg("../testdata/test.dmp")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    assert!(!output.status.success());
    assert_eq!(stdout, "");
    assert!(!stderr.is_empty());
}

fn minimal_minidump() -> SynthMinidump {
    let context = minidump_synth::x86_context(Endian::Little, 0xf00800, 0x1010);
    let stack = Memory::with_section(
        Section::with_endian(Endian::Little).append_repeated(0, 0x1000),
        0x1000,
    );
    let thread = Thread::new(Endian::Little, 0x1234, &stack, &context);
    let system_info = SystemInfo::new(Endian::Little);
    SynthMinidump::with_endian(Endian::Little)
        .add_thread(thread)
        .add_system_info(system_info)
        .add(context)
        .add_memory(stack)
}

fn unloaded_minidump() -> PathBuf {
    // Testing how we handle a stack frame having no module mapping, but many
    // "hits" with unloaded modules.
    let synth_path = test_output("unloaded-minidump.dmp");

    let mod1_name = DumpString::new("many.dll", Endian::Little);
    let mod2_name = DumpString::new("solo.dll", Endian::Little);
    let mod3_name = DumpString::new("unused.dll", Endian::Little);

    // All of these should "hit", but this one will be hacked into JSON
    let mod1_1 = UnloadedModule::new(
        Endian::Little,
        0xf00000,
        0x1000,
        &mod1_name,
        0xb1054d2a,
        0x34571371,
    );
    let mod1_2 = UnloadedModule::new(
        Endian::Little,
        0xf00100,
        0x1000,
        &mod1_name,
        0xb1054d2a,
        0x34571371,
    );
    let mod1_3 = UnloadedModule::new(
        Endian::Little,
        0xf003a0,
        0x1000,
        &mod1_name,
        0xb1054d2a,
        0x34571371,
    );
    // Same as mod1_1, to check deduping
    let mod1_4 = UnloadedModule::new(
        Endian::Little,
        0xf00000,
        0x1000,
        &mod1_name,
        0xb1054d2a,
        0x34571371,
    );
    // This one should hit
    let mod2_1 = UnloadedModule::new(
        Endian::Little,
        0xf00220,
        0x2000,
        &mod2_name,
        0xb1054d2a,
        0x34571371,
    );
    // This one should miss
    let mod2_2 = UnloadedModule::new(
        Endian::Little,
        0xaf00220,
        0x2000,
        &mod2_name,
        0xb1054d2a,
        0x34571371,
    );
    // Same as mod 2_1, to check deduping
    let mod2_3 = UnloadedModule::new(
        Endian::Little,
        0xaf00220,
        0x2000,
        &mod2_name,
        0xb1054d2a,
        0x34571371,
    );
    // This one should miss
    let mod3 = UnloadedModule::new(
        Endian::Little,
        0xa003a0,
        0x1000,
        &mod3_name,
        0xb1054d2a,
        0x34571371,
    );

    // Vaguely randomize the module order
    let minidump = minimal_minidump()
        .add_unloaded_module(mod3)
        .add_unloaded_module(mod1_1)
        .add_unloaded_module(mod2_2)
        .add_unloaded_module(mod1_2)
        .add_unloaded_module(mod1_3)
        .add_unloaded_module(mod2_1)
        .add_unloaded_module(mod2_3)
        .add_unloaded_module(mod1_4)
        .add(mod1_name)
        .add(mod2_name)
        .add(mod3_name)
        .finish()
        .unwrap();

    // Write the synth minidump to disk
    {
        let mut file = File::create(&synth_path).unwrap();
        file.write_all(&minidump).unwrap();
    }

    synth_path
}

#[test]
fn test_unloaded() {
    // Test that unloaded modules show up in stack frames.
    //
    // Unfortunately since this is testing two unique outputs
    // via --cyborg, you will need to "fix" this test twice
    // if you ever change both outputs. ;-;
    let synth_path = unloaded_minidump();
    let cyborg_out_path = test_output("mdsw-test-unloaded-out.json");

    let bin = env!("CARGO_BIN_EXE_minidump-stackwalk");
    let output = Command::new(bin)
        .arg("--cyborg")
        .arg(&cyborg_out_path)
        .arg("--pretty")
        .arg(synth_path)
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .unwrap();

    let stdout = String::from_utf8(output.stdout).unwrap();
    let stderr = String::from_utf8(output.stderr).unwrap();

    let json_file = File::open(cyborg_out_path).unwrap();
    let mut json_bytes = vec![];
    BufReader::new(json_file)
        .read_to_end(&mut json_bytes)
        .unwrap();
    let json_out = String::from_utf8(json_bytes).unwrap();

    assert!(output.status.success());
    insta::assert_snapshot!("human-unloaded", stdout);
    insta::assert_snapshot!("json-pretty-unloaded", json_out);
    assert_eq!(stderr, "");
}


text:
package org.siggd.editor;

import org.siggd.Convert;
import org.siggd.actor.Actor;

public class RotateCommand extends Command {
	private float mDegrees;
	private Actor mActor;

	public RotateCommand(Actor actor, float degrees) {
		mActor = actor;
		mDegrees = degrees;
	}

	@Override
	public void doit() {
		float a = Convert.getFloat(mActor.getProp("Angle"))+mDegrees;
		mActor.setProp("Angle", a);

	}

	@Override
	public void undo() {
		float a = Convert.getFloat(mActor.getProp("Angle"))-mDegrees;
		mActor.setProp("Angle", a);
	}

}