text:
# Spready
[![npm version](https://badge.fury.io/js/spready.svg)](https://badge.fury.io/js/spready)

Spready will help you to create a RESTFul backend  including basic CRUD operations with [NodeJS](https://nodejs.org/), [Express.js](https://expressjs.com/) and [MongoDB](https://www.mongodb.com/).

## Install
```shell
$ npm install -g spready
```
## use
```shell
// Initialize project
$ spready init
$ cd [project_name]

// Add new module
$ spready add-module ModuleName
```
It should make a question, like:
  + Name of the project (It will create a folder in your current working directory and the folder name will be your project name)

### Display the command options with the -h option:
```sh
$ spready -h

  Usage: spready [options] [name]

  Options:

    -h, --help          output usage information
        --version       output the version number
    -i, --init           initialize your project, create new
    -am, --add-module     Add new module
    -rm, --remove-module  Remove existing module
        --git           add .gitignore
    -f, --force         force on non-empty directory
```
## Project Structure
```bash
├── bin
│   ├── www
├── libs
│   ├── logger.js
├── modules
│   ├── module_one
│   │   ├── controllers/index.js
│   │   ├── models/index.js
│   │   ├── routes/index.js
│   ├── module_two
│   │   ├── controllers/index.js
│   │   ├── models/index.js
│   │   ├── routes/index.js
├── routes
│   ├── index.js
├── node_modules
├── app.js
├── variable.env
├── package.json
├── variable.env.example
└── .gitignore
```

`variables.env.example` is the file that serves as example for other people contributing to your project, it contains all the needed *env* variables with dummy values to be replaced after your project gets cloned (`variables.env` does not get tracked by git).

## Before running this project (after cloned from *github*)
* change the name of `variables.env.example` to `variables.env`
* inside `variables.env` replace the value of the variables with your values
* run `npm install` to make sure dependencies intallation

## How to Run this project
```shell
// Development
$ npm run dev
// Debug
$ npm run debug
// Default
$ npm start

```

## Mongoose
You can choose if you want to use [mongoose](http://mongoosejs.com/) in your project.

We recomend you to create an account on [mlab](https://mlab.com/), it is free; after that create a new database. To use it your project, you should paste the MongoDB URI (the one that you find after creating the database) in the files `variables.env` and `variables.env.now` into MONGO_URI, MONGO_PASSWORD, MONGO_USER
> If you don't use authenticated mongodb e.g local mongodb then remove MONGO_USER and MONGO_PASSWORD from variable.env file.
## Third-Party Libraries

+ winston: We are using `winston-2.x.x` to as logger. You can find the package [here](https://www.npmjs.com/package/winston)
> If you want to write logs into file then uncomment the first console from `lib/logger.js` and make a log file with same name.

+ slug: We are using `slug` to slugify. You can find the package [here](https://www.npmjs.com/package/slug)

+ mongoose-unique-validator: it is a plugin to validate unique into Mongoose Unique Validation instances. You can find the package [here](https://www.npmjs.com/package/mongoose-unique-validator)

## Endpoints
Request      | Response
-------------|----------------------------
GET base-url/examples | This will return all example with pagination support
POST base-url/examples | This will create a new example
GET base-url/example/{id} | This will return a example
PUT base-url/example/{id} | This is for updating a example
DELETE base-url/example | This will delete the example with identification

### Upcoming Features
- [ ] JWT integration for authentication and authorization
- [ ] DeployNow integration
- [ ] AWS-SDK
- [ ] ApiDoc generation
- [ ] Automated deploy with pm2 and Python-Fabric
- [ ] Dockerize
- [ ] and Based on feedback

## License
### The MIT License

Copyright (c) 2018 [Osman Goni Nahid](https://osmangoni.info/)

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

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

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

repository: osmangoninahid/spready

repo_name: osmangoninahid/spready


text:
# RedAgate's barcode tag library
#### QR Code, Code39, Code128, EAN (13/8/5/2) / UPC (A/E), ITF, NW7 (Codabar), etc...

[![npm](https://img.shields.io/npm/v/red-agate-barcode.svg)](https://www.npmjs.com/package/red-agate-barcode)
[![GitHub release](https://img.shields.io/github/release/shellyln/red-agate-barcode.svg)](https://github.com/shellyln/red-agate-barcode/releases)
[![Travis](https://img.shields.io/travis/shellyln/red-agate-barcode/master.svg)](https://travis-ci.org/shellyln/red-agate-barcode)
[![GitHub forks](https://img.shields.io/github/forks/shellyln/red-agate-barcode.svg?style=social&label=Fork)](https://github.com/shellyln/red-agate-barcode/fork)
[![GitHub stars](https://img.shields.io/github/stars/shellyln/red-agate-barcode.svg?style=social&label=Star)](https://github.com/shellyln/red-agate-barcode)

[RedAgate Project Home](https://github.com/shellyln/red-agate)

## Install

```bash
$ npm install red-agate --save
$ npm install red-agate-barcode --save
```

## License
[ISC](https://github.com/shellyln/red-agate-barcode/blob/master/LICENSE.md)
Copyright (c) 2017, Shellyl_N and Authors.

license: ISC

repository: shellyln/red-agate-barcode

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: shellyln/red-agate-barcode


text:
# Wavefront Helm Charts

[Helm](https://helm.sh/) is a package manager for Kubernetes. You can use Helm for installing Wavefront packages in your Kubernetes cluster.

Available Wavefront packages:
- [Wavefront Collector for Kubernetes](./wavefront/)
- [Wavefront HPA Adapter for Kubernetes](./wavefront-hpa-adapter/)
- [Wavefront Storage Adapter for Prometheus](./prometheus-storage-adapter/)
- [Wavefront Adapter for Istio](./wavefront-adapter-for-istio/)

## Installation

### Add the Wavefront Repo
```
helm repo add wavefront https://wavefronthq.github.io/helm/
helm repo update
```
### Install a chart
Follow the steps within the packages listed above to install the relevant chart.

repository: wavefrontHQ/helm

gha_language: Shell

repo_name: wavefrontHQ/helm


text:
# SmartHue esp8266

For a while, I wanted to create my own smart light. It's not a new concept, many similar repositories are already out there. But I couldn't find a firmware that also provides security and deployment.

I know, this is kind of free advertisement, but if you really want to know on what board I was developing: https://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/

Clone this repo:
```
git clone --recurse-submodules https://github.com/ThomasDevoogdt/SmartHue.git
cd SmartHue
```

## 1. Deploy

##### Install PlatformIO Core (CLI)

Have a look at the well-documentated page of [platformio](https://platformio.org/):

    https://docs.platformio.org/en/latest/installation.html

The installation can be checked with ```pio --version```.

```bash
$ pio --version
PlatformIO, version 3.6.3
```

##### Edid the ```config.json``` file:

Probably, You'll also need to change the ```ota_ap_pass``` in the ```platformio.ini``` file.

```json
{
    "security": {
        "soft_ap_pass": "4jBqXvQuEx7TBWfC",
        "ota_ap_pass": "QLZWyG9Q9JNmth9t",
        "www_user": "admin",
        "www_pass": "a2XEnxmsq7zm2B9P"
    }
}
```

### 1.1 Deploy: Using the serial interface. (The first time.)

```bash
platformio run --target upload
```

### 1.2. Deploy: Using OTA. (This can only be done if there's already a previous installation.)

Of course, its possible to manually upgrade every device with the ```platformio``` cli, but the preferred way is the usage of the deployment module.

How to manually upgrade: https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update

##### Setup python environment:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

##### Edid the ```devices.json``` file.

```json
{
    "devices": {
        "deploy": [
            "SmartHue-12345a",
            "SmartHue-12345c",
            "SmartHue-12345d"
        ]
    }
}
```

##### Run the deploy script:

```bash
python deployer.py -d devices.json
```

## 2. Usage

Super, you've now managed to upload the firmware to the esp8266. The esp8266 will boot and create a WiFi hotspot. The SSID is equal than the hostname of the device. Write it down, maybe you'll need it for an OTA update. Now you can test the device by calling https://<IP_ADDRESS>/api/systeminfo.

For security reasons, the AP/hotspot disables itself after 10 minutes. A power cycle is needed to re-enable the AP.

## 2.1 Device API

Note that everything goes over https. The certificates can be found under ```src/secure/ssl.h```. Accept them in your browser, or add them to your system trusted certificates. It's also a good thing to replace them with your own certificates.

- base url:
    * AP ip address (Only while serving AP):  https://<IP_ADDRESS>/
    * Over mDNS.local (Always up!): https://SmartHue-12345a.local/
- www_user: ```admin```
- www_pass: ```a2XEnxmsq7zm2B9P```

##### GET /api/version

no authentification needed

response: json body

##### GET /api/reboot

response: plain text: ok

##### GET /api/systeminfo

no authentification needed

response: json body

##### GET/POST /api/config

response/body: json body

```json
{
    "wifi": {
        "ssid": "SSID",
        "pass": "PASS"
    },
    "syslog": {
        "ip": "SYSLOG-IP"
    }
}
```

The syslog key is optional.

##### GET /api/config/reload

Only needed to apply changes after ```/api/config```

response: plain text: ok

##### GET /api/config/reset

Reset the current config to its default settings.

response: plain text: ok

##### GET /api/get [optional: ?relay=1]

no authentification needed

response: json body

```json
{
  "relay": 1,
  "value": true
}
```

##### POST /api/set

body: json body

```json
{
  "relay": 1,
  "value": true
}
```

response: plain text: ok

##### GET /api/ota

no authentification needed

response: json body

```json
{
    "ota": "success/Auth Failed/Begin Failed/Connect Failed/Receive Failed/End Failed"
}
```

## License

I'm not a juridical expert but please, be compliant with the license. If you like the project or write about it, please mention it. A simple link to this repo is enough.

license: MIT

repository: ThomasDevoogdt/SmartHue

gha_license_id: MIT

repo_name: ThomasDevoogdt/SmartHue


text:
#Team Information
* <Neha Lalwani>, <001268916><EMAIL_ADDRESS>* <Nirali Merchant>, <001268909><EMAIL_ADDRESS>* <Chintan Koticha>, <001267049><EMAIL_ADDRESS>* <Apoorva Lakhmani>, <001256312><EMAIL_ADDRESS>
#Prerequisites for building and deploying the application locally
* Click a spring boot web application with gradle project and mention all dependencies in build.gradle file
* Developing the source code for Rest based API endpoints.
* Mention persistant database environment (like MySQL) based details in applications.properties file
* Auto build trigger for Travis-CI needs to be handled by travis.yml file. Ensure scripts of artifact integration and test file integrations are written. Sync repository with Travis-CI and ensure it runs only when project contains travis.yml file.
* Build the project as a war package artifact and ensure project structure module has artifact linked to it.
* Edit configurations and add a local server(like tomcat). Create a deployment link to artifact create by project build.

#Instructions to run unit, integration test
* Write unit tests and integration tests in separate Java Class and annotate with required testing platform dependencies.
* For running locally, right click on the test functions and run them.
* For running on manual build trigger through Travis-CI server, ensure travis.yml contains scripts linked to the folder that contains unit tests. Push the code to repository to trigger a build or else trigger manual build from the travis-CI console to get the results.

#Instructions to run load based tests
* Install Apache-jmeter as a load test functional behavior and measuring performance.
* Run ./jmeter.sh through command line to open jmeter GUI console.
* Create a new thread group and set-up load testing platform like number of users and ramp-up time on the server for performance measurement
* Add the following to thread group:
	- Http Request sampler: Configure for the webpage server, GET/POST method, port number, and REST API endpoint URL.
	- HTTP Authorization Manager: Configure webpage server, Username and password for testing.
	- View results in tree: View results on running the application and jmeter test server.

#Link to Travis-CI build
* https://travis-ci.com/lakhmania/csye6225-fall2017

repository: lakhmania/AWS-TO-DO-application

repo_name: lakhmania/AWS-TO-DO-application


text:
### [CVE-2015-3900](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3900)
![](https://img.shields.io/static/v1?label=Product&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Version&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Vulnerability&message=n%2Fa&color=brighgreen)

### Description

RubyGems 2.0.x before 2.0.16, 2.2.x before 2.2.4, and 2.4.x before 2.4.7 does not validate the hostname when fetching gems or making API requests, which allows remote attackers to redirect requests to arbitrary domains via a crafted DNS SRV record, aka a "DNS hijack attack."

### POC

#### Reference
- http://www.oracle.com/technetwork/topics/security/bulletinoct2015-2511968.html
- https://hackerone.com/reports/103993

#### Github
- https://github.com/SpiderLabs/cve_server
- https://github.com/dcordero/Travis-Issue-7361

repository: trickest/cve

branch_name: refs/heads/main

gha_language: HTML

repo_name: trickest/cve


text:
# gulp-watchify-example

gulp + watchify + sourcemaps

gulpfile from: <https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md>

## Getting started

* `npm install`
* Start watching: `gulp js`
* Serve files: `http-server` (npm install -g http-server) or similar
* Edit JS files in `src/`

repository: nishanths/gulp-watchify-example

repo_name: nishanths/gulp-watchify-example


text:
# Brewery-App

Beer and a Movie App is a application designed to help you find a style of beer to drink based on what movie you're watching.

## Technologies used
Here are some technologies used:

- BreweryDB
- OMDB API
- tingle.js
- CSS3 Animations
- Firebase
- Html5
- Javascript
- Jquery

## Getting Started

Heroku Link

1. Search for a movie in the search-bar
2. receive results regarding that movie
3. click on the beer or movie poster for more information
4. search again

## Built With

* Atom - Sublime Text is pretty cool too I guess
* Firebase - The Database
* HTML - The Content
* CSS3 - Lots and lots of CSS3
* Tingle.js - The Modals

## Walk throughs of code
Here's some code for one of our modals.

```
var modal = new tingle.modal({
    footer: true,
    stickyFooter: false,
    closeLabel: "Close",
    cssClass: ['custom-class-1', 'custom-class-2', 'firstModal'],
    onOpen: function() {
        console.log('modal open');
    },
    onClose: function() {
        console.log('modal closed');
    },
    beforeClose: function() {
        // here's goes some logic
        // e.g. save content before closing the modal
        return true; // close the modal
      return false; // nothing happens
    }
});

// set content
modal.setContent('<h1>Are you 21 years of age or older?</h1>');

// add a button
modal.addFooterBtn('Yes', 'yesBtn tingle-btn tingle-btn--primary', function() {
   // Code for the push
   over21++
    firebase.database().ref().set({
      under21: under21,
      over21: over21
    });

    // here goes some logic
    modal.close();
    $(".contentDiv").removeClass("hide");
```

## Authors

Built with a love for beer by:
Iman Hamidi
Gregory Lee
Oscar Luna
Zackery Rilling

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

* Hat tip to robin parisi for his tingle.js that gave us modals
* Thanks to the alcohol i was drinking that gave me the idea
* Thanks Mom and Dad

repository: CodeOrangeZ/Brewery-App

gha_language: CSS

repo_name: CodeOrangeZ/Brewery-App


text:
---
type: rule
title: Do you have alerting for Azure Security Center?
uri: alert-for-azure-security-center
authors:
  - title: Bryden Oliver
    url: https://www.ssw.com.au/people/bryden-oliver
created: 2021-09-01T16:42:19.624Z
guid: 4becc3ae-639c-4690-8836-7f0a1f74630d
---
Once your environment is secured sufficiently you need to configure some alerting.
This will ensure that any changes either due to changes in your Azure deployment or more importantly improved scanning in Security Center result in you being alerted so that your infrastructure can be better secured.

<!--endintro-->

![Figure: To configure alerting try this](azure-security-center-alert.png)

You can then set up the Action to notify you. There're all sorts of filtering functionality as well.

Set up alerting on at least the Security Center recommendations and Threat Detection alerts. If you need to comply with a regulatory framework, then it's important to add an alert for that too (this is the 3rd of the Security Center data types), so that you can avoid compliance failures.

gha_language: TSQL


text:
## Release your app to the Play Store

*If you want to confirm that `fastlane` is installed before proceeding, open the Terminal and run `fastlane -v`. You should see the current version of `fastlane` displayed.*

First, you need to setup your Google Developers Service Account:

- Open the [Google Play Console](https://play.google.com/apps/publish/)
- Select **Settings** tab, followed by the **API access** tab
- Click the **Create Service Account** button and follow the **Google Developers Console** link in the dialog
- Click **Add credentials** and select **Service account**
- Select **JSON** as the Key type and click **Create**
- Make a note of the file name of the JSON file downloaded to your computer, and close the dialog
- Make a note of the **Email address** under **Service accounts** - this is the user which you will need later
- Back on the Google Play developer console, click **Done** to close the dialog
- Click on **Grant Access** for the newly added service account
- In the **Invite a New User** dialog, paste the service account email address you noted earlier into the **Email address** field
- Choose **Release Manager** from the **Role** dropdown and click **Send Invitation** to close the dialog

Once done, navigate to your Android project directory, run `fastlane init`, and follow the prompts. The command will create the following:

- A fastlane directory within your project directory
  - fastlane/Fastfile, which stores your deployment pipelines (lanes)
  - fastelane/Appfile, which stores your JSON key file path and package name

This lane uses two fastlane [actions](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md): `supply`. `supply` invokes the `supply` [tool](https://github.com/fastlane/fastlane/tree/master/supply) to upload Android apps and their metadata to the Play Store. Please note that the app
must already exist on the Play Store.

Open the fastlane/Fastfile in your preferred text editor, change the syntax highlighting to Ruby, and find the `deploy` lane:

```ruby
desc "Deploy a new version to the Google Play"
lane :deploy do
  gradle(task: "assembleRelease")
  supply
end
```

Run `fastlane android deploy` to execute the lane.

To see the full list of option to deploy your app, run `fastlane action supply`.

repository: atljeremy/setups

repo_name: atljeremy/setups


text:
# Charts

Dumping ground for various Helm Charts

## To-Do

- Consolidate all peoplesoft-related kubernetes helm charts under a single project
- Deprecate consul and vault charts in favor of the official hashicorp variants
  * https://github.com/hashicorp/consul-helm
  * https://github.com/hashicorp/vault-helm
- Enhance mssql-linux implementation
  * archive purging
  * sandbox image from registry
  * ha-ag
  * passwords from vault in addition to autogen
  * configurable pvc
  * add rancher-compatible chart questionaire
  * istio/linkerd/consul-connect compatibility
- Split ps-midtier into separate components
  * ps-webapp
  * ps-ib
  * ps-prcs

> WARNING: don't spend too much time on this - there's bigger fish to fry

repository: umaritimus/charts

gha_language: Smarty

repo_name: umaritimus/charts


text:
---
layout: post
title:  "Wooden Sanctuary"
date:   2017-01-01
source: From the Arcane Archive
tags: [cleric, druid, ranger, witch, level2, transmutation, hb, fan]
---

**2nd-level transmutation**

**Casting Time**: 1 action

**Range**: Self

**Components**: V, S

**Duration**: Concentration, up to 1 minute

You step into a wooden object or tree large enough to fully contain your body, melding yourself and all the equipment you carry with the wood for the duration. Using your movement, you step into the wood at a point you can touch. Nothing of your presence remains visible or otherwise detectable by nonmagical senses.
While merged with the wood, you can't see what occurs outside it, and any Wisdom (Perception) checks you make to hear sounds outside it are made with disadvantage. You remain aware of the passage of time and can cast spells on yourself while merged in the wood. You can use your movement to leave the wood where you entered it, which ends the spell. You otherwise can't move.
Minor physical damage to the wood doesn't harm you, but its partial destruction or a change in its shape (to the extent that you no longer fit within it) expels you and deals 3d6 bludgeoning damage to you; the same happens if your concentration is broken while merged with the wood. The wood's complete destruction (or transmutation into a different substance) expels you and deals 25 bludgeoning damage to you. If expelled, you fall prone in an unoccupied space closest to where you first entered.

repository: Teamdael/spellbook

extension: markdown

repo_name: Teamdael/spellbook


text:
---
title: "Ignore errors"
---

Sometimes an error is raised which AppSignal shouldn't send alert about. It's
not desired to capture an exception with a `begin..rescue` block just to
prevent AppSignal from alerting you. Instead, the exception should be handled
by the framework the application is using.

To prevent AppSignal from picking up these errors and alerting you, you can add
exceptions that you want to ignore to the list of ignored errors in your
configuration.

```yaml
# config/appsignal.yml
default: &defaults
  ignore_errors:
    - ActiveRecord::RecordNotFound
    - ActionController::RoutingError
```

You can also configure ignore exceptions via an environment variable.

```bash
export APPSIGNAL_IGNORE_ERRORS="ActiveRecord::RecordNotFound,ActionController::RoutingError"
```

Any exceptions defined here will not be sent to AppSignal and will not trigger
a notification.

Read more about [Exception
handling](/ruby/instrumentation/exception-handling.html).

repository: andrew/appsignal-docs

gha_language: Ruby

repo_name: andrew/appsignal-docs


text:
# Authentication

When arriving on the web interface, the user will be asked to authenticate itself, he can choose to login if he already has an account, or register if he's new to the platform.

## Login

To login, the user will have to provide a valid email and password.

<img :src="$withBase('/auth/login.png')" alt="Login form">

## Register

To register, the user will have to provide multiple informations to create an account.

<img :src="$withBase('/auth/register.png')" alt="Register form">


text:
---
published: true
title: The 2020 Spring Simulation Conference program is online
layout: post
categories:
- Workshop/Conference Organization
tags:
- spring simulation conference
---

<img src="{{ site.baseurl }}/images/posts/20200508_springsim_program.png" alt="SpringSim'20 Program" />

We are just ten days away from the 2020 Spring Simulation Conference. As the Program Chair of the conference, I am excited to tell you that we have an outstanding program, even though we had to shift all face-to-face events into a virtual setting. The conference will feature five tutorial sessions, one DEVS dissertation awards session, one demo session, eighteen regular paper + panel sessions covering 71 peer-reviewed papers. You can take a look at the details of the program [here](https://scs.org/springsim/). It is still not too late to register and participate in the conference. Never been at SpringSim before? Contact me for a free invitation. The conference has some slots for first-time, non-author participants.

gha_language: Jupyter Notebook


text:
# Feature Envy

## Introduction

_Feature Envy_ occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

_Feature Envy_ reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

_Feature Envy_ also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

_Feature Envy_ often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments.  That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

## Example

Running Reek on:

```Ruby
class Warehouse
  def sale_price(item)
    (item.price - item.rebate) * @vat
  end
end
```

would report:

```Bash
Warehouse#sale_price refers to item more than self (FeatureEnvy)
```

since this:

```Ruby
(item.price - item.rebate)
```

belongs to the Item class, not the Warehouse.

## Current Support in Reek

_Feature Envy_ reports any method that refers to self less often than it refers to (ie. send messages to) some other object.

## Edge cases

Be aware that there are some edge cases like this code:

```Ruby
class Foo
  def initialize
    @map = {
      a: ->(arg) { arg.css('table') },
      b: ->(arg) { arg.css('div') },
      c: ->(arg) { arg.css('span') }
    }
  end
end
```

Reek cannot reliably detect that each call's receiver is a different arg and will report:

```
  [4, 5, 6]:FeatureEnvy: Foo#initialize refers to 'arg' more than self (maybe move it to another class?)
```

If you're running into this problem you can disable this smell detector for this method either via
configuration:

```Yaml
---
FeatureEnvy:
  exclude:
    - 'Foo#bar'
```

or via source code comment:

```Ruby
class Foo
  # :reek:FeatureEnvy
  def initialize
    @map = {
    # ....
  end
end
```

## Differences to _Utility Function_

_Feature Envy_ is only triggered if there are some references to self and _[Utility Function](Utility-Function.md)_ is triggered if there are no references to self.

## Configuration

_Feature Envy_ supports the [Basic Smell Options](Basic-Smell-Options.md).

repository: troessner/reek

repo_name: troessner/reek


text:
# OMS Development VM (new)
The other one is not deprecated, but it is no longer in use

### How do I get set up? ###

Please read the [official landing page](https://oms-project.atlassian.net/wiki/spaces/OMS) at the documentation central repository

* Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and
  [Vagrant](https://www.vagrantup.com/downloads.html).
* Follow the instruction at the bottom of [this page](https://oms-project.atlassian.net/wiki/display/PROV/The+installation+script%3A+usage) and launch it with your POSIX-compliant shell (= FOR LINUX/OSX USERS ONLY). For windows users, if you want to virtualise linux keep in mind that the machine has to be powerful enough to virtualise at its inside. And you may have to fight with the port forwarding.
* Visit localhost:8000 in a browser to check if installation was successful.

### Possibly other remarks for Windows hosts ###

If you use Windows as host (i.e., as development platform), you have to be cautious about a few things:

* Be careful about too long filenames. Either clone at a high point of your folder structure (for example at `C:\aegee`), or use `git config --system core.longpaths true`(with Git 1.9.0 and above). See [here](http://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows) for details.
* You MUST use LF line endings in git. This is true for all submodules as well! See [this article](https://help.github.com/articles/dealing-with-line-endings/) for details.  See [this article](http://stackoverflow.com/questions/5917249/git-symlinks-in-windows) for more info.

repository: AEGEE/oms-homestead

repo_name: AEGEE/oms-homestead


text:
---
name: Feature proposal
about: Propose an idea for a feature
---

<!-- Please keep in mind that Lighthouse is a community project and features take effort.
Are you willing to provide a PR for this issue or aid in developing it? -->

**What problem does this feature proposal attempt to solve?**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Which possible solutions should be considered?**

<!-- How could the problem be solved? What alternative solutions exist? Which is best? -->

repository: nuwave/lighthouse

gha_language: PHP

repo_name: nuwave/lighthouse


text:
# WebDevSnippets by Jordi Corbilla
Just a collection of Snippets using different technologies (jQuery, AngularJS, etc.)

Example can be seen here for Draggable Layout:
http://output.jsbin.com/nunulo/1

repository: JordiCorbilla/WebDevSnippets

repo_name: JordiCorbilla/WebDevSnippets


text:
---
layout: post
title: "Meeting Minutes: March 29th"
categories: minutes
---

# Forum Topics

## Graverobbing
Hunter asks where all the new hardware came from and how it got so messy. It will get cleaned up before saturday.

## 3 lab directors?
The forum discusses the pros and cons of having 3 lab directors.

## Ryzen Purchase
Bobby shows off the finalized version of the Ryzen build. It will cost $1987. The forum approves the purchace.

# Lightning Talk

## DID YOU KNOW: XFCE Supports Animated Desktop Background [Kinda]!
Graham shows off a way to animate your desktop backgrounds, so long as you're using XFCE.

## Pan Corp
Pan Pan shows off his origional MP* page...

## LaTeX
Mike shows off LaTeX, a logical typesetting language, which makes quite beautiful formatted text files. He also shows off overleaf, an online LaTeX service.

## CSS Variable Fonts
Ben shows off the bleading edge CSS feature which allows Fonts to dynamically change on screen. Currently the only browser that supports it is the beta version of safari.

## CSS Grid
Ben shows off CSS's new grid proporty, giving people the ability to lay things out in better ways.

## Google Summer of Code
Anthony shows off Google's summer of code, where they pair you with a open source project to work on over the summer.

## https://searchinternethistory.com/  (once reddit hug of death subsides)
Kyle shows off a website based on the recent house resolution to allow ISP's to sell your browser history.

# Project Updates

## TalksCLI & Go Cross Compilation
Ben shows off the changes he's made to talks, allowing the view of the page from the command line. While making these changes he came across the fact that "go" can cross compile to any system.

## Roombas!
Kyle shows off the roombas that he's been fixing up for the labs.

## Meal Milker
Mike shows off the begining of the Meal Milker app for android. It syncs up freshman with free meals to upperclassman in need.

# Announcements

## Accepted Students Day this Saturday
Ben tells the lab that there will be an open house this saturday and COSI will be cleaned friday night.

## Ultimate Go w/ Bill Kennedy: May 11-12 @ SUNY Potsdam
Ben tells the labs that Bill Kennedy will be giving a talk at the SUNY Potsdam ACM where he will be teaching people how to use the Go programming language.

# After Meeting Slot
There was some joke after meeting slots...

repository: COSI-Lab/meeting-minutes

branch_name: refs/heads/gh-pages

repo_name: COSI-Lab/meeting-minutes


text:
# REoptLite.jl
*Renewable Energy Optimization and Integration*

!!! note
    This package is currently under development and not necessarily stable. It contains a subset of the [REopt Lite API](https://github.com/NREL/REopt_Lite_API) capabilities.

repository: djmartingale/REoptLite

repo_name: djmartingale/REoptLite


text:
## Bridge networks
 Are connect two networks while creating a single aggregate network from multiple communication networks or network segments, hence the name bridge.

![alt text](https://github.com/collabnix/dockerlabs/blob/master/beginners/images/Bridge_network.png)

In the above image Station A and Station B are connected by a bridge. Thus by using the bridge we aggregated both network in a single unit (on a high level). Bridge can even be used to create connection between networks on same host. This is generally required if the host is running multiple VM's or containers.

## Overlay networks

Are usually used to create a virtual network between two separate hosts. Virtual, since the network is build over an existing network.

![alt text](https://github.com/collabnix/dockerlabs/blob/master/beginners/images/Overlay_network.png)

In the above image host A and host B are connected over an external network and an overlay network is built over that network. For example initially internet was built as an overlay over telephone lines, but now many telephone networks (using VoIP) are an overlay over internet.

repository: sudharsanabrundha/dockerlabs

repo_name: sudharsanabrundha/dockerlabs


text:
# Contributing to picnic-basket

The first step toward contributing is a desire to improve the project!  Thank
you!

## Quick-contribute

* Create an account on [GitHub](http://github.com).
* Fork the cookbook
* Submit your change as a pull request
* If Matt hasn't looked at your PR or commented on it in a timely manner, please email him at<EMAIL_ADDRESS>or contact him on Slack (Chef employees only)

## The Apache License

Licensing is very important to open source projects, it helps ensure
the software continues to be available under the terms that the author
desired. Chef uses the Apache 2.0 license to strike a balance between
open contribution and allowing you to use the software however you
would like to.

The license tells you what rights you have that are provided by the
copyright holder. It is important that the contributor fully
understands what rights they are licensing and agrees to them.
Sometimes the copyright holder isn't the contributor, most often when
the contributor is doing work for a company.

## Ticket Tracker (GitHub Issues)

The [ticket tracker](https://github.com/mattstratton/picnic-basket/issues) is
the most important documentation for the code base. It provides significant
historical information, such as:

* Which release a bug fix is included in
* Discussion regarding the design and merits of features
* Error output to aid in finding similar bugs

Each ticket should aim to fix one bug or add one feature.

## Using git

You can get a quick copy of the repository for this cookbook by
running `git clone
git@github.com:mattstratton/picnic-basket.git`.

For collaboration purposes, it is best if you create a Github account
and fork the repository to your own account. Once you do this you will
be able to push your changes to your Github repository for others to
see and use.

If you have another repository in your GitHub account named the same
as the cookbook, we suggest you suffix the repository with -cookbook.

### Branches and Commits

You should submit your patch as a git branch named after the ticket,
such as ISSUE-22. This is called a _topic branch_ and allows users to
associate a branch of code with the ticket.

It is a best practice to have your commit message have a _summary
line_ that includes the ticket number, followed by an empty line and
then a brief description of the commit. This also helps other
contributors understand the purpose of changes to the code.

    [ISSUE-22] - platform_family and style

    * use platform_family for platform checking
    * update notifies syntax to "resource_type[resource_name]" instead of
      resources() lookup
    * ISSUE-692 - delete config files dropped off by packages in conf.d
    * dropped debian 4 support because all other platforms have the same
      values, and it is older than "old stable" debian release

Remember that not all users use Chef in the same way or on the same
operating systems as you, so it is helpful to be clear about your use
case and change so they can understand it even when it doesn't apply
to them.

## Functional and Unit Tests

This cookbook is set up to run tests under
[Test Kitchen](https://github.com/test-kitchen). It
uses [Serverspec](http://serverspec.org) to run integration tests after the node
has been converged to verify that the state of the node.

Test Kitchen should run completely without exception using the `.kitchen.yml`
file included in the project.

If your changes are only for a specific recipe, run only its
configuration with Test Kitchen. If you are adding a new recipe, or
other functionality such as a LWRP or definition, please add
appropriate tests and ensure they run with Test Kitchen.

Please investigate any failures before submitting your patch.

Any new feature should have unit tests included with the patch with
good code coverage to help protect it from future changes. Similarly,
patches that fix a bug or regression should have a _regression test_.
Simply put, this is a test that would fail without your patch but
passes with it. The goal is to ensure this bug doesn't regress in the
future. Consider a regular expression that doesn't match a certain
pattern that it should, so you provide a patch and a test to ensure
that the part of the code that uses this regular expression works as
expected. Later another contributor may modify this regular expression
in a way that breaks your use cases. The test you wrote will fail,
signaling to them to research your ticket and use case and accounting
for it.

If you need help writing tests, please ask on the [Chef Developer's mailing
list](http://lists.opscode.com/sympa/arc/chef-dev), or the [#chef-hacking IRC
channel](https://botbot.me/freenode/chef-hacking/).

## Versioning Policy

This cookbook follows the [Cookbook Versioning
Policy](http://chef-community.github.io/cvp/) maintained by the [Chef Community
organization on GitHub](https://github.com/chef-community).

## Cookbook Contribution Do's and Don't's

Please **do include tests** for your contribution. If you need help, ask
on the
[chef-dev mailing list](http://lists.opscode.com/sympa/arc/chef-dev)
or the
[#chef-hacking IRC channel](https://botbot.me/freenode/chef-hacking/).
Not all platforms that a cookbook supports may be supported by Test
Kitchen. Please provide evidence of testing your contribution if it
isn't trivial so we don't have to duplicate effort in testing. Chef
10.14+ "doc" formatted output is sufficient.

Please **do indicate new platform (families) or platform versions** in the
commit message, and update the relevant ticket.

If a contribution adds new platforms or platform versions, indicate
such in the body of the commit message(s), and update the relevant
issues. When writing commit messages, it is helpful for others if
you indicate the issue. For example:

    git commit -m '[ISSUE-1041] - Updated pool resource to correctly
    delete.'

Please **do use [foodcritic](http://acrmp.github.com/foodcritic)** to
lint-check the cookbook. Except FC007, it should pass all correctness
rules. FC007 is okay as long as the dependent cookbooks are *required*
for the default behavior of the cookbook, such as to support an
uncommon platform, secondary recipe, etc.

Please **do ensure that your changes do not break or modify behavior for
other platforms** supported by the cookbook. For example if your changes
are for Debian, make sure that they do not break on CentOS.

Please **do not modify the version number** in the metadata.rb, Chef
will select the appropriate version based on the release cycle
information above.

Please **do not update the CHANGELOG.md** for a new version. Not all
changes to a cookbook may be merged and released in the same versions.
Matt will update the CHANGELOG.md when releasing a new version of
the cookbook.

repository: mattstratton/picnic-basket

repo_name: mattstratton/picnic-basket


text:
Vending Machine Kata (PHP)
==========================
> The kata of machines, their vending and stuff.

In this exercise you will build the brains of a vending machine. It will accept
money, make change, maintain inventory, and dispense products. All the things
that you might expect a vending machine to accomplish.

The point of this kata to to provide a larger than trivial exercise that can be
used to practice TDD. A significant portion of the effort will be in
determining what tests should be written and, more importantly, written next.

How to Install
--------------

The recommended way to run this exercise is via [Vagrant](https://www.vagrantup.com/)
but it can be installed locally if your workstation is running PHP 7.

### Vagrant Install

Download [VirtualBox](https://www.virtualbox.org/) and
[Vagrant](https://www.vagrantup.com/) if you do not already have them. If you
have [Homebrew](http://brew.sh/) w/[Cask](http://caskroom.io/) on OS X you can
install it from the terminal via:

```sh
brew cask install virtualbox vagrant
```

Then run the following from the project directory root:

```sh
vagrant up
vagrant ssh
cd /vagrant
```

Once you are done with the Vagrant box to exit the SSH session enter:

```sh
exit
```

Then to shutdown the VM type:

```sh
vagrant halt
```

And lastly, when you are ready to delete the Vagrant box VM:

```sh
vagrant destroy
```

### Standard Install

Get [Composer](https://getcomposer.org/) if you do not have it already. Then
from the project directory root in the terminal:

- If you have a system wide install of Composer...

  ```sh
  composer install
  ```

- If you have a PHAR download of Composer...

  ```sh
  php composer.phar install
  ```

_Tested against PHP 7.0.3 and Composer 1.0-dev._

How to Test
-----------

From inside the project root in your terminal:

```sh
bin/phpspec run
```

Features
--------

### Accept Coins

_As a vendor_
_I want a vending machine that accepts coins_
_So that I can collect money from the customer_

The vending machine will accept valid coins (nickels, dimes, and quarters) and
reject invalid ones (pennies). When a valid coin is inserted the amount of the
coin will be added to the current amount and the display will be updated. When
there are no coins inserted, the machine displays "INSERT COIN". Rejected coins
are placed in the coin return.

NOTE: The temptation here will be to create Coin objects that know their value.
However, this is not how a real vending machine works. Instead, it identifies
coins by their weight and size and then assigned a value to what was inserted.
You will need to do something similar. This can be simulated using strings,
constants, enums, symbols, or something of that nature.

- [x] Accept nickels.
- [x] Accept dimes.
- [x] Accept quarters.
- [x] Reject pennies.

### Select Product

_As a vendor_
_I want customers to select products_
_So that I can give them an incentive to put money in the machine_

There are three products: cola for $1.00, chips for $0.50, and candy for $0.65.
When the respective button is pressed and enough money has been inserted, the
product is dispensed and the machine displays "THANK YOU".  If the display is
checked again, it will display "INSERT COIN" and the current amount will be set
to $0.00.  If there is not enough money inserted then the machine displays
PRICE and the price of the item and subsequent checks of the display will
display either "INSERT COIN" or the current amount as appropriate.

- [x] Sell cola for $1.00.
- [x] Sell chips for $0.50.
- [x] Sell candy for $0.65.
- [x] Display "INSERT COIN" and a zero balance if checked after purchase.
- [x] If there is not enough money inserted then the machine displays "PRICE" and the price of the item.
- [x] Display "INSERT COIN" if no money was inserted.
- [x] Display the current balance if any money was inserted.

### Make Change

_As a vendor_
_I want customers to receive correct change_
_So that they will use the vending machine again_

When a product is selected that costs less than the amount of money in the
machine, then the remaining amount is placed in the coin return.

- [x] Return change after a purchase.

### Return Coins

_As a customer_
_I want to have my money returned_
_So that I can change my mind about buying stuff from the vending machine_

When the return coins is selected, the money the customer has placed in the
machine is returned and the display shows "INSERT COIN".

- [x] Return deposited coins when the change return is pressed and display "INSERT COIN".

### Sold Out

_As a customer_
_I want to be told when the item I have selected is not available_
_So that I can select another item_

When the item selected by the customer is out of stock, the machine displays
"SOLD OUT".  If the display is checked again, it will display the amount of
money remaining in the machine or "INSERT COIN" if there is no money in the
machine.

- [x] When a selected item is sold out display "SOLD OUT".

### Exact Change Only

_As a customer_
_I want to be told when exact change is required_
_So that I can determine if I can buy something with the money I have before inserting it_

When the machine is not able to make change with the money in the machine for
any of the items that it sells, it will display "EXACT CHANGE ONLY" instead of
"INSERT COIN".

- [x] When unable to make change for any of the items it sells the display should read "EXACT CHANGE ONLY".

License
-------
This project is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT). You can view the full license [here](LICENSE).

repository: jbenner-radham/vending-machine-kata-php

repo_name: jbenner-radham/vending-machine-kata-php


text:
338\. Counting Bits

Easy

Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.

**Example 1:**

**Input:** n = 2

**Output:** [0,1,1]

**Explanation:**

    0 --> 0
    1 --> 1
    2 --> 10

**Example 2:**

**Input:** n = 5

**Output:** [0,1,1,2,1,2]

**Explanation:**

    0 --> 0
    1 --> 1
    2 --> 10
    3 --> 11
    4 --> 100
    5 --> 101

**Constraints:**

*   0 <= n <= 105

**Follow up:**

*   It is very easy to come up with a solution with a runtime of `O(n log n)`. Can you do it in linear time `O(n)` and possibly in a single pass?
*   Can you do it without using any built-in function (i.e., like `__builtin_popcount` in C++)?

repository: javadev/LeetCode-in-Java

gha_language: Java

repo_name: javadev/LeetCode-in-Java


text:
# session_manager

Reviewed on: 2021-10-01

`session_manager` is the component that runs and manages [session components](glossary.session-component).

## Building

Add the `session_manager` component to builds by including `--with-base
//src/session/bin/session_manager` in the `fx set` invocation followed by
rebuilding and re-paving the device.

Product configurations built on Session Framework (such as `fx set
workstation_eng.x64`) include `//src/session/bin/session_manager` by default.

## Running

`session_manager` is launched in one of two ways: manually or automatically on
system boot.

In general, running manually is useful during development, while running on boot
is desirable for a production configuration.

### Running manually

Use the [`ffx session`]((/docs/development/tools/ffx/getting-started.md) tool
to launch a specific session:

```
ffx session launch fuchsia-pkg://fuchsia.com/your_session#meta/your_session.cm
```

### Launching a session on boot

`session_manager` attempts to launch a session on boot based on the contents of
its `session_url` configuration parameter.

To boot into a session, include `session_manager` and the session component in
the base package set and assign the URL of the session component to the product
configuration:

```
fx set core.qemu-x64 \
  --with-base //src/session/bin/session_manager \
  --with-base //path/to/your_session \
  --args=product_config.session_url="fuchsia-pkg://fuchsia.com/your_package#meta/your_session.cm"
```

This can also be configured directly in a product's definition `*.gni` files
or via `fx args`.

Re-build, re-pave, and restart your device and it will boot into
`session_manager` and launch your session.

## Testing

Unit tests for `session_manager` are included in the `session_manager_tests`
package, and integration tests are included in the
`session_manager_integration_tests` package.

Both can be included in your build by adding `--with //src/session:tests` to
your `fx set`.

```
fx test session_manager_tests
fx test session_manager_integration_tests
```

## Source layout

The entry point for `session_manager` is in `src/main.rs` with implementation
details in other files within `src/`.

Unit tests are co-located with the code, while integration tests are in
[`//src/session/tests`](/src/session/tests).

[glossary.session-component]: /docs/glossary.md#session-component

repository: gnoliyil/fuchsia

repo_name: gnoliyil/fuchsia


text:
[![PyPi version](https://img.shields.io/pypi/v/html2json.svg)](https://pypi.python.org/pypi/html2json/)
[![PyPi pyversions](https://img.shields.io/pypi/pyversions/html2json.svg)](https://pypi.python.org/pypi/html2json/)
[![PyPi license](https://img.shields.io/pypi/l/html2json.svg)](https://pypi.python.org/pypi/html2json/)

Convert a HTML webpage to JSON data using a template defined in JSON.

Installation
----

This package is available on PyPi. Just use `pip install -U html2json` to install it. Then you can import it using `from html2json import collect`.

API
----

The method is `collect(html, template)`. `html` is the HTML of page loaded as string, and `template` is the JSON of template loaded as Python objects.

Note that the HTML must contain the root node, like `<html>...</html>` or `<div>...</div>`.

Template Syntax
----

- The basic syntax is `keyName: [selector, attr, [listOfRegexes]]`.
    1. `selector` is a CSS selector (supported by [lxml](http://lxml.de/)).
        - When the selector is `null`, the root node itself is matched.
        - When the selector cannot be matched, `null` is returned.
    2. `attr` matches the attribute value. It can be `null` to match either the inner text or the outer text when the inner text is empty.
    3. The list of regexes `[listOfRegexes]` supports two forms of regex operations. The operations with in the list are executed sequentially.
        - Replacement: `s/regex/replacement/g`. `g` is optional for multiple replacements.
        - Extraction: `/regex/`.

For example:

```json
{
    "Color": ["head link:nth-of-type(1)", "href", ["/\\w+(?=\\.css)/"]],
}
```

- As JSON, nested structure can be easily constructed.

```json
{
    "Cover": {
        "URL": [".cover img", "src", []],
        "Number of Favorites": [".cover .favorites", "value", []]
    },
}
```

- An alternative simplified syntax `keyName: [subRoot, subTemplate]` can be used.
    1. `subRoot` a CSS selector of the new root for each sub entry.
    2. `subTemplate` is a sub-template for each entry, recursively.

For example, the previous example can be simplified as follow.

```json
{
    "Cover": [".cover", {
        "URL": ["img", "src", []],
        "Number of Favorites": [".favorites", "value", []]
    }],
}
```

- To extract a list of sub-entries following the same sub-template, the list syntax is `keyName: [[subRoot, subTemplate]]`. Please note the difference (surrounding `[` and `]`) from the previous syntax above.
    1. `subRoot` is the CSS selector of the new root for each sub entry.
    2. `subTemplate` is the sub-template for each entry, recursively.

For example:

```json
{
    "Comments": [[".comments", {
        "From": [".from", null, []],
        "Content": [".content", null, []],
        "Photos": [["img", {
            "URL": ["", "src", []]
        }]]
    }]]
}
```


text:
# nics-web

## Building

You can build a 'debug' build using:

    mvn package

Or a 'production' build using:

    mvn package -Dproduction

Both options will build nics.war to the webapp/target/ directory

## Frequently Asked Questions

### What is the difference between a debug and production build?

A production build takes some extra steps to optimize the static resources like minifying the Javascript.

### What are these 'modules'?

Each 'module' is a maven jar project. It will package any compiled Java code for that module, plus any static resources (Javascript, CSS, Images) in [META-INF/resources](https://blogs.oracle.com/alexismp/entry/web_inf_lib_jar_meta). When these jars are included in the webapp WAR project, they Java will be executed at runtime and the static resources will be available.

### How do I use these modules?

Just add the module as a dependency of the webapp WAR project and add any code to bootstrap your module. This will likely include adding your module to main.js in the webapp and adding html link tags for your CSS to be included.

repository: hadrsystems/nics-web

repo_name: hadrsystems/nics-web


text:
# MLiy Open Source Administrator Guide

## Pre-requisites
- Knowledge of how to launch EC2, ELB and RDS resources in AWS
- AWS Account with subnets in a VPC
- Four security groups: One for ELB, one for MLiy Web Application, one for MLiy instances and one for MySQL RDS
  1.	MLiy-elb (if using ELB): Inbound on HTTPS port 443 from allowed networks and MLiy-ec2 and Outbound to HTTPS port 443 on MLiy-web.
  2. MLiy-web: Inbound on SSH 22 from allowed networks and on HTTPS port 443 from MLiy-elb (if ELB) or MLiy-ec2 (if no ELB),and Outbound to MySQL port 3306 on MLiy-db, LDAPS port 636 to LDAP server, DNS REST API port on 443 to DNS Registration service (optional)
  3. MLiy-ec2: Inbound SSH port 22 and HTTPS port 443 from allowed networks and Outbound to MLiy-elb (if ELB) or MLiy-ec2 (if no ELB) on HTTPS port 443, to the Internet directly or via proxy or to any other internal network and data services.
  4. MLiy-rds: Inbound to MySQL port 3306 from MLiy-web
- A location in S3 bucket to store the MLiy package
- An IAM role to use create and manage the following resources: CloudFormation, EC2, EBS, Auto Scaling Launch Configuration and Auto Scaling Group, Elastic Load Balancer and RDS DBInstance.
- An IAM instance profile for MLiy EC2 instance with ability to manage EC2, EBS, Cloudformation Stack and  read access to the S3 bucket containing the MLiy package and pass role permission to IAM role for MLiy
- An IAM instance profile for MLiy with encrypt/decrypt access to KMS keys and read/write access to S3 buckets
- SSL Certificate for MLiy website and wildcard certificate for application domain.
- Active Directory (AD) listening on LDAPS. OpenLDAP can be used with additional configuration. Not all features are supported with OpenLDAP out of the box.
- An LDAP account to be configured as a service account in order to verify group authorization
## Build
Checkout the MLiy project from Git.

Change directory to the scripts folder and run the following command to build:
```
cd scripts
bash build.sh
```
MLiy package odapweb.tar.gz is generated in the ./dist folder. Stage the ./dist/odapweb.tar.gz file in an S3 location.

## Install
### MLiy Web Application
The CloudFormation Stack will launch an EC2 instance via Auto Scaling Launch Configuration and Group and optionally create and ELB with multi-AZ support. Use AWS Console or CLI to invoke the CloudFormation template ./scripts/AWS_APP_MLiy_CloudFormation.json specifying the parameters appropriate for your environment.

- ImageId: The AMI (Amazon Machine Image) to use.
- KeyName: The SSH key pair to use.
- IamInstanceProfile: The instance profile to use.
- SecurityGroups: Security Groups to associate with Launch Configuration
- SourceBucket: The source S3 bucket where the installation script is located. Do not prefix with s3://.
- asVpcSubnets: The subnet(s) to use for the autoscaling group.
- OdapMgrHostname: The Fully Qualified Hostname of MLiy Web Application application.
- DjangoSecretKey: The secret key for a particular Django installation. This is used to provide cryptographic signing, and should be set to a unique, unpredictable value.
- LdapAuthUrl: Specifies the LDAP server, the base DN, the attribute to use in the search, as well as the extra search filter to use in the format ldaps://Your_LDAP_FQDN:636/User_DN?sAMAccountName?sub?(objectClass=*)
- LdapBindDn: A DN to bind with during the search phase.
- LdapBindPassword: A password to bind with during the search phase.
- LdapGroupAttribute: Authorize member of this group to access.

If you are using OpenLDAP, you will have to modify the file /etc/httpd/conf.d/odapserver.conf with the following changes:
1. Replace default Active Directory attributes with your OpenLDAP attributes in the value of AuthLDAPURL; for example, replace 'sAMAccountName,givenName,sn' with 'uid,cn,sn'
2. replace 'ldap-attribute memberOf=' with ldap-group and remove the double quotes around Group DN.
3. Restart Apache for the changes to take affect.

See http://httpd.apache.org/docs/current/mod/mod_authnz_ldap.html on how make your LDAP server work with MLiy. If your LDAP server does not have valid SSL certificate, you may temporarily disable certificate verification by uncommenting #LDAPVerifyServerCert Off in /etc/httpd/conf.d/odapserver.conf to test connectivity. It is recommended that you use valid SSL certificates.

MLiy deployment script creates Django models in the included sqllite3 database. You will want to use a separate MySQL database for production deployments.

### MySQL RDS
Similarly, use the CloudFormation template ./scripts/AWS_RDS_MLiy_CloudFormation.json to create a MySQL database.

- DBName: The database name.
- MasterUsername: The database admin account username.
- MasterUserPassword: The database admin account password
- VPCSecurityGroups: The list of VPC security groups that contains instances that need access to the database
- DBSubnetGroupName: A DB subnet group to associate with the DB instance.
- KmsKeyId: The ARN of the AWS Key Management Service (AWS KMS) master key that's used to encrypt the DB instance.
- DBParameterGroupName: The name of an existing DB parameter group.
- OptionGroupName: The option group that this DB instance is associated with.

## Post Installation Tasks
### Setup MySQL RDS Connection
1. On the MLiy web application server, replace information for sqlite3 with MySQL in the Databases section of odapweb/odapweb/settings.py file and restart the Apache server:
```
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME' : 'odapweb',
        'HOST' : 'your_rds_identifier.your_region.rds.amazonaws.com',
        'USER' : 'user_id_to_use_to_connect_to_mysql_db',
        'PASSWORD' : 'password_for_the_user_id',
        'OPTIONS' : {
                'charset' : 'utf8',
                'ssl': {'ca': '/etc/aws-rds/ssl/rds-combined-ca-bundle.pem'},
        }
    }
}
```
2. Go to the odapweb/odapweb folder and run the following commands to create the models in your MySQL RDS:
```
python manage.py makemigrations
python manage.py migrate
```
3. Restart apache
```
apachectl stop
apachectl start
```

### Create an admin user
Logon to MLiy instance using the SSH Key-pair and sudo to odapapp user and change to odapweb directory:
```
sudo su – odapapp
cd odapweb
```
Activate the Python virtual environment:
```
source ../img/odap-python/bin/activate
```
Run the following command to create an admin user:
```
python manage.py createsuperuser
```
You will be prompted to enter a username, email address and associated password. Please keep the credentials in a safe location.

You should now be able to open the MLiy website in a browser, click on “Log in to My Dashboard” on the top right corner, and logon with administrative credentials.

## Initial Setup and Ongoing Maintenance
Before you are able to launch and start using MLiy instances, you will need to create and register (see pre-requisites) some AWS resources.  Logon to MLiy Admin console using the URL https://dns_entry_for_odap_with_ssl_cert/admin. You will see a screen similar to the following:

Click on the Home link on the top left corner and click on Security Groups and add one or more valid security groups in the VPC.

Click on the Home link on the top left corner and click on Instance Types and add one or more valid EC2 instance types.

Click on the Home link on the top left corner and click on Groups and add one or more groups.

If MLiy is configured to use an LDAP/Active Directory server, a user will be added automatically the first time the user logs on. If MLiy is configured to use the local database for authentication, click on the Home link on the top left corner and click on Users and add one or more users.

Click on the Home link on the top left corner and click on Group Configs and add one or more group configuration. Select the group created earlier from the drop down box and give the group configuration a name (usually the same as the group name). Is a user is a member of the specified AD group, the user will automatically provisioned to this group and group configuration. Select any instance types to exclude, default security groups to use (in order to limit access to data and services) and optional security groups.

In order to identify EC2 instances launched by this group, provide an instance name.  Provide project name code and charge code and software development tags for AWS resources. Associate SSH keypair and IAM instance profile with this group configuration.

Click on the Home link on the top left corner and click on Software Configs and add one or more software configuration. Give the software configuration a name. Specify the shell script to run during instance provisioning and associated AWS Cloudformation template to call from the drop downs. Specify the AMI ID to launch the EC2 instance with. Select the compatible EC2 instance types for this software configuration.

Associate the groups/group configurations permitted to use this software configuration.  Specify the default instance name launched with this software configuration if none provided in the group configuration. Describe the software configuration in HTML format; users will see text when launching this software configuration.

Optionally, have the software configuration create an EBS volume. If so, specify the KMS key to encrypt is with, the device path the volume to be made available to the instance, the default size of the volume.

## Configuring MLiy Image
MLiy web application package includes a sample MLiy EC2 image in scripts/ec2 folder: bootstrap script userdata_MLiy.sh and the associated AWS Cloudformation template AWS_EC2_MLiy_CloudFormation.json.  If you extend and add your own bootstrap scripts and Cloudformation templates here, and build and deploy, you will be able to select them from the dropdown in the Software Configuration of MLiy Administrative Interface. You will notice tokens ({{{TEXT}}}) in the following bootstrap script. You can add parameters in Software Configuration to search and replace these tokens with appropriate values and set the environment variables to pass on to MLiy image.

```
# BEGIN Mandatory Settings
# Package Location, Name and Installation Script
export SOURCE_BUCKET='{{{SOURCE_BUCKET}}}'
export SOURCE_SCRIPT='{{{SOURCE_SCRIPT}}}'
export SOURCE_PACKAGE='{{{SOURCE_PACKAGE}}}'
# EBS Volume Device Name
export EBS_DEVICE='{{{EBS_DEVICE}}}'
# Set Time Zone see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
export TIME_ZONE='{{{TIME_ZONE}}}'
# END Mandatory Settings

# BEGIN Custom Settings
# The DNS resolvable fully qualified hostname for MLiy Website
export ODAPMGR_HOSTNAME='{{{ODAPMGR_HOSTNAME}}}'

# Custom R and Python Repository URLs
export CRAN_REPO='{{{CRAN_REPO}}}'
export PyPi_REPO='{{{PyPi_REPO}}}'

# LDAP Settings
export LDAP_HOST_NAME='{{{LDAP_HOST_NAME}}}'
export LDAP_USER_ID='{{{LDAP_USER_ID}}}'
# Command to execute in order to obtain password for LDAP_USER_ID. This could be opensource credstash, AWS secret manager or just simple echo password
export LDAP_USER_PASSWD_CMD='{{{LDAP_USER_PASSWD_CMD}}}'
export LDAP_USER_BIND_DN="{{{LDAP_USER_BIND_DN}}}"
export LDAP_BASE_DN='{{{LDAP_BASE_DN}}}'
export LDAP_AUTHZ_GROUP="{{{LDAP_AUTHZ_GROUP}}}"
# Wildcard Certificates
export WILDCARD_PUBLIC_CERT='{{{WILDCARD_PUBLIC_CERT}}}'
export WILDCARD_PRIVATE_CERT='{{{WILDCARD_PRIVATE_CERT}}}'
export WILDCARD_CERTS_ARCHIVE='{{{WILDCARD_CERTS_ARCHIVE}}}'
# Custom Root Cert to add to Linux trust store and Java Key Store
export CUSTOM_ROOT_CERTS='{{{CUSTOM_ROOT_CERTS}}}'

# END Custom Settings

cd ~
mkdir MLiy
cd MLiy
aws s3 cp s3://$SOURCE_BUCKET/$SOURCE_PACKAGE .
tar xzf $SOURCE_PACKAGE scripts/proxy.sh scripts/ec2/MLiy
rm -rf $SOURCE_PACKAGE
cd scripts/ec2/MLiy
export SCRIPT_DIR=$(pwd)
bash $SOURCE_SCRIPT
```

## Administrator commands

The MLiy website comes with several administrative commands that can be ran from the server instance. These commands implement the django admin command interface. The documentation for these commands can be found here:

[https://docs.djangoproject.com/en/2.0/ref/django-admin/]

#### Invoking using command line

The commands can be invoked using the command line on the instance. This can be done using a crontab, bash script or by directly running the command from the terminal.

To call the command you need to be in the proper python environment. MLiy comes with a virtual environment installed that is already provisioned with all the necessary libraries. This can  be accessed by calling:

```
source ~/odap-python/bin/activate

cd ~/odap-web

./manage.py 'command name'
```

#### Invoking using python

The commands can also be called inside python code, for example using the plugin system or when editing the source code. They can be called like so:

```
from django.core.management import call_command

call_command('command name')
```

### Refresh Models

This command will start an update thread to sync the database internal to the website with the actual state of instances in AWS. This thread will also be launched by the website, but in a low volume of traffic context it might make sense to run the thread on a schedule. Another use case is running the update thread early morning or after a weekend to make sure the website is prepared for the first user.

The command can be invoked with

```
./manage.py refresh
```

### Sync Cloudformation

This command takes the cloudformation templates and user data scripts from the internal file system and on the s3 location. The file system and s3 locations are located in the settings.py file. They can be set to any location where you will have the cloudformation and user data scripts.

```
DIRECTORY_FILE_LOCATION="scripts/ec2"

S3_FILE_LOCATION=""
```

The command will take the files on s3 and push them to the local repository. It will then populate the internal database with the cloudformation and user data such that you can choose them from a list within software configurations. It can be called with:

```
./manage.py sync_cf
```

### Load data

This is not a management command, but can be very useful when setting up the website initially. There are two fixtures provided with the site, which can be loaded as per this documentation:

[https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-loaddata]

```
./manage.py loaddata simpledb
```

Loads the database with sample information. This will have to be configured later but gives a starting point to work with. This will only work with at least one user and group already in the website (Probably the website superuser and a test group)

```
./manage.py loaddata instances
```

Loads the database with Amazon instance types. No prerequisites necessary.

repository: kcompher/MLiy

path: /docs/Administrator Guide.md

filename: Administrator Guide.md

repo_name: kcompher/MLiy


text:
# tsanley

Tsanley is a shape analyzer for tensor programs, using popular tensor libraries: `tensorflow`, `pytorch`, `numpy`. Plugs into your existing code seamlessly, with minimal changes.

Builds upon the library [tsalib](https://github.com/ofnote/tsalib) for specifying, annotating and transforming tensor shapes using **named dimensions**.

### Quick Start

`tsanley` discovers shape errors at runtime by checking the runtime tensor shapes against the user-specified shape annotations. Tensor shape annotations are specified in the `tsalib` shape shorthand notation, e.g., `x: 'btd'`.

More details on the shorthand format [here](https://github.com/ofnote/tsalib/blob/master/notebooks/shorthand.md).

#### Example

Suppose we have the following functions `foo` and `test_foo` in our existing code. To setup `tsanley` analyzer for shape checking in `foo`, we add a function `setup_named_dims` *before* calling `test_foo`, label tensor variables by their expected shorthand shapes (e.g., `b,d`) and then execute the code normally.

```python
def foo(x):
    x: 'b,t,d' #shape check: ok!               [line 36]
    y: 'b,d' = x.mean(dim=0)  # error!         [line 37]
    z: 'b,d' = x.mean(dim=1) #shape check: ok! [line 38]

def test_foo():
    import torch
    x = torch.Tensor(10, 100, 1024)
    foo(x)

def setup_named_dims():
    from tsalib import dim_vars
    #declare the named dimension variables using the tsalib api
    #e.g., 'b' stands for 'Batch' dimension with size 10
    dim_vars('Batch(b):10 Length(t):100 Hidden(d):1024')

    # initialize tsanley's dynamic shape analyzer
    from tsanley.dynamic import init_analyzer
    init_analyzer(trace_func_names=['foo'], show_updates=True) #check_tsa=True, debug=False

if __name__ == '__main__':
    setup_named_dims()
    test_foo()
```

On executing the above program, `tsanley` tracks shapes of tensor variables (`x`, `y`, `z`) in function `foo` and reports following shape check results.

#### Output

```bash
> Analyzing function foo

Update at line 36: actual shape of x = b,t,d
  >> shape check succeeded at line 36

Update at line 37: actual shape of y = t,d
  >> FAILED shape check at line 37
  expected: (b:10, d:1024), actual: (100, 1024)

Update at line 38: actual shape of z = b,d
  >> shape check succeeded at line 38
saving shapes to /tmp/shape_log.json ..
```

#### What does setup_named_dims do?

- Declare the named dimension variables (using `dim_vars`) -- using them we can specify the expected shape of tensor variables in the code. For example, here we declare 3 dimension variables, `Batch`, `Length` and `Hidden`, and refer to them via shorthand names `b`,`t`, `d`.
- We use shorthand names to label tensor variables and check their shapes in one or more functions, e.g., `foo` here.
- Initialize the `tsanley` analyzer by calling `init_analyzer`: parameter `trace_func_names` takes a list of function names as Unix shell-style wildcards (using the `fnmatch` library). We can specify names with wildcards, e.g., `Resnet.*` to track all functions in the `Resnet` class.

See examples in [models](models/) directory.

### Installation

```
pip install tsanley
```

### Annotation

`tsanley` can also annotate tensor variables in existing *executable* code with shape labels. This is useful when trying to understand external open-source code or labeling one's own code.

Suppose, we have some un-annotated code residing in file `model.py`.

1. First, generate *shape logs* by adding `setup_named_dims` to the `model.py`.
2. Execute `model.py`. The logs are stored in `/tmp/shape_log.json`.
2. Use the logs to annotate `model.py`.

#### Example
Let's revisit the earlier example, without our manual annotations. Suppose it resides in `model.py`.

```python
def foo(x):
    y = x.mean(dim=0)
    z = x.mean(dim=1)

def test_foo():
    import torch
    x = torch.Tensor(10, 100, 1024)
    foo(x)
```

We add `setup_named_dims` to the code, and execute it.

```python
def setup_named_dims():
    from tsalib import dim_vars
    #declare the named dimension variables using the tsalib api
    #e.g., 'b' stands for 'Batch' dimension with size 10
    dim_vars('Batch(b):10 Length(t):100 Hidden(d):1024')

    # initialize tsanley's dynamic shape analyzer
    from tsanley.dynamic import init_analyzer
    init_analyzer(trace_func_names=['foo'], show_updates=True, check_tsa=False) # debug=False

if __name__ == '__main__':
    setup_named_dims()
    test_foo()
```

This generates the shape logs in `/tmp/shape_log.json`. Flag `check_tsa=False` ensures no shape checks are performed by `tsanley`.

Now, annotate `foo` with the command:

> tsa annotate -f model.py

The output is a file `tsa_model.py` with `foo` updated as follows:

```python
def foo(x):
    y: 't,d' = x.mean(dim=0)
    z: 'b,d' = x.mean(dim=1)
```

`tsanley` makes smart guesses to map runtime shape values (`100`) to the shorthand names (`t`). If we do not declare the dimension names using `dim_vars` in `setup_named_dims`, we get the following annotation:

```python
def foo(x):
    y: '100,1024' = x.mean(dim=0)
    z: '10,1024' = x.mean(dim=1)
```

### Status: Work-In-Progress

`tsanley` is a work in progress. It performs a best-effort shape tracking during program execution. Here are a few tricky scenarios:

- calling same function multiple times -- shape values from only the last call are cached.
- recursive calls -- not handled.

Tested with `pytorch` examples. `tensorflow` and `numpy` programs should also work (`tsalib` supported backends), but remain to be tested.

Try it out and open an issue if you spot a missing feature or run into problems.

repository: ofnote/tsanley

repo_name: ofnote/tsanley


text:
# apex-source-control
Introducing file-based version-control for Oracle Application Express apps!

* Designed to be used by teams who want to bring their experience in version-control and APEX development together
* Any version-control tool can be used, not just git
* Tested on Linux and OSX (Windows not supported)

# Obsolete
This is obsolete now that SQLcl includes the application export functionality.
Running `apex export -skipExportDate -expOriginalIds -split -splitNoCheckSum -applicationid $apexappid`
will give the same result except for replacing absolute paths with relative paths in the scripts for git.

## Getting Started
Prerequisites:
* Oracle SQLcl on the path (https://www.oracle.com/database/technologies/appdev/sqlcl.html)

If you don't/can't use SQLcl, this also still supports the legacy tools from APEX 5.  To use them instead of sqlcl, you require:
* APEXExport.class and APEXExportSplitter.class which come with [APEX 5.0] (http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html) and above
* An `export APEX_HOME` with `$APEX_HOME/utilities/oracle/apex/*.class` being the location of the above mentioned files
* An installation of [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html)
* An `export ORACLE_HOME` with an existing `$ORACLE_HOME/jdbc/lib/jdbc6.jar` (likely included in installation of Oracle Instant Client)
* `sqlplus` on path

## Usage
#### Bring an existing APEX app into source control

1) Make a local directory for your app and in the new directory run `npm init` and follow the given prompts

2) Add the following lines to your devDependencies in package.json (Note: delete or repurpose the pre-existing scripts value)
```
"scripts": {
   "apex-to-file" : "apex-source-control apex-to-file",
   "file-to-apex" : "apex-source-control file-to-apex",
   "new-conf-file" : "apex-source-control new-conf-file",
   "switch-conf-file" : "apex-source-control switch-conf-file",
   "read-conf-file" : "apex-source-control read-conf-file",
   "generate-app-id" : "apex-source-control generate-app-id",
   "uninstall-apex" : "apex-source-control uninstall-apex"
},
```
If you want you can change the npm run commands (under scripts) to anything you'd like.

3) Run the following commands and follow the prompts. The app id, parsing_schema, workspace_name and database connection info should all correspond to the app you want to download (see Configuration)
```
npm install --save-dev apex-source-control
npm run new-conf-file 		#create a config file with the info of the app you want to download
npm run switch-conf-file 	#unnecessary if you choose to switch to your new config file in npm run in previous command
npm run apex-to-file 		#download the app locally
```
You can now set up the application as a git or other version-control repository. Be warned that if you downloaded the app from another developer's copy of the app, or some other version of the app you don't want to overwrite, you should create a new config file and set up a new version of the application.

#### Setting up from an APEX export file

1) Make a local directory for your app and in the new directory run `npm init` and follow the given prompts

2) Add the following lines to your devDependencies in package.json (Note: delete or repurpose the pre-existing scripts value)
```
"scripts": {
   "apex-to-file" : "apex-source-control apex-to-file",
   "file-to-apex" : "apex-source-control file-to-apex",
   "new-conf-file" : "apex-source-control new-conf-file",
   "switch-conf-file" : "apex-source-control switch-conf-file",
   "read-conf-file" : "apex-source-control read-conf-file",
   "generate-app-id" : "apex-source-control generate-app-id",
   "uninstall-apex" : "apex-source-control uninstall-apex"
},
```
If you want you can change the npm run commands (under scripts) to anything you'd like (see npm scripts Commands).

3) Run `npm install --save-dev apex-source-control`

4) Copy the export file into your project directory

5) Set up your classpath and run APEXExportSplitter on the export file
```
export CLASSPATH=$APEX_HOME/utilities:$ORACLE_HOME/jdbc/lib/ojdbc6.jar
java oracle.apex.APEXExportSplitter $export_file
```
The CLASSPATH variable does not need to be added to your bash profile

6) Rename the generated directory to apex/

7) cd into apex/ and run `sed -i 's^@application^@apex/application^g' install.sql`

We do this because we need to set the relative path to the install components from the top level directory

8) Remove the old `$export_file` or place it in a different directory

From here you can now either set up the project as a git/subversion/etc. repository or install into apex using:
```
npm run new-conf-file
npm run switch-conf-file #unnecessary if you choose to switch to your new config file in npm run new-conf-file
npm run file-to-apex
```
## Working with existing apex-source-control project

1) Clone the repository locally

2) Use `npm install` to install dependencies

3) Run the following commands and follow the prompts. This will set up your config file and put the application into your APEX workspace
```
npm run new-conf-file 		#create config file with the info of the app you want to use for version control
npm run switch-conf-file 	#unnecessary if you choose to switch to your new config file in npm run new-conf-file
npm run file-to-apex 		#download the app locally
```
That's it!

When you run `npm run new-conf-file` you can either enter the info of the app you are already using to develop (your version will be overwritten by the one in version control) or enter in the info of a non-existent app which will be automatically created after running `npm run file-to-apex` (see Configuration).

## npm scripts Commands
Note: You can change these commands to anything you like by editing the scripts value of `package.json`.
For example if you replaced `"apex-to-file" : "apex-source-control apex-to-file"` with `"atf" : "apex-source-control apex-to-file"` then your new command would be `npm run atf`.
##### npm run apex-to-file
Turn your apex workspace project into a file directory suitable for version control tools.
##### npm run file-to-apex
Import your file directory into apex as an apex application.
Will overwrite any existing app in the same workspace with the same id.

This command will only work with a $PROJECT_HOME/apex/ dir which was generated by `npm run apex-to-file` or is setup as described in steps 6 to 8 of Setting up from an APEX export file.
##### npm run uninstall-apex
Uninstall your app from apex
##### npm run new-conf-file
Creates a new config file using user input.
##### npm run switch-conf-file
Switches the symlink to the config file of user's choice
##### npm run read-conf-file
Outputs the name and contents of the config file currently being used
##### npm run generate-app-id
Logs into your database and automatically generates an unused app-id.
Used in order to avoid accidentaly overwritting someone else's app.
Can only be run if your config file is set up with proper database login info (see Config file examples).
###Workflow & Project Sanitation
* Ignore config files in version control (.gitignore for git) since you'll likely not want to share login info in version control.
If you want to leave the configs in version control then you should at least ignore the asc.conf symlink to avoid unnecessary noise
* Any non apex files you wish to put into version control along with your apex app should be placed in a project-top-level dir called non-apex
* After merging your code you should `npm run file-to-apex` and test that the merge didn't break anything
If you have automated tests you can just run those instead
* It is good practice to start your day with a merge

## Configuration
Config files are placed in a top level config/ directory.
Each developer has their own config file with their app data which is then refrenced by a symlink named `asc.conf` (short for apex-source-control.conf).
Config files should not be put under version control (unless you want to share connection data for some reason).
##### apexappid
The unique application id # of your APEX app in Oracle.
Used to tell APEX which application to export.

The application id does not have to already exist in APEX in order to be installed by `npm run file-to-apex` but must not conflict with an app id in a different workspace.
It can be the same as a pre-existing APEX app in the same workspace, but be careful about overwriting work that isn't your own.
##### workspace_name
Name of the workspace where the app is installed or is to be installed to.
The workspace should already exist before usage
##### parsing_schema
The parsing_schema used by APEX for this app.
If set incorrectly the app may not function at all when imported into APEX.
##### app_alias
The app alias to be used by APEX. Should usually not be set.

Since aliases must be unique within a workspace (and recommended to be unique within an instance) this should only be set for important versions of the app (i.e. production or dev versions).
If this field is left blank an app_alias will be auto-generated ('F' + $apexappid) to avoid conflicts.
##### database_connection
The database_connection info in [JDBC](http://www.orafaq.com/wiki/JDBC) format, i.e. Hostname:Port/SID. Example: `myhost:1521/orcl`.
Used in connect statements such as `sqlplus $username/$password@$database_connection`
##### username
Username of database login
##### password
Password of database login
#### Config file examples
A normal developer config file
```
apexappid=116
workspace_name=TEST_WORKSPACE
parsing_schema=PARSER
app_alias=
database_connection=localhost:1521/xe
username=the_coolest_guy
password=no_really_the_coolest
```
A config file for using `npm run generate-app-id`
```
apexappid=
workspace_name=
parsing_schema=
app_alias=
database_connection=localhost:1521/xe
username=the_coolest_guy
password=no_really_the_coolest
```
A config file for a production version of an app
```
apexappid=113
workspace_name=PROD_APPS
parsing_schema=PARSER
app_alias=Hello_World
database_connection=localhost:1521/xe
username=i_wanna_be_the_very_best
password=that_no_one_ever_was
```
###Known Issues
#### Deleting a page will always win merges
**To Reproduce**:
* Have two developers working on different versions of an app (i.e. working on different features to be added).
* Developer 1 deletes a page in the app and pushes to the project's repo.
* Developer 2 merges developer 1's changes and decides to keep the deleted page in the merge.
* When developer 2 reinstalls the app into apex the page will still be deleted.

**Why it occurs**:

Since a page was deleted, it's removed from the install.sql script generated by apex. When git sees the merge of the two developers, only one has changed the install.sql script so it automatically applies those changes to the merge meaning the page is no longer called during install so it's never created in your apex application.

**How to avoid**:

Be extremely careful when deleting pages and consult with your teammates first

**How to fix**:

If you do end up accidently deleting a page then you will have to manually re-add the install lines to the install.sql

#### Random version control noise in application meta-data
On every commit there will be conflicts within the create_application.sql (and likely some others) which will have to be resolved by hand.
Unfortunately there is no easy way to avoid this, but as you continue to use this tool you'll be able to quickly identify which files have real changes and which are garbage.

## Inspiration
These scripts were designed using [this paper] (http://www.rwijk.nl/AboutOracle/psdua.pdf) as reference.
There's a lot of good information about directory structure and general developer workflow so it's definitely worth a read.

It should be noted that if you decide to read the paper we have changed the names/functions of the scripts slightly: file-to-apex=install_apex.sql; uninstall-apex=uninstall_apex.sql; and apex-to-file=apexupdate.sh (Except we don't auto-update using subversion in order to leave more user freedom)

## Developers
To release:

 - update the version in package.json
 - tag with matching tag.  E.g. `git tag -a v1.3.2`
 - deploy to npm repo `npm publish`

repository: ntreeinc/apex-source-control

repo_name: ntreeinc/apex-source-control


text:
About
=====

This is collection of scripts to run each image

Files of interests
==================

* conf.d/builder

    Change IMAGES_DIR to point to location where all build images are stored

* conf.d/builder.bbs-*

    NET_MAC can be changed, noting that last 4 octets of mac address will be
    used to generate IP address of machine

Contact
=======

Michał Łyszczek<EMAIL_ADDRESS>

repository: mlyszczek/builder-init

repo_name: mlyszczek/builder-init


text:
---
id: engine
title: Engine
sidebar_label: Engine
---

The way to generate an engine is pretty simple, most of the time, you will use the `create_engine` method, expose in `tartiflette` package. This method performs all the necessary task needed to build your engine.

## `create_engine` prepares and cooks your engine

`create_engine` is the easiest and quickiest method to instanciate and build an Engine(). Behind the scene, this factory will implement the regular [cooking process](#cook-your-tartiflette).

### Using the SDL _(Schema Definition Language)_ parameter with different types

#### When the `sdl` parameter contains the raw schema

```python
from tartiflette import create_engine

engine = await create_engine(
    """
    type Query {
        hello: String
    }
    """
)
```

#### When the `sdl` parameter targets a file

The file path specified has to contain the full schema definition language.

```python
from tartiflette import create_engine

engine = await create_engine(
    "/User/chuck/workspace/mytartiflette/schema.graphql"
)
```

#### When the `sdl` parameter targets a file list

Every file will be concatenated, in the order of the provided list.

```python
from tartiflette import create_engine

engine = await create_engine(
    [
        "/User/chuck/workspace/mytartiflette/schema_query.graphql",
        "/User/chuck/workspace/mytartiflette/schema_mutation.graphql"
    ]
)
```

#### When the `sdl` parameter targets a folder

Every file which ends by `.graphql` _(or `.sdl`)_ will be concatenated in lexicographical order.

```python
from tartiflette import create_engine

engine = await create_engine(
    "/User/chuck/workspace/mytartiflette"
)
```

### Advanced constructor

The `create_engine` method provides an advanced interface for initialization. It accepts optional and named parameters.

```python
from tartiflette import create_engine

engine = await create_engine(
    sdl,
    schema_name="default",
)
```

1. **sdl:** Schema Definition Language, detailed above.
2. **schema_name:** Schema used from the **[Schema Registry](./schema-registry.md)**. _(default: "default")_
3. **[error_coercer](#parameter-error-coercer):** Coercer used when an error is raised.
4. **[custom_default_resolver](#parameter-custom-default-resolver):** Use another default resolver. (Useful if you want to override the behavior for resolving a property, e.g. from snake_case to camelCase and vice versa).
5. **[modules](#parameter-modules):** list of modules containing your decorated code such as `@Resolver`, `@Subscription`, `@Scalar` and `@Directive`.

#### Parameter: `error_coercer`

The main objective of the `error_coercer` is to provide you a way to extend the behavior when an exception is raised into tartiflette.

For instance:
* Add a log entry when a third-party exceptions is raised _(e.g pymsql, redis)_.
* Hide technical message's exception for production environment _(don't expose your internal stack from outside)_

`error_coercer` SHOULDN'T be used for custom functional exception, for this common use-case, please take a look of the [`TartifletteError` and its documentation's page](./error-handling.md).

```python
import logging
from tartiflette import create_engine

class CustomException(Exception):
    def __init__(self, type_name, message):
        self.type = type_name
        self.message = message

def my_error_coercer(exception, error) -> dict:
    if isinstance(exception, CustomException):
        logging.error("Unable to reach the Storage host.")
        error["extensions"]["type"] = exception.type

    return error

e = await create_engine(
    "my_sdl.graphql",
    error_coercer=my_error_coercer
)
```

#### Parameter: `custom_default_resolver`

Use another default resolver. It can be useful to override the behavior for resolving a property, from `snake_case` to `camelCase` and vice versa.

```python
from tartiflette import create_engine

async def my_default_resolver(parent_result, arguments, context, info):
    do_ing_some_thin_gs = 42
    return a_value

e = await create_engine(
    "my_sdl.graphql",
    custom_default_resolver=my_default_resolver
)
```

#### Parameter: `modules`

Prior creating the `Engine()`, all your code must be decoratored by these following ones to be taken into account.

* `@Resolver`
* `@Subscription`
* `@Scalar`
* `@Directive`

Doing it by yourself could be verbose and generate a lot of imports.

Both for your internal code and the plugins management, tartiflette provides a parameters called `modules` which give you the ability to specify all the internal and external code you want to import. In addition to the module, you will be able to specify a configuration, which will be mostly used by the [tartiflette plugin approach](../plugins/introduction.md).

```python
from tartiflette import create_engine

engine = await create_engine(
    os.path.dirname(os.path.abspath(__file__)) + "/sdl",
    modules=[
        "recipes_manager.query_resolvers",
        "recipes_manager.mutation_resolvers",
        "recipes_manager.subscription_resolvers",
        "recipes_manager.directives.auth",
        "recipes_manager.directives.rate_limiting",
    ]
)
```

instead of
```python
import recipes_manager.query_resolvers
import recipes_manager.mutation_resolvers
import recipes_manager.subscription_resolvers
import recipes_manager.directives.auth
import recipes_manager.directives.rate_limiting

engine = await create_engine(
    os.path.dirname(os.path.abspath(__file__)) + "/sdl"
)
```

##### Giving configuration to a module

```python
from tartiflette import create_engine

engine = create_engine(
    os.path.dirname(os.path.abspath(__file__)) + "/sdl",
    modules=[
        "recipes_manager.query_resolvers",
        "recipes_manager.mutation_resolvers",
        { "name": "a.module.that.needs.config", "config": {"key": "value"} },
        { "name": "another.module.that.needs.config", "config": {"key": "value"} }
    ]
)
```

## Advanced instanciation

For those who want to integrate tartiflette in advanced use-cases. You could be interested by owning the process of building an `Engine()`.

### Why owning the cooking (building) process of tartiflette?

The cooking process of tartiflette is equals to a `build` process on another librairies, it will prepare your engine to be executed. Thus, it's useless to say that an engine instance can't be executed without beeing cooked. Like the meal, you can't eat a tartiflette without cooking it first. That's it.

Customise the cooking process is interesting to integrate tartiflette into another librairies, like `aiohttp`, `starlette`, `django` and so one.

_For your information_: `tartiflette-aiohttp` has its own flow to manage the cooking process of the Engine.

### `cook()` your tartiflette

As specified above, the Engine() needs to be cook() before being executed. Here are the sequence to execute a query on an `Engine()` instance.

```python
from tartiflette import Engine

# 1. Create an instance of the Engine
engine = Engine()

# 2. Cook (build) the engine to prepare it to be executed
await engine.cook(
    """
    type Query {
        hello: String
    }
    """
)

# 3. Execute a GraphQL Query
engine.execute(
    query="query { hello )"
)
```

#### `cook()` interface

The `cook()` method is asynchronous, this *strong choice* will allow us to execute asynchronous tasks during the building process, like:

* Fetching SDL from another API.
* Fetch third-parties services _(Database structure, Cloud provider objects ...)_
* Fetch Schema from a Schema Manager.

```python
async def cook(
        self,
        sdl: Union[str, List[str]],
        error_coercer: Callable[[Exception], dict] = None,
        custom_default_resolver: Optional[Callable] = None,
        modules: Optional[Union[str, List[Union[str, Dict[str, Union[str, Dict[str, str]]]]]]] = None,
        schema_name: str = "default",
    ):
    pass
```

1. **sdl:** Schema Definition Language, detailed above.
2. **[error_coercer](#parameter-error-coercer):** Coercer used when an error is raised.
3. **[custom_default_resolver](#parameter-custom-default-resolver):** Use another default resolver. (Useful if you want to override the behavior for resolving a property, e.g. from snake_case to camelCase and vice versa).
4. **[modules](#parameter-modules):** list of modules containing your decorated code such as `@Resolver`, `@Subscription`, `@Scalar` and `@Directive`.
5. **schema_name:** Schema used from the **[Schema Registry](./schema-registry.md)**. _(default: "default")_

repository: adamhaney/tartiflette

repo_name: adamhaney/tartiflette