text:
# MongoDB Usage Analysis

## DB
The application uses only one database, named `test_suite`

### Collections
There are three collections in the `test_suite` database

#### `OIDC_REGISTERED_CLIENTS` Collection
This collection holds the dynamically registered client information when a user logs into the test suite using something other than Google. (I.E<EMAIL_ADDRESS>
##### Fields
> `_id`:  This is the ID of the client, it is the same as the 'issuer' (e.g. `https://mitreid.org`
>
> `_class`: This is the class used by Spring to represent this information, should be `com.mongodb.BasicDBObject`
>
> `client_json`: This contains the serialized JSON for the client registration.
>
> `time`: NumberLong timestamp for the entry

Since this collection is only searched by the issuer (`_id`) The default index on the `_id` field is sufficent.

#### `TEST_INFO` Collection
This collection contains information about each test instance in the framework.

##### Fields
> `_id`: Id field, random string
>
> `_class`: Java class used by Spring to represent this data (should be `com.mongodb.BasicDBObject`)
>
> `testId`: Same as `_id`?
>
> `testName`: This is the name of the test being run. (What type of test is being run)
>
> `started`: Timestamp of when the test was started
>
> `config`: This contains a structure that is the configuration for the test being run. the contents of this sub document depend on the test.
>
> `alias`: Alias for this test. A non-unique name that can be attached to the particular instance of a test.
>
> `owner`: The owner of the test, it is a sub document with the `sub` and `iss` properties of the user. ('subject' and 'issuer' related to how they logged in.
>
> `status`: Current Status of the test, a String value.
>
> `result`: Final result of the test.

##### Queries from `TestInfoApi.java`
`/info` Request Mapping:
> If the user is an admin, it is just a `.find()` of all objects.
If the user isn't an admin, the `owner` field is used, since this is a majority of the cases, an index on just `owner` could be useful

`/info/{id}` RequestMapping:
> As an admin, the query hits just the `_id` field, so the default index is sufficant.
> As a non-admin, the query hits both `_id` and `owner`, HOWEVER since `_id` is unique and already indexed, MongoDB will use the `_id` index to find the document first, then compair the `owner` to it. This means adding a compound index won't be helpful.

##### Queries from `DBTestInfoService.java`
The only `queries` of note in the `DBTestInfoService` are the update operations which are performed on documents based on `_id` (and sometimes `owner`), thus the default index is fine here.

####`EVENT_LOG` Collection

##### Fields (A subset of the fields that are relevnet)
> `_id`: Id field, made up from the `testId` plus a `-` and a long string of random chars
>
> `_class`: Java class used by Spring to represent this data (should be `com.mongodb.BasicDBObject`)
>
> `testId`: Same as `_id`?
>
> `testName`: This is the name of the test being run. (What type of test is being run)
>
> `started`: Timestamp of when the test was started
>
> `alias`: Alias for this test. A non-unique name that can be attached to the particular instance of a test.
>
> `testOwner`: The owner of the test, it is a sub document with the `sub` and `iss` properties of the user. ('subject' and 'issuer' related to how they logged in.
>
> `src`: Where the log came from.
>

##### Queries from `LogApi.java`
`/log` Request Mapping:
> `testOwner` is used to filter documents if the user is not an admin (so an index on `testOwner` could be helpful
>
> There is a call to get distinct `testId`s using the `testOwner` filter from above. There can perhaps be a better way to deal with this index wise. **DO MORE RESEARCH**

`/log/{id}` Request Mapping:
> The main filter being done here is on `testId` so an index on that could help immensly. Addtionally `testOwner` is used, but that can be fufilled by an index on `testOwner` alone. (from above...)
> Additionally a `.sort()` is done on the `time` field. Again an index will speed this operation.

##### Queries from `ImageAPI.java`
The updates performed here use the `testId` field for the main searching. (Along with placeholders, etc. But since all queries use `testId` an index on that should be the most bennificial.)

# Suggested addtional Indeices
Along with the default `_id` index that is on all collections, the following indices could be added to speed performance.

`OIDC_REGISTERED_CLIENTS`
> None. Only the `_id` field is used.

`TEST_INFO`
> `owner` This is used quite often to limit results, so creating an index on this field would be most helpful

`EVENT_LOG`
> `testOwner` is used when preparing the list of log entries
> `testId` is used extensivly (this is used in the 'distinct' call as well)
> `time` is used to sort fields along with `testId`

repository: openid-certification/conformance-suite

gha_language: Java

repo_name: openid-certification/conformance-suite


text:
filterByKey
===========

A plugin for Phile that adds a Twig function to filter a Page by a specific meta key

### 1.1 Installation (composer)

```
php composer.phar require phile/filterByKey:*
```

### 1.2 Installation (Download)

* Install [Phile](https://github.com/PhileCMS/Phile)
* Clone this repo into `plugins/phile/filterByKey`

### 2. Activation

After you have installed the plugin. You need to add the following line to your `config.php` file:

* add `$config['plugins']['phile\\filterByKey'] = array('active' => true);` to your `config.php`

### What Is This For?

I had a list of pages that only contained a *specific meta key* I wanted to iterate over. I also had to echo out a divider for each 3 items. I was going to use the [batch](http://twig.sensiolabs.org/doc/filters/batch.html) feature in Twig, but it required that my array was already sorted. So I needed a way to create a new array with only the pages that contained that specific meta key *and then* use batch on that new array.

This new Twig function allows you to filter an array of pages, into a new array of pages that only contains the meta key that you want. See the example below to see a real world use case.

#### Examples:

```twig
{# Give me a new array, but leave out pages that dont have meta.instructor_name #}
{% set team = filter_by_key(pages, 'instructor_name') %}

<div class="row">
{% for member in team %}
  <div class="col col-3">
    <a href="{{ member.url }}" title="{{ member.title }}">{{ member.meta.instructor_name }}</a>
  </div>
{% endfor %}
</div>
```

```twig
{# I only want an array that contains pages with 'Alt Data:' in the meta comment #}
{% set items = filter_by_key(pages, 'alt_data') %}

<table>
{% for row in items|batch(3, 'No item') %}
    <tr>
        {% for column in row %}
            <td>{{ column }}</td>
        {% endfor %}
    </tr>
{% endfor %}
</table>
```

license: MIT

repository: PhileCMS/filterByKey

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: PhileCMS/filterByKey


text:
---
Order: 30
Title: Examples
Description: Examples for using the Cake.Issues.PullRequests.Tfs addin.
---

## Using with repository remote url and source branch name

This example shows how to write issues as comments to a Team Foundation Server (TFS) or
Visual Studio Team Services (VSTS) pull request while using repository information.

For determing the remote repository URL and source branch of the pull request you need the [Cake.Git] addin:

```csharp
#addin "Cake.Git"
```

To write issues as comments to TFS or VSTS pull requests you need to import the core addin,
the core pull request addin, the TFS/VSTS support and one or more issue provider, in this example
for JetBrains InspectCode:

```csharp
#addin "Cake.Issues"
#addin "Cake.Issues.InspectCode"
#addin "Cake.Issues.PullRequests"
#addin "Cake.Issues.PullRequests.Tfs"
```

In the following task we'll first determine the remote repository URL and
source branch of the pull request and with this information call the [TfsPullRequests] alias:

```csharp
Task("ReportIssuesToPullRequest").Does(() =>
{
    var repoRootFolder = MakeAbsolute(Directory("./"));
    var currentBranch = GitBranchCurrent(repoRootFolder);
    var repoRemoteUrl = new Uri(currentBranch.Remotes.Single(x => x.Name == "origin").Url);
    var sourceBranchName = currentBranch.CanonicalName;

    ReportIssuesToPullRequest(
        InspectCodeIssuesFromFilePath(
            @"C:\build\inspectcode.log"),
        TfsPullRequests(
            repoRemoteUrl,
            sourceBranchName,
            TfsAuthenticationNtlm()),
        repoRootFolder);
});
```

## Voting for pull requests

The [Cake.Issues.PullRequests.Tfs addin] also provides an alias for approving or voting for pull requests.

:::{.alert .alert-info}
The approve functionality can be used without using the [Cake.Issues addin].
:::

The following example will approve a pull request on a Team Foundation Server:

```csharp
#addin "Cake.Issues.PullRequests.Tfs"

Task("Vote-PullRequest").Does(() =>
{
    var pullRequestSettings =
        new TfsPullRequestSettings(
            new Uri("http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository"),
            "refs/heads/feature/myfeature",
            TfsAuthenticationNtlm());

    TfsVotePullRequest(
        pullRequestSettings,
        TfsPullRequestVote.Approved);
});
```

You can also vote based on the issues provided to the [Cake.Issues addin].

The following example will mark the pull request as waiting for author if any JetBrains InspectCode
warnings have occurred and approves the pull request otherwise:

```csharp
#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools"
#addin "Cake.Issues"
#addin "Cake.Issues.Issues.InspectCode"
#addin "Cake.Issues.PullRequests.Tfs"

var logPath = @"c:\build\inspectcode.xml";
var repoRootPath = @"c:\repo";

Task("Analyze-Project").Does(() =>
{
    // Run InspectCode.
    var settings = new InspectCodeSettings() {
        OutputFile = logPath
    };

    InspectCode(repoRootPath.CombineWithFilePath("MySolution.sln"), settings);
});

Task("Vote-Pullrequest")
.IsDependentOn("Analyze-Project")
.Does(() =>
{
    // Read Issues.
    var issues = ReadIssues(
        InspectCodeIssuesFromFilePath(logPath),
        repoRootPath);

    // Vote for pull request.
    var vote = issues.Any() ? TfsPullRequestVote.WaitingForAuthor : TfsPullRequestVote.Approved;
    TfsVotePullRequest(
        pullRequestSettings,
        vote);
});
```

[TfsPullRequests]: ../../../api/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases/
[Cake.Git]: https://www.nuget.org/packages/Cake.Git/
[Cake.Issues.PullRequests.Tfs addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.Tfs
[Cake.Issues addin]: https://www.nuget.org/packages/Cake.Issues


text:
# Lean Testing in C# with LeanTest.Net

LeanTest.Net is a shared library which is used to simplify the process of creating and maintaining
simple, consistent and lean developer tests across projects.

You can find the documentation in [GitHub Pages](https://belgaard.github.io/Leantest/).

## Deployment
The latest AppVeyor build [![Build status](https://ci.appveyor.com/api/projects/status/gd05aw9aslc3kgbq/branch/master?svg=true)](https://ci.appveyor.com/project/belgaard/leantest/branch/master) (from the latest push to master on GitHub) is available on myGet.org,
 - https://www.myget.org/F/belgaard-ci/api/v3/index.json

LeanTest.Net is built on at least .Net Standard 2.0, in order to avoid the many supporting dependencies needed by 1.0.
Older versions from v0.13.* were built on .Net Standard 1.0
in order to make it possible to use LeanTest.Net on all platforms supported by .Net Standard.

We use semantic versioning, so you can count on minor version upgrades being backwards compatible.
However, note that older versions that start with _0._, are considered as pre-releases.
The consequence of this is that there may be small breaking changes
even though only the minor part of the version was bumped up.

Officially released builds are available on nuGet.org,
 - Core: [![nuGet Core](https://img.shields.io/nuget/v/LeanTest.Core.svg?style=plastic)](https://www.nuget.org/Packages/LeanTest.Core)
 - Mock: [![nuGet Mock](https://img.shields.io/nuget/v/LeanTest.Mock.svg?style=plastic)](https://www.nuget.org/Packages/LeanTest.Mock)
 - JSon: [![nuGet JSon](https://img.shields.io/nuget/v/LeanTest.JSon.svg?style=plastic)](https://www.nuget.org/Packages/LeanTest.JSon)

## Support
 [![Join the chat at https://gitter.im/Leantestnet/Lobby](https://badges.gitter.im/Leantestnet/Lobby.svg)](https://gitter.im/Leantestnet/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## References
An early version of LeanTest, as well as the concept of developer testing,
was used extensively while developing Saxo Bank's social web site,
[TradingFloor.com](https://www.tradingfloor.com/).
Around 850+ developer tests (today 1000+ tests) covered most business functionality, running on a typical developer PC in around one minute.
Major refactorings of the code were done with these tests as a safety net.

LeanTest is currently used internally in Saxo Bank's REST based [OpenAPI](https://developer.saxo).

repository: dotnet-school/Leantest

repo_name: dotnet-school/Leantest


text:
# ILanguageCloud

[![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]

Generate interactive wordclouds for any language, with automatic stop word detection and ability to export as svg or png.

![lexicon_browser2](https://cloud.githubusercontent.com/assets/196199/6282934/6bc5fb10-b90f-11e4-8e4c-8fb9bbf0799f.png)

![screen shot 2014-05-23 at 02 07 45 pm](https://cloud.githubusercontent.com/assets/196199/3065420/31f27b7c-e262-11e3-9208-f5c58ca7177a.png)

## Getting Started
### On the server
Install the module with: `npm install ilanguage-cloud`

```javascript
var ILanguageCloud = require('ilanguage-cloud');
new ILanguageCloud().render(); // returns a wordcloud object with default options
```

### In the browser

Install the module with: `bower install ilanguage-cloud --save`

Or, download the [production version][min] or the [development version][max].

[min]: https://raw.github.com/iLanguage/iLanguageCloud/master/dist/ilanguage-cloud.min.js
[max]: https://raw.github.com/iLanguage/iLanguageCloud/master/dist/ilanguage-cloud.js

In your web page:

```html
<script src="ilanguage-cloud.min.js"></script>
<script>
  new ILanguageCloud({text: 'A cloud is a visible mass ...'}).render(); // renders the text as a cloud to a div id="cloud" if exists
</script>
```

In your code, you can attach ILanguageCloud's methods to any object.

```html
<script>
var exports = WordCloud;
</script>
<script src="ilanguage-cloud.min.js"></script>
<script>
  new WordCloud({text: 'A cloud is a visible mass ...'}).render();
</script>
```

## Documentation

Optionally, you can pass an options object to ILanguageCloud.

```html
<script>
  var myOptions = {
    element: 'cloud',
    text: 'A cloud is a visible mass of condensed droplets or frozen crystals suspended in the atmosphere.',
    font: 'FreeSans',
    nonContentWords: 'a is by in of the or'
  };
</script>
<script src="ilanguage-cloud.min.js"></script>
<script>
  new ILanguageCloud(myOptions).render();
</script>
```

## Examples

* [Javascript](samples/vanilla)
* [Angular](samples/angular)
* [Backbone](samples/backbone)
* [JQuery-plugin](samples/jquery_plugin)

* [Android](https://github.com/iLanguage/iLanguageCloudAndroid)
* [Chrome App](https://github.com/iLanguage/iLanguageCloudChrome)
* [WordPress](https://github.com/iLanguage/iLanguageCloudWordPress)

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using the scripts in `package.json`.

[More details...](CONTRIBUTING.md)

## Release History

* v1.0 Feb 9 2012 - Initial word cloud using CSS rotation in vanilla js
* v2.0 Jan 29 2013 - WordPress plugin with SVG generation in vanilla js
* v3.0 Nov 15 2013 - Switched to Jason Davies' [d3-cloud](https://github.com/iLanguage/d3-cloud) to generate SVG
[Download on Google Play](https://play.google.com/store/apps/details?id=ca.ilanguage.ilanguagecloud)

## License

Copyright (c) 2012-2017 iLanguageCloud Contributors. Licensed under the Apache 2.0 license.

[npm-url]: https://npmjs.org/package/ilanguage-cloud
[npm-image]: https://badge.fury.io/js/ilanguage-cloud.svg
[travis-url]: https://travis-ci.org/iLanguage/iLanguageCloud
[travis-image]: https://travis-ci.org/iLanguage/iLanguageCloud.svg?branch=master
[daviddm-url]: https://david-dm.org/iLanguage/iLanguageCloud.svg?theme=shields.io
[daviddm-image]: https://david-dm.org/iLanguage/iLanguageCloud

repository: MatMath/iLanguageCloud

repo_name: MatMath/iLanguageCloud


text:
# Bootchain

## SecureROM
The secure Read-Only Memory is what is reffered to as BootROM.
The code on the SecureROM is flashed at production and can not be modified as the name already clarifies, it is read-only.
Flaws in the algorithmic logic of the BootROM are persistant and can not be patched unless the device is taken into a factory and the chip is replaced.
Apple Inc. can decide to make it harder to exploit flaws at SecureROM level but they can never fully prevent exploitation.
Therefore jailbreaks built on BootROM level vulnerabilities are the most consistant.
Internal references to BootROM can be found in the leaked source code of iBoot which may aid research on this absolute lowest-level of the iPhone software.
Usually bugs can be found through analyzing dumps of BootROM.
SecureROM code is loaded into the memory at a very early stage of the boot process, therefore when having code execution in the bootloader one can dump this code from the physical fixed memory address it is mapped to.
With this dump one can create a section in IDA and combine it with a RAM and NOR dump taken from the same stage.
Then vulnerabilities can be found and sometimes even implementations from Apple Inc. that are open-source can be used to symbolicate structures (e.g. Apple's memcpy).
For symbolicating one would simply need to compile that source code from Apple Inc. and create a FLAIR import for the IDA.
IDA will do the rest.

## Low-Level Bootloader

## iBoot Single Stage

## iBoot Epoch Change

## iBoot

## DeviceTree

## Secure BootChain

### SHSH Tickets (ApTicket)

## KernelCache

## RamDisk

## FileSystem

repository: UKERN-Developers/DarwinisticEducation

repo_name: UKERN-Developers/DarwinisticEducation


text:
# LEGO® MINDSTORMS® Education EV3 for Microsoft MakeCode [![Build Status](https://travis-ci.org/microsoft/pxt-ev3.svg?branch=master)](https://travis-ci.org/microsoft/pxt-ev3)

This repo contains the editor target hosted at https://makecode.mindstorms.com

## Local setup

These instructions assume familiarity with dev tools and languages.

* install Node.js 8.9.4+
* install Docker; make sure `docker` command is in your `PATH`
* (optional) install [Visual Studio Code](https://code.visualstudio.com/)

* clone https://github.com/Microsoft/pxt-ev3 to ``pxt-ev3`` folder
* go to ``pxt`` and run

```
npm install
```

* to run the local server,
```
pxt serve --cloud
```

## Local Dev setup

In the common folder,

* clone https://github.com/Microsoft/pxt to ``pxt`` folder
* clone https://github.com/Microsoft/pxt-common-packages to ``pxt-common-packages`` folder

* go to ``pxt-common-packages`` and run

```
npm install
npm link ../pxt
```

* go to ``pxt-ev3`` and run

```
npm install
npm link ../pxt
npm link ../pxt-common-packages
```

## to run the local server

From root github folder,

```
cd pxt-ev3
pxt serve --cloud
```

## to build and deploy a single package via command line

```
cd libs/core
pxt deploy
```

## License
MIT

## Trademarks
MICROSOFT, the Microsoft Logo, and MAKECODE are registered trademarks of Microsoft Corporation. They can only be used for the purposes described in and in accordance with Microsoft’s Trademark and Brand guidelines published at https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general.aspx. If the use is not covered in Microsoft’s published guidelines or you are not sure, please consult your legal counsel or the MakeCode team (makecode@microsoft.com).

## Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode<EMAIL_ADDRESS>with any additional questions or comments.

gha_license_id: NOASSERTION


text:
# Setup

Install Clojure and Leiningen (on Arch Linux):

    # pacman -S clojure leiningen

Create a sample project (called `demo`) and run it:

    $ lein new app demo
    $ cd demo
    $ lein run

Create an executable "uberjar" and execute it:

    $ lein uberjar
    $ java -jar target/uberjar/demo-0.1.0-SNAPSHOT-standalone.jar

Start a REPL and start the `-main` function from it:

    $ lein repl
    => (-main)

# Emacs

Install Emacs (on Arch Linux, without X components):

    # pacman -S emacs-nox

Setup the MELPA package repository in `~/.emacs`:

    (require 'package)
    (add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
    (package-initialize)

Re-open emacs and install `clojure-mode` and CIDER with nrepl as follows:

    M-x package-install [RET] clojure-mode [RET]
    M-x package-install [RET] cider [RET]

Use another shell to start your repl:

    $ cd demo
    $ lein repl
    nREPL server started on port 39711 on host <IP_ADDRESS> - nrepl://<IP_ADDRESS>:39711

Back in Emacs, connect to the REPL using the indications given by Leiningen:

    M-x cider-connect [RET] localhost [RET] 39711

Or simpler, use `cider-jack-in`, which automatically figures out the parameters
from the `.nrepl-port` file:

    M-x cider-jack-in

# Links

- [Clojure](https://clojure.org/)
- [Leiningen](https://leiningen.org/)

repository: patrickbucher/docs

gha_language: TeX

repo_name: patrickbucher/docs


text:
<img src="https://raw.githubusercontent.com/halomademeapc/GravyIrc/master/docfx_project/logo.png" alt="GravyIrc Logo" width="128"/>

# GravyIrc
[![Build Status](https://img.shields.io/travis/halomademeapc/GravyIrc?style=flat-square)](https://travis-ci.org/github/halomademeapc/GravyIrc) [![GitHub issues](https://img.shields.io/github/issues/halomademeapc/GravyIrc?style=flat-square)](https://github.com/halomademeapc/GravyIrc/issues) [![Nuget](https://img.shields.io/nuget/dt/GravyIrc?style=flat-square)](https://www.nuget.org/packages/GravyIrc/) [![Nuget](https://img.shields.io/nuget/v/GravyIrc?style=flat-square)](https://www.nuget.org/packages/GravyIrc/)

IRC client library targetting .NET Standard 2.0.  Built off of the work done in [fredimachado/NetIRC](https://github.com/fredimachado/NetIRC).

## Goals
* Up-to-date builds on NuGet
* More complete coverage of IRC message types
* Improved documentation
* Runtime extendability

## Quick Start
See the `Guides` section under `Articles` to get started.

You can get GravyIrc from [NuGet](https://www.nuget.org/packages/GravyIrc/).

Check out [Connecting](/articles/guide-connect.html) for your first step after installing the package.

repository: halomakes/GravyIrc

repo_name: halomakes/GravyIrc


text:
# What is the gcloud storage command set?

Using the new `gcloud storage ...` command set is an alternative to using `gsutil` commands to work with GCS (Google Cloud Storage) object instances (buckets, folders, files).

(From GCP [Docs](https://cloud.google.com/blog/products/storage-data-transfer/new-gcloud-storage-enables-super-fast-data-transfers)) *"Gcloud storage takes large files and breaks them down into pieces, so that transfers can best take advantage of the available bandwidth. What’s new in `gcloud storage` (vs `gsutil`) is its **parallelization strategy**, which treats task management as a graph problem, where each unit of work is treated as a node, and each dependency as an edge. This strategy allows **more work to be done in parallel** with far less overhead. Under the hood, gcloud storage also benefits from a new hashing library that enables faster integrity checking. It can also adjust its own settings based on the workload and local machine size to optimize for performance."*

## Performance Comparision

When transferring **100 files** that were 100MB in size
- `gcloud storage` was **79% faster** than `gsutil` on download and 33% faster on upload
-  with both using a composite upload strategy, where a file was broken up and uploaded as separate files, and then recombined into a single file.

When transferring **a single large file**, the difference is even more pronounced
- With a 10GB file, `gcloud storage` was **94% faster** than `gsutil` on download and 57% faster on upload.

To quickly try it out
```
gcloud storage ls gs://pub
gcloud storage cp -r gs://pub/shakespeare/ .
```

## gcloud storage syntax examples

### list buckets and objects
`gcloud storage ls`

### create bucket
`gcloud storage buckets create my-bucket`

### list objects
`gcloud storage ls my-bucket`

### list object contents
`gcloud storage cat my-bucket/my-file.txt`

### upload file
`gcloud storage cp my-bucket/my-file.txt`

### move/rename file
`gcloud storage mv my-bucket/my-file.txt  my-new-filename.txt`

### delete file
`gcloud storage rm my-bucket/my-file.txt`

### delete bucket
`gcloud storage buckets delete my-bucket`

repository: lynnlangit/gcp-essentials

gha_language: Python

repo_name: lynnlangit/gcp-essentials


text:
# 736.

The syntax for these expressions is given as follows.

* An expression is either an integer, a let-expression, an add-expression, a mult-expression, or an assigned variable. Expressions always evaluate to a single integer.
* (An integer could be positive or negative.)
* A let-expression takes the form (let v1 e1 v2 e2 ... vn en expr), where let is always the string "let", then there are 1 or more pairs of alternating variables and expressions, meaning that the first variable v1 is assigned the value of the expression e1, the second variable v2 is assigned the value of the expression e2, and so on sequentially; and then the value of this let-expression is the value of the expression expr.
* An add-expression takes the form (add e1 e2) where add is always the string "add", there are always two expressions e1, e2, and this expression evaluates to the addition of the evaluation of e1 and the evaluation of e2.
* A mult-expression takes the form (mult e1 e2) where mult is always the string "mult", there are always two expressions e1, e2, and this expression evaluates to the multiplication of the evaluation of e1 and the evaluation of e2.
* For the purposes of this question, we will use a smaller subset of variable names. A variable starts with a lowercase letter, then zero or more lowercase letters or digits. Additionally for your convenience, the names "add", "let", or "mult" are protected and will never be used as variable names.
* Finally, there is the concept of scope. When an expression of a variable name is evaluated, within the context of that evaluation, the innermost scope (in terms of parentheses) is checked first for the value of that variable, and then outer scopes are checked sequentially. It is guaranteed that every expression is legal. Please see the examples for more details on scope.

**Evaluation Examples:**
```
Input: (add 1 2)
Output: 3

Input: (mult 3 (add 2 3))
Output: 15

Input: (let x 2 (mult x 5))
Output: 10

Input: (let x 2 (mult x (let x 3 y 4 (add x y))))
Output: 14
Explanation: In the expression (add x y), when checking for the value of the variable x,
we check from the innermost scope to the outermost in the context of the variable we are trying to evaluate.
Since x = 3 is found first, the value of x is 3.

Input: (let x 3 x 2 x)
Output: 2
Explanation: Assignment in let statements is processed sequentially.

Input: (let x 1 y 2 x (add x y) (add x y))
Output: 5
Explanation: The first (add x y) evaluates as 3, and is assigned to x.
The second (add x y) evaluates as 3+2 = 5.

Input: (let x 2 (add (let x 3 (let x 4 x)) x))
Output: 6
Explanation: Even though (let x 4 x) has a deeper scope, it is outside the context
of the final x in the add-expression.  That final x will equal 2.

Input: (let a1 3 b2 (add a1 1) b2)
Output 4
Explanation: Variable names can contain digits after the first character.
```
**Note:**

* The given string expression is well formatted: There are no leading or trailing spaces, there is only a single space separating different components of the string, and no space between adjacent parentheses. The expression is guaranteed to be legal and evaluate to an integer.
* The length of expression is at most 2000. (It is also non-empty, as that would not be a legal expression.)
* The answer and all intermediate calculations of that answer are guaranteed to fit in a 32-bit integer.

Companies: Uber

Related Topics: Stack

Similar Questions: Can Place Flowers

repository: jiadaizhao/LeetCode

gha_license_id: MIT

repo_name: jiadaizhao/LeetCode


text:
# Containerized Heketi with an dedicated GlusterFS cluster (static and dynamic provisioning)

Using GlusterFS and Heketi is a great way to perform static and dynamic provisioning
in a Kubernetes based cluster for persistent volume shared filesystems.  Typically this is accomplished by running both
Heketi and GlusterFS as containerized components of the cluster (gk-deploy), but what about only running Heketi as a container
and communicating with a dedicated GlusterFS cluster (non-containerized)?

This example will walk through a simple version of this setup to take advantage of existing dedicated storage environments while
still providing the benefits of reliability and failover from a Kubernetes environment.

This example assumes some familiarity with Kubernetes and the [Kubernetes Persistent Storage](http://kubernetes.io/docs/user-guide/persistent-volumes/) model.

This example also assumes you have access to an existing GlusterFS cluster that has raw devices available for consumption and management by Heketi Server.  If
you do not have this, you can create a 3 node (CentOS or fedora) cluster using your Virtual Machine solution of choice and make sure you create a few raw devices and give
plenty of space.  See below for a quick start guide or [installing GluserFS Guide](https://www.gluster.org/)

### Environment and prerequisites for this example.

- GlusterFS Cluster running CentOS 7 (2 nodes, each with at least 2 X 200GB raw devices)
   - gluster25.rhs (<IP_ADDRESS>)
   - gluster26.rhs (<IP_ADDRESS>)

- Kubernetes Node running CentOS 7 (1.5 or later, this example will use the latest source from HEAD for 1.7 version)
   - k8dev3.rhs (<IP_ADDRESS>)
   - run a single node cluster using ./hack/local-up-cluster.sh

***NOTE:*** When running local-up-cluster.sh to build a single node Kubernets cluster I typically run export HOSTNAME_OVERRIDE=yourhostname

### Verify functioning and accessible dedicated GlusterFS environment

Below are some basic commands to help validate that your GlusterFS cluster is working properly.
Also, for this example, an existing volume was created to store the Heketi db file, to simulate a dedicated environment
with existing volumes.

#### Installing and configuring GlusterFS Nodes (If needed)

Install 2 nodes to run as the GlusterFS storage cluster and simulate an existing legacy environment.
This example uses 2 CentOS 7 systems all running latest GlusterFS. More advanced and additional information can be found on the official [GlusterFS Site](https://www.gluster.org/)

***NOTE:*** 2 node clusters are not officially recommended as it causes some known replication issues (split brain), and if possible a 3+ node cluster should be used if possible.

#### View basic node and device information.

Execute `lsblk` command to show our raw devices (which will be used later in this example to load into Heketi).

```
	# lsblk
	NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
	sda           8:0    0   20G  0 disk
	├─sda1        8:1    0    1G  0 part /boot
	└─sda2        8:2    0   19G  0 part
	  ├─cl-root 253:0    0   17G  0 lvm  /
	  └─cl-swap 253:1    0    2G  0 lvm  [SWAP]
	sdb           8:16   0  200G  0 disk  <1>
	sdc           8:32   0  200G  0 disk  <2>
	sr0          11:0    1 1024M  0 rom
```
<1> 200GB raw device that we will let Heketi manage

<2> 200GB raw device that we will let Heketi manage

#### Confirm proper access and communication between GlusterFS nodes.

- Update `/etc/hosts` with ip and hostname (i.e.  <IP_ADDRESS> gluster25.rhs)
- Set up password-less SSH communication between all nodes

```
	# ssh-keygen  (take defaults)
	# ssh-copy-id -i /root/.ssh/id_rsa.pub<EMAIL_ADDRESS>```
***NOTE:*** Repeat this from each node as necessary that you might want to ssh

#### Enable firewall rules.

Add Some Firewall Rules On All Nodes (if you have not disabled firewalld)

```
	# firewall-cmd --zone=public --add-service=glusterfs --permanent
	# firewall-cmd --reload
```

#### Check peer status and volume info for GlusterFS cluster.

```
	# gluster peer status
	# gluster volume list
```

### Prepare the Kubernetes Master and All Nodes
This directory structure will be used to store the SSH keys for heketi as well
as the configuration files that are needed.

````
	# mkdir -p /usr/share/heketi/keys
````

#### Validate communication and Gluster prerequisites on the Kubernetes node(s).

- Make sure glusterfs-client is installed

```
	# yum install epel-release -y
	# yum install glusterfs-client -y
	# modprobe fuse
```

- As with the other CentOS VMs that have been created, make sure the Kubernetes cluster has proper firewall access and can communicate with the heketi server and glusterfs servers.

```
	Update /etc/hosts...

	Add some firewall rules...
	# firewall-cmd --permanent --zone=public --add-port=8080/tcp
	# firewall-cmd --permanent --zone=public --add-port=8081/tcp
	# firewall-cmd --reload

	Add SELinux booleans for fuse...
	# setsebool -P virt_use_fusefs 1
	# setsebool -P virt_sandbox_use_fusefs 1
```

#### Install the Heketi-Client.
On the master node install the Heketi-Client.
Download the [latest Heketi release](https://github.com/heketi/heketi/releases) and untar it into the /etc/heketi directory.

```
	Install
	# wget https://github.com/heketi/heketi/releases/download/v4.0.0/heketi-client-v4.0.0.linux.amd64.tar.gz
	# mkdir -p /etc/heketi && tar xzvf heketi-client-v4.0.0.linux.amd64.tar.gz -C /etc/heketi

	Export PATH
	# export PATH=$PATH:/etc/heketi/heketi-client/bin
	# heketi-cli --version
	heketi-cli v4.0.0
```

***NOTE:*** The client can be installed on any node/system in your network that has access to the Kubernetes cluster and GlusterFS cluster.

#### Create Heketi private keys on master node.

A private key is needed for Heketi to communicate with the Gluster nodes, to accomplish this
we will create the ssh keys from the master (or one of the nodes in the cluster),
and generate a Kubernetes secret that can be used for cluster communication to GlusterFS storage pool.

From the master node.

```
	If not already created, create the keys directory:
        # mkdir -p /usr/share/heketi/keys

        On the master node:
	# cd /usr/share/heketi/keys  <1>
 	# ssh-keygen -f /usr/share/heketi/keys/heketi_key -t rsa -N ''  <2>
 	# ssh-copy-id -i /usr/share/heketi/keys/heketi_key.pub<EMAIL_ADDRESS><3>
	# ssh-copy-id -i /usr/share/heketi/keys/heketi_key.pub<EMAIL_ADDRESS><3>
	# chmod 770 heketi* <4>
```
<1> Change directory to the dir that was created earlier

<2> Generate the ssh key

<3> copy each ssh key to the dedicated gluster cluster nodes

<4> Change the permissions on the keys

#### Create the Heketi secret in Kubernetes

```
	# kubectl create secret generic ssh-key-secret --from-file=/usr/share/heketi/keys
	secret "ssh-key-secret" created
```

#### Obtain and edit the Heketi configuration file to setup the SSH executor.

The heketi.json file is used to configure Heketi on initial container start up. There are multiple
ways to create and have Heketi properly access and load this file, for this
example we are simply creating a configmap from the file that can be easily passed
around the cluster.  Alternatively you could simply copy the heketi.json file
to each node and put in /usr/share/heketi and create a hostPath volume or
even store on another share point (GlusterFS volume or NFS, etc...). A sample
heketi.json file is included with this repo or you can obtain the latest from
the Heketi repo.

Below is an excerpt from the heketi.json file highlighting the sections
that potentially could/would need to be changed for your environment.

```
	{
  	"_port_comment": "Heketi Server Port Number",
  	"port": "8081",  <1>
	...
        ...
	"executor": "ssh",  <2>

	"_sshexec_comment": "SSH username and private key file information",
	"sshexec": {
  	  "keyfile": "/usr/share/keys/heketi_key",  <3>
  	  "user": "root",  <4>
  	  "port": "22",  <5>
  	  "fstab": "/etc/fstab"  <6>
	},
        ...

```
<1> Default port is 8080, you can configure a different port like 8081, especially if 8080 is already in use.

<2> Change "executor": from mock to ssh

<3> Add in the public key directory specified in previous step from the perspective of the pods directory
defined in the heketi-deployment.yaml (where the secret volume will be mounted in the pod)

<4> Update SSH user (should have sudo/root type access)

<5> Set the port to 22 - remove all other text

<6> Set the fstab to default (etc/fstab) - remove all other text

#### Create the configmap from the heketi.json file

```
	# kubectl create configmap heketi-config --from-file=/usr/share/heketi/heketi.json
	configmap "heketi-config" created
```

#### Create the dedicated GlusterFS cluster endpoints and service.

The endpoints and service are used to access the GlusterFS cluster to establish mounts.
These are used for our ReplicationController/Container in future steps and also can be reused
for any other pods that need access to GlusterFS cluster.
Run the following yaml examples.

glusterfs-endpoints.yaml
```
apiVersion: v1
kind: Endpoints
metadata:
 name: glusterfs-cluster
subsets:
 - addresses:
   - ip: <IP_ADDRESS>
   ports:
   - port: 1
     protocol: TCP
 - addresses:
   - ip: <IP_ADDRESS>
   ports:
   - port: 1
     protocol: TCP
```

gluster-service.yaml
```
kind: Service
apiVersion: v1
metadata:
  name: glusterfs-cluster
spec:
  ports:
  - port: 1
```

#### Create the Heketi deployment
A Kubernetes deployment will create a deployment, ReplicaSet (next generation Replication Controller) and the container pods.
A sample heketi-deployment.yaml is included below.

```
	# kubectl create -f heketi-deployment.yaml
	deployment "heketi-deployment" created
```

heketi-deployment.yaml
```
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: heketi-deployment
  labels:
    app: heketi
  annotations:
    description: Defines how to deploy Heketi
spec:
  replicas: 1
  template:
    metadata:
      name: heketi
      labels:
        app: heketi
    spec:
      hostNetwork: true
      containers:
      - name: heketi
        image: heketi/heketi:dev
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: keys
          mountPath: /usr/share/keys  <1>
        - name: config
          mountPath: /etc/heketi  <2>
        - name: db
          mountPath: /var/lib/heketi  <3>
      volumes:
        - name: keys
          secret:
            secretName: ssh-key-secret  <1>
        - name: config
          configMap:
            name: heketi-config  <2>
        - name: db
          glusterfs:
            endpoints: glusterfs-cluster
            path: MyHeketi  <3>
```

<1>  The ssh secret key mount and volume

<2>  The Heketi config configmap mount and volume.

<3>  Set up a Heketi db volume and path to store the heketi.db.  Notice we are using a volume on our actual GlusterFS cluster to store this heketi.db (volume should be greater than 40Gb).

***NOTE:*** For this example we have a chosen a Deployment, but a DaemonSet or even a simple ReplicationController would also acceptable.

#### Create the Heketi Service.
A service will expose the Heketi port.
From the master node run the following commands:

```
	Get the ReplicaSet name to pass into our `kubectl expose`
	# kubectl get rs
	NAME                	      DESIRED   CURRENT   READY     AGE
	heketi-deployment-4226138653   1         1         1         34m

	Create the ReplicaSet service
	# kubectl expose rs heketi-deployment-4226138653 --port=8081 --target-port=8081 --name=heketi-service
	service "heketi-service" exposed

	This would also work, but currently there is a bug in latest code base (will replace when fixed)
	# kubectl expose deployment heketi-deployment --port=8081 --target-port=8081 --type=LoadBalancer --name=heketi-service
	error: no kind "Deployment" is registered for version "apps/v1beta1"
```

#### Validate the Heketi pod is running.

```
	# kubectl get deployment
	NAME                KIND
	heketi-deployment   Deployment.v1beta1.apps

	# kubectl get rs
	NAME                           DESIRED   CURRENT   READY     AGE
	heketi-deployment-4226138653   1         1         1         42m

	# kubectl get pod -o wide
	NAME                                 READY     STATUS    RESTARTS   AGE       IP              NODE
	heketi-deployment-4226138653-2gcc3   1/1       Running   0          43m       <IP_ADDRESS>   k8dev3.rhs

	# kubectl logs heketi-deployment-4226138653-2gcc3
	Heketi v4.0.0-46-g8e58761
	[heketi] INFO 2017/03/21 16:18:54 Loaded ssh executor
	[heketi] INFO 2017/03/21 16:18:54 Loaded simple allocator
	[heketi] INFO 2017/03/21 16:18:54 GlusterFS Application Loaded
	Listening on port 8081
```

***NOTE:*** Because we used HOSTNAME_OVERRIDE environment variable to start local-up-cluster.sh and set the hostNetwork: true in our container
the container picks up the actual ipaddr of the node it is running on.

#### Test connection to Heketi.

```
	# curl http://k8dev3.rhs:8081/hello
	Hello from Heketi
```

#### Set an environment variable for the Heketi Server.
In a previous step we have installed the Heketi-Client on our
master node.

```
	# export HEKETI_CLI_SERVER=http://k8dev3.rhs:8081
```

### Using Heketi with Gluster

A topology file is used to tell Heketi about the GlusterFS storage environment and what devices will be loaded and managed.

***NOTE:*** Heketi is currently limited to managing raw devices only, if a device is already a Gluster volume it
will be skipped and ignored.

#### Create and load the topology file.

There is a sample file located in /etc/heketi/heketi-client/share/heketi/topology-sample.json depending on where you unpacked the client from previous step.
The lsblk command run from the GlusterFS nodes can help determine what devices are available, for this example I will only load the /dev/sdc device into the
topology.

```
	# lsblk
	NAME                                                                              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
	sda                                                                                8:0    0  100G  0 disk
	└─vg_brick1-lv_brick1                                                             253:2    0   20G  0 lvm  /mnt/registry
	sdb                                                                                8:16   0  100G  0 disk
	└─vg_brick2-lv_brick2                                                             253:23   0   80G  0 lvm  /mnt/heketimgmt
	sdc                                                                                8:32   0  100G  0 disk <1>
	sdd                                                                                8:48   0  100G  0 disk <2>
	sde                                                                                8:64   0  100G  0 disk <3>
```
<1> Available device as /dev/sdc

<2> Available device as /dev/sdd

<3> Available device as /dev/sde

Example topology.json file
```
{
  "clusters": [
    {
      "nodes": [
        {
          "node": {
            "hostnames": {
              "manage": [
                "gluster25.rhs"  <1>
              ],
              "storage": [
                "<IP_ADDRESS>"  <2>
              ]
            },
            "zone": 1
          },
          "devices": [
            "/dev/sdc"
          ]
        },
        {
          "node": {
            "hostnames": {
              "manage": [
                "gluster26.rhs"
              ],
              "storage": [
                "<IP_ADDRESS>"
              ]
            },
            "zone": 1
          },
          "devices": [
            "/dev/sdc"
          ]
        }
      ]
    }
  ]
}
```
<1> The manage element should be the fully qualified hostname (not the ip address).

<2> The storage element should be the ip address of the storage node (not the fqdn).

***NOTE:*** The `manage` element in the above json file should be the actual hostname of the GlusterFS node,
and the `storage` element should be the actual ip address of the storage node as it is in the glusterfs-endpoints.

#### Using heketi-cli, run the following command to load the topology of your environment.

```
	# heketi-cli topology load --json=topology.json
	Found node gluster25.rhs on cluster bfd8d40abd5092c4d7c072cf80d0444c
		Adding device /dev/sdc ... OK
	Creating node gluster26.rhs ... ID: 35997ef9bd1ec225713d0eaff5abe9d5
		Adding device /dev/sdc ... OK
```

#### Create a Gluster volume to verify Heketi.

```
	# heketi-cli volume create --size=20 --replica=2

	Name: vol_fe4a7ebca82b989cd7d101945852462b
	Size: 10
	Volume Id: fe4a7ebca82b989cd7d101945852462b
	Cluster Id: bfd8d40abd5092c4d7c072cf80d0444c
	Mount: <IP_ADDRESS>:vol_fe4a7ebca82b989cd7d101945852462b
	Mount Options: backup-volfile-servers=<IP_ADDRESS>
	Durability Type: replicate
	Distributed+Replica: 2
```

***NOTE:*** --replica=2 only needed if you have a 2 node cluster, not a standard 3+ node cluster

#### View the volume information from one of the the Gluster nodes:

```
	# gluster volume list
	MyVolume
	registry
	vol_1b2b344fa375ea17a403e35c3f91dc89
	vol_c8204282e60d55ce9308404e667425c5
	vol_fe4a7ebca82b989cd7d101945852462b <1>

	# gluster volume info vol_fe4a7ebca82b989cd7d101945852462b
	Volume Name: vol_fe4a7ebca82b989cd7d101945852462b <1>
	Type: Distributed-Replicate
	Volume ID: 75be7940-9b09-4e7f-bfb0-a7eb24b411e3
	Status: Started
        ...
	...
```
<1> Volume created by heketi-cli.

### Dynamically Provision a Volume from Kubernetes.

Using the Kubernetes cluster (for this example a single node cluster using ./hack/local-up-cluster.sh). As stated, this part of
the example assumes some familiarity with Kubernetes (installing, running, etc...).

#### Create a Storage Class.

Below definition is based on Kuberenetes 1.6, this version of Storage Class is the minimum needed for this
example to work.  There are other parameters for more advanced use cases and they can be seen in the latest Kubernetes
documentation.

```
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: gluster-dyn
provisioner: kubernetes.io/glusterfs
parameters:
  resturl: "http://k8dev3.rhs:8081"  <1>
  restauthenabled: "false"  <2>
  volumetype: "replicate:2" <3>
```
<1> The resturl pointing to the Heketi Server from HEKETI_CLI_SERVER env variable.

<2> Since we did not turn on authentication, setting this to false.

<3> Typically this parameter is not needed, but since we have a 2 node storage pool, we need to specify that we are doing a 2 node replica set.

***NOTE:*** Recommended and default replica setting is 3, if you have a 3 node storage pool already, no need to pass in the volumetype parameter.

#### From the Kubernetes master node, using kubectl, create the storage class.

```
	# kubectl create -f glusterfs-storageclass1.yaml
	storageclass "gluster-dyn" created
```

#### Now create a pvc, requesting the storage class, below is a sample definition.

```
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: gluster-dyn-pvc
 annotations:
   volume.beta.kubernetes.io/storage-class: gluster-dyn
spec:
 accessModes:
  - ReadWriteMany
 resources:
   requests:
 	storage: 20Gi
```

#### From the Kubernetes master node, create the pvc.

```
	# kubectl create -f glusterfs-pvc-storageclass.yaml
	persistentvolumeclaim "gluster-dyn-pvc" created
```

#### View the pvc to see that the volume was dynamically created and bound to the pvc.

```
	# kubectl get pv
	NAME                                       CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS    CLAIM                     STORAGECLASS   REASON    AGE
	pvc-cf518abc-0e7f-11e7-b2e0-080027d93841   20Gi       RWX           Delete          Bound     default/gluster-dyn-pvc                            2s

	# kubectl get pvc
	NAME              STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
	gluster-dyn-pvc   Bound     pvc-cf518abc-0e7f-11e7-b2e0-080027d93841   20Gi       RWX           gluster-dyn    21s
```

#### Verify and view the new volume on one of the Gluster Nodes.

```
	# gluster volume list
	MyVolume
	registry
	vol_1b2b344fa375ea17a403e35c3f91dc89
	vol_c8204282e60d55ce9308404e667425c5
	vol_fe4a7ebca82b989cd7d101945852462b <1>
	vol_fe4a7ebca82b989cd7d101945852462b <2>
```
<1> Volume created by heketi-cli in previous manual step.

<2> New dynamically created volume triggered by Kubernetes and the Storage Class.

### Create a NGINX pod that uses the PVC

At this point we have a dynamically created GlusterFS volume, bound to a PersistentVolumeClaim, we can now utilize this claim
in a pod.  We will create a simple NGINX pod.

```
apiVersion: v1
kind: Pod
metadata:
  name: gluster-pod1
  labels:
    name: gluster-pod1
spec:
  containers:
  - name: gluster-pod1
    image: gcr.io/google_containers/nginx-slim:0.8
    ports:
    - name: web
      containerPort: 80
    securityContext:
      privileged: true
    volumeMounts:
    - name: gluster-vol1
      mountPath: /usr/share/nginx/html
  volumes:
  - name: gluster-vol1
    persistentVolumeClaim:
      claimName: gluster-dyn-pvc <1>
```
<1> The name of the PVC created in the previous step

#### Create the Pod YAML file.  Save it.  Then submit it to Kubernetes.

```
kubectl create -f nginx-pod.yaml
pod "gluster-pod1" created
```

#### View the Pod (Give it a few minutes, it might need to download the image if it doesn't already exist):

```
kubectl get pods -o wide
NAME                               READY     STATUS    RESTARTS   AGE       IP               NODE
gluster-pod1                       1/1       Running   0          9m        <IP_ADDRESS>        node1

```

#### Now we will exec into the container and create an index.html file.

```
kubectl exec -ti gluster-pod1 /bin/sh
$ cd /usr/share/nginx/html
$ echo 'Hello World from GlusterFS!!!' > index.html
$ ls
index.html
$ exit
```

#### Now we can curl the URL of our pod:

```
curl http://<IP_ADDRESS>
Hello World from GlusterFS!!!
```

repository: slpcat/docker-images

gha_language: Go

repo_name: slpcat/docker-images


text:
# employee-directory

## Technology Used
 * React
 * HashRouter
 * React-Router
 * API fetch
 * React Class and Function Components

## Links
Deployed Application (https://mkotte.github.io/employee-directory/)

Repository (https://github.com/mkotte/employee-directory)

repository: mkotte/employee-directory

branch_name: refs/heads/main

repo_name: mkotte/employee-directory


text:
# Mirage
The best solution against xray users.

![alt text](https://files.smoofyuniverse.net/images/mirage_screenshots.png)

* Ore page: https://ore.spongepowered.org/Yeregorix/Mirage

If you have an issue with eltrydev's mod,
please download the jar files [here](https://files.smoofyuniverse.net/smoofymirage/) instead of on the ore page.
These files have been slightly modified to be compatible.

repository: Yeregorix/Mirage

repo_name: Yeregorix/Mirage


text:
## Dependencies

This project makes use of gorilla/mux, gorm, and godotenv.

## Getting Started

**1. Clone the application**

```bash
git clone https://github.com/nicolaspearson/go.heroes.api.git
```

**2. Start the database**

```bash
docker-compose up
```

**3. Build and run the app**

#### Run the app in development mode:

```bash
go run main.go
```

The app will start running at <http://localhost:8000>

#### Run the app in release mode:

```bash
go build
./go-hero
```

The app will start running at <http://localhost:8000>

## Endpoints

The following endpoints are available:

```
POST /user/register
```

```
POST /user/login
```

```
GET /hero?id={heroId}
```

```
GET /heroes
```

```
POST /hero
```

```
PUT /hero/{heroId}
```

```
DELETE /hero/{heroId}
```

## Benchmarking

Run this command to benchmark request performance:

```
wrk -d1m http://localhost:8000/heroes
```

![benchmark](/img/benchmark.png)


text:
**Preliminary Note
The thesis is complete and submitted in April, 201. It will be made public here once the marking process is done**

## Bachelor Thesis
# Application of Data Mining Methods for Customer Clustering

## Abstract
Knowing its customers is essential for a company’s success. Esp. in the age of e-commerce, where customers became just rows of lists, it is important to target them more individually. The traces buyers leave in an online-store, allow detailed insights on their habits how they interact with an organization. Their purchase history contains all transactional data to build meaningful customer segments. These segments allow more targeted communication and actions towards customers.

The motivation behind this thesis is to investigate the value of clustering in the machine learning/data mining context for customer segmentation. Classical database marketing methods are combined with data mining tools. Data mining techniques can be used to create the segments automatically. The outcome shows that machine learning can be applied successfully for the needs of small and medium organizations and can help in handling a growing customer base.

## Contents
1. Introduction
    1. Commoditization of E-Commerce
    2. Targeting customers
    3. The road-map of this thesis
2. Customer segmentation
    1. Overview
    2. Cohort Analysis
    3. RFM Analysis
        1. The Metrics
        2. Working with the segmented data
        3. Critical Appraisal
        4. Chapter summary and outlook
3. Data Collection
4. Pre-processing
   1. Preparation
   2. Featurescalingg
   3. Standardizing
5. Clustering
   1. Applying clustering for segmentation
   2. Interpreting the cohort analysis
   3. Selecting algorithms for comparative analysis
   4. Choosing the number of clusters
   5. ApplyingClusteringAlgorithms
       1. K-Means
       2. Agglomerative
       3. DBSCAN
6. Evaluation
    1. Cohort Analysis
    2. Clustering using the RFM approach
        1. Quality ofs segmentation
        2. Cluster sizes
        3. Cluster boundaries
        4. Numberofclusters
7. Conclusions

## Exemplary data visualisations and outcomes (based on Shopify Store Data)
The underlying data for the analysis was collected from a Shopify store with about 5.000 customers, 12.000 orders, and a total of 30.000 sold items.

### K-Means applied on aggregated customer data with the dimensions Recency, Frequency and Monetary Value
![alt text](https://github.com/zinyosrim/customer-clustering-thesis/raw/master/Kmeans_transformed.png "Aggregated customer data of a Shopify store was clustered using the K-Means algorithm")

### The Cohort Analysis applied to Shopify data shows to which extent a store is doing well with regard to customer retention
![alt text](https://github.com/zinyosrim/customer-clustering-thesis/raw/master/Cohort_analysis.png "Cohort Analysis applied on aggregated customer data of a Shopify store")

*Stay tuned, more to come...*

repository: zinyosrim/customer-clustering-thesis

repo_name: zinyosrim/customer-clustering-thesis


text:
# Errors

A error package that allows you to wrap/unwrap, multi error and inspect error

## Issues

- [#54](https://github.com/dyweb/gommon/issues/54) init
-

## Implementation

- [doc/design](doc/design) contains some survey and design choices we made
- `Wrap` checks if this is already a `WrappedErr`, if not, it attach stack
- `MultiErr` keep a slice of errors, the thread safe version use mutex and returns copy of slice when `Errors` is called

## Survey

- Wrap error with context (stack, cause etc.)
  - [pkg/errors](doc/pkg-errors.md)
    - Wrap() add withStack only if no cause with stack present https://github.com/pkg/errors/pull/122/
  - [juju/errors](doc/juju-errors.md)
  - [hashicorp/errwrap](doc/hashicorp-errwrap.md)
  - [ ] https://godoc.org/github.com/gorilla/securecookie#Error
- Multi errors
  - [hashicorp/go-multierror](doc/hashicorp-go-multierror.md)
  - [uber/multierr](doc/uber-multierr.md)
    - Wish we could tell if the append happened  https://github.com/uber-go/multierr/issues/21
  - [ ] https://godoc.org/github.com/gorilla/securecookie#MultiError

repository: puresteelzhang/gommon

repo_name: puresteelzhang/gommon


text:
![](images/widgetPreview.jpeg)

# Dow Jones to Gold Ratio Widget
A widget for the iOS app 'Scriptable' that shows the Dow Jones to Gold ratio of the last 5 days

# Setup
- just copy the whole code of the file dowJonesGoldRatioWidget.js into a new script in your Scriptable app
- alternatively you can use the following link: https://scriptdu.de/?name=dowJonesGoldRatioWidget&source=https%3A%2F%2Fraw.githubusercontent.com%2Flwitzani%2FdowJonesGoldRatioWidget%2Fmain%2FdowJonesGoldRatioWidget.js%3Ftoken%3DAGKXXFWL36PZT4K3Y3YORNDARGXSQ&docs=https%3A%2F%2Fgithub.com%2Flwitzani%2FdowJonesGoldRatioWidget
- there is only one variable at the top of the script that matters: FILE_MANAGER_MODE
    - use FILE_MANAGER_MODE = 'LOCAL' if you do not use icloud
    - use FILE_MANAGER_MODE = 'ICLOUD' (or anything else) if you use icloud

- default is FILE_MANAGER_MODE = 'ICLOUD'

# Technical Background
- the graph shown is a finished image that is just loaded from the web
- the image is not loaded every time the script runs but only once a day
- the script saves the image and a json file to the phone or to iCloud
- the json file contains the last date the image was updated (to know when to update again)

repository: lwitzani/dowJonesGoldRatioWidget

repo_name: lwitzani/dowJonesGoldRatioWidget


text:
# Import the Certificate as a Trusted Certificate

Suppose that you are Ruth and have received from Stan Smith

- The signed JAR file `sContract.jar` containing a contract
- The file `StanSmith.cer` containing the public key certificate for the public key corresponding to the private key used to sign the JAR file

Before you can use the `jarsigner` tool to check the authenticity of the JAR file's signature, you need to import Stan's certificate into your keystore.

Even though you (acting as Stan) created these files and they haven't actually been transported anywhere, you can simulate being someone other than the creater and sender, Stan. Acting as Ruth, type the following command to create a keystore named `exampleruthstore` and import the certificate into an entry with an alias of `stan`.

```

**keytool -import -alias stan -file StanSmith.cer -keystore exampleruthstore**

```

Since the keystore doesn't yet exist, `keytool` will create it for you. It will prompt you for a keystore password.

The `keytool` prints the certificate information and asks you to verify it; For example, by comparing the displayed certificate fingerprints with those obtained from another (trusted) source of information. (Each fingerprint is a relatively short number that uniquely and reliably identifies the certificate.) For example, in the real world you can phone Stan and ask him what the fingerprints should be. He can get the fingerprints of the `StanSmith.cer` file he created by executing the command

```

**keytool -printcert -file StanSmith.cer**

```

If the fingerprints he sees are the same as the ones reported to you by `keytool`, then you both can assume that the certificate has not been modified in transit. You can safely let `keytool` procede to place a "trusted certificate" entry into your keystore. This entry contains the public key certificate data from the file `StanSmith.cer`. `keytool` assigns the alias `stan` to this new entry.

url: https://raw.githubusercontent.com/li-jiabao/li-jiabao.github.io/f42a68eeeb57e54b6b628030379255d9ac00b131/_drafts/BigJava/Security Features in Java SE/Steps for the Contract Receiver.md

filename: Steps for the Contract Receiver.md


text:
Title: Upload Image Help
Skeleton: /dcw/MarkdownViewer
AuthTags: Admin,Editor

Guidance on the size of the photo desired will be provided.  This is for the largest of the photos, sometimes smaller versions of the photo are also required.  These smaller variations will be generated automatically after you upload the file.

Select the file your wish to upload (may say "Choose File" or similar).  Click `Upload` and wait for the progress bar to complete - once progress is complete you'll be returned to the gallery.

repository: Gadreel/dcraft

repo_name: Gadreel/dcraft


text:
## How To Use The IBM Cloud Container Registry With Horizon

**Note:** not all of this functionality is in wiotp prod yet, so you can only do this in our bluehorizon hybrid environment at the moment. See [these instructions](https://docs.google.com/document/d/1_dIH79AKo_ngzbW9teE_x0sRfc8wpfikBqHugQQjKME/edit#heading=h.e9qakpsaxtok) for setting that up.

### Install and Use the IBM Cloud CLI Tool on x86 (Including Mac)
Begin by installing the IBM Cloud CLI (this must be done on an x86 host).  Instructions are available at the link below for Linux, MacOS, and Windows hosts: [https://console.bluemix.net/docs/cli/reference/bluemix_cli/get_started.html](https://console.bluemix.net/docs/cli/reference/bluemix_cli/get_started.html).

Homebrew for MacOS shortcut:
   `brew install homebrew/cask/ibm-cloud-cli`

### Login To IBM Cloud
Use the IBM Cloud CLI bx command login:

   `bx login`

Note that IBM employees should instead login with:

   `bx login -sso`

### Configure Organization
Once you have successfully logged-in to BlueMix, tell the IBM Cloud CLI which of your organization ID and space names you wish to use:

   `bx target -o <org ID> -s <space ID>`

For example:

   `bx target -o<EMAIL_ADDRESS>-s wiotp`

Or for our department's shared space (associated with Mike's master account):

   `bx target -o Hovitos -s dev`

If you don’t know your org ID and space name, use a web browser to login to the IBM cloud with the link below, and find your org ID and space at the top of that page:
	[https://console.bluemix.net/](https://console.bluemix.net/)

If it is your first time logging in to the IBM Cloud, you will need to create a new org and space.

### Install Container Registry Plugin
You will then need to add the BlueMix container registry plugin onto the IBM Cloud CLI, as follows:

   `bx plugin install container-registry -r Bluemix`

### Create Your Private Namespace
Use this container registry plugin to create a private namespace in the container registry under your account:

   `bx cr namespace-add <your namespace name>`

For example:

   `bx cr namespace-add glendarling`

Then finally, login to that Docker registry namespace by using the command:

   `bx cr login`

For more sub-commands, see the [bx cr CLI documentation](https://console.bluemix.net/docs/services/Registry/registry_cli.html) or run:

   `bx cr --help`

At this point you will be logged in to your private namespace in the IBM Cloud container registry and will be able to use registry paths like the one below in docker commands:

   `registry.ng.bluemix.net/<namespace>/<arch/image>:<version>`

### Create a Read/Write Token For Publishing Services
To push a docker image to the IBM Cloud container registry (including having `hzn exchange service publish` do it for you)  you must create a read/write token for yourself. With that you can use `docker login` (instead of `bx cr login`) and then use all of the normal `docker` and `hzn` commands.

To create the read/write token:

   `bx cr token-add --description '...' --non-expiring --readwrite`

The output should contain a line that begins with “Token”, then whitespace, then a long string of characters.  That long string is your token.  You can ignore everything else in that output.  To use this token with docker login, use a user name of “token” (literally those 5 characters) and then pass the token created above as the password:

   `docker login -u token -p 'WJh3NDJ2…' registry.ng.bluemix.net`

Alternatively, you can [create an API key](https://console.bluemix.net/docs/services/Registry/registry_tokens.html#registry_access) and use that in the `docker login` command.

### Create Read-Only Token For Horizon Users
To enable Horizon edge nodes to pull your service container images, you need to create a read-only token that Horizon can use on your edge nodes to access to your private namespace in the IBM Cloud Container Registry.  The bx command below will create such a token:

   `bx cr token-add --description '...' --non-expiring`

The output should contain a line that begins with “Token”, then whitespace, then a long string of characters.  That long string is your token.  You'll use this token in the next section.

### Build And Publish Your Images (On Any Machine)
Build your docker images as you normally would, and name them in this form:

   `registry.ng.bluemix.net/<your-namespace>/<arch>/<name>:<tag>`

When you are ready to publish your service to horizon, use the hzn command like this:

   `hzn exchange service publish -k <private-key-file> -K <public-key-file> -r "registry.ng.bluemix.net:<readonly-token>" -f service.definition.json`

That command will do several things:
Push the docker images to your ibm cloud container registry, and get the digest of the image in the process
Sign the digest and the deployment information with the private key/cert
Put the service metadata (including the signature) into the exchange
Put the key/cert into the exchange under the service definition so horizon edge nodes can automatically retrieve it to verify signatures when needed
Put your IBM Cloud container registry read-only token into the exchange under the service definition so horizon edge nodes can automatically retrieve it when needed

**Note:** this publish command is only available for services, not microservices or workloads.

### Using Your Service on Horizon Edge Nodes
The only thing special you or anyone else needs to do to use this service in a pattern on an edge node is to verify that /etc/horizon/anax.json contains these values and then restart anax:

```
"TrustCertUpdatesFromOrg": true,
"TrustDockerAuthFromOrg": true,
"ServiceUpgradeCheckIntervalS": 300
```

(This is a temporary thing until the horizon-wiotp deb package sets these.)

After that create a pattern for your gw type that includes your service, and register your edge node with it. The edge node Horizon agent will automatically get the readonly token for this service from the exchange, and do the equivalent of docker login so it can access the service images.

If for debug you want to manually log your edge node into the container registry, run:

   `docker login -u token -p <token> registry.ng.bluemix.net`

### Additional Commands and Further Reading
Once you have push your images to the IBM Cloud registry, you can list all your images with this command:

   `bx cr images`

The `image-rm` sub-command may be used to remove images from your namespace.

For more information, please see [using API keys and tokens with bx cr](https://console.bluemix.net/docs/services/Registry/registry_tokens.html#registry_access).

repository: dnguyenv/examples

repo_name: dnguyenv/examples


text:
# Vuetify Dashboard

Dashboard based on Vuetify (<https://vuetifyjs.com>)

![Vuetify Dashboard App CI](https://github.com/p2well/vuetify-dashboard/workflows/Vuetify%20Dashboard%20App%20CI/badge.svg)

gha_language: Vue


text:
# Typed Photoshop ExtendScript
TypeScript typings for Photoshop ExtendScript.

## Installation
```
yarn add -D https://github.com/fsjohnhuang/typed-photoshop.git
```
or
```
npm install --save-dev https://github.com/fsjohnhuang/typed-photoshop.git
```

## Include Declaration Files
Because this repository is not sub-project of DefinitelyTyped project yet, you have to include the declaration files manually in two ways.
1. Add a `types` reference.
```
/// <reference types="typed-photoshop"/>

app.load(File("/path/to/image.tif"))
alert(activeDocument.channels)
app.close()
```

2. Add `./node_modules/typed-photoshop` to `compilerOptions.typeRoot` property in tsconfig.json.
```
{
    "compilerOptions": {
        "typeRoot": ["./node_modules/@types", "./node_modules/typed-photoshop"]
    }
}
```
```
app.load(File("/path/to/image.tif"))
alert(activeDocument.channels)
app.close()
```

## Recommendation
### Polyfill
Since ExtendScript is based on ES3, there is no built-in `Array.prototype.map` method and other modern JavaScript APIs for you. `core-js` is a powerful and widely used polyfill library, but it's a sad story that errors occur while it's running on ExtendScript engine. Fortunately, `es5-shim` does work fine.

Meanwhile `json2` helps us to fit the pain from the lack of native JSON support.

#### Installation
```
yarn add es5-shim json2
```
or
```
npm install es5-shim json2 --save
```
#### Usage
```
import 'es5-shim'
import 'json2'
// import polyfill library in main.ts file.
```

#### Object Notes
Because it's impossible to emulate property descriptors in ES3 engine, the following functions are just mocks and you should avoid to use them if possible, only shim thirdparty library.
`defineProperty` and `defineProperties`
Supports only *Data Descriptor*. *Writable*, *Enumerable* and *Configurable* properties of descriptor are ignored. If you try to define `set` or `get` property, there is an error thrown.
`getOwnPropertyDescriptor`
Supports only *Data Descriptor*. *Configurable* property of descriptor is always *TRUE*. *Writable* and *Enumerable* will be always *TRUE* on user defined objects, but may vary on built-ins.
`freeze`, `preventExtensions` and `seal`
Only validate input parameter and return the input if it is an object.
`isExtensible`, `isFrozen` and `isSealed`
If the input parameter is an object, returns *TRUE*, *FALSE* and *FALSE* respectively.

The following functions could be used in our code.
`getOwnPropertyNames`
The function uses reflection interface which are provided by ExtendScript. It gets the own properties of an object no matter enumerable or not. But there is no guarantee to the order of enumeration is the same as in the _for in loop_ statement.
`keys`
Used in the _for in loop_ statement along with `getOwnProperty` function to get own enumerable properties of an object.
`getPrototypeOf`
Return the built-in `__proto__` property of an object.

### tsconfig.json
1. Set `compilerOptions/target` to `ES3` to avoiding errors caused by `Object.defineProperty` running in ExtendScript engine;
2. Because the default setting of `compilerOptions/lib` includes `DOM` whose `File` definition is different from that in ExtendScript totally, set `compilerOptions/lib` to `["ES3"]` or `["ES5"]` please.

repository: gxfan/typed-photoshop

repo_name: gxfan/typed-photoshop


text:
# From CSS Color

A package that creates Flutter Color instances from CSS color strings according to [CSS Color Module Level 3](https://drafts.csswg.org/css-color-3).
Hex, RGB(A), HSL(A) and X11 keywords are supported.

Backwards conversion from Color to CSS color string is also available with `toCssColor()` extention method.

## Usage

To use this plugin, add `from_css_color` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).

## Example

Import the library.

```dart
import 'package:from_css_color/from_css_color.dart';
```

Use it anywhere you want to create a Color from CSS color definition format:

```dart
Container(
  color: fromCssColor('#ff00aa'),
  // ...
)

Container(
  color: fromCssColor('rgb(100, 5, 32)'),
  // ...
)
```

Convert Color back to CSS string:

```dart
final color = const Color(0xFFFBAFBA);

color.toCssString(); // '#fbafba'
```

Check CSS color string correctness:

```dart
isCssColor('#ff00aa'); // true
```

Visit examples for more details.

gha_language: Dart


text:
Remote debugging for Horizon with [Redux DevTools extension](https://github.com/zalmoxisus/redux-devtools-extension) and [remotedev](https://github.com/zalmoxisus/remotedev).

![Demo](https://cloud.githubusercontent.com/assets/7957859/18026426/9a1ae9d2-6c4e-11e6-8d52-8d3a3f981fa6.gif)

## Installation

#### 1. Get the extension
##### 1.1 For Chrome
 - from [Chrome Web Store](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd)
 - or build it with `npm i & npm run build:extension` and [load the extension's folder](https://developer.chrome.com/extensions/getstarted#unpacked) `./build/extension`
 - or run it in dev mode with `npm i & npm start` and [load the extension's folder](https://developer.chrome.com/extensions/getstarted#unpacked) `./dev`.

##### 1.2 For Firefox
 - from [AMO](https://addons.mozilla.org/en-US/firefox/addon/remotedev/)
 - or build it with `npm i & npm run build:firefox` and [load the extension's folder](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox) `./build/firefox`.

##### 1.3 For Electron
  - just specify `REDUX_DEVTOOLS` in [`electron-devtools-installer`](https://github.com/GPMDP/electron-devtools-installer).

##### 1.4 For other browsers, for React Native, hybrid, desktop and server side apps
  - Use [remotedev.io](http://remotedev.io/local/) or if you have the extension select `Remote DevTools` from the context menu. Just specify `remote` parameter, and optionally `hostname` and `port`. [See the API](https://github.com/zalmoxisus/mobx-remotedev#remotedevstore-config) for details.

#### 2. Install the library

##### NPM

```
npm install --save horizon-remotedev
```

##### CDN

```
<script src="https://unpkg.com/horizon-remotedev/dist/horizon-remotedev.js"></script>
```

## Usage

```js
// import hzRemotedev from 'horizon-remotedev';
// or import hzRemotedev from 'horizon-remotedev/lib/dev'
// in case you want to use it in production or don't have process.env.NODE_ENV === 'development'

//Setup Horizon connection
const horizon = Horizon();

// ...

// Specify the horizon instance to monitor
hzRemotedev(horizon("react_messages"))
```

See [chat example](https://github.com/zalmoxisus/horizon-remotedev/blob/master/examples/chat-app/dist/app.jsx).

## API
#### `remotedev(store, [config])`
  - arguments
    - **store** *object* - horizon instance.  Example: `horizon("react_messages")`.
    - **config** *object* (optional as the parameters bellow)
      - **name** *string* - the instance name to be showed on the monitor page. Default value is table title.
      - **remote** *boolean* - set it to `true` to have remote monitoring via the local or `remotedev.io` server.
      - **hostname** *string* - use to specify host for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server). If `port` is specified, default value is `localhost`.
      - **port** *number* - use to specify host's port for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server).

Also see [the extension API](https://github.com/zalmoxisus/redux-devtools-extension#documentation) and [my presentation at React Europe](https://youtu.be/YU8jQ2HtqH4).

## Exclude / include DevTools in production builds

By default use
```js
import remotedev from 'horizon-remotedev';
```

It will work only when `process.env.NODE_ENV === 'development'`, otherwise the code will be stripped.

In case you want to use it in production or cannot set `process.env.NODE_ENV`, use
```js
import remotedev from 'horizon-remotedev/lib/dev';
```
So, the code will not be stripped from production bundle and you can use the extension even in production. It wouldn't affect the performance for end-users who don't have the extension installed.

## LICENSE

[MIT](LICENSE)

## Created By

If you like this, follow [@mdiordiev](https://twitter.com/mdiordiev) on twitter.

repository: zalmoxisus/horizon-remotedev

gha_language: JavaScript

repo_name: zalmoxisus/horizon-remotedev


text:
# This exercise has been imported from w3resource on https://www.w3resource.com/python-exercises/class-exercises/python-class-exercise-11.php

# Please refer to the below for the exercise.

# Pleae refer to the solution in .py file. exercise01_class.py

# Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle.

repository: djangojeng-e/TIL

repo_name: djangojeng-e/TIL


text:
---
{
    "description": "Information on Kickstand UI's Font Design Tokens",
    "meta": [
        {
            "property": "og:title",
            "content": "Font Design Tokens - Kickstand UI"
        },
        {
            "property": "og:description",
            "content": "Information on Kickstand UI's Font Design Tokens"
        }
    ]
}
---

# Font Design Tokens

## Base Font Size

The will be the default base font size applied to the `body` element.

```scss
$font-size-base: 16px;
```

```css
:root {
    --ks-font-size-base: 16px;
}
```

:::tip NOTE
This actually controls a lot more that just the font size. Most of the sizing and spacing use [CSS rem units](https://www.sitepoint.com/understanding-and-using-rem-units-in-css) which are based off of the font size set on the `body` element, so increasing or decreasing this value will also cause those values to increase or decrease as well.
:::

### Usage

This really only should be used _once_ on the `body` element. Updating the token in SASS will automatically update the CSS variable.

```css
html,
body {
    font-size: var(--ks-font-size-base);
}
```

## Font Families

There are 3 default font types set up to start out with (`accent`, `base`, and `monospace`). This should usually be more than enough for a website or application. If you feel like you need more font families in your project than this, feel free to add them, but do so carefully. Having all of those fancy fonts on your site may look nice, but they come at a cost (both for performance and usability).

For performance reasons, the default values that have been set for these variables are system fonts. For further reading on this, check out Marcin Wichary's excellent [Smashing Magazine article](https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/).

| Type      | Description                                |
| --------- | ------------------------------------------ |
| Accent    | This is primarily used for things like headings or blockquotes. This should help those pieces of your design stand out from the rest of your content.                                                               |
| Base      | This is the default font for your site. If it is not text that should stand out more than other text, it should be using this font. This font should be simple and easy to read at both large and small font sizes. |
| Monospace (optional) | If you are creating a tutorial site that has code snippets or special call-out text, this font is an excellent way to help highlight those parts of your application. This is an _optional_ font and most sites will not need it.                                           |

```scss
$fonts: (
    accent: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, Noto Sans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
    base: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, Noto Sans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
    monospace: 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
);
```

```css
:root {
    --ks-font-accent: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
    --ks-font-base: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
    --ks-font-monospace: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
}
```

### Usage

#### SASS

There is a SASS mixin to add the appropriate rules and variables to your code.

```scss
// signature - font($font: base, $important: false)
// returns   - font-family: {selected font CSS variable} !important (if set to "true")
body {
    @include font(base);
}

// using the $important value - should rarely be used
h1 {
    @include font(accent, true);
}
```

#### CSS

```css
body {
    font-family: var(--ks-font-base);
}
```

## Font Sizes

The default font sizes are `xxs-xxl`. As mentioned before, they use `rem`'s for the unit of measure. This is to provide proper scaling when the user's browser default font size is increased or they zoom in and out or adjust their default font size.

```scss
$font-sizes: (
    xxs: 0.75rem, // 12px
    xs: 0.875rem, // 14px
    sm: 1rem,     // 16px
    md: 1.25rem,  // 30px
    lg: 1.5rem,   // 24px
    xl: 2rem,     // 32px
    xxl: 3rem     // 48px,
);
```

```css
:root {
    --ks-font-size-xxs: 0.75rem;
    --ks-font-size-xs: 0.875rem;
    --ks-font-size-sm: 1rem;
    --ks-font-size-md: 1.25rem;
    --ks-font-size-lg: 1.5rem;
    --ks-font-size-xl: 2rem;
    --ks-font-size-xxl: 3rem;
}
```

### Usage

#### SASS

```scss
// signature - font-size($size, $important: false)
// returns   - font-size: {selected font-size CSS variable} !important (if set to "true")

h1 {
    @include font-size(xxl);
}

// this will add the `!important` attribute to the rule
.text-xxs {
    @include font-size(xxs, true);
}
```

#### CSS

```css
p {
    font-size: var(--ks-font-size-sm);
}
```

repository: break-stuff/kickstand-ui-docs-beta

gha_language: Shell

repo_name: break-stuff/kickstand-ui-docs-beta


text:
# Chainlink External Initiator Connected to Conflux Network
How to connect trigger a Chainlink run from a Conflux Network transaction using an External Initiator (EI).

### Setting up the Chainlink Node
Start a Chainlink node: https://docs.chain.link/docs/running-a-chainlink-node

Sample `.env` file for Chainlink Node:
```
ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=3
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0x20fe562d797a42dcb3399062ae9546cd06f63280
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
DATABASE_TIMEOUT=0
DATABASE_URL=DATABASE_URL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE
ETH_DISABLED=true
FEATURE_EXTERNAL_INITIATORS=true
CHAINLINK_DEV=true
```

Command to start Chainlink node in docker container:
```
cd ~/.chainlink-ropsten && docker run -p 6688:6688 -v ~/.chainlink-ropsten:/chainlink -it --env-file=.env smartcontract/chainlink local n
```

### Setting up the External Initiator
External Initiators for Conflux: https://github.com/Conflux-Network-Global/external-initiator (use the `generalized-EI` branch)

Create a `.env` file in the `external-initiator` folder with the following contents:

```
EI_DATABASEURL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE
EI_CHAINLINKURL=http://localhost:6688
EI_IC_ACCESSKEY=<INSERT KEY>
EI_IC_SECRET=<INSERT KEY>
EI_CI_ACCESSKEY=<INSERT KEY>
EI_CI_SECRET=<INSERT KEY>
```

The 4 keys in the `external-initiator/.env` file are generated by the Chainlink node with the following process. [Link](https://docs.chain.link/docs/miscellaneous) to more Chainlink/Docker documentation.

1. Use `docker ps` and obtain the container ID for the Chainlink node. To access the command line within the container, use `docker exec -it <containerID> /bin/bash`.
1. Once inside the container, log in using `chainlink admin login` and the username/password from when the container is created.
1. To create the keys, `chainlink initiators create <NAME> <URL>`. Note that in this case the url is `http://<IP_ADDRESS>:8080/jobs` to access the locally run external-initiator using the docker container gateway. It will look something like this: `chainlink initiators create cfx http://<IP_ADDRESS>:8080/jobs
` (otherwise, they are on two different networks). The 4 keys are generated in the same order as listed above.

The external initiator can be started up using:

```
./external-initiator "{\"name\":\"cfx-testnet\",\"type\":\"conflux\",\"url\":\"http://testnet-jsonrpc.conflux-chain.org:12537\"}" --chainlinkurl "http://localhost:6688/"
```

### Connecting the EI to Conflux Network and the Chainlink Node
Job spec for Chainlink node to start the EI to connect to Conflux Network:
```
{
  "initiators": [
    {
      "type": "external",
      "params": {
        "name": "cfx",
        "body": {
          "endpoint": "cfx-testnet",
          "addresses": ["0x80b5f9f22141268d2a1ea50d65eb2838922e3179"]
        }
      }
    }
  ],
  "tasks": [
    {"type": "noop"}
  ]
}
```
The address is the same as the address for the deployed Conflux Network smart contract.

### Resources:
- Chainlink job specifications: https://docs.chain.link/docs/job-specifications
- Chainlink built-in adapters: https://docs.chain.link/docs/adapters
- Chainlink initiators: https://docs.chain.link/docs/initiators
- More advanced demo code: https://github.com/Conflux-Network-Global/demo-cfx-chainlink

repository: lifeisgooddev/webinar-code

repo_name: lifeisgooddev/webinar-code


text:
# Standalone-Android-Sdk-Manager

* If you have been using the Sdk Manager that is included with Android Studio, this should look and feel pretty familiar. :D

## Getting Started
---
   * Download and Install the latest [Release](https://github.com/GlassToeStudio/Standalone-Android-Sdk-Manager/releases)
   * Unzip the folder contents.
   * Run setup.exe

   *you may get a warning, because the cert used to sign is not widely known.*

   *If this is too risky for you, there is always the option to clone the repo, and build the exe on your own system :D*

---
## Prerequisites
---

__This Program requires the Android SDK Command Line Tools and the Java JDK__
### ★ Already have a valid Sdk installed and Java JDK?
* You are done :D

---

#### ★ Don't have a valid JDK installed?

 * __Go download [Java JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) and install it. (For Windows)__

    * After installation add Java to your `PATH`
    * More information about adding Java to `PATH` can be found [here](https://javatutorial.net/set-java-home-windows-10)

#### ★ Don't have a valid Sdk installed?

  * __Go download [Android Sdk Command Line Tools](https://developer.android.com/studio#downloads). (For windows)__

    * Create a root `Sdk` folder somewhere that is easy to find `C:\\` is a good place.
    * Extract the zip file to that root `Sdk` folder.
    * Folder structure should be `C:\\Sdk\tools` (if you chose `C:\\`)
    * Folder structure is important for this to work, since you will need to navigate to the root `Sdk` folder within the application, It will then look in `\tools\bin\` for the sdkmanager.bat file that is included with the command-line tools.

---

### Notes:
* I named the root folder `Sdk`, the name does not matter. Additionally, this folder can be inside any other folder. The important part is that you know which is the root.
* A common structure is `C:\\Android\Sdk\` or `C:\\Android-Sdk\` as the root folder name.
* It is preferable (but not necessary) that `C:\\Sdk\tools` has been added to your `PATH`.
* More info about adding to your `PATH` can be found [here](https://www.androidcentral.com/installing-android-sdk-windows-mac-and-linux-tutorial)

* If contributing, be sure to have `git` installed.
---

## Usage
---

* After installing, and upon the first run, you will need to navigate to your Sdk `root` folder.
* If you had previously used Android Studio to install the Sdk, the default location is:
  * `%LOCALAPPDATA%\Android\Sdk`
  * aka: `C:\\Users\UserName\AppData\Local\Android\Sdk`
* The program will automatically populate the Sdk field with this info, if it is not where your Sdk is installed, you will need to manually navigate to your Sdk location.
* You should only need to do this once, as the program will save the location.
* Now you can use the UI to manage your Sdk.
  * Install new packages and tools
  * Uninstall old packages
  * Update current packages
  * etc.

---
## Contributing
---
This project is open source and controlled under the [MIT License](LICENSE)

Want to contribute?

See the [Contributing](CONTRIBUTING.md) guidelines!

Please be sure to check the [Code of Conduct ](CODE_OF_CONDUCT.md) as well!

gha_language: C#


text:
{{{
  "title": "Deploying a Java Application",
  "date": "06-02-2015",
  "author": "Chris Sterling",
  "attachments": [],
  "related-products" : [],
  "contentIsHTML": false
}}}

### Audience

Application developers

### Overview

AppFog includes the [Cloud Foundry Java buildpack](https://github.com/cloudfoundry/java-buildpack) by default. This enables the deployment of Java applications using many JVM-based languages and frameworks. To learn more about the extent of this support, please read more details on the [Cloud Foundry Java buildpack README](https://github.com/cloudfoundry/java-buildpack).

This article is going to focus on deploying a Cloud Foundry sample application called [Spring Music](https://github.com/cloudfoundry-samples/spring-music). This application is based on [Spring Framework](http://spring.io/), a JVM-based application framework. [Gradle](https://gradle.org/) is used for building the deployment artifact, a WAR file.

### Build Deployment Artifact

To deploy the Spring Music application you must first download the code. One way to download the code is using [Git](https://git-scm.com/). There are many ways to install Git so please check for the appropriate client on the [Git downloads](https://git-scm.com/downloads) page. Once you have a Git client installed, you can clone the Spring Music repository with the following command:

```
$ cd [directory to clone Spring Music code into]
$ git clone https://github.com/cloudfoundry-samples/spring-music.git
```

Once the code is cloned into a local directory you can go into the spring-music directory and build the WAR file to be used as the deployment artifact into AppFog:

```
$ cd spring-music
$ ./gradlew assemble
```

This may take some time since it has to download many dependencies before executing the build steps. Once it has completed there should be a WAR file created:

```
$ ls -l build/libs/spring-music.war
```

### Deploy Java Application

Now that we have a deployment artifact we can push the application to AppFog using the [Cloud Foundry CLI](login-using-cf-cli.md). The Spring Music application includes a manifest.yml file that defines metadata to tell AppFog how to deploy the application. Here is the manifest.yml contents:

```
---
applications:
- name: spring-music
  memory: 512M
  instances: 1
  host: spring-music-${random-word}
  path: build/libs/spring-music.war
```

This manifest.yml file tells AppFog that:

* The `name` of the application is spring-music
* Each application instance needs 512 MB of `memory` reserved to run
* Launch a single instance
* The URL route should be `spring-music-` with a random word added to the end. This is a less known feature that attempts to give each push of a Spring Music application a unique route.
* The `path` to the deployment artifact

To deploy the Spring Music application run the following:

```
$ cf push
```

The output may end with console logs that look something like the following:

```
...
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
1 of 1 instances running

App started

OK

App spring-music was started using this command `JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -Xmx382293K -Xms382293K -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=64M -Xss995K -Daccess.logging.enabled=false -Dhttp.port=$PORT" $PWD/.java-buildpack/tomcat/bin/catalina.sh run`

Showing health and status for app spring-music in org DEMO / space Dev as demo_user...
OK

requested state: started
instances: 1/1
usage: 512M x 1 instances
urls: spring-music-inconstant-ivyberry.useast.appfog.ctl.io
last uploaded: Wed Jun 3 01:41:07 UTC 2015

     state     since                    cpu    memory           disk           details
#0   running   2015-06-02 06:42:43 PM   0.0%   467.8M of 512M   150.5M of 1G
```

Once the application has successfully started then you can go to the given URL route provided as the value for `urls` in the console log. The example URL route above is `spring-music-inconstant-ivyberry.useast.appfog.ctl.io`. Take this URL and go to a browser to see the running application.

<img src="../images/2015-06-03-spring-music-browser.png"/>

repository: pascualin/PublicKB

repo_name: pascualin/PublicKB


text:
# SoraTel

## What is this?

SORACOM Air SIM controller by telephone.

## Quick start

* Create [Twilio](https://www.twilio.com/) account.
  * get new phone number to control SORACOM SIMs.
  * Get Twilio auth token.
* Create [Heroku](https://www.heroku.com/) account.
* Press Deploy button and configure.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/tmtysk/soratel)

* Visit [Twilio dashboard](https://www.twilio.com/user/account/voice/phone-numbers) and set Request URL to `GET https://<yourappname>.herokuapp.com/twilio` on incoming voice call.
* Now, try to call to the number gotten on Twilio!

repository: tmtysk/soratel

repo_name: tmtysk/soratel


text:
# Setting up Third Party Apps FAQ

## Tower

Tower provides [instructions](https://www.git-tower.com/help/mac/integration/environment).

## GitHub Desktop

Should just work, no configuration needed

## Fork

Add this to your `~/.ssh/config` (the path should match the socket path from the setup flow).

```
Host *
	IdentityAgent /Users/$YOUR_USERNAME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh
```

## VS Code

Add this to your `~/.ssh/config` (the path should match the socket path from the setup flow).

```
Host *
	IdentityAgent /Users/$YOUR_USERNAME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh
```

## nushell

Add this to your `~/.ssh/config` (the path should match the socket path from the setup flow).

```
Host *
	IdentityAgent /Users/$YOUR_USERNAME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh
```

## Cyberduck

Add this to `~/Library/LaunchAgents/com.maxgoedjen.Secretive.SecretAgent.plist`

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>link-ssh-auth-sock</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/sh</string>
    <string>-c</string>
    <string>/bin/ln -sf $HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh $SSH_AUTH_SOCK</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>
```

Log out and log in again before launching Cyberduck.

 Then enable "Use local SSH agent in GitKraken Preferences (Located under Preferences -> SSH)

# The app I use isn't listed here!

If you know how to get it set up, please open a PR for this page and add it! Contributions are very welcome.
If you're not able to get it working, please file a [GitHub issue](https://github.com/maxgoedjen/secretive/issues/new) for it. No guarantees we'll be able to get it working, but chances are someone else in the community might be able to.

repository: maxgoedjen/secretive

gha_language: Swift

repo_name: maxgoedjen/secretive


text:
# <img src="resources/jmaqslogo.jpg" height="32" width="32"> Database Features

## Overview
JMAQS provides support for testing database applications.

## BaseTest
BaseDatabaseTest is an abstract test class you can extend.
Extending the class allows you to automatically use JMAQS's database testing capabilities.
```java
public class MyDatabaseTests extends BaseDatabaseTest
```

## Driver
The DatabaseDriver is an object that allows you to interact with database services.
This driver wraps common database interactions, making testing relatively easy.
The driver is also thread safe, which means you can run multiple database tests in parallel.
*Information, such as the OS version is pulled from the JMAQS configuration.

## DriverManager
Driver that manages the driver manager.

## Log
There is also logger (also thread safe) the can be used to add log message to your log.
```java
this.getLog().logMessage("I am testing with JMAQS");
```

## TestObject
The TestObject can be thought of as your test context, It holds all the JMAQS test execution related data.
This includes the database driver, logger, soft asserts, performance timers, plus more.

*Notes:*
* *Most of the test object objects are already accessible on the test level. For example **this.getLog()** and **this.getTestObject().getLog()** both access the same logger.*
* *You seldom use the test object directly. It is usually only used when you want to share your test JMAQS context with another piece of code*

## Utilities
Stores functions for Capturing screenshots, saving page sources, waiting with the database driver, and killing the driver.

## Config
Stores methods for interacting with the App.config

## EventFiringDriver
Wrap basic firing database interactions

## Providers
Manages the provider connections.

## ConnectionFactory
Gets a database connection based on configuration values

## Sample code
```java
import com.magenic.jmaqs.base.BaseGenericTest;
import com.magenic.jmaqs.database.entities.StatesEntity;
import com.magenic.jmaqs.utilities.helper.TestCategories;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;

public class DatabaseDriverUnitTest extends BaseGenericTest {
{
    @Test(groups = TestCategories.DATABASE)
      public void testQuery() {
        DatabaseDriver openConnection = ConnectionFactory.getOpenConnection();
        List results = openConnection.query("SELECT * FROM information_schema.tables");
        Assert.assertTrue(results.stream().anyMatch(n -> ((Object[]) n)[2].equals("States")));
      }
}
```

repository: Magenic/JMAQS

repo_name: Magenic/JMAQS