text:
# taw
taw is a command line interface for Amazon EC2.
taw stands for Tiny Amazon ec2 Wrapper.
taw is designed to provide a limited number of operations
so that new users can easily understand what they can do with Amazon
EC2, S3, and Route 53.

taw is designed for researchers who try to use the computing resources of
Amazon EC2 but are not familier with cloud computing environments such
as Amazon EC2, Microsoft Azure, or Google Compute Platform,
but maybe it is also useful for other people.

Amazon EC2 is a great cloud environment that provides us with easy-to-use
on-demand computing resources. The web interface of Amazon EC2 is
sophisticated so that new users can easily use cloud resources.
However, the command line interface for Amazon EC2 (CLI, hereafter) is too complex and
hard to understand. This design was chosen presumably because the users of
the command line interface are professional and more familier with
the system of Amazon EC2. First, CLI provides only a low-level interface
although the web interface provides higher-level operations for common
operations. Second, CLI exposes all APIs with all parameters in an equal way.
In other words, new users have no way to guess which API is more common
than others. Deprecated parameters for compatibility are hidden as
optional parameters with a reasonable default value in the web
interface but the document for CLI does not explain it at all.

In academia, a small group of researchers such as a lab in a university
is the one who greatly benefits from cloud computing environments
because they unload the burden of maintaining computing resources internally.
The pay-as-you-go nature of cloud computing allows us to same a
significant amount of money because the small lab usually needs
a huge computing resource only occasionally, and for the rest of
the time computers would be almost all idle, which is wasteful.
However, unlike other core computing facilities where computer geeks
are familier with the local computing facility and ready to ask anything,
a small lab usually does not afford to hire a person who dedicates to
maintain the lab computing infrastructure.

taw is designed specifically for such use cases where no one is
familiar with cloud computing nor interested in system maintanace
matters. taw is also designed for a small use of cloud computing.
If you are going to use thousands of CPU cores on Amazon EC2 or
use hundreads of terabytes of storage in Amazon S3,
I recommend you to learn how Amazon EC2 works; you would be
able to use the Amazon Command Line interface and maybe
you would not need taw.

The design goal of taw is to make a small group of people who
use only a handful of resources (up to 100 instances, up to thousands
objects in a S3 bucket, a few zones, etc.) feel more comfortable
with the command line interface.

# Quick Start
Set up your AWS credential.
```bash
$ aws configure
```

List instances.

```bash
$ taw list                       # this is a shorthand for 'taw instance list'
$ taw instance list
```

List all instances in all regions.
```bash
$ taw instance list --allregions
```

Start an instance with `NAME` tag with a value `webserver01`.

```bash
$ taw instance start webserver01
```

Stop an instance with `NAME` tag with a value `webserver01`.

```bash
$ taw instance stop webserver01
```

Terminate an instance with `NAME` tag with a valie `webserver01`.

```bash
$ taw instance terminate webserver01
```

# Installation
`python setup.py install` will install `taw` command.
It is not (yet) available in PyPI, but it will appear soon.

First you need to setup your credential (ID/password).
You can set it up in [the same way as AWS Command Line
Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).
Briefly, you need to execute `aws configure` and answer the questions
(the example below is taken from the mentioned web page).

```bash
$ aws configure
AWS Access Key ID [None]: <REDACTED_AWS_ACCESS_KEY>
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: ENTER
```

Those configs are written in plain text files, `~/.aws/credentials` and
`~/.aws/config` so you can edit them if needed.

If you have multiple AWS accounts and wish to switch over them, you can
specify `--profile` option to save another credential (again, the
example is taken from the official document).

```bash
$ aws configure --profile user2
AWS Access Key ID [None]: <REDACTED_AWS_ACCESS_KEY>
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text
```

You can give `--profile=user2` to taw when you use profile `user2`.
Setting an environment variable `AWS_DEFAULT_PROFILE` changes the
default profile used.

# Subcommands
taw has subcommands like git has subcommands.
Each subcommand has a document in `doc/` directory.

# Bash Command-line Completion
Bash uesrs can use bash completion for `taw`. To use the completion feature,
source `taw_completion.sh` in `.bash_profile` or others.

# Zsh Command-line Completion
zsh users can use command-line compoletion for `taw` as well. zsh has
a "bashcompinit" feature with which users can use a completion script
for bash. To use the completion feature, put the following in
`.zsh_profile` (or wherever you want).

```zsh
autoload bashcompinit
bashcompinit
source taw_completion.sh
```

# License
MIT

# Author
Masahiro Kasahara

repository: mkasa/taw

repo_name: mkasa/taw


text:
modastylz admin API handlers
============================

This is the modastylz admin handler for Project modastylz.

This project contains just one main verticle which is responsible for listening Brands, Styles, Products, Tryitusersave, and Tryitupdated for  address on message bus.

DONE
----
* Configured listener
* Provided a initializer and finalizer mechanism for components to initialize and clean up themselves
* Processor layer is created which is going to take over the message processing from main verticle once message is read
* Logging and app configuration
* Transformer layer working for positive cases
* DB layer to actually do the operations
* Transformer layer implementation so that output from DB layer could be transformed and written back to message bus

**API features**

To understand build related stuff, take a look at BUILD_README

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# [Playground Demo](https://github.com/counterfactual/monorepo/tree/master/packages/playground) <img align="right" src="../../logo.svg" height="80px" />

This is an environment to run dApps (state channel-based decentralized applications) using [CF.js](../cf.js). It allows to showcase different demo apps, presenting a variety of use cases where state channels are applicable.

## Usage

For the moment, this package is available as a local app _(hosted version coming soon!)_.

**Make sure you have Yarn v1.10.1 installed or higher**. Refer to [Yarn's installation guide](https://yarnpkg.com/lang/en/docs/install/) for setup instructions for your operating system.

To install the dependencies:

```shell
yarn
```

To run the Playground:

```shell
yarn start
```

This will build the application and open a `stencil` dev server instance in your preferred browser, while watching the source files for any changes.

If using Firefox or any browsers without full support to Custom Elements, you can run the project with ES5 transpiling enabled (it'll slow down the live rebuilding a bit but it'll work):

```shell
yarn start --es5
```

### Execution requeriments

Ideally, you'd run in parallel at least three packages in order to fully use the Playground:

- The Playground itself (this package)
- The [Playground Server](../playground-server)
- At least one dApp (i.e. [High Roller](../dapp-high-roller))

You can use the following command at the monorepo's root to run all three projects:

```shell
yarn run:playground
```

license: MIT

repository: blockchain-develop/alano

repo_name: blockchain-develop/alano


text:
# sgame

A minimalist (web) game development framework. Extracted from a (unreleased) closed source game I've been working on. _Pretty early: seems pretty stable but options limited (e.g. assumes is always fullscreen canvas)_.

Uses [Solandra](https://solandra.netlify.com/) for drawing.

Allows you to quickly make games without bitmap assets (everything is code).

Explicitly separates state updates (handled by the update function) and rendering. Though unlike some functional frameworks that were inspirations isn't pure. You typically mutate stuff directly (but you could easily drop in [immer](https://github.com/immerjs/immer) if that bothers you).

# Example

See [running demo](https://sgame.netlify.com/).

Example code:

```typescript
import React from "react";
import Game from "sgame";
import { State, createInitialState, update, render } from "../ball";

const GamePage = () => (
  <Game<State>
    render={render}
    update={update}
    initialState={createInitialState()}
  />
);
```

Implementation of game in one file, `ball.ts`:

```typescript
import {
  SCanvas,
  Point2D,
  Vector2D,
  v,
  Rect,
  Circle,
  clamp,
  RoundedRect
} from "solandra";
import { Update } from "sgame";

export type State = {
  time: number;
  ballPosition: Point2D;
  ballVelocity: Vector2D;
  paddlePosition: number;
  paddleDirection: -1 | 0 | 1;
  best: number;
  current: number;
};

export function createInitialState(): State {
  return {
    time: 0,
    ballPosition: [0.5, 0.5],
    ballVelocity: v.normalise([0.2, 0.5]),
    paddlePosition: 0.5,
    paddleDirection: 0,
    best: 0,
    current: 0
  };
}

export function update(state: State, update: Update) {
  switch (update.kind) {
    case "time":
      state.time += update.dT;
      state.ballPosition = v.add(
        v.scale(state.ballVelocity, update.dT),
        state.ballPosition
      );

      if (state.ballPosition[0] > 1) {
        state.ballVelocity[0] = -state.ballVelocity[0];
        state.ballPosition[0] = 1;
      }
      if (state.ballPosition[0] < 0) {
        state.ballVelocity[0] = -state.ballVelocity[0];
        state.ballPosition[0] = 0;
      }

      if (state.ballPosition[1] > 1) {
        if (Math.abs(state.ballPosition[0] - state.paddlePosition) < 0.075) {
          state.ballVelocity[1] = -state.ballVelocity[1];
          state.ballPosition[1] = 1;
          state.current++;
          if (state.current > state.best) state.best = state.current;
        } else {
          state.current = 0;
          state.ballPosition = [0.5, 0.5];
          state.ballVelocity = v.normalise([0.2, 0.5]);
        }
      }
      if (state.ballPosition[1] < 0) {
        state.ballVelocity[1] = -state.ballVelocity[1];
        state.ballPosition[1] = 0;
      }

      state.paddlePosition += state.paddleDirection * update.dT * 0.5;
      state.paddlePosition = clamp(
        { from: 0.1, to: 0.9 },
        state.paddlePosition
      );
      break;
    case "key":
      switch (update.key) {
        case "ArrowLeft":
          if (update.event === "down") {
            state.paddleDirection = -1;
          } else {
            state.paddleDirection = 0;
          }
          break;
        case "ArrowRight":
          if (update.event === "down") {
            state.paddleDirection = 1;
          } else {
            state.paddleDirection = 0;
          }
          break;
      }
  }
}

export function render(s: SCanvas, state: State) {
  const { bottom, center } = s.meta;
  const minD = Math.min(bottom, 1);
  const w = minD * 0.8;
  const h = minD * 0.8;
  const sX = (1 - w) / 2;
  const sY = (bottom - h) / 2;

  s.background(state.current * 5, 90, 20);

  s.setFillColor(state.current * 5, 80, 15);
  s.fill(
    new Rect({
      at: [sX, sY],
      w,
      h
    })
  );

  s.setFillColor(state.current * 5, 90, 30);
  s.fillText(
    {
      at: center,
      align: "center",
      size: 0.05
    },
    `${state.current} (Best: ${state.best})`
  );

  s.setFillColor(0, 0, 95);
  s.fill(
    new Circle({
      at: v.add([sX, sY], v.scale(state.ballPosition, w)),
      r: 0.02 * w
    })
  );

  s.fill(
    new RoundedRect({
      align: "center",
      at: [sX + w * state.paddlePosition, sY + h],
      w: 0.15 * w,
      h: 0.01 * w,
      r: 0.005
    })
  );
}
```

repository: jamesporter/sgame

repo_name: jamesporter/sgame


text:
## [0.0.2+1] - (2021-Sep-13).

* Made formatting.

## [0.0.2] - (2021-Sep-13).

* Breaking changes. Now result of translation returns with TranslationModel with two properties
  - translatedText
  - detectedSourceLanguage
  This is helps to detect cases when language we translate To is same as the source.

## [0.0.1+1] - (2021-Aug-8).

* Fixed readme & description.

## [0.0.1] - (2021-Aug-7).

* Added first method 'translate' - translate to selected language, autodetect language from given
  text.

branch_name: refs/heads/main


text:
---
title: File Number tag
type: feature
---

Added File Number tag to return a sequential number for a file attachment, for use with the Filename Format property.

See [System Tags]({{ site.baseurl }}/tags/system-tags) and [Filename Format]({{ site.baseurl }}/questions/properties/filename-format)

repository: formsbyair/Documentation

repo_name: formsbyair/Documentation


text:
## Khan Academy Extension
### [![Install](https://storage.googleapis.com/chrome-gcs-uploader.appspot.com/image/WlD8wC6g8khYWPJUsQceQkhXSlv1/iNEddTyWiMfLSwFD6qGq.png)](https://chrome.google.com/webstore/detail/the-khan-academy-extensio/gniggljddhajnfbkjndcgnomkddfcial)
Khan Academy Extension is a browser extension for the computing section of [Khan Academy](https://khanacademy.org).

It is developed by [Jett Burns](https://github.com/jettburns14), [Ethan Luis McDonough](https://github.com/EthanLuisMcDonough), [Matthias Portzel](https://github.com/MatthiasPortzel) and [Luke Krikorian](https://github.com/lukekrikorian).

### Contributing
#### Run the extension locally:
* Run `npm install` in the extension directory.
* Make your changes!
* Run `npm run build` to build the extension.
* [Run the extension in Developer mode](https://developer.chrome.com/extensions/getstarted#unpacked)

PRs are welcomed!

### Scripts
* `npm run build` - build the extension
* `npm run clean` - clean ./dist
* `npm run lint` - check for linting errors
* `npm run fix` - clean up most linting errors automatically
* `./release.sh` - zip up the extension for release (requires [jq](https://github.com/stedolan/jq))
* `./release.sh --source` - zip up the extension source code

#### Thanks
* [Scott Schraeder](https://github.com/CosignCosine)
* [Literally Void](https://github.com/LiterallyVoid)
* [cursorweb](https://github.com/cursorweb)
* [An0n3m0us](https://github.com/An0n3m0us)
* [Bhavjit Chauhan](https://github.com/bhavjitChauhan)
* [jjroley](https://github.com/jjroley)
* [vExcess](https://github.com/vExcess)

repository: ka-extension/ka-extension-ts

gha_language: TypeScript

gha_license_id: MIT

repo_name: ka-extension/ka-extension-ts


text:
## Weights

This Is Collection of Weights (pre-trained models) used in python application

you will need to download them separately .

| Weight Name | Link |
| ------ | ------ |
| resnet50.h5 |[Download](https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet50_weights_tf_dim_ordering_tf_kernels.h5)  |
| VG19.h5 | [Download](https://drive.google.com/file/d/1Sk0jIQonfxkeaybotFML1VYY-faP9lhD/view) |

repository: Byakugan-Team/Pinder

gha_language: JavaScript

repo_name: Byakugan-Team/Pinder


text:
---
name: 'Bug / Feature '
about: Create a report to help us improve
title: ''
labels: ''
assignees: thrijith

---

**User Story**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behaviour:
1. Go to '...'
2. Click on '....'
3. See error

**Acceptance Criteria**
A clear and concise description of what you expected to happen.

**Mockup**
If applicable, add mockup.

**Technical Documentation**
If applicable, add any technical documentation.

**Additional context**
Add any other context about the problem here.

repository: laterpay/laterpay-wordpress-plugin

branch_name: refs/heads/develop

gha_language: PHP

repo_name: laterpay/laterpay-wordpress-plugin


text:
# Py Trees

[[About](#about)][[Docs & Demos](#docs-and-demos)][[Releases](#releases)][[Installation](#installation)][[PyTrees-Ros Ecosystem](#pytrees-ros-ecosystem)]

----

## About

PyTrees is a python implementation of behaviour trees designed to facilitate the rapid development of medium sized decision making engines for use in fields like robotics. Brief feature list:

* Sequence, Selector, Parallel and Chooser composites
* Blackboards for data sharing
* Python generators for smarter ticking over the tree graph
* Python decorators for enabling meta behaviours
* Render trees to dot graphs or visualise with ascii graphs on stdout

## Docs and Demos

[![devel][docs-devel-image]][docs-devel] [![2.0.x][docs-2.0.x-image]][docs-2.0.x] [![1.2.x][docs-1.2.x-image]][docs-1.2.x] [![0.6.x][docs-0.6.x-image]][docs-0.6.x]

## Releases

* `0.5.x`/`0.6.x` - first open source releases
* `1.0.x` - first stable release
* `1.1.x` - improvements
* `1.2.x` - improvements
* `2.0.x` - blackboards v2, with namespaces, access permissions and key tracking

| | Devel | 2.0.x | 1.2.x | 0.6.x | 0.5.x |
|:---:|:---:|:---:|:---:|:---:|:---:|
| Sources | [![devel][sources-devel-image]][sources-devel] | [![2.0.x][sources-2.0.x-image]][sources-2.0.x] | [![1.2.x][sources-1.2.x-image]][sources-1.2.x] | [![0.6.x][sources-0.6.x-image]][sources-0.6.x] | [![0.5.x][sources-0.5.x-image]][sources-0.5.x]
| Compatibility | [![Python 3.6][python36-image]][python36-docs] | [![Python 3.6][python36-image]][python36-docs] | [![Python 3.6][python36-image]][python36-docs] | [![Python 2.7][python27-image]][python27-docs] | [![Python 2.7][python27-image]][python27-docs] |
| Continuous Integration | [![devel-Status][devel-build-status-image]][devel-build-status] | [![2.0.x-Status][2.0.x-build-status-image]][2.0.x-build-status] | [![1.2.x-Status][1.2.x-build-status-image]][1.2.x-build-status] | [![melodic-Status][melodic-build-status-image]][melodic-build-status] | [![kinetic-Status][kinetic-build-status-image]][kinetic-build-status] | |
| Documentation | [![devel-Docs][rtd-devel-image]][docs-devel] | [![2.0.x-Docs][rtd-2.0.x-image]][docs-2.0.x] | [![1.2.x-Docs][rtd-1.2.x-image]][docs-1.2.x] | [![0.6.x-Docs][rtd-0.6.x-image]][docs-0.6.x] | ![0.5.x-Docs][not-available-docs-image] | |

## Installation

From [ppa](https://launchpad.net/~d-stonier/+archive/ubuntu/snorriheim) on Ubuntu/Bionic:

```
$ sudo apt install python3-py-trees
```

From [pypi](https://pypi.python.org/pypi/py_trees):

```
$ pip install py_trees
```

In a Python Virtual Environment:

```
$ git clone https://github.com/splintered-reality/py_trees
$ cd py_trees
$ source ./virtualenv.bash
```

Build your own python3 deb:

```
$ git clone https://github.com/splintered-reality/py_trees
$ cd py_trees
$ source ./virtualenv.bash
$ make deb
```

From the ROS2 ecosystem:

```
$ sudo apt install ros-<rosdistro>-py-trees
```

## PyTrees-ROS Ecosystem

See the `py_trees_ros` [README](https://github.com/splintered-reality/py_trees_ros/blob/devel/README.md) for the latest information on pytrees packages in the ROS ecosystem and their status.

[license-image]: https://img.shields.io/badge/License-BSD%203--Clause-orange.svg?style=plastic
[license]: LICENSE

[python36-image]: https://img.shields.io/badge/python-3.6-green.svg?style=plastic
[python36-docs]: https://docs.python.org/3.6/
[python27-image]: https://img.shields.io/badge/python-2.7-green.svg?style=plastic
[python27-docs]: https://docs.python.org/2.7/

[devel-build-status-image]: http://build.ros.org/job/Mbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[devel-build-status]: https://circleci.com/gh/splintered-reality/py_trees/tree/devel
[2.0.x-build-status-image]: http://build.ros.org/job/Mbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[2.0.x-build-status]: https://circleci.com/gh/splintered-reality/py_trees/tree/release/2.0.x
[1.3.x-build-status-image]: http://build.ros.org/job/Mbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[1.3.x-build-status]: https://circleci.com/gh/splintered-reality/py_trees/tree/release/1.3.x
[1.2.x-build-status-image]: http://build.ros.org/job/Mbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[1.2.x-build-status]: https://circleci.com/gh/splintered-reality/py_trees/tree/release/1.2.x
[crystal-build-status-image]: http://build.ros2.org/view/Cbin_uB64/job/Cbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[crystal-build-status]: http://build.ros2.org/view/Cbin_uB64/job/Cbin_uB64__py_trees__ubuntu_bionic_amd64__binary/
[melodic-build-status-image]: http://build.ros.org/job/Mbin_uB64__py_trees__ubuntu_bionic_amd64__binary/badge/icon?style=plastic
[melodic-build-status]: http://build.ros.org/job/Mbin_uX64__py_trees__ubuntu_bionic_amd64__binary
[kinetic-build-status-image]: http://build.ros.org/job/Kbin_uX64__py_trees__ubuntu_xenial_amd64__binary/badge/icon?style=plastic
[kinetic-build-status]: http://build.ros.org/job/Kbin_uX64__py_trees__ubuntu_xenial_amd64__binary

[docs-devel]: http://py-trees.readthedocs.io/
[docs-2.0.x]: http://py-trees.readthedocs.io/en/release-2.0.x/
[docs-1.3.x]: http://py-trees.readthedocs.io/en/release-1.3.x/
[docs-1.2.x]: http://py-trees.readthedocs.io/en/release-1.2.x/
[docs-0.6.x]: http://py-trees.readthedocs.io/en/release-0.6.x/
[docs-0.5.x]: http://docs.ros.org/kinetic/api/py_trees/html/

[docs-devel-image]: http://img.shields.io/badge/docs-devel-brightgreen.svg?style=plastic
[docs-2.0.x-image]: http://img.shields.io/badge/docs-2.0.x-brightgreen.svg?style=plastic
[docs-1.3.x-image]: http://img.shields.io/badge/docs-1.3.x-brightgreen.svg?style=plastic
[docs-1.2.x-image]: http://img.shields.io/badge/docs-1.2.x-brightgreen.svg?style=plastic
[docs-0.6.x-image]: http://img.shields.io/badge/docs-0.6.x-brightgreen.svg?style=plastic
[docs-0.5.x-image]: http://img.shields.io/badge/docs-0.5.x-brightgreen.svg?style=plastic

[rtd-devel-image]: https://readthedocs.org/projects/py-trees/badge/?version=devel&style=plastic
[rtd-2.0.x-image]: https://readthedocs.org/projects/py-trees/badge/?version=release-2.0.x&style=plastic
[rtd-1.3.x-image]: https://readthedocs.org/projects/py-trees/badge/?version=release-1.3.x&style=plastic
[rtd-1.2.x-image]: https://readthedocs.org/projects/py-trees/badge/?version=release-1.2.x&style=plastic
[rtd-0.6.x-image]: https://readthedocs.org/projects/py-trees/badge/?version=release-0.6.x&style=plastic
[rtd-0.5.x-image]: https://readthedocs.org/projects/py-trees/badge/?version=release-0.5.x&style=plastic
[not-available-docs-image]: http://img.shields.io/badge/docs-n/a-yellow.svg?style=plastic

[sources-devel]: https://github.com/splintered-reality/py_trees/tree/devel
[sources-2.0.x]: https://github.com/splintered-reality/py_trees/tree/release/2.0.x
[sources-1.3.x]: https://github.com/splintered-reality/py_trees/tree/release/1.3.x
[sources-1.2.x]: https://github.com/splintered-reality/py_trees/tree/release/1.2.x
[sources-0.6.x]: https://github.com/splintered-reality/py_trees/tree/release/0.6.x
[sources-0.5.x]: https://github.com/splintered-reality/py_trees/tree/release/0.5.x

[sources-devel-image]: http://img.shields.io/badge/sources-devel-blue.svg?style=plastic
[sources-2.0.x-image]: http://img.shields.io/badge/sources-2.0.x-blue.svg?style=plastic
[sources-1.3.x-image]: http://img.shields.io/badge/sources-1.3.x-blue.svg?style=plastic
[sources-1.2.x-image]: http://img.shields.io/badge/sources-1.2.x-blue.svg?style=plastic
[sources-0.6.x-image]: http://img.shields.io/badge/sources-0.6.x-blue.svg?style=plastic
[sources-0.5.x-image]: http://img.shields.io/badge/sources-0.5.x-blue.svg?style=plastic

branch_name: refs/heads/devel

gha_license_id: NOASSERTION


text:
# mongo_rest

VueJS client app. Django server with REST API using Pymongo. Mongo database.

## System Requirements

- Python (3+)
- Django (2+)
- Docker
- Node
- Mongo Compass (optional)

## Installation

Clone this repository

        $ git clone https://github.com/charlon/mongo-restapi

Go to your newly created repository

        $ cd mongo-restapi

## Configuration

Copy the sample .env file so that your environment can be run.

        $ cp .env.sample .env

# Development

## Docker

Docker/Docker Compose is used to containerize your local build environment and deploy it to an 'app' container which is exposed to your localhost so you can view your application. Docker Compose creates a 'devtools' container - which is used for local development. Changes made locally are automatically syncd to the 'app' container. A 'db' container is created for the Mongo database.

        $ docker-compose up

In the case that changes are made to the Dockerfile or docker-compose.yml file, you will need to rebuild the image.

        $ docker-compose up --build

## MongoDB

The MongoDB server can be accessed using the following hostnames and default port.

        Internal: mongo_rest_db:27017
        External: localhost:27017

On the initial first build, 'mongo-volume' will be created and mounted. This volume will allow your database to persist for future builds. Delete this directory to clear your data.

Run Docker exec to bring up a bash console for your app container.

        $ docker exec -it mongo_rest_app /bin/bash

Activate virtualenv

        $ source bin/activate

Run the 'create_collection' managment command to create your empty collections.

        $ python manage.py create_collections

## Django

Django is used for both the backend API server and client app.

        API: http://localhost:8000/api/spots/

## Vue

Webpack watches for file changes and creates the bundles which is served from the client app (index.html).

        Vue: http://localhost:8000/

repository: charlon/mongo-restapi

gha_language: Python

repo_name: charlon/mongo-restapi


text:
# VDA Middleware

This middleware using HapiJS as a backend service. You can read full documentation about HapiJS at [Official HapiJS Site](https://hapi.dev/).

## How to run server
run `npm run dev` to run locally


text:
# piper

`vagrant up --provider=aws`

## salt-master and salt-cloud

This states should be installed on the instance by default

1. `sudo salt-call state.sls salt.master`
2. `sudo salt-call state.sls salt.cloud`

## zookeeper quorum

**Requires**:

1. salt-master
2. salt-cloud

Change settings under: `salt/pillar/instances` and `/salt/pillar/salt/cloud.sls`
a template for the latter is provided as `salt/pillar/salt/cloud.sls.template`

1. `sudo salt-call state.sls instances.zookeeper`
2. `sudo salt 'zoo*' state.highstate`

## kafka cluster

**Requires**:

1. zookeeper quorun

Change settings under: `salt/pillar/instances` and `/salt/pillar/salt/cloud.sls`
a template for the latter is provided as `salt/pillar/salt/cloud.sls.template`

1. `sudo salt-call state.sls instances.kafka`
2. `sudo salt 'kafka*' state.highstate`

repository: chenweihua/piper

repo_name: chenweihua/piper


text:
---
title: Browser Launch API
---

Before Cypress launches a browser, it gives you the ability to modify the arguments used to launch it.

This is helpful to modify, remove, or add your own arguments.

The most common use case is adding your own chrome extension.

# Usage

## Modify args based on browser

Using your {% url "`pluginsFile`" plugins-guide %} you can tap into the `before:browser:launch` event and modify the arguments based on the browser that Cypress is launching.

This event will yield you the `browser` as an object, and `args` which are the default arguments used to launch the browser.

`args` may be an array or an object (based on the type of browser we're launching). Whatever you return from this event will become the new args for launching the browser.

Here are options for the currently supported browsers:

* {% url 'Chrome, Chromium, or Canary' "https://peter.sh/experiments/chromium-command-line-switches/" %}
* {% url 'Electron' "https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions" %}

```js
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, args) => {
    // browser will look something like this
    // {
    //   name: 'chrome',
    //   displayName: 'Chrome',
    //   version: '63.0.3239.108',
    //   path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    //   majorVersion: '63'
    // }

    if (browser.name === 'chrome') {
      // `args` is an array of all the arguments
      // that will be passed to Chrome when it launchers
      args.push('--start-fullscreen')

      // whatever you return here becomes the new args
      return args
    }

    if (browser.name === 'electron') {
      // `args` is a `BrowserWindow` options object
      // https://electronjs.org/docs/api/browser-window#new-browserwindowoptions
      args['fullscreen'] = true

      // whatever you return here becomes the new args
      return args
    }
  })
}
```

## Modify Electron app switches

Cypress Test Runner is an Electron application, and its behavior (and the behavior of the bundled-in Electron browser) can be customized using command line switches. The supported switches depend on the Electron version, see {% url "Electron documentation" https://electronjs.org/docs/api/chrome-command-line-switches/history %}.

You can pass Electron-specific launch arguments using the `ELECTRON_EXTRA_LAUNCH_ARGS` environment variable. For example, to disable HTTP browser cache and ignore certificate errors, open or run the Cypress Test Runner like this:

```shell
export ELECTRON_EXTRA_LAUNCH_ARGS=--disable-http-cache --ignore-certificate-errors
npx cypress open|run
```

Cypress already sets some the Electron command line switches internally. See file {% url "packages/server/lib/environment.coffee" https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/environment.coffee %}. There is no way to see all currently set switches after Electron's launch.

## See all Chrome browser switches

If you are running Cypress tests using Chrome browser, you can see ALL currently set command line switches and the browser version information by opening a new tab and typing `chrome://version` url.

{% imgTag /img/api/chrome-switches.png "See all Chrome switches" %}

# Examples

## Use fake video for webcam testing

By default, Cypress passes the Chrome command line switch to enable a fake video for a media stream. This is to better enable testing webcam functionality without having to have the necessary hardware to test.

{% imgTag /img/api/browser-launch-fake-video.gif "Enable fake video for testing" %}

You can however send your own video file for testing by passing a Chrome command line switch pointing to a video file.

```js
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, args) => {
    if (browser.name === 'chrome') {
      // Mac/Linux
      args.push('--use-file-for-fake-video-capture=cypress/fixtures/my-video.y4m')

      // Windows
      // args.push('--use-file-for-fake-video-capture=c:\\path\\to\\video\\my-video.y4m')
    }

    return args
  })
}
```


text:
# Introduction to Dart and Flutter

### WARNING: This repository has been created just for seeing my progress.

- Introduction to MaterialApp and Scaffold widgets, FloatingActionButton and material design rules, Container Widget and features, Alignment Class and Margin - Padding parameters, MainAxis, CrossAxis, Expanded Widget and Flex features.

![dart-flutter-basic-example](https://user-images.githubusercontent.com/76449375/106367110-63098080-6351-11eb-9c6c-a9e5a597d491.png)

- Asset, Network and Circle Avatar Image Types, Using FadeinImage and IntrinsicHeight, FlutterLogo and PlaceHolder Widget features, Basic Button Types.

![Screenshot 2021-01-28 225136](https://user-images.githubusercontent.com/76449375/106367117-67359e00-6351-11eb-9824-df3fd4f8bd2c.png)

- Stateless and Stateful Widgets, Buildcontext Theme.

![Screenshot 2021-01-29 202326](https://user-images.githubusercontent.com/76449375/106367121-68ff6180-6351-11eb-8fbb-e61b57fcc1cc.png)

- Cards, ListTile Divider for Lists, Basic Usage of Listview and List.map Method. (You can scroll down and up with Listview.)

![Screenshot 2021-01-30 191616](https://user-images.githubusercontent.com/76449375/106367124-6a308e80-6351-11eb-998a-742f4e958ad4.png)

- ItemBuilder and Seperator Builder for RAM-Friendly Lists. (You can see that scrool move and separating how it's like.)

**NOTE: I continued to use main4.dart for these operations. It is enough to just specify the class that we will define in the body: part.**

![ezgif com-gif-maker](https://user-images.githubusercontent.com/76449375/106366782-52580b00-634f-11eb-82e3-080cedd994ba.gif)

- List Click Events and Fluttertoast Package Download, Using AlertDialog and SingleChildScrollView when List Element is clicked.

**NOTE: This section is a continuation of the previous section. It is the updated version of the previous part under efficientListExample2 with some concepts. The topics I mentioned in before the note.**

![ezgif com-gif-maker (1)](https://user-images.githubusercontent.com/76449375/106390083-c4842a80-63f7-11eb-800a-d33ab653148c.gif)

GridView Usages and Types

![Screenshot 2021-02-01 195800](https://user-images.githubusercontent.com/76449375/106491703-2f9d3200-64c8-11eb-84bb-64a7a8093e39.png)

repository: gokberkguner/Dart-Flutter-Adventure

repo_name: gokberkguner/Dart-Flutter-Adventure


text:
# Stairwell

Making SQL more accessible while maintaining safety in Rails projects.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'stairwell'
```

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install stairwell

## Usage

Define a class in your app that inherits from `Stairwell::Query`. We're going to assume you are in a rails app, but this will work in any ruby app, although ActiveRecord is a dependency of this gem.
In rails you could create a directory called `app/queries` for instance.

Define your `validate_type`, which will be the arguments you send in, and their type. For instance, if your query looks like this: `SELECT * FROM users WHERE name = :name`, and name is a `String`, your `validate_type` will look like this `validate_type :name, :string`, and you'll pass in a hash of your binds like this: `{ name: "<name value>" }`

Here's an example:
```ruby
class UsersSql < Stairwell::Query
  validate_type :name, :string
  validate_type :age, :integer
  validate_type :active, :boolean
  validate_type :gpa, :float
  validate_type :date_joined, :sql_date
  validate_type :created_at, :sql_date_time
  validate_type :favorite_numbers, [:integer]

  query <<-SQL
    SELECT
      *
    FROM users
    WHERE name = :name
      AND age = :age
      AND active = :active
      AND gpa = :gpa
      AND date_joined = :date_joined
      AND created_at >= :created_at
      AND favorite_numbers IN (:favorite_numbers)
    ;
  SQL
end

# if you pass in the following named binds:

binds = {
  name: "First",
  age: 99,
  active: true,
  gpa: 4.2
  date_joined: "2008-08-28",
  created_at: "2008-08-28 23:41:18",
  favorite_numbers: [4, 7, 100]
}

# and call the following:

UsersSql.sql(binds)

# You will receive the following result:

"SELECT * FROM users WHERE name = 'First' AND age = 99 AND active = TRUE AND date_joined = '2008-08-28' AND created_at >= '2008-08-28 23:41:18' AND gpa = 4.2 AND favorite_numbers IN (4, 7, 100) ;"
```

Binds passed in are validated against the validate_type, so if you have a validate_type you must include that value in your binds hash.
They types of the binds are validated too.
The names binds in your sql are also validated.
All types are quoted using ActiveRecord quoting, which will be different depending on your database type (Mysql, postgres etc.)

## Supported Types

| Type         | Values Accepted      | Info                                                                                |
|--------------|----------------------|------------------------------------------------------------------------------------------------------|
| :boolean     | TrueClass/FalseClass | Not fully supported since many databases require 'IS TRUE' or 'IS FALSE'                             |
| :column_name | String               | for quoting a column name                                                                            |
| :date_time   | String               | only taking the actual string for now                                                                |
| :date        | String               | only taking the actual string for now                                                                |
| :float       | Float                |                                                                                |
| [<type>]     | Array                | will quote any type provided in the array [:integer]                                                 |
| :integer     | Integer              |                                                                                |
| :null        | NilClass             | nil/NULL values are not completely supported since many databases require 'IS NULL' or 'IS NOT NULL' |
| :string      | String               |                                                                                |
| :table_name  | String               | for quoting a table name                                                                             |

## Known issues

* nil/NULL values are not completely supported, since many databases require `IS NULL`, or `IS NOT NULL`, you can use the null_type here, but it will only accept `nil`, and it will possibly not support what you're trying to do. YMMV.
* Date/Datetime are not validated for their format, it is expected that you will pass the correct format.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tobyond/stairwell.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

repository: tobyond/stairwell

gha_language: Ruby

repo_name: tobyond/stairwell


text:
# Find loarithm Extension for Numi

## What is this extension for? :mag_right:

This extension allows you to easily calculate a logarithm with any base

## Installation :floppy_disk:

Simply download the .js file to your numi extensions directory.

## How to use it :wrench:

You can get log base 2 like follows:

`log 4`

Or any base can be specified as first parameter:

`log 2;4`

repository: nikolaeu/numi

repo_name: nikolaeu/numi


text:
# RealityHack-Challenge-3
RealityHack Challenge #3: Reinvent the Workplace (Estimote + Slack API)

Team Members
-----
- Juan Herrador
- Hugo Peral
- Jose Salazar
- Isra San Jose

# Repository structure
- **ios:** ai{D}FY iOS application
- **cloud/activity-aidifycloud:** ai{D}FY activity management service, store github event data
- **cloud/apigateway-aidifycloud:** Rest api to access ai{D}FY services, offers response caching.
- **cloud/github-aidifycloud:** ai{D}FY GitHub service, retrieve user and organization events from GitHub.
- **cloud/messagebroker:** ai{D}FY light weight message broker for asynchronous communications between services.
- **cloud/pointsservice:** ai{D}FY scoring system, emit pointed activities.
- **cloud/slackservice:** ai{D}FY slack service, send direct messages to the users in Slack when a new activity is processed.
- **cloud/statsmanagement:** ai{D}FY stats management service, store user statistics.
- **cloud/usermanagement-aidifycloud:** ai{D}FY user management service, store github user data.


text:
# Flask Social Network

Sign up, login, make posts, and follow other users.

Configured for PythonAnywhere deployment.

######################################

* User registration and authentication

* Password hashing

* Form validation

* Joins

repository: sinpman/flask-social-network

repo_name: sinpman/flask-social-network


text:
# Mobify
###About
Mobify is an open source mobile notification software to send messages in real-time to users' mobile devices.

###Status
Work in progress.

###Modules
* **mobify-server**: RESTful backend using Spring Boot. The data is stored in a Cassandra database.
* **mobify-ui**: User interface for the administrator using AngularJS.
* **mobify-ionic**: Mobile application to receive real-time notifications, developed using multi-platform framework Ionic v2 (Angular 2).
* **mobify-client**: A sample client to send notifications using command line.
* **demo-oauth-server**: OAuth 2.0 authorization server implementation for testing and development purposes. The software should be integrated with your own OAuth 2.0 authentication server for production use.

repository: mehtarakesh/mobify

repo_name: mehtarakesh/mobify


text:
# Alem Mela

## Overview

Asynchronous framework that makes it really simple to build RabbitMQ services.

## Installation

`pip install mela`

## Usage

Basic usage does look like this:

`app.py`:
```
from mela import Mela

app = Mela(__name__)
app.read_config_yaml('application.yml')

@app.service("printer")
def printer(body, message):
    # Just print message body and push
    # unchanged message to output queue.
    print(body)
    return body

if __name__ == '__main__':
    app.run()

```

`application.yml`:
```
connections:
  default:
    host: localhost
    port: 5672
    username: user
    password: bitnami

services:
  printer:
    consumer:
      exchange: general-sentiment-x
      routing_key: general-sentiment-q
      queue: general-sentiment-q
    publisher:
      exchange: general-sentiment-x
      routing_key: general-sentiment-q
```

For more use cases and examples please
check `/examples` directory.

## Authors

Developed in Alem Research.

Core maintainer: Daniyar Supiyev (undead.thunderbird@gmail.com).

Producer: Sergazy Narynov.

repository: zloy-zhake/mela

repo_name: zloy-zhake/mela


text:
# Contributing to React Native Chart Kit

👍🎉 First off, thanks for taking the time to contribute! 🎉👍

Suggestions and pull requests are highly encouraged! Have a look at the [open issues](https://github.com/indiespirit/react-native-chart-kit/issues).

## Workflow

First clone:

```sh
git clone git@github.com:indiespirit/react-native-chart-kit.git
cd react-native-chart-kit
yarn install
```

In order to run it, you are gonna have to flip values for "main" and "_main" in package json. This is nessesary because both npm and expo have a notion of a main file, but for npm it's the file that you run when you import this library in your app; and for expo it's the file that it uses to display the example app.

Don't forget to flip it back before commiting.

**After you update fix the package.json**

```sh
yarn start # And get you expo app ready on your phone
```


text:
# Flame Graphs for Spark - Tools and Notes

In this note you can find a few links and basic examples relevant to using FlameGraphs for profiling Apache Spark workloads
running in the JVM on Linux. This covers profiling the JVM and profiling Python (notably for Python UDFs in Spark).

## TL;DR use async-profiler for profiling JVM and py-spy for Python

### Flamegraphs for JVM: Java, Scala (Spark)
**Link to [async-profiler on GitHub](https://github.com/jvm-profiling-tools/async-profiler)**. Build async profiler as in the README:
 - downloaded the latest version
 - or build from source with `make` (need to `export JAVA_HOME=..` to a valid JDK first)

**Example** of how to use async-profiler for Spark

- A simple test is with Spark in local mode, as in this configuration driver and executors are all in
  one JVM on your local machine (`bin/spark-shell --master local[*]`)
   - First find the pid of the JVM running Spark driver and executor, for example run:
     ```
     $ jps
     171657 SparkSubmit
     ```
-  For Spark on clusters, this is more complex
  - identify one executor to trace (use the Spark WebUI to find the address of the running executors)
  - connect (via shell) to the executor: for example to a YARN node or k8s container
  - you need to be able to run async-profiler on the shell

- Profile JVM and create the FlameGraph:
```
# profile by time (regardless if process is on CPU or waiting)
# with older versions of async profiler use .svg files rather than .html
./profiler.sh -e wall -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>

# profile on-CPU threads, without using perf
./profiler.sh -e itimer -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>
```

- Visualize the JVM execution FlameGraph:
```
firefox flamegraph1.svg
```
- Drill down to the part of the FlameGraph of interest (click on svg to zoom in), for example:
zoom in to `java/util/concurrent/ThreadPoolExecutor$Worker.run` +
 further zoom in to `org/apache/spark/executor/Executor$TaskRunner.run`

If you want to use CPU profiling (or profiling other per events) using perf (mode `-e cpu` you need also
to set the following and run profiling as root:
```
# echo 1 > /proc/sys/kernel/perf_event_paranoid
# echo 0 > /proc/sys/kernel/kptr_restrict
```
## FlameGraph repo:
Download: ```git clone https://github.com/brendangregg/FlameGraph```

## Example of usage of async-profiler

Download from [https://github.com/jvm-profiling-tools/async-profiler]
Build as in the README (export JAVA_HOME and make)
Find the pid of the JVM runnign the Spark executor, example:
```aidl
$ jps
171657 SparkSubmit
171870 Jps
```

Profile JVM and create the flamegraph, example:
```
./profiler.sh -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>
```

Visualize the on-CPU flamegraph:
```
firefox flamegraph1.html
```

Example of the output:
[Click here to get the SVG version of the on-CPU Flamegraph](https://canali.web.cern.ch/canali/svg/Flamegraph_Spark_SQL_read_CPU-bound.svg)
![Example](https://1.bp.blogspot.com/-HMAOBL9gl58/Wcy7HBUBghI/AAAAAAAAFAw/YrvKqOGhSwEn9QuOAQqBJvoKNn7IweiuQCLcBGAs/s1600/Flamegraph_Spark_SQL_read_CPU-bound_javacolors.PNG)

---
async-profiler by default records stack traces on CPU events, it can also be configured to record stack traces on other type of events.
The list of available events is available as in this example:
```
./profiler.sh list <pid_of_JVM>

Basic events:
  cpu
  alloc
  lock
  wall
  itimer
Perf events:
  page-faults
  context-switches
  cycles
  instructions
  cache-references
  cache-misses
  branches
  branch-misses
  bus-cycles
  L1-dcache-load-misses
  LLC-load-misses
  dTLB-load-misses
  mem:breakpoint
  trace:tracepoint
```

Example of profile on alloc (heap memory allocation) events
```
./profiler.sh -d 30  -e alloc -f $PWD/flamegraph_heap.svg <pid_of_JVM>
../FlameGraph/flamegraph.pl --colors=mem flamegraph_heap.txt >flamegraph_heap.svg
```
Example output:
[Click here to get the SVG version of the Heap Flamegraph](https://canali.web.cern.ch/canali/svg/Flamegraph_Spark_SQL_read_Parquet_annotated.svg)
![Example](https://2.bp.blogspot.com/-Bxaa4CCKfx8/Wc60YfC2A5I/AAAAAAAAFBA/aENnOyv-SjQZFkUUMWwJjahrssmdlpekACLcBGAs/s1600/Flamegraph_HEAP_Spark_SQL_read_Parquet.png)

## Python
Profile Python code with flame graph for Spark when using PySpark and Python UDF, for example.
A good tool to use (for test environments) is [py-spy](https://github.com/benfred/py-spy):
Install and example:
```python
pip install py-spy
py-spy record -d 30 -p <pid> --nonblocking -o myFlamegraph.svg
```

Ideas on how to profile Python UDF: attach the profiler to the pyspark.daemon coordinator with `-s` option
to profile also the subprocesses spawned by it (the pyspark.daemon workers).
Note: I found at least one case where `--nonblocking` was needed, see also [this](https://github.com/benfred/py-spy/issues/83)

----
### FlameGraph and async JVM stack profiling for Spark on YARN
Profile one executor, example:
 - First, find the executor hostname and pid, for example use Spark WebUI or run `sc.getExecutorMemoryStatus`
 - With `ps` or `jps -v` find pid of the executor process, on YARN Spark 3.0 uses the class`YarnCoarseGrainedExecutorBackend`,
  on Spark 2.4 is instead `CoarseGrainedExecutorBackend`
 - Profile the executor pid as detailed above

### FlameGraph and Async JVM stack profiling for Spark on Kubernetes
How to profile one executor, example:
 - Identify a Kubernetes pod to profile `kubectl get pods [-n namespace]`
 - copy async profiler from driver to executor:
 `kubectl cp async-profiler-1.6 <pod_name_here>:/opt/spark/work-dir`
 - run profiler as described above, in `-e wall` or `-e itimer` mode
 - using async profiler with perf in `-e cpu` mode, is also possible, ideally running from host system/VM, [details here](https://github.com/jvm-profiling-tools/async-profiler#profiling-java-in-a-container)

----

## Context

Stack profiling and on-CPU Flame Graph visualization are very useful tools and techniques for investigating CPU workloads.
See [Brendan Gregg's page on Flame Graphs](http://www.brendangregg.com/flamegraphs.html)
Stack profiling is useful for understanding and drilling-down on "hot code":
you can use it to find parts of the code using considerable amount of time and provide insights for troubleshooting.
FlameGraph visualization of the stack profiles brings additional value, including the fact of
being an appealing interface and providing context about the running the code, by showing for example the parent functions.

The main challenge that several tools undertake for profiling the JVM is on how to collect stack frames
precisely and with low overhead.
For more details related to the challenges of profiling Java/JVM see
- [Nitsan Wakart](https://twitter.com/nitsanw): [Using FlameGraphs To Illuminate The JVM by](https://en.wikipedia.org/wiki/DTracehttps://www.youtube.com/watch?v=ugRrFdda_JQ), [Exploring Java Perf Flamegraphs](https://2017.javazone.no/program/56179b136b91458a843383e13fd2efa1)
- [Brendan Gregg](https://twitter.com/brendangregg): [Java in Flames](https://medium.com/netflix-techblog/java-in-flames-e763b3d32166)

## A list of profilers relevant for troubleshooting Spark workloads

- [async-profiler](https://github.com/jvm-profiling-tools/async-profiler) (see also an example of usage later in this note)
  - based on AsyncGetCallTrace, also has perf events
  - no need to install agents
  - info from the tool's author: [Andrei Pangin](https://twitter.com/AndreiPangin): [Everything you wanted to know about Stack Traces and Heap Dumps](https://2017.javazone.no/program/c5577d90198b474cbf14c7867209d96c)
  - more info at [http://psy-lob-saw.blogspot.ch/2017/02/flamegraphs-intro-fire-for-everyone.html]
  - see also this [http://blogs.microsoft.co.il/sasha/2017/07/07/profiling-the-jvm-on-linux-a-hybrid-approach/]
  - issues with sampling at safepoint: [http://psy-lob-saw.blogspot.ch/2016/02/why-most-sampling-java-profilers-are.html]
- [honest-profiler](https://github.com/jvm-profiling-tools/honest-profiler)
  - also based on AsyncGetCallTrace, deploy an agent on the JVM, which allows also remote control
- methods based on Java Flight Recorder
  - See [https://gist.github.com/kayousterhout/7008a8ebf2babeedc7ce6f8723fd1bf4]
  - an example at [Apache Spark 2.0 Performance Improvements Investigated With Flame Graphs](https://externaltable.blogspot.com/2016/09/spark-20-performance-improvements.html):
  - only measures the JVM
  - needs also [https://github.com/lhotari/jfr-report-tool]
  - JFR requires license from Oracle if used in production up to Java version 1.8, for Java 9 and higher
  I understand with is now in open source
- Perf
  - see Brendan's pages and the blog post [Java in Flames](https://medium.com/netflix-techblog/java-in-flames-e763b3d32166)
  - goes together with [perf-map-agent](https://github.com/jvm-profiling-tools/perf-map-agent)
  - See also [Profiling JVM applications](https://developer.lightbend.com/blog/2018-04-09-profiling-JVM-applications/)
  - perf is a great tool, but not my favourite method for Spark profiling, as many functions appear listed as "interpreter" and cannot be resolved by this method.
  - see also the additional JVM options when running Spark (see examples below)
- method with the statsd-jvm-profiler
  - see [Spark in Flames](https://www.paypal-engineering.com/2016/09/08/spark-in-flames-profiling-spark-applications-using-flame-graphs/)
  - note, I have not yet tested this
- Methods based on jstack
  - run [jstack](http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstack.html) on the executors at low frequency for profiling has high overhead. Typically you would do this manually to get an idea of a stuck process. Similarly one can dump executors stack traces "manually" from the WebUI
  - I understood that Facebook used a jstack-sampling method for their flamegraph, as reported at the Spark Summit
   Europe 2016 talk [Apache Spark at Scale: A 60 TB+ Production Use Case by Sital Kedia](https://www.slideshare.net/SparkSummit/spark-summit-eu-talk-by-sital-kedia) Reported to hav
- Many commercial tools exist that provide profiling
  - the talk [Using FlameGraphs To Illuminate The JVM by Nitsan Wakart](Using FlameGraphs To Illuminate The JVM by Nitsan Wakart)
    lists some of the tools
  - most commercial profiling tool report prole data as trees
  - most commercial profiling tools use SafePoints rather than AsyncGetCallTrace
- Distributed Hadoop Profiler [HProfiler](https://github.com/cerndb/Hadoop-Profiler)
  - based on perf, integrates with YARN and aggregates profiles
- Python: [py-spy](https://github.com/benfred/py-spy)
---
---
## Example of usage of perf for java/Spark:

Get perf-map-agent and build it following instructions at:
```https://github.com/jvm-profiling-tools/perf-map-agent```

set JAVA_HOME and AGENT_OME for FlameGraph/jmaps

run Spark with extra java options. examples:
```--conf "spark.driver.extraJavaOptions"="-XX:+PreserveFramePointer"```
or:
```--conf "spark.driver.extraJavaOptions"="-XX:+PreserveFramePointer -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints"```
note:
similarly add options on executors with `--conf "spark.driver.extraJavaOptions"=...`

Gather data with (example):
```perf record -a -g -F 99 -p <pid> sleep 10; FlameGraph/jmaps```

Generate the flamegraph:
```perf script |../FlameGraph/stackcollapse-perf.pl | ../FlameGraph/flamegraph.pl > perfFlamegraph1.svg```

----
## Example of usage of JMC and Java Flight Recorder

Start Spark with the extra Java options (only driver options needed if running in local mode):
```
--conf "spark.driver.extraJavaOptions"="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:FlightRecorderOptions=stackdepth=1024"
--conf "spark.executor.extraJavaOptions"="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:FlightRecorderOptions=stackdepth=1024"
```

Gather data:
```
jcmd 146903 JFR.start filename=sparkProfile1.jfr duration=30s
```

Process the Java Flight Recorder file with jfr-report-tool, see instructions at: [https://github.com/lhotari/jfr-report-tool]
```
jfr-report-tool/jfr-report-tool -e none -m 1 sparkProfile3.jfr
```

In alternative can use:
[https://github.com/chrishantha/jfr-flame-graph]
jfr-flame-graph/run.sh -f sparkProfile1.jfr -o spark_jfr_out.txt
../FlameGraph/flamegraph.pl spark_jfr_out.txt > perf2.svg

repository: LucaCanali/Miscellaneous

gha_language: Jupyter Notebook

repo_name: LucaCanali/Miscellaneous


text:
---
layout: post
title: The Orrery
description: A little solar system visualisation with Elm.

custom_css: /gallery/elm-orrery/style.css
custom_js: /gallery/elm-orrery/script.js
---

Hello! Sorry for taking so long to write another post. I've been really quite busy looking for a new place to live and a new office to work in, you see. Anyway, instead of adding _another_ post in my introductory theme, I thought I'd show you how this **Orrery** works! It's written in Elm, which isn't supported by GitHub's highlighter _yet_, so I've modified it a little (_my excuse for why the code blocks look a bit naff_).

Anyway, I hope it's useful to someone - we'll talk about Elm's successes and my failings, and everything should hopefully be clear enough. If anything doesn't make sense, though, feel free to [send me a Tweet](http://www.twitter.com/am_i_tom) and I'll do my best to clarify!

## Preamble

```haskell
module Main exposing (..)

import AnimationFrame
import Html
import Http
import Json.Decode as Decode
import Svg
import Svg.Attributes exposing (..)
import Time exposing (inMinutes, Time)
```

This project uses a few dependencies. To anyone who's written any amount of Elm before, the only stranger is `AnimationFrame`, from the `elm-lang/animation-frame` package. This lets us subscribe to the browser's RAF API. Everything else should be fairly obvious: `Html` / `Svg` for our view, `Http` / `Json.Decode` for the AJAX request, and `Time` for our orbit.

```haskell
main =
    Html.program
        { init          = init
        , subscriptions = \_ -> AnimationFrame.times Tick
        , update        = update
        , view          = view
        }
```

We can't use the `beginnerProgram` because of the need for both subscriptions _and_ commands, so we opt for the next easiest thing. _Perhaps_ against convention, I tend to put one-line declarations (e.g. `subscriptions`) directly in the `Html.program` call - it looks prettier to me... _Sorry, Evan!_

## The Model

```haskell
type alias System =
    { colour : String
    , orbit  : Float
    , radius : Float
    , speed  : Float
    , moons  : Moons
    }
```

The model for this visualisation is **recursive**: a system is a body and its _moons_, all of which are systems themselves. However, this means we have an **infinitely-nesting** type, so we have to use sidestep this with a new `type Moons` to get a solid alias.

```haskell
type Moons
    = Moons (List System)
```

Of course, aside from a little extra destructuring, this doesn't change the capability of the type _at all_.

```haskell
type alias Model =
    { time   : Time
    , system : Maybe System
    }
```

The model is then just the current `Time` (from our subscription) and _maybe_ a `System`. If the AJAX response hasn't come back yet, or an error occurred during the lifecycle, our `System` is `Nothing`, and we can show something other than an empty sky.

```haskell
init =
    ( { time = 0, system = Nothing }
    , Http.send Register
        << Http.get "./test.json"
        <| planetify
    )
```

The initial command is the AJAX request: when this completes, the model will hold the returned JSON **or lack thereof**. I think this whole `Cmd` approach is really neat: our IO actions end up handled in _exactly_ the same way as our user interactions.

## JSON

```haskell
planetify : Decode.Decoder System
planetify =
    Decode.map5 System
        (Decode.field "colour" Decode.string)
        (Decode.field "orbit"  Decode.float )
        (Decode.field "radius" Decode.float )
        (Decode.field "speed"  Decode.float )
        (Decode.field "moons" << Decode.map Moons
                              << Decode.lazy
                              <| \_ -> Decode.list planetify)
```

When we get the AJAX response, we need to map it into a **data type**: in our case, the `System` type. In Elm, we do this with a `Json.Decoder`. Here, we use a decoder that can recursively deconstruct the JSON to match our type. It also validates our JSON response at the same time!

We need to use the `Decode.map` and `Decode.lazy` functions to avoid that pesky infinite type: the `Moons` type will be populated by a second map that occurs _lazily_.

## Update

```haskell
type Msg
    = Tick Time
    | Register (Result Http.Error System)
```

There are really only two things that happen in this visualisation: the `Time` updates (for the next animation frame), and the AJAX response _correctly or otherwise_.

```haskell
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Tick time ->
            ( { model | time = time }, Cmd.none )

        Register result ->
            ( { model | system = Result.toMaybe result }
            , Cmd.none
            )
```

Consequently, the handlers for these two cases are _very_ simple. Any `Time` update simply updates the model, and any server `Result` is recorded. As mentioned before, I have converted the `Result` to `Maybe` so I can encode _the response has not yet been received_ in the same way as _the request failed_ and _the response is invalid_. Don't be fooled: this is pure laziness on my part.

## View Ordering

```haskell
type alias Coordinate =
    ( Float, Float )
```

A coordinate is represented as `( x, y )`. If I weren't going for brevity, some operations would be helpful (e.g. `add`).

```haskell
type Renderable
    = Orbit
        { x      : Float
        , y      : Float
        , radius : Float
        }

    | Planet
        { x      : Float
        , y      : Float
        , radius : Float
        , colour : String
        }
```

In the first iteration of this code, there was no ordering on the `Svg` elements. This looked odd when satellites didn't go _behind_ a parent body (e.g. when the moon's orbit is at the "back" of the diagram), so I picked a configuration where this didn't happen. A few weeks later, however, I felt ashamed of myself, and fixed it.

So, now, we generate inspectable (thus easily orderable) records, and convert them to `SVG` later on. I think this turns out quite neatly, though it's perhaps the result of staring for too long at `Free` structures and interpreters.

```haskell
ordering : Renderable -> Float
ordering object =
    case object of
        Planet { y } -> y
        _            -> negate 1 / 0
```

For now, we just put `Orbit` rings right at the back. This looks a bit odd at times, and I think a better solution would be to split up the `ellipse` into several arcs, (to order around other `Svg`s), but that's one for another time.

---

Converting a `Renderable` to an `Svg` is very straightforward, as all the required information is stored within the `Renderable` type already. An easy modification to this app would be to allow user-defined _camera tilt_ (i.e. configurable `skew`), and it could simply be passed in as a parameter here.

It's perhaps worth pointing out that my `<<` and `<|` usage is a direct mapping from Haskell's `.` and `$`. The `<<` could quite easily be replaced with another `<|` of course, but it's just not the way I'm used to doing things! _Old dogs, new tricks..._

```haskell
renderables : Coordinate -> Time -> System -> List Renderable
renderables ( cx, cy ) time { orbit, colour, radius, speed, moons } =
    let
        ( cx_, cy_ ) =
            fromPolar (orbit, speed * inMinutes time)
                |> \( x, y ) -> ( cx + x, cy + 0.4 * y )

        ring =
            Orbit { x      = cx
                  , y      = cy
                  , radius = orbit
                  }

        planet =
            Planet { x      = cx_
                   , y      = cy_
                   , radius = radius
                   , colour = colour
                   }

        subrenderer =
            renderables ( cx_, cy_ ) time

        children =
            case moons of
                Moons ms ->
                    List.concatMap subrenderer ms
    in
        ring :: planet :: children
```

## View Construction

```haskell
toSvg : Renderable -> Svg.Svg Msg
toSvg renderable =
    case renderable of
        Orbit { x, y, radius } ->
            Svg.ellipse [ cx <| toString x
                        , cy <| toString y
                        , rx <| toString radius
                        , ry << toString <| 0.4 * radius
                        ] []

        Planet { x, y, radius, colour } ->
            Svg.circle [ cx    <| toString x
                       , cy    <| toString y
                       , r     <| toString radius
                       , style <| "fill:" ++ colour
                       ] []
```

See where those `Coordinate` functions would be useful?

I'll say now that **I don't like this function**: there's a pretty obvious optimisation to be made here. What I would _really_ like is a type of `Coordinate -> System -> List (Time -> Renderable)`, or even a result like `Time -> List Renderable`: in other words, we'd end up with a list of bodies positioned with respect to each _recursive_ orbit via _composed_ functions.

I haven't looked enough into Elm's compiler to know for certain, but I would imagine that this could be compiled efficiently if we ended up with `let .. in \time ->` as our general form. As `time` is the only important variable here, we could pre-build all this at the time of JSON receipt, and cut down on the calculations needed at run-time. It's just a thought, really.

For small-ish `System` cases, this works fine, but I'm not really a huge fan of the _good enough_ mentality, and I'm **certain** this function has room for improvement. It certainly shouldn't need to know the `skew` value to build view-independent coordinates.

```haskell
view : Model -> Html.Html Msg
view { time, system } =
    let
        container =
            Svg.svg [ viewBox "0 0 600 240"
                    , width "600px"
                    ]
    in
        case system of
            Nothing ->
                Html.div [] [ Html.text "What a quiet night..." ]

            Just data ->
                container << List.map toSvg
                          << List.sortBy ordering
                          << renderables ( 300.0, 120.0 ) time
                          <| data
```

Finally, we have the **view** function: the entry point for all the rendering process. This is nice and easy to understand, I hope: we can display some cursory error to the user for when AJAX fails, and otherwise kick off the animation.

Of course, I'd love to get `skew` into the `Model` so that it can be configured (and then passed to the rest of the view logic at render-time). Ooer.

That gets us to the end of the file! **All** the code for the top visualisation (that isn't just imported library code) is here: it really is that simple. If you want to see it more clearly, there is [a Gist of all the code](https://gist.github.com/i-am-tom/229afcf287bf870ac76b5a909cdcfb81) to be found here.

_Elm is wonderful. Try it._

Take care ♥


text:
# OpenAVT-iOS

[![License](https://img.shields.io/github/license/asllop/OpenAVT-iOS)](https://github.com/asllop/OpenAVT-iOS)

1. [ Introduction ](#intro)
2. [ Installation ](#install)
3. [ Usage ](#usage)
4. [ Custom Elements ](#custom)
5. [ Examples ](#examp)
6. [ Documentation ](#doc)
7. [ Author ](#auth)
8. [ License ](#lice)

## 1. Introduction

The Open Audio-Video Telemetry is a set of tools for performance monitoring in multimedia applications. The objectives are similar to those of the OpenTelemetry project, but specifically for sensing data from audio and video players. OpenAVT can be configured to generate Events, Metrics, or a combination of both.

## 2. Installation

To install OpenAVT-iOS, simply add the following line to your Podfile:

```ruby
pod 'OpenAVT-Core', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

Besides the Core, the following modules are available:

#### 2.1 AVPlayer Tracker

Tracker for the AVPlayer video and audio player.

```ruby
pod 'OpenAVT-AVPlayer', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

#### 2.2 Google IMA Tracker

Tracker for the Google IMA ads library.

```ruby
pod 'OpenAVT-IMA', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

#### 2.3 Graphite Backend

Backend for the Graphite metrics database.

```ruby
pod 'OpenAVT-Graphite', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

#### 2.4 InfluxDB Backend

Backend for the InfluxDB metrics database.

```ruby
pod 'OpenAVT-InfluxDB', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

#### 2.5 New Relic Backend

Backend for the New Relic data ingestion service.

```ruby
pod 'OpenAVT-NewRelic', :git => 'https://github.com/asllop/OpenAVT-iOS'
```

## 3. Usage

There are many ways to use the OpenAVT library, depending on the use case, here we will cover the most common combinations. We won't explain all the possible arguments passed to the constructors, only the essential ones. For the rest check out the [documentation](#doc).

### 3.1 Choosing a Backend

The first step is choosing the backend where the data will be sent. We currently support OOTB three different backends: Graphite, InfluxDB, and New Relic. Let's see how to init them:

#### 3.1.1 Init the Graphite Backend

```swift
let backend = OAVTBackendGraphite(host: "<IP_ADDRESS>")
```

`host` is the address of the Graphite server.

#### 3.1.2 Init the InfluxDB Backend

```swift
let backend = OAVTBackendInfluxdb(url: URL(string: "http://<IP_ADDRESS>:8086/write?db=test")!)
```

`url` is the URL of the InfluxDB server used to write data to a particular database (in this case named `test`).

#### 3.1.3 Init the New Relic Backend

```swift
let backend = OAVTBackendNewrelic()
```

The New Relic Mobile Agent must be installed and set up to use this backend.

### 3.2 Choosing a Hub

Next, we will choose a Hub. This element is used to obtain the data coming from the trackers and process it to pass the proper events to the backend. Users can implement their logic for this and use their custom hubs, but OpenAVT provides a default implementation that works for most cases.

For instruments with video tracker only, we will choose:

```swift
let hub = OAVTHubCore()
```

And for instruments with video and ads tracker:

```swift
let hub = OAVTHubCoreAds()
```

### 3.3 Choosing a Metricalc

This step is optional and only necessary if we want to generate metrics, if we only need events this section can be omitted. A Metricalc is something like a Hub but for metrics, it gets events and processes them to generate metrics. Again, users can provide custom implementation, but the OpenAVT library provides a default one:

```swift
let metricalc = OAVTMetricalcCore()
```

### 3.4 Choosing Trackers

And finally, the trackers, the piece that generates the data. Currently, OpenAVT provides two trackers: AVPlayer and Google IMA Ads. We won't cover how to set up the AVPlayer and IMA libraries, for this check out the corresponding documentation or the [examples](#examp).

#### 3.4.1 Init the AVPlayer Tracker

```swift
let tracker = OAVTTrackerAVPlayer(player: avplayer)
```

Where `player` is an instance of the AVPlayer.

#### 3.4.2 Init the IMA Tracker

```swift
let adTracker = OAVTTrackerIMA()
```

### 3.5 Creating the Instrument

Once we have all the elements, the only step left is putting everything together:

```swift
let instrument = OAVTInstrument(hub: hub, metricalc: metricalc, backend: backend)
let trackerId = instrument.addTracker(tracker)
let adTrackerId = instrument.addTracker(adTracker)
instrument.ready()
```

Here we have created a new instrument that contains all the elements, and once all are present, we called `ready()` to initialize everything, This will cause the execution of the method `OAVTComponentProtocol.instrumentReady(...)` in all trackers, hub, metricalc and backend. Now the instrument is ready to start generating data.

## 4. Custom Elements

OpenAVT provides a set of elements that cover a wide range of possibilities, but not all. For this reason, the most interesting capability it offers is its flexibility to accept custom implementations of these elements.

### 4.1 Custom Models

Creating custom models we can extend the data model, adding information that is useful for our specific use case and is not directly covered by OpenAVT.

#### 4.1.1 Custom Actions

Actions are instances of the class `OAVTAction`, and generatic a custom action is as easy as creating a new instance, providing the action name in the constructor:

```Swift
let myAction = OAVTAction(name: "CustomAction")
```

> By convention, action names are in upper camel case.

Now we can use it normally as any other action, for examplem, on an `emit`:

```Swift
instrument.emit(action: myAction, trackerId: trackerId)
```

#### 4.1.2 Custom Attributes

Attributes are instances of the class `OAVTAttribute`. We build a custom attribute by creating a new instance of the class, providing the name in the constructor:

```Swift
let myAttr = OAVTAttribute(name: "customAttribute")
```

> By convention, attribute names are in lower camel case.

In the previous section we saw how to create custom actions, but we left something. All actions have an associated time-since attribute. The attribute name is autogenerated based on the action name, being `timeSince` plus the action name the default. In the case of the example, it will be `timeSinceCustomAction`. But we can provide an attribute in the constructor if the default one doesn't work for us:

```Swift
let myAction = OAVTAction(name: "CustomAction", timeAttribute: OAVTAttribute(name: "myTimeSince"))
```

> You can read more on time-since attributes [here](https://github.com/asllop/OpenAVT-Docs#model), section *4.3 Attributes*.

A custom attribute can be used as any other attribute, for example, setting it on an event:

```Swift
// `event` is an instance of OAVTEvent
event.setAttribute(key: myAttr, value: "any value")
```

#### 4.1.3 Custom Metrics

Metrics are instances of the class `OAVTMetric`, and we build custom metrics by creating new instances of the class, providing the metric name, type and value in the constructor:

```Swift
let myMetric = OAVTMetric(name: "CustomMetric", type: .Gauge, value: 10.1)
```

> By convention, metric names are in upper camel case, like action names.

### 4.2 Custom Components

Components are objects that are part of an instrument, and conform to one of the derived protocols of `OAVTComponentProtocol`. In OpenAVT there are four types of components: Trackers, Hubs, Metricalcs and Backends.

Instruments allow hot-plugging of components, by using the lifecycle methods defined in the `OAVTComponentProtocol`. With `OAVTInstrument.addTracker(...)` and `OAVTInstrument.removeTracker(...)` we can add and remove tracker, and with `OAVTInstrument.setHub(...)`, `OAVTInstrument.setMetrical(...)` and `OAVTInstrument.setBackend(...)` we can set and overwrite hubs, metricals and backends. When this happens, the instrument calls `OAVTComponentProtocol.endOfService()` on the removed component. After any change on the instrument is made, we must call `OAVTInstrument.ready()`, that will call `OAVTComponentProtocol.ready()` on each component.

#### 4.2.1 Custom Trackers

A tracker is the element that knows about specific players, reading properties, registering observers, etc. In OpenAVT a tracker is a class that conforms to the `OAVTTrackerProtocol`, that in turn extends the `OAVTComponentProtocol`. So, the simplest possible tracker will look like:

```Swift
class DummyTracker: OAVTTrackerProtocol {
    private var state = OAVTState()

    func initEvent(event: OAVTEvent) -> OAVTEvent? {
        // Called when an emit(...) happens. It receives the event and must return an event or nil.
        // If an event is returned, it will be passed to the Hub.
        return event
    }

    func getState() -> OAVTState {
        // Return the state object
        return self.state
    }

    // Tracker ID, set by the instrument when the tracker is created.
    var trackerId: Int?

    func instrumentReady(instrument: OAVTInstrument) {
        // Called when ready() is called on the instrument.
    }

    func endOfService() {
        // Called when the tracker is removed from the instrument or when shutdown() is called.
    }
}
```

This tracker does almost nothing, just bypass the events received. But we could improve it a bit, let's say we want to send an event when the instrument is ready:

```Swift
    // Note that this must be a weak reference, otherwise we will have a retain cycle, because the instrument owns a reference to the tracker.
    private weak var instrument: OAVTInstrument?

    ...

    func instrumentReady(instrument: OAVTInstrument) {
        if self.instrument == nil {
            self.instrument = instrument
            self.instrument?.emit(action: OAVTAction.TrackerInit, tracker: self)
        }
    }
```

And now maybe we want to set a custom attribute to that event, but only that, no other one:

```Swift
    func initEvent(event: OAVTEvent) -> OAVTEvent? {
        if event.getAction() == OAVTAction.TrackerInit {
            event.setAttribute(key: OAVTAttribute(name: "myCustomAttr"), value: 1000)
        }
        return event
    }
```

Any event generated calling `emit` will pass thought this method (if the tracker argument of `emit` points to this tracker). Most events will be generated from within the tracker, when something happens in the player (a stream starts, the user pauses the playback, etc), but we can also call `emit` from any other place.

Generally, `instrumentReady` is used to do initializations, like registering observers in the player, set up states, send starting events, etc. And `endOfService` is used to undo all this, unregister observers, etc.

A tracker can also register attribute getters. An attribute getter binds a tracker method with an `OAVTAttribute`. Let's say our player reports the current playback position, and we want to include this attribute on every event. OpenAVT offers a pre-defined attribute to report this information: `OAVTAttribute.position`. We can define a method in our tracker that returns that position:

```Swift
    func getPosition() -> Int? {
        let p = ... //do whatever with the supported player to get the position.
        return p
    }
```

> By convention, times are reported as integers in milliseconds.

Now we need to bind this method to the attribute:

```Swift
    func instrumentReady(instrument: OAVTInstrument) {
        ...

        self.instrument?.registerGetter(attribute: OAVTAttribute.position, getter: self.getPosition, tracker: self)
    }
```

After this, every event that is emitted will contain the attribute `OAVTAttribute.position` automatically. But what if we only want to include the attribute in some events? For this we have an optional argument in the `registerGetter`, the `filter`. We pass it a function that returns a boolean:

```Swift
    self.instrument?.registerGetter(attribute: OAVTAttribute.position, getter: self.getPosition, tracker: self, filter: { event, _ in
        return event.getAction() == OAVTAction.Ping
    })
```

Now only ping events will have the attribute.

But, why all this complexity? It would be much easier to just call the `getPosition` method, and then set the attribute using `OAVTEvent.setAttribute`.

Certainly we could do that and it would work. But by registering attribute getters, any element outside the tracker, for example a Hub, can query for a specific attribute value (using `OAVTInstrument.callGetter(...)`), doesn't matter the class and the interface. And if the  queried getter is not defined, it will just return nil.

#### 4.2.2 Custom Hubs

A hub is the element that contains the bussiness logic. It receives events from the tracker and according to the type, state, and other conditions, it decides what to do. It can also act over other components, for example updating trackers state. In OpenAVT a hub is a class that conforms to the `OAVTHubProtocol`, that in turn extends the `OAVTComponentProtocol`. A simple hub could look like:

```Swift
class DummyHub: OAVTHubProtocol {
    func processEvent(event: OAVTEvent, tracker: OAVTTrackerProtocol) -> OAVTEvent? {
        // Called with the result of tracker's initEvent. It receives the event and must return an event or nil.
        // If an event is returned, it will be sent to the Metricalc and the Backend.
        return event
    }

    func instrumentReady(instrument: OAVTInstrument) {
        // Called when ready() is called on the instrument.
    }

    func endOfService() {
        // Called when the tracker is removed from the instrument or when shutdown() is called.
    }
}
```

The main method for a hub is the `processEvent`, that is called with the event returned by a tracker. Along with the event, it receives the tracker that generated it.

This simple hub does nothing more than bypassing the events received, but it could implement complex logics: It could update the tracker's state depending on the received events, block an event that is not supposed to happen, add or modify attributes, start or stop timers, etc. It's up to your particular use case. In the following example we see how to handle the pause logic:

```Swift
    func processEvent(event: OAVTEvent, tracker: OAVTTrackerProtocol) -> OAVTEvent? {
        if event.getAction() == OAVTAction.PauseBegin {
            if tracker.getState().isPaused {
                return nil
            }
            tracker.getState().isPaused = true
        }
        else if event.getAction() == OAVTAction.PauseFinish {
            if !tracker.getState().isPaused {
                return nil
            }
            tracker.getState().isPaused = false
        }
        return event
    }
```

#### 4.2.3 Custom Metricalcs

A metricalc is similar to a hub, but for metrics, it handles the business logic to generate metrics. A metricalc is a class that conforms to the `OAVTMetricalcProtocol`:

```Swift
class DummyMetricalc: OAVTMetricalcProtocol {
    func processMetric(event: OAVTEvent, tracker: OAVTTrackerProtocol) -> [OAVTMetric] {
        // Called with the result of hub's processEvent. It receives the event and returns an array of metrics.
        // If any metric is returned, it will be sent to the Backend.
        return []
    }

    func instrumentReady(instrument: OAVTInstrument) {
        // Called when ready() is called on the instrument.
    }

    func endOfService() {
        // Called when the tracker is removed from the instrument or when shutdown() is called.
    }
}
```

This metricalc does nothing, it generates no metrics. Let's imagine we want to generate a metric that measures the time between quality change events. We could do something like:

```Swift
    private var tsOfLastEvent: TimeInterval = 0.0

    func processMetric(event: OAVTEvent, tracker: OAVTTrackerProtocol) -> [OAVTMetric] {
        if event.getAction() == OAVTAction.QualityChangeUp || event.getAction() == OAVTAction.QualityChangeDown {
            if self.tsOfLastEvent > 0.0 {
                let metric = OAVTMetric(name: "TimeBetweenQualityChanges", type: .Gauge, value: NSDate().timeIntervalSince1970 - self.tsOfLastEvent)
                self.tsOfLastEvent = NSDate().timeIntervalSince1970
                return [metric]
            }
        }

        return []
    }
```

#### 4.2.4 Custom Backends

The final stop for an event is the backend, that is a class conforming to the `OAVTBackendProtocol`. Is the backend's duty to store or redirect data to a database, server, filesystem, etc.

```Swift
class DummyBackend: OAVTBackendProtocol {
    func sendEvent(event: OAVTEvent) {
        // Called with the result of hub's processEvent.
    }

    func sendMetric(metric: OAVTMetric) {
        // Called with the results of metricalc's processMetric.
    }

    func instrumentReady(instrument: OAVTInstrument) {
        // Called when ready() is called on the instrument.
    }

    func endOfService() {
        // Called when the tracker is removed from the instrument or when shutdown() is called.
    }
}
```

The method `sendMetric` is called once with each metric returned by metricalc's `processMetric`.

## 5. Examples

Inside the `Examples` folder, you will find multiple usage examples. To run them execute `pod install` from each example directory.

#### 5.1 ExampleAVPlayer

Shows how to use the AVPlayer tracker.

#### 5.2 ExampleAVPlayer+IMA

Shows how to use the AVPlayer tracker and the Google IMA ads tracker.

#### 5.3 ExamplePlayer-ObjC

Simple example using AVPlayer tracker in Objective-C.

## 6. Documentation

**Check out the [Documentation Repository](https://github.com/asllop/OpenAVT-Docs) for general and platform-independent documentation.**

All classes and methods are documented with annotations. To generate the docs in HTML or Markdown you can use [swift-doc](https://github.com/SwiftDocOrg/swift-doc), like this:

```bash
$ swift doc generate Sources/ --module-name OpenAVT --format html -o docs
$ cd docs
$ python -m SimpleHTTPServer 8000
```

And then open [http://localhost:8000](http://localhost:8000) with your preferred browser.

## 7. Author

Andreu Santarén Llop (asllop)

andreu.santaren at gmail .com

## 8. License

OpenAVT-iOS is available under the MIT license. See the LICENSE file for more info.

repository: asllop/OpenAVT-iOS

gha_language: Swift

repo_name: asllop/OpenAVT-iOS


text:
# DetectFrida
This project has 3 ways to detect frida hooking
a. Detect through named pipes used by Frida
b. Detect through frida specific named thread
c. Compare text section in memory with text section in disk

More details can be found @ https://darvincitech.wordpress.com/2019/12/23/detect-frida-for-android/

Also this project has 3 mechanisms to harden the native code
a. Replace certain libc calls with syscalls
b.  The hardened APK is provided for interested reverse engineers to analyze.

Updates:
a. Re-aligned functions
b. Fix scanning of executable sections only if it is readable to avoid crashes when app is targetting API 29
c. Stripped comment section in native library to prevent APKId detecting O-LLVM obfuscator is used


text:
# **Premutation Method**

**for Premutation method with MATLAB and Excel fol Alternatives**

## Step 01: Install Matlab software and Microsoft Excel

## Step 02: Learn about Premutation method

## Step 03: Download Premutation method in Excel [this here](https://1drv.ms/x/s!AguT2uoy_QiRiCjfm-dhnsNK1aTm)

## Step 04: Run Matlab code [this here](https://github.com/MKarimi21/University-of-Bojnurd/blob/master/MCDM/M-Karimi/MCDM-Premutation/MCDM_Premutation.m)

**Enjoy it!**

---
## For Guide or need help, Contact me:
- [Email](mailto:mkarimi21@hotmail.com), [LinkedIn](https://www.linkedin.com/in/mkarimi21/), [Telegram](https://telegram.me/mkarimi21).


text:
# Vanilla JS accordion.

This project implements Grunt and Sass whit only ES6.
For more information on Grunt, see the [Getting Started](http://gruntjs.com/getting-started) guide.

## Getting Started

Please make sure to install to run this project.
- [Node.js](https://nodejs.org/en/)
- [Grunt](http://gruntjs.com/)

Before start run
```bash
npm install
```

Start server and watch for changes:
```bash
npm start
```
this will open a window in the browser at `http://<IP_ADDRESS>:8081/`

Run lint:
```bash
npm run lint
```

repository: GonzaloChacon/vanilla-js-accordion

repo_name: GonzaloChacon/vanilla-js-accordion


text:
---
title: "Docker"
date: 2017-01-05
draft: true
---

# Docker {#sec:pi-docker}

Docker is a tool that allows us to deploy applications inside of
software containers.  A container allows a developer to package the
application along with dependencies associated with it and put all in
a box which is an isolated environment so that the underlying host
operating system is completely abstracted from the application running
inside the box.

It is a method of packaging software, to include not only our code,
but also other components such as a full file system, system tools,
services, and libraries. This can be useful for the Raspberry Pi
because it allows users to run applications without lot of steps, as
long as the application is packaged inside of a Docker image. We
simply install Docker and run the container.

According to the developers of Docker it includes the following
features:

* Portability
* Density
* Scalability
* Security

## Installation

First we need to make sure the Raspberry Pi is up to date so we can
install a recent version of docker.  The automated script maintained
by the Docker project will create a systemd service file and copy the
relevant Docker binaries into `/usr/bin/`.

```bash
pi$ sudo apt-get update
pi$ curl -sSL https://get.docker.com | sh
```

In order for us to start the docker daemon at the next boot, we add it
as follows:

```bash
pi$ sudo systemctl enable docker
```

Now if we reboot, the Docker daemon will start. In case you like to
avoid the first reboot, you can use the command:

```bash
pi$ sudo systemctl start docker
```

Naturally you do not have to do this after you reboot the next time.

The Docker client can only be used by `root` or members of the
`docker` group.  Thus, let us add the user pi (or your equivalent
user) to the docker group using:

```bash
pi$ sudo usermod -aG docker pi
```

After executing the previous command, we log out of the terminal restart
it so we are sure the user permissions are available in the shell we
use.

To test docker is installed successfully, we run the `hello-world`
docker image with the command:

```bash
pi$ docker run hello-world
```

If Docker is installed properly, we will see a `Hello from Docker!`
message.

## Docker Swarm

Swarm is a native clustering and scheduling tool for Docker. Instead
of just managing containers on a single server, we can manage
containers on a set of servers. The containers will be automatically
scheduled on the pool of servers making them appear as a single
resource. We will set up and use Docker on a number of Raspberry Pi's
install Docker on them and register them into a Docker Swarm.

## Creating a Network of Pi's with docker

In [Network of Pis](#pi-now-main) section we explained how to set up a network
of Pis. Here we assume that we start from such a network. The Pi's have all
different names, and are registered on the network. Each Pi has the public key
installed from the machine where you will login from for setting up the swarm.

Let us assume the names of the hosts are stored in a shell variable called

	hostnames = (red00 red01 red02 red03 red04)

Naturally, we want to install on these machines docker and register
them to the swarm. A variety of tools exist to simplify this process,
such as

* parallel shell <https://github.com/vallard/psh>
* cloudmesh parallel (TODO: find the link)

For now we use this simple shell program to install docker on each of
the hosts in the hostnames

```bash
hostnames = (red00 red01 red02 red03 red04)
for host in "${hostnames[@]}"
do
      ssh pi@$host curl -sSL https://get.docker.com | sh
done
```

Save this script in a file called `docker-install.sh` and set the executable rights with

	chmod u+x docker-install.sh

When we execute it with

	$ docker-install.sh

It will sequentially install docker on each host. This is not very
efficient and only works for a small number of hosts.

## Registering the Pi to the Swarm

Next we need to run on one of the nodes the management node for the
swarm to which all others servers register as workers. Although we
could run on this node als a worker, we will just run the manager on
it as we want to avoid overloading it and make sure it operates
smoothly.

We select the first host in our hostlist for it called `red00` Let us
assume the host has the ipaddress `<manager-ip-address>`. We can log
into this computer and execute the command

```bash
$ sudo docker swarm init --advertise-addr <manager-ip-address>:2377
```

This command will print out a token that we can use on the workers to
register with our swarm. The token will look something like:

	SWMTKN-abc...xyz

Let us use the term `<token>` to indicate the token. To register a
worker a two step process is used.

If you ever forget the token, you simply can use the following command
on the manager

	$ docker swarm join-token worker

It will print out the command that you will have to execute on a worker.

```bash
$ sudo docker swarm join --token SWMTKN-abc...manager...xyz <manager-ip-address>:2377
```

To see the list of nodes, you can use the command

```bash
I $ sudo docker node ls
```

## Docker Cheat Sheet

The following table is copied from the
[docker manual](https://github.com/docker/labs/blob/master/developer-tools/java/chapters/appa-common-commands.adoc)

.<div class="smalltable">

| Purpose| Command |
| ---- | ------------ |
| **Image** | |
| Build an image| docker image build --rm=true . |
| Install an image | docker image pull ${IMAGE} |
| List of installed images | docker image ls |
| List of installed images (detailed listing) | docker image ls --no-trunc |
| Remove an image | docker image rm ${IMAGE_ID} |
| Remove unused images | docker image prune |
| Remove all images | docker image rm $(docker image ls -aq) |
| **Containers** | |
| Run a container | docker container run |
| List of running containers | docker container ls |
| List of all containers | docker container ls -a |
| Stop a container | docker container stop ${CID} |
| Stop all running containers | docker container stop $(docker container ls -q) |
| List all exited containers with status 1 | docker container ls -a --filter "exited=1" |
| Remove a container | docker container rm ${CID} |
| Remove container by a regular expression | docker container ls -a `|` grep gregor `|` awk '{print $1}' `|` xargs docker container rm -f |
| Remove all exited containers | docker container rm -f $(docker container ls -a `|` grep Exit `|` awk '{ print $1 }') |
| Remove all containers | docker container rm $(docker container ls -aq) |
| Find IP address of the container | docker container inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID} |
| Attach to a container | docker container attach ${CID} |
| Open a shell in to a container | docker container exec -it ${CID} bash |
| Get container id for an image by a regular expression | docker container ls | grep gregor | awk '{print $1}' |

</div>

## Exercise

Swarm.1

: Your task is is to identify technologies to execute the Installation
  in parallel. Suitable technologies include

  * psh
  * ansible
  * puppet
  * python threads
  * cloudmesh

  We like that the class is split up in groups and each group develops this
  solution. Naturally you can test this first with not installing docker, but
  with a simple command such as `uname -a`

Swarm.2

: Develop a python cloudmesh command called

  `cms swarm config hostnames.yaml`

  where the yaml file looks something like

  ```yaml
  manager: <ip00>
  worker:
  - <ip01>
  - <ip02>
  - <ip03>
  ```

  Similarly create other convenient functions such as

  * `cms swarm kill`, which kills the swarm
  * `cms swarm ls`, which gives details about the swarm

repository: CoopYoung/pi

repo_name: CoopYoung/pi


text:
Base theme
===============================
[Link to theme-selector](theme-selector).

[FIGURE src="image/dynapac/basetheme.PNG?w=450" class="center w50"]

###Color schedule - Monokrom

Used just the base colors white and black in the base theme.

ACCENT
SECONDARY-1

###Font

For both the headings and the normal text Calibri is used and it is part of the Sans serif font family.

###Design elements
Because its a base theme I wanted to add as little extra design on the site as possible such as texture, lines and shapes. The colors is kept to the basic setup,
mostly white and black.

###Design principles
I have kept the grid based layout because I wanted to keep the unity and balance that it is giving to the site. It also provides some
form of proportion to the site. I've kept the flash image from earlier course tasks and that together with the BG-logotype is
creating a contrast.


text:
# ofxAnimation.h

## Requirements
* C++11 (is anyone *not* using this these days?)

## Usage
To use this library, include `ofxAnimation.h`.

the two objects the user deals with are:

* `AnimationFactory.h`
* `EasingFunction.h`

Create an instance of AnimationFactory:

`std::shared_ptr<AnimationFactory> factory = AnimationFactory::getInstance();`

You can call this function in any class with AnimationFactory.h included to call the factory.

If you'd like to create an animation, then select an easing function:

`std::shared_ptr<EasingFunction> myEasingFunction = EasingFunction::make(QUADRATIC, EASE_IN);`

and then create an animation:

`factory->addAnimation(myVariable, targetValue, 1000, myEasingFunction);`

the above will set the variable "myVariable" to transition to "targetValue" over 1000 milliseconds (1 second), using myEasingFunction.

You can reuse the same easing function for multiple variables:

```
factory->addAnimation(myVariable, targetValue, 1000, myEasingFunction);
factory->addAnimation(myOtherVariable, otherTargetValue, 5000, myEasingFunction);
factory->addAnimation(myFinalVariable, finalTargetValue, 3350, myEasingFunction);
```

The types of variables that can be animated are `float`, `ofColor`, and `ofPoint` -- for each of them use the
`addAnimation()` function:

```
factory->addAnimation(myFloat, 1234.567, 1000, myEasingFunction);
factory->addAnimation(myColor, ofColor(255, 0, 255, 128), 5000, myEasingFunction);
factory->addAnimation(myPoint, ofPoint(ofGetWidth/2.0, ofGetHeight()/2.0, 0.0), 3350, myEasingFunction);
```

Once you've added animations, just run `AnimationFactory::update()` in your loop -- this will update the clock for each
animation and update their values.

There are also optional callbacks that can be run when the animation is updating, or when it is completed.  Read the
header files to find out more about how to use these.

## Examples
* None yet!  But I'll make some soon.

## Contributing
This project uses the [Git Flow](http://nvie.com/posts/a-successful-git-branching-model/) paradigm.  Before contributing, please make your own feature branch with your changes.

## More Information
None at the moment.

repository: morphogencc/ofxAnimation

repo_name: morphogencc/ofxAnimation


text:
**Title:** Code War Kata - Alternate Capitalization

**Directions:**
Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even.

For example, capitalize("abcdef") = ['AbCdEf', 'aBcDeF']. See test cases for more examples.

The input will be a lowercase string with no spaces.

repository: dknore/Code-Wars

repo_name: dknore/Code-Wars