text:
## gitlab-irc

[![Build Status](https://travis-ci.org/nTraum/gitlab-irc.png?branch=master)](https://travis-ci.org/nTraum/gitlab-irc)
[![Dependency Status](https://gemnasium.com/nTraum/gitlab-irc.svg)](https://gemnasium.com/nTraum/gitlab-irc)

Tiny web / IRC application that announces commits for GitLab repositories via IRC.
Built with Sinatra and cinch. Uses GitLab's web hooks, no voodoo required.

Example message:

> [gitlab-irc(master)] nTraum | initial commit | [http://goo.gl/yYTGcM](http://goo.gl/yYTGcM)

### Requirements

* Redis (already installed if you run it on the same host as GitLab)
* Ruby 1.9.3 or newer (JRuby / Rubinius will do the job as well)
* (tmux / screen / nohup)

### Installation & Usage

1. Clone the repository: `git clone https://github.com/nTraum/gitlab-irc.git`
2. Install required gems: `cd gitlab-irc; gem install bundler; bundle`
2. Edit `config/config.yml` to your needs (e.g. IRC channel and server)
3. Start the app: `foreman start` in a tmux / screen shell
4. Add a web hook pointing to the app: `http://localhost:4567/commit` (host / port may differ, depending on your configuration)

### License

gitlab-irc is released under the [MIT License](http://opensource.org/licenses/MIT).

repository: nTraum/gitlab-irc

repo_name: nTraum/gitlab-irc


text:
## Instructions / Notes for developers

### Example of setting up your sources on OSX

[source file](setup)

### Writing a new Node

A Node-RED node is composed of 2 components:

- the UI component used in the UI / Editor
- the executing component running on the server

Note the actual node code executes only on the server, the UI/Editor node part is only to represent your node, connections, etc... in the Visual Programming editor, but do not run any code logic.

#### The WEB Browser / Editor node component

[forge-wait-and-go.html](../forge-wait-and-go.html#L24) is where you define the UI for the parameters' panel. It really consist of rows of control.

[forge-wait-and-go.html](../forge-wait-and-go.html#L42) is where you register your node, and define default values for all the parameters.

[forge-wait-and-go.html](../forge-wait-and-go.html#L60) the label() function is to display text on the flow graph representation.

Other functions could be:

	// oneditprepare is called immediately before the dialog is displayed.
	// oneditsave is called when the edit dialog is okayed.
	// oneditcancel is called when the edit dialog is cancelled.
	// oneditdelete is called when the delete button in a configuration node’s edit dialog is pressed.
	// oneditresize is called when the edit dialog is resized.

There is a special control available: typedInput, which can handle special treatment 'flow', 'global', 'str', 'env', ...

#### The executing Node-RED node

[forge-wait-and-go.js](../forge-wait-and-go.js#L76) is where you register your node, and the callback function to create instance of your node when flow are executed.

[forge-wait-and-go.js](../forge-wait-and-go.js#L25) is the callback function mentioned above.

[forge-wait-and-go.js](../forge-wait-and-go.js#L26) instanciate a node.

```RED.nodes.getNode(n.forge);``` would gave you access to the instance' parameters.

[forge-wait-and-go.js](../forge-wait-and-go.js#L72) is where you register a callback for anytime there is a value coming in your instance node.

[forge-wait-and-go.js](../forge-wait-and-go.js#L43) is where you return the result after running your instance code / parameter.

#### Registering your node in Node-RED

This is done in your [package.json](../package.json#L24) file. What is important is that the names used in the ```RED.nodes.registerType()``` calls in the html and js files must all match with the one used here.

#### Localization principles

Mainly for the UI component and is a set of 2 files [in this folder](../locales/en-US)

- the [html file](../locales/en-US/forge-wait-and-go.html) is used to display information about the node in the editor.

- the [json file](../locales/en-US/forge-wait-and-go.json) is the catalog of UI messages / labels for controls, etc... It use the i18n library to render the messages in the UI.

#### Forge specific implementation

One downside in Node-RED today is that copying nodes, or instancing subflows reset the crendentials parameter. And it is not really easy / convenient to reinitialize all the node' credentials. Moreover, if a subflow is instantiated multiple times, you may want to use different credentials for each of them, and that's not possible. Last, Node-RED does not allow retrieving flows' ID during initialization.

For that reason, the Forge nodes accepts an additional parameter 'nodeFlowId', and/or a default flow credential setup.

When using the 'nodeFlowId', a node will try to retrieve a default 'forge-default-credentials' node sitting within the same flow as the node is running into. If that 'nodeFlowId' parameter is missing, the node will try to find any initialized 'forge-default-credentials' node.

The 'nodeFlowId' parameter is handled [here](../forge-oss.js#L45), and the 'forge-default-credentials' [here](../forge-oss.js#L63).

### VS Code configuration example

```
{
	"name": "Launch Program",
	"type": "node",
	"request": "launch",
	"cwd": "${workspaceFolder}/../node-red",
	"program": "${workspaceFolder}/../node-red/packages/node_modules/node-red/red.js",
	//"port": 9229,
	// "runtimeArgs": [
	//     "--preserve-symlinks"
	// ],
	"args": [
		"--userDir", "~/Projects/node-red/cyrille"
	],
	"env": {
		"NODE_ENV": "development"
		//"FORGE_CLIENT_ID": "cyrille-noderd-test2"
	}
}
```

## Additional material

There is a video available [here](.) which goes thought the POC / concept implementation.

license: MIT

repository: cyrillef/node-red-node-forge

branch_name: refs/heads/master

extension: md

gha_language: HTML

gha_license_id: MIT

license_type: permissive

repo_name: cyrillef/node-red-node-forge


text:
<!--
title: 'Serverless Framework Node Express API on AWS'
description: 'This template demonstrates how to develop and deploy a simple Node Express API running on AWS Lambda using the traditional Serverless Framework.'
layout: Doc
framework: v3
platform: AWS
language: nodeJS
priority: 1
authorLink: 'https://github.com/serverless'
authorName: 'Serverless, inc.'
authorAvatar: 'https://avatars1.githubusercontent.com/u/13742415?s=200&v=4'
-->

# Serverless Framework Node Express API on AWS

This template demonstrates how to develop and deploy a simple Node Express API service running on AWS Lambda using the traditional Serverless Framework.

## Anatomy of the template

This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).

## Usage

### Deployment

Install dependencies with:

```
npm install
```

and then deploy with:

```
serverless deploy
```

After running deploy, you should see output similar to:

```bash
Deploying aws-node-express-api-project to stage dev (us-east-1)

✔ Service deployed to stack aws-node-express-api-project-dev (196s)

endpoint: ANY - https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com
functions:
  api: aws-node-express-api-project-dev-api (766 kB)
```

_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/).

### Invocation

After successful deployment, you can call the created application via HTTP:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
```

Which should result in the following response:

```
{"message":"Hello from root!"}
```

Calling the `/hello` path with:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/hello
```

Should result in the following response:

```bash
{"message":"Hello from path!"}
```

If you try to invoke a path or method that does not have a configured handler, e.g. with:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/nonexistent
```

You should receive the following response:

```bash
{"error":"Not Found"}
```

### Local development

It is also possible to emulate API Gateway and Lambda locally by using `serverless-offline` plugin. In order to do that, execute the following command:

```bash
serverless plugin install -n serverless-offline
```

It will add the `serverless-offline` plugin to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`.

After installation, you can start local emulation with:

```
serverless offline
```

To learn more about the capabilities of `serverless-offline`, please refer to its [GitHub repository](https://github.com/dherault/serverless-offline).

repository: serverless/examples

gha_language: JavaScript

gha_license_id: NOASSERTION

repo_name: serverless/examples


text:
---
layout: post
title: Rally Trophy rally driving game
category: simulation
image: /pics/rallytrophy.jpg
---

Getting Rally Trophy to run on Windows 8

[Rally Trophy][rtw] by *BugBear Entertainment* and *JoWooD Productions* is the best rally driving simulation I have ever played.
These days it is available as a [free download][rt] on *oldpcgaming.net*. You can run the game in Windows XP compatibility mode.

Note that in order to be able to configure the joystick and keyboard controls, you need to install [Microsoft DirectInput Mapper][di].

There is a code to unlock all cars, tracks, and modes. Just enter **KALJAKOPPA** as your name in the game menu. It will clear the name and then you can enter your normal player name.

I didn't manage to get it to work under *GNU/Linux* using *Wine*. Also I haven't looked into the [modifications][ng] available for it.

Enjoy!

**Update:**

One can get the [modifications][ng] running using the [RTBZFManager.exe][man] tool.
Note that you need to configure the program to run in *Windows XP compatibility mode* otherwise it will silently fail to install game modifications. Also you need to change the settings so that it will export modifications to the data folder. For example:

{% highlight text %}
C:\Program Files (x86)\JoWooD\Rally Trophy\Data
{% endhighlight %}

Now if you for example install the [VW Käfer][beetle] RTP file, it should create a folder named *car_3* next to the *car_3.bzf* file in the *Data\\Cars* folder.

Another distinct looking car is the [Citroën DS3][dm].

In terms of handling the [Peugeot 206][pg] is great fun.

Another really responsive car to drive is the [Porsche 911][po].

**See also:**

* [Rally Trophy review and download][rt]
* [PC Gaming Wiki][pcgw]
* [Microsoft DirectInput Mapper][di]
* [Rally Trophy cheat code][ch]
* [No Grip Racing: Rally Trophy downloads][ng]
* [VW Beetle][beetle]
* [Citroën DS3][dm]
* [Peugeot 206][pg]
* [Porsche 911 SC RS][po]

[rt]: http://www.oldpcgaming.net/rally-trophy-review/
[pcgw]: https://pcgamingwiki.com/wiki/Rally_Trophy
[di]: https://community.pcgamingwiki.com/files/file/58-microsoft-directinput-mapper/
[rtw]: https://en.wikipedia.org/wiki/Rally_Trophy
[ch]: http://uk.ign.com/wikis/pc-cheats/Rally_Trophy_Cheats
[ng]: http://www.nogripracing.com/files.php?maincat=1
[man]: http://www.nogripracing.com/details.php?filenr=119
[beetle]: http://www.nogripracing.com/details.php?filenr=47
[dm]: http://www.nogripracing.com/details.php?filenr=3598
[pg]: http://www.nogripracing.com/details.php?filenr=139
[po]: http://www.nogripracing.com/details.php?filenr=741


text:
# Features and rewards
## Features:
### Done:
- Currently making changes to how we approach features.
    - Every feature should return values in relation to State and Action

### Not done:
- Robot driving into walls
- Robot is within dropZone
- Robot getting closer to debris
- Robot is ready to pickup debris
- Robot has debris in shovel
- Robot with debris getting closer to dropzone

---------------------

## Rewards:
### Done:
#### Positive rewards:
- Debris in dropzone
- Locate debris
- Debris in shovel
- Debris in shovel and going to dropzone
- Drive towards debris

#### Negative rewards:
- Drop debris outside of dropzone
- Debris rolls out of dropzone
- Time passing
- Drive into walls

### Other simulation implementation
- Reset simulation if robot is flipped

### Not Done
- NONE


text:
# NAME
count - count the elements that satisfy the condition.

# SYNOPSIS

    (count FN LIST)

# DESCRIPTION
The function `count` count the elements that satisfy the predicate.

# RETURN VALUE
Returns the number of elements in the `LIST` that satisfy the predicate function `FN`.

# NOTES

    (count fn lis) <=> (len (select fn lis))

# EXAMPLES

    ) (count even? (.. 10))
    5
    ) (count odd? (.. 10))
    5
    ) (count zero? (.. 10))
    1

# SEE ALSO
- `len(3)`
- `select(3)`

repository: mukaiizawa/Paren

gha_language: OpenEdge ABL

repo_name: mukaiizawa/Paren


text:
# form.js: HTML5 Form Functionality

A form using HTML5 form elements, that validates both client- and server-side and stores the entries in XML.

Please note that the PHP form was created for demonstration purposes only.

## How to include the script

The stylesheet is best included in the header of the document.

```html
<link rel="stylesheet" href="css/form.css"/>
```

This include can be added to the header or placed inline before the script is invoked.

```html
<script src="lib/positions.js"></script>
<script src="lib/transitions.js"></script>
<script src="js/form.js"></script>
```

Or use [Require.js](https://requirejs.org/).

```js
requirejs([
	'lib/positions.js',
	'lib/transitions.js',
	'js/form.js'
], function(positions, transitions, Form) {
	...
});
```

Or import into an MVC framework.

```js
var positions = require('lib/positions.js');
var transitions = require('lib/transitions.js');
var Form = require('js/form.js');
```

## How to start the script

```javascript
var form = new Form({
	'element' : document.getElementById('id'),
	'input' : 'input, select, textarea',
	'output' : 'div.summary',
	'message' : '<div class="failure"><h3>Please correct the following problem(s):</h3>{0}</div>'
});
```

**id : {string}** - The ID attribute of an element somewhere in the document.

**input : {string}** - A CSS Rule that describes the form elements.

**output : {string}** - A CSS Rule that describes the output area.

**message : {string}** - An HTML template for a validation error message.

## How to control the script

### Focus

```javascript
form.validateForm();
```

Performs the form validation manually.

## How to build the script

This project uses node.js from http://nodejs.org/

This project uses gulp.js from http://gulpjs.com/

The following commands are available for development:
+ `npm install` - Installs the prerequisites.
+ `gulp import` - Re-imports libraries from supporting projects to `./src/libs/` if available under the same folder tree.
+ `gulp dev` - Builds the project for development purposes.
+ `gulp dist` - Builds the project for deployment purposes.
+ `gulp watch` - Continuously recompiles updated files during development sessions.
+ `gulp serve` - Serves the project on a temporary web server at http://localhost:8500/.
+ `gulp php` - Serves the project on a temporary php server at http://localhost:8500/.

## License

This work is licensed under a [MIT License](https://opensource.org/licenses/MIT). The latest version of this and other scripts by the same author can be found on [Github](https://github.com/WoollyMittens) and at [WoollyMittens.nl](https://www.woollymittens.nl/).

repository: WoollyMittens/useful-form

repo_name: WoollyMittens/useful-form


text:
## Exercise 1-8

Identify the errors in this Java fragment and repair it by rewriting with an idiomatic loop:

```Java
int count = 0;
while (count < total) {
    count++;
    if (this.getName(count) == nameTable.userName()) {
        return (true);
    }
}
```

## Solution

The `getName()` function seems to be the sort of function that receives an offset index in an array (or equivalent data structure) to retrieve the corresponding entry; if that's the case, then there is an off-by-one error because `count` is incremented before, thus accessing the array one position past the end. `count` doesn't seem to be a good name choice, it is in fact used as an array index. This function is simply traversing an array-like data structure to check if a given name exists. Single letter variable names such as `i` or `j` are enough for this.

Using an idiomatic loop not only fixes the off-by-one error, but also scopes the control variable to the loop construct, and makes the code easier to read.

```Java
for (int i = 0; i < total; i++) {
    if (this.getName(i) == nameTable.userName()) {
        return true;
    }
}
```

repository: filipegoncalves/tpop

repo_name: filipegoncalves/tpop


text:
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [CSSUsage](#cssusage)
    -   [start](#start)
    -   [stop](#stop)
    -   [toggle](#toggle)
    -   [oneshot](#oneshot)
    -   [createEditorReport](#createeditorreport)
    -   [createEditorReportForSheet](#createeditorreportforsheet)
    -   [createPageReport](#createpagereport)

## CSSUsage

**Extends Actor**

CSSUsage manages the collection of CSS usage data.
The core of a CSSUsage is a JSON-able data structure called \_knownRules
which looks like this:
This records the CSSStyleRules and their usage.
The format is:
    Map({
      <CSS-URL>\|<START-LINE>\|<START-COLUMN>: {
        selectorText: <CSSStyleRule.selectorText>,
        test: <simplify(CSSStyleRule.selectorText)>,
        cssText: <CSSStyleRule.cssText>,
        isUsed: <TRUE|FALSE>,
        presentOn: Set([ <HTML-URL>, ... ]),
        preLoadOn: Set([ <HTML-URL>, ... ]),
        isError: <TRUE|FALSE>,
      }
    })

For example:
    this.\_knownRules = Map({
      "<http://eg.com/styles1.css|15|0">: {
        selectorText: "p.quote:hover",
        test: "p.quote",
        cssText: "p.quote { color: red; }",
        isUsed: true,
        presentOn: Set([ "http://eg.com/page1.html", ... ]),
        preLoadOn: Set([ "http://eg.com/page1.html" ]),
        isError: false,
      }, ...
    });

### start

Begin recording usage data

**Parameters**

-   `url` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** It's best if we start by reloading the current page
                                  because that starts the test at a known point, but there could be reasons
                                  why we don't want to do that (e.g. the page contains state that will be
                                  lost across a reload) (optional, default `false`)

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### stop

Cease recording usage data

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### toggle

Start/stop recording usage data depending on what we're currently doing.

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### oneshot

Running start() quickly followed by stop() does a bunch of unnecessary work, so this cuts all that out

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### createEditorReport

Returns a JSONable structure designed to help marking up the style editor,
which describes the CSS selector usage.
Example:
[
    {
        selectorText: "p#content",
        usage: "unused|used",
        start: { line: 3, column: 0 },
    },
    ...
]

**Parameters**

-   `url` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** url of page you want to audit

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### createEditorReportForSheet

Compute the stylesheet URL and delegate the report creation to createEditorReport.
See createEditorReport documentation.

**Parameters**

-   `url` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** url of page you want to audit

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

### createPageReport

Returns a JSONable structure designed for the page report which shows
the recommended changes to a page.

"preload" means that a rule is used before the load event happens, which
means that the page could by optimized by placing it in a <style> element
at the top of the page, moving the <link> elements to the bottom.

Example:
  {
    preload: \[
      {
        url: "<http://example.org/page1.html">,
        shortUrl: "page1.html",
        rules: [
          {
            url: "http://example.org/style1.css",
            shortUrl: "style1.css",
            start: { line: 3, column: 4 },
            selectorText: "p#content",
            formattedCssText: "p#content {\n  color: red;\n }\n"
         },
         ...
        ]
      }
    ],
    unused: \[
      {
        url: "<http://example.org/style1.css">,
        shortUrl: "style1.css",
        rules: [ ... ]
      }
    ]
  }

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** request response

repository: saucelabs/foxdriver

branch_name: refs/heads/main

repo_name: saucelabs/foxdriver


text:
## Enhancing Pharmacovigilance with Drug Reviews and Social Media

### Brent Biseda and Katie Mo
### Spring 2020

This project was completed for the class MIDS W266 Natural Language Processing with Deep Learning.

**Abstract**

This paper explores whether the use of drug reviews and social media could be leveraged as potential alternative sources for pharmacovigilance of adverse drug reactions (ADRs). We examined the performance of BERT (Devlin et al., 2018) alongside two variants that are trained on biomedical papers, BioBERT (Jinhyuk et al., 2019), and clinical notes, Clinical BERT (Alsentzer et al., 2019).  A variety of 8 different BERT models were fine-tuned and compared across three different tasks in order to evaluate their relative performance to one another in the ADR tasks. The tasks include sentiment classification of drug reviews, presence of ADR in twitter postings, and named entity recognition of ADRs in twitter postings. BERT demonstrates its flexibility with high performance across all three different pharmacovigilance related tasks.

**Tasks**

- [Sentiment Classification of Drug Reviews](./task1_sentiment)
- [ADR Classification of Tweets](./task2_adr)
- [Named entity recognition of ADRs in Tweets](./task3_ner)

**Deliverables**

- [Final Project Paper](https://github.com/brentbiseda/w266_project/blob/master/W266%20Final%20Project%20Paper.pdf)
- [Final Project Presentation](https://github.com/brentbiseda/w266_project/blob/master/W266%20Final%20Project%20Presentation%20Slides.pdf)

**Datasets**

- [Drug reviews](https://archive.ics.uci.edu/ml/datasets/Drug+Review+Dataset+%28Drugs.com%29)
- [ADRs in Twitter](http://diego.asu.edu/Publications/ADRMine.html)

**Github References**

- [BERT](https://github.com/google-research/bert)
- [BioBERT](https://github.com/dmis-lab/biobert)
- [clinicalBERT](https://github.com/EmilyAlsentzer/clinicalBERT)
- [clinical-BioBERT](https://github.com/arnavbhandari/clinical-BioBERT)

## Installation

#### CUDA Install

cuda_10.0.130_411.31_win10.exe

#### Pip install

pip install --upgrade pip
pip install -r requirements.txt

#### Start up Tensorboard and set directory

tensorboard --logdir ../output

Go to Tensorboard location: http://localhost:6006


text:
# Example

Generate a What's New page using the HTML structure and the CSS from the [GitHub
  Desktop web site](https://desktop.github.com).

repository: osteele/changelog-parser

repo_name: osteele/changelog-parser


text:
# Tower Defense

Tower Defense Game developed over 4 days using phaser framework. Users can place walls and towers. Click play and runners move across board. Towers auto target and auto shoot based on type. Gold is accumulated to purchase more towers.
It is a survival game in which the goal is to eliminate all runners before they exit the map.

### Support and Contact Details

* Github for Joshua Rinard: https://github.com/jrinard

* Email<EMAIL_ADDRESS>

# Setup
  download project
  cd project directory
```
  npm install
  npm install grunt -global
```

# Run App in terminal
```
  grunt
```

# Development Team
Joshua Rinard, Bryant Wang, Erik Killops, and Annie Sonna

### License

MIT

Copyright (c) 2016 Joshua Rinard

repository: jrinard/tower-defense

repo_name: jrinard/tower-defense


text:
### [CVE-2022-1334](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1334)
![](https://img.shields.io/static/v1?label=Product&message=WP%20YouTube%20Live&color=blue)
![](https://img.shields.io/static/v1?label=Version&message=1.8.3%3C%201.8.3%20&color=brighgreen)
![](https://img.shields.io/static/v1?label=Vulnerability&message=CWE-79%20Cross-site%20Scripting%20(XSS)&color=brighgreen)

### Description

The WP YouTube Live WordPress plugin before 1.8.3 does not validate, sanitise and escape various of its settings, which could allow high privilege users such as admin to perform Cross-Site Scripting attacks even when unfiltered_html is disallowed

### POC

#### Reference
No PoCs from references.

#### Github
- https://github.com/ARPSyndicate/cvemon

repository: trickest/cve

repo_name: trickest/cve


text:
---
title: GenericScan
permalink: GenericScan.html
layout: wiki
---

Generic Scan Instrument
-----------------------

This is a DTD for an example generic instrument which performs scans.
This example is for an omega-two-theta (rotation\_angle polar\_angle in
NeXus notation) scan and serves to highlight NeXus scan data storage
principles:

-   Assume np to be the number of scan points
-   Variable data (such as motors) which can vary during the scan are
    stored as arrays of length np at their proper place in the
    NXinstrument hierarchy.
-   In NXdata links to all varied positions and the dectector counts are
    created. This provides for easy access to the popular table format
    for scans.
-   In the case of multi dimensional detectors, the PSD data must be
    stored with the scan variable being the fastest varying
    dimension(the first) for technical reasons.
-   If you to choose to store PSD scans in separate files or separate
    entries, it is the users responsibility to process the data in the
    right order.

<!-- -->

    <?xml version="1.0" ?>
    <!--
    URL: http://www.neutron.anl.gov/nexus/xml/NXscan.xml
    Editor: Mark Koennecke
    Version: October 2006

    Instrument Definition example for a simple two axis scan. This example is for
    an omega-two-theta (rotation_angle polar_angle in NeXus notation)
    scan and serves to highlight NeXus scan data storage principles:
    - Assume np to be the number of scan points
    - Variable data (such as motors) which can vary during the scan are stored as arrays of length np at
      their proper place in the NXinstrument hierarchy.
    - In NXdata links to all varied positions and the dectector counts are created. This
      provides for easy access to the popular table format for scans.
    - In the case of multi dimensional detectors, the PSD data must be stored with the scan
      variable being the fastest varying dimension(the first) for technical reasons.
    - If you to choose to store PSD scans in separate files or separate entries, it is the users
      responsibility to process the data in the right order.

    Note:
    This example is fairly minimal. Feel free to add whatever you think necessary. However, if
    items are missing which are required for standard data reduction tasks, please consult the
    editor of this example.

    -->

    <NXroot>
       <NXentry name="{Entry name}">+
            <title>{Extended title for entry}</title>
            <NXsample name="{sample}">
                <name>{Descriptive name of sample}</name>
                <environment>{Type of sample environment}</environment>
                <polar_angle type="NX_FLOAT32[np]">
                   {polar_angle to monochromator}
                </polar_angle>
                <rotation_angle type="NX_FLOAT32[np]">
                   { sample rotation}
                </rotation_angle>
            </NXsample>
            <NXinstrument name="{name}">
                <name>{name of instrument}</name>
                <NXsource name="{name}">
                    <name>{name of facility}</name>

                    <type>"Reactor"</type>
                    <power units="MW" type="NX_FLOAT32">{reactor power}</power>
                </NXsource>
                <NXcrystal name="monochromator">
                    <wavelength units="Angstrom" type="NX_FLOAT32[np]">
                      {wavelength at each scan position}
                    </wavelength>
                </NXcrystal>
                <NXdetector name="primary">
                  <data type="NX_INT32[np]" signal="1">
                    {Detector counts for each scan position}
                  </data>
                  <polar_angle type="NX_FLOAT32[np]" axis="1">
                     {polar angle for each scan position}
                  </polar_angle>
                </NXdetector>
            </NXinstrument>
            <NXmonitor name="control">
               <mode type="NX_CHAR">monitor | timer</mode>
               <preset type="NX_FLOAT32">
                  {preset value for monitor or timer}
                </preset>
                <data type="NX_INT32[np]">
                   {Monitor counts for each scan position}
                </data>
            </NXmonitor>
            <NXdata name="{data}">
                <data type="NX_INT32[np]" signal="1">
                  {Link to detector counts}
                </data>
                <polar_angle axis="1" primary="2">
                  {Link to detector polar_angle}
               </polar_angle>
               <rotation_angle axis="1" primary="1">
                  {Link to sample rotation_angle}
               </rotation_angle>
            </NXdata>
        </NXentry>
    </NXroot>

repository: nexusformat/wiki

gha_language: CSS

repo_name: nexusformat/wiki


text:
# test Docker

All Docker tests, tutorials and examples

:link:[docs.docker.com/get-started](https://docs.docker.com/get-started/part2/#build-the-app)

# Table of Contents

- [**Docker Overview**](#docker-overview)
  - [Docker Engine](#docker-engine)
  - [Docker Architecture](#docker-architecture)
- [**The Underlying Technology**](#the-underlying-technology)
  - [Namespaces](#namespaces)
- [**Dockerfile Reference**](#dockerfile-reference-link)
  - [FROM](#from-dockerfile-reference)
  - [RUN](#run-dockerfile-reference)
  - [CMD](#cmd-dockerfile-reference)
  - [LABEL](#label-dockerfile-reference)
  - [EXPOSE](#expose-dockerfile-reference)
  - [ENV](#env-dockerfile-reference)
  - [ADD](#add-dockerfile-reference)
  - [COPY](#copy-dockerfile-reference)
  - [ENTRYPOINT](#entrypoint-dockerfile-reference)
  - [VOLUME](#volume-dockerfile-reference)
  - [USER](#user-dockerfile-reference)
  - [WORKDIR](#workdir-dockerfile-reference)
  - [ARG](#arg-dockerfile-reference)
  - [ONBUILD](#onbuild-dockerfile-reference)
  - [STOPSIGNAL](#stopsignal-dockerfile-reference)
  - [HEALTHCHECK](#healthcheck-dockerfile-reference)
  - [SHELL](#shell-dockerfile-reference)
- [**Compose file version 3 reference**](#compose-file-version-3-reference-link)
  - [Service configuration reference](#service-configuration-reference-link)
    - [build](#build-link)
    - [cap\_add, cap\_drop](#cap_add-cap_drop-link)
    - [command](#command-link)
    - [configs](#configs-link)
    - [cgroup\_parent](#cgroup_parent-link)
    - [container\_name](#container_name-link)
    - [credential\_spec](#credential_spec-link)
    - [deploy](#deploy-link)
    - [devices](#devices-link)
    - [depends\_on](#depends_on-link)
    - [dns](#dns-link)
    - [dns\_search](#dns_search-link)
    - [tmpfs](#tmpfs-link)
    - [entrypoint](#entrypoint-link)
    - [env\_file](#env_file-link)
    - [environment](#environment-link)
    - [expose](#expose-link)
    - [external\_links](#external_links-link)
    - [extra\_hosts](#extra_hosts-link)
    - [healthcheck](#healthcheck-link)
    - [image](#image-link)
    - [isolation](#isolation-link)
    - [labels](#labels-link)
    - [links](#links-link)
    - [logging](#logging-link)
    - [network\_mode](#network_mode-link)
    - [networks](#networks-link)
    - [pid](#pid-link)
    - [ports](#ports-link)
    - [secrets](#secrets-link)
    - [security\_opt](#security_opt-link)
    - [stop\_grace\_period](#stop_grace_period-link)
    - [stop\_signal](#stop_signal-link)
    - [sysctls](#sysctls-link)
    - [ulimits](#ulimits-link)
    - [userns\_mode](#userns_mode-link)
    - [volumes](#volumes-link)
    - [restart](#restart-link)
  - [Specifying durations](#specifying-durations-link)
  - [Specifying byte values](#specifying-byte-values-link)
  - [Volume configuration reference](#volume-configuration-reference-link)
    - [driver](#driver-link)
    - [driver\_opts](#driver_opts-link)
    - [external](#external-link)
    - [labels](#labels-link)
    - [name](#name-link)
  - [Network configuration reference](#network-configuration-reference-link)
    - [driver](#driver-link)
    - [driver\_opts](#driver_opts-link)
    - [attachable](#attachable-link)
    - [enable\_ipv6](#enable_ipv6-link)
    - [ipam](#ipam-link)
    - [internal](#internal-link)
    - [labels](#labels-link)
    - [external](#external-link)
    - [name](#name-link)
  - [configs configuration reference](#configs-configuration-reference-link)
  - [secrets configuration reference](#secrets-configuration-reference-link)
  - [Variable substitution](#variable-substitution-link)
  - [Extension fields](#extension-fields-link)
- [**Recap and cheat sheet**](#recap-and-cheat-sheet)
  - [Containers](#containers)
  - [Services](#services)
  - [Swarms](#swarms)
  - [Stacks](#stacks)

# Docker Overview

[_Back to TOC_](#table-of-contents)

## Docker Engine

Docker Engine is a client-server application with these major components:

* A server which is a type of long-running program called a daemon process (the dockerd command).
* A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
* A command line interface (CLI) client (the docker command).

![engine-components-flow](https://raw.githubusercontent.com/quanpan302/test/master/t00-Docker/engine-components-flow.png)

[_Back to TOC_](#table-of-contents)

## Docker Architecture

Docker uses a client-server architecture.

The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers.

The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon.

The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface.

<img src="https://raw.githubusercontent.com/quanpan302/test/master/t00-Docker/architecture.svg?sanitize=true">

[_Back to TOC_](#table-of-contents)

# The Underlying Technology

Docker is written in `Go` and takes advantage of several features of the Linux kernel to deliver its functionality.

[_Back to TOC_](#table-of-contents)

## Namespaces

Docker uses a technology called namespaces to provide the isolated workspace called the container.
When you run a container, Docker creates a set of namespaces for that container.

Docker Engine uses namespaces such as the following on Linux:

* **The `pid` namespace**: Process isolation (PID: Process ID).
* **The `net` namespace**: Managing network interfaces (NET: Networking).
* **The `ipc` namespace**: Managing access to IPC resources (IPC: InterProcess Communication).
* **The `mnt` namespace**: Managing filesystem mount points (MNT: Mount).
* **The `uts` namespace**: Isolating kernel and version identifiers. (UTS: Unix Timesharing System).

[_Back to TOC_](#table-of-contents)

# Dockerfile Reference [link](https://docs.docker.com/engine/reference/builder/)

These recommendations help you to write an efficient and maintainable `Dockerfile`.

[_Back to TOC_](#table-of-contents)

## FROM [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#from)

   `FROM <image> [AS <name>]`

   `FROM <image>[:<tag>] [AS <name>]`

   `FROM <image>[@<digest>] [AS <name>]`

[_Back to TOC_](#table-of-contents)

## RUN [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#run)

   `RUN <command>` _(shell form, the command is run in a shell, which by default is `/bin/sh -c` on Linux_ or _`cmd /S /C` on Windows)_

   `RUN ["executable", "param1", "param2"]` _(exec form)_

[_Back to TOC_](#table-of-contents)

## CMD [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#cmd)

   `CMD ["executable","param1","param2"]` _(exec form, this is the preferred form)_

   `CMD ["param1","param2"]` _(as default parameters to ENTRYPOINT)_

   `CMD command param1 param2` _(shell form)_

[_Back to TOC_](#table-of-contents)

## LABEL [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#label)

   `LABEL <key>=<value> <key>=<value> <key>=<value> ...`

   ```
   LABEL "com.example.vendor"="ACME Incorporated"
   LABEL com.example.label-with-value="foo"
   LABEL version="1.0"
   LABEL description="This text illustrates \
   that label-values can span multiple lines."
   ```

[_Back to TOC_](#table-of-contents)

## EXPOSE [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#expose)

   `EXPOSE <port> [<port>/<protocol>...]`

[_Back to TOC_](#table-of-contents)

## ENV [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#env)

   ```
   ENV <key> <value>
   ENV <key>=<value> ...
   ```

[_Back to TOC_](#table-of-contents)

## ADD [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#add)

   * `ADD [--chown=<user>:<group>] <src>... <dest>`
   * `ADD [--chown=<user>:<group>] ["<src>",... "<dest>"]` _(this form is required for paths containing whitespace)_

[_Back to TOC_](#table-of-contents)

## COPY [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#copy)

   * `COPY [--chown=<user>:<group>] <src>... <dest>`
   * `COPY [--chown=<user>:<group>] ["<src>",... "<dest>"]` _(this form is required for paths containing whitespace)_

[_Back to TOC_](#table-of-contents)

## ENTRYPOINT [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#entrypoint)

   * `ENTRYPOINT ["executable", "param1", "param2"]` _(exec form, preferred)_
   * `ENTRYPOINT command param1 param2` _(shell form)_

   |                              | No ENTRYPOINT                | ENTRYPOINT exec\_entry p1\_entry | ENTRYPOINT [“exec\_entry”, “p1\_entry”]            |
   |------------------------------|------------------------------|----------------------------------|----------------------------------------------------|
   | No CMD                       | error, not allowed           | /bin/sh -c exec\_entry p1\_entry | exec\_entry p1\_entry                              |
   | CMD [“exec\_cmd”, “p1\_cmd”] | exec\_cmd p1\_cmd            | /bin/sh -c exec\_entry p1\_entry | exec\_entry p1\_entry exec\_cmd p1\_cmd            |
   | CMD [“p1\_cmd”, “p2\_cmd”]   | p1\_cmd p2\_cmd              | /bin/sh -c exec\_entry p1\_entry | exec\_entry p1\_entry p1\_cmd p2\_cmd              |
   | CMD exec\_cmd p1\_cmd        | /bin/sh -c exec\_cmd p1\_cmd | /bin/sh -c exec\_entry p1\_entry | exec\_entry p1\_entry /bin/sh -c exec\_cmd p1\_cmd |

[_Back to TOC_](#table-of-contents)

## VOLUME [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#volume)

   `VOLUME ["/data"]`

   For more information/examples and mounting instructions via the Docker client,
   refer to [Share Directories via Volumes](https://docs.docker.com/storage/volumes/) documentation.

[_Back to TOC_](#table-of-contents)

## USER [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#user)

   ```
   USER <user>[:<group>]
   USER <UID>[:<GID>]
   ```

[_Back to TOC_](#table-of-contents)

## WORKDIR [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#workdir)

   `WORKDIR /path/to/workdir`

   The `WORKDIR` instruction can resolve environment variables previously set using `ENV`.
   You can only use environment variables explicitly set in the `Dockerfile`.

   ```
   ENV DIRPATH /path
   WORKDIR $DIRPATH/$DIRNAME
   RUN pwd
   ```

   The output of the final `pwd` command in this `Dockerfile` would be `/path/$DIRNAME`

[_Back to TOC_](#table-of-contents)

## ARG [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#arg)

   `ARG <name>[=<default value>]`

   **Using ARG variables**

   _constant\_image\_version_

   ```
   FROM ubuntu
   ARG CONT_IMG_VER
   ENV CONT_IMG_VER ${CONT_IMG_VER:-v1.0.0}
   RUN echo $CONT_IMG_VER
   ```

   **--build-arg \<varname\>=\<value\>**

   `docker build --build-arg CONT_IMG_VER=v2.0.1 .`

   **Predefined ARGs**

   * `HTTP_PROXY`
   * `http_proxy`
   * `HTTPS_PROXY`
   * `https_proxy`
   * `FTP_PROXY`
   * `ftp_proxy`
   * `NO_PROXY`
   * `no_proxy`

[_Back to TOC_](#table-of-contents)

## ONBUILD [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#onbuild)

   `ONBUILD [INSTRUCTION]`

[_Back to TOC_](#table-of-contents)

## STOPSIGNAL [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#stopsignal)

   `STOPSIGNAL signal`

[_Back to TOC_](#table-of-contents)

## HEALTHCHECK [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#healthcheck)

   * `HEALTHCHECK [OPTIONS] CMD command` _(check container health by running a command inside the container)_
   * `HEALTHCHECK NONE` _(disable any healthcheck inherited from the base image)_

   The options that can appear before CMD are:

   * `--interval=DURATION` (default: `30s`)
   * `--timeout=DURATION` (default: `30s`)
   * `--start-period=DURATION` (default: `0s`)
   * `--retries=N` (default: `3`)

   ```
   HEALTHCHECK --interval=5m --timeout=3s \
     CMD curl -f http://localhost/ || exit 1
   ```

[_Back to TOC_](#table-of-contents)

## SHELL [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#shell)

   `SHELL ["executable", "parameters"]`

   The default shell

   * on Linux is `["/bin/sh", "-c"]`
   * on Windows is `["cmd", "/S", "/C"]`

[_Back to TOC_](#table-of-contents)

# Compose file version 3 reference [link](https://docs.docker.com/compose/compose-file/)

| Compose file format | Docker Engine release |
|---------------------|-----------------------|
| 3.6                 | 18.02.0+              |
| 3.5                 | 17.12.0+              |
| 3.4                 | 17.09.0+              |
| 3.3                 | 17.06.0+              |
| 3.2                 | 17.04.0+              |
| 3.1                 | 1.13.1+               |
| 3.0                 | 1.13.0+               |
| 2.3                 | 17.06.0+              |
| 2.2                 | 1.13.0+               |
| 2.1                 | 1.12.0+               |
| 2.0                 | 1.10.0+               |
| 1.0                 | 1.9.1.+               |

[_Back to TOC_](#table-of-contents)

## Service configuration reference [link](https://docs.docker.com/compose/compose-file/#service-configuration-reference)

### build [link](https://docs.docker.com/compose/compose-file/#build)

Configuration options that are applied at build time.

build can be specified either as a string containing a path to the build context:

```
version: '3'
services:
  webapp:
    build: ./dir
```

Or, as an object with the path specified under `context` and optionally `Dockerfile` and `args`:

```
version: '3'
services:
  webapp:
    build:
      context: ./dir
      dockerfile: Dockerfile-alternate
      args:
        buildno: 1
```

* [CONTEXT](https://docs.docker.com/compose/compose-file/#context)
* [DOCKERFILE](https://docs.docker.com/compose/compose-file/#dockerfile)
* [ARGS](https://docs.docker.com/compose/compose-file/#args)
* [CACHE_FROM](https://docs.docker.com/compose/compose-file/#cache_from)
* [LABELS](https://docs.docker.com/compose/compose-file/#labels)
* [SHM_SIZE](https://docs.docker.com/compose/compose-file/#shm_size)

[_Back to TOC_](#table-of-contents)

### cap\_add, cap\_drop [link](https://docs.docker.com/compose/compose-file/#cap_add-cap_drop)

Add or drop container capabilities. See `man 7 capabilities` for a full list.

```
cap_add:
  - ALL

cap_drop:
  - NET_ADMIN
  - SYS_ADMIN
```

[_Back to TOC_](#table-of-contents)

### command [link](https://docs.docker.com/compose/compose-file/#command)

Override the default command.

```
command: bundle exec thin -p 3000
```

The command can also be a list, in a manner similar to dockerfile:

```
command: ["bundle", "exec", "thin", "-p", "3000"]
```

[_Back to TOC_](#table-of-contents)

### configs [link](https://docs.docker.com/compose/compose-file/#configs)

Grant access to configs on a per-service basis using the per-service `configs` configuration.

Two different syntax variants are supported.

* [SHORT SYNTAX](https://docs.docker.com/compose/compose-file/#short-syntax)
* [LONG SYNTAX](https://docs.docker.com/compose/compose-file/#long-syntax)

[_Back to TOC_](#table-of-contents)

### cgroup\_parent [link](https://docs.docker.com/compose/compose-file/#cgroup_parent)

Specify an optional parent cgroup for the container.

```
cgroup_parent: m-executor-abcd
```

[_Back to TOC_](#table-of-contents)

### container\_name [link](https://docs.docker.com/compose/compose-file/#container_name)

Specify a custom container name, rather than a generated default name.

```
container_name: my-web-container
```

[_Back to TOC_](#table-of-contents)

### credential\_spec [link](https://docs.docker.com/compose/compose-file/#credential_spec)

Configure the credential spec for managed service account.

This option is only used for services using Windows containers.
The `credential_spec` must be in the format `file://<filename>` or `registry://<value-name>`.

```
credential_spec:
  file: my-credential-spec.json
```

[_Back to TOC_](#table-of-contents)

### deploy [link](https://docs.docker.com/compose/compose-file/#deploy)

Specify configuration related to the deployment and running of services.

This only takes effect when deploying to a `swarm` with `docker stack deploy`,
and is ignored by `docker-compose up` and `docker-compose run`.

```
version: '3'
services:
  redis:
    image: redis:alpine
    deploy:
      replicas: 6
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
```

[_Back to TOC_](#table-of-contents)

### devices [link](https://docs.docker.com/compose/compose-file/#devices)

List of device mappings. Uses the same format as the `--device` docker client create option.

```
devices:
  - "/dev/ttyUSB0:/dev/ttyUSB0"
```

[_Back to TOC_](#table-of-contents)

### depends\_on [link](https://docs.docker.com/compose/compose-file/#depends_on)

Express dependency between services, Service dependencies cause the following behaviors:

* `docker-compose up` starts services in dependency order. In the following example, `db` and redis are started before `web`.
* `docker-compose up SERVICE` automatically includes `SERVICE`’s dependencies.
  In the following example, `docker-compose up web` also creates and starts `db` and `redis`.

```
version: '3'
services:
  web:
    build: .
    depends_on:
      - db
      - redis
  redis:
    image: redis
  db:
    image: postgres
```

[_Back to TOC_](#table-of-contents)

### dns [link](https://docs.docker.com/compose/compose-file/#dns)

Custom DNS servers. Can be a single value or a list.

```
dns: <IP_ADDRESS>
dns:
  - <IP_ADDRESS>
  - <IP_ADDRESS>
```

[_Back to TOC_](#table-of-contents)

### dns_search [link](https://docs.docker.com/compose/compose-file/#dns_search)

Custom DNS search domains. Can be a single value or a list.

```
dns_search: example.com
dns_search:
  - dc1.example.com
  - dc2.example.com
```

[_Back to TOC_](#table-of-contents)

### tmpfs [link](https://docs.docker.com/compose/compose-file/#tmpfs)

Mount a temporary file system inside the container. Can be a single value or a list.

**Version 3.6 file format and up.**

```
 - type: tmpfs
     target: /app
     tmpfs:
       size: 1000
```

[_Back to TOC_](#table-of-contents)

### entrypoint [link](https://docs.docker.com/compose/compose-file/#entrypoint)

Override the default entrypoint.

```
entrypoint: /code/entrypoint.sh
```

The entrypoint can also be a list, in a manner similar to dockerfile:

```
entrypoint:
    - php
    - -d
    - zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
    - -d
    - memory_limit=-1
    - vendor/bin/phpunit
```

[_Back to TOC_](#table-of-contents)

### env\_file [link](https://docs.docker.com/compose/compose-file/#env_file)

Add environment variables from a file. Can be a single value or a list.

```
env_file: .env

env_file:
  - ./common.env
  - ./apps/web.env
  - /opt/secrets.env
```

[_Back to TOC_](#table-of-contents)

### environment [link](https://docs.docker.com/compose/compose-file/#environment)

Add environment variables. You can use either an array or a dictionary.

Any boolean values; true, false, yes no, need to be enclosed in quotes to ensure they are not converted to True or False by the YML parser.

```
environment:
  RACK_ENV: development
  SHOW: 'true'
  SESSION_SECRET:

environment:
  - RACK_ENV=development
  - SHOW=true
  - SESSION_SECRET
```

[_Back to TOC_](#table-of-contents)

### expose [link](https://docs.docker.com/compose/compose-file/#expose)

Expose ports without publishing them to the host machine - they’ll only be accessible to linked services.

Only the internal port can be specified.

```
expose:
 - "3000"
 - "8000"
```

[_Back to TOC_](#table-of-contents)

### external\_links [link](https://docs.docker.com/compose/compose-file/#external_links)

Link to containers started outside this `docker-compose.yml` or even outside of Compose, especially for containers that provide shared or common services.

`external_links` follow semantics similar to the legacy option `links` when specifying both the container name and the link alias (`CONTAINER:ALIAS`).

```
external_links:
 - redis_1
 - project_db_1:mysql
 - project_db_1:postgresql
```

[_Back to TOC_](#table-of-contents)

### extra\_hosts [link](https://docs.docker.com/compose/compose-file/#extra_hosts)

Add hostname mappings. Use the same values as the docker client `--add-host` parameter.

```
extra_hosts:
 - "somehost:<IP_ADDRESS>"
 - "otherhost:<IP_ADDRESS>"
```

[_Back to TOC_](#table-of-contents)

### healthcheck [link](https://docs.docker.com/compose/compose-file/#healthcheck)

Configure a check that’s run to determine whether or not containers for this service are “healthy”.

See the docs for the `HEALTHCHECK Dockerfile instruction` for details on how healthchecks work.

```
healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost"]
  interval: 1m30s
  timeout: 10s
  retries: 3
  start_period: 40s
```

[_Back to TOC_](#table-of-contents)

### image [link](https://docs.docker.com/compose/compose-file/#image)

Specify the image to start the container from. Can either be a repository/tag or a partial image ID.

```
image: redis
image: ubuntu:14.04
image: tutum/influxdb
image: example-registry.com:4000/postgresql
image: a4bc65fd
```

[_Back to TOC_](#table-of-contents)

### isolation [link](https://docs.docker.com/compose/compose-file/#isolation)

Specify a container’s isolation technology.

* On Linux, the only supported value is default.
* On Windows, acceptable values are `default`, `process` and `hyperv`.

Refer to the Docker Engine docs for details.

[_Back to TOC_](#table-of-contents)

### labels [link](https://docs.docker.com/compose/compose-file/#labels-2)

Add metadata to containers using Docker labels. You can use either an array or a dictionary.

```
labels:
  com.example.description: "Accounting webapp"
  com.example.department: "Finance"
  com.example.label-with-empty-value: ""

labels:
  - "com.example.description=Accounting webapp"
  - "com.example.department=Finance"
  - "com.example.label-with-empty-value"
```

[_Back to TOC_](#table-of-contents)

### links [link](https://docs.docker.com/compose/compose-file/#links)

[_Back to TOC_](#table-of-contents)

### logging [link](https://docs.docker.com/compose/compose-file/#logging)

Logging configuration for the service.

```
logging:
  driver: syslog
  options:
    syslog-address: "tcp://<IP_ADDRESS>:123"
```

[_Back to TOC_](#table-of-contents)

### network\_mode [link](https://docs.docker.com/compose/compose-file/#network_mode)

Network mode. Use the same values as the docker client `--net` parameter, plus the special form `service:[service name]`.

```
network_mode: "bridge"
network_mode: "host"
network_mode: "none"
network_mode: "service:[service name]"
network_mode: "container:[container name/id]"
```

[_Back to TOC_](#table-of-contents)

### networks [link](https://docs.docker.com/compose/compose-file/#networks)

Networks to join, referencing entries under the top-level `networks` key.

```
services:
  some-service:
    networks:
     - some-network
     - other-network
```

[_Back to TOC_](#table-of-contents)

### pid [link](https://docs.docker.com/compose/compose-file/#pid)

Sets the PID mode to the host PID mode.

This turns on sharing between container and the host operating system the PID address space.

Containers launched with this flag can access and manipulate other containers in the bare-metal machine’s namespace and vise-versa.

```
pid: "host"
```

[_Back to TOC_](#table-of-contents)

### ports [link](https://docs.docker.com/compose/compose-file/#ports)

Expose ports.

SHORT SYNTAX

```
ports:
 - "3000"
 - "3000-3005"
 - "8000:8000"
 - "9090-9091:8080-8081"
 - "49100:22"
 - "<IP_ADDRESS>:8001:8001"
 - "<IP_ADDRESS>:5000-5010:5000-5010"
 - "6060:6060/udp"
```

LONG SYNTAX

```
ports:
  - target: 80
    published: 8080
    protocol: tcp
    mode: host
```

[_Back to TOC_](#table-of-contents)

### secrets [link](https://docs.docker.com/compose/compose-file/#secrets)

Grant access to secrets on a per-service basis using the per-service secrets configuration.

Two different syntax variants are supported.

SHORT SYNTAX

```
version: "3.1"
services:
  redis:
    image: redis:latest
    deploy:
      replicas: 1
    secrets:
      - my_secret
      - my_other_secret
secrets:
  my_secret:
    file: ./my_secret.txt
  my_other_secret:
    external: true
```

LONG SYNTAX

```
version: "3.1"
services:
  redis:
    image: redis:latest
    deploy:
      replicas: 1
    secrets:
      - source: my_secret
        target: redis_secret
        uid: '103'
        gid: '103'
        mode: 0440
secrets:
  my_secret:
    file: ./my_secret.txt
  my_other_secret:
    external: true
```

[_Back to TOC_](#table-of-contents)

### security\_opt [link](https://docs.docker.com/compose/compose-file/#security_opt)

Override the default labeling scheme for each container.

```
security_opt:
  - label:user:USER
  - label:role:ROLE
```

[_Back to TOC_](#table-of-contents)

### stop\_grace\_period [link](https://docs.docker.com/compose/compose-file/#stop_grace_period)

Specify how long to wait when attempting to stop a container if it doesn’t handle SIGTERM (or whatever stop signal has been specified with stop_signal), before sending SIGKILL.

Specified as a duration.

```
stop_grace_period: 1s
stop_grace_period: 1m30s
```

[_Back to TOC_](#table-of-contents)

### stop\_signal [link](https://docs.docker.com/compose/compose-file/#stop_signal)

Sets an alternative signal to stop the container.
By default `stop` uses SIGTERM.

Setting an alternative signal using stop_signal causes stop to send that signal instead.

```
stop_signal: SIGUSR1
```

[_Back to TOC_](#table-of-contents)

### sysctls [link](https://docs.docker.com/compose/compose-file/#sysctls)

Kernel parameters to set in the container. You can use either an array or a dictionary.

```
sysctls:
  net.core.somaxconn: 1024
  net.ipv4.tcp_syncookies: 0

sysctls:
  - net.core.somaxconn=1024
  - net.ipv4.tcp_syncookies=0
```

[_Back to TOC_](#table-of-contents)

### ulimits [link](https://docs.docker.com/compose/compose-file/#ulimits)

Override the default ulimits for a container.

You can either specify a single limit as an integer or soft/hard limits as a mapping.

```
ulimits:
  nproc: 65535
  nofile:
    soft: 20000
    hard: 40000
```

[_Back to TOC_](#table-of-contents)

### userns\_mode [link](https://docs.docker.com/compose/compose-file/#userns_mode)

Disables the user namespace for this service, if Docker daemon is configured with user namespaces.

See dockerd for more information.

```
userns_mode: "host"
```

[_Back to TOC_](#table-of-contents)

### volumes [link](https://docs.docker.com/compose/compose-file/#volumes)

Mount host paths or named volumes, specified as sub-options to a service.

You can mount a host path as part of a definition for a single service, and there is no need to define it in the top level `volumes` key.

But, if you want to reuse a volume across multiple services, then define a named volume in the top-level volumes key. Use named volumes with services, swarms, and stack files.

```
version: "3.2"
services:
  web:
    image: nginx:alpine
    volumes:
      - type: volume
        source: mydata
        target: /data
        volume:
          nocopy: true
      - type: bind
        source: ./static
        target: /opt/app/static

  db:
    image: postgres:latest
    volumes:
      - "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock"
      - "dbdata:/var/lib/postgresql/data"

volumes:
  mydata:
  dbdata:
```

[_Back to TOC_](#table-of-contents)

### restart [link](https://docs.docker.com/compose/compose-file/#restart)

`no` is the default restart policy, and it does not restart a container under any circumstance.

When `always` is specified, the container always restarts.

The `on-failure` policy restarts a container if the exit code indicates an on-failure error.

```
restart: "no"
restart: always
restart: on-failure
restart: unless-stopped
```

[_Back to TOC_](#table-of-contents)

## Specifying durations [link](https://docs.docker.com/compose/compose-file/#specifying-durations)

Some configuration options, such as the `interval` and `timeout` sub-options for `check`, accept a duration as a string in a format that looks like this:

```
2.5s
10s
1m30s
2h32m
5h34m56s
```

> The supported units are `us`, `ms`, `s`, `m` and `h`.

[_Back to TOC_](#table-of-contents)

## Specifying byte values [link](https://docs.docker.com/compose/compose-file/#specifying-byte-values)

Some configuration options, such as the `shm_size` sub-option for `build`, accept a byte value as a string in a format that looks like this:

```
2b
1024kb
2048k
300m
1gb
```

> The supported units are `b`, `k`, `m` and `g`, and their alternative notation `kb`, `mb` and `gb`.

Decimal values are not supported at this time.

[_Back to TOC_](#table-of-contents)

## Volume configuration reference [link](https://docs.docker.com/compose/compose-file/#volume-configuration-reference)

While it is possible to declare volumes on the file as part of the service declaration,
this section allows you to create named volumes (without relying on volumes_from)
that can be reused across multiple services,
and are easily retrieved and inspected using the docker command line or API.

See the docker volume subcommand documentation for more information.

```
version: "3"

services:
  db:
    image: db
    volumes:
      - data-volume:/var/lib/db
  backup:
    image: backup-service
    volumes:
      - data-volume:/var/lib/backup/data

volumes:
  data-volume:
```

[_Back to TOC_](#table-of-contents)

### driver [link](https://docs.docker.com/compose/compose-file/#driver)

```
driver: foobar
```

[_Back to TOC_](#table-of-contents)

### driver\_opts [link](https://docs.docker.com/compose/compose-file/#driver_opts)

```
driver_opts:
  foo: "bar"
  baz: 1
```

[_Back to TOC_](#table-of-contents)

### external [link](https://docs.docker.com/compose/compose-file/#external)

```
version: '2'

services:
  db:
    image: postgres
    volumes:
      - data:/var/lib/postgresql/data

volumes:
  data:
    external: true
```

[_Back to TOC_](#table-of-contents)

### labels [link](https://docs.docker.com/compose/compose-file/#labels-3)

```
labels:
  com.example.description: "Database volume"
  com.example.department: "IT/Ops"
  com.example.label-with-empty-value: ""

labels:
  - "com.example.description=Database volume"
  - "com.example.department=IT/Ops"
  - "com.example.label-with-empty-value"
```

[_Back to TOC_](#table-of-contents)

### name [link](https://docs.docker.com/compose/compose-file/#name)

```
version: '3.4'
volumes:
  data:
    name: my-app-data
```

[_Back to TOC_](#table-of-contents)

## Network configuration reference [link](https://docs.docker.com/compose/compose-file/#network-configuration-reference)

The top-level networks key lets you specify networks to be created.

* For a full explanation of Compose’s use of Docker networking features and all network driver options, see the Networking guide.
* For Docker Labs tutorials on networking, start with Designing Scalable, Portable Docker Container Networks

[_Back to TOC_](#table-of-contents)

### driver [link](https://docs.docker.com/compose/compose-file/#driver-1)

Specify which driver should be used for this network.

The default driver depends on how the Docker Engine you’re using is configured, but in most instances it is `bridge` on a single host and `overlay` on a Swarm.

```
driver: overlay
```

* BRIDGE
* OVERLAY
* HOST OR NONE

[_Back to TOC_](#table-of-contents)

### driver\_opts [link](https://docs.docker.com/compose/compose-file/#driver_opts-1)

Specify a list of options as key-value pairs to pass to the driver for this network.

Those options are driver-dependent - consult the driver’s documentation for more information. Optional.

```
driver_opts:
  foo: "bar"
  baz: 1
```

[_Back to TOC_](#table-of-contents)

### attachable [link](https://docs.docker.com/compose/compose-file/#attachable)

Only used when the driver is set to overlay.

If set to true, then standalone containers can attach to this network, in addition to services.

If a standalone container attaches to an overlay network,
it can communicate with services and standalone containers that are also attached to the overlay network from other Docker daemons.

```
networks:
  mynet1:
    driver: overlay
    attachable: true
```

[_Back to TOC_](#table-of-contents)

### enable\_ipv6 [link](https://docs.docker.com/compose/compose-file/#enable_ipv6)

Enable IPv6 networking on this network.

[_Back to TOC_](#table-of-contents)

### ipam [link](https://docs.docker.com/compose/compose-file/#ipam)

Specify custom IPAM config.

This is an object with several properties, each of which is optional:

* `driver`: Custom IPAM driver, instead of the default.
* `config`: A list with zero or more config blocks, each containing any of the following keys:
  * `subnet`: Subnet in CIDR format that represents a network segment

```
ipam:
  driver: default
  config:
    - subnet: <IP_ADDRESS>/16
```

[_Back to TOC_](#table-of-contents)

### internal [link](https://docs.docker.com/compose/compose-file/#internal)

By default, Docker also connects a bridge network to it to provide external connectivity.

If you want to create an externally isolated overlay network, you can set this option to `true`.

[_Back to TOC_](#table-of-contents)

### labels [link](https://docs.docker.com/compose/compose-file/#labels-4)

Add metadata to containers using `Docker labels`.

You can use either an array or a dictionary.

```
labels:
  com.example.description: "Financial transaction network"
  com.example.department: "Finance"
  com.example.label-with-empty-value: ""

labels:
  - "com.example.description=Financial transaction network"
  - "com.example.department=Finance"
  - "com.example.label-with-empty-value"
```

[_Back to TOC_](#table-of-contents)

### external [link](https://docs.docker.com/compose/compose-file/#external-1)

If set to true, specifies that this network has been created outside of Compose.

`docker-compose up` does not attempt to create it, and raises an error if it doesn’t exist.

```
version: '2'

services:
  proxy:
    build: ./proxy
    networks:
      - outside
      - default
  app:
    build: ./app
    networks:
      - default

networks:
  outside:
    external: true
```

[_Back to TOC_](#table-of-contents)

### name [link](https://docs.docker.com/compose/compose-file/#name-1)

Set a custom name for this network.

The name field can be used to reference networks which contain special characters.

The name is used as is and will not be scoped with the stack name.

```
version: '3.5'
networks:
  network1:
    name: my-app-net
```

[_Back to TOC_](#table-of-contents)

## configs configuration reference [link](https://docs.docker.com/compose/compose-file/#configs-configuration-reference)

The top-level configs declaration defines or references configs that can be granted to the services in this stack.

The source of the config is either file or external.

* `file`: The config is created with the contents of the file at the specified path.
* `external`: If set to true, specifies that this config has already been created. Docker does not attempt to create it, and if it does not exist, a config not found error occurs.
* `name`: The name of the config object in Docker.
  This field can be used to reference configs that contain special characters.
  The name is used as is and will not be scoped with the stack name.
  Introduced in version 3.5 file format.

In this example, `my_first_config` is created (as `<stack_name>_my_first_config`),
when the stack is deployed, and `my_second_config` already exists in Docker.

```
configs:
  my_first_config:
    file: ./config_data
  my_second_config:
    external: true
```

[_Back to TOC_](#table-of-contents)

## secrets configuration reference [link](https://docs.docker.com/compose/compose-file/#secrets-configuration-reference)

The top-level secrets declaration defines or references secrets that can be granted to the services in this stack.

The source of the secret is either file or external.

* `file`: The secret is created with the contents of the file at the specified path.
* `external`: If set to true, specifies that this secret has already been created. Docker does not attempt to create it, and if it does not exist, a secret not found error occurs.
* `name`: The name of the secret object in Docker.
  This field can be used to reference secrets that contain special characters.
  The name is used as is and will not be scoped with the stack name.
  Introduced in version 3.5 file format.

In this example, `my_first_secret` is created (as `<stack_name>_my_first_secret`),
when the stack is deployed, and `my_second_secret` already exists in Docker.

```
secrets:
  my_first_secret:
    file: ./secret_data
  my_second_secret:
    external: true
```

[_Back to TOC_](#table-of-contents)

## Variable substitution [link](https://docs.docker.com/compose/compose-file/#variable-substitution)

Your configuration options can contain environment variables.

Compose uses the variable values from the shell environment in which `docker-compose` is run.

For example, suppose the shell contains `POSTGRES_VERSION=9.3` and you supply this configuration:

```
db:
  image: "postgres:${POSTGRES_VERSION}"
```

[_Back to TOC_](#table-of-contents)

## Extension fields [link](https://docs.docker.com/compose/compose-file/#extension-fields)

It is possible to re-use configuration fragments using extension fields.

Those special fields can be of any format as long as they are located at the root of your Compose file and their name start with the `x-` character sequence.

```
version: '2.1'
x-custom:
  items:
    - a
    - b
  options:
    max-size: '12m'
  name: "custom"
```

[_Back to TOC_](#table-of-contents)

# Recap and cheat sheet

_Here are some commands you might like to run to interact with your swarm and your VMs a bit_

[_Back to TOC_](#table-of-contents)

## [Containers](http://devdocs.io/docker~17/get-started/part2/index)

```
docker build -t friendlyhello .                    # Create image using this directory's Dockerfile
==============
docker run -p 4000:80 friendlyhello                # Run "friendlyhello" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello             # Same thing, but in detached mode
docker run username/repository:tag                 # Run image from a registry
==============
docker container ls                                # List all running containers
docker container ls -a                             # List all containers, even those not running
docker container ls -q                          # List container IDs
docker container stop <hash>                       # Gracefully stop the specified container
docker container kill <hash>                       # Force shutdown of the specified container
docker container rm <hash>                         # Remove specified container from this machine
docker container rm $(docker container ls -a -q)   # Remove all containers
==============
docker image ls -a                                 # List all images on this machine
docker image rm <image id>                         # Remove specified image from this machine
docker image rm $(docker image ls -a -q)           # Remove all images from this machine
==============
docker login                                       # Log in this CLI session using your Docker credentials
==============
docker tag <image> username/repository:tag         # Tag <image> for upload to registry
docker push username/repository:tag                # Upload tagged image to registry
```

[_Back to TOC_](#table-of-contents)

## [Services](http://devdocs.io/docker~17/get-started/part3/index)

```
docker stack ls                                 # List stacks or apps
docker stack deploy -c <composefile> <appname>  # Run the specified Compose file
docker stack rm <appname>                       # Tear down an application
==============
docker service ls                               # List running services associated with an app
docker service ps <service>                     # List tasks associated with an app
==============
docker inspect <task or container>              # Inspect task or container
```

[_Back to TOC_](#table-of-contents)

## [Swarms](https://docs.docker.com/get-started/part4/)

```
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1                  # Win10
& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 | Invoke-Expression   # Windows command to connect shell to myvm1
==============
docker-machine create --driver virtualbox myvm1                                           # Create a VM myvm1 (Mac, Win7, Linux)
docker-machine create --driver virtualbox myvm2                                           # Create a VM myvm2 (Mac, Win7, Linux)
==============
docker-machine ls                                                                         # list VMs, asterisk shows which VM this shell is talking to
==============
docker-machine env myvm1                                                                  # View basic information about your node, show environment variables and command for myvm1
                                                                                # myvm1 ACTIVE -
docker-machine ssh myvm1                                                                  # Open an SSH session with the VM; type "exit" to end
docker-machine ssh myvm1 "docker swarm init --advertise-addr <node manager ip> "          # Manager
docker-machine ssh myvm2 "docker swarm join --token <SWMTKN> <node manager ip>:<port>"    # Worker
docker-machine ssh myvm1 "docker node ls"                                                 # List the nodes in your swarm
docker-machine ssh myvm1 "docker node inspect <node ID>"                                  # Inspect a node
docker-machine ssh myvm1 "docker swarm join-token -q worker"                              # View join token
==============
eval $(docker-machine env myvm1)                                                          # Mac command to connect shell to myvm1
                                                                                # myvm1 ACTIVE *
docker node ls                                                                            # View nodes in swarm (while logged on to manager)
==============
eval $(docker-machine env -u)                                                             # Disconnect shell from VMs, use native docker
==============
docker-machine ssh myvm2 "docker swarm leave"                                             # Make the worker leave the swarm
docker-machine ssh myvm1 "docker swarm leave -f"                                          # Make master leave, kill swarm
==============
docker-machine stop myvm1                                                                 # Stop a VM that is currently not running
docker-machine start myvm1                                                                # Start a VM that is currently not running
==============
docker-machine stop $(docker-machine ls -q)                                               # Stop all running VMs
docker-machine rm $(docker-machine ls -q)                                                 # Delete all VMs and their disk images
==============
docker stack deploy -c docker-compose.yml getstartedlab                                   # Deploy an app;
docker stack deploy -c <file> <app>                                                       # Deploy an app; command shell must be set to talk to manager (myvm1), uses local Compose file
docker stack ps <app>                                                                     # List
docker stack rm <app>                                                                     # Remove
docker-machine scp docker-compose.yml myvm1:~                                             # Copy file to node's home dir (only required if you use ssh to connect to manager and deploy the app)
docker-machine ssh myvm1 "docker stack deploy -c <file> <app>"                            # Deploy an app using ssh (you must have first copied the Compose file to myvm1)
```

[_Back to TOC_](#table-of-contents)

## [Stacks](https://docs.docker.com/get-started/part5/)

[_Back to TOC_](#table-of-contents)


text:
# Calc.js API Reference

The world's smallest JavaScript calculator library (probably).

## Usage

```javascript

var c1 = Calc(2);
var c2 = Calc(10);

c1.plus(2)
c2.times(10)
c2..divide(2);

console.log(c1.getVal());
console.log(c2.getVal());
console.log(c1.getVal());

```

## API Functions
Here are the functions that are available through Calc.js:

\# *Calc*(number)

> Constructs a Calc object with the current value set to `number`

\# *Calc.getVal*()

> Returns the current value in the Calc object

\# *Calc.plus(number)

> Adds the current value in the Calc object with 'number'

\# *Calc.minus(number)

> Subtracts the current value in the Calc object with 'number'

\# *Calc.times(number)

> Multiplies the current value in the Calc object with 'number'

\# *Calc.divide(number)

> Divides the current value in the Calc object with 'number'

\# *Calc.clear()

> Resets the current value to '0'


text:
Table of Contents

- [APManager](#apmanager)
- [Purpose](#purpose)
- [Pre-Requisites](#pre-requisites)
- [Device Endpoints / Schema](#device-endpoints--schema)
  - [GET](#get)
    - [/deviceInfo](#deviceinfo)
    - [/scanInfo](#scaninfo)
  - [POST](#post)
    - [/connectWifi](#connectwifi)

# APManager

Using the platformio IDE to create an APManager similar to the [WifiManager](https://github.com/tzapu/WiFiManager)

# Purpose

Uses HTTP Requests to Webserver to configure the ESP8266 device.

This lets us embed the portal/configuration inside a custom application

# Pre-Requisites

- cJSON
  - Used for parsing JSON objects that are received while configuring the device

NOTE: The **APManager** library will be present inside the `lib` folder. Can be copy pasted to the project of your choice.

# Device Endpoints / Schema

## GET

### /deviceInfo

- Gets the device Mac address.
- Other unique device attributes can be returned here

``` json
{
    "macaddress":"$unique_mac_address"
}
```

### /scanInfo

This request scans for access points near the device

**NOTE: The scan can take 2000-3000ms. Configure your HTTP Clients appropriately**

- Gets a JSON Object of the SSID and RSSI of WiFi points near the device

``` json
{
    "networks": [
        {
            "ssid" : "$ssid_1",
            "rssi" : "$rssi_1"
        },
        {
            "ssid" : "$ssid_2",
            "rssi" : "$rssi_2"
        },
        {
            ...
        }
    ]
}
```

## POST

### /connectWifi

Tries to establish connection to the device

``` json
{
    "ssid" : "$ssid",
    "password" : "$password"
}
```

![Block Diagram](BlockDiagram.png)


text:
# MM Blocks
A wide range of matrix multiplication variations to explore and validate performance measurement methods. The kernel performs a dense matrix multiplication between two matrices and store the result in a third martix. By default all three matrices are 8192 by 8192 double precision floating point elements.

## Matrix multiplication vaiations
We include a range of implementations of the matrix multiplcation which allow the user to examine how a new method of performance analysis works when applied to a known situation.

### Default
By default, the matrices are all arranged so that the elements are aligned in memory so that the elements in each row are adjacent in memory. As a result, the second input matrix has a poor memory access pattern, only using one matrix element of those loaded in a cache line.

### Transpose
The first optimization is to transpose the second matrix to improve the memory access pattern.

### UNROLLJAM
The second optimization is to unroll the inner loop which can improve IPC and SIMD performance.

### BLOCKED
The inner two loops are blocked to improve the cache performance.

### BLOCKED_INTERCHANGE
All three loops are blocked for the cache performance.

### BLOCK_UNROLL
The inner two loops are blocked to improve the cache performance and the innermost is unrolled

### GAP
Some of the versions can also use a gapping in the matrix allocation. This could be useful for aligning the memory with cache lines or for avoiding conflicts and false sharing.

### INTERCHANGE
This version is similar to transpose, but has the loop ordering swapped. This change negatively impacts performance and memory access which makes it a useful example in some cases.

## Useage
make ORDER=8192 BLOCK_ROWS=256 BLOCK_COLS=256 D=1
./test_linear_d.out

See the makefile for the full set of options along with the executable name that will be produced.

To change the number of threads or parallelism settings, use OMP environment variables.

repository: HPCL/benchmarks

gha_language: Fortran

repo_name: HPCL/benchmarks


text:
# generator-react-component
> Yeoman generator for react component based on webpack.

## usage
```shell
# 1. Make sure you have install yeoman.
npm install -g yo

# 2. Install react-component generator
git clone git@github.com:afeiship/generator-react-component.git

# 3. link
cd generator-react-component
npm link

# 4. Then generate your new project:
yo @jswork/react-component
```

repository: afeiship/generator-react-component

repo_name: afeiship/generator-react-component


text:
---
layout: default
title: Use Tile Studio to construct tiled maps
tags: tile studio game 2d map
comments: true
---
# Use Tile Studio to construct tiled maps

[Tile Studio](http://tilestudio.sourceforge.net/) is a free and open source utility for making tile based games.

The key features of Tile Studio are

1. Manage several tile sets in a single project. Multiple maps can be created with each tile set.

2. Bitmap editor for editing tiles.

3. Specify bounds for collision detection. The left, right, top, bottom and diagonals of a cell can be marked. The bounds can be exported, along with other map data, to be used in games or applications.

4. Specify a one byte map code for any cell in the map. This can be used to tag each cell with a special value which can indicate, among other things, enemy positions in games.

5. Create and use animated tiles.

6. Export tile sets to image files in bitmap or PNG format.

7. Export map data to binary files.

8. Generate game code using templates.

![tilestudio](/assets/img/tilestudio.jpg)

## Exporting the tile map

Tile Studio provides means to export map data to files by means of templates that can produce complete source code or just simple text or binary files.

In the example template `export.tsd` below we do two things

1. Export the tile set images to PNG files.

2. Produce a binary file containing a sequence of 32-bit integer values, by reading the map data row by row. Each 32-bit integer is a result of the concatenation of the tile index, the bound values and the map code. We assume that we will have no more than 2^15 – 1 i.e. 32,767 tiles in each tile set.

The image files created by Tile Studio can and should be optimized further using image manipulation tools that optimize the color palette and other aspects. Programs such as [pngout](http://advsys.net/ken/util/pngout.htm), that optimize the image size further by using better compression, can also be used.

```text
;
; Create the tile set bitmap. The width by default has been limited to 160
; pixels. Adjust this as required.
;
#tileset
#tilebitmap <TileSetIdentifier>.png 160
#end tilebitmap
#end tileset

;
; Generate binary files containing map data. The file format is an
; ordinary sequence of 32 bit values.
;
#tileset
#map
; concatenate tile number, bounds data and map value into a 32 bit value
#binfile <MapIdentifier>.bin 32
#mapdata
<TileNumber:"16"><BoundMapValue:"16">
#end mapdata
#end binfile
#end map
#end tileset
```

## Compressing map data

The binary file exported from Tile Studio can be optimized further to reduce size of resources of games and applications. Unfortunately, the template language provided by the tool itself is quite limited. We built a Java utility `TileStudioUtil.java` that is reproduced below. Have a look at the javadoc of the `writeSparseMatrix` method, to get a notion of the format used in the output file created by the utility.

The utility can be executed in the following manner

```cmd
java TileStudioUtil diags.bin diags.map 20 20 1
```

```java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;

public class TileStudioUtil {

    private static final int INFILE_INDEX = 0;

    private static final int OUTFILE_INDEX = 1;

    private static final int HEIGHT_INDEX = 2;

    private static final int WIDTH_INDEX = 3;

    private static final int INDEXSIZE_INDEX = 4;

    private static final int NUM_ARGUMENTS = 5;

    /**
     * Main method.
     *
     * @param args
     *            Arguments to the main method
     */
    public static void main(String[] args) {
        try {
            System.out.println(args.length + " arguments received.");
            if (args.length < NUM_ARGUMENTS) {
                System.out
                        .print("Command line options: ");
                System.out
                        .println("infile outfile height width indexSize");
                System.out
                        .print("infile\t\t");
                System.out
                        .println("The binary file exported from Tile Studio");
                System.out
                        .print("outfile\t\t");
                System.out
                        .println("The binary file exported by this program");
                System.out.println("height\t\tThe height of the matrix");
                System.out.println("width\t\tThe width of the matrix");
                System.out
                        .print("indexSize\tThe storage size of the matrix");
                System.out
                        .println("index in bytes");
                System.exit(0);
            }

            int indexSize = Integer.parseInt(args[INDEXSIZE_INDEX]);
            int width = Integer.parseInt(args[WIDTH_INDEX]);
            int height = Integer.parseInt(args[HEIGHT_INDEX]);
            int a[][] = new int[height][width];
            InputStream in;
            OutputStream out;

            System.out.println("Reading file " + args[INFILE_INDEX]);
            in = new FileInputStream(args[INFILE_INDEX]);
            readMatrix(in, a, height, width);
            in.close();

            System.out.println("Writing file " + args[OUTFILE_INDEX]);
            out = new FileOutputStream(args[OUTFILE_INDEX]);
            writeSparseMatrix(out, a, height, width, indexSize);
            out.close();

            System.out.println("Testing file written");
            int b[][] = new int[height][width];
            in = new FileInputStream(args[OUTFILE_INDEX]);
            readSparseMatrix(in, b, height, width, indexSize);
            in.close();

            // Compare
            for (int i = 0; i < height; i++) {
                for (int j = 0; j < width; j++) {
                    if (a[i][j] != b[i][j]) {
                        System.out.println("Different data at row " + i
                                + ", column " + j);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    /**
     * Read an int value from an array of bytes.
     *
     * @param data
     *            an array of bytes, only the first four elements are read
     * @param littleEndian
     *            Pass true if the least signficant byte is stored in the first
     *            element of the byte array
     *
     * @return int value
     * @throws IllegalArgumentException
     */
    public static int toInt(byte[] data, boolean littleEndian)
            throws IllegalArgumentException {
        int val = 0;

        if (littleEndian) {
            for (int i = 0; i < data.length; i++) {
                val += (data[i] & 0xFF) << (i * 8);
            }
        } else { // big endian
            for (int i = 0; i < data.length; i++) {
                val += (data[i] & 0xFF) << ((data.length - i - 1) * 8);
            }
        }

        return val;
    }

    /**
     * Write an int to an array of bytes.
     *
     * @param i
     *            The int value to write
     * @param data
     *            The byte array to write to
     * @param littleEndian
     *            If set to true the least significant byte is stored first
     * @throws IllegalArgumentException
     */
    public static void toByteArray(int i, byte[] data, boolean littleEndian)
            throws IllegalArgumentException {
        if (data.length < 4) {
            throw new IllegalArgumentException("Need at least 4 bytes");
        }

        if (littleEndian) {
            data[3] = (byte) ((i >>> 24) & 0xFF);
            data[2] = (byte) ((i >>> 16) & 0xFF);
            data[1] = (byte) ((i >>> 8) & 0xFF);
            data[0] = (byte) (i & 0xFF);
        } else {
            data[0] = (byte) ((i >>> 24) & 0xFF);
            data[1] = (byte) ((i >>> 16) & 0xFF);
            data[2] = (byte) ((i >>> 8) & 0xFF);
            data[3] = (byte) (i & 0xFF);
        }
    }

    /**
     * Reads an int matrix in binary format into an array. The file structure is
     * a simple sequence of int values. Each int is little endian. All int
     * values in the first row are stored sequentially followed by all int
     * values in the second row and so on.
     *
     *
     * @param file
     *            Binary file
     * @param array
     *            Data array
     * @param width
     *            The array width
     * @param height
     *            The array height
     * @throws IOException
     */
    public static void readMatrix(InputStream in, int array[][], int rows,
            int columns) throws IOException {
        byte[] data = new byte[4];
        int n, r, c;

        r = 0;
        while (r < rows) {
            c = 0;
            while (c < columns) {
                n = in.read(data);
                if (n == -1)
                    throw new IOException("Error reading map data at row " + r
                            + " and column " + c);
                array[r][c] = toInt(data, true);
                c++;
            }
            r++;
        }

    }

    /**
     * Writes a sparse matrix to a binary format. The binary format is a simple
     * structure as represented in the BNF notation below:
     *
     * <pre>
     *       number_of_types (type number_of_positions (positions)+)+
     *       number_of_types ::= int value
     *       type ::= int value
     *       number_of_positions ::= int value
     *       positions ::= row column
     *       row ::= int value stored in indexSize bytes
     *       column ::= int value stored in indexSize bytes
     * </pre>
     *
     * A type is any unique value, other than zero, that occurs at least once
     * in the array.
     *
     * @param out
     *            Binary output stream
     * @param array
     *            Data array
     * @param rows
     *            The number of rows in the matrix
     * @param columns
     *            The number of columns in the matrix
     * @param indexSize
     *            Size in bytes of row or column index
     *
     * @throws IOException
     */
    public static void writeSparseMatrix(OutputStream out, int array[][],
            int rows, int columns, int indexSize) throws IOException {
        byte[] data; // a byte array to store int
        Hashtable table = new Hashtable(); // a hashtable to store type
                                            // locations
        int r, c;
        Integer type; // A type (unique value) in the array
        Vector positions; // a vector to store positions of a type
        Enumeration keys;
        Iterator p;

        // Analyze data and store it in an optimized format in memory
        for (r = 0; r < rows; r++) {
            for (c = 0; c < columns; c++) {
                if (array[r][c] == 0)
                    continue;

                type = new Integer(array[r][c]);
                if (table.containsKey(type)) {
                    positions = ((Vector) table.get(type));
                } else {
                    positions = new Vector();
                    table.put(type, positions);
                }
                data = new byte[4];
                toByteArray(r, data, true);
                positions.add(data);
                data = new byte[4];
                toByteArray(c, data, true);
                positions.add(data);
            }
        }

        // Dump sparse matrix to binary file

        data = new byte[4];

        // write number of types
        toByteArray(table.size(), data, true);
        out.write(data);

        keys = table.keys();
        while (keys.hasMoreElements()) {
            type = (Integer) keys.nextElement();

            // write type
            toByteArray(type.intValue(), data, true);
            out.write(data);

            positions = (Vector) table.get(type);

            // write number of positions the type occurs
            toByteArray(positions.size() / 2, data, true);
            out.write(data);

            // write positions of type
            p = positions.iterator();
            while (p.hasNext()) {
                out.write((byte[]) p.next(), 0, indexSize);
            }
        }

    }

    /**
     * Read a sparse matrix from a binary format.
     *
     * @param file
     *            File with binary data
     * @param array
     *            Array to write to
     * @param rows
     *            Rows in the matrix
     * @param columns
     *            Columns in the matrix
     * @param indexSize
     *            The storage size of the matrix index in bytes
     * @throws IOException
     *
     * @see #writeSparseMatrix(OutputStream, int[][], int, int, int)
     */
    public static void readSparseMatrix(InputStream in, int array[][],
            int rows, int columns, int indexSize) throws IOException {
        byte[] data = new byte[4]; // a byte array to store int
        byte[] pos = new byte[indexSize]; // a byte array to store position
        int bytesRead, numTypes, t, type, numPositions, n, r, c;

        // Read sparse matrix from binary file

        // read number of types
        bytesRead = in.read(data);
        if (bytesRead == -1)
            throw new IOException("Error reading number of types");
        numTypes = toInt(data, true);

        for (t = 0; t < numTypes; t++) {
            // read type
            bytesRead = in.read(data);
            if (bytesRead == -1)
                throw new IOException("Error reading type");
            type = toInt(data, true);

            // read number of positions
            bytesRead = in.read(data);
            if (bytesRead == -1)
                throw new IOException("Error reading number of positions");
            numPositions = toInt(data, true);

            for (n = 0; n < numPositions; n++) {
                // read row
                bytesRead = in.read(pos);
                if (bytesRead == -1)
                    throw new IOException("Error reading row");
                r = toInt(pos, true);
                // read column
                bytesRead = in.read(pos);
                if (bytesRead == -1)
                    throw new IOException("Error reading column");
                c = toInt(pos, true);

                array[r][c] = type;
            }

        }

    }
}
```

[Tiled](http://www.mapeditor.org/) is another neat editor for creating tiled maps.

gha_language: Ruby


text:
---
title: Hello World!
author: Devin Shoemaker
author_title: Maintainer of nxtend
author_url: https://twitter.com/paranoidcoder
author_image_url: https://avatars2.githubusercontent.com/u/1919548?s=460&u=e8799ad545249d59bf57b7ee35a8841825004ca0&v=4
tags: [docs]
---

I am excited to announce the release of [nxtend.dev](https://nxtend.dev), the official website for documentation and release notes for nxtend plugins. However, the blog itself is not all that I'm excited about. This site was created with the `@nx-plus/docusaurus` Nx plugin, so not only is the development experience great by being able to store my documentation in the same repo as my plugins, it also proves the potential for community Nx plugins.

I have a lot of changes planned for `@nxtend/ionic-react`, and I have another plugin that is nearing release that will go hand-in-hand with `@nxtend/ionic-react`. To stay tuned to updates, follow this blog, my [Twitter](https://twitter.com/paranoidcoder), or my [dev.to](https://dev.to/devinshoemaker).

repository: beeman/nxtend

repo_name: beeman/nxtend