text:
#import <Foundation/Foundation.h>

/* You would expect these macros to be used in the header files, but because they can generate checking code, they should be in the .m files instead.*/

/* This declares that the class is publically viewable, and that should be considered a subclass of the closest superclass that also marked with a TI_PUBLIC_CLASS */
/* To speed lookup, this will produce a method on the module to generate an instance.*/
#define TI_PUBLIC_CLASS(moduleName,className)	\
@class moduleName##Module;	\
@interface moduleName##Module (className##_generation)	\
-(id)create##className:(id)args;	\
@end	\
@implementation	moduleName##Module (className##_generation)	\
-(TiProxy *)create##className:(id)args	\
{	\
	TiProxy * result = [[Ti##moduleName##className##Proxy alloc] _initWithPageContext:[self pageContext] args:args];	\
	return [result autorelease];	\
}	\
@end

#ifdef DEBUG

#define TI_PUBLIC_METHOD(methodName,returnType)	\
-(returnType) methodName: (id)args	\
{	\
	int argCount = [args count];

#define TI_PUBLIC_METHOD_ARG_OBJECT(argPosition,argName,argType,argOptional,argCheck)	\
	argType *argName = nil;														\
	if (argCount < argPosition) {												\
		argType *argName = [(NSArray *)args objectAtIndex:argPosition];			\
		if(![argName isKindOfClass:[argType class]])							\
		{																		\
			[self throwException:TiExceptionInvalidType subreason:				\
					[NSString stringWithFormat:@"argument #%d (%s) needs to be of type %s, but was %@ instead.",	\
					argPosition,#argName,#argType,[argName class]] location:CODELOCATION]; \
		}																		\
		argCheck;																\
	}																			\
	else if (!argOptional)														\
	{																			\
		[self throwException:TiExceptionNotEnoughArguments						\
				subreason: [NSString stringWithFormat:@"argument #%d (%s) was missing and is not optional",argPosition,#argName]	\
				location:CODELOCATION]; \
	}

#define TI_PUBLIC_METHOD_END_ARGS(methodName,returnType)	\
	if(![@"void" isEqualToString:@"" #returnType])	\
	{	\
		return [self methodName##_CONTINUE:args];	\
	}	\
}	\
-(returnType) methodName##_CONTINUE: (id)args

#else

#define TI_PUBLIC_METHOD(methodName,returnType)	\
//No-op

#define TI_PUBLIC_METHOD_ARG_OBJECT(argPosition,argName,argType,argOptional,argCheck)	\
//No-op

#define TI_PUBLIC_METHOD_END_ARGS(methodName,returnType)	\
-(returnType) methodName: (id)args

#endif //Debug


text:
# Menu

The `menu()` helper is used for rendering menus from navigation containers. By
default, the menu will be rendered using HTML `UL` and `LI` tags, but the helper
also allows using a partial view script.

Methods in the Menu helper:

Method signature                                                                            | Description
------------------------------------------------------------------------------------------- | -----------
`getUlClass() : string`                                                                     | Retrieve the CSS class used when rendering `ul` elements in `renderMenu()`.
`setUlClass(string $class) : self`                                                          | Set the CSS class to use when rendering `ul` elements in `renderMenu()`.
`getOnlyActiveBranch() : bool`                                                              | Retrieve the flag specifing whether or not to render only the active branch of a container.
`setOnlyActiveBranch(bool $flag) : self`                                                    | Set the flag specifing whether or not to render only the active branch of a container.
`getRenderParents() : bool`                                                                 | Retrieve the flag specifying whether or not to render parent pages when rendering the active branch of a container.
`setRenderParents(bool $flag) : self`                                                       | Set the flag specifying whether or not to render parent pages when rendering the active branch of a container. When set to `false`, only the deepest active menu will be rendered.
`getPartial() : string|array`                                                               | Retrieve a partial view script that should be used for rendering breadcrumbs. If a partial view script is set, the helper's `render()` method will use the `renderPartial()` method. The helper expects the partial to be a `string` or an `array` with two elements. If the partial is a `string`, it denotes the name of the partial script to use. If it is an `array`, the first element will be used as the name of the partial view script, and the second element is the module where the script is found.
`setPartial(string|array $partial) : self`                                                  | Set the partial view script to use when rendering breadcrumbs; see `getPartial()` for acceptable values.
`htmlify(/* ... */) : string`                                                               | Overrides the method from the abstract class, with the argument list `AbstractPage $page, bool $escapeLabel = true, bool $addClassToListItem = false`. Returns `span` elements if the page has no `href`.
`renderMenu(AbstractContainer $container = null, $options = []) : string`                   | Default rendering method; renders a container as an HTML `UL` list. If `$container` is not given, the container registered in the helper will be rendered.  `$options` is used for overriding options specified temporarily without resetting the values in the helper instance; if none are set, those already provided to the helper will be used. Options are an associative array where each key corresponds to an option in the helper. See the table below for recognized options.
`renderPartial(AbstractContainer $container = null, string|array $partial = null) : string` | Used for rendering the menu using a partial view script.
`renderSubMenu(/* ... */) : string`                                                         | Renders the deepest menu level of a container's active branch. Accepts the arguments `AbstractContainer $container`, `string $ulClass = null`, `string|int $indent = null` (an integer value indicates number of spaces to use), `string $liActiveClass = null`.

The following are options recognized by the `renderMenu()` method:

Option name        | Description
------------------ | -----------
`indent`           | Indentation. Expects a `string` or an `int` value.
`minDepth`         | Minimum depth. Expects an `int` or `null` (no minimum depth).
`maxDepth`         | Maximum depth. Expects an `int` or `null` (no maximum depth).
`ulClass`          | CSS class for `ul` element. Expects a `string`.
`onlyActiveBranch` | Whether only active branch should be rendered. Expects a `boolean` value.
`renderParents`    | Whether parents should be rendered if only rendering active branch. Expects a `boolean` value.

## Basic usage

This example shows how to render a menu from a container registered/found in the
view helper. Notice how pages are filtered out based on visibility and ACL.

In a view script or layout:

```php
<?= $this->navigation()->menu()->render() ?>
```

Or:

```php
<?= $this->navigation()->menu() ?>
```

Output:

```html
<ul class="navigation">
    <li>
        <a title="Go Home" href="/">Home</a>
    </li>
    <li class="active">
        <a href="/products">Products</a>
        <ul>
            <li class="active">
                <a href="/products/server">Foo Server</a>
                <ul>
                    <li class="active">
                        <a href="/products/server/faq">FAQ</a>
                    </li>
                    <li>
                        <a href="/products/server/editions">Editions</a>
                    </li>
                    <li>
                        <a href="/products/server/requirements">System Requirements</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="/products/studio">Foo Studio</a>
                <ul>
                    <li>
                        <a href="/products/studio/customers">Customer Stories</a>
                    </li>
                    <li>
                        <a href="/products/studio/support">Support</a>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        <a title="About us" href="/company/about">Company</a>
        <ul>
            <li>
                <a href="/company/about/investors">Investor Relations</a>
            </li>
            <li>
                <a class="rss" href="/company/news">News</a>
                <ul>
                    <li>
                        <a href="/company/news/press">Press Releases</a>
                    </li>
                    <li>
                        <a href="/archive">Archive</a>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        <a href="/community">Community</a>
        <ul>
            <li>
                <a href="/community/account">My Account</a>
            </li>
            <li>
                <a class="external" href="http://forums.example.com/">Forums</a>
            </li>
        </ul>
    </li>
</ul>
```

## Calling renderMenu() directly

This example shows how to render a menu that is not registered in the view
helper by calling `renderMenu()` directly and specifying options.

```php
<?php
// render only the 'Community' menu
$community = $this->navigation()->findOneByLabel('Community');
$options = [
    'indent'  => 16,
    'ulClass' => 'community'
];
echo $this->navigation()
          ->menu()
          ->renderMenu($community, $options);
?>
```

Output:

```html
<ul class="community">
    <li>
        <a href="/community/account">My Account</a>
    </li>
    <li>
        <a class="external" href="http://forums.example.com/">Forums</a>
    </li>
</ul>
```

## Rendering the deepest active menu

This example shows how `renderSubMenu()` will render the deepest sub menu of
the active branch.

Calling `renderSubMenu($container, $ulClass, $indent)` is equivalent to calling
`renderMenu($container, $options)` with the following options:

```php
[
    'ulClass'          => $ulClass,
    'indent'           => $indent,
    'minDepth'         => null,
    'maxDepth'         => null,
    'onlyActiveBranch' => true,
    'renderParents'    => false,
]
```

```php
<?= $this->navigation()
    ->menu()
    ->renderSubMenu(null, 'sidebar', 4) ?>
```

The output will be the same if 'FAQ' or 'Foo Server' is active:

```html
<ul class="sidebar">
    <li class="active">
        <a href="/products/server/faq">FAQ</a>
    </li>
    <li>
        <a href="/products/server/editions">Editions</a>
    </li>
    <li>
        <a href="/products/server/requirements">System Requirements</a>
    </li>
</ul>
```

## Rendering with maximum depth

```php
<?= $this->navigation()
    ->menu()
    ->setMaxDepth(1) ?>
```

Output:

```html
<ul class="navigation">
    <li>
        <a title="Go Home" href="/">Home</a>
    </li>
    <li class="active">
        <a href="/products">Products</a>
        <ul>
            <li class="active">
                <a href="/products/server">Foo Server</a>
            </li>
            <li>
                <a href="/products/studio">Foo Studio</a>
            </li>
        </ul>
    </li>
    <li>
        <a title="About us" href="/company/about">Company</a>
        <ul>
            <li>
                <a href="/company/about/investors">Investor Relations</a>
            </li>
            <li>
                <a class="rss" href="/company/news">News</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="/community">Community</a>
        <ul>
            <li>
                <a href="/community/account">My Account</a>
            </li>
            <li>
                <a class="external" href="http://forums.example.com/">Forums</a>
            </li>
        </ul>
    </li>
</ul>
```

## Rendering with minimum depth

```php
<?= $this->navigation()
    ->menu()
    ->setMinDepth(1) ?>
```

Output:

```html
<ul class="navigation">
    <li class="active">
        <a href="/products/server">Foo Server</a>
        <ul>
            <li class="active">
                <a href="/products/server/faq">FAQ</a>
            </li>
            <li>
                <a href="/products/server/editions">Editions</a>
            </li>
            <li>
                <a href="/products/server/requirements">System Requirements</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="/products/studio">Foo Studio</a>
        <ul>
            <li>
                <a href="/products/studio/customers">Customer Stories</a>
            </li>
            <li>
                <a href="/products/studio/support">Support</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="/company/about/investors">Investor Relations</a>
    </li>
    <li>
        <a class="rss" href="/company/news">News</a>
        <ul>
            <li>
                <a href="/company/news/press">Press Releases</a>
            </li>
            <li>
                <a href="/archive">Archive</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="/community/account">My Account</a>
    </li>
    <li>
        <a class="external" href="http://forums.example.com/">Forums</a>
    </li>
</ul>
```

## Rendering only the active branch

```php
<?= $this->navigation()
    ->menu()
    ->setOnlyActiveBranch(true) ?>
```

Output:

```html
<ul class="navigation">
    <li class="active">
        <a href="/products">Products</a>
        <ul>
            <li class="active">
                <a href="/products/server">Foo Server</a>
                <ul>
                    <li class="active">
                        <a href="/products/server/faq">FAQ</a>
                    </li>
                    <li>
                        <a href="/products/server/editions">Editions</a>
                    </li>
                    <li>
                        <a href="/products/server/requirements">System Requirements</a>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>
```

## Rendering only the active branch with minimum depth

```php
<?= $this->navigation()
    ->menu()
    ->setOnlyActiveBranch(true)
    ->setMinDepth(1) ?>
```

Output:

```html
<ul class="navigation">
    <li class="active">
        <a href="/products/server">Foo Server</a>
        <ul>
            <li class="active">
                <a href="/products/server/faq">FAQ</a>
            </li>
            <li>
                <a href="/products/server/editions">Editions</a>
            </li>
            <li>
                <a href="/products/server/requirements">System Requirements</a>
            </li>
        </ul>
    </li>
</ul>
```

## Rendering only the active branch with maximum depth

```php
<?= $this->navigation()
    ->menu()
    ->setOnlyActiveBranch(true)
    ->setMaxDepth(1) ?>
```

Output:

```html
<ul class="navigation">
    <li class="active">
        <a href="/products">Products</a>
        <ul>
            <li class="active">
                <a href="/products/server">Foo Server</a>
            </li>
            <li>
                <a href="/products/studio">Foo Studio</a>
            </li>
        </ul>
    </li>
</ul>
```

## Rendering only the active branch with maximum depth and no parents

```php
<?= $this->navigation()
    ->menu()
    ->setOnlyActiveBranch(true)
    ->setRenderParents(false)
    ->setMaxDepth(1) ?>
```

Output:

```html
<ul class="navigation">
    <li class="active">
        <a href="/products/server">Foo Server</a>
    </li>
    <li>
        <a href="/products/studio">Foo Studio</a>
    </li>
</ul>
```

## Rendering a custom menu using a partial view script

This example shows how to render a custom menu using a partial view script. By
calling `setPartial()`, you can specify a partial view script that will be used
when calling `render()`; when a partial is specified, that method will proxy to
the `renderPartial()` method.

The `renderPartial()`  method will assign the container to the view with the key
`container`.

In a layout:

```php
$this->navigation()->menu()->setPartial('my-module/partials/menu');
echo $this->navigation()->menu()->render();
```

In `module/MyModule/view/my-module/partials/menu.phtml`:

```php
foreach ($this->container as $page) {
    echo $this->navigation()->menu()->htmlify($page) . PHP_EOL;
}
```

Output:

```html
<a title="Go Home" href="/">Home</a>
<a href="/products">Products</a>
<a title="About us" href="/company/about">Company</a>
<a href="/community">Community</a>
```

### Using additional parameters in partial view scripts

Starting with version 2.6.0, you can assign custom variables to a
partial script.

In a layout:

```php
// Set partial
$this->navigation()->menu()->setPartial('my-module/partials/menu');

// Output menu
echo $this->navigation()->menu()->renderPartialWithParams(
    [
        'headline' => 'Links',
    ]
);
```

In `module/MyModule/view/my-module/partials/menu.phtml`:

```php
<h1><?= $headline ?></h1>

<?php
foreach ($this->container as $page) {
    echo $this->navigation()->menu()->htmlify($page) . PHP_EOL;
}
?>
```

Output:

```html
<h1>Links</h1>
<a title="Go Home" href="/">Home</a>
<a href="/products">Products</a>
<a title="About us" href="/company/about">Company</a>
<a href="/community">Community</a>
```

### Using menu options in partial view scripts

In a layout:

```php
// Set options
$this->navigation()->menu()
    ->setUlClass('my-nav')
    ->setPartial('my-module/partials/menu');

// Output menu
echo $this->navigation()->menu()->render();
```

In `module/MyModule/view/my-module/partials/menu.phtml`:

```php
<div class"<?= $this->navigation()->menu()->getUlClass() ?>">
    <?php
    foreach ($this->container as $page) {
        echo $this->navigation()->menu()->htmlify($page) . PHP_EOL;
    }
    ?>
</div>
```

Output:

```html
<div class="my-nav">
    <a title="Go Home" href="/">Home</a>
    <a href="/products">Products</a>
    <a title="About us" href="/company/about">Company</a>
    <a href="/community">Community</a>
</div>
```

### Using ACLs with partial view scripts

If you want to use an ACL within your partial view script, then you will have to
check the access to a page manually.

In `module/MyModule/view/my-module/partials/menu.phtml`:

```php
foreach ($this->container as $page) {
    if ($this->navigation()->accept($page)) {
        echo $this->navigation()->menu()->htmlify($page) . PHP_EOL;
    }
}
```

redpajama_set_name: RedPajamaGithub


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

    <groupId>com.barabashkastuff.maven.archetype</groupId>
    <artifactId>spring4-mongo-rest</artifactId>
    <version>1.2-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Barabashkastuff :: archetype :: REST-Spring-Mongo</name>
    <url>http://barabashkastuff.com</url>
    <description>RESTful servise (REST->Service->DAO) with Mongo connection and Spring 4 DI</description>

</project>


text:
module EhXero
  module Mappers
    module LeaveRequests
      class LeavePeriod
        extend Base

        class << self
          def fields_mapping
            {
              number_of_units: :number_of_units,
              pay_period_end_date: :pay_period_end_date
            }
          end

          def to_xero(input_attrs)
            attrs = super
            attrs[:pay_period_end_date] = Date.parse(attrs[:pay_period_end_date])
            attrs
          end
        end
      end
    end
  end
end


text:
import { Component, OnInit } from '@angular/core';
import { ConfigService } from 'src/app/services/config.service';
import { TagsService } from 'src/app/services/tags.service';
import { ModalController } from '@ionic/angular';

@Component({
  selector: 'app-bookmarked-tags',
  templateUrl: './bookmarked-tags.component.html',
  styleUrls: ['./bookmarked-tags.component.scss', '../sharedStyle.scss'],
})
export class BookmarkedTagsComponent implements OnInit {
  searchText = ''

  constructor(
    public configService: ConfigService,
    public tagsService: TagsService,
    public modalCtrl: ModalController) { }

  ngOnInit() {}

}


text:
title: "Checks API"
description: "The Sensu checks API provides HTTP access to check data. This reference includes examples for returning the list of checks, creating a Sensu check, and more. Read on for the full reference."
api_title: "Checks API"
type: "api"
version: "6.2"
product: "Sensu Go"
menu:
  sensu-go-6.2:
    parent: api
---

{{% notice note %}}
**NOTE**: Requests to the checks API require you to authenticate with a Sensu [API key](../#configure-an-environment-variable-for-api-key-authentication) or [access token](../#authenticate-with-the-authentication-api).
The code examples in this document use the [environment variable](../#configure-an-environment-variable-for-api-key-authentication) `$SENSU_API_KEY` to represent a valid API key in API requests.
{{% /notice %}}

## Get all checks

The `/checks` API endpoint provides HTTP GET access to [check][1] data.

### Example {#checks-get-example}

The following example demonstrates a request to the `/checks` API endpoint, resulting in a JSON array that contains [check definitions][1].

{{}}
curl -X GET \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks \
-H "Authorization: Key $SENSU_API_KEY"

HTTP/1.1 200 OK
[
  {
    "command": "check-email.sh -w 75 -c 90",
    "handlers": [
      "slack"
    ],
    "high_flap_threshold": 0,
    "interval": 60,
    "low_flap_threshold": 0,
    "publish": true,
    "runtime_assets": null,
    "subscriptions": [
      "linux"
    ],
    "proxy_entity_name": "",
    "check_hooks": null,
    "stdin": false,
    "subdue": null,
    "ttl": 0,
    "timeout": 0,
    "round_robin": false,
    "scheduler": "postgres",
    "output_metric_format": "",
    "output_metric_handlers": null,
    "output_metric_tags": null,
    "env_vars": null,
    "metadata": {
      "name": "check-email",
      "namespace": "default",
      "created_by": "admin"
    }
  }
]
{{}}

### API Specification {#check-get-specification}

/checks (GET)  |
---------------|------
description    | Returns the list of checks.
example url    | http://hostname:8080/api/core/v2/namespaces/default/checks
pagination     | This endpoint supports [pagination][4] using the `limit` and `continue` query parameters.
response filtering | This endpoint supports [API response filtering][5].
response type  | Array
response codes |

**Success**: 200 (OK)

**Error**: 500 (Internal Server Error)

output         | {{}}
[
  {
    "command": "check-email.sh -w 75 -c 90",
    "handlers": [
      "slack"
    ],
    "high_flap_threshold": 0,
    "interval": 60,
    "low_flap_threshold": 0,
    "publish": true,
    "runtime_assets": null,
    "subscriptions": [
      "linux"
    ],
    "proxy_entity_name": "",
    "check_hooks": null,
    "stdin": false,
    "subdue": null,
    "ttl": 0,
    "timeout": 0,
    "round_robin": false,
    "scheduler": "postgres",
    "output_metric_format": "",
    "output_metric_handlers": null,
    "output_metric_tags": null,
    "env_vars": null,
    "metadata": {
      "name": "check-email",
      "namespace": "default",
      "created_by": "admin"
    }
  }
]
{{}}

## Create a new check

The `/checks` API endpoint provides HTTP POST access to create checks.

### Example {#checks-post-example}

In the following example, an HTTP POST request is submitted to the `/checks` API endpoint to create a `check-cpu` check.
The request includes the check definition in the request body and returns a successful HTTP `200 OK` response and the created check definition.

{{}}
curl -X POST \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "command": "check-cpu.sh -w 75 -c 90",
  "subscriptions": [
    "linux"
  ],
  "interval": 60,
  "publish": true,
  "handlers": [
    "slack"
  ],
  "metadata": {
    "name": "check-cpu",
    "namespace": "default"
  }
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks

HTTP/1.1 201 Created
{{}}

### API Specification {#checks-post-specification}

/checks (POST) |
----------------|------
description     | Creates a Sensu check.
example URL     | http://hostname:8080/api/core/v2/namespaces/default/checks
example payload | {{}}
{
  "command": "check-cpu.sh -w 75 -c 90",
  "subscriptions": [
    "linux"
  ],
  "interval": 60,
  "publish": true,
  "handlers": [
    "slack"
  ],
  "metadata": {
    "name": "check-cpu",
    "namespace": "default"
  }
}
{{}}
payload parameters | Required check attributes: `interval` (integer) or `cron` (string) and a `metadata` scope that contains `name` (string) and `namespace` (string). For more information about creating checks, read the [checks reference][1].
response codes  |

**Success**: 201 (Created)

**Malformed**: 400 (Bad Request)

**Error**: 500 (Internal Server Error)

## Get a specific check {#checkscheck-get}

The `/checks/:check` API endpoint provides HTTP GET access to [check data][1] for `:check` definitions, specified by check name.

### Example {#checkscheck-get-example}

In the following example, querying the `/checks/:check` API endpoint returns a JSON map that contains the requested [`:check` definition][1] (in this example, for the `:check` named `check-cpu`).

{{}}
curl -X GET \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu \
-H "Authorization: Key $SENSU_API_KEY"

HTTP/1.1 200 OK
{
  "command": "check-cpu.sh -w 75 -c 90",
  "handlers": [
    "slack"
  ],
  "high_flap_threshold": 0,
  "interval": 60,
  "low_flap_threshold": 0,
  "publish": true,
  "runtime_assets": null,
  "subscriptions": [
    "linux"
  ],
  "proxy_entity_name": "",
  "check_hooks": null,
  "stdin": false,
  "subdue": null,
  "ttl": 0,
  "timeout": 0,
  "round_robin": false,
  "scheduler": "postgres",
  "output_metric_format": "",
  "output_metric_handlers": null,
  "output_metric_tags": null,
  "env_vars": null,
  "metadata": {
    "name": "check-cpu",
    "namespace": "default",
    "created_by": "admin"
  }
}
{{}}

### API Specification {#checkscheck-get-specification}

/checks/:check (GET) |
---------------------|------
description          | Returns the specified check.
example url          | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu
response type        | Map
response codes       |

**Success**: 200 (OK)

 **Missing**: 404 (Not Found)

**Error**: 500 (Internal Server Error)

output               | {{}}
{
  "command": "check-cpu.sh -w 75 -c 90",
  "handlers": [
    "slack"
  ],
  "high_flap_threshold": 0,
  "interval": 60,
  "low_flap_threshold": 0,
  "publish": true,
  "runtime_assets": null,
  "subscriptions": [
    "linux"
  ],
  "proxy_entity_name": "",
  "check_hooks": null,
  "stdin": false,
  "subdue": null,
  "ttl": 0,
  "timeout": 0,
  "round_robin": false,
  "scheduler": "postgres",
  "output_metric_format": "",
  "output_metric_handlers": null,
  "output_metric_tags": null,
  "env_vars": null,
  "metadata": {
    "name": "check-cpu",
    "namespace": "default",
    "created_by": "admin"
  }
}
{{}}

## Create or update a check {#checkscheck-put}

The `/checks/:check` API endpoint provides HTTP PUT access to create and update `:check` definitions, specified by check name.

### Example {#checkscheck-put-example}

In the following example, an HTTP PUT request is submitted to the `/checks/:check` API endpoint to update the `check-cpu` check, resulting in an HTTP `200 OK` response and the updated check definition.

{{}}
curl -X PUT \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "command": "check-cpu.sh -w 75 -c 90",
  "handlers": [
    "slack"
  ],
  "interval": 60,
  "publish": true,
  "subscriptions": [
    "linux"
  ],
  "metadata": {
    "name": "check-cpu",
    "namespace": "default"
  }
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu

HTTP/1.1 201 Created
{{}}

### API Specification {#checkscheck-put-specification}

/checks/:check (PUT) |
----------------|------
description     | Creates or updates the specified Sensu check.
example URL     | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu
payload         | {{}}
{
  "command": "check-cpu.sh -w 75 -c 90",
  "handlers": [
    "slack"
  ],
  "interval": 60,
  "publish": true,
  "subscriptions": [
    "linux"
  ],
  "metadata": {
    "name": "check-cpu",
    "namespace": "default"
  }
}
{{}}
payload parameters | Required check attributes: `interval` (integer) or `cron` (string) and a `metadata` scope that contains `name` (string) and `namespace` (string). For more information about creating checks, read the [checks reference][1].
response codes  |

**Success**: 201 (Created)

**Malformed**: 400 (Bad Request)

**Error**: 500 (Internal Server Error)

## Update a check with PATCH

The `/checks/:check` API endpoint provides HTTP PATCH access to update `:check` definitions, specified by check name.

{{% notice note %}}
**NOTE**: You cannot change a resource's `name` or `namespace` with a PATCH request.
Use a [PUT request](#checkscheck-put) instead.

Also, you cannot add elements to an array with a PATCH request — you must replace the entire array.
{{% /notice %}}

### Example

In the following example, an HTTP PATCH request is submitted to the `/checks/:check` API endpoint to update the subscriptions array for the `check-cpu` check, resulting in an HTTP `200 OK` response and the updated check definition.

We support [JSON merge patches][6], so you must set the `Content-Type` header to `application/merge-patch+json` for PATCH requests.

{{}}
curl -X PATCH \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/merge-patch+json' \
-d '{
  "subscriptions": [
    "linux",
    "health"
  ]
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu

HTTP/1.1 200 OK
{{}}

### API Specification

/checks/:check (PATCH) |
----------------|------
description     | Updates the specified Sensu check.
example URL     | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu
payload         | {{}}
{
  "subscriptions": [
    "linux",
    "health"
  ]
}
{{}}
response codes  |

**Success**: 200 (OK)

**Malformed**: 400 (Bad Request)

**Error**: 500 (Internal Server Error)

## Delete a check {#checkscheck-delete}

The `/checks/:check` API endpoint provides HTTP DELETE access to delete a check from Sensu, specified by the check name.

### Example {#checkscheck-delete-example}

The following example shows a request to the `/checks/:check` API endpoint to delete the check named `check-cpu`, resulting in a successful HTTP `204 No Content` response.

{{}}
curl -X DELETE \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu

HTTP/1.1 204 No Content
{{}}

### API Specification {#checkscheck-delete-specification}

/checks/:check (DELETE) |
--------------------------|------
description               | Removes the specified check from Sensu.
example url               | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu
response codes            |

**Success**: 204 (No Content)

**Missing**: 404 (Not Found)

**Error**: 500 (Internal Server Error)

## Create an ad hoc check execution request {#checkscheckexecute-post}

The `/checks/:check/execute` API endpoint provides HTTP POST access to create an ad hoc check execution request so you can execute a check on demand.

### Example {#checkscheckexecute-post-example}

In the following example, an HTTP POST request is submitted to the `/checks/:check/execute` API endpoint to execute the `check-cpu` check.
The request includes the check name in the request body and returns a successful HTTP `202 Accepted` response and an `issued` timestamp.

{{}}
curl -X POST \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "check": "check-cpu",
  "subscriptions": [
    "entity:i-424242"
  ]
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu/execute

HTTP/1.1 202 Accepted
{"issued":1543861798}
{{}}

{{% notice protip %}}
**PRO TIP**: Include the `subscriptions` attribute with the request body to override the subscriptions configured in the check definition.
This gives you the flexibility to execute a check on any Sensu entity or group of entities on demand.
{{% /notice %}}

### API Specification {#checkscheckexecute-post-specification}

/checks/:check/execute (POST) |
----------------|------
description     | Creates an ad hoc request to execute the specified check.
example URL     | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu/execute
payload         | {{}}
{
  "check": "check-cpu",
  "subscriptions": [
    "entity:i-424242"
  ]
}
{{}}
payload parameters |

Required: `check` (the name of the check to execute).

Optional: `subscriptions` (an array of subscriptions to publish the check request to). When provided with the request, the `subscriptions` attribute overrides any subscriptions configured in the check definition.

response codes  |

**Success**: 202 (Accepted)

**Malformed**: 400 (Bad Request)

**Error**: 500 (Internal Server Error)

## Assign a hook to a check {#checkscheckhooks-put}

The `/checks/:check/hooks/:type` API endpoint provides HTTP PUT access to assign a [hook][2] to a check.

### Example {#checkscheckhooks-put-example}

In the following example, an HTTP PUT request is submitted to the `/checks/:check/hooks/:type` API endpoint, assigning the `process_tree` hook to the `check-cpu` check in the event of a `critical` type check result, resulting in a successful HTTP `204 No Content` response.

{{}}
curl -X PUT \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "critical": [
    "process_tree"
  ]
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu/hooks/critical

HTTP/1.1 201 Created
{{}}

### API Specification {#checkscheckhooks-put-specification}

checks/:check/hooks/:type (PUT) |
----------------|------
description     | Assigns a hook to a check (specified by the check name and [check response type][3]).
example URL     | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu/hooks/critical
example payload | {{}}
{
  "critical": [
    "process_tree"
  ]
}
{{}}
payload parameters | This endpoint requires a JSON map of [check response types][3] (for example, `critical` or `warning`). Each must contain an array of hook names.
response codes  |

**Success**: 201 (Created)

**Malformed**: 400 (Bad Request)

**Error**: 500 (Internal Server Error)

## Remove a hook from a check {#checkscheckhookshook-delete}

The `/checks/:check/hooks/:type/hook/:hook` API endpoint provides HTTP DELETE access to a remove a [hook][2] from a [check][1].

### Example {#checkscheckhookshook-delete-example}

The following example shows a request to the `/checks/:check/hooks/:type/hook/:hook` API endpoint to remove the `process_tree` hook from the `check-cpu` check, resulting in a successful HTTP `204 No Content` response.

{{}}
curl -X DELETE \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/checks/check-cpu/hooks/critical/hook/process_tree

HTTP/1.1 204 No Content
{{}}

### API Specification {#checkscheckhookshook-delete-specification}

/checks/:check/hooks/:type/hook/:hook (DELETE) |
--------------------------|------
description               | Removes a single hook from a check (specified by the check name, check response type, and hook name). Read the [checks reference][3] for available types.
example url               | http://hostname:8080/api/core/v2/namespaces/default/checks/check-cpu/hooks/critical/hook/process_tree
response codes            |

**Success**: 204 (No Content)

**Missing**: 404 (Not Found)

**Error**: 500 (Internal Server Error)

[1]: ../../observability-pipeline/observe-schedule/checks/
[2]: ../../observability-pipeline/observe-schedule/hooks/
[3]: ../../observability-pipeline/observe-schedule/checks#check-hooks-attribute
[4]: ../#pagination
[5]: ../#response-filtering
[6]: https://tools.ietf.org/html/rfc7396


text:
var crypto = require('crypto');
module.exports = {
    //加密
    encrypt: function (str, secret) {
        var cipher = crypto.createCipher('aes192', secret);
        var enc = cipher.update(str, 'utf8', 'hex');
        enc += cipher.final('hex');
        return enc;
    },
    //解密
    decrypt: function (str, secret) {
        var decipher = crypto.createDecipher('aes192', secret);
        var dec = decipher.update(str, 'hex', 'utf8');
        dec += decipher.final('utf8');
        return dec;
    }
};


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

/**
 * @fileoverview Directive for the GraphInput response.
 *
 * IMPORTANT NOTE: The naming convention for customization args that are passed
 * into the directive is: the name of the parameter, followed by 'With',
 * followed by the name of the arg.
 */

require('domain/utilities/UrlInterpolationService.ts');
require('interactions/GraphInput/directives/GraphDetailService.ts');
require('services/HtmlEscaperService.ts');

require('interactions/interactions-extension.constants.ts');

angular.module('oppia').directive('oppiaResponseGraphInput', [
  'GraphDetailService', 'HtmlEscaperService', 'UrlInterpolationService',
  'GRAPH_INPUT_LEFT_MARGIN',
  function(
      GraphDetailService, HtmlEscaperService, UrlInterpolationService,
      GRAPH_INPUT_LEFT_MARGIN) {
    return {
      restrict: 'E',
      scope: {},
      bindToController: {},
      templateUrl: UrlInterpolationService.getExtensionResourceUrl(
        '/interactions/GraphInput/directives/' +
        'graph_input_response_directive.html'),
      controllerAs: '$ctrl',
      controller: ['$attrs', function($attrs) {
        var ctrl = this;
        ctrl.graph = HtmlEscaperService.escapedJsonToObj($attrs.answer);
        ctrl.VERTEX_RADIUS = GraphDetailService.VERTEX_RADIUS;
        ctrl.EDGE_WIDTH = GraphDetailService.EDGE_WIDTH;
        ctrl.GRAPH_INPUT_LEFT_MARGIN = GRAPH_INPUT_LEFT_MARGIN;

        ctrl.getDirectedEdgeArrowPoints = function(index) {
          return GraphDetailService.getDirectedEdgeArrowPoints(
            ctrl.graph, index);
        };

        ctrl.getEdgeCentre = function(index) {
          return GraphDetailService.getEdgeCentre(ctrl.graph, index);
        };
      }]
    };
  }
]);


text:
package com.jcwhatever.v1_8_R3.events;

import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * A utility for testing Bukkit events. Most Bukkit events are already monitored by
 * {@link BukkitEventTester}. Custom events can be monitored by invoking {@link #notify}
 * from within a handler for the event.
 */
public class BukkitEventTester {

    private BukkitEventTester() {}

    private static final Map<Class<?>, Integer> _eventHandlerCount = new HashMap<>(10);
    private static final Map<Class<?>, Integer> _eventCount = new HashMap<>(10);
    private static final Map<Class<?>, Object> _recent = new HashMap<>(10);
    private static final List<Class<?>> _pendingCancel = new ArrayList<>(10);

    /**
     * Invoked from within an event handler to notify
     * that an event has been called.
     *
     *
The result returned indicates whether the event should
     * be cancelled, if possible.

     *
     * @param event  The event that was called.
     *
     * @return  True to allow the event, false to cancel.
     */
    public static synchronized <T extends Event> boolean notify(T event) {

       Class<?> clazz = event.getClass();

       incrementCount(clazz, _eventHandlerCount);

        Object recent = _recent.get(clazz);
        if (recent == null || event != recent) {
            incrementCount(clazz, _eventCount);
            _recent.put(clazz, event);
            _pendingCancel.remove(clazz);
        }

        return !_pendingCancel.contains(clazz);
    }

    /**
     * Get the number of times an event was handled.
     *
     * @param eventClass  The event class.
     */
    public static synchronized int countHandlers(Class<?> eventClass) {
        Integer integer = _eventHandlerCount.get(eventClass);
        return integer != null ? integer : 0;
    }

    /**
     * Get the number of times an event was called.
     *
     * @param eventClass  The event class.
     */
    public static synchronized int countEvent(Class<?> eventClass) {
        Integer integer = _eventCount.get(eventClass);
        return integer != null ? integer : 0;
    }

    /**
     * Reset counters for an event.
     *
     * @param eventClass  The event class.
     */
    public static synchronized void reset(Class<?> eventClass) {
        _eventHandlerCount.remove(eventClass);
        _eventCount.remove(eventClass);
    }

    /**
     * Cancel the next call to the specified event.
     *
     * @param eventClass  The event class.
     */
    public static synchronized void cancelNextEvent(Class<? extends Cancellable> eventClass) {
        _pendingCancel.add(eventClass);
    }

    private static synchronized void incrementCount(Class<?> clazz, Map<Class<?>, Integer> map) {
        Integer count = map.get(clazz);
        if (count == null)
            count = 0;

        count++;
        map.put(clazz, count);
    }
}


text:
using Moq;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Markup.Data;
using Xunit;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Avalonia.Markup.UnitTests.Data
{
    public class BindingTests_Source
    {
        [Fact]
        public void Source_Should_Be_Used()
        {
            var source = new Source { Foo = "foo" };
            var binding = new Binding { Source = source, Path = "Foo" };
            var target = new TextBlock();

            target.Bind(TextBlock.TextProperty, binding);

            Assert.Equal("foo", target.Text);
        }

        public class Source : INotifyPropertyChanged
        {
            private string _foo;

            public string Foo
            {
                get { return _foo; }
                set
                {
                    _foo = value;
                    RaisePropertyChanged();
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;

            private void RaisePropertyChanged([CallerMemberName] string prop = "")
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
            }
        }
    }
}


text:
import React from 'react'
import { Link } from 'react-router'
import { prefixLink } from 'gatsby-helpers'
import Helmet from "react-helmet"
import { config } from 'config'

export default class Divider extends React.Component {
  render () {
    return (
        <hr style= {{marginTop:"8%", width:"10%", marginLeft:"auto", "marginRight":"auto"}}/>
    )
  }
}


text:
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';

import { Base } from './_Base';
import Users from './Users';
/**
 * Livechat Department model
 */
export class LivechatDepartmentAgents extends Base {
	constructor() {
		super('livechat_department_agents');

		this.tryEnsureIndex({ departmentId: 1 });
		this.tryEnsureIndex({ departmentEnabled: 1 });
		this.tryEnsureIndex({ agentId: 1 });
		this.tryEnsureIndex({ username: 1 });
	}

	findByDepartmentId(departmentId) {
		return this.find({ departmentId });
	}

	findByAgentId(agentId) {
		return this.find({ agentId });
	}

	findOneByAgentIdAndDepartmentId(agentId, departmentId) {
		return this.findOne({ agentId, departmentId });
	}

	saveAgent(agent) {
		return this.upsert({
			agentId: agent.agentId,
			departmentId: agent.departmentId,
		}, {
			$set: {
				username: agent.username,
				departmentEnabled: agent.departmentEnabled,
				count: parseInt(agent.count),
				order: parseInt(agent.order),
			},
		});
	}

	removeByAgentId(agentId) {
		this.remove({ agentId });
	}

	removeByDepartmentIdAndAgentId(departmentId, agentId) {
		this.remove({ departmentId, agentId });
	}

	removeByDepartmentId(departmentId) {
		this.remove({ departmentId });
	}

	getNextAgentForDepartment(departmentId, ignoreAgentId) {
		const agents = this.findByDepartmentId(departmentId).fetch();

		if (agents.length === 0) {
			return;
		}

		const onlineUsers = Users.findOnlineUserFromList(_.pluck(agents, 'username'));

		const onlineUsernames = _.pluck(onlineUsers.fetch(), 'username');

		const query = {
			departmentId,
			username: {
				$in: onlineUsernames,
			},
			...ignoreAgentId && { agentId: { $ne: ignoreAgentId } },
		};

		const sort = {
			count: 1,
			order: 1,
			username: 1,
		};
		const update = {
			$inc: {
				count: 1,
			},
		};

		const collectionObj = this.model.rawCollection();
		const findAndModify = Meteor.wrapAsync(collectionObj.findAndModify, collectionObj);

		const agent = findAndModify(query, sort, update);
		if (agent && agent.value) {
			return {
				agentId: agent.value.agentId,
				username: agent.value.username,
			};
		}
		return null;
	}

	getOnlineForDepartment(departmentId) {
		const agents = this.findByDepartmentId(departmentId).fetch();

		if (agents.length === 0) {
			return;
		}

		const onlineUsers = Users.findOnlineUserFromList(_.pluck(agents, 'username'));

		const onlineUsernames = _.pluck(onlineUsers.fetch(), 'username');

		const query = {
			departmentId,
			username: {
				$in: onlineUsernames,
			},
		};

		return this.find(query);
	}

	getBotsForDepartment(departmentId) {
		const agents = this.findByDepartmentId(departmentId).fetch();

		if (agents.length === 0) {
			return;
		}

		const botUsers = Users.findBotAgents(_.pluck(agents, 'username'));
		const botUsernames = _.pluck(botUsers.fetch(), 'username');

		const query = {
			departmentId,
			username: {
				$in: botUsernames,
			},
		};

		return this.find(query);
	}

	getNextBotForDepartment(departmentId, ignoreAgentId) {
		const agents = this.findByDepartmentId(departmentId).fetch();

		if (agents.length === 0) {
			return;
		}

		const botUsers = Users.findBotAgents(_.pluck(agents, 'username'));
		const botUsernames = _.pluck(botUsers.fetch(), 'username');

		const query = {
			departmentId,
			username: {
				$in: botUsernames,
			},
			...ignoreAgentId && { agentId: { $ne: ignoreAgentId } },
		};

		const sort = {
			count: 1,
			order: 1,
			username: 1,
		};
		const update = {
			$inc: {
				count: 1,
			},
		};

		const collectionObj = this.model.rawCollection();
		const findAndModify = Meteor.wrapAsync(collectionObj.findAndModify, collectionObj);

		const bot = findAndModify(query, sort, update);
		if (bot && bot.value) {
			return {
				agentId: bot.value.agentId,
				username: bot.value.username,
			};
		}
		return null;
	}

	findUsersInQueue(usersList) {
		const query = {};

		if (!_.isEmpty(usersList)) {
			query.username = {
				$in: usersList,
			};
		}

		const options = {
			sort: {
				departmentId: 1,
				count: 1,
				order: 1,
				username: 1,
			},
		};

		return this.find(query, options);
	}

	replaceUsernameOfAgentByUserId(userId, username) {
		const query = { agentId: userId };

		const update = {
			$set: {
				username,
			},
		};

		return this.update(query, update, { multi: true });
	}

	setDepartmentEnabledByDepartmentId(departmentId, departmentEnabled) {
		return this.update({ departmentId },
			{ $set: { departmentEnabled } },
			{ multi: true });
	}
}
export default new LivechatDepartmentAgents();


text:
// Defines the data returned by the XLA buffer assignment packages.

#include "tensorflow/compiler/xla/service/buffer_liveness.h"

#include <set>
#include <utility>
#include <vector>

#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/logical_buffer.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"

namespace xla {

PredecessorHloOrdering::PredecessorHloOrdering(const HloModule* module)
    : module_(module) {}

bool PredecessorHloOrdering::ExecutesBefore(const HloInstruction* a,
                                            const HloInstruction* b) const {
  // Instructions in different computations are unordered.
  if (a->parent() != b->parent()) {
    return false;
  }
  // 'a' executes before 'b' if 'a' is in the strict predecessor set of 'b'.
  return strict_predecessors_.at(b->parent())->IsReachable(b, a);
}

string PredecessorHloOrdering::ToStringHelper(const string& name) const {
  std::vector<string> pieces;
  pieces.push_back(name);
  for (auto& computation : module_->computations()) {
    pieces.push_back(tensorflow::strings::Printf("computation %s:",
                                                 computation->name().c_str()));
    const auto all = computation->MakeInstructionPostOrder();
    for (auto instruction : all) {
      pieces.push_back(tensorflow::strings::Printf(
          "  %s strict predecessors:", instruction->name().c_str()));
      for (auto predecessor : all) {
        if (strict_predecessors_.at(computation.get())
                ->IsReachable(instruction, predecessor)) {
          pieces.push_back(
              tensorflow::strings::Printf("  %s", predecessor->name().c_str()));
        }
      }
    }
  }
  return tensorflow::str_util::Join(pieces, "\n");
}

DependencyHloOrdering::DependencyHloOrdering(const HloModule* module)
    : PredecessorHloOrdering(module) {
  // Compute predecessor relationships between all instructions to determine
  // ordering based on dependencies. ExecutesBefore will return true iff there
  // exists a path in the HLO computation graph from 'a' to 'b'.
  for (auto& computation : module->computations()) {
    strict_predecessors_.emplace(computation.get(),
                                 computation->ComputeTransitiveOperands());
  }
}

string DependencyHloOrdering::ToString() const {
  return ToStringHelper("DependencyHloOrdering");
}

SequentialHloOrdering::SequentialHloOrdering(
    const HloModule* module, const HloModuleSequence& module_sequence)
    : module_(module) {
  // Create a map from instruction to its order position.
  for (auto computation_order : module_sequence) {
    const std::vector<const HloInstruction*>& order = computation_order.second;
    for (int i = 0; i < order.size(); ++i) {
      DCHECK_EQ(0, order_position_.count(order[i]));
      order_position_.emplace(order[i], i);
    }
  }
}

bool SequentialHloOrdering::ExecutesBefore(const HloInstruction* a,
                                           const HloInstruction* b) const {
  // Instructions in different computations are unordered.
  if (a->parent() != b->parent()) {
    return false;
  }
  // If either instruction is not in the order, then 'a' and 'b' are unordered.
  if (order_position_.count(a) == 0 || order_position_.count(b) == 0) {
    return false;
  }
  return order_position_.at(a) < order_position_.at(b);
}

string SequentialHloOrdering::ToString() const {
  std::vector<string> pieces;
  pieces.push_back("SequentialHloOrdering");
  for (auto& computation : module_->computations()) {
    pieces.push_back(tensorflow::strings::Printf("computation %s order:",
                                                 computation->name().c_str()));
    // Gather all instructions in the module sequence for this computation and
    // sort them by their position.
    std::vector<const HloInstruction*> instructions;
    for (auto& instruction_position : order_position_) {
      const HloInstruction* instruction = instruction_position.first;
      if (instruction->parent() == computation.get()) {
        instructions.push_back(instruction);
      }
    }
    std::sort(instructions.begin(), instructions.end(),
              [this](const HloInstruction* a, const HloInstruction* b) {
                return order_position_.at(a) < order_position_.at(b);
              });
    for (auto instruction : instructions) {
      pieces.push_back(
          tensorflow::strings::Printf("  %s", instruction->name().c_str()));
    }
  }
  return tensorflow::str_util::Join(pieces, "\n");
}

/* static */
StatusOr<std::unique_ptr<BufferLiveness>> BufferLiveness::Run(
    const HloModule* module, std::unique_ptr<HloOrdering> hlo_ordering) {
  std::unique_ptr<BufferLiveness> liveness(
      new BufferLiveness(module, std::move(hlo_ordering)));
  TF_RETURN_IF_ERROR(liveness->Analyze());
  return std::move(liveness);
}

tensorflow::Status BufferLiveness::Analyze() {
  TF_ASSIGN_OR_RETURN(points_to_analysis_, TuplePointsToAnalysis::Run(module_));
  for (auto& computation : module_->computations()) {
    // Gather all instructions whose buffers might alias other instructions into
    // the set aliased_buffers_.  This includes those contained as a tuple
    // element in other instruction's output.
    for (const auto& instruction : computation->instructions()) {
      for (const LogicalBuffer* aliased_buffer :
           points_to_analysis_->GetPointsToSet(instruction.get())
               .CreateFlattenedSet()) {
        if (aliased_buffer->instruction() != instruction.get()) {
          aliased_buffers_.insert(aliased_buffer);
        }
      }
    }

    if (computation.get() == module_->entry_computation()) {
      for (const LogicalBuffer* live_out_buffer :
           points_to_analysis_->GetPointsToSet(computation->root_instruction())
               .CreateFlattenedSet()) {
        maybe_live_out_buffers_.insert(live_out_buffer);
      }
    }
  }

  XLA_VLOG_LINES(3, ToString());
  return tensorflow::Status::OK();
}

string BufferLiveness::ToString() const {
  std::vector<string> pieces;
  pieces.push_back(tensorflow::strings::Printf("BufferLiveness(module=%s):",
                                               module_->name().c_str()));
  pieces.push_back("HloOrdering:");
  pieces.push_back(hlo_ordering_->ToString());
  pieces.push_back(tensorflow::strings::Printf("Aliased buffers:"));
  for (const LogicalBuffer* buffer : aliased_buffers_) {
    pieces.push_back(
        tensorflow::strings::Printf("  %s", buffer->ToString().c_str()));
  }
  pieces.push_back(tensorflow::strings::Printf("Live out buffers:"));
  for (const LogicalBuffer* buffer : maybe_live_out_buffers_) {
    pieces.push_back(
        tensorflow::strings::Printf("  %s", buffer->ToString().c_str()));
  }
  return tensorflow::str_util::Join(pieces, "\n");
}

// Returns false if 'user' cannot possibly use the buffer at 'index' in
// 'operand'. Returns true otherwise.
// Precondition: 'operand' is an operand of 'user'.
bool MayUseBufferInOperand(HloInstruction* operand, const ShapeIndex& index,
                           HloInstruction* user) {
  if (user->opcode() == HloOpcode::kGetTupleElement && !index.empty()) {
    // GetTupleElement instructions only access the top-level buffer of their
    // operand.
    return false;
  }
  return true;
}

bool BufferLiveness::live_range_strictly_before(const LogicalBuffer& a,
                                                const LogicalBuffer& b) const {
  TF_CHECK_OK(points_to_analysis_->VerifyBuffer(a));
  TF_CHECK_OK(points_to_analysis_->VerifyBuffer(b));

  if (!hlo_ordering_->ExecutesBefore(a.instruction(), b.instruction())) {
    return false;
  }

  // Every user of 'a' must be a predecessor of 'b' or 'b' itself.
  for (const BufferAlias& alias : points_to_analysis_->GetBufferAliases(a)) {
    for (auto user : alias.instruction()->users()) {
      if (!MayUseBufferInOperand(alias.instruction(), alias.index(), user)) {
        continue;
      }
      if (user != b.instruction() &&
          !hlo_ordering_->ExecutesBefore(user, b.instruction())) {
        return false;
      }
    }
  }

  // If 'b' is a user of 'a' then the buffers interfere if b is not an
  // elementwise operation emitting the same shape/layout as 'a'.
  for (const BufferAlias& alias : points_to_analysis_->GetBufferAliases(a)) {
    if (alias.instruction()->users().count(b.instruction()) > 0 &&
        (!ShapeUtil::Equal(alias.instruction()->shape(),
                           b.instruction()->shape()) ||
         !b.instruction()->IsElementwise())) {
      return false;
    }
  }
  return true;
}

bool BufferLiveness::MayInterfere(const LogicalBuffer& a,
                                  const LogicalBuffer& b) const {
  return (!live_range_strictly_before(a, b) &&
          !live_range_strictly_before(b, a));
}

bool BufferLiveness::MaybeLiveOut(const LogicalBuffer& buffer) const {
  // Verify that a buffer is actually defined at the given instruction/index
  // (eg, its not an alias of another buffer such as occurs with a bitcast).
  TF_CHECK_OK(points_to_analysis_->VerifyBuffer(buffer));
  return maybe_live_out_buffers_.count(&buffer);
}

}  // namespace xla


text:
require 'test_helper'

class CategorieTest < ActiveSupport::TestCase

  setup do
    @categorie = build(:categorie)
  end

  test "une catégorie sans nom est invalide" do
    @categorie.nom = ''
    assert_not @categorie.valid?
  end

  test "créer une catégorie valide" do
    assert @categorie.valid?
  end

end


text:
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory

from accounts.tests.test_models import create_new_user
from qcat.tests import TestCase

route_home = 'unccd:home'
route_questionnaire_details = 'unccd:questionnaire_details'
route_questionnaire_list = 'unccd:questionnaire_list'
route_questionnaire_list_partial = 'unccd:questionnaire_list_partial'
route_questionnaire_new = 'unccd:questionnaire_new'
route_questionnaire_new_step = 'unccd:questionnaire_new_step'

def get_valid_new_step_values():
    args = (get_categories()[0][0], 'unccd', 'unccd')
    kwargs = {'page_title': 'UNCCD Form', 'identifier': 'new'}
    return args, kwargs

def get_valid_new_values():
    args = ('unccd', 'questionnaire/details.html', 'unccd')
    kwargs = {'identifier': None}
    return args, kwargs

def get_valid_details_values():
    return ('foo', 'unccd', 'unccd')

def get_valid_list_values():
    return ('unccd', 'unccd/questionnaire/list.html')

def get_category_count():
    return len(get_categories())

def get_categories():
    return (
        ('unccd_0_general_information', 'General Information'),
        ('unccd_0_classification', 'Classification'),
        ('unccd_1_context', 'Section 1: ...'),
        ('unccd_2_problems_addressed', 'Section 2: ...'),
        ('unccd_3_activities', 'Section 3: ...'),
        ('unccd_4_actors_involved', 'Section 4: ...'),
        ('unccd_5_impact', 'Section 5: ...'),
        ('unccd_6_adoption_replicability', 'Section 6: ...'),
        ('unccd_7_lessons_learned', 'Section 7: ...'),
        ('unccd_8_questions_leg1', 'Section 8: ...'),
    )

class UnccdHomeTest(TestCase):

    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse(route_home)

    def test_redirect(self):
        res = self.client.get(self.url)
        self.assertRedirects(res, 'http://testserver/en/wocat/')

class QuestionnaireNewTest(TestCase):

    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse(route_questionnaire_new)
        self.request = self.factory.get(self.url)
        self.request.user = create_new_user()
        self.request.session = {}

    def test_questionnaire_new_login_required(self):
        res = self.client.get(self.url, follow=True)
        self.assertTemplateUsed(res, 'login.html')

class QuestionnaireNewStepTest(TestCase):

    fixtures = [
        'groups_permissions',
        'global_key_values',
        'unccd',
    ]

    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse(
            route_questionnaire_new_step, kwargs={
                'identifier': 'new', 'step': get_categories()[0][0]})
        self.request = self.factory.get(self.url)
        self.request.user = create_new_user()
        self.request.session = {}

    def test_questionnaire_new_step_login_required(self):
        res = self.client.get(self.url, follow=True)
        self.assertTemplateUsed(res, 'login.html')

class QuestionnaireDetailsTest(TestCase):

    fixtures = [
        'groups_permissions',
        'global_key_values',
        'unccd',
        'unccd_questionnaires',
    ]

    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse(
            route_questionnaire_details, kwargs={'identifier': 'unccd_1'})

    def test_renders_correct_template(self):
        res = self.client.get(self.url, follow=True)
        self.assertTemplateUsed(res, 'questionnaire/details.html')
        self.assertEqual(res.status_code, 200)


text:
package securbank.services;

import java.util.List;
import java.util.UUID;

import securbank.models.Transaction;
import securbank.models.Transfer;

/**
 * @author Mitikaa
 *
 */
public interface TransactionService {
	public Transaction initiateDebit(Transaction transaction);
	public Transaction initiateCredit(Transaction transaction);
	public Transaction initiateTransfer(Transfer transfer);
	public Transaction approveTransaction(Transaction transaction);
	public Transfer approveTransfer(Transfer transfer);
	public Transaction declineTransaction(Transaction transaction);
	public Transaction declineTransaction(Transfer transfer);
	public List<Transaction> getPendingTransactionsByAccountNumber(Long accountNumber);
	public List<Transaction> getPendingTransactionsByType(Long accountNumber, String accountType);
	public List<Transaction> getTransactionsByStatus(String approvalStatus);
	public Transaction getTransactionById(UUID id);
	public Transaction getPendingTransactionByAccountNumber(Long accountNumber);
	public Transaction approveTransactionFromTransfer(Transaction transaction);
	public boolean isTransactionValid(Transaction transaction);
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WebApp.Api.LocationCheckins
{
    [Route("api/[controller]")]
    public class LocationCheckinController : Controller
    {
        public IMediator mediator { get; }

        public LocationCheckinController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        // POST api/values
        [HttpPost]
        public CheckinResponse Post([FromBody]CheckinCommand value)
        {
            var response = this.mediator.Send<CheckinResponse>(value);
            return response.Result;
        }
    }
}