text:
# Signer

* [Overview](#overview)
* [Restrictions](#restrictions)
* [Getting Started](#getting-started)
* [Constructor](#constructor)
* [Methods](#methods)
* [Provider Interface](#provider-interface)
* [Error Codes](#error-codes)

## Overview

Waves Signer is a TypeScript/JavaScript library that features signing and broadcasting transactions on behalf of users without asking them for their seed phrases or private keys.

### Provider

In order to work with Signer, you need to link an external Provider library. Provider securely stores user's private data. Your web app and Signer itself do not have access to user's private key and seed phrase.

The Provider authenticates user and generates a digital signature.

Signer implements developer-friendly protocol for interacting with Provider as well as broadcasts transactions to the blockchain.
![](./_assets/signer.png)

For now, you can use one of the following Providers:

* [ProviderSeed](https://github.com/wavesplatform/provider-seed) developed by Waves team creates user account from SEED. ProviderSeed can be used at the app debugging stage.
* [ProviderWeb](https://github.com/waves-exchange/provider-web) developed by Waves.Exchange team uses an account created or imported into the Waves.Exchange web app via user's private key or seed phrase.
* [ProviderCloud](https://github.com/waves-exchange/provider-cloud) developed by Waves.Exchange team uses an email-based Waves.Exchange.

You can also develop your own Provider, see the [Provider Interface](#provider-interface) section below.

### Signer + ProviderWeb: How It Works

When Signer requests to sign a transaction, ProviderWeb opens an [iframe](https://html.spec.whatwg.org/multipage/iframe-embed-object.html), where the user can review transaction details and confirm or reject it. Upon confirmation, ProviderWeb generates a digital signature.

## Restrictions

Signer supports all types of transactions except Exchange transaction and Update Asset Info transaction.

Signer supports all browsers except Brave.

## Getting Started

### 1. Signer and Provider library installation

* To install Signer library use

   ```bash
   npm i @waves/signer
   ```

* To install ProviderSeed developed by Waves team, use

   ```bash
   npm i @waves/provider-seed @waves/waves-transactions
   ```

* To install ProviderWeb developed by Waves.Exchange, use

   ```bash
   npm i @waves.exchange/provider-web
   ```

   For Windows, use the following format:

   ```bash
   npm i<EMAIL_ADDRESS>   ```

* To install ProviderCloud developed by Waves.Exchange, use

   ```bash
   npm i @waves.exchange/provider-cloud
   ```

   For Windows, use the following format:

   ```bash
   npm i<EMAIL_ADDRESS>   ```

### 2. Library initialization

Add library initialization to your app.

* For Testnet & ProviderSeed:

   ```js
   import { Signer } from '@waves/signer';
   import { ProviderSeed } from '@waves/provider-seed';
   import { libs } from '@waves/waves-transactions';

   const seed = libs.crypto.randomSeed(15);
   const signer = new Signer({
     // Specify URL of the node on Testnet
     NODE_URL: 'https://nodes-testnet.wavesnodes.com'
   });
   signer.setProvider(new ProviderSeed(seed));
   ```

* For Testnet & Waves.Exchange ProviderWeb:

   ```js
   import { Signer } from '@waves/signer';
   import { ProviderWeb } from<EMAIL_ADDRESS>
   const signer = new Signer({
     // Specify URL of the node on Testnet
     NODE_URL: 'https://nodes-testnet.wavesnodes.com'
   });
   signer.setProvider(new ProviderWeb('https://testnet.waves.exchange/signer/'))
   ```

* For Testnet & Waves.Exchange ProviderCloud:

   ```js
   import { Signer } from '@waves/signer';
   import { ProviderCloud } from<EMAIL_ADDRESS>
   const signer = new Signer({
     // Specify URL of the node on Testnet
     NODE_URL: 'https://nodes-testnet.wavesnodes.com'
   });
   signer.setProvider(new ProviderCloud('https://testnet.waves.exchange/signer/'))
   ```

* For Mainnet & Waves.Exchange ProviderWeb:

   ```js
   import { Signer } from '@waves/signer';
   import { ProviderWeb } from<EMAIL_ADDRESS>
   const signer = new Signer();
   signer.setProvider(new ProviderWeb());
   ```

* For Mainnet & Waves.Exchange ProviderCloud:

   ```js
   import { Signer } from '@waves/signer';
   import { ProviderCloud } from<EMAIL_ADDRESS>
   const signer = new Signer();
   signer.setProvider(new ProviderCloud());
   ```

After that you will be able to use Signer features in the app.

### 3. Basic example

Now your application is ready to work with Waves blockchain. Let's test it by implementing basic functionality. For example, we could try to authenticate user, get his/her balances and transfer funds.

```js
const user = await signer.login();
const balances = await signer.getBalance();
const [broadcastedTransfer] = await signer
  .transfer({amount: 100000000, recipient: 'alias:T:merry'}) // Transfer 1 WAVES to alias merry
  .broadcast(); // Promise will resolved after user sign and node response

const [signedTransfer] = await signer
  .transfer({amount: 100000000, recipient: 'alias:T:merry'}) // Transfer 1 WAVES to alias merry
  .sign(); // Promise will resolved after user sign
```

### More examples

See example of an app that implements the donate button: <https://github.com/vlzhr/crypto-donate>.

## Constructor

```js
new Signer({
  NODE_URL: 'string',
})
```

Creates an object that features the following [methods](#methods).

Parameters:

| Parameter | Default value | Description |
| :--- | :--- | :--- |
| NODE_URL | https://nodes.wavesnodes.com | Node that is used to access a blockchain |

## Methods

* [User Info](#user-info)

   * [login](#login)
   * [logout](#logout)
   * [getBalance](#getbalance)
   * [getSponsoredBalances](#getsponsoredbalances)

* [Сreate Transactions](#create-transactions)

   * [Common fields](#common-fields)
   * [How to sign and broadcast transactions](#how-to-sign-and-broadcast-transactions)
   * [alias](#alias)
   * [burn](#burn)
   * [cancelLease](#cancellease)
   * [data](#data)
   * [invoke](#invoke)
   * [issue](#issue)
   * [lease](#lease)
   * [massTransfer](#masstransfer)
   * [reissue](#reissue)
   * [setAssetScript](#setassetscript)
   * [setScript](#setscript)
   * [sponsorship](#sponsorship)
   * [transfer](#transfer)
   * [batch](#batch)

* [Others](#others)

   * [broadcast](#broadcast)
   * [getNetworkByte](#getnetworkbyte)
   * [setProvider](#setprovider)
   * [waitTxConfirm](#waittxconfirm)

In code you can use [TypeScript types](https://github.com/wavesplatform/ts-types/blob/master/transactions/index.ts).

### User Info

#### login

Authenticates user with his/her account; creates account if it don't exist.

```js
login();
```

**Returns:**
Promise of user data: address and public key.

**Usage:**
```ts
const {address, publicKey} = await signer.login();
```

**Output example:**

```js
{
  address: '3P8pGyzZL9AUuFs9YRYPDV3vm73T48ptZxs',
  publicKey: 'FuChbN7t3gvW5esgARFytKNVuHSCZpXSYf1y3eDSruEN',
}
```

#### logout

Logs user out.

```js
logout();
```

**Returns:** Promise\<void\>.

**Usage:**
```ts
await signer.logout();
```

#### getBalance

If user logged in, provides balances of assets in user's portfolio.

```js
getBalance();
```

**Returns:** Promise of list of balances.

**Usage:**

```ts
const balances = await signer.getBalance();
```

**Output example:**

```js
[{
  assetId: 'WAVES',
  assetName: 'Waves',
  decimals: 8,
  amount: 100000000,
  isMyAsset: false,
  tokens: 1,
  sponsorship: null,
  isSmart: false
},
{
  assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
  assetName: 'CoffeeCoin',
  decimals: 3,
  amount: 1500,
  isMyAsset: false,
  tokens: 1.5,
  isSmart: false,
  sponsorship: 500
}]
```

**Output fields:**

| Field name | Description |
| :--- | :--- |
| assetId | Base58 encoded ID of the asset |
| assetName | Name of the asset |
| decimals | Number of decimal places in the asset amount |
| amount | Amount of asset multiplied by 10^`decimals`. For example, `decimals` of WAVES is 8, so the real amount is multipied by 10^8. `{ "WAVES": 677728840 }` means 6.77728840 |
| isMyAsset | `true` if current user is an asset issuer |
| tokens | Amount of asset to display in app interface |
| sponsorship | Amount of sponsored asset to be charged to users (per 0.001 WAVES) multiplied by 10^`decimals`
`null` if the asset is not sponsored |
| isSmart | `true` for [smart assets](https://docs.waves.tech/en/building-apps/smart-contracts/what-is-smart-asset) |

#### getSponsoredBalances

If user logged in, provides balances of sponsored assets in user's portfolio. See [Sponsored Fee](https://docs.waves.tech/en/blockchain/waves-protocol/sponsored-fee).

```js
getSponsoredBalances();
```

**Returns:** Promise of list of balances.

**Usage:**

```ts
const sponsoredBalances = await signer.getSponsoredBalances();
```

**Output example:**

```js
[{
  assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
  assetName: 'CoffeeCoin',
  decimals: 3,
  amount: 1500,
  isMyAsset: false,
  tokens: 1.5,
  isSmart: false,
  sponsorship: 500
}]
```

**Output fields** are the same as in [getBalance](#getbalance) method.

### Create transactions

The following methods create transactions (but do not sign or broadcast them):

* [alias](#alias)
* [burn](#burn)
* [cancelLease](#cancellease)
* [data](#data)
* [invoke](#invoke)
* [issue](#issue)
* [lease](#lease)
* [massTransfer](#masstransfer)
* [reissue](#reissue)
* [setAssetScript](#setassetscript)
* [setScript](#setscript)
* [sponsorship](#sponsorship)
* [transfer](#transfer)

> Check which of these transactions are supported by your Provider.

#### Common fields

Each create transaction method has optional fields that you don't specify manually in most cases:

| Field name | Description | Default value |
| :--- | :--- | :--- |
| chainId | 'W'.charCodeAt(0) or 87 means Mainnet
'T'.charCodeAt(0) or 84 means Testnet | Defined by configuration of Waves node that is set in [Constructor](#constructor) |
| fee | Transaction fee | Calculated automatically as described in [Transaction fee](https://docs.waves.tech/en/blockchain/transaction/transaction-fee) section |
| proofs | Array of transaction signatures | Added by `sign` or `broadcast` method (see [How to Sign and Broadcast Transactions](#how-to-sign-and-broadcast-transactions)). If you specify a proof manually, it is also added to the array |
| senderPublicKey | Base58 encoded public key of transaction sender | Returned by [login](#login) method |

#### How to Sign and Broadcast Transactions

Each create transaction method returns object that features the `sign` and `broadcast` methods.

To sign transaction use `sign` method. For example:

```js
signer.invoke({
   dApp: address,
   call: { function: name, args: convertedArgs },
}).sign();
```

To sign transaction and immediately send it to blockchain use `broadcast` method. For example:

```js
signer.invoke({
   dApp: address,
   call: { function: name, args: convertedArgs },
}).broadcast();
```

Note: this `broadcast` method has the same options as the [signer.broadcast](#broadcast) method that is described below.

You can sign or broadcast several transactions at once. For example:

```js
signer.alias({ 'new_alias', })
  .data([{ key: 'value', type: 'integer', value: 1 ])
  .transfer({ recipient: '3P8pGyzZL9AUuFs9YRYPDV3vm73T48ptZxs', amount: 10000 })
}).broadcast();
```

#### alias

Creates [Create Alias transaction](https://docs.waves.tech/en/blockchain/transaction-type/create-alias-transaction).

```js
alias(data: {
  alias: 'string'
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| alias* | | Short and easy to remember name of address. See [Alias](https://docs.waves.tech/en/blockchain/account/alias) for more information |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  alias: 'new_alias',
}

const [tx] = await signer
  .alias(data)
  .broadcast();
```

#### burn

Creates [Burn transaction](https://docs.waves.tech/en/blockchain/transaction-type/burn-transaction).

```js
burn(data: {
    assetId*: 'string',
    quantity*: LONG,
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| assetId* | | Base58 encoded ID of the asset to burn |
| quantity* | | Amount of asset multiplied by 10^`decimals`. For example, `decimals` of WAVES is 8, so the real amount is multipied by 10^8. `{ "WAVES": 677728840 }` means 6.77728840 |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  assetId: '4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC',
  quantity: 100,
}

const [tx] = await signer
  .burn(data)
  .broadcast();
```

#### cancelLease

Creates [Lease Cancel transaction](https://docs.waves.tech/en/blockchain/transaction-type/lease-cancel-transaction).

```js
cancelLease(data: {
    leaseId: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| leasetId* | | Base58 encoded ID of the Lease transaction |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  leaseId: '69HK14PEHq2UGRfRYghVW8Kc3487uJaoUmk2ntT4kw7X',
}

const [tx] = await signer
  .cancelLease(data)
  .broadcast();
```

#### data

Creates [Data transaction](https://docs.waves.tech/en/blockchain/transaction-type/data-transaction).

```js
data(data: [{
  key: 'string',
  type: 'string' | 'integer' | 'binary' | 'boolean',
  value: 'string' | number | boolean,
])
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| key* | | Key of a record. Maximum of 100 characters |
| type | | Type of a record |
| value* | | Value of a record. Maximum of 5 Kbytes |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const records = [
  { key: 'name', type: 'string', value: 'Lorem ipsum dolor sit amet' },
  { key: 'value', type: 'integer', value: 1234567 },
  { key: 'flag', type: 'boolean', value: true }
]

const [tx] = await signer
  .data({ data: records })
  .broadcast();
```

#### invoke

Creates [Invoke Scipt transaction](https://docs.waves.tech/en/blockchain/transaction-type/invoke-script-transaction).

```js
invoke(data: {
  dApp: 'string',
  fee: LONG,
  payment: [{
    assetId: 'string',
    amount: LONG,
  }],
  call: {
    function: 'string',
    args: [{
      type: 'integer' | 'string' | 'binary',
      value: number | 'string',
    }],
  },
  feeAssetId: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| dApp* | | Base58 encoded address or alias (with `alias:T:` prefix) of the dApp whose script should be invoked |
| fee | | We recommend to specify fee depending on number of action performed by called function (see [Transaction Fee](https://docs.waves.tech/en/blockchain/transaction/transaction-fee)) |
| payment | | Payments attached to the transaction. Maximum of two payments |
| payment.assetId* | | Base58 encoded ID of the asset to pay. `WAVES` or `null` means WAVES |
| payment.amount* | | Amount of asset multiplied by 10^`decimals`. For example, `decimals` of WAVES is 8, so the real amount is multipied by 10^8. `{ "WAVES": 677728840 }` means 6.77728840 |
| call | Default function should be invoked in the dApp | Parameters for called function |
| call.function* | | Name of the function that is called |
| call.args* | | Arguments for the function  that is called |
| call.args.type* | | Type of argument |
| call.args.value* | | Value of argument |
| feeAssetId | WAVES | Base58 encoded ID of the sponsored asset to pay the fee. See the [Sponsored Fee](https://docs.waves.tech/en/blockchain/waves-protocol/sponsored-fee) article for more information. `null` or omitted field means WAVES |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**
```ts
const data = {
  dApp: '3Fb641A9hWy63K18KsBJwns64McmdEATgJd',
  fee: 1000000,
  payment: [{
    assetId: '73pu8pHFNpj9tmWuYjqnZ962tXzJvLGX86dxjZxGYhoK',
    amount: 7,
  }],
  call: {
    function: 'foo',
    args: [
      { type: 'integer', value: 1 },
      { type: 'binary', value: 'base64:AAA=' },
      { type: 'string', value: 'foo' }
    ],
  },
}

const [tx] = await signer
  .invoke(data)
  .broadcast();
```

#### issue

Creates [Issue transaction](https://docs.waves.tech/en/blockchain/transaction-type/issue-transaction).

```js
issue(data: {
  name: 'string',
  decimals: number,
  quantity: LONG,
  reissuable: boolean,
  description: 'string',
  script: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| name* | | Asset name |
| decimals* | | Number of digits in decimal part |
| quantity* | | Amount of asset multiplied by 10^`decimals` |
| reissuable* | | `true` – asset reissue is possible.
`false` — asset reissue is not possible |
| description* | | Asset description |
| script | | Base64 encoded script (with `base64:` prefix) to be attached to to asset |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  name: 'MyToken',
  decimals: 8,
  quantity:<PHONE_NUMBER>00,
  reissuable: true,
  description: 'It is a gaming token',
}

const [tx] = await signer
  .issue(data)
  .broadcast();
```

#### lease

Creates [Lease transaction](https://docs.waves.tech/en/blockchain/transaction-type/lease-transaction).

```js
lease(data: {
    amount: LONG,
    recipient: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| amount* | | Amount of WAVES multiplied by 10^8. For example, `{ "WAVES": 677728840 }` means 6.77728840 |
| recipient* | | Base58 encoded [address](https://docs.waves.tech/en/blockchain/account/address) or alias (with `alias:T:` prefix) of the recipient |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
    amount: 10000,
    recipient: 'alias:T:merry',
}

const [tx] = await signer
  .lease(data)
  .broadcast();
```

#### massTransfer

Creates [Mass Transfer transaction](https://docs.waves.tech/en/blockchain/transaction-type/mass-transfer-transaction).

```js
massTransfer(data: {
  assetId: 'string',
  transfers: [{
    amount: LONG,
    recipient: 'string',
  }],
  attachment: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| assetId | WAVES | Base58 encoded ID of the asset to transfer |
| transfers* | | List of transfers |
| transfers.amount* | | Amount of asset multiplied by 10^`decimals`. For example, `decimals` of WAVES is 8, so the real amount is multipied by 10^8. `{ "WAVES": 677728840 }` means 6.77728840 |
| transfers.recipient* | | Base58 encoded [address](https://docs.waves.tech/en/blockchain/account/address) or alias (with `alias:T:` prefix) of the recipient |
| attachment | | Optional binary data base58 encoded. This field is often used to attach a comment to the transaction. The maximum data size is 140 bytes |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const crypto = require('@waves/ts-lib-crypto')

const data = {
    transfers: [
    {
      amount: 100,
      recipient: '3P23fi1qfVw6RVDn4CH2a5nNouEtWNQ4THs',
    },
    {
      amount: 200,
      recipient: 'alias:T:merry',
    }],
    attachment: crypto.base58Encode(crypto.stringToBytes('sample message for recipient'))
]

const [tx] = await signer
  .massTransfer(data)
  .broadcast();
```

#### reissue

Creates [Reissue transaction](https://docs.waves.tech/en/blockchain/transaction-type/reissue-transaction).

```js
reissue(data: {
  assetId: 'string',
  quantity: LONG,
  reissuable: boolean,
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| assetId* | | Base58 encoded ID of the asset to reissue |
| quantity* | | Amount of asset multiplied by 10^`decimals` to reissue |
| reissuable* | | `true` – asset reissue is possible.
`false` — asset reissue is not possible |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx'
  quantity:<PHONE_NUMBER>00,
  reissuable: true,
}

const [tx] = await signer
  .reissue(data)
  .broadcast();
```

#### setAssetScript

Creates [Set Asset Script transaction](https://docs.waves.tech/en/blockchain/transaction-type/set-asset-script-transaction).

```js
setAssetScript(data: {
  assetId: 'string',
  script: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| assetId* | | Base58 encoded ID of the asset |
| script | | Base64 encoded script (with `base64:` prefix) to be attached to the asset |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
  script: 'base64:AwZd0cYf',
}

const [tx] = await signer
  .setAssetScript(data)
  .broadcast();
```

#### setScript

Creates [Set Script transaction](https://docs.waves.tech/en/blockchain/transaction-type/set-script-transaction).

```js
setScript(data: {
  script: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| script | | Base64 encoded [account script](https:/docs.waves.tech/en/ride/script/script-types/account-script) or [dApp script](https://docs.waves.tech/en/ride/script/script-types/dapp-script) (with `base64:` prefix) to be attached to the user account. `null` means cancelling the script |

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  script: 'base64:AAIDAAAAAAAAAAQIARIAAAAAAAAAAA...',
}

const [tx] = await signer
  .setScript(data)
  .broadcast();
```

#### sponsorship

Creates [Sponsor Fee transaction](https:/docs.waves.tech/en/blockchain/waves-protocol/sponsored-fee).

```js
sponsorship(data: {
    assetId: 'string',
    minSponsoredAssetFee: LONG,
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| assetId* | | Base58 encoded ID of the asset |
| minSponsoredAssetFee | | Required amount of sponsored token to be charged to users (per 0.001 WAVES) multiplied by 10^`decimals` |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const data = {
  assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
  minSponsoredAssetFee: 314,
}

const [tx] = await signer
  .sponsorship(data)
  .broadcast();
```

#### transfer

Creates [Transfer transaction](https://docs.waves.tech/en/blockchain/transaction-type/transfer-transaction).

```js
transfer(data: {
  recipient: 'string',
  amount: LONG,
  assetId: 'string',
  attachment: 'string',
  feeAssetId: 'string',
})
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| recipient* | | Base58 encoded [address](https://docs.waves.tech/en/blockchain/account/address) or alias (with `alias:T:` prefix) of the recipient |
| amount* | | Amount of asset multiplied by 10^`decimals`. For example, `decimals` of WAVES is 8, so the real amount is multipied by 10^8. `{ "WAVES": 677728840 }` means 6.77728840 |
| assetId | WAVES | Base58 encoded ID of the asset to transfer. `null` or omitted field means WAVES |
| attachment | | Optional binary data base58 encoded. This field is often used to attach a comment to the transaction. The maximum data size is 140 bytes |
| feeAssetId | WAVES | Base58 encoded ID of the sponsored asset to pay the fee. See the [Sponsored Fee](https://docs.waves.tech/en/blockchain/waves-protocol/sponsored-fee) article for more information. `null` or omitted field means WAVES |

\* Required parameter.

See [Common fields](#common-fields) for other fields description.

**Usage:**

```js
const crypto = require('@waves/ts-lib-crypto')

const data = {
  recipient: '3P8pGyzZL9AUuFs9YRYPDV3vm73T48ptZxs',
  amount: 10000,
  attachment: crypto.base58Encode(crypto.stringToBytes('sample message for recipient'))
}

const [tx] = await signer
  .transfer(data)
  .broadcast();
```

#### batch

Creates list of transactions.

```js
batch([{
  type: number,
  ... // fields depending on the transaction type
}])
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| type* | | [Transaction type ID](https://docs.waves.tech/en/blockchain/transaction-type/) |

\* Required parameter.

**Usage:**

```js
const [transfer, alias, issue] = await signer.batch([
  {
    type: 4,
    recipient: 'alias:T:merry',
    amount: 100000000
  },
  {
    type: 10,
    alias: 'send33'
  },
  {
    type: 3,
    name: 'SomeTokenName',
    description: 'Some Token Description',
    reissuable: false,
    quantity: 100,
    decimals: 1
  }
]).sign(); // Or broadcast
```

In this example, `sign` method returns array of signed transactions in the same order as they are defined in `batch`.

### Others

#### broadcast

Sends transactions that are already signed to the blockchain.

```js
broadcast(tx,[options])
```

**Returns:** Promise of node response. See the [POST /transactions/broadcast](https://docs.waves.tech/en/waves-node/node-api/transactions) method description of Node API.

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| tx* | | Signed transaction or array of signed transactions |
| options.chain | false | [Type: boolean] Send the next transaction only after the previous transaction is put in the blockchain and confirmed |
| options.confirmations | -1 | Number of confirmations after that the Promise is resolved:
less than 0 – Promise is resolved when the transaction is put in UTX pool
0 – Promise is resolved when the block that contains the transaction is added to the blockchain
1 – Promise is resolved when the next block is added to the blockchain and so on |

\* Required parameter.

**Usage:**

```js
const [transfer1] = await signer.transfer({amount: 1, recipient: 'alias:T:merry'}).sign();
const [transfer2] = await signer.transfer({amount: 1, recipient: 'alias:T:merry'}).sign();

await signer.broadcast([transfer1, transfer2], {chain: true, confirmations: 2});
```

In this example:

* `transfer1` transaction is sent to the node and put in UTX pool.
* Block with `transfer1` and two more blocks are added to the blockchain.
* `transfer2` transaction is sent to the node and put in UTX pool.
* Block with `transfer2` and two more blocks are added to the blockchain.
* Promise is resolved and you can notify user that his/her transactions are confirmed.

#### getNetworkByte

Obtains [chain ID](https://docs.waves.tech/en/blockchain/blockchain-network/#chain-id).

```js
getNetworkByte();
```

**Returns:** Promise of chain ID.

**Usage:**

```js
const chainId = signer.getNetworkByte();
```

#### setProvider

Specifies a Provider that is used to sign transactions. See [Provider Interface](#provider-interface) to find out the provider requirements.

```js
setProvider(provider);
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| provider* | | Object that features Provider interface |

\* Required parameter.

**Usage:**
```js
signer.setProvider(new Provider());
```

#### waitTxConfirm

Waits for the transaction to appear in the blockchain.

```js
waitTxConfirm(tx, confirmations)
```

**Parameters:**

| Parameter name | Default value | Description |
| :--- | :--- | :--- |
| tx* | | Transaction or array transactions that are sent to the blockchain |
| confirmations* | | Number of blocks added to the blockchain after the block that contains the transaction |

\* Required parameter.

**Usage:**
```ts
const [tx] = await signer
  .transfer({amount: 10000000, recipient: 'alias:T:merry'})
  .broadcast();

signer.waitTxConfirm(tx, 1).then((tx) => {
  // Tx have one confirmation
}});
```

## Provider Interface

> :warning: To ensure the security of user data, Provider should be based on `iframe`.

Provider should feature the following interface:

```js
interface Provider {

    /**
     * Signer subscribes to login events in the Provider
     * When triggered, the Provider passes user data: address and public key
     * For further unsubscribe Signer calls `off`
     */
    on(
        event: 'login',
        handler:({ address: string; publicKey: string }) => any
    ) => Provider;

    /**
     * Signer subscribes to logout events in the Provider
     * For further unsubscribe Signer calls `off`
     */
    on( event: 'logout', handler:() => any) => Provider;

    /**
     * Signer subscribes to the first login event in the Provider
     * When triggered, the Provider passes user data: address and public key,
     *   then cancels the subscription
     */
    once(
        event: 'login',
        handler:({ address: string; publicKey: string }) => any
    ) => Provider;

    /**
     * Signer subscribes to the first logout event in the Provider
     * When triggered, the Provider cancels the subscription
     */
    once( event: 'logout', handler:() => any) => Provider;

    /**
     * Signer unsubscribes from events previously subscribed to
     */
    off(
        event: 'login',
        handler:({ address: string; publicKey: string }) => any
    ) => Provider;
    off( event: 'logout', handler:() => any) => Provider;

    /**
     * Sets connection to Waves node
     * @param options
     */
    connect(options: {NODE_URL: string, NETWORK_BYTE: number}): Promise<void>;

    /**
     * Authenticates user with their account
     */
    login(): Promise<{address: string, publicKey: string}>;

    /**
     * Logs user out
     */
    logout(): Promise<void>;

    /**
     * Signs custom message
     * @param data
     */
    signMessage(data: string | number): Promise<string>;

    /**
     * Signs typed data
     * @param data
     */
    signTypedData(data: Array<TypedData>): Promise<string>;

    /**
     * Signs transactions in array
     * Here SignedTx<T> is any transaction, T[] is an array of any transactions
     * @param list
     */
    sign<T extends SignerTx>(toSign: T[]): Promise<SignedTx<T>>;
    sign<T extends Array<SignerTx>>(toSign: T): Promise<SignedTx<T>>;
}
```

## Error Codes

| Error's class                  | Code | Type           | Example |
|:------------------------------|:-----|:---------------|:--------|
| SignerOptionsError            | 1000 | validation     | Invalid signer options: NODE_URL, debug |
| SignerNetworkByteError        | 1001 | network        | Could not fetch network from {NODE_URL}: Failed to fetch |
| SignerAuthError               | 1002 | authorization  | Can't use method: getBalance. User must be logged in |
| SignerProviderConnectError    | 1003 | network        | Could not connect the Provider |
| SignerEnsureProviderError     | 1004 | provider       | Can't use method: login. Provider instance is missing
🛈 Possible reasons: the user is in Incognito mode or has disabled cookies |
| SignerProviderInterfaceError  | 1005 | validation     | Invalid provider properties: connect |
| SignerProviderInternalError   | 1006 | provider       | Provider internal error: {...}. This is not error of signer. |
| SignerApiArgumentsError       | 1007 | validation     | Validation error for invoke transaction: {...}. Invalid arguments: senderPublicKey |
| SignerNetworkError            | 1008 | network        | Network Error |

repository: wavesplatform/signer

gha_language: TypeScript

repo_name: wavesplatform/signer


text:
---
title: polymorphic persistents
layout: page
---

We can use polymorphism with our [persistent objects](../model/persistents.html) as well. For
example, let's say our blogging system has two kinds of users: members and commenters. Only members
can have a user profile. Here, we use annotations `@polyPersistent` and `@derivedPersistent` in
place of `@persistent`:

```scala
import longevity.model.annotations.component
import longevity.model.annotations.derivedPersistent
import longevity.model.annotations.polyPersistent

@component[DomainModel]
case class UserProfile(
  tagline: String,
  imageUri: Uri,
  description: Markdown)

@polyPersistent[DomainModel]
sealed trait User {
  val username: Username
  val email: Email
}

@derivedPersistent[DomainModel, User]
case class Member(
  username: Username,
  email: Email,
  profile: UserProfile)
extends User

@derivedPersistent[DomainModel, User]
case class Commenter(
  username: Username,
  email: Email)
extends User
```

As with [polymorphic components](components.html), we must remember to seal the trait to form a
proper abstract data type.

The non-annotation equivalent is as follows:

```scala
import longevity.model.CType
import longevity.model.DerivedPType
import longevity.model.PolyPType

case class UserProfile(
  tagline: String,
  imageUri: Uri,
  description: Markdown)

object UserProfile extends CType[DomainModel, UserProfile]

sealed trait User {
  val username: Username
  val email: Email
}

object User extends PolyPType[DomainModel, User] {
  object props {
    // ...
  }
}

case class Member(
  username: Username,
  email: Email,
  profile: UserProfile)
extends User

object Member extends DerivedPType[DomainModel, Member, User] {
  object props {
    // ...
  }
}

case class Commenter(
  username: Username,
  email: Email)
extends User

object Commenter extends DerivedPType[DomainModel, Commenter, User] {
  object props {
    // ...
  }
}
```

Notice how `User`, `Member`, and `Commenter` all have their own
properties, keys, and indexes. We could, for example, put in a
[key](../ptype/keys.html) on `User.username`, and
[indexes](../ptype/indexes.html) on `User.email` and
`Member.profile.tagline`, like so:

```scala
import longevity.model.annotations.derivedPersistent
import longevity.model.annotations.polyPersistent

@polyPersistent[DomainModel]
trait User {
  val username: Username
  val email: Email
}

object User {
  implicit val usernameKey = key(props.username)
  override val indexSet = Set(index(props.email))
}

@derivedPersistent[DomainModel, User]
case class Member(
  username: Username,
  email: Email,
  profile: UserProfile)
extends User

object Member {
  override val indexSet = Set(index(props.profile.tagline))
}
```

When you construct your [longevity context](../context), you will be able to use
[repository](../repository) for for each of your `@derivedPersistents`, along with one for the
parent `@polyPersistent`. These persistent classes will share the same backing store, so a `Member`
persisted as a `User` will be retrievable as a `Member`, and vice-versa. Keys and indexes declared
in `object User` will apply to all types of `Users`, whereas keys and indexes declared in `object
Member` will only apply to members. For more information, see the section on [persisting
polymorphism](../repo/poly.html).

{% assign prevTitle = "polymorphic components" %}
{% assign prevLink  = "components.html" %}
{% assign upTitle   = "subtype polymorphism" %}
{% assign upLink    = "." %}
{% assign nextTitle = "controlled vocabularies" %}
{% assign nextLink  = "cv.html" %}
{% include navigate.html %}

repository: tspannhw/longevity

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: tspannhw/longevity


text:
# bigdata-project-spark-option

This project lets us find word count in a data file using spark.

### Getting the data for our project:

I am using the data available at [http://shakespeare.mit.edu/hamlet/full.html](http://shakespeare.mit.edu/hamlet/full.html) for my project.

Getting the HTML to a text file using curl commands.

open Git bash on you computer and run the command ```curl "URL for Website" -O "file name to be saved"```

An example of the command I used is ```curl "http://shakespeare.mit.edu/hamlet/full.html" -O
"hamlet.txt"```

Clean up most of the HTML tags using the sed command below

```sed -E 's/<[^>]*>/''/g' hamlet.txt > hamlet_cleaned.txt```

Similarly, remove unwanted data you don't want to count. Now we have our data file ready for spark.

Now for this project, we are not considering the top 35 common words in English as per Wikipedia [https://en.wikipedia.org/wiki/Most_common_words_in_English](https://en.wikipedia.org/wiki/Most_common_words_in_English)

to remove these words use the sed command

```sed -E 's/\b(the|The|be|Be|to|To|of|Of|And|and|a|A|in|In|that|That|have|Have|i|I|it|It|for|For|not|Not|on|On|with|With|he|He|as|As|you|You|do|Do|at|At|this|This|his|His|by|By|from|From|they|They|we|We|say|Say|her|Her|she|She|or|Or|but|But|will|Will|So|so|my|is|your|me|him|are|what|.|O)\b/''/g' hamlet.txt > hamlet_cleaned.txt```

You can add any other words you would like to ignore

---

### Processing the Data using spark.

If you would like to set up Spark on your computer from scratch the repo [https://github.com/denisecase/setup-spark](https://github.com/denisecase/setup-spark) is a good start.

Open PowerShell and run ```spark-shell``` to bring up spark with scala.

Create a Resilient Distributed Dataset (RDD) from the text file which we have created. Use the command to do so

```val rddData = sc.textFile("hamlet_cleaned.txt")```

This command creates an RDD named rddData. Now we have to split the words in ```rddData``` to work on their counts. The below command does so.

```val rddDataSplit = rddData.flatMap(line => line.split(" "));```

Here we are splitting the ```rddData``` based on spaces and saving it into a new dataset ```rddDataSplit```

Since RDD's are [immutable](https://www.google.com/search?q=immutable&rlz=1C1GCEB_enUS863US863&oq=imm&aqs=chrome.0.69i59j69i57j0i67l2j0i433j0i67i433j69i60l2.863j0j4&sourceid=chrome&ie=UTF-8), we cannot work on the same RDD for modifications hence we create a new one.

 So we have to create key-value pairs of words, let's begin by assigning all words, a count of one and the below command does the same operation.

```val rddMapData = rddDataSplit.map(word =>(word,1));```

Now if call the ```collect()``` method we get the array in key-value pairs as below

```Array(("",1), ("",1), (Hamlet,1), (Entire,1), (Play,1), ("",1), ("",1), ("",1), (Tragedy,1), ("",1), (Hamlet,1), (Prince,1), ("",1), (Denmark,1), ("",1), ("",1), ("",1), ("",1), ("",1), ("",1), ("",1), (Shakespeare,1), (homepage,1), ("",1), ("",1), ("",1), ("",1), (|,1), (Hamlet,1), ("",1), ("",1), ("",1), ("",1), (|,1), (Entire,1), (play,1), ("",1), ("",1), (ACT,1), (SCENE,1), (.,1), (Elsinore.,1), ("",1), (platform,1), (before,1), ("",1), (castle.,1), ("",1), (FRANCISCO,1), ("",1), ("",1), (post.,1)```

Now that we have successfully mapped our data, we need to reduce it to find counts of each word. RDD has a method ```reduceByKey()``` that does the operation for us.

```val rddReducedData = rddMapData.reduceByKey(_+_); ```

The ```collect()``` method now shows the individual word count.

```Array((pate,4), (joy.,1), (rises.,1), (lug,1), (shot,7), (prison-house,1), (order,3), (son--,1), (apprehension,2), (Friend,1), (behind,4), (lenten,1), (Sprinkle,1), (been,26), (shoe?,1), (Switzers?,1), (jade,1), (breath,7), (pendent,1), (knows,3), (-night!,1), (tune,2), (FORTINBRAS,9), (records,1), (harlot's,1), (Pretty,1), (smooth,2), (shut,1), (grant,1), (stern,1), (morn,3), (tush,1)```

 But there is a problem here, its still hard to find out which is the most used word. Hence, let's sort it using the RDD method, ```sortBy()```
```val rddResult = rddReducedData.sortBy(_._2, false)```

here the ```false``` indicates sorting in descending order. There are many other ways to sort, but I prefer this. Now the ```collect()``` method returns the array as such and finding out the highest word count is much easy.

``` Array(("",4492), (HAMLET,359), (HORATIO,112), (KINGCLAUDIUS,102), (LORDPOLONIUS,86), (QUEENGERTRUDE,69), (LAERTES,63), (OPHELIA,59), (ROSENCRANTZ,49), (MARCELLUS,36), (GUILDENSTERN,33), (FirstClown,33), (OSRIC,25), (BERNARDO,23), (Exit,19), (.,15), (Ghost,14), (REYNALDO,13), (Exeunt,13), (SecondClown,12), ([Aside],9), (FRANCISCO,8), (FirstPlayer,8), (',8), (ExeuntROSENCRANTZGUILDENSTERN,7), ([Sings],7)```

Now let's just get only the top 10 highest words, The RDD's ```take(n)``` method returns the first ```n``` entries in the dataset.

```rddResult.take(10)```

```Array(("",4492), (HAMLET,359), (HORATIO,112), (KINGCLAUDIUS,102), (LORDPOLONIUS,86), (QUEENGERTRUDE,69), (LAERTES,63), (OPHELIA,59), (ROSENCRANTZ,49), (MARCELLUS,36))```

Now, let's get this data out as a file for processing and creating a chart. using the ```saveAsTextFile()``` of RDD.

```rddResult.saveAsTextFile("sorted")```

---

### Visual report:

Now let's create a visual chart based on the resultant data for the top 10 most used words in the URL we fetched. We can do this easily through excel. Take the output of the dataset and paste it into excel.

Now using the data column of the excel, split the copied data into two columns using ```,``` as out delimiter.

Then select the data you want to visualize, and using in the right-click menu select the quick analysis and select the visual you want.

#### My visual report is below:

![Top 10 words](./top10Chart.jpg)

___

### References:

1. Spark setup --> [https://github.com/denisecase/setup-spark](https://github.com/denisecase/setup-spark)

2. RDD programming guide --> [https://spark.apache.org/docs/latest/rdd-programming-guide.html](https://spark.apache.org/docs/latest/rdd-programming-guide.html)

3. Markdown Syntax --> [https://www.markdownguide.org/basic-syntax/](https://www.markdownguide.org/basic-syntax/)

4. Spark --> [https://spark.apache.org/](https://spark.apache.org/)

5. The Complete Works of William Shakespeare --> [http://shakespeare.mit.edu/index.html](http://shakespeare.mit.edu/index.html)

6. Section break idea for readme was taken from [https://github.com/Bhavya-123/bigdata-project](https://github.com/Bhavya-123/bigdata-project).
___

license: MIT

branch_name: refs/heads/main


text:
# Python SDK {#reference_l5b_225_xdb .reference}

## Download address  {#section_gx3_35f_jdb .section}

SDK GitHub:

[https://github.com/aliyun/aliyun-log-python-sdk](https://github.com/aliyun/aliyun-log-python-sdk)

## Procedure {#section_ylg_r1r_12b .section}

Follow these steps to start using the Log Service Python SDK quickly.

## Step 1. Create an Alibaba Cloud account {#section_zlg_r1r_12b .section}

For more information, see [Sign up with Alibaba Cloud](https://www.alibabacloud.com/help/zh/doc-detail/50482.htm).

## Step 2. Obtain an Alibaba Cloud AccessKey {#section_amg_r1r_12b .section}

Before using Log Service Python SDK, you must apply for an [AccessKey](../../../../../reseller.en-US/API Reference/AccessKey.md).

Log on to the Access Key Management page. Select an AccessKey for SDK.  If you do not have any, create one and make sure the AccessKey is **enabled**. For more information about how to create an access key, see [Preparation](../../../../../reseller.en-US/User Guide/Preparation/Preparation.md).

The AccessKey is used in the following steps and must be kept confidential. For more information about [Configurations](reseller.en-US/SDK Reference/Basic Descriptions /Configurations.md) how to use the AccessKey in SDK.

## Step 3 Create a Log Service project and a Logstore {#section_zrq_dbr_12b .section}

Before using Log Service PHP SDK, you must create a Log Service project and a Logstore in the console.

Before using Log Service Python SDK, you must create a Log Service project and a Logstore in the console.

1.  Log on to the Log Service console.
2.  Click Create Project in the upper-right corner.Click **Create Project** in the upper right corner.
3.  Enter the **Project Name** and select the **Region**. Click **Confirm**.
4.  On the Project List page, click the name of the project, and then click **Create**.  [Create a Logstore](../../../../../reseller.en-US/User Guide/Preparation/Manage a Logstore.md#).

    After you create a project, you can also click **Create** to create a Logstore based on the system prompt.

5.  Complete the configurations, and click **Confirm**.

    Enter the Logstore Name and Data Retention Time.  Select the Number of [Shards](../../../../../reseller.en-US/Product Introduction/Basic concepts/Shard.md#) as needed. In this example, you must configure four shards.

**Note:**

-   Make sure that you use the same Alibaba Cloud account to obtain the Alibaba Cloud AccessKey and create the Log Service project and Logstore.
-   For more information about the concepts of Log Service such as project and Logstore, see [Basic concepts](../../../../../reseller.en-US/Product Introduction/Basic concepts.md).
-   A project name must be globally unique in Log Service, and a Logstore name must be unique in the same project.
-   After a project is created, you cannot modify the region  or migrate the project across regions.

## Step 4. Install a Python environment {#section_a1t_j2j_sy .section}

The Python SDK is a pure Python library and supports all Python operating systems, including Linux, Mac OS  X and Windows. Please install Python as follows:

1.  Download and install the latest Python [installation package](https://www.python.org/downloads/).

    **Note:**

    -   Currently, Python SDK supports the Python 2.6/2.7 and Python  3.3/3.4/3.5/3.6 environments.  You can run the`python  -V`command to query the current version of Python.
    -   Python does not officially support Python 2.6 and Python 3.3. We recommend that you use Python 2.7, Python  3.4, and later versions.
2.  Download and install the Python package management tool  [pip](https://pip.pypa.io/en/latest/installing.html).

    After pip is installed, run`pip  -V` to check whether the installation is successful and query the current pip version.

## Step 5. Install a Python SDK {#section_bqt_42j_sy .section}

Run the following command as an administrator in Shell to install Python SDK.

```
pip install -U aliyun-log-python-sdk
```

## Step 6. Start a Python program {#section_kbx_x2j_sy .section}

You can start using the Python SDK. To interact with Log Service and obtain the relevant output, run the following sample code in a text editor or Python IDE.

For more information, see [Github/readthedocs](http://aliyun-log-python-sdk.readthedocs.io/).

```
# encoding: utf-8
import time
from aliyun.log.logitem import LogItem
from aliyun.log.logclient import LogClient
from aliyun.log.getlogsrequest import GetLogsRequest
from aliyun.log.putlogsrequest import PutLogsRequest
from aliyun.log.listlogstoresrequest import ListLogstoresRequest
from aliyun.log.gethistogramsrequest import GetHistogramsRequest
def main():
    endpoint = '' # Select the endpoint that matches the region of the project created in the preceding step.
    accessKeyId = '' # Use your Alibaba Cloud AccessKey ID.
    accessKey = '' # Use your Alibaba Cloud AccessKey Secret.
    project = '' # The name of the project created in the preceding step.
    logstore = '' # The name of the Logstore created in the preceding step.
    # Note: Configure four shards for the created Logstore for later testing.
    # Construct a client
    client = LogClient(endpoint, accessKeyId, accessKey)
    # List all LogStores
    req1 = ListLogstoresRequest(project)
    res1 = client.list_logstores(req1)
    res1.log_print()
    topic = ""
    source = ""
    # Send 10 data packets, each of which contains 10 logs.
    for i in range(10):
        logitemList = [] # LogItem list
        for j in range(10):
            contents = [('index', str(i * 10 + j))]
            logItem = LogItem()
            logItem.set_time(int(time.time()))
            logItem.set_contents(contents)
            logitemList.append(logItem)
        req2 = PutLogsRequest(project, logstore, topic, source, logitemList)
        res2 = client.put_logs(req2)
        res2.log_print()
    # List all shards and read the data written in the last minute.
    listShardRes = client.list_shards(project, logstore)
    for shard in listShardRes.get_shards_info():
        shard_id = shard["shardID"]
        start_time = int(time.time() - 60)
        end_time = start_time + 60
        res = client.get_cursor(project, logstore, shard_id, start_time)
        res.log_print()
        start_cursor = res.get_cursor()
        res = client.get_cursor(project, logstore, shard_id, end_time)
        end_cursor = res.get_cursor()
        while True:
            loggroup_count = 100 # Read 100 packets each time.
            res = client.pull_logs(project, logstore, shard_id, start_cursor, loggroup_count, end_cursor)
            res.log_print()
            next_cursor = res.get_next_cursor()
            if next_cursor == start_cursor:
                break
            start_cursor = next_cursor
    # Note: You can use the following interfaces to query data only when the index function is enabled.
    time.sleep(60)
    topic = ""
    query = "index"
    From = int(time.time()) - 600
    To = int(time.time())
    res3 = None
    # Query the number of logs that match the query criteria during the past 10 minutes. Retry if not all execution results are correct.
    while (res3 is None) or (not res3.is_completed()):
        req3 = GetHistogramsRequest(project, logstore, From, To, topic, query)
        res3 = client.get_histograms(req3)
    res3.log_print()
    # Obtain the number of logs that match the query conditions.
    total_log_count = res3.get_total_count()
    log_line = 10
    # Read 10 logs each time until all log data is queried. Retry three times if not all query results are correct during each query.
    for offset in range(0, total_log_count, log_line):
        res4 = None
        for retry_time in range(0, 3):
            req4 = GetLogsRequest(project, logstore, From, To, topic, query, log_line, offset, False)
            res4 = client.get_logs(req4)
            if res4 is not None and res4.is_completed():
                break
            time.sleep(1)
        if res4 is not None:
            res4.log_print()
    listShardRes = client.list_shards(project, logstore)
    shard = listShardRes.get_shards_info()[0]
    # Split a shard
    if shard["status"] == "readwrite":
        shard_id = shard["shardID"]
        inclusiveBeginKey = shard["inclusiveBeginKey"]
        midKey = inclusiveBeginKey[:-1] + str((int(inclusiveBeginKey[-1:])) + 1)
        client.split_shard(project, logstore, shard_id, midKey)
    # Merge shards.
    shard = listShardRes.get_shards_info()[1]
    if shard["status"] == "readwrite":
        shard_id = shard["shardID"]
        client.merge_shard(project, logstore, shard_id)
    # Delete shard
    shard = listShardRes.get_shards_info()[-1]
    if shard["status"] == "readonly":
        shard_id = shard["shardID"]
        client.delete_shard(project, logstore, shard_id)
   # Create an external store.
    res = client.create_external_store(project,ExternalStoreConfig("rds_store","cn-qingdao","rds-vpc","vpc-************","i***********","*. *. *.*","3306","root","sfdsfldsfksflsdfs","meta","join_meta"));
    res.log_print()
    res = client.update_external_store(project,ExternalStoreConfig("rds_store","cn-qingdao","rds-vp","rds-vpc","vpc-************","i************","*. *. *.*","3306","root","sfdsfldsfksflsdfs","meta","join_meta"));
    res.log_print()
    res = client.get_external_store(project,"rds_store");
    res.log_print()
    res = client.list_external_store(project,"");
    res.log_print();
    res = client.delete_external_store(project,"rds_store")
    res.log_print();
    # Use python sdk for query analysis.
    req4 = GetLogsRequest(project, logstore, From, To, topic, "* | select count(1)", 10,0, False)
    res4 = client.get_logs(req4)
    # Use python sdk for join rds query.
    req4 = GetLogsRequest(project, logstore, From, To, topic, "* | select count(1) from "+logstore +" l join rds_store r on l.ikey =r.ekey", 10,0, False)
    res4 = client.get_logs(req4)
    # Use python sdk to insert query results into rds.
    req4 = GetLogsRequest(project, logstore, From, To, topic, "* | insert into rds_store select count(1) ", 10,0, False)
    res4 = client.get_logs(req4)
if __name__ == '__main__':
    main()
```

path: /intl.en-US/SDK Reference/Python SDK.md

filename: Python SDK.md

gha_license_id: MIT


text:
# Hourly Utilization Report
The Hourly Utilization Report gives an overview of an organization’s hourly slot utilization measured in slot hours.

Slot hours are derived by dividing the total number of slot-milliseconds (`total_slot_ms`) consumed by all jobs in a given hour by the number of milliseconds in an hour `(1000 * 60 * 60)`. This aggregate-level computation provides the most accurate approximation of the overall slot utilization for a given hour. Note that this calculation is most accurate for organizations with consistent hourly slot usage. If your organization does not have consistent slot usage this number might be lower than expected.

More details about calculating average slot utilization can be found [here](https://cloud.google.com/bigquery/docs/information-schema-jobs#examples).

All timestamps in this report are in UTC.

This report leverages the [hourly utilization query](../sql/hourly_utilization.sql).

### Filter Bar & Scorecards
This report allows users to filter data by date, project id, reservation id, job type, or user email. When a filter is applied, all charts and scorecards on the page will be updated to use those filters. Dashboard owners and editors can define a default date range that is most suitable for their use case.

Below the filters are several scorecards that provide general statistics including total projects used, total reservations used, and total distinct users. These scorecards will also show how the values have changed as a percent increase or decrease relative to the previous period.

![Filter Bar and Scorecards](../images/hourly_utilization/filters_and_scorecards.png)

### Overall utilization
This time series graph displays overall slot utilization per hour for an organization. It also includes a trend line in grey. Spikes in this graph would indicate that certain hours of the day had more slot usage than other hours. Periodic spikes, like the one in this example, may correspond to the execution of a scheduled query at a specific time of day.

![Overall Utilization](../images/hourly_utilization/overall.png)

### By Job Type
This time series graph breaks down the overall slot utilization by job type (QUERY, LOAD, EXTRACT, or COPY).

![By Job Type](../images/hourly_utilization/by_job_type.png)

### By Project Id
This time seres graph breaks down the overall slot utilization by GCP project.

![By Project](../images/hourly_utilization/by_project.png)

### By Reservation Id
This time series graph breaks down the overall slot utilization by reservation. `null` represents usage for jobs that did not run within a specific reservation.

![By Reservation Id](../images/hourly_utilization/by_reservation.png)

### By User
This time series graph breaks down the overall slot utilization by user. This can also include service accounts.

![By User](../images/hourly_utilization/by_user.png)

### By Top Usage
This chart displays the average usage for every hour, sorted by days with the most slot usage.

![By Top Usage](../images/hourly_utilization/by_top_usage.png)

### Hourly Heatmap
This chart displays the average slot hours used broken down by day and hour.
Cell color scales based on slot usage and the largest values are shown in red.

![Hourly Heatmap](../images/hourly_utilization/hourly_heatmap.png)

repository: GoogleCloudPlatform/bigquery-utils

gha_language: Java

repo_name: GoogleCloudPlatform/bigquery-utils


text:
```
_.nth(array, [n=0])
```

Gets the element at index n of array. If n is negative, the nth element from the end is returned.


text:
# Cockpit Native
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fcrunchbutton%2Fcockpit-native.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fcrunchbutton%2Fcockpit-native?ref=badge_shield)

Cockpit Native built using Cordova and a dynamic updater. The app itself contacts the server to check version, and downloads a bundle of updated resources if it is updated. It uses Ionic only for resource generation.

There are Cockpit versions in both iOS and Android stores.

This repository is mostly for educational purposes. Though the complete source of this app works just fine!

---

## Install

```sh
npm install -g cordova ionic
cordova platform add ios
cordova platform add android
ionic resources
```

---

## Release
For iOS, use xcode for your releases. For Android, you can use the **release_android.sh** script. You will need to create an android keystore in the **cert** directory.

```sh
./release_android.sh
```

---

## Notes

Note that newer versions of Cordova require cocoapods installed. There is a pod required for the push plugin which will error out if you do not have cocoapods properly configured.

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fcrunchbutton%2Fcockpit-native.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fcrunchbutton%2Fcockpit-native?ref=badge_large)

repository: fossabot/cockpit-native

repo_name: fossabot/cockpit-native


text:
# ui-driver

The ui-driver is helper that simplifies the connecting of [material-components](http://garth.github.io/material-components) (react form components) to [cerebral](http://www.cerebraljs.com/). It automates signals, validation, i18n and more to simplify and reduce repetative code in React form components.

## Overview

When the user interface is pure and all app state is managed centrally, hooking up all data and events between the user interface components and controller can be a tedious task. Take the example of a pure select component that renders labels and error messages.

```js
<Select
  label="Options"
  value={selectedValue}
  options={options}
  isError={isError}
  message="Please select"
  isOpen={isSelectOpen}
  onOpen={setOpenState}
  onChange={optionSelected}
  onClose={setClosedState}/>
```

Whist not complicated, we need to hookup the selected value, list items and onChange events. But becuase this Select control does a little more we also need to hookup the label, error status and message. Finally, since this is a pure component, we also need to pass the isOpen state and handle the onOpen and onClose events which toggle the isOpen state.

What you also don't see is the work that each event handler must do, which can ammount to 2 or 3 times as much code again. And for some controlls where we need to do validation, such as email inputs or password complixity checks, this can add up to much more.

Imagine now that we have a form with 10 or even 20 of these components. Together with other markup and event handling we have a lot of repetative typing to do. What if instead of manually hooking up the properties and events we could just do the following:

```js
<Select ...bindings.selectProps('options', options)/>
```

This is the ui-driver. All background event handling is built-in as well as field and form level validation.

## Example

Let's take the example of a sign-in form.

```js
// signin component

import React, { Component, PropTypes } from 'react';
import { Decorator as State } from 'cerebral-react';
import { Form, Button, Input, Row, Col } from 'material-components';
import driver from 'ui-driver';
import i18n from 'i18n-lib';

// create an instance of the form driver that is bound to the /signin object
// in the state tree
const formDriver = driver.createForm('signin');

// the form driver will generate the neccessary cerebral properties that it
// needs
@State(Object.assign({
  locale: ['locale']
}, formDriver.props()))
export default class Signin extends Component {
  render() {
    const {
      locale,
      signals
    } = this.props;

    // This is an optional translation library, without this the field labels
    // and error messages can be defined directly on each binding.
    // We use messageformat (https://github.com/SlexAxton/messageformat.js), but
    // any object t that has function properties that return a string should
    // work (eg t.emailLabel() => 'Email')
    const t = i18n(locale, 'signin');

    // create the bindings by passing the current props and optional t to the
    // form driver
    const bindings = formDriver.getBindings(this.props, t);

    // create the form, notice the formDriver.getValidationData() that is
    // passed to the onSubmit signal, this will gather all form data and pass
    // it to the ui-driver actions for validaton purposes
    return (
      <Form
        style={{ marginTop: '30px' }}
        onSubmit={() => signals.signinRequested(formDriver.getValidationData())}
      >
        <Input ...bindings.inputEmailProps('email', { required: true })/>
        <Input ...bindings.inputPasswordProps('password', { required: true })/>
        <Button type="submit">{t.submitButton()}</Button>
      </Form>
    );
  }
}
```

The ui-driver also provides two actions that you can use in your signals to validate submitted forms and to clear the driver data after the form editing has completed.

```js
// signin signal

import controller from './path/to/cerebral/controller';
import ajax from './path/to/actions/ajax';
import showSnackbar from './path/to/actions/showSnackbar';
import stateToOutput from 'cerebral-addons/stateToOutput';
import { validateForm, resetFormDriver } from 'ui-driver/actions';

controller.signal('signinRequested', [
  validateForm, { // validateForm accepts all data passed by the onSubmit signal
                  // and outputs success or error paths
    success: [
      stateToOutput('signin', 'data'),
      [ajax.post('/api/signin'), {
        success: [
          resetFormDriver('signin') // tidy up the temp driver form data
                                    // from the central state tree
        ],
        error: [
          ...showSnackbar('signin')
        ]
      }]
    ],
    error: showSnackbar('signin', 'hasValidationErrors')
  }
]);
```

## Setup

The ui-driver has some internal signals that must be registered with your cerebral controller.

```js
import controller from './path/to/cerebral/controller';
import signals from 'ui-driver/signals';

signals.register(controller);
```

## Supported Bindings

ui-driver currently supports the following bindings:

### Checkbox

Field value must be a bool

```js
checkboxProps('fieldName', {
  label: 'checkbox' // optional unless t is not given
})
```

### Date

Field must be a date

```js
inputDateProps('fieldName', {
  label: 'date',   // optional unless t is not given
  required: true,  // optional
  dateFormat: 'L', // optional, momentjs date format defaults to 'L'
  messages: {      // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  }
})
```

### Email

Field must be a string

```js
inputEmailProps('fieldName', {
  label: 'email',  // optional unless t is not given
  required: true,  // optional
  messages: {      // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  }
})
```

### Equals

Field must be a string, field must === comparisonValue to validate

```js
inputEqualsProps('fieldName', comparisonValue, {
  label: 'Confirm',      // optional unless t is not given
  inputType: 'password', // optional
  messages: {            // optional, taken from t when given, default is shown
    invalid: 'invalid'
  }
})
```

### Input

Field must be a string

```js
inputProps('fieldName', {
  label: 'name',  // optional unless t is not given
  required: true, // optional
  messages: {     // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  },
  signalData: {   // optional, validation params
    maxLength: 10
  }
})
```

### Int

Field must be an int

```js
inputIntProps('fieldName', {
  label: 'age',   // optional unless t is not given
  required: true, // optional
  messages: {     // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  }
})
```

### Menu

Menu consists of two bindings, one for the element that will open the menu (eg button) and one for the menu element itself.

```js
menuOpenProps('menuName', {
  eventType: 'onTouchTap' // optional, defaults to 'onTouchTap'
})
menuProps('menuName')
```

### Password

Field must be a string

```js
inputPasswordProps('fieldName', {
  label: 'password',   // optional unless t is not given
  required: true,      // optional
  checkStrength: true, // optional
  messages: {          // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  }
  signalData: {        // optional, password strength
    minLength = 8,     // config - defaults are shown
    maxLength = 128,
    minPhraseLength = 20,
    minPassingTests = 3,
    tests = [
      /[a-z]/,
      /[A-Z]/,
      /[0-9]/,
      /[^A-Za-z0-9]/
    ]
  }
})
```

### Select

Field can be of any type but the selected value in the options collection must === the field value

```js
options = [
  { value: 1, label: t['oneLabel']() }
];

selectProps('fieldName', options, {
  label: 'options' // optional unless t is not given
})
```

### Time

Field must be an int which represents minutes from start of day

```js
inputTimeProps('fieldName', {
  label: 'time',      // optional unless t is not given
  required: true,     // optional
  timeFormat: 'H:mm', // optional, momentjs time format defaults to 'H:mm'
  messages: {         // optional, taken from t when given, defaults are shown
    invalid: 'invalid',
    required: 'required'
  }
})
```

## Side Effects

Sometimes changing one form field has side effects on other parts of the form. With ui-driver this can be handled by SideEffects.

```js
// register a side affects handler for a specific form and field
import driver from 'ui-driver';

driver.registerSideEffect('formName', 'fieldName', function sideEffectFunction(field, value, state) {
  // field: contains all kinds of data about the field that has been changed
  // value: is the new value of the changing field (the value in the state is updated
  //        after the sideEffect has executed
  // state: is the cerebral state object provided to the syncronouse validateForm action,
  //        use this to apply any side effects to the central state
});
```

## Contribute

Fork repo

* `npm install`
* `npm run dev` runs dev mode which watches for changes and auto lints, tests and builds
* `npm test` runs the tests
* `npm run lint` lints the code
* `npm run build` compiles es6 to es5

repository: tnrich/ui-driver

repo_name: tnrich/ui-driver


text:
# Byssolophis ampla (Berk. & Broome) L. Holm, 1986 SPECIES

#### Status
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Windahlia 16: 50 (1986)

#### Original name
Aulographum amplum Berk. & Broome, 1854

### Remarks
null

repository: mdoering/backbone

path: /life/Fungi/Ascomycota/Dothideomycetes/Pleosporales/Lophiostomataceae/Byssolophis/Byssolophis sphaerioides/ Syn. Byssolophis ampla/README.md

repo_name: mdoering/backbone


text:
---
layout: essay
type: essay
title: Simplifying Intutive Design
date: 2017-10-05
labels:
  - Software Engineering
  - Learning
  - Semantic UI
---

<img class="ui tiny left circular floated image" src="https://react.semantic-ui.com/logo.png">

"Semantic is a development framework that helps create beautiful, responsive layouts using human-friendly HTML."
    - Semantic UI's homepage

I have only had a week's worth of work with Semantic UI, but I cannot imagine programming for the web without it. Having a UI
Framework enables one to make sleek and professional-looking websites in a matter of hours. Whereas without Semantic UI, it will
take me hours to produce a bland website that looks like it was developed in the early-2000s at best.

Semantic makes it easy to create simple-to-complex websites with, as they advertsie, "human-friendly HTML". Making a class with the
name "ui borderless menu" or "ui three column grid container" is easily understood by the developer writing the code as well as
someone reading over the HTML—it's English.

Semantic UI has a plethora of features that make it easy to design every component of a webpage—from the header to the footer.
Semantic makes it easy to manipulate elements of any kind with easy-to-use functions that all for quick and dramatic personalization.
As far as I have seen, if I can imagine it, Semantic UI can do it.

I have no real frame-of-reference. Semantic might be a terrible UI framework. However, as far as I can tell, Semantic is a leading
option of web developers alongside the likes of bootstrap and ionic. Regardless of how they stack up, using a UI framework of this
calibre makes front-end web design amazingly convenient and is practically essential for any serious project


text:
# 2018 Kickoff: Hackathon Event

## Preparation for the Hackathon

### I. Software Installation
#### [Intellij](https://www.jetbrains.com/idea/)
For at least a portion of the hackathon, you will be using [Scala](https://www.scala-lang.org/).  The preferred IDE for Scala is [Intellij](https://www.jetbrains.com/idea/). The community edition should be sufficient as long as you install the Scala plugin.

#### [Visual Studio Code](http://https://code.visualstudio.com) with [Graphviz](./doc/GraphViz.md) extention
We'll use an extension for Visual Studio Code (free) to assist us in our designs.  This extension allows Visual Studio Code to interpret the [DOT language](https://graphviz.gitlab.io/_pages/doc/info/lang.html).  You may find the [dotguide] (http://www.graphviz.org/pdf/dotguide.pdf) is useful to you.
##### Installing Graphviz - follow these instructions provided [here.](./doc/GraphViz.md)

### II. Accounts you need to setup
##### if you dont already have these associated with your @numerix.com email address

#### A. Set up a [Github](http://www.github.com) account
Please create a github account for yourself.  Once you have created that account, please send me a quick note on Slack that shares your github user name with me.
> **Notes on the use of GitHub:**
You may find it odd that I am recommending that you get a GitHub account when, as a company, we use BitBucket.  Not everyone participating in the event will have a BitBucket account (nor will they need one).  We are charged for BitBucket licenses.  So, in order to introduce everyone to Git (and do so without cost), I am using GitHub to provide you with the materials to prep you for the event AND introduce you to the numerous projects on GitHub (in case you havent experienced it.)

> **TO BE CLEAR, WE WILL NOT USE GITHUB FOR THE ARTIFACTS/DELIVERABLES/CODE that is produced at the event.  For that, the devs on each team will use their BitBucket accounts.  GitHub is only needed for preparation for the event.**

##### i.  Make sure that you secure Github, by [setting up an ssh key](/doc/setting-up-ssh-windows.md)
You should probably set up an ssh key rather than using HTTPS authentication.  The above link provides the steps you'll need to follow if you don't already know how to do this.

#### B.  Get a [Slack](https://www.slack.com) account
We will use a specially created slack workspace called [nx-hackathon.slack.com](https://nx-hackathon.slack.com) for this event.

### III.  Fork our private github repository (or our bitbucket repo, if you are already a bitbucket user) and clone your fork

#### Step One:

### IV. Materials to Prepare you for the hackathon
#### A. Read the [case study](pre-read-case-study.md)
#### B.  Try the [Exercises](/exercises/overview.md)
#### C. Look at the [forks](https://github.com/evolution-labs) in the evolution-labs github account
>##### [Online Auction (Scala)](https://github.com/evolution-labs/online-auction-scala)
>Reference Application using Lagom, Kafka and Cassandra, written in **Scala**.

>##### [Online Auction (Java)](https://github.com/evolution-labs/online-auction-java)
>Reference Application using Lagom, Kafka and Cassandra, written in **JAVA**

>##### [pykafka](https://github.com/evolution-labs/pykafka)
>Apache Kafka client for Python with examples. [Documentation here.](http://pykafka.readthedocs.io/en/latest/)

>##### [Apache Kafka .NET Client](https://github.com/evolution-labs/confluent-kafka-dotnet)
>Confluent's Apache Kafka .NET client [Docs here.](https://docs.confluent.io/current/clients/confluent-kafka-dotnet/api/Confluent.Kafka.html)

>##### [ExcelDna](https://github.com/evolution-labs/ExcelDna)
>Could be useful if you want to wire excel up to a Kafka topic.

>##### [Akka Samples](https://github.com/evolution-labs/akka-samples)
>Sample Akka Projects from Lightbend

### D. Explore the [Resources](/doc/resource-index.md) that we curated for you


text:
---
title: Querying Trace Data
keywords: data, distributed tracing
tags: [tracing]
sidebar: doc_sidebar
permalink: trace_data_query.html
summary: Learn how to query for Wavefront trace data.
---

After your application sends [trace data](tracing_basics.html#wavefront-trace-data) to Wavefront, you can examine that data in the Traces browser. By fine-tuning the trace query in the Traces browser, you find the traces that you're interested in by describing the spans they must contain.

1. Select **Applications > Traces** in the task bar to display the Traces browser.
2. [Select an operation](#select-an-operation) to specify the scans to be matched.
![tracing query builder](images/tracing_query_builder.png)
3. Optionally [add one or more filters](#add-filters) to refine your query.
![tracing query builder](images/tracing_query_builder_filter.png)
4. Click **Search** in the query bar to update the list of traces.

**Note:** As an alternative, you can use [Query Editor](#use-query-editor-power-users) to submit advanced trace queries explicitly.

## Select an Operation

You select an operation to display traces with at least one span that represents the work done by that operation.

1. Display the Traces browser.
2. Click the **Operation** selector to open the cascading menu.
    ![tracing query builder operation selector](images/tracing_query_builder_operation_selector.png)

3. Select name components for an application, service, and operation.
    ![tracing query builder operation menu](images/tracing_query_builder_operation_menu.png)

4. Either [add filters](#add-filters) or click **Search**.

**Note:** You can select `*` instead of name components to select all operations in a service, or all operations in all services:
    ![tracing query builder operation menu](images/tracing_query_builder_operation_menu_all.png)

**Note:** The names in the cascading menus correspond to tag values and span names that a developer specified while instrumenting the application code.

## Add Filters

After you have selected an operation, you can optionally add filters to further describe the traces you want to see. You can add different types of filters in any order.

1. Select an operation if you have not already done so.
2. Click **Add Filter** and select a filter type.
![tracing query builder filter type menu](images/tracing_query_builder_filter_type_menu.png)

4. Click next to the filter type and specify the filter setting. Depending on the filter type:
  * Select settings from menus.
  * Type one or more settings in fields.

5. Click **Add Filter** to add another filter, or click **Search**.

<colgroup>
<col width="25%"/>
<col width="75%"/>
</colgroup>

Choose This Filter Type	To Return

**Tags**
Traces with at least one span that is associated with a selected tag, or that was emitted from a selected source (host).
Use this type for indexed tags that your application uses, typically `cluster`, `shard`, `component`, `source`, and so on.

**RawTags**
Traces with at least one span that is associated with a specified tag, for example, `env="prod"`. Use this type for custom or unindexed span tags.

**Duration**
Traces that have a specified minimum and/or maximum length (in milliseconds).

**Limit**
Up to a specified number of traces.

**Error**
Traces with at least one span with an error (`error=true`).

## Understand Trace Query Results

A trace query:
1. Finds the spans that match the description you specify.
2. Finds the traces that contain at least one qualifying span.
3. Uses duration thresholds (if you specified any) to filter the set of returned traces.

For example, you can query for traces that each have at least one member span that meets all of the following criteria:
* Represents an operation called `dispatch` that is performed by a service called `delivery`.
* Represents work done on a cluster called `us-west-2`.
* Is associated with a custom tag `env=production`.

If you also specified a minimum (or maximum) duration, the query filters out any traces that are shorter (longer) than the threshold you specified.

## Limited Result Set

Using the **Limit** filter to limit the number of returned traces can make your query complete faster. The trace query starts by returning the most recent traces.  After reaching the limit, the query stops looking for more traces.

**Note:** The current time window for the Traces browser also implicitly limits by the result set. Traces are returned only if they contain a matching span _and_ start within the current time window.

## Sort the Result Set

You can sort a set of returned traces by selecting a sort order from the **Sort By** menu. For example:
* Choose **Most Recent** to start with the traces that have the most recent start times.
* Choose **Longest First** to start with the longest traces.
* Choose **Outliers** to start with the traces whose duration is unusually long or unusually short.
* Choose **Most Spans** to start with the traces that contain the largest number of spans.

If you both limit and sort the query results, sorting applies after limiting. For example, suppose you limit the number of returned traces to 50, and then sort the result set from shortest to longest. The sorted list includes only the 50 traces that were originally returned by the query. We do not first sort all traces containing a matching span, and then display the 50 shortest traces.

**Note:** If you've enabled a sampling strategy, results are found among the spans that have actually been ingested. The query does not search through spans before they’ve been sampled.

## Use Query Editor (Power Users)

1. Select **Applications > Traces** in the task bar to display the Traces browser.
2. Click the icon to toggle to Query Editor:
    ![tracing query toggle](images/tracing_query_toggle.png)
3. Type a query that includes the [`traces()` function](ts_traces.html):
![tracing query editor](images/tracing_query_editor_populated.png)
4. Click **Search** in the query bar to update the list of traces.

repository: subhajitpalit/docs

repo_name: subhajitpalit/docs


text:
0.3.1 / 2015-01-23
==================

 * Fixed a bug where left-hand 'object' attribute were overwritten by empty values from right-hand objects

0.3.0 / 2015-01-23
==================

 * Made empty discarding optional and updated `README.md` with usage documentation
 * Prevent attributes with `{ }`, `undefined`, `null` or `0` as values to be lost in the merge

0.2.0 / 2014-09-09
==================

  * Update README.md with usage examples for new opts
  * Update to allow Boolean param to provide compatibility with in 0.1.0
  * Add opts parameter and shallow merge option

0.1.0 / 2014-01-30
==================

 * Pin dependencies
 * Merge pull request #2 from gvilarino/allow-inheritance
 * Added support for allowing inheritance merging
 * Update README
 * Add README.md

0.0.1 / 2013-10-12
==================

 * First commit

repository: cristiandouce/merge-util

gha_language: JavaScript

repo_name: cristiandouce/merge-util


text:
BernardBundle
=============

Integrates Bernard neatly with a Symfony application.

[![Build Status](https://travis-ci.org/bernardphp/BernardBundle.png?branch=master)](https://travis-ci.org/bernardphp/BernardBundle)

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

Everything starts by installing the bundle. This is done through composer by adding the following lines
to your `composer.json` file and running `composer update bernard/bernard-bundle`.

``` json
{
    "require" : {
        "bernard/bernard-bundle" : "~1.0"
    }
}
```

Next up is adding the bundle to your kernel and configuring it in `config.yml`.

``` php
// app/AppKernel.php
// .. previous class definition
public function registerBundles()
{
    // .. all the other bundles you have registered.
    $bundles[] = new Bernard\BernardBundle\BernardBernardBundle();
    // .. the rest of the method
}
```

``` yml
# .. previous content of app/config/config.yml
bernard_bernard:
    driver: file # you can choose redis, predis, pheanstalk, file, doctrine etc.
    serializer: simple # this is the default and it is optional. Other values are symfony or jms
```

Great! You are now ready to use this diddy. Go and read the rest of the documentation on Bernard at bernardphp.com.

### Running the Consumer

What good is a message queue if you don't know how to run the consumer? Luckily this bundle auto registeres the commands
with you application. So if you run `php app/console` you should see `bernar:consume` and `bernard:produce`. Theese
works just as the documentation descripes but if you are in doubt just add `--help` when trying to run the command.

Todo
----

Currently this Bundle implements what i needed. This means there is proberly something that is missing.

 * Missing test for `BernardExtension` and `MiddlewarePass`.
 * Missing some drivers


text:
[Bubble sort][1], also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, it is not efficient for sorting large lists; other algorithms are better.

The only significant advantage that bubble sort has over most other implementations, even quicksort, but not insertion sort, is that the ability to detect that the list is sorted is efficiently built into the algorithm. Performance of bubble sort over an already-sorted list (best-case) is O(n).

Pseudocode implementation

The algorithm can be expressed as:

procedure bubbleSort( A : list of sortable items )
  repeat
    swapped = false
    for i = 1 to length(A) - 1 inclusive do:
      if A[i-1] > A[i] then
        swap( A[i-1], A[i] )
        swapped = true
      end if
    end for
  until not swapped
end procedure

The bubble sort algorithm can be easily optimized by observing that the n-th pass finds the n-th largest element and puts it into its final place. So, the inner loop can avoid looking at the last n-1 items when running for the n-th time:

procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat
      swapped = false
      for i = 1 to n-1 inclusive do
         if A[i-1] > A[i] then
            swap(A[i-1], A[i])
            swapped = true
         end if
      end for
      n = n - 1
   until not swapped
end procedure

More generally, it can happen that more than one element is placed in their final position on a single pass. In particular, after every pass, all elements after the last swap are sorted, and do not need to be checked again. This allows us to skip over a lot of the elements, resulting in about a worst case 50% improvement in comparison count (though no improvement in swap counts)

procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat
      newn = 0
      for i = 1 to n-1 inclusive do
         if A[i-1] > A[i] then
            swap(A[i-1], A[i])
            newn = i
         end if
      end for
      n = newn
   until n = 0
end procedure

Step-by-step example

Let us take the array of numbers "5 1 4 2 8", and sort the array from lowest number to greatest number using bubble sort algorithm. In each step, elements written in bold are being compared. Three passes will be required.

First Pass:
( 5 1 4 2 8 ) \to ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps them.
( 1 5 4 2 8 ) \to ( 1 4 5 2 8 ), Swap since 5 > 4
( 1 4 5 2 8 ) \to ( 1 4 2 5 8 ), Swap since 5 > 2
( 1 4 2 5 8 ) \to ( 1 4 2 5 8 ), Now, since these elements are already in order (8 > 5), algorithm does not swap them.
Second Pass:
( 1 4 2 5 8 ) \to ( 1 4 2 5 8 )
( 1 4 2 5 8 ) \to ( 1 2 4 5 8 ), Swap since 4 > 2
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )
Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.
Third Pass:
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )
( 1 2 4 5 8 ) \to ( 1 2 4 5 8 )

Algorithmic Efficiency

Although bubble sort is one of the simplest sorting algorithms to understand and implement, its O(n2) complexity means it is far too inefficient for use on lists having more than a few elements. Even among simple O(n2) sorting algorithms, algorithms like insertion sort are usually considerably more efficient.

Bubble sort is asymptotically equivalent in running time to insertion sort in the worst case, but the two algorithms differ greatly in the number of swaps necessary. Experimental results such as those of Astrachan have also shown that insertion sort performs considerably better even on random lists. For these reasons many modern algorithm textbooks avoid using the bubble sort algorithm in favor of insertion sort.

[1]:http://en.wikipedia.org/wiki/Bubble_sort, "Bubble Sort"

repository: christofur/workbench

repo_name: christofur/workbench


text:
# Advanced topics
Advanced topics sounds better then misc.

## Wireing responses from ƒ-xxx
When you wire a ƒ-methodname, a non bubbling event *ƒ-methodname* with the response value in event.detail will be fired.
Use the response by adding a `@-ƒ-methodname`.

There is no difference to another fired event. You can fire another event, which eventually bubbles, park the response to a property, wire it,...

You can receive and rewire the response from a methodname with **@-ƒ-methodnamename="--wire""**.
```html

   <furo-button @-click="--calcNumber(_number)"> calculate sqrt </furo-button>
   <!-- root calculator -->
   <square-root ƒ-calculate="--calcNumber" @-ƒ-calculate="--calculatedSqrRoot"></square-root>

   <display-result ƒ-show="--calculatedSqrRoot"></display-result>
```

## Spread arguments
//Todo @veith write documentation asap.

<furo-horizontal-flex>
Parking Data
<furo-empty-spacer></furo-empty-spacer>
Scripting
</furo-horizontal-flex>

repository: theNorstroem/FuroBaseComponents

repo_name: theNorstroem/FuroBaseComponents


text:
TracingDoc
==========

A one stop shop to get into tracing

What is tracing?
================

Tracing is the action of writing the flow of a program during normal and abnormal behavior. It is used to troubleshoot problems without affecting teh flow of the program.

Tracing differs from logging in that the data is generally not human readible but is able to be written quickly. Also, every event should have a timestamp allowing overlap with profiling.

Why Trace?
==========

Tracing is useful to debug problems in production machines. It also allows peolpe to figure out why their program may be running slower than expected. It will give the full view of a system.

Because of this , the three main reasons to trace are:

* understanding: to get a better idea of what's going on under the hood
* performance profiling: to figure out why your system is consuming the resources it is. (CPU/RAM/IO/NET...)
* non-disruptive testing: (minimally disruptive) testing protocols or real-time systems where a late answer is a bad answer

How to Trace?
=============

Using Printf?

Using LTTng?

How To View Traces?
===================

Picking the tool

Using Babeltrace?

Using Battrace

Using Eclipse/LTTng

Using LTTv

Digging deeper
==============

Now that you've opeened and viewed a trace, here's some more analysis that can be done.

Babeltrace

Battrace

Eclipse/LTTng

LTTv

References
==========

http://multivax.blogspot.ca/

http://dtrace.org/blogs/brendan/2013/08/16/memory-leak-growth-flame-graphs/

repository: TheMatthew/TracingDoc

repo_name: TheMatthew/TracingDoc


text:
# Wordpress

The official [wordpress](https://hub.docker.com/_/wordpress/) and [mysql](https://hub.docker.com/_/mysql/) image combined for a [sloppy.io](https://sloppy.io) project. You can extend the json/yml with more variables from the official images.

## Start it

```
sloppy start -var=USERNAME:username -var=URI:mydomain.sloppy.zone -var=DBUSER:db-user-for-wordpress -var=DBPASS:db-password-for-wordpress -var=DBROOT:db-root-password wordpress.json

Example:

sloppy start -var=URI:mywordpress.sloppy.zone -var=DBUSER:wpadmin -var=DBPASS:secret -var=DBROOT:moresecret wordpress.json
```

repository: sloppyio/quickstarters

gha_language: Dockerfile

repo_name: sloppyio/quickstarters


text:
# Fluent-bit Daemonset for Kubernetes Logging

[![Build Status](https://jenkins.migrations.cnct.io/buildStatus/icon?job=pipeline-fluent-bit/master)](https://jenkins.migrations.cnct.io/job/pipeline-fluent-bit/job/master)

[Fluent-bit](http://fluentbit.io/) daemonset dependencies for Kubernetes
logging.  It uses this [helm chart](https://github.com/samsung-cnct/chart-fluent-bit/tree/master/charts/fluent-bit) and this [docker image](https://github.com/samsung-cnct/chart-fluent-bit/blob/master/rootfs/fluent-bit/Dockerfile).

Currently this daemonset reads [Docker logs](https://docs.docker.com/engine/admin/logging/overview/) from `/var/log/containers` and [journald logs](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) from `/var/log/journal` and `/run/log/journal`. It adds Kubernetes metadata to the logs and writes them to stdout.
It is included in our [logging](https://github.com/samsung-cnct/chart-logging) pipeline.

## How to install on running Kubernetes cluster with `helm`
Ensure that you have helm and [tiller](https://docs.helm.sh/using_helm/) installed.
### From our chart repository
```
helm repo add cnct https://charts.migrations.cnct.io
helm repo update
helm install cnct/fluent-bit
```
### To install from local repository from `/chart-fluent-bit/charts`

```
helm install --name my-release --namespace my-namespace ./fluent-bit

e.g.

helm install cnct/chart-fluent-bit. --name=fb-test --namespace=logging --set elasticSearchPassword="mlnpass",cluster_uuid=22222222-3333-0000-0000-000000000000,elasticSearchHost=es.newcluster.cluster.cnct.io
```

## Plugins

#### Systemd Input Plugin

This input plugin reads from /var/log/journal, which contains kernel, dockerd, and rkt logs, among others. It is new as of v0.12.
More informaton on this plugin can be found at:
http://fluentbit.io/documentation/0.14/input/systemd.html

#### Tail Input Plugin

This input plugin monitors text files as matched by a specified Path; in this case, `/var/log/containers/*.log`, excluding `/var/log/containers/fluent*.log`. More information on this plugin can be found at: http://fluentbit.io/documentation/0.14/input/tail.html

#### Kubernetes Metadata Filter

This filter adds the following data into the body of the log.
* namespace
* pod id
* pod name
* labels
* host
* container name
* docker container id

For more information on the filter or to see a list of configuration options: http://fluentbit.io/documentation/0.14/filter/kubernetes.html

repository: nowjean/chart-fluent-bit

repo_name: nowjean/chart-fluent-bit


text:
# Upgrade

## 1.7.x

  - __[Data Loader]__ The `FileSystemLoader` data loader performs a more robust security check against image resource
    paths to ensure they reside within the defined data root path(s). If utilizing symbolic links, you should reference
    the troubleshooting guide at the end of this upgrade notice.

  - __[Data Loader]__ The `FileSystemLoader` data loader now accepts an array of paths (as strings) for its third
    constructor argument, enabling the loader to check multiple paths for the requested image resource.
    *Note: this change breaks those extending this class and relying on the protected property `$dataRoot`, which has
    been renamed to `$dataRoots` and is now of the type `string[]` instead of the prior type of `string`.*

  - __[Configuration]__ The `liip_imagine.loaders.default.filesystem.data_root` bundle configuration option now accepts
    an array of paths (as strings) or a single scalar path ()if only one is required for your configuration), allowing
    the `filesystem` data loader to check multiple data root paths for the requested image resource. The following YML
    configuration shows examples for all allowed value types.

    ```yml

      # provide an array of scalar paths
      liip_imagine:
        loaders:
          default:
            filesystem:
              data_root:
                - /multiple/root/paths/foo
                - /multiple/root/paths/bar

      # provide an single scalar path
      liip_imagine:
        loaders:
          default:
            filesystem:
              data_root: /single/root/path

    ```

  - __[Troubleshooting]__ If you are using the `filesystem` data loader and have *symbolic links* within the `data_root`
    that point outside this path (the `data_root` option defaults to `%kernel.root_dir%/../web`) then you are *required*
    to configure all outside resource paths as additional `data_root` paths using the following option key in your
    application's configuration: `liip_imagine.loaders.default.filesystem.data_root`.

    The following is a list of the most common exception error messages encountered when the `data_root` option is not
    correctly configured:

    - > Source image not resolvable "%s" in root path(s) "%s"
    - > Source image invalid "%s" as it is outside of the defined root path(s) "%s"

## 1.0.0-alpha7

  - __[Configuration]__ `liip_imagine.controller_action` option was removed in favour of an array of actions. See
    `liip_imagine.controller` config

      ```diff

        -liip_imagine:
        -    controller_action: AcmeDemoBundle:Default:filterAction
        +liip_imagine:
        +    controller:
        +       filter_action: AcmeDemoBundle:Default:filterAction

      ```

## 1.0.0-alpha6

  - __[Route]__ `ImagineLoader` was removed. Please adjust your `app/config/routing.yml` file.

      ```diff

        -_imagine:
        -    resource: .
        -    type:     imagine
        +_liip_imagine:
        +    resource<EMAIL_ADDRESS>
      ```

  - __[Configuration]__ `liip_imagine.filter_sets.route` option and sub options were removed.

  - __[Configuration]__ `liip_imagine.cache_prefix` option was removed.

## 1.0.0-alpha5

  - __[Symfony]__ Required minimum symfony version was updated to 2.3.

  - __[Logger]__ Symfony `LoggerInterface` was replaced with PSR-3 one.

  - __[Cache]__ New `isStored` method was added.

  - __[Cache]__ The method `ResolverInterface::getBrowserPath` was removed.

  - __[Cache]__ The method `ResolverInterface::store` accept `BinaryInterface` as first argument.

  - __[Cache]__ The method `ResolverInterface::store` return nothing.

  - __[Cache]__ The method `ResolverInterface::remove` return nothing.

  - __[Cache]__ The method `ResolverInterface::remove` takes required array of filter as first argument.

  - __[Cache]__ The method `ResolverInterface::remove` takes optional path as second argument.

  - __[Cache]__ The method `ResolverInterface::clean` was removed.

  - __[Cache]__ The method `ResolverInterface::resolve` takes path and filter as arguments.

  - __[Cache]__ The method `ResolverInterface::resolve` return absolute url of the cached image.

  - __[Cache]__ The method `CacheManager::resolve` may throw OutOfBoundsException if required resolver does not exist.

  - __[Cache]__ The method `CacheManager::resolve` return absolute url of the cached image.

  - __[Cache]__ The method `CacheManager::store` accept `BinaryInterface` as first argument.

  - __[Cache]__ The method `CacheManager::store` return nothing.

  - __[Cache]__ The method `CacheManager::clearResolversCache` was removed.

  - __[Cache]__ The method `CacheManager::getWebRoot` was removed.

  - __[Cache]__ The method `CacheManager::getBrowserPath` third argument was changed, now it is `runtimeConfig`.

  - __[Cache]__ The method `CacheManager::generateUrl` third argument was changed, now it is `runtimeConfig`.

  - __[Cache]__ `NoCacheResolver` renamed to `NoCacheWebPathResolver`.

  - __[Cache]__ `AbstractFilesystemResolver` was removed.

  - __[Data Loader]__ `LoaderInterface::find` now can return string or `BinaryInterface` instance.

  - __[Data Loader]__ `DataManager::find` now can return `BinaryInterface` instance only.

  - __[Data Loader]__ All data loaders moved to `Binary/Loader` folder.

  - __[Data Loader]__ Tag name `liip_imagine.data.loader` changed to `liip_imagine.binary.loader`

  - __[Data Loader]__ Parameter key `liip_imagine.data.loader.filesystem.class` changed to
    `liip_imagine.binary.loader.filesystem.class`

  - __[Data Loader]__ Parameter key `liip_imagine.data.loader.stream.class` changed to
    `liip_imagine.binary.loader.stream.class`

  - __[Data Loader]__ Service id `liip_imagine.data.loader.prototype.filesystem` changed to
    `liip_imagine.binary.loader.prototype.filesystem`

  - __[Data Loader]__ Service id `liip_imagine.data.loader.prototype.stream` changed to
    `liip_imagine.binary.loader.prototype.stream`

  - __[Filter]__ `FilterManager::applyFilter` now return instance of `BinaryInterface`.

  - __[Filter]__ `FilterManager::applyFilter` first argument was changed from Image instance to BinaryInterface one.

  - __[Filter]__ `FilterManager::get` was removed.

  - __[Configuration]__ `liip_imagine.filter_sets.path` option was removed.

  - __[Configuration]__ `liip_imagine.filter_sets.format` option was removed.

  - __[Configuration]__ `liip_imagine.cache_mkdir_mode` option was removed.

  - __[Configuration]__ `liip_imagine.web_root` option was removed.

  - __[Configuration]__ `liip_imagine.cache` default value was changed from `web_path`to `default`.

  - __[Configuration]__ `liip_imagine.formats` option was removed.

  - __[Configuration]__ `liip_imagine.data_root` option was removed.