text:
Jenkins, Travis, or other services provide.

Alternatively to reading the deploy key from root (the default location), you may set the `ZAPIER_DEPLOY_KEY` environment variable to run privileged commands without the human input needed for `zapier login`. We suggest encrypting your deploy key in the manner your CI provides (such as [these instructions](https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml), for Travis).

### Debugging Tests

Sometimes tests aren't enough, and you may want to step through your code and set breakpoints. The testing suite is a regular Node.js process, so debugging it doesn't take anything special. Because we recommend `jest` for testing, these instructions will outline steps for debugging w/ jest, but other test runners will work similarly. You can also refer to [Jest's own docs on the subject](https://jestjs.io/docs/en/troubleshooting#tests-are-failing-and-you-dont-know-why).

To start, add the following line to the `scripts` section of your `package.json`:

```
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand"
```

This will tell `node` to inspect the `jest` processes, which is exactly what we need.

Next, add a `debugger;` statement somewhere in your code, probably in a `perform` method:

```js
// triggers on a new pizza with a certain tag
const perform = async (z, bundle) => {
  const response = await z.request({
    url: "https://jsonplaceholder.typicode.com/posts",
    params: {
      tag: bundle.inputData.tagName,
    },
  });
  debugger;
  // this should return an array of objects
  return response.data;
};
```

This creates a _breakpoint_ while `inspect`ing, or a starting point for our manual inspection.

Next, you'll need an inspection client. The most available one is probably the Google Chrome browser, but there are [lots of options](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients). We'll use Chrome for this example. In your terminal (and in your integration's root directory), run `yarn test:debug` (or `npm run test:debug`). You should see the following:

```
% yarn test:debug
yarn run v1.22.10
$ node --inspect-brk node_modules/.bin/jest --runInBand
Debugger listening on ws://<IP_ADDRESS>:9229/5edaab3c-a1d3-45e4-b374-0536095c559b
For help, see: https://nodejs.org/en/docs/inspector
```

Now in Chrome, go to chrome://inspect. Make sure `Discover Network Targets` is checked and you should see a path to your `jest` file on your local machine:

![](https://cdn.zappy.app/e2836d2950e1f8a03e3621a22452c3cd.png)

Click `inspect`. A new window will open. Next, click the little blue arrow in the top right to actually run the code:

![](https://cdn.zappy.app/a64e7963a7090e9730d9c8e7b3595a6a.png)

After a few seconds, you'll see your code, the `debugger` statement, and info about the current environment on the right panel. You should see familiar data in the `Locals` section, such as the `response` variable, and the `z` object.

![](https://cdn.zappy.app/4bfdfe079a344ab7aced64ad7728bc6a.png)

Debugging combined with thorough unit tests will hopefully equip you in keeping your Zapier integration in smooth working order.

## Using `npm` Modules

Use `npm` modules just like you would use them in any other node app, for example:

```bash
npm install --save jwt
```

And then `package.json` will be updated, and you can use them like anything else:

```js
const jwt = require('jwt');
```

During the `zapier build` or `zapier push` step - we'll copy all your code to a temporary folder and do a fresh re-install of modules.

> Note: If your package isn't being pushed correctly (IE: you get "Error: Cannot find module 'whatever'" in production), try adding the `--disable-dependency-detection` flag to `zapier push`.

> Note 2: You can also try adding a `includeInBuild` array property (with paths to include, which will be evaluated to RegExp, with a case insensitive flag) to your `.zapierapprc` file, to make it look like:

```json
{
  "id": 1,
  "key": "App1",
  "includeInBuild": [
    "test.txt",
    "testing.json"
  ]
}

```

> Warning: Do not use compiled libraries unless you run your build on the AWS AMI `ami-4fffc834`, or follow the Docker instructions below.

## Building Native Packages with Docker

Unfortunately if you are developing on a macOS or Windows box you won't be able to build native libraries locally. If you try and push locally build native modules, you'll get runtime errors during usage. However, you can use Docker and Docker Compose to do this in a pinch. Make sure you have all the necessary Docker programs installed and follow along.

First, create your `Dockerfile`:

```Dockerfile
FROM amazonlinux:2<IP_ADDRESS>70812

RUN yum install zip findutils wget gcc44 gcc-c++ libgcc44 cmake -y

RUN wget https://nodejs.org/dist/v8.10.0/node-v8.10.0.tar.gz && \
    tar -zxvf node-v8.10.0.tar.gz && \
    cd node-v8.10.0 && \
    ./configure && \
    make && \
    make install && \
    cd .. && \
    rm -rf node-v8.10.0 node-v8.10.0.tar.gz

RUN npm i -g zapier-platform-cli

WORKDIR /app
```

And finally, create your `docker-compose.yml` file:

```yml
version: '3.4'

services:
  pusher:
    build: .
    volumes:
      - .:/app
      - node_modules:/app/node_modules:delegated
      - ~/.zapierrc:/root/.zapierrc
    command: 'bash -c "npm i && zapier push"'
    environment:
      ZAPIER_DEPLOY_KEY: ${ZAPIER_DEPLOY_KEY}

volumes:
  node_modules:
```

> Note: Watch out for your `package-lock.json` file, if it exists for local install it might incorrectly pin a native version.

Now you should be able to run `docker-compose run pusher` and see the build and push successfully complete!

## Using Transpilers

If you would like to use a transpiler like `babel`, you can add a script named `_zapier-build` to your `package.json`, which will be run during `zapier build`,
`zapier push`, and `zapier upload`.  See the following example:

```json
{
  "scripts": {
    "zapier-dev": "babel src --out-dir lib --watch",
    "_zapier-build": "babel src --out-dir lib"
  }
}
```

Then, you can have your fancy ES7 code in `src/*` and a root `index.js` like this:

```js
module.exports = require('./lib');
```

And work with commands like this:

```bash
# watch and recompile
npm run zapier-dev

# tests should work fine
zapier test

# every build ensures a fresh build
zapier push
```

There are a lot of details left out - check out the full example app [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/babel).

> We recommend using `zapier init .`  to create an app - you’ll be presented with a list of currently available example templates to start with.

## FAQs

### Why doesn't Zapier support newer versions of Node.js?

We run your code on AWS Lambda, which only supports a few [versions](https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html) of Node. Sometimes that doesn't include the latest version. Additionally, with thousands of apps running on the Zapier platform, we have to be sure upgrading to the latest Node version will not have a negative impact.

### How do I manually set the Node.js version to run my app with?

Update your `zapier-platform-core` dependency in `package.json`.  Each major version ties to a specific version of Node.js. You can find the mapping [here](https://github.com/zapier/zapier-platform/blob/main/packages/cli/src/version-store.js). We only support the version(s) supported by [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html).

**IMPORTANT CAVEAT**: AWS periodically deprecates Node versions as they reach EOL. They announce this[on their blog](https://aws.amazon.com/blogs/developer/node-js-6-is-approaching-end-of-life-upgrade-your-aws-lambda-functions-to-the-node-js-10-lts/). Similar info and dates are available on [github](https://github.com/nodejs/Release). Well before this date, we'll have a version of `core` that targets the newer Node version.

If you don't upgrade before the cutoff date, there's a chance that AWS will throw an error when attempting to run your app's code. If that's the case, we'll instead run it under the oldest Node version still supported. All that is to say, **we may run your code on a newer version of Node.js than you intend** if you don't update your app's dependencies periodically.

### When to use placeholders or curlies?

You will see both [template literal placeholders](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Expression_interpolation) `${var}` and (double) "curlies" `{{var}}` used in examples.

In general, use `${var}` within functions and use `{{var}}` anywhere else.

Placeholders get evaluated as soon as the line of code is evaluated. This means that if you use `${process.env.VAR}` in a trigger configuration, `zapier push` will substitute it with your local environment's value for `VAR` when it builds your app and the value set via `zapier env:set` will not be used.

> If you're not familiar with [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), know that `const val = "a" + b + "c"` is essentially the same as const val = `a${b}c`.

### Does Zapier support XML (SOAP) APIs?

Not natively, but it can! Users have reported that the following `npm` modules are compatible with the CLI Platform:

* [pixl-xml](https://github.com/jhuckaby/pixl-xml)
* [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js)
* [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser)

Since core v10, it's possible for [shorthand requests](#shorthand-http-requests) to parse XML. Use an `afterResponse` [middleware](#using-http-middleware) that sets `response.data` to the parsed XML:

```js
const xml = require('pixl-xml');

const App = {
  // ...
  afterResponse: [
    (response, z, bundle) => {
      // Only works on core v10+!
      response.throwForStatus();
      response.data = xml.parse(response.content);
      return response;
    },
  ],
  // ...
};

```

### Is it possible to iterate over pages in a polling trigger?

Yes, though there are caveats. Your entire function only gets 30 seconds to run. HTTP requests are costly, so paging through a list may time out (which you should avoid at all costs).

```js
// some async call
const makeCall = (z, start, limit) => {
  return z.request({
    url: 'https://jsonplaceholder.typicode.com/posts',
    params: {
      _start: start,
      _limit: limit,
    },
  });
};

// triggers on paging with a certain tag
const performPaging = async (z, bundle) => {
  // array of promises
  const promises = [];

  // 5 requests with page size = 3
  let start = 0;
  const limit = 3;
  for (let i = 0; i < 5; i++) {
    promises.push(makeCall(z, start, limit));
    start += limit;
  }

  // send requests concurrently
  const responses = await Promise.all(promises);
  return responses.map((res) => res.data);
};

module.exports = {
  key: 'paging',
  noun: 'Paging',

  display: {
    label: 'Get Paging',
    description: 'Triggers on a new paging.',
  },

  operation: {
    inputFields: [],
    perform: performPaging,
  },
};

```

If you need to do more requests conditionally based on the results of an HTTP call (such as the "next URL" param or similar value), using `async/await` (as shown in the example below) is a good way to go. If you go this route, only page as far as you need to. Keep an eye on the polling [guidelines](https://zapier.com/developer/documentation/v2/deduplication/), namely the part about only iterating until you hit items that have probably been seen in a previous poll.

```js
// a hypothetical API where payloads are big so we want to heavily limit how much comes back
// we want to only return items created in the last hour

const asyncExample = async (z, bundle) => {
  const limit = 3;
  let start = 0;
  const twoHourMilliseconds = 60 * 60 * 2 * 1000;
  const hoursAgo = new Date() - twoHourMilliseconds;

  let response = await z.request({
    url: 'https://jsonplaceholder.typicode.com/posts',
    params: {
      _start: start,
      _limit: limit,
    },
  });

  let results = response.data; // response.json if you're using core v9 or older

  // keep paging until the last item was created over two hours ago
  // then we know we almost certainly haven't missed anything and can let
  //   deduper handle the rest

  while (new Date(results[results.length - 1].createdAt) > hoursAgo) {
    start += limit; // next page

    response = await z.request({
      url: 'https://jsonplaceholder.typicode.com/posts',
      params: {
        _start: start,
        _limit: limit,
      },
    });

    results = results.concat(response.data);
  }

  return results;
};

```

### How do search-powered fields relate to dynamic dropdowns and why are they both required together?

To understand search-powered fields, we have to have a good understanding of dynamic dropdowns.

When users are selecting specific resources (for instance, a Google Sheet), it's important they're able to select the exact sheet they want. Instead of referencing the sheet by name (which may change), we match via `id` instead. Rather than directing the user copy and paste an id for every item they might encounter, there is the notion of a **dynamic dropdown**. A dropdown is a trigger that returns a list of resources. It can pull double duty and use its results to power another trigger, search, or action in the same app.  It provides a list of ids with labels that show the item's name:

![](https://cdn.zappy.app/2d7eeda63ff34b70f1d1788de0117181.png)

The field's value reaches your app as an id. You define this connection with the `dynamic` property, which is a string: `trigger_key.id_key.label_key`. This approach works great if the user setting up the Zap always wants the Zap to use the same spreadsheet. They specify the id during setup and the Zap runs happily.

**Search fields** take this connection a step further. Rather than set the spreadsheet id at setup, the user could precede the action with a search field to make the id dynamic. For instance, let's say you have a different spreadsheet for every day of the week. You could build the following zap:

1. Some Trigger
2. Calculate what day of the week it is today (Code)
3. Find the spreadsheet that matches the day from Step 2
4. Update the spreadsheet (with the id from step 3) with some data

If the connection between steps 3 and 4 is a common one, you can indicate that in your field by specifying `search` as a `search_key.id_key`. When paired **with a dynamic dropdown**, this will add a button to the editor that will add the search step to the user's Zap and map the id field correctly.

![](https://cdn.zappy.app/081e63141ff05c131dadb8ebbea727b0.png)

This is paired most often with "update" actions, where a required parameter will be a resource id.

### What's the deal with pagination? When is it used and how does it work?

Paging is **only used when a trigger is part of a dynamic dropdown**. Depending on how many items exist and how many are returned in the first poll, it's possible that the resource the user is looking for isn't in the initial poll. If they hit the "see more" button, we'll increment the value of `bundle.meta.page` and poll again.

Paging is a lot like a regular trigger except the range of items returned is dynamic. The most common example of this is when you can pass a `offset` parameter:

```js
const perform = async (z, bundle) => {
  const response = await z.request({
    url: 'https://example.com/api/list.json',
    params: {
      limit: 100,
      offset: 100 * bundle.meta.page
    }
  });
  return response.data; // or response.json you're using core v9 or older
};
```

If your API uses cursor-based paging instead of an offset, you can use `z.cursor.get` and `z.cursor.set`:

```js
const perform = async (z, bundle) => {
  let cursor;

  // if fetching a page other than the first (first page is 0),
  // get the cursor stored after fetching the previous page.
  if (bundle.meta.page > 0) {
    cursor = await z.cursor.get();

    // if the previous page was the last one and cursor is empty/null,
    // return an empty array.
    if (!cursor) {
      return [];
    }
  }

  const response = await z.request(
    'https://5ae7ad3547436a00143e104d.mockapi.io/api/recipes',
    {
      // cursor typically is a param to pass along to the next request,
      // or the full URL for the next page of items.
      params: { cursor },
    }
  );

  // after fetching a page, set the returned cursor for the next page,
  // or empty/null if this was the last one.
  await z.cursor.set(response.nextPage);

  return response.items;
};

```

Cursors are stored per-zap and last about an hour. Per the above, make sure to only include the cursor if `bundle.meta.page > 0`, so you don't accidentally reuse a cursor from a previous poll.

Lastly, you need to set `canPaginate` to `true` in your polling definition (per the [schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#basicpollingoperationschema)) for the `z.cursor` methods to work as expected.

### How does deduplication work?

Each time a polling Zap runs, Zapier needs to decide which of the items in the response should trigger the zap. To do this, we compare the `id`s to all those we've seen before, trigger on new objects, and update the list of seen `id`s. When a Zap is turned on, we initialize the list of seen `id`s with a single poll. When it's turned off, we clear that list. For this reason, it's important that calls to a polling endpoint always return the newest items.

For example, the initial poll returns objects 4, 5, and 6 (where a higher `id` is newer). If a later poll increases the limit and returns objects 1-6, then 1, 2, and 3 will be (incorrectly) treated like new objects.

There's a more in-depth explanation [here](https://platform.zapier.com/legacy/dedupe).

### Why are my triggers complaining if I don't provide an explicit `id` field?

For deduplication to work, we need to be able to identify and use a unique field. In older, legacy Zapier Web Builder apps, we guessed if `id` wasn't present. In order to ensure we don't guess wrong, we now require that the developers send us an `id` field. If your objects have a differently-named unique field, feel free to adapt this snippet and ensure this test passes:

```js
// ...
let items = response.data.items; // or response.json.items if you're using core v9 or older
return items.map((item) => {
  item.id = item.contactId;
  return item;
});
```

### Node X No Longer Supported

If you're seeing errors like the following:

```
InvalidParameterValueException An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: The runtime parameter of nodejs6.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejsX.Y) while creating or updating functions.
```

... then you need to update your `zapier-platform-core` dependency to a non-deprecated version that uses a newer version of Node.js. Complete the following instructions as soon as possible:

1. Edit `package.json` to depend on a later major version of `zapier-platform-core`. There's a list of all breaking changes (marked with a :exclamation:) in the [changelog](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md).
2. Increment the `version` property in `package.json`
3. Ensure you're using version `v18` (or greater) of node locally (`node -v`). Use [nvm](https://github.com/nvm-sh/nvm) to use a different one if need be.
4. Run `rm -rf node_modules && npm i` to get a fresh copy of everything
5. Run `zapier test` to ensure your tests still pass
6. Run `zapier push`
7. Run `zapier promote YOUR_NEW_VERSION` (from step 2)
8. Migrate your users from the previous version (`zapier migrate OLD_VERSION YOUR_NEW_VERSION`)

### What Analytics are Collected?

Starting with v8.4.0, Zapier collects information about each invocation of the CLI tool.

This data is collected purely to improve the CLI experience and will **never** be used for advertising or any non-product purpose. There are 3 collection modes that are set on a per-computer basis.

**Anonymous**

When you run a command with analytics in `anonymous` mode, the following data is sent to Zapier:

* which command you ran
* if that command is a known command
* how many arguments you supplied (but not the contents of the arguments)
* which flags you used (but not their contents)
* the version of CLI that you're using

**Enabled** (the default)

When analytics are fully `enabled`, the above is sent, plus:

* your operating system (the result of calling [`process.platform`](https://nodejs.org/api/process.html#process_process_platform))
* your Zapier user id

**Disabled**

Lastly, analytics can be `disabled` entirely, either by running `zapier analytics --mode disabled` or setting the `DISABLE_ZAPIER_ANALYTICS` environment variable to `1`.

We take great care not to collect any information about your filesystem or anything otherwise secret. You can see exactly what's being collecting at runtime by prefixing any command with `DEBUG=zapier:analytics`.

### What's the Difference Between an "App" and an "Integration"?

We're in the process of doing some renaming across our Zapier marketing terms. Eventually we'll use "integration" everywhere. Until then, know that these terms are interchangeable and describe the code that you write that connects your API to Zapier.

## Command Line Tab Completion

Introduced in v9.1.0, the `zapier autocomplete` command shows instructions for generating command line autocomplete.

Follow those instructions to enable completion for `zapier` commands and flags!

## The Zapier Platform Packages

The Zapier Platform consists of 3 npm packages that are released simultaneously.

- [`zapier-platform-cli`](https://github.com/zapier/zapier-platform/tree/main/packages/cli) is the code that powers the `zapier` command. You use it most commonly with the `test`, `scaffold`, and `push` commands. It's installed with `npm install -g zapier-platform-cli` and does not correspond to a particular app.
- [`zapier-platform-core`](https://github.com/zapier/zapier-platform/tree/main/packages/core) is what allows your app to interact with Zapier. It holds the `z` object and app tester code. Your app depends on a specific version of `zapier-platform-core` in the `package.json` file. It's installed via `npm install` along with the rest of your app's dependencies.
- [`zapier-platform-schema`](https://github.com/zapier/zapier-platform/tree/main/packages/schema) enforces app structure behind the scenes. It's a dependency of `core`, so it will be installed automatically.

To learn more about the structure of the code (especially if you're interested in contributing), check out the `ARCHITECTURE.md` file(s).

### Updating These Packages

The Zapier platform and its tools are under active development. While you don't need to install every release, we release new versions because they are better than the last. We do our best to adhere to [Semantic Versioning](https://semver.org/) wherein we won't break your code unless there's a `major` release. Otherwise, we're just fixing bugs (`patch`) and adding features (`minor`).

Broadly speaking, all releases will continue to work indefinitely. While you never *have* to upgrade your app's `zapier-platform-core` dependency, we recommend keeping an eye on the [changelog](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md) to see what new features and bug fixes are available.

For more info about which Node versions are supported, see [the faq](#how-do-i-manually-set-the-nodejs-version-to-run-my-app-with).

The most recently released version of `cli` and `core` is **15.0.1**. You can see the versions you're working with by running `zapier -v`.

To update `cli`, run `npm install -g zapier-platform-cli`.

To update the version of `core` your app depends on, set the `zapier-platform-core` dependency in your `package.json` to a version listed [here](https://www.npmjs.com/package/zapier-platform-core?activeTab=versions) and reinstall your dependencies (either `yarn` or `npm install`).

For maximum compatibility, keep the versions of `cli` and `core` in sync.

## Get Help!

You can get help by either emailing<EMAIL_ADDRESS>or by [joining our developer community here](https://community.zapier.com/developer-discussion-13).

---

## Developing on the CLI

See [CONTRIBUTING.md](https://github.com/zapier/zapier-platform/blob/main/CONTRIBUTING.md).

{% endraw %}

license: MIT

branch_name: refs/heads/master

extension: md

gha_license_id: MIT

license_type: permissive


text:
title: What I learned about Elixir by writing a static site generator
summary: A collection of things that I learned by doing this exercise
tags: elixir
published: date_stub
---

As part of my journey in learning Elixir, I decided to write a small proof-of-concept static content generator. These kinds of projects can be very small and easy to do when you are short of time.

This is a quick list of what I have learned while working on this short project.

## The requirements

The requirements are simple. The application should give me the ability to setup the site structure, create drafts, and publish them. That is all what I wanted to build to begin with.

I wanted to have a command line interface that would do these tasks.

## Mix tasks

One of my favorite ruby features is rake. I have never used it as a make, but I have used it to create command line tasks. What I like the most is how easy it is to write these tasks.

Elixir has mix. Writing mix tasks is also easy, yet more verbose than writing them in Ruby.

[Example ruby] [Example Elixir]

## How to run OS commands

In my experience being able to use OS commands from a language is useful for writing practical applications.

Here Elixir gives us two options:

For simple os commands

System.cmd command, arguments

When you need to do something more elaborate on the shell that needs pipes and redirections

:os.cmd char_list_command

The idiom that I found useful is

"type NUL > newfile.txt" |> String.to_charlist |> :os.cmd

## Working with other libraries

A lot of early learning projects tends to be more of an exploration of the default libraries. Yet an important part of effectively using a language is to know the ecosystem of libraries that are available to the language so that they can be used when appropriate.

During this project I have learned to use yamerl and timex.

Here I have ran into the problems of incompatible libraries working on different versions of the erlang vm, the beam. This is one of those problems that one must see them and remember them for the future.

## Working directly with Erlang libraries

When reading books about Elixir, they often talk about how nice it is to be able to reach down and use erlang libraries directly. Although it is a cool idea to keep in mind, nothing matches actually having the experience of needed this.

While working on the project I wanted to use yaml_elixir. Yet the published verison wouldn''t compile. To troubleshoot the problem, I had to work directly with the base library.

Another praise for Elixir here: the interop is so simple that it is almost invisible. There was no pain using; there was no need to check books or search for blogs to tell me exactly how you are meant to do it.

## Adding documentation

Documentation is needed. Unfortunately it is often better not to have documentation than to have bad documentation. For years I have followed the philosophy that code should be self-documented. I still believe this. But my exposure to a course on programming where they stress the importance of documentation as a tool for function design and looking at how useful and easy to use Elixir documentation is changing my mine on this topic.

I can''t go into detail on this the position of the book, but the most important part is that documentation helps us clear our intent. This may sound familiar to those who know about TDD/BDD. And that is because tests are part of documentation.

Adding documentation in Elixir is easy. You use @moduledoc or @doc to add the documentation text. And Elixir''s documentation also has a page giving you guidelines on [https://hexdocs.pm/elixir/master/writing-documentation.html](Elixir''s writting documentation guide).

repository: hugoestr/ahab

repo_name: hugoestr/ahab


text:
# Study Drills
 1. Convert this while- loop to a function that you can call, and replace 6
 in the test (i < 6) with a variable.

 2. Now use this function to rewrite the script to try different numbers.

 3. Add another variable to the function arguments that you can pass in that
 lets you change the + 1 on line 8, so you can change how much it increments by.

 4. Rewrite the script again to use this function to see what effect that has.

 5. Now, write it to use for- loops and range instead. Do you need the
 incrementor in the middle anymore? What happens if you do not get rid of it?

**If at any time that you are doing this it goes crazy (it probably will), just hold down CTRL and hit
c (CTRL- c) and the program will abort.**

path: /33. While-Loops/README.md

gha_language: Python


text:
---
title: ShipIt to Marketplace
position: 1.8
right_code: |
  ~~~groovy
  tasks {
      shipIt2marketplace(deployArtifactName: 'Plan DSL') {
          description 'ship it to the Atlassian Marketplace'
          enabled true
          isFinal false
          onlyAllowToTriggerFromJira true
          runOnBranchBuilds false
          publicVersion true
          deduceBuildNrFromPluginVersion true
          bambooUserId 'admin'
          jqlToCollectReleaseNotes 'status in (resolved,closed,done)'
      }
  }
  ~~~
  {: title="DSL" }
  ~~~ yml
  tasks:
    - !shipit2marketplace
      deployArtifactName: Plan DSL
      description: ship it to the Atlassian Marketplace
      enabled: true
      isFinal: false
      onlyAllowToTriggerFromJira: true
      runOnBranchBuilds: false
      publicVersion: true
      deduceBuildNrFromPluginVersion: true
      bambooUserId: admin
      jqlToCollectReleaseNotes: status in (resolved,closed,done)
  ~~~
  {: title="YAML" }
---
Deploys your plug-ins to the Atlassian Marketplace. This task is provided by the
ShipIt to Marketplace for Bamboo
plug-in.

repository: mibexsoftware/bamboo-plan-dsl-plugin

gha_language: Groovy

gha_license_id: NOASSERTION

repo_name: mibexsoftware/bamboo-plan-dsl-plugin


text:
## Perspective Expression Syntax

This README outlines the capabilities and syntax of Perspective's expression
engine. To create a new computed expression column, use the `Add Column` button
in the bottom left corner of the UI.

### Column Names

All column names must be wrapped with _double quotes_ or _single quotes_.
Columns can also be dragged into the expression input area using the UI.

### Operators

There are five mathematical operators:

- `+` Addition
- `-` Subtraction
- `*` Multiplication
- `/` Division
- `%` Percent A of B

Expressions using these should have a column name or an expression
wrapped in parentheses on either side.

### Functions

Perspective offers a variety of computation functions for different uses:

#### Math

- `sqrt` Square root
- `pow2` Power of 2
- `abs` Absolute value
- `invert` 1/x
- `bin10` Bucket column by 10
- `bin100` Bucket by 100
- `bin1000` Bucket by 1000
- `bin10th` Bucket by 0.1
- `bin100th` Bucket by 0.01
- `bin1000th` Bucket by 0.001

#### String

- `length` Length of string
- `uppercase` Uppercase string
- `lowercase` Lowercase string
- `concat_comma` Join two strings with comma
- `concat_space` Join two strings with space

#### Datetime/Date

- `hour_of_day` Hour of day (as integer)
- `day_of_week` Day of week (as string)
- `month_of_year` Month of year (as string)
- `second_bucket` Bucket by seconds
- `minute_bucket` Bucket by minute
- `hour_bucket` Bucket by hour
- `day_bucket` Bucket by day
- `week_bucket` Bucket by week
- `month_bucket` Bucket by month
- `year_bucket` Bucket by year

To use a function, simply write the function name followed by parentheses and
a column name:

`sqrt("Sales")`

Functions can have expressions inside them, but each expression __MUST__ be
wrapped in its own set of parentheses:

`invert((pow2((abs("Sales)))))`

Functions can be combined with operators, and vice versa:

`(abs("Sales")) * (pow2("Profit"))`

### Custom Column Names

Use `AS` to give your computed expression columns a custom name:

`"Sales" * "Profit" as "New Column"`

### Error Handling

The UI will validate your expression as you type, and provide error messages
when the expression is malformed or otherwise invalid.

After the expression has been validated, its inputs will be type checked
to make sure that all input column types are valid for the expression.

If any types are invalid, the error message will display the column name and
expected input types.

repository: zepaz/perspective

gha_language: JavaScript

repo_name: zepaz/perspective


text:
#  E-Commerce Back End

## Description

Internet retail, also known as **e-commerce**, is the largest sector of the electronics industry, generating an estimated $29 trillion in 2019. E-commerce platforms like Shopify and WooCommerce provide a suite of services to businesses of all sizes. This code functions as the back end for an ecommerce site and uses sequelize to manipulate and interact with a MYSQL database with the store's products and information.

## Installation

* Navigate to https://github.com/mpkahn/ecommerce and clone repository to local machine.
* Once on local machine:
* Install npm (`npm i`).
* Install` npm sequelize`
* Install `npm mysql`
* Install npm dotenv
* Ensure correct information in .env file
* Either initialize database in mysql workbench ~or~ utilize ``mysql -u root -p`` (followed by your password)
* Seed databse with ``npm run seed`` or ``node seed``
* Once NPM is installed, run "npm start" to launch application

## Usage

See video demo: https://drive.google.com/file/d/1blo3yuL1axHVFeGvVC5iOV3mpuany9m9/view

npm start will initiate server

* Utilize insomnia core to get data by product/category/tag
* Utilize insomnia core to post new data
* Utilize insomnia core to update or delete data from db

## Credits

* node.js and its documentation on file systems https://nodejs.org/api/fs.html & https://nodejs.org/en/knowledge/file-system/how-to-write-files-in-nodejs/
npm js,
* Sequelize
* MYSQL https://dev.mysql.com/doc/refman/8.0/en/keywords.html
* Insomnia core
* Screencastify

## License

MIT License

Copyright (c) [2021] [Michael Kahn]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

 IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

repository: mpkahn/ecommerce

branch_name: refs/heads/main

repo_name: mpkahn/ecommerce


text:
# Boost.KernelTest
C++14 automated code test infrastructure with permutation, fuzzing, sanitising and edge coverage

Do NOT attempt to use this library in its current state!

## Some notes on what this library is for and will eventually do

KernelTest is a test runner for your choice of unit test framework, so the idea is that instead of
_test cases_, you write instead _test kernels_ which are simply small functions exercising a
**minimal set** of your public API. Here's one from AFIO:

```c++
namespace file_handle_create_close
{
  BOOST_AFIO_TEST_KERNEL_DECL boost::outcome::result<boost::afio::file_handle> test_kernel_file_handle(boost::afio::file_handle::mode m, boost::afio::file_handle::creation c, boost::afio::file_handle::flag f)
  {
    auto h = boost::afio::file_handle::file("testfile.txt", m, c, boost::afio::file_handle::caching::all, f);
    if(h)
      h.get().close();
    return h;
  }
}
```

In the above test kernel only three parameters of the `afio::file_handle::file()` constructor
are exposed. One then has KernelTest call that test kernel many times with a long initialiser
list of parameter permutations and expected outcomes like this:

```c++
//  Outcome (void means no error)    Kernel parameter call set                                                                     Preconditions       Postconditions
{   make_ready_result<void>(),       { file_handle::mode::none,       file_handle::creation::if_needed, file_handle::flag::none }, { "existing1"    }, { "existing1"    }},
{   make_ready_result<void>(),       { file_handle::mode::attr_read,  file_handle::creation::if_needed, file_handle::flag::none }, { "existing1"    }, { "existing1"    }},
{   make_ready_result<void>(),       { file_handle::mode::attr_write, file_handle::creation::if_needed, file_handle::flag::none }, { "existing1"    }, { "existing1"    }},
{   make_ready_result<void>(),       { file_handle::mode::write,      file_handle::creation::if_needed, file_handle::flag::none }, { "non-existing" }, { "existing0"    }},
{   make_ready_result<void>(),       { file_handle::mode::write,      file_handle::creation::if_needed, file_handle::flag::none }, { "existing1"    }, { "existing1"    }},
{   make_ready_result<void>(),       { file_handle::mode::append,     file_handle::creation::if_needed, file_handle::flag::none }, { "non-existing" }, { "existing0"    }},
{   make_ready_result<void>(),       { file_handle::mode::append,     file_handle::creation::if_needed, file_handle::flag::none }, { "existing1"    }, { "existing1"    }},
...
```

It is however tedious and error prone to write out by hand every single **valid** permutation of
even the above three parameter sets. KernelTest was written to automate away almost all of that
tedium.

Very, very recent clangs (>= 4.0) have gained the ability to instrument your code with calls informing
you of why the execution flow changed as execution progresses. You simply must compile your
piece of test code with `-fsanitize-coverage=trace-pc,indirect-calls -fsanitize-coverage=trace-cmp -fsanitize-coverage=trace-div -fsanitize-coverage=trace-gep`
and clang will emit these functions:

`void __sanitizer_cov_trace_pc()`
`void __sanitizer_cov_trace_pc_indirect(void *callee)`

Called per edge executed. Edge can be identified via `__builtin_return_address(0)`.

`void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2)`
`void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2)`
`void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2)`
`void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2)`

Called when a comparison is about to be performed which will determine which edge
to execute next.

`void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases)`

Called when a comparison of a value to a list of values is about to performed,
again determining what the next edge to be executed will be. Note if() statements
comparing a single variable to multiple items are collapsed into one of these.

`void __sanitizer_cov_trace_div4(uint32_t Val)`
`void __sanitizer_cov_trace_div8(uint64_t Val)`

Called when an integer divide is about to happen.

`void __sanitizer_cov_trace_gep(uintptr_t Idx)`

Called when an array index is about to happen.

There is also another sanitiser `-fsanitize=dataflow` which lets you taint each input
parameter and clang will propagate that taint throughout a piece of code. This lets
you determine that variables calculated from input parameters depend on those parameters.

This instrumentation is meant for fuzzers, but it nearly offers enough to do a
poor man's **symbolic execution engine** i.e. to determine what inputs cause what parts
of a program to execute, and thereby automatically generate a minimum set of
parameter call sets for some function which exercise every possible control
flow in the potential execution graph. That minimum set of parameter call sets
can then be automatically inserted by KernelTest into its kernel unit test runner
call lists which can be customised by hand where appropriate. A build tooling pass
or CI pass can also keep those test runner call tests fresh as the code changes.

By "poor man'", as you'll see next I really do mean "nearly offers enough" because this is a
very inefficient way of implementing a unit test case generator as compared to a
proper SMT solving symbolic execution engine like say KLEE (https://klee.github.io/).

Imagine for example this real world function with all its prerequisites minimally
pasted in front:

```c++
/* A small standalone program to test whether the permuter works
*/

#include "outcome/include/outcome.hpp"

#include "quickcpplib/include/bitfield.hpp"
#include <filesystem>

namespace minimal_afio
{
  using namespace OUTCOME_V2_NAMESPACE;
  struct native_handle_type
  {
    HANDLE h;
    native_handle_type()
        : h(nullptr)
    {
    }
  };
  struct file_handle
  {
    using path_type = std::experimental::filesystem::path;
    enum class mode : unsigned char
    {
      unchanged = 0,
      none = 2,        //!< No ability to read or write anything, but can synchronise (SYNCHRONIZE or 0)
      attr_read = 4,   //!< Ability to read attributes (FILE_READ_ATTRIBUTES|SYNCHRONIZE or O_RDONLY)
      attr_write = 5,  //!< Ability to read and write attributes (FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES|SYNCHRONIZE or O_RDONLY)
      read = 6,        //!< Ability to read (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|SYNCHRONISE or O_RDONLY)
      write = 7,       //!< Ability to read and write (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA|FILE_APPEND_DATA|SYNCHRONISE or O_RDWR)
      append = 9       //!< All mainstream OSs and CIFS guarantee this is atomic with respect to all other appenders (FILE_APPEND_DATA|SYNCHRONISE or O_APPEND)
    };
    enum class creation : unsigned char
    {
      open_existing = 0,
      only_if_not_exist,
      if_needed,
      truncate  //!< Atomically truncate on open, leaving creation date unmodified.
    };
    enum class caching : unsigned char  // bit 0 set means safety fsyncs enabled
    {
      unchanged = 0,
      none = 1,                //!< No caching whatsoever, all reads and writes come from storage (i.e. <tt>O_DIRECT|O_SYNC</tt>). Align all i/o to 4Kb boundaries for this to work. <tt>flag_disable_safety_fsyncs</tt> can be used here.
      only_metadata = 2,       //!< Cache reads and writes of metadata but avoid caching data (<tt>O_DIRECT</tt>), thus i/o here does not affect other cached data for other handles. Align all i/o to 4Kb boundaries for this to work.
      reads = 3,               //!< Cache reads only. Writes of data and metadata do not complete until reaching storage (<tt>O_SYNC</tt>). <tt>flag_disable_safety_fsyncs</tt> can be used here.
      reads_and_metadata = 5,  //!< Cache reads and writes of metadata, but writes of data do not complete until reaching storage (<tt>O_DSYNC</tt>). <tt>flag_disable_safety_fsyncs</tt> can be used here.
      all = 4,                 //!< Cache reads and writes of data and metadata so they complete immediately, sending writes to storage at some point when the kernel decides (this is the default file system caching on a system).
      safety_fsyncs = 7,       //!< Cache reads and writes of data and metadata so they complete immediately, but issue safety fsyncs at certain points. See documentation for <tt>flag_disable_safety_fsyncs</tt>.
      temporary = 6            //!< Cache reads and writes of data and metadata so they complete immediately, only sending any updates to storage on last handle close in the system or if memory becomes tight as this file is expected to be temporary (Windows only).
                               // NOTE: IF UPDATING THIS UPDATE THE std::ostream PRINTER BELOW!!!
    };
    QUICKCPPLIB_BITFIELD_BEGIN(flag)
    {
      none = 0,  //!< No flags
      unlink_on_close = 1 << 0, disable_safety_fsyncs = 1 << 2, disable_safety_unlinks = 1 << 3,

      win_disable_unlink_emulation = 1 << 24,  //!< See the documentation for `unlink_on_close`

      overlapped = 1 << 28,         //!< On Windows, create any new handles with OVERLAPPED semantics
      byte_lock_insanity = 1 << 29  //!< Using insane POSIX byte range locks
    }
    QUICKCPPLIB_BITFIELD_END(flag)
    file_handle(path_type path, caching, flag)
        : _path(std::move(path))

    {
    }
    native_handle_type _v;
    path_type _path;
  };
  using handle = file_handle;
  static inline result<ACCESS_MASK> access_mask_from_handle_mode(handle::mode _mode)
  {
    ACCESS_MASK access = SYNCHRONIZE;
    switch(_mode)
    {
    case handle::mode::unchanged:
      return make_errored_result<ACCESS_MASK>(EINVAL);
    case handle::mode::none:
      break;
    case handle::mode::attr_read:
      access |= FILE_READ_ATTRIBUTES;
      break;
    case handle::mode::attr_write:
      access |= FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
      break;
    case handle::mode::read:
      access |= GENERIC_READ;
      break;
    case handle::mode::write:
      access |= GENERIC_WRITE | GENERIC_READ;
      break;
    case handle::mode::append:
      access |= FILE_APPEND_DATA;
      break;
    }
    return access;
  }
  static inline result<DWORD> attributes_from_handle_caching_and_flags(handle::caching _caching, handle::flag flags)
  {
    DWORD attribs = 0;
    if(flags & handle::flag::overlapped)
    {
      attribs |= FILE_FLAG_OVERLAPPED;
    }
    switch(_caching)
    {
    case handle::caching::unchanged:
      return make_errored_result<DWORD>(EINVAL);
    case handle::caching::none:
      attribs |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
      break;
    case handle::caching::only_metadata:
      attribs |= FILE_FLAG_NO_BUFFERING;
      break;
    case handle::caching::reads:
    case handle::caching::reads_and_metadata:
      attribs |= FILE_FLAG_WRITE_THROUGH;
      break;
    case handle::caching::all:
    case handle::caching::safety_fsyncs:
      break;
    case handle::caching::temporary:
      attribs |= FILE_ATTRIBUTE_TEMPORARY;
      break;
    }
    if(flags & handle::flag::unlink_on_close)
      attribs |= FILE_FLAG_DELETE_ON_CLOSE;
    return attribs;
  }
}

namespace file_create
{
  using namespace minimal_afio;
  using QUICKCPPLIB_NAMESPACE::ringbuffer_log::last190;
  extern BOOST_SYMBOL_EXPORT result<file_handle> test_file_create(file_handle::path_type _path, file_handle::mode _mode = file_handle::mode::read, file_handle::creation _creation = file_handle::creation::open_existing, file_handle::caching _caching = file_handle::caching::all,
                                                                  file_handle::flag flags = file_handle::flag::none) noexcept
  {
    result<file_handle> ret(file_handle(std::move(_path), _caching, flags));
    native_handle_type &nativeh = ret.get()._v;
    BOOST_OUTCOME_FILTER_ERROR(access, access_mask_from_handle_mode(_mode));
    DWORD creation = OPEN_EXISTING;
    switch(_creation)
    {
    case file_handle::creation::open_existing:
      break;
    case file_handle::creation::only_if_not_exist:
      creation = CREATE_NEW;
      break;
    case file_handle::creation::if_needed:
      creation = OPEN_ALWAYS;
      break;
    case file_handle::creation::truncate:
      creation = TRUNCATE_EXISTING;
      break;
    }
    BOOST_OUTCOME_FILTER_ERROR(attribs, attributes_from_handle_caching_and_flags(_caching, flags));
    if(INVALID_HANDLE_VALUE == (nativeh.h = CreateFile(ret.value()._path.c_str(), access, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, creation, attribs, NULL)))
    {
      DWORD errcode = GetLastError();
      // assert(false);
      return make_errored_result<file_handle>(errcode, last190(ret.value()._path.u8string()));
    }
    if(flags & file_handle::flag::unlink_on_close)
    {
      // Hide this item
      SetFileAttributes(ret.value()._path.c_str(), FILE_ATTRIBUTE_HIDDEN);
    }
    return ret;
  }
}
```

The above is a standalone program, and the function we want to automatically generate unit tests for is
`test_file_create()`. A future clang AST parser will inspect the function being tested and figure out
from the AST a set of seed value permutations. In the case above, most of the parameters are enums of
some kind, so a complete list of call permutations can be generated just by the AST parser alone. But
let's assume for a minute that at least one of those parameters was just a simple signed integer where
its negativity, zero and the range 1-5 and 6 to `INT_MAX` are the four possible minimum variations which
cause the function to do something different.

You can see in the source code that `test_file_create()`'s parameters are transformed into parameters
with which to call `CreateFile()`. Via the clang instrumentation, we can permute say the mode parameter
and notice that one or many of the `__sanitizer_cov_trace_cmp1()` and/or `__sanitizer_cov_trace_switch()`
calls will always be passed that same input value and/or change when the input changes (e.g. a bitfield
or a value calculated from the input). If the input was compared unmodified, we can then assemble a list
of all the values that that mode parameter is ever compared to on the basis that each of those values,
and those values plus or minus 1 is highly likely to cause new edges to get executed, thus illuminating
more new potential parameter values to test.

This works well for simple integer parameters which represent some unique number meaning something,
and in fact of course mode is actually an enum and therefore only has a small set of valid states
anyway. The clang AST parser should be able to spot enums which are bitfields and tag them appropriately
for permutation, so that covers pretty well the simple stuff.

Things get harder for where calculations are performed onto an input before it is compared. Unless
`-fsanitize=dataflow` is enabled in which case we can taint each input parameter and the taint
will follow onto any calculated variables, we cannot necessarily know that a relationship exists
between a value calculated from input parameters and those input parameters. Even with tainting
on, we may know a relationship exists but have no idea what it is, it could be highly non linear
or any old weird thing. Here simple brute force comes into play, we split the valid input range
into two powers ranges, and if there is change between those we split each range in half again and so
on, effectively performing a binary search for those input values which cause a compared value to change.
_The chances are_ that most calculations from input parameters to compared parameters which don't use
divide nor an array index is going to be linear and so this divide and conquer technique will work,
but I can see some corner cases might slip through. They ought to be fairly rare however.

You can probably see by now that this problem is ultimately recursive, and the total set of
permutations which must be tried rises very quickly when input parameters have any range on them
as total valid permutations is two to the power of the bits of free range. To try and keep down
the bits of free range, one can mark up individual parameters with valid ranges using C++ attributes
and the clang AST parser will ensure that the permuter limits itself to that range.

Where KernelTest doesn't do well is on stuff like string input where the set of unique and potentially
meaningful permutations rises very quickly and this poor man's symbolic execution engine begins
to fall down quite badly. KernelTest takes the view that you the user needs to use a proper fuzzer
with a genetic learning algorithm for string inputs, and so therefore ignores those entirely.

KernelTest isn't capable of performing magic. It can only figure out, via brute force, the total
permutations of a test kernel which you the programmer necessarily will have to carefully write in
a fashion which limits the exercise of the APIs it calls. That will leave unit test coverage gaps as wide
as you are unwilling to introduce mocks for syscalls, or parameter ranges you overconstrain, or
the time you allow the brute force program to run and so on.

Nevertheless, with careful test kernel design KernelTest ought to automate the lion's share of the
tedium of writing unit test code for your APIs and achieving a test coverage much higher than an
equivalent amount of programmer effort without KernelTest would achieve.


text:
# Cylon.js for Leap Motion

[![Build Status](https://secure.travis-ci.org/hybridgroup/cylon-leapmotion.png?branch=master)](http://travis-ci.org/hybridgroup/cylon-leapmotion)

Cylon.js (http://cylonjs.com) is a JavaScript framework for robotics and physical computing using Node.js

This module provides an adaptor and driver for the Leap Motion (https://www.leapmotion.com/) gesture controller.

Want to use Ruby on robots? Check out our sister project [Artoo](http://artoo.io).

## Getting Started

Install the module via NPM:

    npm install cylon-leapmotion

In order to use this module , you need to install the drivers/software from the Leapmotion site [https://www.leapmotion.com/setup](https://www.leapmotion.com/setup), make sure that is installed before use the commands and events.

## Examples

```javascript
var Cylon = require('cylon');

Cylon.robot({
  connection: {
    name: 'leapmotion',
    adaptor: 'leapmotion',
    port: '<IP_ADDRESS>:6437'
  },

  device: {
    name: 'leapmotion',
    driver: 'leapmotion'
  },

  work: function(my) {
    my.leapmotion.on('hand', function(payload) {
      Logger.info(payload.toString());
    });
  }
}).start();

```

## Documentation

We're busy adding documentation to [cylonjs.com](http://cylonjs.com). Please check there as we continue to work on Cylon.js.

Thank you!

## Contributing

* All patches must be provided under the Apache 2.0 License
* Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
* Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
* We will look at the patch, test it out, and give you feedback.
* Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
* Take care to maintain the existing coding style.
* Add unit tests for any new or changed functionality & Lint and test your code using [Grunt](http://gruntjs.com/).
* All pull requests should be "fast forward"
  * If there are commits after yours use “git rebase -i <new_head_branch>”
  * If you have local changes you may need to use “git stash”
  * For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git

## Release History

Version 0.12.0 - Compatibility with Cylon 0.18.0

Version 0.11.0 - Compatibility with Cylon 0.16.0, add peerDependencies

Version 0.10.0 - Add back 'gesture' event, tweaked 'hand' objects.

Version 0.9.0 - Compatibility with Cylon 0.15.0, use LeapJS instead of custom implementation

Version 0.8.0 - Compatibility with Cylon 0.14.0, remove node-namespace.

Version 0.7.0 - Move object mapping to new `Leap.Frame#addObjectRelations` function

Version 0.6.0 - Release for cylon 0.12.0

Version 0.5.0 - Release for cylon 0.11.0, refactor into pure JavaScript

Version 0.4.0 - Release for cylon 0.10.0

Version 0.3.0 - Release for cylon 0.9.0

Version 0.2.0 - Release for cylon 0.8.0

Version 0.1.0 - Initial release

## License

Copyright (c) 2013-2014 The Hybrid Group. Licensed under the Apache 2.0 license

repository: GiulSposito/lm-drone

repo_name: GiulSposito/lm-drone


text:
Summary: Add images, links and more to your blog posts

Blot converts text files from [Markdown](http://daringfireball.net/projects/markdown/). You can use markdown to make text bold, italicized, create lists, links and more. You can mix Markdown and HTML in the same file.

## Bold and Italic

To create italics, use a single asterix (*) on either side of the text:

```*This text will be italic.*```

*This text will be italic.*

Surrounding text with two asterisks makes text bold:

```**This text will be bold.**```

**This text will be bold.**

Both * or _ symbols work to make text bold or italic. This way you can combine bold and italic in the same sentence. For example:

```**Everyone _must_ listen.**```

**Everyone _must_ listen.**

## Strikethrough

Put a double tilde (~) on either side of the text you want to strikethrough:

```~~Strike out mistakes~~```

~~Strike out mistakes~~

## Bulleted Lists
Make a bulleted list by preceding list items with a single asterix (*) or a hyphen (-). You need a space between the asterix and the text.

```
- Round
- Shell
- Projectile
```

* Round
* Shell
* Projectile

## Numbered Lists

Create a numbered list by preceding list items with a number.

```
1. Eins
2. Deux
3. Tres
```

1. Eins
2. Deux
3. Tres

## Links

Create a text link by wrapping the linked text in brackets [ ], and then wrapping the link in parenthesis ( ). For example:

```[Wikipedia](https://wikipedia.org) ```

[Wikipedia](https://wikipedia.org)

## Headings

```
# Largest heading
## Subheading
### Section heading
```

## Mathematics

Blot will convert equations set in LaTeX. Check out this useful [guide](https://nrich.maths.org/discus/messages/24097/66497.html). To use this, wrap your LaTeX in two dollar signs (${{x}}$) like this:

${{x}}$ f(x) = 2x^2 + 2/3 ${{x}}$

    $$ f(x) = 2x^2 + 2/3 $$

## Images

Here's what the markdown looks like, note the ‘!’ before the tag.

```
![alt text](http://example.com/image-url.jpg "Title")
```

Yes, first create a [public folder](/help/publishing-with-blot#public-files), e.g. '_images', put the image inside then embed the image like this:

```
![Image title](/_images/image.jpg)
```

## Code snippets

Indent code with four spaces:

    var foo = “bar”;

You can also wrap ```code.snippets``` with three backticks ``` `{{x}}```. This is useful for inserting code snippets inside a paragraph.

If you have enabled the syntax highlighting app, Blot will process the snippet using [highlight.js](https://highlightjs.org/). Every Blot template comes with its own syntax highlighting theme. If you are designing a custom blog template and want to use syntax highlighting, please [add a theme](https://highlightjs.org/static/demo/) to your blog’s CSS file.

## Videos

You can also paste the HTML for a video embed directly into a blog post. Blot also automatically converts plain URLs to Youtube and Vimeo videos into video embeds. To embed a youtube video in your blog post just paste its URL like this:

```
https://www.youtube.com/watch?v=nkJA6SYwa94
```

## Footnotes

You can specify footnotes using this syntax:

```
A line with a footnote.[^1] Another line.[^2]

[^1]: And the note goes here.
[^2]: And the second goes here too.
```

## Layout

I wrote a Markdown extension for Blot which provides basic layout shortcuts. The features are as follows:

| The tag…        | should make its contents...  | by applying this CSS class…    |
| --------------- |------------------------------|-----------------------------------------|
| ```{<<}```      | extend into the left margin  | ```wide left```  |
| ```{>>}```      | extend into the right margin | ```wide right``` |
| ```{<>}```      | extend into both margins     | ```wide```       |
| ```{>}```       | float right inside the page  | ```right inside```|
| ```{<}```       | float left inside the page   | ```left inside```|
| ```{|<}```      | hang in the right margin     | ```right margin```|
| ```{>|}```      | hang in the left margin      | ```left margin```|
| ```{||}```      | sit inside a 1/2 width column    | ```two column```|
| ```{|||}```     | sit inside a 1/3 width column    | ```three column```|
| ```{||||}```    | sit inside a 1/4 width column    | ```four column```|

You can including multiple lines inside the same layout tag by indenting them:

```
{<<} ## Subtitle which extends into left margin
     A paragraph which will also extend into the left margin.

{>>} ## Subtitle which extends into right margin
     A paragraph which will also extend into the right margin.
```

Your blog's template controls how the layout HTML is styled. Most Blot templates come with a variation on [layout.css](/public/layout.css) which provides the above features as described.

repository: TheAmateurTechnologist/Blot

path: /app/views/help/src/4. Formatting blog posts.md

filename: 4. Formatting blog posts.md

repo_name: TheAmateurTechnologist/Blot


text:
# Reporting & Results Processing

Reporting functionality in Taurus is delegated to special modules category. There is special [internal facility](#results-reading-and-aggregating-facility) that reads results from [executors](ExecutionSettings.md), aggregates them and feeds to configured reporters. Reporters are specified as list under top-level config key `reporting`, by default it is configured with two reporters:

```yaml
---
reporting:
    - final_stats
    - console
```

The example above uses a shorthand form for specifying reporters. Full form is using dictionaries and allows specifying some additional settings for reporters:

```yaml
---
reporting:
    - module: final_stats
    - module: console
```

Possible reporting modules are listed below.

## Post-Test Summary

This is the simplest reporter that just prints few basic KPIs in the console log after test execution, for example:

```
18:04:24 INFO: Samples count: 367, 8.17% failures
18:04:24 INFO: Average times: total 0.385, latency 0.115, connect 0.000
18:04:24 INFO: Percentile   0.0%: 0.125
18:04:24 INFO: Percentile  50.0%: 0.130
18:04:24 INFO: Percentile  90.0%: 1.168
18:04:24 INFO: Percentile  95.0%: 1.946
18:04:24 INFO: Percentile  99.0%: 2.131
18:04:24 INFO: Percentile  99.9%: 3.641
18:04:24 INFO: Percentile 100.0%: 3.641
```

This reporter is enabled by default. To enable it manually, use following config, some additional options are available:

```yaml
---
reporting:
  - module: final_stats
      summary: true  # overall samples count and percent of failures
      percentiles: true  # display average times and percentiles
      failed-labels: false  # provides list of sample labels with failures
      test-duration: true  # provides test duration
      dump-xml: filename to export data in XML format
      dump-csv: filename to export data in CSV format
```

### Dump Summary for Jenkins Plot Plugin

Two options `dump-csv` and `dump-xml` allows to export final cumulative stats into files that can be used by [Jenkins Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin) to plot historical data inside Jenkins. Prefer CSV as it is much easier to use with Plot Plugin. XML format also can be used with other tools to automate results processing.

Field names with explanations:

 - `label` - is the sample group for which this CSV line presents the stats. Empty label means total of all labels
 -   `concurrency` - average number of Virtual Users
 -   `throughput` - total count of all samples
 -   `succ` - total count of not-failed samples
 -   `fail`  - total count of saved samples
 -   `avg_rt` - average response time
 -   `stdev_rt` - standard deviation of response time
 -   `avg_ct` - average connect time if present
 -   `avg_lt`  - average latency if present
 -   `rc_200` - counts for specific response codes
 -   `perc_0.0 .. perc_100.0` - percentile levels for response time, 0 is also minimum response time, 100 is maximum

## Console Screen

This reporter shows fullscreen dashboard with some KPIs and even ASCII-art graphs like this:

![Console Screen](console-rsz.png)

This reporter is enabled by default. To enable it manually, use following config:

```yaml
---
reporting:
    - console
```

There is module settings for Console Screen, containing option `disable`. It allows easy disabling fullscreen display by using [command-line](CommandLine.md) switch `-o`:

```bash
bzt config.yml -o modules.console.disable=true
```

On Windows, Console Screen is shown in separate window and users may change font size by holding Ctrl key and using mouse wheel.
Two additional options are `dummy-cols` and `dummy-rows`, they affect the size of _dummy_ screen that is used for non-tty output.

## Pass/Fail Criteria

Every execution has pass/fail status and there is a way to set this status based on runtime criteria. Special `fail-criteria` reporter offers this functionality. Another useful feature of pass/fail criteria is _auto-stop_ functionality, allowing to interrupt failed tests automatically, sparing the time and resources.

Pass/fail criteria are specified as array of `criteria`, set through `reporting` item in config:

```yaml
---
reporting:
 - module: fail-criteria
   criterias:
   - avg-rt of Sample Label>150ms for 10s, stop as failed
   - fail of Sample Label>50% for 10s, stop as failed
```

The above example use short form for criteria, its general format is `subject of label{condition}threshold {logic} timeframe, action as status`, where:

  - `subject` is the KPI that will be compared, listed below
  - `label` is sample label, empty for overall
  - `{condition}` is the comparison operator, one of `>`, `<`, `>=`, `<=`, `=`, `==` (same as `=`)
  - `threshold` is the value to compare with, some KPIs allows percentage thresholds
  - `{logic}` is the way value aggregated withing timeframe, `for` means taking latest value, `within` means aggregating as average or sum (depends on criteria nature)
  - `timeframe` is number of seconds the comparison must be valid, if `timeframe` is omitted, then the cumulative value for whole test will be used for comparison.
  - `action` is one of `stop` or `continue`, default is `stop`, if you have chosen to continue, the fail status will be applied at the end of the test execution
  - `status` is one of `failed` (default) or `non-failed`

Any non-required parameters might be omitted, the minimal form is `subject{condition}threshold`.

Possible subjects are:

 - `avg-rt` - average response time, e.g. `avg-rt>2s500ms`
 - `avg-lt`- average latency, e.g. `avg-lt for mylabel>2`
 - `avg-ct` - average connect time, e.g. `avg-ct>100ms`
 - `stdev-rt` - standard deviation for full response time, e.g. `stdev-rt>0.5`
 - `p...` - percentile timing, e.g. `p90>1s for 10s`, `p99.9>10s, stop as failed`
 - `hits` - number of responses, e.g. `hits for my-label>100 for 5s, stop as non-failed`
 - `succ` or `success` - successful responses, supports percentage threshold, e.g. `succ\<100%`
 - `fail` or `failures` - failed responses, supports percentage threshold, e.g. `failures>50% for 5s, stop as failed`
 - `rc...` - response codes criteria, supports percentage threshold, response code may be specified using wildcards `?` and `\*`, e.g. `rc500>20 for 5s, stop as failed`, `rc4??>20%`, `rc\*>=10 for 1m`, `rcException>99% for 1m, continue as failed`,

The full form of the criteria is conducted by Taurus automatically from short form. You can also specify it as this:

```yaml
---
reporting:
 - module: fail-criteria
  criterias:
  - subject: avg-rt  # required
    label: 'Sample Label'  # optional, default is ''
    condition: '>'  # required
    threshold: 150ms  # required
    timeframe: 10s  # optional, default is none
    logic: for  # optional, logic to aggregate values within timeframe.
                # Default 'for' means take latest,
                # 'within' means take sum/avg of all values within interval
    fail: true  # optional, default is true
    stop: true  # optional, default is true
```

### Custom Messages for Criteria

By default, Taurus uses criteria string to present it in messages. If you want to change the message, you can do one of:
 - set `message` field for full form of criteria
 - set message by prepending it to criteria string, like this: `My message: avg-rt>10s`
 - use dictionary instead of array to specify message and criteria, like this:

```yaml
---
reporting:
 - module: fail-criteria
   criterias:
     My Message: avg-rt of Sample Label>150ms for 10s, stop as failed
     Sample Label fails too much: fail of Sample Label>50% for 10s, stop as failed
```

## BlazeMeter.com Reporting Service

Like it always happens with tools that focused on _executing_ tests, they are unable to provide sufficient reporting functionality. As professional user, you need some centralized storage to be able to access test results in convenient and interactive way, compare different executions, see trends over time and collaborate with your colleagues. [BlazeMeter.com](http://blazemeter.com) offers such service, it has both commercial and free of charge versions.

![BlazeMeter Report](blazemeter-rsz.png)

### Anonymous Usage

The simplest way to get a taste of BlazeMeter reporting is to use `-report` command-line switch. This will enable result feeding to service without any other settings required. You will receive the link for your report in the console text, and the link will be automatically opened in your default browser, see `browser-open` option for more tuning.

The official policy for BlazeMeter reports uploaded from Taurus, is that anonymous reports are kept for 7 days and if you're using your own account, then reports are kept according to the retention policy of your account. For details see BlazeMeter service [website](https://blazemeter.com/).

### Personalized Usage

If you want the results to be stored in your existing BlazeMeter account, you'll need to specify the reporting settings in your configuration file. Get the API token from BlazeMeter.com (find it under your [Settings => API Key](https://a.blazemeter.com/app/#settings/api-key)) and put it into `token` option:

```yaml
---
modules:
  blazemeter:
    token: TDknBxu0hmVnJ7NqtG2F
```

It is highly recommended to place the token setting in your personal [per-user config](CommandLine.md#configuration-files-processing) `~/.bzt-rc` to prevent it from being logged and collected in artifacts.

Now you can use `-report` command-line switch, or you can set BlazeMeter reporting as part of your config, the `test` option specifies test name to use, `project` names group of tests:

```yaml
---
reporting:
  - module: blazemeter
    report-name: Jenkins Build 1
    test: Taurus Demo
    project: Taurus Tests Group
```

Advanced settings:

```yaml
---
modules:
  blazemeter:
    address: https://a.blazemeter.com  # reporting service address
    data-address: https://data.blazemeter.com  # data service address
    browser-open: start  # auto-open the report in browser,
                         # can be "start", "end", "both", "none"
    send-interval: 30s   # send data each n-th second
    timeout: 5  # connect and request timeout for BlazeMeter API
    artifact-upload-size-limit: 5  # limit max size of file (in megabytes) that goes into zip for artifact upload, 10 by default

    # following instructions will have effect when no per-reporter settings
    report-name: My Next Test  # if you will use value 'ask', it will ask it from command line
    test: Taurus Test
    project: My Local Tests
```

Note how easy is to set report settings from command line, i.e. from inside Jenkins build step:
```bash
bzt mytest.yml -o modules.blazemeter.report-name="Jenkins Build ${BUILD_NUMBER}"
```

## JUnit XML Reporter

This reporter provides test results in JUnit xml format parsable by Jenkins [JUnit Plugin](https://wiki.jenkins-ci.org/display/JENKINS/JUnit+Plugin).
Reporter has two options:
- `filename` (full path to report file, optional. By default `xunit.xml` in artifacts dir)
- `data-source` (which data source to use: `sample-labels` or `pass-fail`)

If `sample-labels` used as source data, report will contain urls with test errors.
If `pass-fail` used as source data, report will contain Pass/Fail criterias information.

Sample configuration:

```yaml
---
reporting:
  - module: junit-xml
    filename: /path_to_file/file.xml
    data-source: pass-fail
```

## Results Reading and Aggregating Facility

Aggregating facility module is set through general settings, by default it is:

```yaml
---
settings:
  aggregator: consolidator
```

The `consolidator` has several settings:

```yaml
---
modules:
  consolidator:
    generalize-labels: false  # replace digits and UUID sequences
                              # with N and U to decrease label count
    ignore-labels: # sample labels from this list
                   # will be ignored by results reader
      - ignore
    buffer-seconds: 2  # this buffer is used to wait
                       # for complete data within a second
    percentiles:  # percentile levels to track,
                  # 0 also means min, 100 also means max
    - 0.0
    - 50.0
    - 90.0
    - 95.0
    - 99.0
    - 99.9
    - 100.0
```

Note that increasing `buffer-seconds` might sometimes make results aggregation more robust, by price of delaying analysis.

repository: anilmainali/taurus

repo_name: anilmainali/taurus


text:
---
layout: post
title: Debugging Crashlytics Installation & Launch Issues
---

Sometimes with Crashlytics beta you can run into scenarios where the application will either close immediately upon launch, or won't even install and alerts the user:

> "Unable to Download App
> _______ could not be installed at this time"

Most of the time time this is a profile issue, though there are some very specific errors which can occur either in the code or on the test device.

## For Developers
To start check to make sure it's not caused by the usual offenders:

* Building the app with the wrong provisioning profile or a profile which was revoked
* Entitlements which don't match the profile (`YourAppName.entitlements` in Xcode)
* Cached profiles in Xcode which haven't updated

Ideally provisioning profiles should be freshly downloaded followed by a project clean as part of your build process to avoid these types of issues.

### Debugging
If nothing appears to be wrong you can check the device logs when installing (assuming you have access to the device or it's logs), look for any errors coming from the `installd` process.

To check the profile of the build you can open terminal and run the following command with the path to the .mobileprovision file of the build:

`security cms -D -i /path/to/TestApp.app/embedded.mobileprovision`

To find the .app file you'll need access to the iOS App File (`*.ipa`) or the Xcode Archive. Download either if you store build ouput as part of your build process, if the project was archived on a local machine you can find the archive in: `~/Library/Developer/Xcode/Archives/<date archived>/` or by using Xcode's organizer and right-clicking the build in question.

Opening a local archive will look something like:

`$ security cms -D -i ~/Library/Developer/Xcode/Archives/<date archived>/<app name and date>.xcarchive>/Products/Aplications/<app name>.app/embedded.mobileprovision`

To open an `ipa` you'll need to `unzip` it (or you can just give it the `.zip` extension to open it in Finder). Inside you should find `/Payload/<app name>.app/embedded.mobileprovision`.

## For Testers

It's always a good idea to deploy to a test device first before sending the build notification, just to make sure everything is running smoothly. If everything seems fine but there are still issues on a test device you can try a few things:

* Delete any copies of the existing app and **restart the device**
* Make sure Crashlytics profile is installed on the device
* If it is installed delete it and download it again by tapping on the "install" button in the Crashlytics email

Here are the steps for checking/deleting a profile:

![_config.yml]({{ site.baseurl }}/images/removing-profile-step-1.png)
![_config.yml]({{ site.baseurl }}/images/removing-profile-step-2.png)
![_config.yml]({{ site.baseurl }}/images/removing-profile-step-3.png)
![_config.yml]({{ site.baseurl }}/images/removing-profile-step-4.png)


text:
Minimal examples for Stackoverflow question [How do I control (PART) numbering in gitbook TOC?](http://stackoverflow.com/questions/43688902/how-do-i-control-part-numbering-in-gitbook-toc)

Here are some iterations of currently supported heading syntaxes and how they render the toc in a gitbook.

### Would be nice if this worked:

![Do want can't have!](https://github.com/brooksambrose/bookdown-partnumbering/blob/master/partnumber/do-want-cant-have.png)

### Correct Scene numbers but incorrect Part numbers:

![](https://github.com/brooksambrose/bookdown-partnumbering/blob/master/partnumber/almost2.png)

### This doesn't help differentiate the Parts from the Scenes.

![](https://github.com/brooksambrose/bookdown-partnumbering/blob/master/partnumber/close-but-ugly.png)

### This would make sense if it worked

![](https://github.com/brooksambrose/bookdown-partnumbering/blob/master/partnumber/syntax.png)

### Indentiation is a nice effect but forces subsection numbering
![Almost but not quite](https://github.com/brooksambrose/bookdown-partnumbering/blob/master/partnumber/almost1.png?raw=true)

license: Unlicense

repository: brooksambrose/bookdown-partnumbering

repo_name: brooksambrose/bookdown-partnumbering


text:
# ZoftWhere Bolt Assertion

![Language](https://img.shields.io/github/languages/top/ZoftWhere/bolt-assertion)
[![License](https://img.shields.io/github/license/ZoftWhere/bolt-assertion)](https://github.com/ZoftWhere/bolt-assertion/blob/master/license.txt)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/ZoftWhere/bolt-assertion)
![GitHub Release Date](https://img.shields.io/github/release-date/ZoftWhere/bolt-assertion)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/ZoftWhere/bolt-assertion/master?label=master%20updated)

Bolt-on unit test assertion for program output.

## Overview

The ZoftWhere Bolt Assertion Library is a bolt-on for unit-testing. It has an elegant Java based DSL for testing the
output of a program.

## Compiling and Installing the Library

The source code can be compiled with Java language version 8. It has been tested with Oracle JDK8, JDK11 and JDK14. The
test sources, including examples, compile with JUnit \(v5.6.2\), and JDK 11.

The project is Maven based, so executing the ```mvn install``` should install the library to the local repository
\(Requires at least JDK11\). It has been tested with Apache Maven v3.6.3.

The project will package the JavaDoc archive using JDK8 rules and styles. The JavaDoc archive can be set to a later
release by specifying the ```maven.compiler.main-jdk``` property. For example, the JavaDoc will be packaged and
installed for JDK11 by calling:

``` shell script
mvn clean install -Dmaven.compiler.main-jdk=11
```

If the project needs to be installed against JDK8, it can be accomplished by calling the following Maven command:

``` shell script
mvn clean compiler:compile@main-compile-jdk8 jar:jar@main-jar source:jar@main-sources javadoc:jar@main-javadoc-jdk8 moditect:add-module-info@main-jpms install:install-file@main-install
```

## Testing the Library

The library source code can/should be tested when using Maven to package the library to a Java archive.

To check for any hidden issue, a barrage of tests can be run by running the `app.zoftwhere.bolt.BoltDelugeBarrage` test
application.

## Release Notes

The [ZoftWhere Bolt Assertion Release Notes](/main-github/release-notes) are available for
viewing/download [here](/main-github/release-notes).

## Examples

Note that the example code includes the JUnit @Test annotation. Java programmers may omit/replace these as is needed
with the unit testing-framework of their choice.

### Hello World Lambda

The bolt assertion provides a Runner instance. Here is a Hello World example:

```java
public class HelloWorldExample {

  // An immutable runner that can be reused.
  private final Runner runner = new Runner();

  @Test
  void testCase() {
    runner
        .run((Scanner scanner, PrintStream out) -> out.print("Hello World!"))
        .input()
        .expected("Hello World!")
        .assertSuccess();
  }
}
```

### Structured Command Line Programs

Java programs that need to read from an input stream, and write to a file \(based on environment variables\), can be
written for testing. The following is an example of this:

```java
public class CommandLineExample {

  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      try (PrintStream out = new PrintStream(System.getenv("OUTPUT_PATH"))) {
        run(args, scanner, out);
      }
    }
  }

  // Make a proxy method to decrease boilerplate, and simplify.
  static void run(String[] arguments, Scanner scanner, PrintStream out) {
    String name = scanner.nextLine();
    out.printf("Hello %s!%n", name);
  }
}
```

```java
public class CommandLineExampleTest {

  private final Runner runner = new Runner();

  @Test
  void testCase() {
    runner
        .run(CommandLineExample::main)
        .argument()
        .input("World")
        .expected("Hello World!", "")
        .assertSuccess();
  }
}
```

### Standard Java Output Redirection

Although it is not recommended, with the correct unit testing framework, an existing program can be run, as is, with the
standard console input/output/error stream redirected. Calling code should include resetting the input/output/error
streams afterward.

```java
public class ConsoleOutputExample {

  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      String name = scanner.nextLine();
      System.out.printf("Hello %s!%n", name);
    }
  }
}
```

```java
public class ConsoleOutputExampleTest {

  private final Runner runner = new Runner();

  /** Not Thread Safe * */
  private static RunConsoleArgued redirect(final ThrowingConsumer<String[]> program) {
    return (arguments, inputStream, outputStream) -> {
      var systemIn = System.in;
      var systemOutput = System.out;
      var systemError = System.err;

      System.setIn(inputStream);
      System.setOut(new PrintStream(outputStream));
      System.setErr(new PrintStream(outputStream));

      try {
        program.accept(arguments);
      } finally {
        System.setIn(systemIn);
        System.setOut(systemOutput);
        System.setErr(systemError);
      }
    };
  }

  @Test
  void testCase() {
    // Not Thread Safe!
    runner
        .runConsole(redirect(ConsoleOutputExample::main))
        .argument()
        .input("World")
        .expected("Hello World!", "")
        .assertSuccess();
  }

  private interface ThrowingConsumer<T> {

    void accept(T value) throws Exception;
  }
}
```

### More Examples

The source code for the [ZoftWhere Bolt Assertion Examples](/test-java/example), and more, are available for
download [here](/test-java/example).

## License

Copyright (c) 2019-2023 ZoftWhere

Licensed under the MIT License

------

repository: ZoftWhere/bolt-assertion

gha_language: Java

repo_name: ZoftWhere/bolt-assertion


text:
---
navtitle: events
---

# Tool "events"

Nikita provides a facility to publish and listen to events. An instance of the [Node.js EventEmitter](https://nodejs.org/api/events.html) class is exported and available under the `tools.events` property.

Events messages don't need to respect any particular structure unless you use an event name reserved internally by Nikita. No validation will occur.

Refers to the [`tools.log`](/current/api/tools/log/) function for a more sophisticated mechanism, it internally relies on `tools.events`. It provides context information to the event listener such as the module name where the event occurred, the logging level, etc.

## Usage

You can publish events by calling the `tools.events.emit(eventName[, ...args])` function and subscribe to those events by registering listeners with the `tools.events.on(eventName, listener)` function. The following example demonstrates it:

```js
nikita(({tools}) => {
  // Register a listener
  tools.events.on('whoami', (name) => {
    console.info(`I am ${name}`)
  })
  // Emit an event
  tools.events.emit('whoami', 'Nikita')
})
// Outputs with "I am Nikita"
```

## Available events

Certain events are automatically emitted. They correspond to the action lifecycle and provide notifications on the internal state of the Nikita session:

- `nikita:action:start`
  It is emitted right before an action handler execution.
- `nikita:action:end`
  It is emitted after the action handler has completed, whether it failed or was successful.
- `nikita:resolved`
  It is emitted once at a Nikita session when all action handlers have completed successfully.
- `nikita:rejected`
  It is emitted once at a Nikita session when an action handler has failed.

Some functionality like [logging and debugging](/current/guide/logging_debugging/) introduces their own events:

- `diff`
  Content modification. It is emitted by the `file` action.
- `stderr`
  Data string written to standard error when executing a command. It is emitted by the `nikita.execute` action to store the stderr output from the executed command.
- `stderr_stream`
  Datastream written to standard error. It is emitted by the `nikita.execute` to listen to stderr. A message `null` is emitted to indicate that the stream is closed.
- `stdin`
  Executed command. It is emitted by the `nikita.execute` action to share the executed command.
- `stdout`
  Data string written to standard output when executing a command. It is emitted by the `nikita.execute` action to store the stdout output from the executed command.
- `stdout_stream`
  Datastream written to standard output. It is emitted by the `nikita.execute` to listen to stdout. A message `null` is emitted to indicate that the stream is closed.
- `text`
  Default event when the `tools.log()` function is called.

repository: adaltas/node-nikita

gha_language: CoffeeScript

repo_name: adaltas/node-nikita


text:
Go-examples is a set of examples programing in golang with general patterns.
It's really helpful for the beginners who want to learn patterns of coding in golang.

Go-examples has the following categorys:
- **Concurrency**

- **Error handling**

- **Pipeline**

- **Functional Options**

### WeChat

The Go-examples community is also available on WeChat. If you want to join our WeChat group, send a request mail to [swiftabc@gmail.com](mailto:swiftabc@gmail.com), with your personal information that includes the following:

- WeChat ID (**Required**)
- Other basic information

We will invite you in right away.

## License

Go-examples is under the MIT license. See the [LICENSE](./LICENSE) file for details.

## Acknowledgments

- Thanks [coolshell](https://coolshell.cn/) for providing some great golang coding patterns.

repository: hecomlilong/go-examples

repo_name: hecomlilong/go-examples


text:
# [Fixed-rank matrices](@id FixedRankMatrices)

```@autodocs
Modules = [Manifolds]
Pages = ["FixedRankMatrices.jl"]
Order = [:type, :function]
```

## Literature

```@bibliography
Pages = ["manifolds/fixedrankmatrices.md"]
Canonical=false
```

gha_language: Julia


text:
# Simple Threadpool in C

This is a simple implementation of a threadpool in C. Yes, there are several of these on github, but this is my take on a simple solution of this problem.

This code has been tested on linux (it doesn't work in OSX since unnamed semaphores aren't supported).

This implementation uses semaphores for synchronisation as opposed to the mutex and conditional variable pair.

This threadpool is simple to include in any project of yours, just copy the source file and include the header file.

The threading library used here is the POSIX thread (pthreads) and queues are maintained using doubly linked lists.

There are just 3 functions in this library
* `tpool_create()` - Creates a threadpool instance and returns a pointer to the thread pool handle
* `tpool_add_job()` - Enqueues a job onto the given threadpool. An optional destructor can be provided for cleanup of the given argument
* `tpool_destroy()` - Waits for all worker threads to terminate and then destroys the given threadpool. If there are jobs remaining on the queue, the threadpool can be configured to perform the jobs before destroying the pool.

## Getting Started

To build the example code, use GNU make to build using the provided makefile.
```
make
```


text:
---
layout: creature
name: "Wood Golem"
tags: [medium, construct, cr3, tome-of-horrors]
cha: 5 (-3)
wis: 11 (+0)
int: 7 (-2)
con: 15 (+2)
dex: 10 (+0)
str: 16 (+3)
size: Medium construct
alignment: neutral
challenge: "3 (700 XP)"
languages: "understands the languages of its creator but can’t speak"
senses: "darkvision 60 ft., passive Perception 10"
damage_vulnerabilities: "fire"
damage_immunities: "cold, lightning, poison, psychic; bludgeoning, piercing, and slashing from nonmagical weapons that aren’t adamantine"
condition_immunities: "charmed, exhaustion, frightened, paralyzed, petrified, poisoned"
speed: "30 ft."
hit_points: "45 (7d8 + 14)"
armor_class: "13 (natural armor)"
---

***Alarm.*** Whenever a creature other than its creator comes within 60
feet of the golem, it releases an audible alarm sound which can
be heard out to a range of 300 feet.

***Immutable Form.*** The golem is immune to any spell or effect that
would alter its form.

***Magic Resistance.*** The golem has advantage on saving throws against
spells and other magical effects.

***Magic Weapon.*** The golem’s weapon attacks are magical.

### Actions

***Multiattack.*** The wood golem makes two slam attacks.

***Slam.*** Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 12
(2d8 + 3) bludgeoning damage.

gha_language: CSS


text:
# Keen Dashboard Builder

## Build status

[![CircleCI](https://circleci.com/gh/keen/dashboard-builder/tree/develop.svg?style=svg)](https://circleci.com/gh/keen/dashboard-builder/tree/develop)

## Install

For npm package manager

```ssh
npm install keen-dashboard-builder --save
```
For yarn
```ssh
yarn add keen-dashboard-builder
```

## Example

```javascript
const myDashboardBuilder = new DashboardBuilder({
  container: '#app-container',
  keenAnalysis: {
    config: {
      projectId: 'YOUR_PROJECT_ID',
      masterKey: 'YOUR_MASTER_KEY',
      protocol: 'https',
      host: 'api.keen.io'
    }
  },
  keenWebHost: 'keen.io' // optional, the default is window.location.host
});
```

## React component

https://github.com/keen/react-dashboards

## npm scripts

List of useful commands that could be used by developers.

| Command               | Description                                                                       |
| --------------------- | --------------------------------------------------------------------------------- |
| `lint`                | run linter against current application codebase.                                  |
| `test`                | run unit tests against current application codebase.                              |
| `circular`            | run scripts responsible for the detection of circular dependencies between files. |
| `commit`              | run commit command line interface.                                                |
| `prettier`            | run code formatter process against current codebase.                              |

## commit

This project uses [Conventional Commits](https://www.conventionalcommits.org) to enforce common commit standards.

repository: siddique-ahmed-cowlar/dashboard-builder

repo_name: siddique-ahmed-cowlar/dashboard-builder


text:
---
layout: default
---

# 1998-01-25 - Re: Burning papers

## Header Data

From<EMAIL_ADDRESS>(Igor Chudov @ home)

To<EMAIL_ADDRESS>(Bill Stewart)

Message Hash: 1f90d3466faea8b48e38a7de05ee7b069949d3a7f395e905d1ac580fb79bfae1

Message ID<EMAIL_ADDRESS>Reply To<EMAIL_ADDRESS>UTC Datetime: 1998-01-25 20:14:27 UTC

Raw Date: Mon, 26 Jan 1998 04:14:27 +0800

## Raw message

```
{% raw  %}From<EMAIL_ADDRESS>(Igor Chudov @ home)
Date: Mon, 26 Jan 1998 04:14:27 +0800
To<EMAIL_ADDRESS>(Bill Stewart)
Subject: Re: Burning papers
In-Reply-To<EMAIL_ADDRESS>Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text

Bill Stewart wrote:
> Of course, if your documents are on floppy disks, any shredder that
> won't jam on them does a pretty good job :-)

I burned a couple of floppies, too. Actually I am not sure how good job
would shredding of floppies do. I assume that bits and pieces of data
can still be recovered... But hopefully no one would care enough.

	- Igor.

{% endraw %}
```

## Thread

+ Return to [January 1998](/archive/1998/01)

+ Return to "[Bill Stewart <bill.stewart@pobox.com>](/authors/bill_stewart_bill_stewart_at_pobox_com_)"
+ Return to<EMAIL_ADDRESS>(Igor Chudov @ home)](/authors/ichudov_at_algebra_com_igor_chudov__at__home_)"
+ Return to "[Kent Crispin <kent@songbird.com>](/authors/kent_crispin_kent_at_songbird_com_)"
+ Return to<EMAIL_ADDRESS>(Anonymous)](/authors/nobody_at_replay_com_anonymous_)"
+ Return to "["Uhh...this is Joe [Randall Farmer]" <rfarmer@HiWAAY.net>](/authors/uhh_this_is_joe_randall_farmer_rfarmer_at_hiwaay_net_)"

+ 1998-01-25 (Mon, 26 Jan 1998 02:23:45 +0800) - [Burning papers](/archive/1998/01/077b9d4bcf8a70d0cac4f7fc5d1d5af96d072fcdc7c83d2cbdb1da5e3b19ee8b) -<EMAIL_ADDRESS>(Igor Chudov @ home)_
  + 1998-01-25 (Mon, 26 Jan 1998 04:04:26 +0800) - [Re: Burning papers](/archive/1998/01/e73291418920c195067367718c803d2efef9bbc07e751cc1e6ac03a490ab763e) - _Bill Stewart<EMAIL_ADDRESS>    + 1998-01-25 (Mon, 26 Jan 1998 04:14:27 +0800) - Re: Burning papers -<EMAIL_ADDRESS>(Igor Chudov @ home)_
      + 1998-01-28 (Thu, 29 Jan 1998 06:06:35 +0800) - [Predicting cipher life / NSA rigged DES? / Destroying encrypted data (Tangent to Re: Burning papers)](/archive/1998/01/3e4587a8ed019b2311ce8facbbcdca674f043aa0bfe62221616646fcb5848154) - _"Uhh...this is Joe [Randall Farmer]"<EMAIL_ADDRESS>    + 1998-01-26 (Mon, 26 Jan 1998 11:04:54 +0800) - [Re: Burning papers](/archive/1998/01/4a8d7c1077fdaf2339381269349373d0c0e478d474f0e9c5af4c0844764cff50) -<EMAIL_ADDRESS>(Anonymous)_
  + 1998-01-26 (Mon, 26 Jan 1998 16:26:21 +0800) - [Re: Burning papers](/archive/1998/01/62a7bdf4f3901391852143cb73e4d89c649281c66387a3acd1d2e1f8368b8076) - _Kent Crispin<EMAIL_ADDRESS>


text:
# Update
You can get features from the public repo by doing a pull request from the base repo.

# Deploy

Manual for now.  remember to upgrade version

export version=v1.0.5
docker build . -t eu.gcr.io/akbm-infrastructure/mssql-to-bq:${version}
docker push eu.gcr.io/akbm-infrastructure/mssql-to-bq:${version}

# Config.yaml template and secret template
Note that the first three dashes are important.
```yaml
---
  db_username: the_username
  db_password: the_password
  db_host: <IP_ADDRESS>
  db_database: thedb
```

# SM secrets tutorial
First make sure you can create and access secrets, or have a SA that can do it.
## To Get the SECRETMANAGER_URI
- To to cloud console
- https://console.cloud.google.com/security/secret-manager/secret/jeeves-db-credentials/versions?project=akbm-infrastructure
- click the three dots, copy resource id:
- For Jeeves this is: projects/483261958633/secrets/jeeves-db-credentials/versions/1

Set the SECRETMANAGER_URI environment variable to that value and you are good to go.

## Creating secrets
- secretmanager, clikc create secret
- in the "secret value" input the 5 lines from the template.  Replace values as needed.
- leave rest to default.

repository: AkerBioMarine/sqlserver-to-bigquery

repo_name: AkerBioMarine/sqlserver-to-bigquery