text:
import {
  AsyncTestCompleter,
  beforeEach,
  ddescribe,
  describe,
  el,
  expect,
  iit,
  inject,
  IS_DARTIUM,
  it,
} from 'angular2/test_lib';

import {DOM} from 'angular2/src/dom/dom_adapter';
import {List, ListWrapper, Map, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {Type, isBlank, stringify, isPresent, BaseException} from 'angular2/src/facade/lang';
import {PromiseWrapper, Promise} from 'angular2/src/facade/async';

import {DomCompiler} from 'angular2/src/render/dom/compiler/compiler';
import {ProtoViewDto, ViewDefinition, DirectiveMetadata, ViewType} from 'angular2/src/render/api';
import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step';
import {CompileStepFactory} from 'angular2/src/render/dom/compiler/compile_step_factory';
import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';

import {resolveInternalDomProtoView} from 'angular2/src/render/dom/view/proto_view';

export function runCompilerCommonTests() {
  describe('DomCompiler', function() {
    var mockStepFactory: MockStepFactory;

    function createCompiler(processClosure, urlData = null) {
      if (isBlank(urlData)) {
        urlData = new Map();
      }
      var tplLoader = new FakeViewLoader(urlData);
      mockStepFactory = new MockStepFactory([new MockStep(processClosure)]);
      return new DomCompiler(mockStepFactory, tplLoader, false);
    }

    describe('compile', () => {

      it('should run the steps and build the AppProtoView of the root element',
         inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler((parent, current, control) => {
             current.inheritedProtoView.bindVariable('b', 'a');
           });
           compiler.compile(
                       new ViewDefinition({componentId: 'someComponent', template: '

'}))
               .then((protoView) => {
                 expect(protoView.variableBindings)
                     .toEqual(MapWrapper.createFromStringMap({'a': 'b'}));
                 async.done();
               });
         }));

      it('should run the steps and build the proto view', inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler((parent, current, control) => {
             current.inheritedProtoView.bindVariable('b', 'a');
           });

           var dirMetadata = DirectiveMetadata.create(
               {id: 'id', selector: 'CUSTOM', type: DirectiveMetadata.COMPONENT_TYPE});
           compiler.compileHost(dirMetadata)
               .then((protoView) => {
                 expect(DOM.tagName(DOM.firstChild(DOM.content(
                            resolveInternalDomProtoView(protoView.render).rootElement))))
                     .toEqual('CUSTOM');
                 expect(mockStepFactory.viewDef.directives).toEqual([dirMetadata]);
                 expect(protoView.variableBindings)
                     .toEqual(MapWrapper.createFromStringMap({'a': 'b'}));
                 async.done();
               });
         }));

      it('should use the inline template and compile in sync',
         inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler(EMPTY_STEP);
           compiler.compile(
                       new ViewDefinition({componentId: 'someId', template: 'inline component'}))
               .then((protoView) => {
                 expect(DOM.getInnerHTML(resolveInternalDomProtoView(protoView.render).rootElement))
                     .toEqual('inline component');
                 async.done();
               });
         }));

      it('should load url templates', inject([AsyncTestCompleter], (async) => {
           var urlData = MapWrapper.createFromStringMap({'someUrl': 'url component'});
           var compiler = createCompiler(EMPTY_STEP, urlData);
           compiler.compile(new ViewDefinition({componentId: 'someId', templateAbsUrl: 'someUrl'}))
               .then((protoView) => {
                 expect(DOM.getInnerHTML(resolveInternalDomProtoView(protoView.render).rootElement))
                     .toEqual('url component');
                 async.done();
               });
         }));

      it('should report loading errors', inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler(EMPTY_STEP, new Map());
           PromiseWrapper.catchError(
               compiler.compile(
                   new ViewDefinition({componentId: 'someId', templateAbsUrl: 'someUrl'})),
               (e) => {
                 expect(e.message).toEqual(
                     'Failed to load the template for "someId" : Failed to fetch url "someUrl"');
                 async.done();
                 return null;
               });
         }));

      it('should return ProtoViews of type COMPONENT_VIEW_TYPE',
         inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler(EMPTY_STEP);
           compiler.compile(
                       new ViewDefinition({componentId: 'someId', template: 'inline component'}))
               .then((protoView) => {
                 expect(protoView.type).toEqual(ViewType.COMPONENT);
                 async.done();
               });
         }));

    });

    describe('compileHost', () => {

      it('should return ProtoViews of type HOST_VIEW_TYPE',
         inject([AsyncTestCompleter], (async) => {
           var compiler = createCompiler(EMPTY_STEP);
           compiler.compileHost(someComponent)
               .then((protoView) => {
                 expect(protoView.type).toEqual(ViewType.HOST);
                 async.done();
               });
         }));

    });

  });
}

class MockStepFactory extends CompileStepFactory {
  steps: List<CompileStep>;
  subTaskPromises: List<Promise<any>>;
  viewDef: ViewDefinition;

  constructor(steps) {
    super();
    this.steps = steps;
  }
  createSteps(viewDef): List<CompileStep> {
    this.viewDef = viewDef;
    return this.steps;
  }
}

class MockStep implements CompileStep {
  processClosure: Function;
  constructor(process) { this.processClosure = process; }
  process(parent: CompileElement, current: CompileElement, control: CompileControl) {
    this.processClosure(parent, current, control);
  }
}

var EMPTY_STEP = (parent, current, control) => {
  if (isPresent(parent)) {
    current.inheritedProtoView = parent.inheritedProtoView;
  }
};

class FakeViewLoader extends ViewLoader {
  _urlData: Map<string, string>;
  constructor(urlData) {
    super(null, null, null);
    this._urlData = urlData;
  }

  load(view: ViewDefinition): Promise<any> {
    if (isPresent(view.template)) {
      return PromiseWrapper.resolve(DOM.createTemplate(view.template));
    }

    if (isPresent(view.templateAbsUrl)) {
      var content = this._urlData.get(view.templateAbsUrl);
      return isPresent(content) ?
                 PromiseWrapper.resolve(DOM.createTemplate(content)) :
                 PromiseWrapper.reject(`Failed to fetch url "${view.templateAbsUrl}"`, null);
    }

    throw new BaseException('View should have either the templateUrl or template property set');
  }
}

var someComponent = DirectiveMetadata.create(
    {selector: 'some-comp', id: 'someComponent', type: DirectiveMetadata.COMPONENT_TYPE});


text:
title: Get Started
is_hidden: false
---

# Falcon+

- [Installation and Usage](http://book.open-falcon.org)
- [Open-Faclon API](http://open-falcon.org/falcon-plus)

# Get Started

*before start , please make sure you prepared [this](https://book.open-falcon.org/zh/install_from_src/prepare.html) ready.*

And then

```
git clone https://github.com/open-falcon/falcon-plus.git
cd falcon-plus/
```

# Compilation

```
# all modules
make all

# specified module
make agent

# pack all modules
make pack
```

* *after `make pack` you will got `open-falcon-vx.x.x.tar.gz`*
* *if you want to edit configure file for each module, you can edit `config/xxx.json` before you do `make pack`*

#  Unpack and Decompose

```
export WorkDir="$HOME/open-falcon"
mkdir -p $WorkDir
tar -xzvf open-falcon-vx.x.x.tar.gz -C $WorkDir
cd $WorkDir
```

# Run Open-Falcon Commands

for example:

```
# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start hbs

./open-falcon check
        falcon-graph         UP           79292
          falcon-hbs         UP           79295
       falcon-sender         UP           79298
        falcon-judge         UP           79301
     falcon-transfer         UP           79304
       falcon-nodata         UP           79307
         falcon-task         UP           79310
   falcon-aggregator         UP           79313
        falcon-agent         UP           79316
      falcon-gateway         UP           79319
          falcon-api         UP           98421
        falcon-alarm         UP           86388

```

* For debugging , You can check `$WorkDir/$moduleName/log/logs/xxx.log`

# Package Management
## How-to

Make sure you're using Go 1.5+ and **GO15VENDOREXPERIMENT=1** env var is exported. (You can ignore GO15VENDOREXPERIMENT using Go 1.6+.)

 0. Install `trash` by `go get github.com/rancher/trash`.
 1. Edit `trash.yml` file to your needs. See the example as follow.
 2. Run `trash --keep` to download the dependencies.

trash file example:

```
package: github.com/open-falcon/falcon-plus

import:
- package: github.com/open-falcon/common              # package name
  version: origin/develop                        # tag, commit, or branch
  repo:    https://github.com/open-falcon/common.git  # (optional) git URL
```

# Package Release

```
make clean all pack
```

# Q&A

Any issue or question is welcome, Please feel free to open github issues:)

redpajama_set_name: RedPajamaGithub


text:
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.NullnessUnspecified;

abstract class NotNullAwareIfCondition {
  abstract int i();

  abstract int j();

  abstract boolean b();

  abstract Boolean boxed();

  abstract @NullnessUnspecified Boolean boxedUnspec();

  abstract @Nullable Boolean boxedUnionNull();

  void go() {
    if (i() == j()) {}

    if (b()) {}

    // jspecify_nullness_not_enough_information
    if (boxed()) {}

    // jspecify_nullness_not_enough_information
    if (boxedUnspec()) {}

    // jspecify_nullness_mismatch
    if (boxedUnionNull()) {}
  }
}


text:
package java.net;

/**
 * This class represents a datagram packet.
 *

 * Datagram packets are used to implement a connectionless packet
 * delivery service. Each message is routed from one machine to
 * another based solely on information contained within that packet.
 * Multiple packets sent from one machine to another might be routed
 * differently, and might arrive in any order. Packet delivery is
 * not guaranteed.
 *
 * @author  Pavani Diwanji
 * @author  Benjamin Renaud
 * @version 1.46, 04/07/06
 * @since   JDK1.0
 */
public final
class DatagramPacket {

    /**
     * Perform class initialization
     */
    static {
	java.security.AccessController.doPrivileged(
		  new sun.security.action.LoadLibraryAction("net"));
	init();
    }

    /*
     * The fields of this class are package-private since DatagramSocketImpl
     * classes needs to access them.
     */
    byte[] buf;
    int offset;
    int length;
    int bufLength;
    InetAddress address;
    int port;

    /**
     * Constructs a DatagramPacket for receiving packets of
     * length length, specifying an offset into the buffer.
     *

     * The length argument must be less than or equal to
     * buf.length.
     *
     * @param   buf      buffer for holding the incoming datagram.
     * @param   offset   the offset for the buffer
     * @param   length   the number of bytes to read.
     *
     * @since 1.2
     */
    public DatagramPacket(byte buf[], int offset, int length) {
	setData(buf, offset, length);
	this.address = null;
	this.port = -1;
    }

    /**
     * Constructs a DatagramPacket for receiving packets of
     * length length.
     *

     * The length argument must be less than or equal to
     * buf.length.
     *
     * @param   buf      buffer for holding the incoming datagram.
     * @param   length   the number of bytes to read.
     */
    public DatagramPacket(byte buf[], int length) {
	this (buf, 0, length);
    }

    /**
     * Constructs a datagram packet for sending packets of length
     * length with offset ioffsetto the
     * specified port number on the specified host. The
     * length argument must be less than or equal to
     * buf.length.
     *
     * @param   buf      the packet data.
     * @param   offset   the packet data offset.
     * @param   length   the packet data length.
     * @param   address  the destination address.
     * @param   port     the destination port number.
     * @see java.net.InetAddress
     *
     * @since 1.2
     */
    public DatagramPacket(byte buf[], int offset, int length,
			  InetAddress address, int port) {
	setData(buf, offset, length);
	setAddress(address);
	setPort(port);
    }

    /**
     * Constructs a datagram packet for sending packets of length
     * length with offset ioffsetto the
     * specified port number on the specified host. The
     * length argument must be less than or equal to
     * buf.length.
     *
     * @param   buf      the packet data.
     * @param   offset   the packet data offset.
     * @param   length   the packet data length.
     * @param   address  the destination socket address.
     * @throws  IllegalArgumentException if address type is not supported
     * @see java.net.InetAddress
     *
     * @since 1.4
     */
    public DatagramPacket(byte buf[], int offset, int length,
			  SocketAddress address) throws SocketException {
	setData(buf, offset, length);
	setSocketAddress(address);
    }

    /**
     * Constructs a datagram packet for sending packets of length
     * length to the specified port number on the specified
     * host. The length argument must be less than or equal
     * to buf.length.
     *
     * @param   buf      the packet data.
     * @param   length   the packet length.
     * @param   address  the destination address.
     * @param   port     the destination port number.
     * @see     java.net.InetAddress
     */
    public DatagramPacket(byte buf[], int length,
			  InetAddress address, int port) {
	this(buf, 0, length, address, port);
    }

    /**
     * Constructs a datagram packet for sending packets of length
     * length to the specified port number on the specified
     * host. The length argument must be less than or equal
     * to buf.length.
     *
     * @param   buf      the packet data.
     * @param   length   the packet length.
     * @param   address  the destination address.
     * @throws  IllegalArgumentException if address type is not supported
     * @since 1.4
     * @see     java.net.InetAddress
     */
    public DatagramPacket(byte buf[], int length,
			  SocketAddress address) throws SocketException {
	this(buf, 0, length, address);
    }

    /**
     * Returns the IP address of the machine to which this datagram is being
     * sent or from which the datagram was received.
     *
     * @return  the IP address of the machine to which this datagram is being
     *          sent or from which the datagram was received.
     * @see     java.net.InetAddress
     * @see #setAddress(java.net.InetAddress)
     */
    public synchronized InetAddress getAddress() {
	return address;
    }

    /**
     * Returns the port number on the remote host to which this datagram is
     * being sent or from which the datagram was received.
     *
     * @return  the port number on the remote host to which this datagram is
     *          being sent or from which the datagram was received.
     * @see #setPort(int)
     */
    public synchronized int getPort() {
	return port;
    }

    /**
     * Returns the data buffer. The data received or the data to be sent
     * starts from the offset in the buffer,
     * and runs for length long.
     *
     * @return  the buffer used to receive or  send data
     * @see #setData(byte[], int, int)
     */
    public synchronized byte[] getData() {
	return buf;
    }

    /**
     * Returns the offset of the data to be sent or the offset of the
     * data received.
     *
     * @return  the offset of the data to be sent or the offset of the
     *          data received.
     *
     * @since 1.2
     */
    public synchronized int getOffset() {
	return offset;
    }

    /**
     * Returns the length of the data to be sent or the length of the
     * data received.
     *
     * @return  the length of the data to be sent or the length of the
     *          data received.
     * @see #setLength(int)
     */
    public synchronized int getLength() {
	return length;
    }

    /**
     * Set the data buffer for this packet. This sets the
     * data, length and offset of the packet.
     *
     * @param buf the buffer to set for this packet
     *
     * @param offset the offset into the data
     *
     * @param length the length of the data
     *       and/or the length of the buffer used to receive data
     *
     * @exception NullPointerException if the argument is null
     *
     * @see #getData
     * @see #getOffset
     * @see #getLength
     *
     * @since 1.2
     */
    public synchronized void setData(byte[] buf, int offset, int length) {
	/* this will check to see if buf is null */
	if (length < 0 || offset < 0 ||
	    ((length + offset) > buf.length)) {
	    throw new IllegalArgumentException("illegal length or offset");
	}
	this.buf = buf;
	this.length = length;
	this.bufLength = length;
	this.offset = offset;
    }

    /**
     * Sets the IP address of the machine to which this datagram
     * is being sent.
     * @param iaddr the InetAddress
     * @since   JDK1.1
     * @see #getAddress()
     */
    public synchronized void setAddress(InetAddress iaddr) {
	address = iaddr;
    }

    /**
     * Sets the port number on the remote host to which this datagram
     * is being sent.
     * @param iport the port number
     * @since   JDK1.1
     * @see #getPort()
     */
    public synchronized void setPort(int iport) {
	if (iport < 0 || iport > 0xFFFF) {
	    throw new IllegalArgumentException("Port out of range:"+ iport);
	}
	port = iport;
    }

    /**
     * Sets the SocketAddress (usually IP address + port number) of the remote
     * host to which this datagram is being sent.
     *
     * @param address the SocketAddress
     * @throws  IllegalArgumentException if address is null or is a
     *          SocketAddress subclass not supported by this socket
     *
     * @since 1.4
     * @see #getSocketAddress
     */
    public synchronized void setSocketAddress(SocketAddress address) {
	if (address == null || !(address instanceof InetSocketAddress))
	    throw new IllegalArgumentException("unsupported address type");
	InetSocketAddress addr = (InetSocketAddress) address;
	if (addr.isUnresolved())
	    throw new IllegalArgumentException("unresolved address");
	setAddress(addr.getAddress());
	setPort(addr.getPort());
    }

    /**
     * Gets the SocketAddress (usually IP address + port number) of the remote
     * host that this packet is being sent to or is coming from.
     *
     * @return the SocketAddress
     * @since 1.4
     * @see #setSocketAddress
     */
    public synchronized SocketAddress getSocketAddress() {
	return new InetSocketAddress(getAddress(), getPort());
    }

    /**
     * Set the data buffer for this packet. With the offset of
     * this DatagramPacket set to 0, and the length set to
     * the length of buf.
     *
     * @param buf the buffer to set for this packet.
     *
     * @exception NullPointerException if the argument is null.
     *
     * @see #getLength
     * @see #getData
     *
     * @since JDK1.1
     */
    public synchronized void setData(byte[] buf) {
	if (buf == null) {
	    throw new NullPointerException("null packet buffer");
	}
	this.buf = buf;
	this.offset = 0;
	this.length = buf.length;
	this.bufLength = buf.length;
    }

    /**
     * Set the length for this packet. The length of the packet is
     * the number of bytes from the packet's data buffer that will be
     * sent, or the number of bytes of the packet's data buffer that
     * will be used for receiving data. The length must be lesser or
     * equal to the offset plus the length of the packet's buffer.
     *
     * @param length the length to set for this packet.
     *
     * @exception IllegalArgumentException if the length is negative
     * of if the length is greater than the packet's data buffer
     * length.
     *
     * @see #getLength
     * @see #setData
     *
     * @since JDK1.1
     */
    public synchronized void setLength(int length) {
	if ((length + offset) > buf.length || length < 0) {
	    throw new IllegalArgumentException("illegal length");
	}
	this.length = length;
	this.bufLength = this.length;
    }

    /**
     * Perform class load-time initializations.
     */
    private native static void init();
}


text:
boardgame-socketserver
======================

A server for pluggable board game implementations, implemented using gevent.

The server included here is designed to work with
`jbradberry/boardgame-socketplayer
<https://github.com/jbradberry/boardgame-socketplayer>`_ and the Monte
Carlo Tree Search implementation `jbradberry/mcts
<https://github.com/jbradberry/mcts>`_.

Requirements
------------

* Python 2.7, 3.5+; PyPy is not supported by the server
* gevent
* six

Getting Started
---------------

To set up your local environment you should create a virtualenv and
install everything into it. ::

    $ mkvirtualenv boardgames

Pip install this repo, either from a local copy, ::

    $ pip install -e boardgame-socketserver

or from github, ::

    $ pip install git+https://github.com/jbradberry/boardgame-socketserver

To run the server with (for example) `Ultimate Tic Tac Toe
<https://github.com/jbradberry/ultimate_tictactoe>`_ ::

    $ board-serve.py t3

Optionally, the server ip address and port number can be added ::

    $ board-serve.py t3 0.0.0.0
    $ board-serve.py t3 0.0.0.0 8000

To connect a client as a human player, using `boardgame-socketplayer
<https://github.com/jbradberry/boardgame-socketplayer>`_ ::

    $ board-play.py t3 human
    $ board-play.py t3 human 192.168.1.1 8000   # with ip addr and port

To connect a client using one of the compatible `Monte Carlo Tree
Search AI <https://github.com/jbradberry/mcts>`_ players ::

    $ board-play.py t3 jrb.mcts.uct    # number of wins metric
    $ board-play.py t3 jrb.mcts.uctv   # point value of the board metric

Games
-----

Compatible games that have been implemented include:

* `Reversi <https://github.com/jbradberry/reversi>`_
* `Connect Four <https://github.com/jbradberry/connect-four>`_
* `Ultimate (or 9x9) Tic Tac Toe
  <https://github.com/jbradberry/ultimate_tictactoe>`_
* `Chong <https://github.com/jbradberry/chong>`_


text:
using System;
using System.Net.Configuration;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using System.Web.Configuration;

namespace MvcTemplate.Components.Mail
{
    public class SmtpMailClient : IMailClient
    {
        public async Task SendAsync(String email, String subject, String body)
        {
            using (SmtpClient client = new SmtpClient())
            {
                String sender = ((SmtpSection)WebConfigurationManager.GetSection("system.net/mailSettings/smtp")).From;
                MailMessage mail = new MailMessage(sender, email, subject, body);
                mail.SubjectEncoding = Encoding.UTF8;
                mail.BodyEncoding = Encoding.UTF8;
                mail.IsBodyHtml = true;

                await client.SendMailAsync(mail);
            }
        }
    }
}


text:
// Copyright (c) 2010-2011 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.IO;
using System.Windows.Forms;
using SharpDX.MediaFoundation;
using SharpDX.Multimedia;

namespace DecodeAudioToWav
{
    /// <summary>
    /// This samples demonstrates how to use <see cref="AudioDecoder"/> to decode any audio file (wma, mp3,... or even video files)
    /// to WAV format. This sample is using also the <see cref="WavWriter"/>
    /// </summary>
    public class Program
    {
        [STAThread]
        private static void Main(string[] args)
        {
            string fileName;
            if (args.Length == 1)
            {
                fileName = args[0];
            }
            else
            {
                var dialog = new OpenFileDialog {Title = "Select an audio file (wma, mp3, ...etc.) or video file..."};
                if (dialog.ShowDialog() != DialogResult.OK)
                    return;
                fileName = dialog.FileName;
            }

            var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            var audioDecoder = new AudioDecoder(stream);

            var outputWavStream = new FileStream("output.wav", FileMode.Create, FileAccess.Write);

            var wavWriter = new WavWriter(outputWavStream);

            // Write the WAV file
            wavWriter.Begin(audioDecoder.WaveFormat);

            // Decode the samples from the input file and output PCM raw data to the WAV stream.
            wavWriter.AppendData(audioDecoder.GetSamples());

            // Close the wav writer.
            wavWriter.End();

            audioDecoder.Dispose();
            outputWavStream.Close();
            stream.Close();
        }
    }
}


text:
require 'helper'

module Bixby
module Test::Controllers
class Rest::Models::Annotations < TestCase

  tests ::Rest::Models::AnnotationsController

  def setup
    super
    @user = FactoryGirl.create(:user)
    sign_in @user
  end

  def test_index
    Bixby::Metrics.new(nil, nil, @user).add_annotation("foobar", [], nil, "baz")
    get :index
    common_assertions
  end

  def test_index_by_name
    Bixby::Metrics.new(nil, nil, @user).add_annotation("frobnicate", [], nil, "bar")
    Bixby::Metrics.new(nil, nil, @user).add_annotation("foobar", [], nil, "baz")
    get :index, :name => "foobar"
    common_assertions
  end

  def test_index_by_detail
    Bixby::Metrics.new(nil, nil, @user).add_annotation("foobar", [], nil, MultiJson.dump({:user => "joe"}))
    Bixby::Metrics.new(nil, nil, @user).add_annotation("foobar", [], nil, MultiJson.dump({:user => "john"}))
    get :index, :name => "foobar", :detail => "user=joe"
    assert @response
    assert_response 200

    data = MultiJson.load(@response.body)
    assert data
    assert_kind_of Array, data
    assert_equal 1, data.size
    detail = MultiJson.load(data.first["detail"])
    assert_equal "joe", detail["user"]
  end

  def test_index_limit
    50.times do
      Bixby::Metrics.new(nil, nil, @user).add_annotation("foobar", [], nil, "baz")
    end

    get :index
    assert @response
    assert_response 200
    data = MultiJson.load(@response.body)
    assert_equal 20, data.size
  end

  private

  def common_assertions
    assert @response
    assert_response 200

    data = MultiJson.load(@response.body)
    assert data
    assert_kind_of Array, data
    assert_equal 1, data.size
    a = data.first
    assert a
    assert_equal "foobar", a["name"]
    assert_equal "baz", a["detail"]
    assert_empty a["tags"]
  end

end
end
end


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317663 $ -->

<refentry xml:id="function.gupnp-context-timeout-add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>gupnp_context_timeout_add</refname>
  <refpurpose>Sets a function to be called at regular intervals</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>gupnp_context_timeout_add</methodname>
   <methodparam><type>resource</type><parameter>context</parameter></methodparam>
   <methodparam><type>int</type><parameter>timeout</parameter></methodparam>
   <methodparam><type>mixed</type><parameter>callback</parameter></methodparam>
   <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam>
  </methodsynopsis>
  <para>
   Sets a function to be called at regular intervals.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>context</parameter></term>
     <listitem>
      <para>
       A context identifier, returned by <function>gupnp_context_new</function>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>timeout</parameter></term>
     <listitem>
      <para>
       A timeout in miliseconds.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>callback</parameter></term>
     <listitem>
      <para>
       The callback function calling every <parameter>timeout</parameter> period of time.
       Typically, callback function takes on <parameter>arg</parameter> parameter.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>arg</parameter></term>
     <listitem>
      <para>
       User data for <parameter>callback</parameter>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Create new UPnP context and set callback</title>
    <programlisting role="php">
<![CDATA[
<?php

$user_data = "user data";

function timeout_cb($arg)
{
    printf("Call timeout_cb, user data: '%s'", $arg);
    return true;
}

/* Create the UPnP context */
$context = gupnp_context_new();

if (!$context) {
 die("Error creating the GUPnP context\n");
}

/* Create root device */
$dev = gupnp_root_device_new($context, "/devicedesc.xml");

/* Set callback for timeout */
gupnp_context_timeout_add($context, 5000, "timeout_cb", $user_data);

/* Run the main loop */
gupnp_root_device_start($dev);

?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   Issues E_WARNING with not valid callback function.
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>gupnp_context_new</function></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


text:
package ipamplugin

import (
	"fmt"
	"net"
	"strings"

	"github.com/docker/libnetwork/ipamapi"
	"github.com/docker/libnetwork/netlabel"
	"github.com/weaveworks/weave/api"
	. "github.com/weaveworks/weave/common"
	"github.com/weaveworks/weave/common/docker"
)

const (
	WeaveContainer = "weave"
)

type ipam struct {
	client *docker.Client
	weave  *api.Client
}

func NewIpam(client *docker.Client, version string) (ipamapi.Ipam, error) {
	resolver := func() (string, error) { return client.GetContainerIP(WeaveContainer) }
	return &ipam{client: client, weave: api.NewClientWithResolver(resolver)}, nil
}

func (i *ipam) GetDefaultAddressSpaces() (string, string, error) {
	Log.Debugln("GetDefaultAddressSpaces")
	return "weavelocal", "weaveglobal", nil
}

func (i *ipam) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (poolname string, subnet *net.IPNet, data map[string]string, err error) {
	Log.Debugln("RequestPool", addressSpace, pool, subPool, options)
	defer func() { Log.Debugln("RequestPool returning", poolname, subnet, data, err) }()
	if pool == "" {
		subnet, err = i.weave.DefaultSubnet()
	} else {
		_, subnet, err = net.ParseCIDR(pool)
	}
	if err != nil {
		return
	}
	iprange := subnet
	if subPool != "" {
		if _, iprange, err = net.ParseCIDR(subPool); err != nil {
			return
		}
	}
	// Cunningly-constructed pool "name" which gives us what we need later
	poolname = strings.Join([]string{"weave", subnet.String(), iprange.String()}, "-")
	// Pass back a fake "gateway address"; we don't actually use it,
	// so just give the network address.
	data = map[string]string{netlabel.Gateway: subnet.String()}
	return
}

func (i *ipam) ReleasePool(poolID string) error {
	Log.Debugln("ReleasePool", poolID)
	return nil
}

func (i *ipam) RequestAddress(poolID string, address net.IP, options map[string]string) (ip *net.IPNet, _ map[string]string, err error) {
	Log.Debugln("RequestAddress", poolID, address, options)
	defer func() { Log.Debugln("allocateIP returned", ip, err) }()
	// If we pass magic string "_" to weave IPAM it stores the address under its own string
	if poolID == "weavepool" { // old-style
		ip, err = i.weave.AllocateIP("_")
		return
	}
	parts := strings.Split(poolID, "-")
	if len(parts) != 3 || parts[0] != "weave" {
		err = fmt.Errorf("Unrecognized pool ID: %s", poolID)
		return
	}
	var subnet, iprange *net.IPNet
	if _, subnet, err = net.ParseCIDR(parts[1]); err != nil {
		return
	}
	if _, iprange, err = net.ParseCIDR(parts[2]); err != nil {
		return
	}
	// We are lying slightly to IPAM here: the range is not a subnet
	if ip, err = i.weave.AllocateIPInSubnet("_", iprange); err != nil {
		return
	}
	ip.Mask = subnet.Mask // fix up the subnet we lied about
	return
}

func (i *ipam) ReleaseAddress(poolID string, address net.IP) error {
	Log.Debugln("ReleaseAddress", poolID, address)
	return i.weave.ReleaseIP(address.String())
}


text:
struct GpaHardwareCounterDesc;
#include "auto_generated/gpu_perf_api_counter_generator/gpa_hw_counter_gfx9.h"

namespace counter_gfx9_gfx909
{
/// @brief Uses the input ASIC type to determine if this data provides an ASIC specific version.
///
/// @param [in] asic_type The ASIC type that is currently in use.
///
/// @return True if the ASIC is matched by this file.
inline bool MatchAsic(GDT_HW_ASIC_TYPE asic_type)
{
    static std::set<GDT_HW_ASIC_TYPE> asics_supported = { GDT_GFX9_0_9, GDT_GFX9_0_C };

    if (asics_supported.find(asic_type) == asics_supported.end())
    {
        return false;
    }

    return true;
}

    extern GpaHardwareCounterDesc kCb0CountersGfx9_gfx909[]; ///< Array of internal counters for Cb0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb1CountersGfx9_gfx909[]; ///< Array of internal counters for Cb1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb2CountersGfx9_gfx909[]; ///< Array of internal counters for Cb2 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb3CountersGfx9_gfx909[]; ///< Array of internal counters for Cb3 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb4CountersGfx9_gfx909[]; ///< Array of internal counters for Cb4 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb5CountersGfx9_gfx909[]; ///< Array of internal counters for Cb5 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb6CountersGfx9_gfx909[]; ///< Array of internal counters for Cb6 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb7CountersGfx9_gfx909[]; ///< Array of internal counters for Cb7 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb8CountersGfx9_gfx909[]; ///< Array of internal counters for Cb8 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb9CountersGfx9_gfx909[]; ///< Array of internal counters for Cb9 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb10CountersGfx9_gfx909[]; ///< Array of internal counters for Cb10 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb11CountersGfx9_gfx909[]; ///< Array of internal counters for Cb11 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb12CountersGfx9_gfx909[]; ///< Array of internal counters for Cb12 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb13CountersGfx9_gfx909[]; ///< Array of internal counters for Cb13 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb14CountersGfx9_gfx909[]; ///< Array of internal counters for Cb14 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kCb15CountersGfx9_gfx909[]; ///< Array of internal counters for Cb15 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSu0CountersGfx9_gfx909[]; ///< Array of internal counters for PaSu0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSu1CountersGfx9_gfx909[]; ///< Array of internal counters for PaSu1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSu2CountersGfx9_gfx909[]; ///< Array of internal counters for PaSu2 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSu3CountersGfx9_gfx909[]; ///< Array of internal counters for PaSu3 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSc0CountersGfx9_gfx909[]; ///< Array of internal counters for PaSc0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSc1CountersGfx9_gfx909[]; ///< Array of internal counters for PaSc1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSc2CountersGfx9_gfx909[]; ///< Array of internal counters for PaSc2 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kPaSc3CountersGfx9_gfx909[]; ///< Array of internal counters for PaSc3 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc0CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc1CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc2CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc2 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc3CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc3 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc4CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc4 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc5CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc5 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc6CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc6 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc7CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc7 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc8CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc8 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc9CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc9 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc10CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc10 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc11CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc11 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc12CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc12 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc13CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc13 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc14CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc14 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kTcc15CountersGfx9_gfx909[]; ///< Array of internal counters for Tcc15 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kIa0CountersGfx9_gfx909[]; ///< Array of internal counters for Ia0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kIa1CountersGfx9_gfx909[]; ///< Array of internal counters for Ia1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kRpbCountersGfx9_gfx909[]; ///< Array of internal counters for Rpb block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea0CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea0 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea1CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea1 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea2CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea2 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea3CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea3 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea4CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea4 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea5CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea5 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea6CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea6 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea7CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea7 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea8CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea8 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea9CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea9 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea10CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea10 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea11CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea11 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea12CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea12 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea13CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea13 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea14CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea14 block for Gfx9_gfx909 family
    extern GpaHardwareCounterDesc kGcea15CountersGfx9_gfx909[]; ///< Array of internal counters for Gcea15 block for Gfx9_gfx909 family

/// @brief Replaces count number of block instance counters at the destination with the overriding source counters.
///
/// @param [in] dest_counter Destination to update.
/// @param [in] src_counter Source to update from.
/// @param [in] count Number of counters to update.
inline void ReplaceBlockInstanceCounters(GpaHardwareCounterDesc* dest_counter, GpaHardwareCounterDesc* src_counter, uint32_t count)
{
    for (uint32_t i = 0; i < count; i++)
    {
        dest_counter[i] = src_counter[i];
    }
}

/// @brief If the requested ASIC type is supported, then the global GPU generation block instance counters are updated.
///
/// @param [in] asic_type The ASIC type that is currently in use.
///
/// @return True if the ASIC is matched by this file and block instances are updated, otherwise false.
inline bool OverrideBlockInstanceCounters(GDT_HW_ASIC_TYPE asic_type)
{
    if (!MatchAsic(asic_type))
    {
        return false;
    }

    ReplaceBlockInstanceCounters(counter_gfx9::kCb0CountersGfx9, kCb0CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb1CountersGfx9, kCb1CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb2CountersGfx9, kCb2CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb3CountersGfx9, kCb3CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb4CountersGfx9, kCb4CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb5CountersGfx9, kCb5CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb6CountersGfx9, kCb6CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb7CountersGfx9, kCb7CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb8CountersGfx9, kCb8CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb9CountersGfx9, kCb9CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb10CountersGfx9, kCb10CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb11CountersGfx9, kCb11CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb12CountersGfx9, kCb12CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb13CountersGfx9, kCb13CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb14CountersGfx9, kCb14CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kCb15CountersGfx9, kCb15CountersGfx9_gfx909, 444);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSu0CountersGfx9, kPaSu0CountersGfx9_gfx909, 351);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSu1CountersGfx9, kPaSu1CountersGfx9_gfx909, 351);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSu2CountersGfx9, kPaSu2CountersGfx9_gfx909, 351);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSu3CountersGfx9, kPaSu3CountersGfx9_gfx909, 351);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSc0CountersGfx9, kPaSc0CountersGfx9_gfx909, 492);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSc1CountersGfx9, kPaSc1CountersGfx9_gfx909, 492);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSc2CountersGfx9, kPaSc2CountersGfx9_gfx909, 492);
    ReplaceBlockInstanceCounters(counter_gfx9::kPaSc3CountersGfx9, kPaSc3CountersGfx9_gfx909, 492);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc0CountersGfx9, kTcc0CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc1CountersGfx9, kTcc1CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc2CountersGfx9, kTcc2CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc3CountersGfx9, kTcc3CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc4CountersGfx9, kTcc4CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc5CountersGfx9, kTcc5CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc6CountersGfx9, kTcc6CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc7CountersGfx9, kTcc7CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc8CountersGfx9, kTcc8CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc9CountersGfx9, kTcc9CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc10CountersGfx9, kTcc10CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc11CountersGfx9, kTcc11CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc12CountersGfx9, kTcc12CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc13CountersGfx9, kTcc13CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc14CountersGfx9, kTcc14CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kTcc15CountersGfx9, kTcc15CountersGfx9_gfx909, 256);
    ReplaceBlockInstanceCounters(counter_gfx9::kIa0CountersGfx9, kIa0CountersGfx9_gfx909, 31);
    ReplaceBlockInstanceCounters(counter_gfx9::kIa1CountersGfx9, kIa1CountersGfx9_gfx909, 31);
    ReplaceBlockInstanceCounters(counter_gfx9::kRpbCountersGfx9, kRpbCountersGfx9_gfx909, 63);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea0CountersGfx9, kGcea0CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea1CountersGfx9, kGcea1CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea2CountersGfx9, kGcea2CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea3CountersGfx9, kGcea3CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea4CountersGfx9, kGcea4CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea5CountersGfx9, kGcea5CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea6CountersGfx9, kGcea6CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea7CountersGfx9, kGcea7CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea8CountersGfx9, kGcea8CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea9CountersGfx9, kGcea9CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea10CountersGfx9, kGcea10CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea11CountersGfx9, kGcea11CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea12CountersGfx9, kGcea12CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea13CountersGfx9, kGcea13CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea14CountersGfx9, kGcea14CountersGfx9_gfx909, 83);
    ReplaceBlockInstanceCounters(counter_gfx9::kGcea15CountersGfx9, kGcea15CountersGfx9_gfx909, 83);

    return true;
}

bool OverrideMaxBlockEvents(GDT_HW_ASIC_TYPE asic_type);
} // counter_gfx9_gfx909

#endif  // GPA_AUTO_GENERATED_GPU_PERF_API_COUNTER_GENERATOR_GPA_HW_COUNTER_GFX9_GFX909_H_

// clang-format on


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using NUnit.Compatibility;

namespace NUnit.TestUtilities
{
    public class TestFile : IDisposable
    {
        private bool _disposedValue = false;
        private string _resourceName;
        private FileInfo _fileInfo;
        private long _fileLength;

        public TestFile(string fileName, string resourceName)
            : this(fileName, resourceName, false)
        {
        }

        public TestFile(string fileName, string contentSource, bool isContent)
        {
            if (Path.IsPathRooted(fileName))
                _fileInfo = new FileInfo(fileName);
            else
            {
                var tempPath = Path.GetTempPath();
                _fileInfo = new FileInfo(Path.Combine(tempPath, fileName));
            }

            if (isContent)
            {
                using (var fs = _fileInfo.CreateText())
                {
                    fs.Write(contentSource);
                }

                _fileLength = contentSource.Length;
                return;
            }

            // HACK! Only way I can figure out to avoid having two copies of TestFile
            _resourceName = GetType().GetTypeInfo().Assembly.GetName().Name.Contains("nunitlite")
                ? "NUnitLite.Tests." + contentSource
                : "NUnit.Framework.Tests." + contentSource;
            _fileLength = 0L;

            Assembly a = typeof(TestFile).GetTypeInfo().Assembly;
            using (Stream s = a.GetManifestResourceStream(_resourceName))
            {
                if (s == null)
                    throw new Exception("Manifest Resource Stream " + _resourceName + " was not found.");

                var buffer = new byte[1024];
                using (FileStream fs = _fileInfo.Create())
                {
                    while (true)
                    {
                        int count = s.Read(buffer, 0, buffer.Length);
                        if (count == 0)
                            break;
                        fs.Write(buffer, 0, count);
                        _fileLength += count;
                    }
                }
            }
        }

        public long FileLength
        {
            get { return _fileLength; }
        }

        public long OffsetOf(char target)
        {
            if (_resourceName == null)
                return -1L;

            Assembly a = typeof(TestFile).GetTypeInfo().Assembly;
            using (Stream s = a.GetManifestResourceStream(_resourceName))
            {
                if (s == null)
                    throw new Exception("Manifest Resource Stream " + _resourceName + " was not found.");

                byte[] buffer = new byte[1024];
                long offset = 0L;

                while (true)
                {
                    int count = s.Read(buffer, 0, buffer.Length);
                    if (count == 0)
                        break;
                    foreach (char c in buffer)
                        if (c == target)
                            return offset;
                        else
                            offset++;
                }

                return -1L;
            }
        }

        /// <summary>
        /// Gets the test file.
        /// </summary>
        public FileInfo File { get { return _fileInfo; } }

        /// <summary>
        /// Returns the full path of the contained test directory
        /// </summary>
        public override string ToString()
        {
            return _fileInfo == null ? string.Empty : _fileInfo.FullName;
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
                if (disposing)
                    if (_fileInfo.Exists)
                        _fileInfo.Delete();

            _disposedValue = true;
        }

        #region IDisposable Members

        public void Dispose()
        {
            // Do not change this code.  Put cleanup code in Dispose(bool disposing) above.
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        #endregion
    }
}
#endif


text:
Task: Genderation Bias
======================
Description: The task in this directory is not a task itself, but rather a wrapper. The task will flatten a specified other ParlAI task (that is, turn multi-turn episodes into single-turn examples), and append a control token that corresponds with the level of gender present in the label, where word lists from https://github.com/uclanlp/gn_glove/blob/main/wordlist/ are used to count the number of gendered words. Depending on the counts, the control token will be one of the following:

- `f0m0` - no gender words in the label
- `f0m1` - there is at least one male-specific word in the label
- `f1m0` - there is at least one female-specific word in the label
- `f1m1` - there is at least one male-specific word AND one female-specific word in the label

For example, one could run the following command:

```
$ parlai display_data -t genderation_bias:controllable_task:convai2
```

Which would yield the following:

```
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ? f1m0
   i am spending time with my 4 sisters what are you up to
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ?
i am spending time with my 4 sisters what are you up to
wow , four sisters . just watching game of thrones . f0m0
   that is a good show i watch that while drinking iced tea
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ?
i am spending time with my 4 sisters what are you up to
wow , four sisters . just watching game of thrones .
that is a good show i watch that while drinking iced tea
i agree . what do you do for a living ? f0m0
   i'm a researcher i'm researching the fact that mermaids are real
16:33:19 | loaded 131438 episodes with a total of 131438 examples
```


text:
package hydrograph.ui.perspective.config;

// TODO: Auto-generated Javadoc
/**
 *
 * @author Bitwise
 * Aug 28, 2015
 *
 */

public enum ELTPerspectives {
	ETLPerspective("hydrograph.ui.perspective.ETLPerspective");

	private final String perspectiveID;

	private ELTPerspectives(final String perspectiveID){
		this.perspectiveID = perspectiveID;
	}

	/**
	 * Contains.
	 *
	 * @param perspectiveID
	 *            the perspective id
	 * @return true, if successful
	 */
	public static boolean contains(String perspectiveID){
		for(ELTPerspectives eltPerspective : ELTPerspectives.values()){
			if(eltPerspective.toString().equals(perspectiveID)){
				return true;
			}
		}
		return false;
	}

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


text:
package org.matrix.androidsdk.rest.api;

import org.matrix.androidsdk.data.Pusher;
import org.matrix.androidsdk.rest.model.PushersResponse;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;

/**
 * The pusher API
 */
public interface PushersApi {
    @POST("pushers/set")
    Call<Void> set(@Body Pusher pusher);

    @GET("pushers")
    Call<PushersResponse> get();
}


text:
TODO: finish API doc

## Response Header

All Responses from etcd API have a [response header][response_header] attached. The response header includes the metadata of the response.

```proto
message ResponseHeader {
  uint64 cluster_id = 1;
  uint64 member_id = 2;
  int64 revision = 3;
  uint64 raft_term = 4;
}
```

* Cluster_ID - the ID of the cluster that generates the response
* Member_ID - the ID of the member that generates the response
* Revision - the revision of the key-value store when the response is generated
* Raft_Term - the Raft term of the member when the response is generated

An application may read the Cluster_ID (Member_ID) field to ensure it is communicating with the intended cluster (member).

Applications can use the `Revision` to know the latest revision of the key-value store. This is especially useful when applications specify a historical revision to make time `travel query` and wishes to know the latest revision at the time of the request.

Applications can use `Raft_Term` to detect when the cluster completes a new leader election.

## Key-Value API

Key-Value API is used to manipulate key-value pairs stored inside etcd. The key-value API is defined as a [gRPC service][kv-service]. The Key-Value pair is defined as structured data in [protobuf format][kv-proto].

### Key-Value Pair

A key-value pair is the smallest unit that the key-value API can manipulate. Each key-value pair has a number of fields:

```protobuf
message KeyValue {
  bytes key = 1;
  int64 create_revision = 2;
  int64 mod_revision = 3;
  int64 version = 4;
  bytes value = 5;
  int64 lease = 6;
}
```

* Key - key in bytes. An empty key is not allowed.
* Value - value in bytes.
* Version - version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version.
* Create_Revision - revision of the last creation on the key.
* Mod_Revision - revision of the last modification on the key.
* Lease - the ID of the lease attached to the key. If lease is 0, then no lease is attached to the key.

## Data Model

etcd is designed to reliably store infrequently updated data and provide reliable watch queries. etcd exposes previous versions of key-value pairs to support inexpensive snapshots and watch history events ("time travel queries"). A persistent, multi-version, concurrency-control data model is a good fit for these use cases.

etcd stores data in a multiversion [persistent][persistent-ds] key-value store. The persistent key-value store preserves the previous version of a key-value pair when its value is superseded with new data. The key-value store is effectively immutable; its operations do not update the structure in-place, but instead always generates a new updated structure. All past versions of keys are still accessible and watchable after modification. To prevent the data store from growing indefinitely over time from maintaining old versions, the store may be compacted to shed the oldest versions of superseded data.

### Logical View

The store's logical view is a flat binary key space. The key space has a lexically sorted index on byte string keys so range queries are inexpensive.

The key space maintains multiple revisions. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to recover space, revisions before the compact revision will be removed.

A key's lifetime spans a generation. Each key may have one or multiple generations. Creating a key increments the generation of that key, starting at 1 if the key never existed. Deleting a key generates a key tombstone, concluding the key's current generation. Each modification of a key creates a new version of the key. Once a compaction happens, any generation ended before the given revision will be removed and values set before the compaction revision except the latest one will be removed.

### Physical View

etcd stores the physical data as key-value pairs in a persistent [b+tree][b+tree]. Each revision of the store's state only contains the delta from its previous revision to be efficient. A single revision may correspond to multiple keys in the tree.

The key of key-value pair is a 3-tuple (major, sub, type). Major is the store revision holding the key. Sub differentiates among  keys within the same revision. Type is an optional suffix for special value (e.g., `t` if the value contains a tombstone). The value of the key-value pair contains the modification from previous revision, thus one delta from previous revision. The b+tree is ordered by key in lexical byte-order. Ranged lookups over revision deltas are fast; this enables quickly finding modifications from one specific revision to another. Compaction removes out-of-date keys-value pairs.

etcd also keeps a secondary in-memory [btree][btree] index to speed up range queries over keys. The keys in the btree index are the keys of the store exposed to user. The value is a pointer to the modification of the persistent b+tree. Compaction removes dead pointers.

## KV API Guarantees

etcd is a consistent and durable key value store with mini-transaction(TODO: link to txn doc when we have it) support. The key value store is exposed through the KV APIs. etcd tries to ensure the strongest consistency and durability guarantees for a distributed system. This specification enumerates the KV API guarantees made by etcd.

### APIs to consider

* Read APIs
    * range
    * watch
* Write APIs
    * put
    * delete
* Combination (read-modify-write) APIs
    * txn

### etcd Specific Definitions

#### operation completed

An etcd operation is considered complete when it is committed through consensus, and therefore "executed" -- permanently stored -- by the etcd storage engine. The client knows an operation is completed when it receives a response from the etcd server. Note that the client may be uncertain about the status of an operation if it times out, or there is a network disruption between the client and the etcd member. etcd may also abort operations when there is a leader election. etcd does not send `abort` responses to  clients' outstanding requests in this event.

#### revision

An etcd operation that modifies the key value store is assigned with a single increasing revision. A transaction operation might modifies the key value store multiple times, but only one revision is assigned. The revision attribute of a key value pair that modified by the operation has the same value as the revision of the operation. The revision can be used as a logical clock for key value store. A key value pair that has a larger revision is modified after a key value pair with a smaller revision. Two key value pairs that have the same revision are modified by an operation "concurrently".

### Guarantees Provided

#### Atomicity

All API requests are atomic; an operation either completes entirely or not at all. For watch requests, all events generated by one operation will be in one watch response. Watch never observes partial events for a single operation.

#### Consistency

All API calls ensure [sequential consistency][seq_consistency], the strongest consistency guarantee available from distributed systems. No matter which etcd member server a client makes requests to, a client reads the same events in the same order. If two members complete the same number of operations, the state of the two members is consistent.

For watch operations, etcd guarantees to return the same value for the same key across all members for the same revision. For range operations, etcd has a similar guarantee for [linearized][Linearizability] access; serialized access may be behind the quorum state, so that the later revision is not yet available.

As with all distributed systems, it is impossible for etcd to ensure [strict consistency][strict_consistency]. etcd does not guarantee that it will return to a read the "most recent" value (as measured by a wall clock when a request is completed) available on any cluster member.

#### Isolation

etcd ensures [serializable isolation][serializable_isolation], which is the highest isolation level available in distributed systems. Read operations will never observe any intermediate data.

#### Durability

Any completed operations are durable. All accessible data is also durable data. A read will never return data that has not been made durable.

#### Linearizability

Linearizability (also known as Atomic Consistency or External Consistency) is a consistency level between strict consistency and sequential consistency.

For linearizability, suppose each operation receives a timestamp from a loosely synchronized global clock. Operations are linearized if and only if they always complete as though they were executed in a sequential order and each operation appears to complete in the order specified by the program. Likewise, if an operation's timestamp precedes another, that operation must also precede the other operation in the sequence.

For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*, and the returned value, current at *t2* when the read began, might be "stale" by *t3*.

etcd does not ensure linearizability for watch operations. Users are expected to verify the revision of watch responses to ensure correct ordering.

etcd ensures linearizability for all other operations by default. Linearizability comes with a cost, however, because linearized requests must go through the Raft consensus process. To obtain lower latencies and higher throughput for read requests, clients can configure a request's consistency mode to `serializable`, which may access stale data with respect to quorum, but removes the performance penalty of linearized accesses' reliance on live consensus.

[persistent-ds]: https://en.wikipedia.org/wiki/Persistent_data_structure
[btree]: https://en.wikipedia.org/wiki/B-tree
[b+tree]: https://en.wikipedia.org/wiki/B%2B_tree
[seq_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Sequential_consistency
[strict_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Strict_consistency
[serializable_isolation]: https://en.wikipedia.org/wiki/Isolation_(database_systems)#Serializable
[Linearizability]: #Linearizability
[kv-proto]: https://github.com/coreos/etcd/blob/master/mvcc/mvccpb/kv.proto
[kv-service]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto
[response_header]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto


text:
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

/*
 * @author max
 */
package com.intellij.openapi.wm.impl.welcomeScreen;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
import com.intellij.openapi.util.DimensionService;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.WelcomeScreen;
import com.intellij.ui.ScreenUtil;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class NewWelcomeScreen extends JPanel implements WelcomeScreen {

  public NewWelcomeScreen() {
    super(new BorderLayout());
    add(createHeaderPanel(), BorderLayout.NORTH);
    add(createFooterPanel(), BorderLayout.SOUTH);
    add(createInnerPanel(this), BorderLayout.CENTER);
  }

  private static WelcomePane createInnerPanel(WelcomeScreen screen) {
    WelcomeScreenGroup root = new WelcomeScreenGroup(null, "Quick Start");

    ActionManager actionManager = ActionManager.getInstance();
    ActionGroup quickStart = (ActionGroup)actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
    for (AnAction child : quickStart.getChildren(null)) {
      root.add(child);
    }

    root.add(buildRootGroup(AllIcons.General.Settings, "Configure", IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE));
    root.add(buildRootGroup(AllIcons.Actions.Help, "Docs and How-Tos", IdeActions.GROUP_WELCOME_SCREEN_DOC));

    // so, we sure this is the last action
    final AnAction register = actionManager.getAction("WelcomeScreen.Register");
    if (register != null) {
      root.add(register);
    }
    return new WelcomePane(root, screen);
  }

  private static WelcomeScreenGroup buildRootGroup(@NotNull Icon groupIcon, @NotNull String groupText, @NotNull String groupId) {
    WelcomeScreenGroup result = new WelcomeScreenGroup(groupIcon, groupText);
    ActionGroup docsActions = (ActionGroup)ActionManager.getInstance().getAction(groupId);
    for (AnAction child : docsActions.getChildren(null)) {
      result.add(child);
    }
    return result;
  }

  private static JPanel createFooterPanel() {
    JLabel versionLabel = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName() +
                             " " +
                             ApplicationInfo.getInstance().getFullVersion() +
                             " Build " +
                             ApplicationInfo.getInstance().getBuild().asStringWithoutProductCode());
    makeSmallFont(versionLabel);
    versionLabel.setForeground(WelcomeScreenColors.FOOTER_FOREGROUND);

    JPanel footerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    footerPanel.setBackground(WelcomeScreenColors.FOOTER_BACKGROUND);
    footerPanel.setBorder(new EmptyBorder(2, 5, 2, 5) {
      @Override
      public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        g.setColor(WelcomeScreenColors.BORDER_COLOR);
        g.drawLine(x, y, x + width, y);
      }
    });
    footerPanel.add(versionLabel);
    footerPanel.add(makeSmallFont(new JLabel(".  ")));
    footerPanel.add(makeSmallFont(new LinkLabel("Check", null, new LinkListener() {
      @Override
      public void linkSelected(LinkLabel aSource, Object aLinkData) {
        UpdateChecker.updateAndShowResult(null, null);
      }
    })));
    footerPanel.add(makeSmallFont(new JLabel(" for updates now.")));
    return footerPanel;
  }

  private static JLabel makeSmallFont(JLabel label) {
    label.setFont(label.getFont().deriveFont((float)10));
    return label;
  }

  private static JPanel createHeaderPanel() {
    JPanel header = new JPanel(new BorderLayout());
    JLabel welcome = new JLabel("Welcome to " + ApplicationNamesInfo.getInstance().getFullProductName(),
                                IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getWelcomeScreenLogoUrl()),
                                SwingConstants.LEFT);
    welcome.setBorder(new EmptyBorder(10, 15, 10, 15));
    welcome.setFont(welcome.getFont().deriveFont((float) 32));
    welcome.setIconTextGap(20);
    welcome.setForeground(WelcomeScreenColors.WELCOME_HEADER_FOREGROUND);
    header.add(welcome);
    header.setBackground(WelcomeScreenColors.WELCOME_HEADER_BACKGROUND);

    header.setBorder(new BottomLineBorder());
    return header;
  }

  @Override
  public JComponent getWelcomePanel() {
    return this;
  }

  @Override
  public void setupFrame(JFrame frame) {
    frame.setResizable(false);
    frame.pack();
    Point location = DimensionService.getInstance().getLocation(WelcomeFrame.DIMENSION_KEY, null);
    Rectangle screenBounds = ScreenUtil.getScreenRectangle(location != null ? location : new Point(0, 0));
    frame.setLocation(new Point(
      screenBounds.x + (screenBounds.width - frame.getWidth()) / 2,
      screenBounds.y + (screenBounds.height - frame.getHeight()) / 3
    ));
  }

  @Override
  public void dispose() {
  }

  public static boolean isNewWelcomeScreen(@NotNull AnActionEvent e) {
    return e.getPlace() == ActionPlaces.WELCOME_SCREEN;
  }

  private static class WelcomeScreenGroup extends DefaultActionGroup {
    private WelcomeScreenGroup(Icon icon, String text, AnAction... actions) {
      super(text, true);
      for (AnAction action : actions) {
        add(action);
      }

      getTemplatePresentation().setText(text);
      getTemplatePresentation().setIcon(icon);
    }
  }
}


text:
PKGNAME=	${DISTNAME:C/-/10-plpython-/}
COMMENT=	PL/Python procedural language for the PostgreSQL backend
PKGREVISION=	1

DEPENDS+=	postgresql10-server>=${PKGVERSION_NOREV}:../../base/postgresql10-server

.include "../../base/postgresql10/Makefile.common"

CONFIGURE_ARGS+=	--with-python
CONFIGURE_ENV+=		PYTHON="${PYTHONBIN}"
BUILD_MAKE_FLAGS=	PGXS=1

BUILD_DIRS=		src/pl/plpython contrib/hstore_plpython

.include "../../base/postgresql10-client/buildlink3.mk"
.include "../../lang/python/extension.mk"
.include "../../mk/bsd.pkg.mk"


text:
/**
 * Singpath services.
 *
 * Note: if a service usage is limited to a component, it should be defined with the component.
 */
'use strict';

import {singpath} from '../module.js';
import * as datastore from'./datastore.js';
import * as routes from './routes.js';

singpath.constant('routes', routes.map);
singpath.factory('spfDataStore', datastore.factory);


text:
package com.decaflabs.trux.site;

public interface Surface {

	public String soilSample();

}


text:
import random

import eventlet
import mock
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils

from neutron.agent.common import config as agent_config
from neutron.agent.common import ovs_lib
from neutron.agent.l2.extensions import manager as ext_manager
from neutron.agent.linux import interface
from neutron.agent.linux import polling
from neutron.agent.linux import utils as agent_utils
from neutron.common import config as common_config
from neutron.common import constants as n_const
from neutron.common import utils
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import config \
    as ovs_config
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl \
    import br_int
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl \
    import br_phys
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl \
    import br_tun
from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_neutron_agent \
    as ovs_agent
from neutron.tests.common import net_helpers
from neutron.tests.functional.agent.linux import base

LOG = logging.getLogger(__name__)

class OVSAgentTestFramework(base.BaseOVSLinuxTestCase):

    def setUp(self):
        super(OVSAgentTestFramework, self).setUp()
        agent_rpc = ('neutron.plugins.ml2.drivers.openvswitch.agent.'
                     'ovs_neutron_agent.OVSPluginApi')
        mock.patch(agent_rpc).start()
        mock.patch('neutron.agent.rpc.PluginReportStateAPI').start()
        self.br_int = base.get_rand_name(n_const.DEVICE_NAME_MAX_LEN,
                                         prefix='br-int')
        self.br_tun = base.get_rand_name(n_const.DEVICE_NAME_MAX_LEN,
                                         prefix='br-tun')
        patch_name_len = n_const.DEVICE_NAME_MAX_LEN - len("-patch-tun")
        self.patch_tun = "%s-patch-tun" % self.br_int[patch_name_len:]
        self.patch_int = "%s-patch-int" % self.br_tun[patch_name_len:]
        self.ovs = ovs_lib.BaseOVS()
        self.config = self._configure_agent()
        self.driver = interface.OVSInterfaceDriver(self.config)
        self.namespace = self.useFixture(net_helpers.NamespaceFixture()).name

    def _get_config_opts(self):
        config = cfg.ConfigOpts()
        config.register_opts(common_config.core_opts)
        config.register_opts(interface.OPTS)
        config.register_opts(ovs_config.ovs_opts, "OVS")
        config.register_opts(ovs_config.agent_opts, "AGENT")
        agent_config.register_interface_driver_opts_helper(config)
        agent_config.register_agent_state_opts_helper(config)
        ext_manager.register_opts(config)
        return config

    def _configure_agent(self):
        config = self._get_config_opts()
        config.set_override(
            'interface_driver',
            'neutron.agent.linux.interface.OVSInterfaceDriver')
        config.set_override('integration_bridge', self.br_int, "OVS")
        config.set_override('ovs_integration_bridge', self.br_int)
        config.set_override('tunnel_bridge', self.br_tun, "OVS")
        config.set_override('int_peer_patch_port', self.patch_tun, "OVS")
        config.set_override('tun_peer_patch_port', self.patch_int, "OVS")
        config.set_override('host', 'ovs-agent')
        return config

    def _bridge_classes(self):
        return {
            'br_int': br_int.OVSIntegrationBridge,
            'br_phys': br_phys.OVSPhysicalBridge,
            'br_tun': br_tun.OVSTunnelBridge
        }

    def create_agent(self, create_tunnels=True):
        if create_tunnels:
            tunnel_types = [p_const.TYPE_VXLAN]
        else:
            tunnel_types = None
        local_ip = '192.168.10.1'
        bridge_mappings = {'physnet': self.br_int}
        agent = ovs_agent.OVSNeutronAgent(self._bridge_classes(),
                                          self.br_int, self.br_tun,
                                          local_ip, bridge_mappings,
                                          polling_interval=1,
                                          tunnel_types=tunnel_types,
                                          prevent_arp_spoofing=False,
                                          conf=self.config)
        self.addCleanup(self.ovs.delete_bridge, self.br_int)
        if tunnel_types:
            self.addCleanup(self.ovs.delete_bridge, self.br_tun)
        agent.sg_agent = mock.Mock()
        return agent

    def start_agent(self, agent):
        self.setup_agent_rpc_mocks(agent)
        polling_manager = polling.InterfacePollingMinimizer()
        self.addCleanup(polling_manager.stop)
        polling_manager.start()
        agent_utils.wait_until_true(
            polling_manager._monitor.is_active)
        agent.check_ovs_status = mock.Mock(
            return_value=constants.OVS_NORMAL)
        t = eventlet.spawn(agent.rpc_loop, polling_manager)

        def stop_agent(agent, rpc_loop_thread):
            agent.run_daemon_loop = False
            rpc_loop_thread.wait()

        self.addCleanup(stop_agent, agent, t)

    def _create_test_port_dict(self):
        return {'id': uuidutils.generate_uuid(),
                'mac_address': utils.get_random_mac(
                    'fa:16:3e:00:00:00'.split(':')),
                'fixed_ips': [{
                    'ip_address': '10.%d.%d.%d' % (
                         random.randint(3, 254),
                         random.randint(3, 254),
                         random.randint(3, 254))}],
                'vif_name': base.get_rand_name(
                    self.driver.DEV_NAME_LEN, self.driver.DEV_NAME_PREFIX)}

    def _create_test_network_dict(self):
        return {'id': uuidutils.generate_uuid(),
                'tenant_id': uuidutils.generate_uuid()}

    def _plug_ports(self, network, ports, agent, ip_len=24):
        for port in ports:
            self.driver.plug(
                network.get('id'), port.get('id'), port.get('vif_name'),
                port.get('mac_address'),
                agent.int_br.br_name, namespace=self.namespace)
            ip_cidrs = ["%s/%s" % (port.get('fixed_ips')[0][
                'ip_address'], ip_len)]
            self.driver.init_l3(port.get('vif_name'), ip_cidrs,
                                namespace=self.namespace)

    def _get_device_details(self, port, network):
        dev = {'device': port['id'],
               'port_id': port['id'],
               'network_id': network['id'],
               'network_type': 'vlan',
               'physical_network': 'physnet',
               'segmentation_id': 1,
               'fixed_ips': port['fixed_ips'],
               'device_owner': 'compute',
               'port_security_enabled': True,
               'security_groups': ['default'],
               'admin_state_up': True}
        return dev

    def assert_bridge(self, br, exists=True):
        self.assertEqual(exists, self.ovs.bridge_exists(br))

    def assert_patch_ports(self, agent):

        def get_peer(port):
            return agent.int_br.db_get_val(
                'Interface', port, 'options', check_error=True)

        agent_utils.wait_until_true(
            lambda: get_peer(self.patch_int) == {'peer': self.patch_tun})
        agent_utils.wait_until_true(
            lambda: get_peer(self.patch_tun) == {'peer': self.patch_int})

    def assert_bridge_ports(self):
        for port in [self.patch_tun, self.patch_int]:
            self.assertTrue(self.ovs.port_exists(port))

    def assert_vlan_tags(self, ports, agent):
        for port in ports:
            res = agent.int_br.db_get_val('Port', port.get('vif_name'), 'tag')
            self.assertTrue(res)

    def _expected_plugin_rpc_call(self, call, expected_devices, is_up=True):
        """Helper to check expected rpc call are received
        :param call: The call to check
        :param expected_devices The device for which call is expected
        :param is_up True if expected_devices are devices that are set up,
               False if expected_devices are devices that are set down
        """
        if is_up:
            rpc_devices = [
                dev for args in call.call_args_list for dev in args[0][1]]
        else:
            rpc_devices = [
                dev for args in call.call_args_list for dev in args[0][2]]
        return not (set(expected_devices) - set(rpc_devices))

    def create_test_ports(self, amount=3, **kwargs):
        ports = []
        for x in range(amount):
            ports.append(self._create_test_port_dict(**kwargs))
        return ports

    def _mock_update_device(self, context, devices_up, devices_down, agent_id,
                            host=None):
        dev_up = []
        dev_down = []
        for port in self.ports:
            if devices_up and port['id'] in devices_up:
                dev_up.append(port['id'])
            if devices_down and port['id'] in devices_down:
                dev_down.append({'device': port['id'], 'exists': True})
        return {'devices_up': dev_up,
                'failed_devices_up': [],
                'devices_down': dev_down,
                'failed_devices_down': []}

    def setup_agent_rpc_mocks(self, agent):
        def mock_device_details(context, devices, agent_id, host=None):

            details = []
            for port in self.ports:
                if port['id'] in devices:
                    dev = self._get_device_details(
                        port, self.network)
                    details.append(dev)
            return {'devices': details, 'failed_devices': []}

        (agent.plugin_rpc.get_devices_details_list_and_failed_devices.
            side_effect) = mock_device_details
        agent.plugin_rpc.update_device_list.side_effect = (
            self._mock_update_device)

    def _prepare_resync_trigger(self, agent):
        def mock_device_raise_exception(context, devices_up, devices_down,
                                        agent_id, host=None):
            agent.plugin_rpc.update_device_list.side_effect = (
                self._mock_update_device)
            raise Exception('Exception to trigger resync')

        self.agent.plugin_rpc.update_device_list.side_effect = (
            mock_device_raise_exception)

    def wait_until_ports_state(self, ports, up):
        port_ids = [p['id'] for p in ports]
        agent_utils.wait_until_true(
            lambda: self._expected_plugin_rpc_call(
                self.agent.plugin_rpc.update_device_list, port_ids, up))

    def setup_agent_and_ports(self, port_dicts, create_tunnels=True,
                              trigger_resync=False):
        self.agent = self.create_agent(create_tunnels=create_tunnels)
        self.start_agent(self.agent)
        self.network = self._create_test_network_dict()
        self.ports = port_dicts
        if trigger_resync:
            self._prepare_resync_trigger(self.agent)
        self._plug_ports(self.network, self.ports, self.agent)