text:
# Lily
an RF power detecting GreatFET neighbor

Required KiCad dependency:

https://github.com/greatscottgadgets/gsg-kicad-lib

If you are using git, the preferred way to install gsg-kicad-lib is to use the
submodule:

```
git submodule init && git submodule update
```

## potential ICs
* LTC5507 100 kHz - 1 GHz
* HMC1120LP4E DC - 3.9 GHz
* MAX2016 LF - 2.5 GHz dual channel
* ADL5904 DC - 6 GHz
* AD8363 DC - 6 GHz
* HMC909LP4E DC - 5.8 GHz

## Pin usage

signal  | pin     | alt1  | alt2
--------|---------|-------|-----
VOUT    | J2.05   | J2.09 | J2.16
ENBL    | J1.03   | J1.04 | J1.05
RST     | GND     | J1.20 | J1.22
Q       |         | J2.17 | J2.18
Q bar   |         | J2.30 | J2.31

## Initial calibration data
Calibration data was taken by driving the RF input of Lily with a function generator creating a 10MHz sine wave at various amplitudes (VPP). The analog voltage output (VRMS) was measured with an oscilloscope and the ADC was used to convert VRMS into a digital measurement. Driving Lily with an input of VPP = 4V resulted in Lily drawing 4mA of supply current. The input should not exceed VPP = 5.62V in order to avoid damaging the board.

VPP     | VRMS    | ADC
--------|---------|-------
10mV    | 25mV    | 7
50mV    | 0.258V  | 84
0.1V    | 0.478V  | 155
0.2V    | 0.697V  | 227
0.3V    | 0.830V  | 267
0.5V    | 0.988V  | 317
1V      | 1.2V    | 386
2V      | 1.4V    | 454
3V      | 1.57V   | 494
4V      | 1.66V   | 524

repository: greatfet-hardware/lily

repo_name: greatfet-hardware/lily


text:
#Cloning the instagram login screen interface.

  Technologies   |
  Getting started   |
  License

---
## 🚀 Technologies

The project is being developed using the following technologies:

- Yarn
- JavaScript
- Node.js
- Expo
- Android Studio
---

## ⌨ Getting started

```bash
# Getting Started with React Native Expo Android / iOS
This project was launched with Expo Android/ iOS
`https://expo.io/learn`

# Opening the emulator project or on your own smartphone
`expo start`
It will open your localhost, http: // localhost: 19002. Containing the console and other functions to open it on the smartphone or emulator to view it.

```

## 📝 License

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

---

Developed with 💜 by Laércio Almeida

license: MIT

branch_name: refs/heads/main

extension: md

license_type: permissive


text:
# KiCad Partslist Editor

KiCad Partslist Editor (PLE) allows you to export/import customizable
fields from a hierarchical KiCad schematic file to and from a CSV.

* Load the root sheet of your project
* export the CSV file
* edit this CSV in your favourite spreadsheet editor (e.g. LibreOffice Calc)
* backimport this CSV into KiCad PLE and save your changes then to your schematic files.

Tested with Python 3.5.2 on Linux Mint 18, with KiCad 4.0.7 and KiCad 5 (nightly)

![Screenshot](screenshot.png)

## Installation

### Windows
Running KiCad Partslist-editor using windows, requires either Python 3
and TKinter, or you can run the compiled version, which can be found in
the folder `\build\exe.win32-3.4\`

### Linux
On linux you have to install python3 and python3-tk with
```sudo apt-get install python3 python3-tk```

Then you can run the part list editor with
```python3 PartsListEditor.py```
or just use the minimal shell script `kicad-partlist-editor-linux.sh`

## Usage

* The 'Load Schematic' button, allows one to open the kicad
.sch files, which subsequently parses the selected schematic
file and all its hierarchical daughter modules.

* Hitting the 'Export CSV' button will allow you to save a
.CSV file containing the parsed contents of the schematic files.

* The 'Import CSV' button lets you select the csv file containing the the
partslist as generated by KiCad PLE including the edits as made by the
user using an external program.

* The 'Save Schematic' button updates the schematic files with the updated
information as loaded through the 'Import CSV' operation.

**NOTE**: the columns `Reference`, `Unit` and `File` must not be edited
in the CSV file.

### Deprecated
These functions need a scrollable canvas to be useful.
* 'List Parts' shows the parts of the opened schematic in the GUI.
* 'Sort Parts' will sort the parts list in alphabetic order.

## Advanced Usage
To change the fields that the KiCad PLE imports, exports and edits, edit
the FieldKeywords.conf file

The syntax of the **FieldKeywords.conf** file is:
First line is version string, this should not be changed
Lastline is end-of-file indicator

All lines starting with "<" define a field KiCad PLE will look for in
.SCH files

The syntax of such a line is as follows:

``` <Fieldname|Field_alias1|Field_alias2|Field_alias3> ```

The Fieldname is the primary alias, so it can be considered Field_alias0
 as well.

The amount of aliases which can be added is theoretically unlimited, but
 the minimum is 1 (i.e. the field name)

``` <MyFieldName> ``` isn't supported, one has to declare it with an alias:
``` <MyFieldName|MyFieldName> ```

The separator for CSV files can be set in the file `config.ini`.
Double quoted fields are used in the CSV, if necessary (if it contains the separator).

## Limitations
* Currently it is not allowed to use double quotes in KiCads field names or field values

## Further Ideas for Improvement
### Extract Field Names from Schematics and CSV
* obsolete FieldKeywords.conf
* type of fields are managed by project data without metadata
* new fields can be defined by the CSV
* redundant field names can easily be merged within CSV-spreadsheet
with 'auto-filter'

### Index Column
* index column 'Index' with a line counting number
* gives ability to sort the list and do a proper file comparison with
diff after manipulations

### Commandline Interface
For scripting it would be nice, if the PLE could be used without any GUI.

branch_name: refs/heads/master

gha_language: Tcl


text:
# Consul Sync

Keep a file's contents updated based on the value of a consul key.

```
Usage: consul-sync [options] key filename

  Sync the value of the Consul key to the file contents

options:
  --http-addr=<IP_ADDRESS>:8500    HTTP address of the Consul agent.

```

repository: metocean/consul-sync

repo_name: metocean/consul-sync


text:
# Contribute to the Moby Project

Want to hack on the Moby Project? Awesome! We have a contributor's guide that explains
[setting up a development environment and the contribution
process](docs/contributing/).

[![Contributors guide](docs/static_files/contributors.png)](https://docs.docker.com/opensource/project/who-written-for/)

This page contains information about reporting issues as well as some tips and
guidelines useful to experienced open source contributors. Finally, make sure
you read our [community guidelines](#moby-community-guidelines) before you
start participating.

## Topics

* [Reporting Security Issues](#reporting-security-issues)
* [Design and Cleanup Proposals](#design-and-cleanup-proposals)
* [Reporting Issues](#reporting-other-issues)
* [Quick Contribution Tips and Guidelines](#quick-contribution-tips-and-guidelines)
* [Community Guidelines](#moby-community-guidelines)

## Reporting security issues

The Moby maintainers take security seriously. If you discover a security
issue, please bring it to their attention right away!

Please **DO NOT** file a public issue, instead send your report privately to
[security@docker.com](mailto:security@docker.com).

Security reports are greatly appreciated and we will publicly thank you for it,
although we keep your name confidential if you request it. We also like to send
gifts—if you're into schwag, make sure to let us know. We currently do not
offer a paid security bounty program, but are not ruling it out in the future.

## Reporting other issues

A great way to contribute to the project is to send a detailed report when you
encounter an issue. We always appreciate a well-written, thorough bug report,
and will thank you for it!

Check that [our issue database](https://github.com/moby/moby/issues)
doesn't already include that problem or suggestion before submitting an issue.
If you find a match, you can use the "subscribe" button to get notified on
updates. Do *not* leave random "+1" or "I have this too" comments, as they
only clutter the discussion, and don't help resolving it. However, if you
have ways to reproduce the issue or have additional information that may help
resolving the issue, please leave a comment.

When reporting issues, always include:

* The output of `docker version`.
* The output of `docker info`.

Also include the steps required to reproduce the problem if possible and
applicable. This information will help us review and fix your issue faster.
When sending lengthy log-files, consider posting them as a gist (https://gist.github.com).
Don't forget to remove sensitive data from your logfiles before posting (you can
replace those parts with "REDACTED").

## Quick contribution tips and guidelines

This section gives the experienced contributor some tips and guidelines.

### Pull requests are always welcome

Not sure if that typo is worth a pull request? Found a bug and know how to fix
it? Do it! We will appreciate it. Any significant improvement should be
documented as [a GitHub issue](https://github.com/moby/moby/issues) before
anybody starts working on it.

We are always thrilled to receive pull requests. We do our best to process them
quickly. If your pull request is not accepted on the first try,
don't get discouraged! Our contributor's guide explains [the review process we
use for simple changes](https://docs.docker.com/contribute/overview/).

### Design and cleanup proposals

You can propose new designs for existing Docker features. You can also design
entirely new features. We really appreciate contributors who want to refactor or
otherwise cleanup our project. For information on making these types of
contributions, see [the advanced contribution
section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in
the contributors guide.

### Connect with other Moby Project contributors

  <col width="45%">
  <col width="65%">

    Forums

      A public forum for users to discuss questions and explore current design patterns and
      best practices about all the Moby projects. To participate, log in with your Github
      account or create an account at https://forums.mobyproject.org.

    Slack

        Register for the Docker Community Slack at
	https://dockr.ly/slack.
        We use the #moby-project channel for general discussion, and there are separate channels for other Moby projects such as #containerd.

    Twitter

      You can follow Moby Project Twitter feed
      to get updates on our products. You can also tweet us questions or just
      share blogs or stories.

### Conventions

Fork the repository and make changes on your fork in a feature branch:

- If it's a bug fix branch, name it XXXX-something where XXXX is the number of
	the issue.
- If it's a feature branch, create an enhancement issue to announce
	your intentions, and name it XXXX-something where XXXX is the number of the
	issue.

Submit tests for your changes. See [TESTING.md](./TESTING.md) for details.

If your changes need integration tests, write them against the API. The `cli`
integration tests are slowly either migrated to API tests or moved away as unit
tests in `docker/cli` and end-to-end tests for Docker.

Update the documentation when creating or modifying features. Test your
documentation changes for clarity, concision, and correctness, as well as a
clean documentation build. See our contributors guide for [our style
guide](https://docs.docker.com/opensource/doc-style) and instructions on [building
the documentation](https://docs.docker.com/opensource/project/test-and-docs/#build-and-test-the-documentation).

Write clean code. Universally formatted code promotes ease of writing, reading,
and maintenance. Always run `gofmt -s -w file.go` on each changed file before
committing your changes. Most editors have plug-ins that do this automatically.

Pull request descriptions should be as clear as possible and include a reference
to all the issues that they address.

### Successful Changes

Before contributing large or high impact changes, make the effort to coordinate
with the maintainers of the project before submitting a pull request. This
prevents you from doing extra work that may or may not be merged.

Large PRs that are just submitted without any prior communication are unlikely
to be successful.

While pull requests are the methodology for submitting changes to code, changes
are much more likely to be accepted if they are accompanied by additional
engineering work. While we don't define this explicitly, most of these goals
are accomplished through communication of the design goals and subsequent
solutions. Often times, it helps to first state the problem before presenting
solutions.

Typically, the best methods of accomplishing this are to submit an issue,
stating the problem. This issue can include a problem statement and a
checklist with requirements. If solutions are proposed, alternatives should be
listed and eliminated. Even if the criteria for elimination of a solution is
frivolous, say so.

Larger changes typically work best with design documents. These are focused on
providing context to the design at the time the feature was conceived and can
inform future documentation contributions.

### Commit Messages

Commit messages must start with a capitalized and short summary (max. 50 chars)
written in the imperative, followed by an optional, more detailed explanatory
text which is separated from the summary by an empty line.

Commit messages should follow best practices, including explaining the context
of the problem and how it was solved, including in caveats or follow up changes
required. They should tell the story of the change and provide readers
understanding of what led to it.

If you're lost about what this even means, please see [How to Write a Git
Commit Message](http://chris.beams.io/posts/git-commit/) for a start.

In practice, the best approach to maintaining a nice commit message is to
leverage a `git add -p` and `git commit --amend` to formulate a solid
changeset. This allows one to piece together a change, as information becomes
available.

If you squash a series of commits, don't just submit that. Re-write the commit
message, as if the series of commits was a single stroke of brilliance.

That said, there is no requirement to have a single commit for a PR, as long as
each commit tells the story. For example, if there is a feature that requires a
package, it might make sense to have the package in a separate commit then have
a subsequent commit that uses it.

 Don't make
your chapter weird.

### Review

Code review comments may be added to your pull request. Discuss, then make the
suggested modifications and push additional commits to your feature branch. Post
a comment after pushing. New commits show up in the pull request automatically,
but the reviewers are notified only when you comment.

Pull requests must be cleanly rebased on top of master without multiple branches
mixed into the PR.

**Git tip**: If your PR no longer merges cleanly, use `rebase master` in your
feature branch to update your pull request rather than `merge master`.

Before you make a pull request, squash your commits into logical units of work
using `git rebase -i` and `git push -f`. A logical unit of work is a consistent
set of patches that should be reviewed together: for example, upgrading the
version of a vendored dependency and taking advantage of its now available new
feature constitute two separate units of work. Implementing a new function and
calling it in another file constitute a single logical unit of work. The very
high majority of submissions should have a single commit, so if in doubt: squash
down to one.

After every commit, [make sure the test suite passes](./TESTING.md). Include
documentation changes in the same pull request so that a revert would remove
all traces of the feature or fix.

Include an issue reference like `Closes #XXXX` or `Fixes #XXXX` in commits that
close an issue. Including references automatically closes the issue on a merge.

Please do not add yourself to the `AUTHORS` file, as it is regenerated regularly
from the Git history.

Please see the [Coding Style](#coding-style) for further guidelines.

### Merge approval

Moby maintainers use LGTM (Looks Good To Me) in comments on the code review to
indicate acceptance, or use the Github review approval feature.

For an explanation of the review and approval process see the
[REVIEWING](project/REVIEWING.md) page.

### Sign your work

The sign-off is a simple line at the end of the explanation for the patch. Your
signature certifies that you wrote the patch or otherwise have the right to pass
it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)):

```
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
```

Then you just add a line to every git commit message:

    Signed-off-by: Joe Smith<EMAIL_ADDRESS>
Use your real name (sorry, no pseudonyms or anonymous contributions.)

### How can I become a maintainer?

The procedures for adding new maintainers are explained in the
[/project/GOVERNANCE.md](/project/GOVERNANCE.md)
file in this repository.

 Make sure you
will have time to make yourself available. You don't have to be a
maintainer to make a difference on the project!

## Moby community guidelines

We want to keep the Moby community awesome, growing and collaborative. We need
your help to keep it that way. To help with this we've come up with some general
guidelines for the community as a whole:

* Be nice: Be courteous, respectful and polite to fellow community members:
  no regional, racial, gender, or other abuse will be tolerated. We like
  nice people way better than mean ones!

* Encourage diversity and participation: Make everyone in our community feel
  welcome, regardless of their background and the extent of their
  contributions, and do everything possible to encourage participation in
  our community.

* Keep it legal: Basically, don't get us in trouble. Share only content that
  you own, do not share private or sensitive information, and don't break
  the law.

* Stay on topic: Make sure that you are posting to the correct channel and
  avoid off-topic discussions. Remember when you update an issue or respond
  to an email you are potentially sending to a large number of people. Please
  consider this before you update. Also remember that nobody likes spam.

* Don't send email to the maintainers: There's no need to send email to the
  maintainers to ask them to investigate an issue or to take a look at a
  pull request. Instead of sending an email, GitHub mentions should be
  used to ping maintainers to review a pull request, a proposal or an
  issue.

The open source governance for this repository is handled via the [Moby Technical Steering Committee (TSC)](https://github.com/moby/tsc)
charter. For any concerns with the community process regarding technical contributions,
please contact the TSC. More information on project governance is available in
our [project/GOVERNANCE.md](/project/GOVERNANCE.md) document.

### Guideline violations — 3 strikes method

The point of this section is not to find opportunities to punish people, but we
do need a fair way to deal with people who are making our community suck.

1. First occurrence: We'll give you a friendly, but public reminder that the
   behavior is inappropriate according to our guidelines.

2. Second occurrence: We will send you a private message with a warning that
   any additional violations will result in removal from the community.

3. Third occurrence: Depending on the violation, we may need to delete or ban
   your account.

**Notes:**

* Obvious spammers are banned on first occurrence. If we don't do this, we'll
  have spam all over the place.

* Violations are forgiven after 6 months of good behavior, and we won't hold a
  grudge.

* People who commit minor infractions will get some education, rather than
  hammering them in the 3 strikes process.

* The rules apply equally to everyone in the community, no matter how much
	you've contributed.

* Extreme violations of a threatening, abusive, destructive or illegal nature
	will be addressed immediately and are not subject to 3 strikes or forgiveness.

* Contact<EMAIL_ADDRESS>to report abuse or appeal violations. In the case of
	appeals, we know that mistakes happen, and we'll work with you to come up with a
	fair solution if there has been a misunderstanding.

## Coding Style

Unless explicitly stated, we follow all coding guidelines from the Go
community. While some of these standards may seem arbitrary, they somehow seem
to result in a solid, consistent codebase.

It is possible that the code base does not currently comply with these
guidelines. We are not looking for a massive PR that fixes this, since that
goes against the spirit of the guidelines. All new contributions should make a
best effort to clean up and make the code base better than they left it.
Obviously, apply your best judgement. Remember, the goal here is to make the
code base easier for humans to navigate and understand. Always keep that in
mind when nudging others to comply.

The rules:

1. All code should be formatted with `gofmt -s`.
2. All code should pass the default levels of
   [`golint`](https://github.com/golang/lint).
3. All code should follow the guidelines covered in [Effective
   Go](http://golang.org/doc/effective_go.html) and [Go Code Review
   Comments](https://github.com/golang/go/wiki/CodeReviewComments).
4. Comment the code. Tell us the why, the history and the context.
5. Document _all_ declarations and methods, even private ones. Declare
   expectations, caveats and anything else that may be important. If a type
   gets exported, having the comments already there will ensure it's ready.
6. Variable name length should be proportional to its context and no longer.
   `noCommaALongVariableNameLikeThisIsNotMoreClearWhenASimpleCommentWouldDo`.
   In practice, short methods will have short variable names and globals will
   have longer names.
7. No underscores in package names. If you need a compound name, step back,
   and re-examine why you need a compound name. If you still think you need a
   compound name, lose the underscore.
8. No utils or helpers packages. If a function is not general enough to
   warrant its own package, it has not been written generally enough to be a
   part of a util package. Just leave it unexported and well-documented.
9. All tests should run with `go test` and outside tooling should not be
   required. No, we don't need another unit testing framework. Assertion
   packages are acceptable if they provide _real_ incremental value.
10. Even though we call these "rules" above, they are actually just
    guidelines. Since you've read all the rules, you now know that.

If you are having trouble getting into the mood of idiomatic Go, we recommend
reading through [Effective Go](https://go.dev/doc/effective_go). The
[Go Blog](https://go.dev/blog/) is also a great resource. Drinking the
kool-aid is a lot easier than going thirsty.

repository: moby/moby

gha_language: Go

repo_name: moby/moby


text:
# Project18 - "Programming & Scripting"

   ### Researched, written and compiled by:
  > Marco Men

## Research

  This project was written and compiled using python's library package named 'panda'( an abbreviation for 'panel data'). The resources and references used are provided below:

 * https://archive.ics.uci.edu - 'UCI Machine Learning Reposityory'
 * https://en.m.wikipedia.org - 'Iris flower data set'
 * https://statcan.gc.ca - 'Constructing box and whisker plots'
 * www.datacarpentry.org - 'Python for ecologists'
 * https://machinelearningmastery.com - 'Your First Machine Learning Project in Python Step-By-Step'
 * blog.bharatbhole.com - ' Creating boxplotswith Matplotlib'
 * https://pandas.pydata.org
 * https://matplotlib.org
 * www.kaggle.com - 'Iris Dataset ML and Deep Learning from Scratch'
 * https://medium.com - 'Basic Analysis of Iris Data set using Python'
 * https://neuraldesigner.com - 'Iris flowers classification'
 * 'Pandas For Everyone - Python Data Analysis' -Daniel Y. Chen(Addison -Wesley) -2018

### Before Start of the Project

Upon completion of literature review consisting of matplotlib documentation review, I have come to a conclusion that 'numpy' could be used as a stand-alone, in conjunction with 'pandas', or just 'pandas' as both packages are compatible and complimentary. There are multiple similar and/or overlapping commands between the two packages. I have thoroughly researched Pandas package and determined that it will be most suitable to complete the project using this package.

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

## Development

Python's library packages used for this project were Panda, Matplotlib and Seaborn. I will briefly clarify them and provide evidence of the knowledge and skills acquired below:

 ### Pandas

This is a relatively new Python package project name of which is derived from the term "panel data", an econometrics term for data sets that include observations over multiple time periods for the same individuals.
The first realease was February 2013 and since then the package has been updated and improved into its current status: "pandas: powerful Python data analysis toolkit". The latest version release was Dec 30, 2017 Version: 0.22.0
Furthermore, this package has received excellent reviews on its website: "https://pandas.pydata.org/pandas-docs/stable/" (definition below), which lead me to a decision to experiment with this relatively new tool for data analysis. Based on its features, I concluded that this package was most suitable for this project.

According to "https://pandas.pydata.org/pandas-docs/stable/ "pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Additionally, it has the broader goal of becoming the most powerful and flexible open source data analysis / manipulation tool available in any language. It is already well on its way toward this goal."

### Matplotlib

Another Python package used in this project for plotting is matplotlib.
According to the "https://matplotlib.org/ "Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shells, the Jupyter notebook, web application servers, and four graphical user interface toolkits.
Matplotlib tries to make easy things easy and hard things possible. You can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc., with just a few lines of code.
For simple plotting the pyplot module provides a MATLAB-like interface, particularly when combined with IPython. For the power user, you have full control of line styles, font properties, axes properties, etc, via an object oriented interface or via a set of functions familiar to MATLAB users."

### Seaborn

For this project 'Seaborn' was used to enhance graphic visualisation of graphs plotted by matplotlib. To make them  more user friendly, facilitating the immediate distinction between different classes (of 'Species') of irises, several different colours were applied. Seaborn also provides a legend to the the graphs to help the users in identification of different variables.

According to https://seaborn.pydata.org/ "Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics."

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

## Consistency

  ### Initial Plan

My initial plan involved everything  already presented in this project with an additional algorithms for claculating SVM and KNN (*by importing modules from sklearn package*),as described in: "https://www.kaggle.com/kamrankausar/iris-dataset-ml-and-deep-learning-from-scratch" and "https://machinelearningmastery.com/machine-learning-in-python-step-by-step/" , these are also mentioned in "Introduction to Machine Learning with Python"-by Andreas C. Mueller & Sarah Guido

  ### Final Project

The reason for non-inclusion of  SVM and KNN was because on project review, I concluded that those algorithms are mainly used for Machine Learning,which was outside the scope of this project. The scope of this project was around "Data Strutures". That is retrieval, storage, manipulation, assembly and visualisation of "Data Structure"(DataFrame). I thought Machine Learning would be best suited for a future assignment.
 As all  objectives set by me initially were reached by calculating the summary of desciptive statistics and the graphs plotted were sufficient to demonstrate to the  users the results of the analysed data.

I then decided to have one file for the calculation and histogram ( using Matplotlib ) without colour distinction ( default lightblue );
another file for the plots( with a matrix ) with colour distinction ( using Seaborn ); and the boxerplots on a separate file

Overall, the main objectives and learning outcomes were achived by me, and they include:
  - Basic understanding of technical knowledge, skills and tools available for data analysis
  - Understanding of requirements for retrieving and storing data files(i.e.CSV files) into a Python environment in order to best manipulate and assemble data required.  **(Please see note below)**
  - Understanding of basic panda's commands to save CSV files into dataframes(df), append column rows(header) without affecting the indexation of rows(df.column), list the five first rows of dataframe(with df.head), list the five last rows(df.tail), obtain information on the type of Panda objects(Series or Dataframe used(df.info()) and size of file
  - Understanding how to list a summary of descriptive statistical calculations(df.describe) of the dataframe saved, or its individual calculations(i.e df.mean(), or df.std(), df.max(), df.min(), df.median(), etc.
  - Understanding on how to select specific rows, create subsets from a dataframe(using iloc-index number or loc-index label).
  - Learn commands to load a Dataframe file for plotting using Matplotlib and Seaborn
  - Basic understanding of plotting with Panda objects.

  ** Note- The iris dataset provided me no issues regarding missing data,NaNs or index issues. Although, I prepared myself to tackle such events, were they to arise - The process of 'tidying data' of Dataframe  and making it ready for analysis is also a learning outcome attained by me

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

 ## Documentation

  > Iris Dataset retrieved from: " https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data " and saved as a csv file on Microsoft VS Code.

A Iris.py was opened that will read,retrive and manipulate data from csv(through import function and export of csv files)

I used anaconda python with VS Code, pandas,matplotlib and seaborn for this project

Created subsets of the all iris dataset:
 - df = DataFrame for the whole 'iris dataset'
 - df1 = DataFrame for 'Iris-setosa'(using the iloc[]method,appended the index range (0,50,1)-(start, end not incl., stepvalue)
 - df2 = DataFrame for 'Iris-versicolor'
 - df3 = DataFrame for 'Iris-virginica'

This block of code was implemented while discovering and experimenting code with Pandas. For each DataFrame, make the basic stats calculations(.describe()method) in 'iris.py'

### About the Iris Data Set

  Iris dataset is a multivariate data set and since it was introduced by Ronald Fisher in 1936 in his paper('The use of multiple measurements in taxonomic problems has been used by other biologists, staticians and students(for statistical studies and projects)
  Its data is comprised by 150 rows and 5 columns('Sepal Width', Sepal Lenght', Petal Width', 'Petal Lenght' and 'Species')
  The 4 first columns are measurements in cms,and the 5th column('Species') describes the type of iris flower

 The data set is composed as folows(and these are known as *classes*):
  - First 50 entries - Iris Setosa
  - From 51 -100 entries - Iris Versicolor
  - From 101 - 150 entries - Iris Virginica

Plenty of information available online and I provided a list of resources used by me whilst doing this project. I used the resources and references listed above to gather information, filter and use what I considered relevant. Also, to provide some benchmark for the results of the algorithms written by me in Python, with regards to outputs.

### Data Science

  One of the cornerstones of Data Science is the subject of Data Structures and this is the main context of this project.
  What was once done manually is possible to automate the most tedious and time consuming tasks. For example, plotting      histograms, scatterplots and boxplots for all 4 different measurements of the different classes of species and compiling it all back together would require months to perform,using traditional statistical studies technique.
  There are however,tricks,skills and techiniques to know. For a Data Scientist,the data retrieved from a source might be too raw(or unsupervised),so the number of information extrapolated by that data will be limited. To enhance results,data must be manipulated and (re) assembled in a more tidy(cleaned) manner. So that the machine can perform the correct calculations and yield the results required.
  A broad knowledge of statistics is required for any Data Analysis project. Although,this was not required for this dataset

  ### The Files and Algorithms

  All my files are in this repository in a folder named 'Project18'.
  The first file iris.csv(Comma Separated Values) was downloaded from UCI Machine Learning website. I then stored the values in another file in the format of a Dataframe. I named this file 'iris.py'.

  #### Iris.py

  This file opened and stored iris.csv as a dataframe(or short df), using pandas library. From there I used built-in commands(df.describe()) to calculate a summary of basic statistics calculations(min., max., std. dev., frequency, quartiles).

  As this was my first time using pandas for Python,I tried different commands(add columns for header, print the first 5 rows of dataframes, append by index row numbers values to different subsets of the dataframe, list information about the Dataframe.
  After all the calculations are performed and presented, a matrix of histograms is plotted and shown with the default lightblue for all 4 variables

  #### Plot.py

  This file uses Matplotlib and Seaborn to plot pairplot graphs in a matrix. Histograms and scatter plots for the different species of iris separated by different colours. We can see that Iris versicolor and virginica are very closely related, because they are distributed very closely(almost overlapping). Here the use of contrasting colours is most beneficial for anyone analysing data, from so closely related variables. As this provides a clearer distinction of the two.
  Each row in the matrix represents each of the 4 variables ('Sepal Width', 'Sepal Lenght', 'Petal Width', 'Petal Lenght')
  The histograms provide a visualisation of frequency and distribution of data

  #### Boxplot.py

  This file shows the boxplots. Each boxplot represents each numerical columns.
  Boxplots provide a clear visualisation of median(Q2),minimum(lower observation on whisker and maximum(highest observation) values,lower quartile(Q1),and upper quartile(Q3)  from iris.py of all 4 columns('Sepal Width', 'Sepal Lenght', 'Petal Width' and 'Petal Lenght')

  #### LinReg.py

  This file shows 2 Linear Regression graphs(one based on 'Sepal' variables and the other based on 'Petal' ), to help identify better co relationship between the 3 species. By viewing the both graphs, I could conclude that 'iris-virginica' and 'iris-versicolor' are closely related by their measured results. 'Iris setosa' seems to be completely unrelated,as its results appear distant and distinguished from the other 2 species.

  ---

  ### Code/Output/Analysis

  ```python

   import pandas as pd
	import seaborn as sns
	import matplotlib.pyplot as plt

	df = pd.read_csv('iris.csv', header = None) # StackOverflow: 'How to add header row to pandas DataFrame and PythonHow.com-'Loading CSV data in Python with pandas'

	df.columns = ['Sepal Length','Sepal Width','Petal Length','Petal Width','Species']

	print(df.info())

	 # Prints the first 5 rows; For the last 5 rows: print(df.tail())

```


text:
# Instant iPhone X Mockup

### HTML5 + CSS iPhone X Mock up
- Purely HTML5 + JS + CSS
- Drag an image to the iPhone X frame and get a mock up in a second.
- Try demo in [live](http://mockuphone.com/instant_iphonex/) on MockUPhone
- Powered by [MockUPhone](https://mockupohone), see more devices there.

![iPhone X Mock up by MockUPhone](https://user-images.githubusercontent.com/1916493/31982184-fd921d76-b989-11e7-8d36-fb9c2e3b3193.png)

### Credits

- Using [devices.css](https://github.com/picturepan2/devices.css) for CSS device frame (MIT LICENCE)

repository: tensiuyan/iphone-x-mockup

repo_name: tensiuyan/iphone-x-mockup


text:
---
path: /learn-ruby/command-line-switches
title: Command Line Switches
---
[Codecabulary Home](/) / [Learn Ruby](/learn-ruby) / Ruby Command Line Switches

<!-- ---title: Command Line Switches -->

When you write a Ruby program, you'll run it from your command line. The command line allows you to select a few special options, called command-line switches, which perform actions on your Ruby code.

The -c flag (Check Syntax)
========================
```
ruby -c example1.rb
```
The -c flag checks the syntax of the program file without executing the program. If everything's looking good, you'll see

```
Syntax OK for example1.rb
```

Remember (for all you that don't have a degree in English Literature), syntax is just the rules for constructing sentences (or lines of Ruby in this case), whereas semantics are the meaning behind the words. In English, you could say "The verb crumpled the milk--terribly." And your sentence would be syntactically correct. But it wouldn't make a whole lot of sense, would it? The -c flag is only checking for syntax, not semantics; so be sure to perform some other tests on your code like:

The -w flag (Warning Mode)
========================
```
ruby -w example1.rb
```

The -w flag runs the Ruby interpreter in warning mode, and will draw your attention to code that, while syntactically correct, is logically or stylistically suspicious. Warning mode is more verbose than running the Ruby interpreter normally; though the normal interpreter will complain about some things, the warning mode interpreter will be the "English Nazi" you always hated, but will love in this case. You love the just punishment of warning mode!

The -cw combination (Check Syntax + Warning Mode)
========================
```
ruby -cw example1.rb
```

This glorious combination of flags (both the -c and -w flags combined) will both check your syntax without running the program and also give you semantic warnings. Good stuff. Any flags can be combined in this way (-ve is another common combination we'll explore below), but these two are the most common combos. They also earn you bonus points in coding heaven, so there's that.

The -e flag (Execute Literal Ruby Script)
========================
```
ruby -e 'puts "Whatever ruby -e wants to put."'
```

The -e flag connotes that literal Ruby script follows and should be run. Most flags are executed on Ruby files (as shown above in the example1.rb files). In those examples, example1.rb contained Ruby code that was passed to the Ruby interpreter to run. With the -e flag, you're passing in the code directly to the interpreter for a result.

The -v flag & -e flag combination (Verbose + Literal)
========================
-e is most often used with the -v flag (which displays the version of Ruby a code will run through, and also runs in warning mode without the need to declare the -w flag), for educational purposes. In a forum, someone might illustrate that a feature changed between Ruby 1.8.6 and 1.9.1 by running both versions and sharing the output. For example:

```
ruby186 -ve "puts 'The end of the world'.start_with?('T')"
ruby 1.8.6(2007-03-13 patchlevel 0) [i686-darwin8.10.1]
-e:1: undefined method 'start_with' for "abc":String (NoMethodError)

ruby -ve "puts 'The end of the world'.start_with?('T')"
ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i386-darwin9.5.0]
true
```

As we see in the latter case, the Ruby method 'start_with' evaluates to true; in the former case, Ruby complained that start_with didn't exist, which it didn't in 1.8.6. Using the -ve combined flag allows us to share the output of different Ruby versions with others in productive ways.

The -l flag (Add a newline after string outputs)
========================
```
ruby -l example1.rb
```

The -l flag forces Ruby to add a newline (\n) after every string literal output. The effect of this change is to transform all print statements into puts statements (puts aka put string automatically adds a newline to its output; print does not).

The --version flag (Print Ruby version)
========================
```
ruby --version
```

This flag prints the current version of Ruby and then exits. Like the -v flag, but without any code to execute on, and (inherently) it won't run in warning mode (since it's not running on anything).

The -h or --help flag (Chduh, man)
========================
```
ruby --help
```

These switches give you a table listing all the command-line switches available, and summarizing what they do, much like this document, but a little less verbose. This doc hopes to add a little clarity to the terse, mechanical goodness of ruby --help.

repository: LaunchAcademy/codecabulary

gha_language: JavaScript

repo_name: LaunchAcademy/codecabulary


text:
# Open In 1Password

Submitted by: [@cycle4passion](https://twitter.com/cycle4passion)

Action extension to send the currently viewed URL to the 1Password Browser, useful for recording new login/password values.

license: Unlicense

repository: FurnasAZ/shortcutsdirectory

path: /shortcuts/Open in 1Password/README.md

repo_name: FurnasAZ/shortcutsdirectory


text:
---
layout: post
title: "Machine Learning: Sequence Models Week3 Notes"
date: 2018-11-24
categories: blog
tags: [Machine Learning]
description: "Notes for machine learning course: Sequence Models"
---

# **Various sequence to sequence architectures**
## **Basic Models**
**Sequence to sequence model**

x<1> x<2> x<3> x<4> x<5>
Jane visite l'Afrique en septembre

y<1> y<2> y<3> y<4> y<5>
---> Jane is visiting Africa in September.

![](https://cdn-images-1.medium.com/max/1000/1*CbrcRZVFynXnSJM0OBZL1w.png)

**Image captioning**

y<1> y<2> y<3> y<4> y<5> y<6>
A cat sitting on a chair

## **Picking the most likely sentence**
**Machine translation as building a conditional language model**

Language model:

Machine translation: decoding network looks just like language model.

(We called it) Conditional language model: Estimate the probability of an English translation conditions on the French input sentence.

**Finding the most likely translation**

Jane visite l'Afrique en septembre.

---> Jane is visiting Africa in September.

---> Jane is going to be visiting Africa in September.

---> In September, Jane will visit Africa.

---> Her African frient welcomed Jane in September.

argmax P(y<1>,...y<Ty> \| x)

Instead of sampling the outputs at random, we want to find the y that maximizes the term.

**Why not a greedy search?**

May result in a less optimized output.

## **Beam Search**
**Beam search algorithm**

B = 3 (beam width)

P(y<1> \| x)

P(y<1>, y<2> \| x) = P(y<1> \| x)P(y<2> \| x, y<1>)

P(y<1>, y<2>, y<3> \| x) = ...

**Beam search (B = 3)**

in september: a, aaron, ... zulu ---> jane

jane is: a ... zulu ---> visiting

jane visits: a ... zulu ---> africa

When B = 1, similar to greedy search

## **Refinements to Beam Search**
**Length Nnormalization**

Doing a log on the original function and divide it by 1/(Ty^a)

**Beam search discussion**

Beam width B? (normal: 10, large: 100, Huge: 1000/3000)

Larger B: better result, slower

Small B: worse result, faster

Unlike exact search algorithms like BFS (Breadth First Search) or DFS (Depth First Search), Beam Search runs faster but is not guaranteed to find exact maximum for arg max_y P(y\|x)

## **Error analysis in beam search**
**Example**
Jane visite l'Afrique en septembre.

Human: Jane visits Africa in September. (y*)

Algorithm: Jane visited Africa last September. (yhat)

Use the RNN model to computes P(y*\|x) and P(yhat\|x) to see which one is larger

- Case 1: P(y*\|x) > P(yhat\|x)

Beam search chose yhat. But y* attains higher P(y\|x).

Conclusion: Beam search is at fault.

- Case 2: P(y*\|x) <= P(yhat\|x)

y* is a better translation than yhat. But RNN predicted P(y*\|x) < P(yhat\|x).

Conclusion: RNN model is at fault.

**Error analysis process**

Human                      | Algorithm                     | P(y*x)   | P(yhatx) | At fault?
---------------------------|-------------------------------|----------|----------|----------
Jane visits Africa in Sep. | Jane visited Africa last Sep. | 2 * e-10 | 1 * e-10 | B
...                        |...                            |...       |...       | R
...                        |...                            |...       |...       |...

## **Bleu Score**
**Evaluation machine translation**
French: Le chat est sur le tapis.

Reference 1: The cat is on the mat.

Reference 2: There is a cat on the mat.

Bleu: Bilingual evaluation understudy (Bleu score measure how good is that machine translation)

MT output: the the the the the the the the.

Precision: 7/7 (check if the predition words appears in the reference)

Modified precision: 2/7 (check the appearence up to the maximum)

**Bleu score on bigrams**
Example:

Reference 1: The cat is on the mat.

Reference 2: There is a cat on the mat.

MT output: The cat the cat on the mat.

Bigrams | Count | Countclip
--------|-------|----------
the cat | 2     | 1
cat the | 1     | 0
cat on  | 1     | 1
on the  | 1     | 1
the mat | 1     | 1

Bleu score = countclip / count = 4 / 6

**Bleu score on unigrams**
Example:

Reference 1: The cat is on the mat.

Reference 2: There is a cat on the mat.

MT output: The cat the cat on the mat.

P1, Pn(n-gram)

**Bleu details**
Pn = Bleu score on n-grams only

Combined Bleu score: BP exp(1/4 sum(Pn))

where BP = brevity penalty

BP = 1 if MT_output_length > reference_output_length

BP = exp(1 - MT_output_length/reference_output_length) otherwise

## **Attention Model Intuition**
**The problem of long sequence**

Looking at part of the sentence at a time.

**Attention model intuition**

## **Attention Model**
**Attention model**

**Computing attention a<t,t'>**

a<t,t'> = amount of attention y<t> should pay to a<t'>

**Attention examples**
July 20th 1969 -> 1969 - 07 - 20

23 April, 1564 -> 1564 - 04 - 23

# **Speech recognition - Audio data**
## **Speech Recognition**
**Speech recognition problem**

audio clip: x -> transcript: y

**Attention model for speech recognition**

**CTC cost for speech recognition**

(Connectionist temporal classification)

Basic rule: collapse repeated characters not separated by "blank"

## **Trigger Word Detection**
**What is trigger word detection?**

**Trigger word detection algorithm**

# **Conclusion**
**Specialization outline**

1. Neural Networks and Deep Learning

2. Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization

3. Structuring Machine Learning Projects

4. Convolutional Neural Networks

5. Sequence Models


text:
# Constant Bit Rate Tester

Sends at a constant rate using the specified path.

The client chooses the packet size, the rate and the path.
The server prints out the receive rate and stall events (freezes or
interruptions in the received packet stream of more than 100ms) if any are
detected.

repository: tcinbis/scion-apps

repo_name: tcinbis/scion-apps


text:
# BakingApp

#### BakingApp is an Android app for learning desserts recipes step by step.

#### The app comes with a widget which gives you the option of showing the ingredients of a selected recipe on your home screen.

## Getting Started

#### These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

## Prerequisites

#### BakingApp was developed using Android Studio IDE so you must install it on your computer before proceeding:

###### https://developer.android.com/studio/

## Next Steps

#### You can directly proceed to clone the project to your local machine, enter Android Studio, import and build your project and start using BakingApp on your Android device.

## Compatibility

#### Minimum Android SDK: BakingApp requires a minimum API level of 21.
#### Compile Android SDK: BakingApp requires you to compile against API 32 or later.

## Getting Help

#### To report a specific problem or feature request, open a new issue on Github. For questions, suggestions, or anything else, email to:

######<EMAIL_ADDRESS>
## Author

#### Daniel Bedoya - @engspa12 on GitHub

## License

#### See the LICENSE file for details.


text:
---
title: RadMonthYearPicker Structure
page_title: RadMonthYearPicker Structure - RadMonthYearPicker
description: Check our Web Forms article about RadMonthYearPicker Structure.
slug: monthyearpicker/getting-started/radmonthyearpicker-structure
tags: radmonthyearpicker,structure
published: True
position: 4
---

# RadMonthYearPicker Structure

The **RadMonthYearPicker** control is composite control that combines the functionality of **RadCalendar** with the functionality of **RadDateInput** to give the broadest possible range of options for selecting month and year values. The control elements are described below:
![RadMonthYearPicker Structure](images/calendar_monthyearpicker_overview.png)

The three major components of a **RadMonthYearPicker** control are:

* **Input area** - This is an embedded **RadDateInput** control, which validates dates or times as the user types.

* **Popup control** - This is a **MonthYearPickerTableView** that is shown in a popup element, so that the user can select a month or year by clicking on the desired selection.

* **Date Popup Button** - an image button, displayed next to the input area that shows and hides the popup control.

# See Also

 * [RadCalendar Structure]({%slug calendar/getting-started/structure%})

 * [RadMonthYearPicker Structure]({%slug monthyearpicker/getting-started/radmonthyearpicker-structure%})

repository: telerik/ajax-docs

gha_language: C#

repo_name: telerik/ajax-docs


text:
# Poetry Slam Prep

### Description

A CLI random word generator/prompt to prepare for a poetry slam.

This was inspired by node-rhyme by @substack, but I found that it wasn't working well for me, even though I just needed a random word prompt.

### Getting Started

Prerequistes

    node 4.x.x and above // cause I was using fat arrows

    git clone github.com/denistsoi/dt-random-word
    cd dt-random-word
    npm start

### Author

Denis Tsoi @ 2016

### License

MIT

repository: denistsoi/dt-random-word

repo_name: denistsoi/dt-random-word


text:
---
heading: QuickBooks Enterprise
seo: Tips | QuickBooks Enterprise | Cloud Elements API Docs
title: Tips
description: QuickBooks Enterprise Tips
layout: sidebarelementdoc
breadcrumbs: /docs/elements.html
elementId: 195
parent: Back to Element Guides
order: 75
---

## Tips

The Tips section includes more information about the element including FAQs, endpoint limitations, and general tips.

## Ground2Cloud

* To successfully authenticate an instance with QuickBooks Enterprise, both the Ground2Cloud and QuickBooks connector services need to be running. You may need to actively restart your connector if your instance is not working.  For more information on Ground2Cloud, see the [Ground2Cloud documentation](https://developers.cloud-elements.comhttps://docs.cloud-elements.com/home/ground-2-cloud-connect-your-on-premise-apps/?resource=).
*

* When setting up polling, you may need to specify a time zone specific to the location of your server. The default time zone is UTC.

    {% include note.html content="QuickBooks Enterprise has a known limitation where It currently does not support daylight savings, which may impact your time zone settings.  " %}

    Example polling configuration:

	```json
	{
		"payments": {
			"url": "/hubs/finance/payments?where=TimeModified >= '${dateTimeZone:America/Denver:yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}'",
			"idField": "TxnID",
			"datesConfiguration": {
				"updatedDateField": "TimeModified",
				"updatedDateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
				"createdDateField": "TimeCreated",
				"createdDateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
			}
		}
	}
	```

* QuickBooks cannot search by `customerref.name` in invoices. For more information, reference the [QuickBooks documentation](https://developer.intuit.com/docs/0100_quickbooks_online/0300_references/0000_programming_guide/0050_data_queries).

* QuickBooks Bulk does not support doing selects with specific column names in your CEQL. The best practice to achieve this functionality is to use transformations.

repository: cloud-elements/devportal

repo_name: cloud-elements/devportal


text:
---
layout: post
title: "Participated as the scientist in 'Skype a Scientist'"
categories: science outreach
author: "Laura Rocha Prado"
---

[Skype a Scientist](https://www.skypeascientist.com/) is an initiative that "matches scientists with classrooms around the world". Their goal is to "give students the opportunity to get to know a “real scientist”."

I was matched with Teacher Jackie Gray and her first grade class students at Euclid Elementary School, in Mt. Prospect, IL, USA.

We had a great time talking about my work as a beetle-expert/biologist and also as a Brazilian immigrant living in the US. The children were really excited and asked many interesting questions about bugs and science. My favorite question was: "how do bugs poop?". I'd recommend that all my scientist friends/peers join this program. My initial motivation was to show kids that women are scientists, too, and I think that was also accomplished.

repository: arbolitoloco/done

repo_name: arbolitoloco/done


text:
# Typetalk.sh
Typetalk.sh is a simple shell script that allow you to post message to [Typetalk](https://www.typetalk.com/).

## How to install
`curl -L -o typetalk https://raw.githubusercontent.com/mohno007/typetalk.sh/master/typetalk && chmod +x typetalk`

Or

1. Clone this repo: `git clone https://github.com/mohno007/typetalk.sh.git`
1. (If you need) Create a bin directory: `mkdir -p $HOME/.local/bin/`
1. Create a symbolic link: `ln -s PATH_TO_typetalk.sh/typetalk $HOME/.local/bin/typetalk`
1. (If you need) Add a bin directory into PATH: `echo 'export PATH="$PATH:$HOME/.local/bin/"' >> ~/.bashrc`

Example:

```sh
git clone https://github.com/mohno007/typetalk.sh.git "$HOME/.typetalk.sh/"
mkdir -p "$HOME/.local/bin/"
ln -s "$HOME/.typetalk.sh/typetalk" "$HOME/.local/bin/typetalk"
echo 'export PATH="$PATH:$HOME/.local/bin/"' >> ~/.bashrc
exec bash
```

If you use another shell, not bash, setup .*shrc appropriately.

## Usage
Create `$HOME/.typetalk_config` and put an API token into it.

`$HOME/.typetalk_config`:

```sh
TYPETALK_TOPIC=1234
TYPETALK_TOKEN="xxxxxxxxxxxxxxx"
```

Example:

```sh
# specifying content by command line
typetalk -m "Hello, world!"

# specifying content from command output
date | typetalk

# specifying content from file
typetalk "some_file"

# specifying config via environment variables
TYPETALK_TOPIC=1234 TYPETALK_TOKEN="xxxxxxxxxxxxxxx" typetalk -m "via envvar"

# show help
typetalk -h
```

## How to update
`git pull`

## License
Typetalk.sh by mohno007

To the extent possible under law, the person who associated CC0 with
Typetalk.sh has waived all copyright and related or neighboring rights
to Typetalk.sh.

You should have received a copy of the CC0 legalcode along with this
work.  If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.


text:
# Command Line

```bash

$ cd /vagrant/

$ ./hack/setup-vms.sh

```

# Kubeadm Ansible Playbook

Build a Kubernetes cluster using Ansible with kubeadm. The goal is easily install a Kubernetes cluster on machines running:

  - Ubuntu 16.04
  - CentOS 7
  - Debian 9

System requirements:

  - Deployment environment must have Ansible `2.4.0+`
  - Master and nodes must have passwordless SSH access

# Usage

Add the system information gathered above into a file called `hosts.ini`. For example:
```
[master]
<IP_ADDRESS>

[node]
192.16.35.[10:11]

[kube-cluster:children]
master
node
```

If you're working with ubuntu, add the following properties to each host `ansible_python_interpreter='python3'`:
```
[master]
<IP_ADDRESS> ansible_python_interpreter='python3'

[node]
192.16.35.[10:11] ansible_python_interpreter='python3'

[kube-cluster:children]
master
node

```

Before continuing, edit `group_vars/all.yml` to your specified configuration.

For example, I choose to run `flannel` instead of calico, and thus:

```yaml
# Network implementation('flannel', 'calico')
network: flannel
```

**Note:** Depending on your setup, you may need to modify `cni_opts` to an available network interface. By default, `kubeadm-ansible` uses `eth1`. Your default interface may be `eth0`.

After going through the setup, run the `site.yaml` playbook:

```sh
$  ansible-playbook site.yaml -i hosts.ini
...
==> master1: TASK [addon : Create Kubernetes dashboard deployment] **************************
==> master1: changed: [<IP_ADDRESS> -> <IP_ADDRESS>]
==> master1:
==> master1: PLAY RECAP *********************************************************************
==> master1: <IP_ADDRESS>               : ok=18   changed=14   unreachable=0    failed=0
==> master1: <IP_ADDRESS>               : ok=18   changed=14   unreachable=0    failed=0
==> master1: <IP_ADDRESS>               : ok=34   changed=29   unreachable=0    failed=0
```

Download the `admin.conf` from the master node:

```sh
$ scp k8s@k8s-master:/etc/kubernetes/admin.conf .
```

Verify cluster is fully running using kubectl:

```sh

$ export KUBECONFIG=~/admin.conf
$ kubectl get node
NAME      STATUS    AGE       VERSION
master1   Ready     22m       v1.6.3
node1     Ready     20m       v1.6.3
node2     Ready     20m       v1.6.3

$ kubectl get po -n kube-system
NAME                                    READY     STATUS    RESTARTS   AGE
etcd-master1                            1/1       Running   0          23m
...
```

# Resetting the environment

Finally, reset all kubeadm installed state using `reset-site.yaml` playbook:

```sh
$ ansible-playbook reset-site.yaml
```
**IMPORTANT:** HTTPS endpoints are only available if you used [Recommended Setup](https://github.com/kubernetes/dashboard/wiki/Installation#recommended-setup), followed [Getting Started](https://github.com/kubernetes/dashboard/blob/master/README.md#getting-started) guide to deploy Dashboard or manually provided `--tls-key-file` and `--tls-cert-file` flags. In case you did not and you access Dashboard over HTTP, then Dashboard can be accessed the same way as [older versions](https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.6.X-and-below).

**NOTE**: Dashboard should not be exposed publicly over HTTP. For domains accessed over HTTP it will not be possible to sign in. Nothing will happen after clicking Sign in button on login page.

## `kubectl proxy`

`kubectl proxy` creates proxy server between your machine and Kubernetes API server. By default it is only accessible locally (from the machine that started it).

First let's check if `kubectl` is properly configured and has access to the cluster. In case of error follow [this guide](https://kubernetes.io/docs/tasks/tools/install-kubectl/) to install and set up `kubectl`.
```sh
$ kubectl cluster-info
# Example output
Kubernetes master is running at https://<IP_ADDRESS>:6443
Heapster is running at https://<IP_ADDRESS>:6443/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://<IP_ADDRESS>:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```

Start local proxy server.
```sh
$ kubectl proxy
Starting to serve on <IP_ADDRESS>:8001
```

Once proxy server is started you should be able to access Dashboard from your browser.

To access HTTPS endpoint of dashboard go to: `http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/`

**NOTE:** Dashboard should not be exposed publicly using `kubectl proxy` command as it only allows HTTP connection. For domains other than `localhost` and `<IP_ADDRESS>` it will not be possible to sign in. Nothing will happen after clicking `Sign in` button on login page.

### Configure kubectl

Run the following command as `user` and `root` to configure `kubectl` command line CLI tool to communicate with the Kubernetes environment.

```
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
```

Check Kubernetes version

```
$ kubectl version --short

Client Version: v1.15.6
Server Version: v1.15.6
```

Untaint the node - this is required since we have only one VM to install objects.

```
$ kubectl taint nodes --all node-role.kubernetes.io/master-
```

Check node status and note that it is not yet ready since we have not yet installed a pod network

```
$ kubectl get nodes
NAME    STATUS     ROLES    AGE   VERSION
osc01   NotReady   master   95s   v1.15.6
```

Check pod status in `kube-system` and you will notice that `coredns` pods are in pending state. This is due to the fact that we have not yet installed the pod network.

Make sure that `etcd`, `kube-apiserver`  , `kube-controller-manager`, `kube-proxy` and `kube-scheduler` pods are showing READY state `1/1` and Status `Runnning`.

```
$ kubectl get pods -A
NAME                            READY   STATUS    RESTARTS   AGE
coredns-bb49df795-lcjvx         0/1     Pending   0          119s
coredns-bb49df795-wqmzb         0/1     Pending   0          119s
etcd-osc01                      1/1     Running   0          80s
kube-apiserver-osc01            1/1     Running   0          60s
kube-controller-manager-osc01   1/1     Running   0          58s
kube-proxy-vprqc                1/1     Running   0          119s
kube-scheduler-osc01            1/1     Running   0          81s
```

## Install Calico network for pods

Choose proper version of Calico [Link](https://docs.projectcalico.org/archive/v3.12/getting-started/kubernetes/requirements)

To get   kubernetes pod network CIDR

```
$ kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}'
<IP_ADDRESS>/24
```

Calico 3.12 is tested with Kubernetes versions 1.14, 1.15 and 1.16
```
$ export POD_CIDR=<IP_ADDRESS>/16
$ curl https://docs.projectcalico.org/v3.12/manifests/calico.yaml -O
$ sed -i -e "s?<IP_ADDRESS>/16?$POD_CIDR?g" calico.yaml
$ kubectl apply -f calico.yaml
```
or
```
$ export POD_CIDR=$(kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}')
$ curl https://docs.projectcalico.org/v3.12/manifests/calico.yaml -O
$ sed -i -e "s?<IP_ADDRESS>/16?$POD_CIDR?g" calico.yaml
$ kubectl apply -f calico.yaml
```
It may take a while to pull Calico images over the slow network.

Check docker images being pulled.
```
$ sudo docker images calico/*
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
calico/node                 v3.10.1             4a88ba569c29        11 days ago         192MB
calico/cni                  v3.10.1             4f761b4ba7f5        11 days ago         163MB
calico/kube-controllers     v3.10.1             8f87d09ab811        11 days ago         50.6MB
calico/pod2daemon-flexvol   v3.10.1             5b249c03bee8        11 days ago         9.78MB
```

Check the status of the cluster and wait for all pods to be in `Running` and `Ready 1/1` state.

```
$ kubectl get pods -A
NAME                                       READY   STATUS    RESTARTS   AGE
calico-kube-controllers-866db6d5f7-w9mfq   1/1     Running   0          33s
calico-node-mwgzx                          1/1     Running   0          33s
coredns-bb49df795-lcjvx                    1/1     Running   0          4m
coredns-bb49df795-wqmzb                    1/1     Running   0          4m
etcd-osc01                                 1/1     Running   0          3m21s
kube-apiserver-osc01                       1/1     Running   0          3m1s
kube-controller-manager-osc01              1/1     Running   0          2m59s
kube-proxy-vprqc                           1/1     Running   0          4m
kube-scheduler-osc01                       1/1     Running   0          3m22s
```

Our single node basic Kubernetes cluster is now up and running.

```
$ kubectl get nodes -o wide
NAME    STATUS   ROLES    AGE     VERSION    INTERNAL-IP       ---
osc01   Ready    master   5m28s   v1.15.0    <IP_ADDRESS>   ---

--- EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION               CONTAINER-RUNTIME
--- <none>        CentOS Linux 7 (Core)   3.10.0-957.21.3.el7.x86_64   docker://18.9.8
```

## Create an admin account

```
$ kubectl --namespace kube-system create serviceaccount admin
```

Grant Cluster Role Binding to the `admin` account

```
$ kubectl create clusterrolebinding admin --serviceaccount=kube-system:admin --clusterrole=cluster-admin
```

## Install kubectl on client machines

We will use the existing VM - which already has `kubectl` and the GUI to run a browser.

However, you can use `kubectl` from a client machine to manage the Kubernetes environment. Follow the [link](https://kubernetes.io/docs/tasks/tools/install-kubectl/) for installing `kubectl` on your chice of client machine (Windows, MacBook or Linux).

## Install busybox to check

```
$ kubectl create -f https://k8s.io/examples/admin/dns/busybox.yaml
```

## Install hostname deployment for sanity checks

Create a deployment
```
kubectl run hostnames --image=k8s.gcr.io/serve_hostname \
                        --labels=app=hostnames \
                        --port=9376 \
                        --replicas=3
```

Create a service

```
$ kubectl expose deployment hostnames --port=80 --target-port=9376
```

## Sanity check for the cluster

[Check this link for testing the cluster](https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/)

Check pod
```
$ kubectl get pods
NAME      READY   STATUS    RESTARTS   AGE
busybox   1/1     Running   0          13s
```

## Install helm and tiller

Starting with Helm 3, the tiller will not be required. We will be using Helm 2.x related charts, so we will not be installing Helm 3.x until charts are migrated to Helm 3.x.

Since Helm charts that we are going to use still However, we will be installing Helm v2.16.7

In principle tiller can be installed using `helm init`.

```
$ curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.16.7-linux-amd64.tar.gz | tar xz

$ cd linux-amd64
$ sudo mv helm /bin
```

Create `tiller` service accoun and grant cluster admin to the `tiller` service account.

```
$ kubectl -n kube-system create serviceaccount tiller

$ kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
```

Helm can be installed with and without security. If no security is required (like demo/test environment), follow Option - 1 or follow option - 2 to install helm with security.

### Option - 1 : No security, ideal for running in a sandbox environment.

Initialize the `helm` and it will install `tiller` server in Kubernetes.

```
$ helm init --service-account tiller
```

Wait for tiller to get deployed. (check `kubectl get pods -A`)

Check helm version

```
$ helm version --short

Client: v2.16.1+gbbdfe5e
Server: v2.16.1+gbbdfe5e
```

If you installed helm without secruity, skip to the [next](#Install-Kubernetes-dashboard) section.

### Option - 2 : With TLS security, ideal for running in production.

Install step

```
$ curl -LOs  https://github.com/smallstep/cli/releases/download/v0.14.4/step_linux_0.14.4_amd64.tar.gz

$ tar xvfz step_linux_0.14.4_amd64.tar.gz

$ sudo mv  step_0.14.4/bin/step /bin

$ mkdir -p ~/helm
$ cd ~/helm
$ step certificate create --profile root-ca "My iHelm Root CA" root-ca.crt root-ca.key
$ step certificate create intermediate.io inter.crt inter.key --profile intermediate-ca --ca ./root-ca.crt --ca-key ./root-ca.key
$ step certificate create helm.io helm.crt helm.key --profile leaf --ca inter.crt --ca-key inter.key --no-password --insecure --not-after 17520h
$ step certificate bundle root-ca.crt inter.crt ca-chain.crt

$ helm init \
--override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' \
--tiller-tls --tiller-tls-verify \
--tiller-tls-cert=./helm.crt \
--tiller-tls-key=./helm.key \
--tls-ca-cert=./ca-chain.crt \
--service-account=tiller

$ cd ~/.helm
$ cp ~/helm/helm.crt cert.pem
$ cp ~/helm/helm.key key.pem
$ rm -fr ~/helm ## Copy dir somewhere and protect it.
```

## Update helm repository

Update Helm repo

```
$ helm repo update
```

If secure helm is used, use --tls at the end of helm commands to use TLS between helm and server.

List Helm repo

```
$ helm repo list
NAME  	URL
stable	https://kubernetes-charts.storage.googleapis.com
local 	http://<IP_ADDRESS>:8879/charts
```

## Install Kubernetes dashboard

Install kubernetes dashboard helm chart

```
$ helm install stable/kubernetes-dashboard --name k8web --namespace kube-system --set fullnameOverride="dashboard"

Note: add --tls above if using secure helm
```
### Dashboard v2
1.reference:
https://hub.helm.sh/charts/k8s-dashboard/kubernetes-dashboard
```bash
# Add kubernetes-dashboard repository
$ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/

# Deploy a Helm Release named "my-release" using the kubernetes-dashboard chart
$  helm install kubernetes-dashboard/kubernetes-dashboard --name k8web --namespace kube-system --set fullnameOverride="dashboard"

Note: add --tls above if using secure helm
```

You can make sure .
```
$ kubectl get pods -n kube-system
NAME                                          READY   STATUS    RESTARTS   AGE
calico-kube-controllers-866db6d5f7-w9mfq      1/1     Running   0          170m
calico-node-mwgzx                             1/1     Running   0          170m
coredns-bb49df795-lcjvx                       1/1     Running   0          173m
coredns-bb49df795-wqmzb                       1/1     Running   0          173m
etcd-osc01                                    1/1     Running   0          173m
k8web-kubernetes-dashboard-574d4b5798-hszh5   1/1     Running   0          44s
kube-apiserver-osc01                          1/1     Running   0          172m
kube-controller-manager-osc01                 1/1     Running   0          172m
kube-proxy-vprqc                              1/1     Running   0          173m
kube-scheduler-osc01                          1/1     Running   0          173m
tiller-deploy-66478cb847-79hmq                1/1     Running   0          2m24s
```

Check helm charts that we deployed

```
$ helm list
NAME    REVISION        UPDATED                         ---
k8web   1               Mon Sep 30 22:21:01 2019        ---

--- STATUS          CHART                           APP VERSION     NAMESPACE
--- DEPLOYED        kubernetes-dashboard-1.10.0     1.10.1          kube-system
```

Check service names for the dashboard

```
$ kubectl get svc -n kube-system
NAME          TYPE        CLUSTER-IP     EXTERNAL-IP   ---
dashboard     ClusterIP   <IP_ADDRESS>   <none>        ---
kube-dns      ClusterIP   <IP_ADDRESS>     <none>        ---
tiller-deploy ClusterIP   <IP_ADDRESS>   <none>        ---

--- PORT(S)         AGE
--- 443/TCP         2m56s
--- 53/UDP,53/TCP   176m
--- 44134/TCP       31m
```

We will patch the dashboard service from CluserIP to NodePort so that we could run the dashboard using the node IP address.

```ssh
kubectl -n kube-system patch svc dashboard --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'
```
Traditionally you can edit it .

```ssh
$ kubectl -n kube-system edit  svc  dashboard
```
You should see `yaml` representation of the service. Change `type: ClusterIP` to `type: NodePort` and save file. If it's already changed go to next step.	Check Kubernetes version
```yaml
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
...
  name: kubernetes-dashboard
  namespace: kube-system
  resourceVersion: "343478"
  selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard-head
  uid: 8e48f478-993d-11e7-87e0-901b0e532516
spec:
  clusterIP: <IP_ADDRESS>
  externalTrafficPolicy: Cluster
  ports:
  - port: 443
    protocol: TCP
    targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
```

Next we need to check port on which Dashboard was exposed.
```sh
$ kubectl -n kube-system get service dashboard
NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
dashboard   <IP_ADDRESS>   <nodes>       443:31707/TCP   21h
```

### Run Kubernetes dashboard

Check the internal DNS server

```
$ kubectl exec -it busybox -- cat /etc/resolv.conf

nameserver <IP_ADDRESS>
search default.svc.cluster.local svc.cluster.local cluster.local servicemesh.local
options ndots:5
```

Internal service name resolution.

```
$ kubectl exec -it busybox -- nslookup kube-dns.kube-system.svc.cluster.local
Server:    <IP_ADDRESS>
Address 1: <IP_ADDRESS> kube-dns.kube-system.svc.cluster.local

Name:      kube-dns.kube-system.svc.cluster.local
Address 1: <IP_ADDRESS> kube-dns.kube-system.svc.cluster.local

$ kubectl exec -it busybox -- nslookup hostnames.default.svc.cluster.local
Server:    <IP_ADDRESS>
Address 1: <IP_ADDRESS> kube-dns.kube-system.svc.cluster.local

Name:      hostnames.default.svc.cluster.local
Address 1: <IP_ADDRESS> hostnames.default.svc.cluster.local
```

Edit VM's `/etc/resolv.conf` to add Kubernetes DNS server

```
sudo vi /etc/resolv.conf
```

Add the following two lines for name resolution of Kubernetes services and save file.

```
search cluster.local
nameserver <IP_ADDRESS>
```

### Get authentication token

If you need to access Kubernetes environment remotely, create a `~/.kube` directory on your client machine and then scp the `~/.kube/config` file from the Kubernetes master to your `~/.kube` directory.

Run this on the Kubernetes master node

```
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin | awk '{print $1}')
```

Output:

```
$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin | awk '{print $1}')
Name:         admin-token-2f4z8
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: admin
              kubernetes.io/service-account.uid: 81b744c4-ab0b-11e9-9823-00505632f6a0

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi10b2tlbi0yZjR6OCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJhZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjgxYjc0NGM0LWFiMGItMTFlOS05ODIzLTAwNTA1NjMyZjZhMCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTphZG1pbiJ9.iaWllI4XHQ9UQQHwXQRaafW7pSD6EpNJ_rEaFqkd5qwedxgJodD9MJ90ujlZx4UtvUt2rTURHsJR-qdbFoUEVbE3CcrfwGkngYFrnU6xjwO3KydndyhLb6v6DKdUH3uQdMnu4V1RVYBCq2Q1bOsejsgNUIxJw1R8N7eUpIte64qUfGYtrFT_NBTnA9nEZPfPAiSlBBXbC0ZSBKXzqOD4veCXsqlc0yy5oXHOoMjROm-Uhv4Oh0gTwdpb-at8Y0p9mPjIy9IQuzSo3Pg5hDKMex4Pwm8WLus4wAaS4mZKu2PI3O2-hhep3GlyvuVH8pOiXQ4p1TI5c0qdDs2rQRs4ow
```

Highlight the authentication token from your screen, right click to copy to the clipboard.

Find out the node port for the `dashboard` service.

```
$ kubectl get svc -n kube-system

NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
dashboard       NodePort    <IP_ADDRESS>   <none>        443:31869/TCP   2m7s
kube-dns        ClusterIP   <IP_ADDRESS>      <none>        53/UDP,53/TCP   7m34s
tiller-deploy   ClusterIP   <IP_ADDRESS>    <none>        44134/TCP       3m13s
```

Doubleclick Google Chrome from the desktop of the VM and run https://localhost:31869 and change the port number as per your output.

Click `Token` and paste the token from the clipboard (Right click and paste).

You have Kubernetes 1.15.6 single node environment ready for you now.

The following are optional and are not recommended. Skip to [this](#power-down-vm).

## Check if kube-proxy is OK

There must be two entries for the hostnames

```
sudo iptables-save | grep hostnames

-A KUBE-SERVICES ! -s <IP_ADDRESS>/16 -d <IP_ADDRESS>/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SERVICES -d <IP_ADDRESS>/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
[vikram@istio04 ~]$ sudo iptables-save | grep hostnames
-A KUBE-SERVICES ! -s <IP_ADDRESS>/16 -d <IP_ADDRESS>/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SERVICES -d <IP_ADDRESS>/32 -p tcp -m comment --comment "default/hostnames: cluster IP" -m tcp --dport 80 -j KUBE-SVC-NWV5X2332I4OT4T3
```

## Install Metrics server (Optional)

Metrics server is required if we need to run `kubectl top` commands to show the metrics.

```
helm install stable/metrics-server --name metrics --namespace kube-system --set fullnameOverride="metrics" --set args="{--logtostderr,--kubelet-insecure-tls,--kubelet-preferred-address-types=InternalIP\,ExternalIP\,Hostname}"
```

Make sure that the `v1beta1.metrics.k8s.io` service is available

```
$ kubectl get apiservice v1beta1.metrics.k8s.io
NAME                     SERVICE               AVAILABLE   AGE
v1beta1.metrics.k8s.io   kube-system/metrics   True        13m
```

If the service shows `FailedDiscoveryCheck` or `MissingEndpoints`, it might be the firewall issue. Make sure that `https` is enabled through the firewall.

If the AVAILLABLE shows `False (MissingEndpoints)`, wait for the end points to become available. Try above command again and make sure that the AVAILABLE shows `True` for the api service `v1beta1.metrics.k8s.io`.

Run the following.
```
kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
```
Wait for a few minutes, `kubectl top nodes` and `kubectl top pods -A` should show output.

## Install VMware Octant (Optional)

VMware provides [Octant](https://github.com/vmware/octant) an alternative to Kubernetes dashboard.

You can install `Octant` on your Windows, MacBook, Linux and it is a simple to use an alternative to using Kubernetes dashboard. Refer to [https://github.com/vmware/octant](https://github.com/vmware/octant) for details to install Octant.

## Install Prometheus and Grafana (Optional)

This is optional if we do not have enough resources in the VM to deploy additional charts.

```
helm install stable/prometheus-operator --namespace monitoring --name mon

Note: add --tls above if using secure helm
```

Check monitoring pods

```
$ kubectl -n monitoring get pods
NAME                                     READY   STATUS    RESTARTS   AGE
alertmanager-mon-alertmanager-0          2/2     Running   0          28s
mon-grafana-75954bf666-jgnkd             2/2     Running   0          33s
mon-kube-state-metrics-ff5d6c45b-s68np   1/1     Running   0          33s
mon-operator-6b95cf776f-tqdp8            1/1     Running   0          33s
mon-prometheus-node-exporter-9mdhr       1/1     Running   0          33s
prometheus-mon-prometheus-0              3/3     Running   1          18s
```

Check Services

```ssh
$ kubectl -n monitoring get svc
NAME                                   TYPE        CLUSTER-IP       EXTERNAL-IP   --- PORT(S)             AGE
alertmanager-operated                  ClusterIP   None             <none>        --- 9093/TCP,6783/TCP   19s
mon-grafana                            ClusterIP   <IP_ADDRESS>     <none>        --- 80/TCP              23s
mon-kube-state-metrics                 ClusterIP   <IP_ADDRESS>   <none>        --- 8080/TCP            23s
mon-prometheus-node-exporter           ClusterIP   <IP_ADDRESS>   <none>        --- 9100/TCP            23s
mon-prometheus-operator-alertmanager   ClusterIP   <IP_ADDRESS>   <none>        --- 9093/TCP            23s
mon-prometheus-operator-operator       ClusterIP   <IP_ADDRESS>    <none>        --- 8080/TCP            23s
mon-prometheus-operator-prometheus     ClusterIP   <IP_ADDRESS>   <none>        --- 9090/TCP            23s
prometheus-operated                    ClusterIP   None             <none>        --- 9090/TCP            9s
```

The grafana UI can be opened using: `http://<IP_ADDRESS>` for service `mon-grafana`. The IP address will be different in your case.

A node port can also be configured for the `mon-grafana` to use the local IP address of the VM instead of using cluster IP address.

```
# kubectl get svc -n monitoring mon-grafana
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
mon-grafana   ClusterIP   <IP_ADDRESS>   <none>        80/TCP    95s
```

Edit the service by running `kubectl edit svc -n monitoring mon-grafana` and change `type` from `ClusterIP` to `NodePort`.

Find out the `NodePort` for the `mon-grafana` service.

```
# kubectl get svc -n monitoring mon-grafana
NAME          TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
mon-grafana   NodePort   <IP_ADDRESS>   <none>        80:32620/TCP   3m15s
```

The grafana UI can be opened through http://localhost:32620 and this node port will be different in your case.

The default user id is `admin` and the password is `prom-operator`. This can be seen through `kubectl -n monitoring get secret mon-grafana -o yaml` and then run `base64 -d` againgst the encoded value for `admin-user` and `admin-password` secret.

You can also open Prometheus UI either by NodePort method as descibed above or by using `kubectl port-forward`

Open a command line window to proxy the Prometheus pod's port to the localhost

First terminal
```
kubectl port-forward -n monitoring prometheus-mon-prometheus-operator-prometheus-0 9090
```

Open `http://localhost:9090` to open the Prometheus UI and `http://localhost:9090/alerts` for alerts.

### Delete prometheus

If you need to free-up resources from the VM, delete prometheus using the following clean-up procedure.

```
helm delete mon --purge
helm delete ns monitoring
kubectl -n kube-system delete crd \
           alertmanagers.monitoring.coreos.com \
           podmonitors.monitoring.coreos.com \
           prometheuses.monitoring.coreos.com \
           prometheusrules.monitoring.coreos.com \
           servicemonitors.monitoring.coreos.com

Note: add --tls above if using secure helm
```

## Uninstall Kubernetes and Docker

In case Kuberenetes needs to be uninstalled.

Find out node name using `kubectl get nodes`

```
kubectl drain <node name> --delete-local-data --force --ignore-daemonsets
kubectl delete node <node name>
```

Remove kubeadm

```
sudo systemctl stop kubelet
sudo kubeadm reset
sudo iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
sudo yum -y remove kubeadm kubectl kubelet kubernetes-cni kube*

rm -fr ~/.kube
```

Remove docker and images
```
sudo su -
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
docker rmi $(docker images -q)
systemctl stop docker
rm -fr /var/lib/docker/*
yum -y remove docker-ce docker-ce-cli
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /var/lib/kubelet"
for dir in $cleanupdirs; do
  echo "Removing $dir"
  rm -rf $dir
done
```

## Power down VM

Click `Player` > `Power` > `Shutdown Guest`.

 It is highly recommended that you take a backup of the directory after installing Kubernetes environment. You can restore the VM from the backup to start again, should you need it.

The files in the directory may show as:

The output shown using `git bash` running in Windows.

```
$ ls -lh
total 7.3G
-rw-r--r-- 1 vikram 197609 2.1G Jul 21 09:44 dockerbackend.vmdk
-rw-r--r-- 1 vikram 197609 8.5K Jul 21 09:44 kube01.nvram
-rw-r--r-- 1 vikram 197609    0 Jul 20 16:34 kube01.vmsd
-rw-r--r-- 1 vikram 197609 3.5K Jul 21 09:44 kube01.vmx
-rw-r--r-- 1 vikram 197609  261 Jul 21 08:58 kube01.vmxf
-rw-r--r-- 1 vikram 197609 5.2G Jul 21 09:44 osdisk.vmdk
-rw-r--r-- 1 vikram 197609 277K Jul 21 09:44 vmware.log
```

Copy above directory to your backup drive for use it later.

## Power up VM

Locate `kube01.vmx` and right click to open it either using `VMware Player` or `VMware WorkStation`.

Open `Terminal` and run `kubectl get pods -A` and wait for all pods to be ready and in `Running` status.

## Conclusion

This is a pretty basic Kubernetes cluster just by using a single VM - which is good for learning purposes. In reality, we should use a Kubernetes distribution built by a provider such as RedHat OpenShift or IBM Cloud Private or use public cloud provider such as AWS, GKE, Azure or many others.

## Ascinema Cast

Click the link below to open the [Asciinema](https://ascinema.org) player to playback the commands that were captured while building the Kubernetes environment.

[![asciicast](https://asciinema.org/a/271731.svg)](https://asciinema.org/a/271731)

## Loadbalancer
GCP,AWS, IBM cloud 一般會提供外部的負載平衡，但此範例處理用keepalived
### Prepare nodes
1.確認核心模組是否載。

```
$ sudo lsmod | grep ^ip_vs
```
2.如果步驟1無任何輸出顯示 。

```
$ sudo ipvsadm -ln
```
3.再執行步驟1確認核心模組是否載。

```
$ sudo lsmod | grep ^ip_vs
```
4.增加ip_vs到系統核心模組清單，讓每次重新開機都會自動載入。

```
$ echo "ip_vs" | sudo tee /etc/modules-load.d/ipvs.conf
```
### keepalived installation

####  helm v2

1. helm v2 to install under k8s1.15-

```bash
$  kubectl label node k8s-m1,k8s-n1,k8s-n2  proxy=true
$  helm repo add kaal https://servicemeshbook.github.io/keepalived
$  helm repo update
$  kubectl create clusterrolebinding    keepalived-cluster-role-binding \
   --clusterrole=cluster-admin --serviceaccount=keepalived:default

$ kubectl create namespace keepalived

$  helm  install kaal/keepalived  --name keepalived\
   --namespace keepalived \
   --set keepalivedCloudProvider.serviceIPRange="<IP_ADDRESS>/29" \
   --set nameOverride="lb"

```
2.  helm v2 to install under k8s1.16+

```bash
$  kubectl label node  k8s-m1,k8s-n1,k8s-n2  proxy=true
$  git clone https://github.com/robert0714/keepalived.git
$  cd keepalived && git  checkout k8s-1.16  && cd ..
$  helm install keepalived --name keepalived \
   --namespace keepalived \
   --set keepalivedCloudProvider.serviceIPRange="<IP_ADDRESS>/29" \
   --set nameOverride="lb"
```


text:
# Collection Filter

Helps to make a simple filter in Filtered Collection pattern for Rails

http://rest-pattern.hatenablog.com/entry/filtered-collection

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

    gem 'collection_filter', github: 'tkawa/collection_filter'

And then execute:

    $ bundle

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
![alt text](https://github.com/clothing-color-coordinator/API/blob/master/assets/colorBar1.PNG "Colors")

# bus mall
> **the** application for all of your bus mall needs

## table of contents
* [purpose](#purpose)
* [summary](#summary)
* [endpoints](#endpoints)
* [methods](#methods)
* [schema](#schema)
* [notes](#notes)
* [versions](#versions)
* [authors](#authors)
* [license](#license)

## purpose:
>  The app's purpose is to have group members choose which product, of the three displayed images, that they would be most likely to purchase, and then store, calculate, and visually display the resulting data

## summary
> To make this market analysis maximally effective, BusMall wants you to build an app that displays potential products to individuals in focus groups (three products at a time, side-by-side-by-side) so you'll need to manage the size and the aspect ratio of the images and perhaps edit them a bit; Mac users can do this in Preview (very cool!), plus, there are lots of online tools.

> The app's purpose is to have the group members choose which product, of the three displayed images, that they would be most likely to purchase, and then store, calculate, and visually display the resulting data.

> To keep the product selection process as untainted as possible, you have been instructed to not allow any results to be shown to users until there have been a total of 25 selections made.

> The marketing team is not only interested in the total number of clicks, but also the percentage of times that an item was clicked when it was shown. So, you'll also need to keep track of how many times each image is displayed and do the calculations.

> You are also responsible for the look and feel of the app, so don't forget a custom font, color palette, layout with semantic HTML, and so on.

## notes
> Images were resized by Edward Abrahamson

## versions:
> Version 1.0  April 8, 2019

## authors
> **Charles Clemens** - *Initial work* - [CClemensJr](https://github.com/CClemensJr)

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

gha_language: CSS


text:
# intro to python

## basic data types

```
# to determine the type of the variable, use type(..)

type(1)
type('hello')
type(1.4)
type(True)
type(a_variable)
```
```
# converting 1 data type to the other

x = 1
type(x)
# will print int

y = float(x)
type(y)
# will print float

z = bool(123)
print(z)
# will print True

type(z)
# will print boolean

n = bool(0)
print(n)
# will print False

m = bool(-2)
print(m)
# will print True

res = str(12)
print(res)
# will print '12'

type(res)
# will print str
```

## comparison and logic operators
### comparison operators

```
# == checks for equality
res = 5 == 5

# < less than
res = 3 < 5

# > greater than
res = 10 > 2

# >= greater than or equal
res = 5 >=2

# <= less than or equal
res = 2 <= 2

# != not equal
res = 5 != 6
```

### logical operators
```
# and
res = True and True

# or
res = True or False

# not
res = not True
```

## conditional if statements

```
# syntax

if <condition>:
    <action>

if <condition>:
    <action>
else:
    <action>

if <condition>:
    <action>
elif <condition>:
    <action>
else:
    <action>
```

## loops

### while loops

```
# syntax

while <condition>:
    <action>

```
```
# example

counter = 1
while counter < 10:
    print(counter)
    counter +=1
```

### for loops
```
# syntax

for <var> in range(<start>,<end+1>):
    <action>

for <var> in <var>:
    <action>
```

```
# examples

for counter in range(0, 10):
    print(counter)

readings = [1.2 , 4.7, 5.9, 2.6]
for value in readings:
    print(value)

```

## functions

a function is a block of code which only runs when it is called. you can pass data, known as parameters, into a function. a function can return data as a result.

```
# syntax

def <function name>([<paramer list...>]):
    <action>
    return [<return value>]
```
```
# example

def do_nothing():
    # this function does not do anyting, it can serve as a placeholder
    # use the 'pass' keyword to indicate that the function doesnt do anything
    pass

def add_numbers(first_num , second_num):
    return first_num + second_num

sum = add_numbers(3, 6)

# default values

def multiply(first_num, second_num = 1)
    return first_num * second_num

prod = multiply(4,3)
prod = multiply(5)

# type hinting
# a formal solution to statically indicate the type of a value within your Python code.
# introduced in python 3.5 and specified in PEP 484
# help catch errors , improve linters ability to detect possible errors, improve your code readability

def greet(name: str) -> str:
    return "Hello, " + name

def add_integer( num_1 : int , num_2 : int) -> int:
    return num_1 + num_2

# can you still pass floats to add_integer ? Yes :(

```

## list

lists are used to store multiple items in a single variable.

```
my_list = ["apple", "banana", "cherry"]

print(my_list)

# can allow duplicates
this_list = ["apple", "banana", "cherry", "apple", "cherry"]

print(len(this_list))

# list can contain different data

list2 = [1, 5, 7, 9, 3]
list3 = [True, False, False]
list1 = ["abc", 34, True, 40, "male"]

# list can be accessed via index
this_list = ["apple", "banana", "cherry"]
print(this_list[1])
print(this_list[-1])
print(this_list[-2])

this_list = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(this_list[2:5])

this_list = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(this_list[:4])

this_list = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(this_list[2:])

# appending data to a list
this_list = ["apple", "banana", "cherry"]
this_list.append("orange")
print(this_list)

this_list = ["apple", "banana", "cherry"]
this_list.insert(1, "orange")
print(this_list)

# removing an item

this_list = ["apple", "banana", "cherry"]
this_list.remove("banana")
print(this_list)

# unlike remove, pop returns the item that was removed

this_list = ["apple", "banana", "cherry"]
this_list.pop(1)

this_list = ["apple", "banana", "cherry"]
this_list.pop()
```

## reading assignment
- list comprehension
- dictionary
- tuples

gha_license_id: MIT