text:
---
title: Troubleshoot Clusters Using PingCAP Clinic
summary: Learn how to use the PingCAP Clinic Diagnostic Service to troubleshoot cluster problems remotely and perform a quick check of the cluster status on a TiDB cluster or DM cluster deployed using TiUP.
---

# Troubleshoot Clusters Using PingCAP Clinic

For TiDB clusters and DM clusters deployed using TiUP, you can use PingCAP Clinic Diagnostic Service (PingCAP Clinic) to troubleshoot cluster problems remotely and perform a quick check on cluster status locally using Diag client (Diag) and Clinic Server.

> **Note:**
>
> - This document **only** applies to clusters deployed using TiUP in an on-premises environment. For clusters deployed using TiDB Operator on Kubernetes, see [PingCAP Clinic for TiDB Operator environments](https://docs.pingcap.com/tidb-in-kubernetes/stable/clinic-user-guide).
>
> - PingCAP Clinic **does not support** collecting data from clusters deployed using TiDB Ansible.

## User scenarios

- [Troubleshoot cluster problems remotely](#troubleshoot-cluster-problems-remotely)

    - When your cluster has some problems, if you need to contact PingCAP technical support, you can perform the following operations to facilitate the remote troubleshooting: collect diagnostic data with Diag, upload the collected data to the Clinic Server, and provide the data access link to the technical support staff.
    - When your cluster has some problems, if you cannot analyze the problems immediately, you can use Diag to collect and save the data for later analysis.

- [Perform a quick check on the cluster status locally](#perform-a-quick-check-on-the-cluster-status-locally)

    Even if your cluster is running stably for now, it is necessary to periodically check the cluster to detect potential stability risks. You can identify potential health risks of a cluster using the local quick check feature provided by PingCAP Clinic. The local check only checks configuration. To check more items, such as metrics and logs, it is recommended to upload the diagnostic data to the Clinic Server and use the Health Report feature.

## Prerequisites

Before using PingCAP Clinic, you need to install Diag (a component to collect data provided by PingCAP Clinic) and prepare the environment to upload data.

1. Install Diag.

   - If you have installed TiUP on your control machine, run the following command to install Diag:

        ```bash
        tiup install diag
        ```

    - If you have installed Diag, you can use the following command to upgrade Diag to the latest version:

        ```bash
        tiup update diag
        ```

    > **Note:**
    >
    > - For clusters without an internet connection, you need to deploy Diag offline. For details, refer to [Deploy TiUP offline: Method 2](/production-deployment-using-tiup.md#deploy-tiup-offline).
    > - Diag is **only** provided in the TiDB Server offline mirror package of v5.4.0 or later.

2. Get and set an access token (token) to upload data.

    When uploading collected data through Diag, you need a token for user authentication. If you already set a token Diag, you can reuse the token and skip this step.

    To get a token, perform the following steps:

    - Log in to the Clinic Server.

        <SimpleTab groupId="clinicServer">

        [Clinic Server for international users](https://clinic.pingcap.com): Data is stored in AWS in US.

        [Clinic Server for users in the Chinese mainland](https://clinic.pingcap.com.cn): Data is stored in AWS in China (Beijing) regions.

        </SimpleTab>

    - Click the icon in the lower-right corner of the Cluster page, select **Get Access Token For Diag Tool**, and click **+** in the pop-up window. Make sure that you have copied and saved the token that is displayed.

        ![Get the Token](/media/clinic-get-token.png)

    > **Note:**
    >
    > - When accessing Clinic Server for the first time, before getting a token, you need to prepare the environment by referring to [Quick Start with PingCAP Clinic](/clinic/quick-start-with-clinic.md#prerequisites).
    > - For data security, TiDB only displays the token upon the token creation. If you have lost the token, delete the old token and create a new one.
    > - A token is only used for uploading data.

    - Then, set the token in Diag. For example:

        ```bash
        tiup diag config clinic.token ${token-value}
        ```

3. Set the `region` in Diag.

    `region` determines the encryption certificate used for packing data and the target service when uploading the data. For example:

    > **Note:**
    >
    > - Diag v0.9.0 and later versions support setting `region`.
    > - For versions earlier than Diag v0.9.0, data is uploaded to Clinic Server in the Chinese region by default. To set `region` in these versions, run the `tiup update diag` command to upgrade Diag to the latest version and then set `region` in Diag.

    <SimpleTab groupId="clinicServer">

    When using Clinic Server for international users, set `region` to `US` using the following command:

    ```bash
    tiup diag config clinic.region US
    ```

    When using Clinic Server for users in the Chinese mainland, set `region` to `CN` using the following command:

    ```bash
    tiup diag config clinic.region CN
    ```

    </SimpleTab>

4. (Optional) Enable log redaction.

    When TiDB provides detailed log information, it might print sensitive information (for example, user data) in the log. If you want to avoid leaking sensitive information in the local log and Clinic Server, you can enable log redaction in the TiDB side. For more information, see [log redaction](/log-redaction.md#log-redaction-in-tidb-side).

## Troubleshoot cluster problems remotely

You can use Diag to quickly collect diagnostic data from TiDB clusters and DM clusters, including monitoring data and configuration information.

### Step 1. Check the data to be collected

For a full list of data that can be collected by Diag, see [PingCAP Clinic Diagnostic Data](/clinic/clinic-data-instruction-for-tiup.md).

To improve the efficiency of the later diagnosis, you are recommended to collect full diagnostic data including monitoring data and configuration information. For details, see [Collect data from clusters](#step-2-collect-data).

### Step 2. Collect data

With Diag, you can collect data from the TiDB clusters and the DM clusters deployed using TiUP.

1. Run the data collection command of Diag.

    For example, to collect the diagnostic data from 4 hours ago to 2 hours ago based on the current time, run the following command:

    <SimpleTab>

    ```bash
    tiup diag collect ${cluster-name} -f="-4h" -t="-2h"
    ```

    ```bash
    tiup diag collectdm ${dm-cluster-name} -f="-4h" -t="-2h"
    ```

    </SimpleTab>

    Descriptions of the parameters for data collection:

    - `-f/--from`: specifies the start time of the data collection. If you do not specify this parameter, the default start time is 2 hours before the current time. To modify the time zone, use the `-f="12:30 +0800"` syntax. If you do not specify the time zone information in this parameter, such as `+0800`, the time zone is UTC by default.
    - `-t/--to`: specifies the end time of the data collection. If you do not specify this parameter, the default end time is the current moment. To modify the time zone, use the `-f="12:30 +0800"` syntax. If you do not specify the time zone information in this parameter, such as `+0800`, the time zone is UTC by default.

    Parameter usage tips:

    In addition to specifying the data collection time, you can use Diag to specify more parameters. To get all parameters, run the `tiup diag collect -h` or `tiup diag collectdm -h` command.

    > **Note:**
    >
    > - Diag does not collect system variables data (db_vars) by default. To collect this data, you need to additionally provide a username and password that can access the database. Note that the reading access to system variables should be enabled in this database.
    > - Diag does not collect performance data (`perf`) and debug data (`debug`) by default.
    > - To collect full diagnostic data including system variables, use the command `tiup diag collect <cluster-name> --include="system,monitor,log,config,db_vars,perf,debug"`.

    - `-l`: the bandwidth limit for transferring files, the unit is Kbit/s, and the default value is `100000` (the `-l` parameter of scp).
    - `-N/--node`: only collects data from a specified node. The format is `ip:port`.
    - `--include`: only collects specific types of data. The optional values are `system`, `monitor`, `log`, `config`, and `db_vars`. To include two or more types, you can use `,` as a separator between the types.
    - `--exclude`: does not collect specific types of data. The optional values are `system`, `monitor`, `log`, `config`, and `db_vars`. To exclude two or more types, you can use `,` as a separator between the types.

    After you run the command, Diag does not start collecting data immediately. Instead, Diag provides the estimated data size and the target data storage path in the output for you to confirm whether to continue. For example:

    ```bash
    Estimated size of data to collect:
    Host               Size       Target
    ----               ----       ------
    <IP_ADDRESS>:9090  43.57 MB   1775 metrics, compressed
    <IP_ADDRESS>        0 B        /tidb-deploy/tidb-4000/log/tidb_stderr.log
    ... ...
    <IP_ADDRESS>       325 B      /tidb-deploy/tikv-20160/conf/tikv.toml
    Total              2.01 GB    (inaccurate)
    These data will be stored in /home/user/diag-fNTnz5MGhr6
    Do you want to continue? [y/N]: (default=N)
    ```

2. Enter `Y` to confirm that you want to start collecting data.

    Collecting data takes a certain amount of time. The time varies according to the volume of data to be collected. For example, in a test environment, collecting 1 GB of data takes about 10 minutes.

    After the collection is complete, Diag provides the folder path where the collected data is located. For example:

    ```bash
    Collected data are stored in /home/user/diag-fNTnz5MGhr6
    ```

### Step 3. View data locally (optional)

The collected data is stored in separate subdirectories based on its data source. These subdirectories are named after machine names and port numbers. The storage locations of the configuration, logs, and other files of each node are the same as their relative storage paths in the real server of your TiDB cluster:

- Basic information of the system and hardware: in `insight.json`
- Contents in the system `/etc/security/limits.conf`: in `limits.conf`
- List of kernel parameters: in `sysctl.conf`
- Kernel logs: in `dmesg.log`
- Network connection during data collection: in `ss.txt`
- Configuration data: in the `config.json` directory of each node
- Meta-information for the cluster itself: in `meta.yaml` (this file is located at the top level of the directory that stores collected data)
- Monitoring data: in the `/monitor` file directory. The monitoring data is compressed by default and cannot be viewed directly. To directly view the JSON files with monitoring data, disable compression with the `--compress-metrics=false` parameter when collecting data.

### Step 4. Upload data

To provide cluster diagnostic data to PingCAP technical support staff, you need to upload the data to the Clinic Server first, and then send the obtained data access link to the staff. The Clinic Server is a cloud service that stores and shares diagnostic data securely.

Depending on the network connection of the cluster, you can choose one of the following methods to upload data:

- Methods 1: if the network where the cluster is located can access the internet, you can [directly upload data using the upload command](#method-1-upload-directly).
- Methods 2: if the network where the cluster is located cannot access the internet, you need to [pack the data and then upload it](#method-2-pack-and-upload-data).

> **Note:**
>
> If you did not set a token or `region` in Diag before uploading data, Diag reports the upload failure and reminds you to set a token or `region`. To set a token, see [the second step in Prerequisites](#prerequisites).

#### Method 1. Upload directly

If the network where the cluster is located can access the internet, you can directly upload the folder with collected data obtained in [Step 2: Collect data](#step-2-collect-data) using the following command:

{{< copyable "shell-regular" >}}

```bash
tiup diag upload
```

After the upload is completed, the `Download URL` is displayed in the output. You can open the link of `Download URL` to see the uploaded data or send the link to the PingCAP technical support staff you contacted before.

#### Method 2. Pack and upload data

If the network where your cluster is located cannot access the internet, you need to pack the data on your intranet and upload the data package to the Clinic Server using a device with internet access. The detailed operations are as follows:

1. Pack the collected data obtained in [Step 2. Collect data](#step-2-collect-data) by running the following command:

    ```bash
    tiup diag package ${filepath}
    ```

    During packaging, Diag encrypts and compresses the data at the same time. In the test environment, 800 MB of data was compressed to 57 MB. The following is an example output:

    ```bash
    Starting component `diag`: /root/.tiup/components/diag/v0.7.0/diag package diag-fNTnz5MGhr6
    packaged data set saved to /home/user/diag-fNTnz5MGhr6.diag
    ```

    After the packaging is complete, the data is packaged to the `.diag` format. The `.diag` file can only be decrypted and viewed after being uploaded to the Clinic Server. If you want to directly forward the collected data instead of uploading it to the Clinic Server, you can compress the data by your own method and forward it.

2. From a machine with internet access, upload the compressed data package:

    ```bash
    tiup diag upload ${filepath}
    ```

    The following is an example output:

    ```bash
    [root@Copy-of-VM-EE-CentOS76-v1 user]# tiup diag upload /home/user/diag-fNTnz5MGhr6
    Starting component `diag`: /root/.tiup/components/diag/v0.7.0/diag upload /home/user/diag-fNTnz5MGhr6
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>>>
    Completed!
    Download URL: "https://clinic.pingcap.com.cn/portal/#/orgs/4/clusters/XXXX"
    ```

3. After the upload is complete, you can open the link of `Download URL` to see the uploaded data or send the link to the PingCAP technical support staff you contacted before.

## Perform a quick check on the cluster status locally

You can have a quick check on the cluster status locally using Diag. Even if your cluster is running stably for now, it is necessary to periodically check the cluster to detect potential stability risks. You can identify potential health risks of a cluster using the local quick check feature provided by PingCAP Clinic. The local check only checks configuration. To check more items, such as metrics and logs, it is recommended to upload the diagnostic data to the Clinic Server and use the Health Report feature.

1. Collect configuration data:

    ```bash
    tiup diag collect ${cluster-name} --include="config"
    ```

    The data of configuration files are relatively small. After the collection, the collected data is stored in the current path by default. In the test environment, for a cluster with 18 nodes, the data size of configuration files is less than 10 KB.

2. Diagnose configuration data:

    ```bash
    tiup diag check ${subdir-in-output-data}
    ```

    `${subdir-in-output-data}` in the above command is the path that stores the collected data, and this path has the `meta.yaml` file.

3. View the diagnostic result:

    The diagnostic result is returned on the command line. For example:

    ```bash
    Starting component `diag`: /root/.tiup/components/diag/v0.7.0/diag check diag-fNTnz5MGhr6

    # Diagnostic result
    lili 2022-01-24T09:33:57+08:00

    ## 1. Cluster basic information
    - Cluster ID:<PHONE_NUMBER>292855808
    - Cluster Name: lili
    - Cluster Version: v5.3.0

    ## 2. Sampling information
    - Sample ID: fNTnz5MGhr6
    - Sampling Date: 2022-01-24T09:33:57+08:00
    - Sample Content:: [system monitor log config]

    ## 3. Diagnostic result, including potential configuration problems
    In this inspection, 22 rules were executed.

    The results of **1** rules were abnormal and needed to be further discussed with support team.

    The following is the details of the abnormalities.

    ### Diagnostic result summary
    The configuration rules are all derived from PingCAP’s OnCall Service.

    If the results of the configuration rules are found to be abnormal, they may cause the cluster to fail.

    There were **1** abnormal results.

    #### Path to save the diagnostic result file

    Rule Name: tidb-max-days
    - RuleID: 100
    - Variation: TidbConfig.log.file.max-days
    - For more information, please visit: https://s.tidb.io/msmo6awg
    - Check Result:
      TidbConfig_<IP_ADDRESS>:4000   TidbConfig.log.file.max-days:0   warning
      TidbConfig_<IP_ADDRESS>:4000   TidbConfig.log.file.max-days:0   warning
      TidbConfig_<IP_ADDRESS>:4000   TidbConfig.log.file.max-days:0   warning

    Result report and record are saved at diag-fNTnz5MGhr6/report-220125153215
    ```

    In the last section of the diagnostic result (under `#### Path to save the diagnostic result file` in the above example output), for each configuration potential risk found, Diag provides a corresponding knowledge base link with detailed configuration suggestions. In the example above, the relevant link is `https://s.tidb.io/msmo6awg`.

## FAQ

1. If the data upload fails, can I re-upload it?

    Yes. Data upload supports breakpoint upload. If the upload fails, you can upload it again directly.

2. After uploading data, I cannot open the returned data access link. What should I do?

    Log in to Clinic Server first. If you still cannot open the link after login success, check whether you have access to data. If not, contact the data owner for permission. After getting the permission, log in to Clinic Server and open the link again.

3. How long will the uploaded data be kept on the Clinic Server?

    The longest time is 180 days. You can delete the data you uploaded on the Clinic Server page at any time.

gha_language: Python


text:
# List of summer schools in machine learning + related fields

Please note that the summer schools are arrange in reverse chronological order of dates i.e. the last one to be held is listed first.

## 2019

Name|Location|Organiser|Dates|Deadline|Aid(Travel Grants etc)|Website
------|--|--|---|--|-|-
Deep\|Bayes Summer School|Moscow, Russia|Higher School Of Economics|Aug|Late March| Yes|http://deepbayes.ru/|
Deep Learning Indaba 2019|Kenyatta, Kenya|Deep Learning Indaba|Aug 25 - Aug 31|NA|NA|http://www.deeplearningindaba.com/indaba-2019.html
Deep Learning and Reinforcement Learning Summer School (DLRL 2019)|Edmonton, Canada|CIFAR, Alberta|July 24 - Aug 2|NA|NA|https://dlrlsummerschool.ca
Machine Leaning Summer School (MLSS London)|London, UK|Imperial and University College London|July 15 – July 26| Jan 31|Yes|https://sites.google.com/view/mlss-2019
Vision Understanding and Machine Intelligence (VISUM 2019)|Porto, Portugal|INESCTEC and Portucalense University Infante D. Henrique|July 4 - July 12|NA|NA|http://visum.inesctec.pt
Eastern European Machine Learning Summer School|Bucharest, Romania|Politehnica University of Bucharest| July 1 - July 6|March 29|Yes|https://www.eeml.eu
AI and Games Summer School|New York, USA|Georgios N. Yannakakis and Julian Togelius|May 27 - May 31|NA|NA|http://school.gameaibook.org/
Machine Leaning Summer School (MLSS Stellenbosch)|Stellenbosch, South Africa|Imperial and University College London|Jan 7 - Jan 18| Nov 16|NA|https://mlssafrica.com/

## 2018

Name|Location|Organiser|Dates|Aid|Website|
------|--|--|---|-|---|
Summer School on Machine Learning and Data Science|Abuja, Nigeria|Data Science Africa|12 Nov - 16 Nov |NA|http://www.datascienceafrica.org/dsa2018abuja/
Deep Learning Indaba 2018|Stellenbosch, South Africa| Deep Learning Indaba|Sep 9 - Sep 14|Yes|http://www.deeplearningindaba.com/2018.html
Gaussian Process and Uncertainty Quantification Summer School (GPSS 2018)|Sheffield, UK|Sheffield University|Sep 3 - Sep 6| No|http://gpss.cc
Machine Learning Summer School (MLSS Madrid)|Madrid, Spain|Universidad Autónoma de Madrid|27 Aug - 7 Sep|Yes|http://mlss.ii.uam.es/mlss2018
Deep\|Bayes Summer School|Moscow, Russia|Higher School Of Economics|Aug 27 - Sep 1| Yes|http://deepbayes.ru/|
Summer School on Statistical Relational Artificial Intelligence (ACAI 2018)|Ferrara, Italy|European Association for Artificial Intelligence|Aug 27 - Aug 31|Yes|http://acai2018.unife.it/
Deep Learning and Reinforcement Learning Summer School (DLRL 2018)|Toronto, Canada|CIFAR, Vector Institute|July 25 - Aug 3| Yes|https://dlrlsummerschool.ca/home/|
International Summer School on Deep Learning (DeepLearn Genoa)|Genova, Italy|University of Genova| July 23 - July 27|No|http://grammars.grlmc.com/DeepLearn2018|
Transylvanian Machine Learning Summer School|Cluj-Napoca, Romania|Romanian Institute of Science and Technology| July 16 - July 22| Yes|https://tmlss.ro|
Vision Understanding and Machine Intelligence (VISUM 2018)|Porto, Portugal|INESCTEC and Portucalense University Infante D. Henrique|July 5 - July 13|NA|http://visum.inesctec.pt/visum-2018-6th-edition/
Summer Schools on Computer Vision And Machine Learning|Hyderabad, India|IIIT Hyderabad| July 2 - July 14| No|http://cvit.iiit.ac.in/summerschoolseries/
PRAIRIE AI Summer School|Grenoble, France|INRIA Grenoble| July 2 - July 6| Yes|https://project.inria.fr/paiss/|
Machine Learning Summer School (MLSS Buenos Aires)|Buenos Aires, Argentina|TO ADD| June 18 - June 30|Yes|http://mlss2018.net.ar|
Advanced Statistics and Data Mining Summer School|Madrid, Spain|Univ. Politécnica de Madrid| June 25 - July 3|No|http://dia.fi.upm.es/ASDM
Data Science Summer School (DS3)|Paris, France|École Polytechnique| June 25 – June 29| No|http://www.ds3-datascience-polytechnique.fr|
Lisbon Machine Learning School (LxMLS 2018)|Lisbon, Portugal|Instituto Superior Técnico| June 14 - June 21|Yes|http://lxmls.it.pt/2018/
Summer School on Machine Learning and Data Science|Nyeri, Kenya|Data Science Africa| May 31 - June 6|NA|http://www.datascienceafrica.org/dsa2018/
AI and Games Summer School|Crete (Chania), Greece|Georgios N. Yannakakis and Julian Togelius|May 28 - June 1|NA|NA|http://school.gameaibook.org/

## Recurring Schools

These are the summer schools which are held regularly :

- CIFAR's Deep Learning And Reinforcement Learning Summer School : https://dlrlsummerschool.ca
- Machine Learning Summer School (by Max Planck Institute, Tübingen) : http://mlss.cc/
- Lisbon Machine Learning Summer School : http://lxmls.it.pt
- Gaussian Process Summer Schools (by University Of Sheffield) : http://gpss.cc/
- Data Science Summer School (by École Polytechnique) : http://www.ds3-datascience-polytechnique.fr/
- Deep Learning Indaba Summer Schools : http://www.deeplearningindaba.com
- Summer Schools on Computer Vision And Machine Learning (byIIIT Hyderabad) : http://cvit.iiit.ac.in/summerschoolseries/
- Resource Aware Machine Learning Summer Schools (by TU Dortmund) : https://sfb876.tu-dortmund.de/GK/index.html
- Artificial Intelligence and Games Summer Schools : http://school.gameaibook.org/

# FAQs

### Reddit

- [Will Sheffield organize a Gaussian Processes Summer School in 2018?](https://www.reddit.com/r/MachineLearning/comments/7v8wxn/d_will_sheffield_organize_a_gaussian_processes/)
- [Videos of Deep|Bayes – Summer School on Bayesian Deep Learning](https://www.reddit.com/r/MachineLearning/comments/9dgnl3/r_videos_of_deepbayes_summer_school_on_bayesian/)
- [Best deep learning/ML summer schools of 2018](https://www.reddit.com/r/MachineLearning/comments/85s9i8/d_best_deep_learningml_summer_schools_of_2018/)
-

### Blogs

- [My first summer school](https://www.stratosphereips.org/blog/2018/8/1/1st-transylvanian-machine-learning-summer-school) (TMLSS 2018)
- [An Insider's Look Into The Summer School Training The World's Top AI Researchers](https://www.forbes.com/sites/williamfalcon/2018/09/03/an-insiders-look-into-the-summer-school-training-the-worlds-top-ai-researchers/#99a8e7ba05f1) (CIFAR DLRL Summer School 2018)
- [2018 Deep Learning And Reinforcement Learning Summer School](https://vectorinstitute.ai/2018/11/07/vector-institute-deep-learning-and-reinforcement-learning-2018-summer-school/) (CIFAR DLRL Summer School 2018)
- [Lisbon Machine Learning Summer School Highlights](http://blog.aylien.com/lisbon-machine-learning-summer-school-highlights/)(LxMLS 2018)
- [[Field report] Data Science Summer School at Ecole Polytechnique (with Bengio, Russell, Bousquet, Archambeau and others)](https://gmarti.gitlab.io/ml/2017/09/02/ds3-datascience-polytechnique.html)(DS3 2017)
- [6 things I learned in the deep learning summer school](http://www.marekrei.com/blog/26-things-i-learned-in-the-deep-learning-summer-school) (DL Summer School 2015)
- [Attending the Lisbon Machine Learning Summer School](http://mfcabrera.com/blog/2014/7/25/lxmls-2014blogorg.html) (LxMLS 2014)

license: MIT

repository: buaazb/awesome-mlss

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: buaazb/awesome-mlss


text:
# Loketh

An experimental smart contract implementation of event ticketing system, running on top of [Ethereum](https://ethereum.org/) blockchain.

## Disclaimer

Once again, this is just an experimental smart contract implementation of event ticketing system.

The author has no responsibility about security, transactions, or any usage of this app.

## Demo

You can watch the Loketh Demo [here on YouTube](https://youtu.be/4p6Vp1jkaGo).

## Installation

### Requirements

Loketh has a few system requirements, make sure your machine has:

- [Node.js >= v10](https://nodejs.org/)
- [Truffle](https://www.trufflesuite.com/truffle)
- [Ganache](https://www.trufflesuite.com/ganache) (Optional, for local development)

### Installing Loketh Smart Contract

*First*, you need to clone this repository into your machine.

```
git clone https://github.com/rymanalu/loketh.git
```

Make sure you are in the root directory of Loketh (e.g., `/path/to/loketh`) before continue to the next steps.

*Second*, if you want to deploy the smart contracts into real network (Mainnet or Testnets), you need to follow this steps. But if you are using Ganache, you can skip this one.

1. Create a new file named `.env` by copying from `.env.example`.

```
cp .env.example .env
```

2. Fill all the params in `.env` with the correct values.

```
// .env

NETWORK_ID=5
NETWORK_ENDPOINT=https://example.endpoint.com
WALLET_MNEMONIC="this is just an example of mnemonic do not use this okay"
WALLET_ADDRESS_INDEX=0
```

*Third*, install all smart contract dependencies.

```
npm install
```

*Fourth*, compile and deploy the smart contracts.

```
truffle migrate
```

You can specify the network you want to deploy by using `--network` option.

That's all. Now, let's continue to installing Loketh client.

### Installing Loketh Client

*First*, let's move to the `client` directory.

```
cd client
```

*Second*, create a new file named `.env` by copying from `.env.example`.

```
cp .env.example .env
```

*Third*, fill all the params in `.env` with the correct values.

```
// client/.env

PUBLIC_URL=/
REACT_APP_NETWORK_ID=5
```

*Fourth*, install all Loketh client dependencies.

```
npm install
```

*Fifth*, run the client.

```
npm start
```

Loketh client is a [React](https://reactjs.org/) app. You can run `npm run build` to builds the app for production.

## Running Tests

Loketh smart contract is well tested. Execute the command below to run the unit tests:

```
truffle test
```

## License

Loketh is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

repository: rymanalu/loketh

repo_name: rymanalu/loketh


text:
# # Key

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**digest** | **string** | URL safe base64 encoded key digest. Returned by the server on batch responses. May be provided by client. | [optional]
**keytype** | **string** | Enum describing the type of the userKey. This field is omitted in MessagePack responses. | [optional]
**namespace** | **string** |  |
**set_name** | **string** |  | [optional]
**user_key** | **object** | The user key, it may be a string, integer, or URL safe Base64 encoded bytes. | [optional]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

branch_name: refs/heads/main

gha_language: PHP


text:
## DYFStoreKit

A lightweight and easy-to-use iOS library for In-App Purchases. (Objective-C)

`DYFStoreKit` uses blocks and [notifications](#Notifications) to wrap `StoreKit`, provides [receipt verification](#Receipt-verification) and [transaction persistence](#Transaction-persistence). `DYFStoreKit` doesn't require any external dependencies.

[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE)
[![CocoaPods](http://img.shields.io/cocoapods/v/DYFStoreKit.svg?style=flat)](http://cocoapods.org/pods/DYFStoreKit)
![CocoaPods](http://img.shields.io/cocoapods/p/DYFStoreKit.svg?style=flat)

[Chinese Instructions (中文说明)](README-zh.md)

## Related Links

- [DYFRuntimeProvider](https://github.com/dgynfi/DYFRuntimeProvider/)
- [DYFKeychain](https://github.com/dgynfi/DYFKeychain/)
- [DYFStoreReceiptVerifier](https://github.com/dgynfi/DYFStoreReceiptVerifier/)
- [Unity-iOS-InAppPurchase](https://github.com/dgynfi/Unity-iOS-InAppPurchase/)
- [https://dgynfi.github.io/2016/10/16/in-app-purchase-complete-programming-guide-for-iOS/](https://dgynfi.github.io/2016/10/16/in-app-purchase-complete-programming-guide-for-iOS/)
- [https://dgynfi.github.io/2016/10/12/how-to-easily-complete-in-app-purchase-configuration-for-iOS/](https://dgynfi.github.io/2016/10/12/how-to-easily-complete-in-app-purchase-configuration-for-iOS/)

## Features

- Super simple in-app purchases.
- Built-in support for remembering your purchases.
- Built-in receipt validation (remote).
- Built-in hosted content downloads and notifications.

## Group (ID:614799921)

## Installation

Using [CocoaPods](https://cocoapods.org):

```
pod 'DYFStoreKit', '~> 1.2.0'
```

Or

```
pod 'DYFStoreKit'
```

Check out the [wiki](https://github.com/dgynfi/DYFStoreKit/wiki/Installation) for more options.

## Usage

Next I'll show you how to use `DYFStoreKit`.

### Initialization

The initialization is as follows.

- Whether to allow the logs output to the console, set 'true' in debug mode, view the logs of the whole process of in-app purchase, and set 'false' when publishing app in release mode.
- Adds the observer of transactions and monitors the change of transactions.
- Instantiates data persistent object and stores the related information of transactions.
- Follows the agreement `DYFStoreAppStorePaymentDelegate` and processes payments for products purchased from the App Store.

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Adds an observer that responds to updated transactions to the payment queue.
    // If an application quits when transactions are still being processed, those transactions are not lost. The next time the application launches, the payment queue will resume processing the transactions. Your application should always expect to be notified of completed transactions.
    // If more than one transaction observer is attached to the payment queue, no guarantees are made as to the order they will be called in. It is recommended that you use a single observer to process and finish the transaction.
    [DYFStore.defaultStore addPaymentTransactionObserver];

    // Sets the delegate processes the purchase which was initiated by user from the App Store.
    DYFStore.defaultStore.delegate = self;

    return YES;
}
```

You can process the purchase which was initiated by user from the App Store and provide your own implementation using the `DYFStoreAppStorePaymentDelegate` protocol:

```
// Processes the purchase which was initiated by user from the App Store.
- (void)didReceiveAppStorePurchaseRequest:(SKPaymentQueue *)queue payment:(SKPayment *)payment forProduct:(SKProduct *)product {

    if (![DYFStore canMakePayments]) {
        [self showTipsMessage:@"Your device is not able or allowed to make payments!"];
        return;
    }

    // Get account name from your own user system.
    NSString *accountName = @"Handsome Jon";

    // This algorithm is negotiated with server developer.
    NSString *userIdentifier = DYF_SHA256_HashValue(accountName);
    DYFStoreLog(@"userIdentifier: %@", userIdentifier);

    [DYFStore.defaultStore purchaseProduct:product.productIdentifier userIdentifier:userIdentifier];
}
```

### Request products

You need to check whether the device is not able or allowed to make payments before requesting products.

```
if (![DYFStore canMakePayments]) {
    [self showTipsMessage:@"Your device is not able or allowed to make payments!"];
    return;
}
```

To begin the purchase process, your app must know its product identifiers. There are two strategies for retrieving information about the products from the App Store.

**Strategy 1:** Your app can uses a product identifier to fetch information about product available for sale in the App Store and to submit payment request directly.

```
- (IBAction)fetchesProductAndSubmitsPayment:(id)sender {

    // You need to check whether the device is not able or allowed to make payments before requesting product.
    if (![DYFStore canMakePayments]) {
        [self showTipsMessage:@"Your device is not able or allowed to make payments!"];
        return;
    }

    [self<EMAIL_ADDRESS>
    NSString *productId = @"com.hncs.szj.coin48";
    [DYFStore.defaultStore requestProductWithIdentifier:productId success:^(NSArray *products, NSArray *invalidIdentifiers) {

        [self hideLoading];

        if (products.count == 1) {

            NSString *productId = ((SKProduct *)products[0]).productIdentifier;
            [self addPayment:productId];

        } else {

            [self showTipsMessage:@"There is no this product for sale!"];
        }

    } failure:^(NSError *error) {

        [self hideLoading];

        NSString *value = error.userInfo[NSLocalizedDescriptionKey];
        NSString *msg = value ?: error.localizedDescription;
        // This indicates that the product cannot be fetched, because an error was reported.
        [self sendNotice:[NSString stringWithFormat:@"An error occurs, %zi, %@", error.code, msg]];
    }];
}

- (void)addPayment:(NSString *)productId {

    // Get account name from your own user system.
    NSString *accountName = @"Handsome Jon";

    // This algorithm is negotiated with server developer.
    NSString *userIdentifier = DYF_SHA256_HashValue(accountName);
    DYFStoreLog(@"userIdentifier: %@", userIdentifier);

    [DYFStore.defaultStore purchaseProduct:productId userIdentifier:userIdentifier];
}
```

**Strategy 2:** It can retrieve information about the products from the App Store and present its store UI to the user. Every product sold in your app has a unique product identifier. Your app uses these product identifiers to fetch information about products available for sale in the App Store, such as pricing, and to submit payment requests when users purchase those products.

```
- (NSArray *)fetchProductIdentifiersFromServer {

    NSArray *productIds =<EMAIL_ADDRESS>  // 42 gold coins for ￥6.
                            @"com.hncs.szj.coin210",  // 210 gold coins for ￥30.
                            @"com.hncs.szj.coin686",  // 686 gold coins for ￥98.
                            @"com.hncs.szj.coin1386", // 1386 gold coins for ￥198.
                            @"com.hncs.szj.coin2086", // 2086 gold coins for ￥298.
                            @"com.hncs.szj.coin4886", // 4886 gold coins for ￥698.
                            @"com.hncs.szj.vip1",     // non-renewable vip subscription for a month.
                            @"com.hncs.szj.vip2"      // Auto-renewable vip subscription for three months.
    ];

    return productIds;
}

- (IBAction)fetchesProductsFromAppStore:(id)sender {

    // You need to check whether the device is not able or allowed to make payments before requesting products.
    if (![DYFStore canMakePayments]) {
        [self showTipsMessage:@"Your device is not able or allowed to make payments!"];
        return;
    }

    [self<EMAIL_ADDRESS>
    NSArray *productIds = [self fetchProductIdentifiersFromServer];
    [DYFStore.defaultStore requestProductWithIdentifiers:productIds success:^(NSArray *products, NSArray *invalidIdentifiers) {

        [self hideLoading];

        if (products.count > 0) {

            [self processData:products];

        } else if (products.count == 0 && invalidIdentifiers.count > 0) {

            // Please check the product information you set up.
            [self showTipsMessage:@"There are no products for sale!"];
        }

    } failure:^(NSError *error) {

        [self hideLoading];

        NSString *value = error.userInfo[NSLocalizedDescriptionKey];
        NSString *msg = value ?: error.localizedDescription;
        // This indicates that the products cannot be fetched, because an error was reported.
        [self sendNotice:[NSString stringWithFormat:@"An error occurs, %zi, %@", error.code, msg]];
    }];
}

- (void)processData:(NSArray *)products {

    NSMutableArray *modelArray = [NSMutableArray arrayWithCapacity:0];

    for (SKProduct *product in products) {

        DYFStoreProduct *p = [[DYFStoreProduct alloc] init];
        p.identifier = product.productIdentifier;
        p.name = product.localizedTitle;
        p.price = [product.price stringValue];
        p.localePrice = [DYFStore.defaultStore localizedPriceOfProduct:product];
        p.localizedDescription = product.localizedDescription;

        [modelArray addObject:p];
    }

    [self displayStoreUI:modelArray];
}

- (void)displayStoreUI:(NSMutableArray *)dataArray {

    DYFStoreViewController *storeVC = [[DYFStoreViewController alloc] init];
    storeVC.dataArray = dataArray;
    [self.navigationController pushViewController:storeVC animated:YES];
}
```

### Add payment

Requests payment of the product with the given product identifier.

```
[DYFStore.defaultStore<EMAIL_ADDRESS>```

If you need an opaque identifier for the user’s account on your system to add payment, you can use a one-way hash of the user’s account name to calculate the value for this property.

Calculates the SHA256 hash function:

```
CG_INLINE NSString *DYF_SHA256_HashValue(NSString *string) {

    const int digestLength = CC_SHA256_DIGEST_LENGTH; // 32
    unsigned char md[digestLength];

    const char *cStr = [string UTF8String];
    size_t cStrLen = strlen(cStr);

    // Confirm that the length of C string is small enough
    // to be recast when calling the hash function.
    if (cStrLen > UINT32_MAX) {
        NSLog(@"C string too long to hash: %@", string);
        return nil;
    }

    CC_SHA256(cStr, (CC_LONG)cStrLen, md);

    // Convert the array of bytes into a string showing its hex represention.
    NSMutableString *hash = [NSMutableString string];
    for (int i = 0; i < digestLength; i++) {

        // Add a dash every four bytes, for readability.
        if (i != 0 && i%4 == 0) {
            //[hash appendString:@"-"];
        }
        [hash appendFormat:@"%02x", md[i]];
    }

    return hash;
}
```

Requests payment of the product with the given product identifier, an opaque identifier for the user’s account on your system.

```
[DYFStore.defaultStore<EMAIL_ADDRESS>userIdentifier:@"A43512564ACBEF687924646CAFEFBDCAEDF4155125657"];
```

### Restore transactions

- Restores transactions without the user account identifier.

```
[DYFStore.defaultStore restoreTransactions];
```

- Restores transactions with the user account identifier.

```
[DYFStore.defaultStore restoreTransactions:@"A43512564ACBEF687924646CAFEFBDCAEDF4155125657"];
```

### Refresh receipt

If `Bundle.main.appStoreReceiptURL` is null, you need to create a refresh receipt request to obtain a receipt for a payment transaction.

```
[DYFStore.defaultStore refreshReceiptOnSuccess:^{
    [self storeReceipt];
} failure:^(NSError *error) {
    [self failToRefreshReceipt];
}];
```

### Notifications

`DYFStoreKit` sends notifications of `StoreKit` related events and extends `NSNotification` to provide relevant information. To receive them, add the observer to a `DYFStoreKit` manager.

#### Add the store observer

```
- (void)addStoreObserver {
    [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(processPurchaseNotification:) name:DYFStorePurchasedNotification object:nil];
    [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(processDownloadNotification:) name:DYFStoreDownloadedNotification object:nil];
}
```

#### Remove the store observer

When the application exits, you need to remove the store observer.

```
- (void)removeStoreObserver {
    [NSNotificationCenter.defaultCenter removeObserver:self name:DYFStorePurchasedNotification object:nil];
    [NSNotificationCenter.defaultCenter removeObserver:self name:DYFStoreDownloadedNotification object:nil];
}
```

#### Payment transaction notifications

Payment transaction notifications are sent after a payment has been requested or for each restored transaction.

```
- (void)processPurchaseNotification:(NSNotification *)notification {

    [self hideLoading];
    self.purchaseInfo = notification.object;

    switch (self.purchaseInfo.state) {
        case DYFStorePurchaseStatePurchasing:
            [self<EMAIL_ADDRESS>            break;
        case DYFStorePurchaseStateCancelled:
            [self sendNotice:@"You cancel the purchase"];
            break;
        case DYFStorePurchaseStateFailed:
            [self sendNotice:[NSString stringWithFormat:@"An error occurred, %zi", self.purchaseInfo.error.code]];
            break;
        case DYFStorePurchaseStateSucceeded:
        case DYFStorePurchaseStateRestored:
            [self completePayment];
            break;
        case DYFStorePurchaseStateRestoreFailed:
            [self sendNotice:[NSString stringWithFormat:@"An error occurred, %zi", self.purchaseInfo.error.code]];
            break;
        case DYFStorePurchaseStateDeferred:
            DYFStoreLog(@"Deferred");
            break;
        default:
            break;
    }
}
```

#### Download notifications

```
- (void)processDownloadNotification:(NSNotification *)notification {

    self.downloadInfo = notification.object;

    switch (self.downloadInfo.downloadState) {
        case DYFStoreDownloadStateStarted:
            DYFStoreLog(@"The download started");
            break;
        case DYFStoreDownloadStateInProgress:
            DYFStoreLog(@"The download progress: %.2f%%", self.downloadInfo.downloadProgress);
            break;
        case DYFStoreDownloadStateCancelled:
            DYFStoreLog(@"The download cancelled");
            break;
        case DYFStoreDownloadStateFailed:
            DYFStoreLog(@"The download failed");
            break;
        case DYFStoreDownloadStateSucceeded:
            DYFStoreLog(@"The download succeeded: 100%%");
            break;
        default:
            break;
    }
}
```

### Receipt verification

`DYFStoreKit` doesn't perform receipt verification by default, but provides reference implementations. You can implement your own custom verification or use the reference verifier provided by the library.

The reference verifier is outlined below. For more info, check out the [wiki](https://github.com/dgynfi/DYFStoreKit/wiki/Receipt-verification).

#### Reference verifier

You create and return a receipt verifier(`DYFStoreReceiptVerifier`) by using lazy loading.

```
- (DYFStoreReceiptVerifier *)receiptVerifier {
    if (!_receiptVerifier) {
        _receiptVerifier = [[DYFStoreReceiptVerifier alloc] init];
        _receiptVerifier.delegate = self;
    }
    return _receiptVerifier;
}
```

The receipt verifier delegates receipt verification, enabling you to provide your own implementation using the `DYFStoreReceiptVerifierDelegate` protocol:

```
- (void)verifyReceiptDidFinish:(nonnull DYFStoreReceiptVerifier *)verifier didReceiveData:(nullable NSDictionary *)data;

- (void)verifyReceipt:(nonnull DYFStoreReceiptVerifier *)verifier didFailWithError:(nonnull NSError *)error;
```

You can start verifying the in-app purchase receipt.

```
// Fetches the data of the bundle’s App Store receipt.
NSData *data = receiptData ?: [NSData dataWithContentsOfURL:DYFStore.receiptURL];
DYFStoreLog(@"data: %@", data);

[_receiptVerifier verifyReceipt:data];

// Only used for receipts that contain auto-renewable subscriptions.
//[_receiptVerifier verifyReceipt:data sharedSecret:@"A43512564ACBEF687924646CAFEFBDCAEDF4155125657"];
```

If security is a concern you might want to avoid using an open source verification logic, and provide your own custom verifier instead.

It is better to use your own server to obtain the parameters uploaded from the client to verify the receipt from the app store server (C -> Uploaded Parameters -> S -> App Store S -> S -> Receive And Parse Data -> C, C: client, S: server).

### Finish transactions

The transaction can be finished only after the client and server adopt secure communication and data encryption and the receipt verification is passed. In this way, we can avoid refreshing orders and cracking in-app purchase. If we were unable to complete the verification, we want `StoreKit` to keep reminding us that there are still outstanding transactions.

```
[DYFStore.defaultStore finishTransaction:transaction];
```

## Transaction persistence

`DYFStoreKit` provides an optional reference implementation for storing transactions in `NSUserDefaults`(`DYFStoreUserDefaultsPersistence`).

When the client crashes during the payment process, it is particularly important to store transaction information. When storekit notifies the uncompleted payment again, it takes the data directly from file and performs the receipt verification until the transaction is completed.

### Store transaction

```
- (void)storeReceipt {
    DYFStoreLog();

    NSURL *receiptURL = DYFStore.receiptURL;
    NSData *data = [NSData dataWithContentsOfURL:receiptURL];
    if (!data || data.length == 0) {
        [self refreshReceipt];
        return;
    }

    DYFStoreNotificationInfo *info = self.purchaseInfo;
    DYFStoreUserDefaultsPersistence *persister = [[DYFStoreUserDefaultsPersistence alloc] init];

    DYFStoreTransaction *transaction = [[DYFStoreTransaction alloc] init];

    if (info.state == DYFStorePurchaseStateSucceeded) {
        transaction.state = DYFStoreTransactionStatePurchased;
    } else if (info.state == DYFStorePurchaseStateRestored) {
        transaction.state = DYFStoreTransactionStateRestored;
    }

    transaction.productIdentifier = info.productIdentifier;
    transaction.userIdentifier = info.userIdentifier;
    transaction.transactionIdentifier = info.transactionIdentifier;
    transaction.transactionTimestamp = info.transactionDate.timestamp;
    transaction.originalTransactionTimestamp = info.originalTransactionDate.timestamp;
    transaction.originalTransactionIdentifier = info.originalTransactionIdentifier;

    transaction.transactionReceipt = data.base64EncodedString;
    [persister storeTransaction:transaction];

    [self verifyReceipt:data];
}
```

### Remove transaction

```
DYFStoreNotificationInfo *info = self.purchaseInfo;
DYFStore *store = DYFStore.defaultStore;
DYFStoreUserDefaultsPersistence *persister = [[DYFStoreUserDefaultsPersistence alloc] init];

if (info.state == DYFStorePurchaseStateRestored) {

    SKPaymentTransaction *transaction = [store extractRestoredTransaction:info.transactionIdentifier];
    [store finishTransaction:transaction];

} else {

    SKPaymentTransaction *transaction = [store extractPurchasedTransaction:info.transactionIdentifier];
    // The transaction can be finished only after the client and server adopt secure communication and data encryption and the receipt verification is passed. In this way, we can avoid refreshing orders and cracking in-app purchase. If we were unable to complete the verification, we want `StoreKit` to keep reminding us that there are still outstanding transactions.
    [store finishTransaction:transaction];
}

[persister removeTransaction:info.transactionIdentifier];
if (info.originalTransactionIdentifier) {
    [persister removeTransaction:info.originalTransactionIdentifier];
}
```

## Requirements

`DYFStoreKit` requires `iOS 7.0` or above and `ARC`.

## Demo

To learn more, please clone this project (`git clone https://github.com/dgynfi/DYFStoreKit.git`) to the local directory.

## Feedback is welcome

If you notice any issue, got stuck or just want to chat feel free to create an issue. I will be happy to help you.


text:
# pdx-docker
*Docker container for pypdx and pdxdisplay*

Here is a simple docker file container for my [pdxdisplay](https://github.com/sid5432/pdxdisplay)
program, used to view [PDX (Product Data eXchange)](https://en.wikipedia.org/wiki/PDX_(IPC-257X))
XML files.

The *pdxdisplay* program is built on top of my [pypdx](https://github.com/sid5432/pypdx) Python
module that parses a PDX XML file into a database; it is a Python [Flask](http://flask.pocoo.org/)
application that provides a simple interface (via a web browser) to upload and display a PDX
XML file.  For more details, please see the github pages for *pypdx* and *pdxdisplay*.

The *Dockerfile* presented here is for building a docker container that runs *pdxdisplay* with
a [PostgreSQL database](https://www.postgresql.org).  The build depends on the file "supervisord.conf".
To build your own docker container with these files (assuming you have docker installed on your
system), download the files, and run soemthing like

	docker build -t pdxcontainer:latest .

in the same directory as the files.  This should pull all the necssary parts (with *Ubuntu:latest*
as the base) and build a docker image called *pdxcontainer:latest*.  If you want a pre-built
container, you can pull this from [dockerhub](https://hub.docker.com/r/sidneyli/pdx/) with

	docker pull sidneyli/pdx:latest

The container runs two main parts: the PostgreSQL database and the *pdxdisplay* app. It exposes
two ports: port 5432 (for PostgreSQL), and port 5000 (for pdxdisplay).  Run the container as
follows:

	docker run -p 5000:5000 sidneyli/pdx:latest

This should start the two services (using the [supervisor](http://supervisord.org/)
process control system), after which you can
connect to the *pdxdisplay* app (in your web browser) with the URL

	http://localhost:5000/

If you are interested in accessing the PostgreSQL database directly, run the docker container
as

	docker run -p 5000:5000 -p 6432:5432 sidneyli/pdx:latest

to expose the PostgreSQL port (on port 6432 on the host computer).  On the local host computer
connect to the database with

	psql -h localhost -U pdxuser -p 6432 pdx

(the database is *pdx*; the username is *pdxuser*).  The password is *billofmaterials*.  For
details about the tables and schema, please visit the [github page on pypdx](https://github.com/sid5432/pypdx).

The *pdxdisplay* docker container is presented here as a convenience for those who want to
try it out without going through the hassle of setting things up (especially the part of
setting up a PostgreSQL database, although it is not really that complicated).  As it is
right now, the container is somwewhat bloated, and could use some trimming, but it does work.

Most recommendations on docker say **not** to run more than one service inside a container.
The container here does not follow that advice, mainly to make things simpler for the user.
If this violates your sense of decency, or if the bloat of the container bothers you, then
you really should set up your own PostgreSQL database (or use the simplier SQLite3 database),
then downloading the *pypdx* and *pdxdisplay* Python modules/programs and run them
directly (with Python, consider also the [virtual environment](https://docs.python.org/3/library/venv.html)
options). You'll be much happier.

(*Last Revised 2018-02-03*)


text:
# ![Sharp7](https://raw.githubusercontent.com/fbarresi/sharp7/master/doc/images/logo.jpg)

[![Build status](https://ci.appveyor.com/api/projects/status/2i77qfjjq8aep50b?svg=true)](https://ci.appveyor.com/project/fbarresi/sharp7)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4ff75e759a66416a84052769a71b70c6)](https://www.codacy.com/manual/fbarresi/Sharp7?utm_source=github.com&utm_medium=referral&utm_content=fbarresi/Sharp7&utm_campaign=Badge_Grade)
[![codecov](https://codecov.io/gh/fbarresi/Sharp7/branch/master/graph/badge.svg)](https://codecov.io/gh/fbarresi/Sharp7)
![Licence](https://img.shields.io/github/license/fbarresi/sharp7.svg)
[![Nuget Version](https://img.shields.io/nuget/v/Sharp7.svg)](https://www.nuget.org/packages/Sharp7/)

Nuget package for Sharp7 - The multi-platform Ethernet S7 PLC communication suite

Sharp7 is a C# port of [Snap7](http://snap7.sourceforge.net) library

For usage and documentation you can visit the [official page](http://snap7.sourceforge.net)
or read the [Wiki](https://github.com/fbarresi/Sharp7/wiki).

# How to install

## Package Manager
```
PM> Install-Package Sharp7
```

## .NET CLI
```
> dotnet add package Sharp7
```

## Do you need more power?

Try [Sharp7Reactive](https://github.com/evopro-ag/Sharp7Reactive)

gha_license_id: MIT


text:
# 2018-05-18
An exercise in base64 encoding a string multiple times.
```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Base64 string encoder
# Take text from the clipboard, convert n times, place base64 encoded text back on clipboard.
import sys, base64, pyperclip

textToEncode = pyperclip.paste()   # Take clipboard contents and put it into variable

if len(sys.argv)-1 != 1:
	print("Usage error: call script.py number   where number is number of times to encode")
	sys.exit()
elif len(textToEncode) < 1:
    print("Usage error")
    print("Place text on clipboard before calling program")
    print("Call script.py with one argument, number for number of times to encode")

timesToEncode = sys.argv[1]

def myB64encoder(aString):
    ''' Function to encode some text a number of times '''
    stringConverted = aString
    ConvertedStringToBytes = bytes(stringConverted, 'utf-8')
    # Example ConvertedStringToBytes will equal "b'YmxhaA=='" if input text is hello
    b64Text = base64.b64encode(ConvertedStringToBytes)
    return b64Text

# Setup for while loop
intermediateText = textToEncode

count=0

while count < int(timesToEncode):
    intermediateText = str(myB64encoder(intermediateText), 'utf-8')
    # need to convert byte output from myB64encoder back to a string
    count += 1

finalB64Encoded = intermediateText  # reassign for easier understanding what this text is.

print(textToEncode + " was encoded " + str(timesToEncode) + " times to:")
print(finalB64Encoded)
print("")
print("Output placed back on clipboard")
pyperclip.copy(finalB64Encoded)
'''
Test input:
The quick brown fox jumps over the lazy dog

Expected output, one time converted:
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
'''
```


text:
@typedef {function} can-component/connectedCallback connectedCallback
@parent can-component.lifecycle

@description A lifecycle hook called after the component's element is inserted into the document.

@signature `connectedCallback: function () { ... }`

Mainly used as the context to orchestrate property bindings that would
otherwise be a stream or an inappropriate side-effect during a getter.

For example, the following listens to changes on the `name` property
and counts them in the `nameChanged` property:

```js
const Person = DefineMap.extend( {
	nameChanged: "number",
	name: "string",
	connectedCallback() {
		this.listenTo( "name", function() {
			this.nameChanged++;
		} );
		const disconnectedCallback = this.stopListening.bind( this );
		return disconnectedCallback;
	}
} );
```

`connectedCallback` is named as such to match the [web components](https://developers.google.com/web/fundamentals/web-components/customelements#reactions) spec for the same concept.

  @return {Function|undefined} The `disconnectedCallback` function to be called during teardown. Defined in the same closure scope as setup, it's used to tear down anything that was set up during the `connectedCallback` lifecycle hook.

repository: jeroencornelissen/pushstate-test

repo_name: jeroencornelissen/pushstate-test


text:
![DoDo](https://github.com/atmb4u/dodo/blob/master/logo.png?raw=true)
DoDo - Task Management for Hackers
----------------------------------

Dodo is an easily maintainable task list for version controlled projects and hackers. We can call `dodo`  a ticket tracking inside the repo itself.
Tasks are called as *DoDo*, and __your goal is to make DoDo's extinct.__

###Getting Started

```python
pip install dodopie
```

###Initializing
```python
dodo init
```
    Options

    dodo init -f [dodo filename]

### List all Tasks
```python
dodo l
```

### Propose a new Task
```bash
dodo c -u atmb4u -d "dodo new version"
dodo add -u atmb4u -d "dodo new version"
dodo propose -u atmb4u -d "dodo new version"
```

### Accept a Tasks
```bash
dodo accept --id 2 -u atmb4u -d "dodo new version"
```

### Reject a proposed Tasks
```bash
dodo reject --id 2 -u atmb4u
```

### Work on a new Tasks
```bash
dodo workon --id 2 -u atmb4u
```

### Mark a task as Finished
```bash
dodo finish --id 1 -u atmb4u -d "dodo new version"
```

## Authors
atmb4u [at] gmail [dot] com


text:
# QuickJS-Pascal

## QuickJS FreePascal / Delphi Bindings sync with the latest version   [QuickJS](https://bellard.org/quickjs) Headers.

### I added a small demo in how to use it ```(it's a very easy engine to use)```.

* Change log
  - Upload Static libs for Mac, IOS, Linux and dynamic ones for Windows
  - sync with QJS Version "2020-03-16"
    - Contains all function and patches from
      - Version "2019-10-27", "2019-12-21", "2020-01-05", "2020-01-19"
    - Dlls not updated yet ( Compile your own for now till I do ^_^ )
  - sync with QJS Version "2019-09-18"
    - Dlls is update to QJS Version "2019-09-18"
  - Sync with QJS Version "2019-09-01"
    - DLLs not updated yet (will upload static libs for mac, linux and dynamic ones for windows ).
  - Add Delphi Support
  - Sync with QJS Version "2019-08-18"
  - Init FPC binding - QJS Version "2019-08-10"

- **TODO**
  - Add more demos
  - update the implementation with every new update :V

# With ❤ From Home.

gha_language: Pascal


text:
# @mattdesl/quick-stub

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

Some personalized scaffolding tools I am using to automate my workflow.

This is an experiment / proof of concept. One day it may grow into a generalized tool for scaffolding modules, apps, components, etc. Feel free to fork or post issues if you want to discuss.

## Usage

Install the module globally to access all the bins.

```sh
npm install @mattdesl/quick-stub -g
```

Now any of the scripts can be run from the command-line. Run them inside a module folder with a `package.json` file. Example:

```sh
# make a module
mkdir my-module
cd my-module
npm init

# add a test and install its dependencies
quick-test tests/index.js
```

The above installs `tape` and `faucet` and writes the following:

```js
var myModule = require('../')
var test = require('tape')

test('your package description', function(t) {

  t.end()
})
```

It also adds the following to your package.json:

```json
"scripts": {
  "test": "node test/index.js | faucet"
}
```

All scripts listed below. As you can see they are highly personalized to my workflow.

- [quick-test](#test)
- [quick-build](#build)
- [quick-bin](#bin)
- [quick-html](#html)
- [quick-budo](#budo)
- [quick-babelify](#babelify)
- [quick-component](#component)

### test

Installs `tape` and `faucet` as dependencies, stubs out a [test file](templates/test.js), and adds a `test` script to your package.json.

Usage:

```sh
quick-test [entry] [opt]
  [entry]    the file to write, default test.js
  -f         force overwrite (no prompt)
```

Examples:

```sh
quick-test
quick-test tests/index.js
```

### build

Installs `browserify` and `uglify-js`, then adds a `"bundle"` script to your package.json that looks like this:

```
"scripts": {
  "bundle": "browserify src/index.js | uglifyjs -cm > app/bundle.js"
}
```

Options:

```
quick-build [entry] [opt]
  [entry]         the entry to build, default src/index.js
  --outfile, -o   the outfile, default bundle.js
  --dir           the out directory, default app/
```

### bin

Adds a `bin` field to your package.json and stubs out a simple `bin/index.js` file with the following:

```
#!/usr/bin/env node

```

Options:

```
quick-bin [filename] [opt]
  [filename]      the file name, default index.js
  --minimist, -m  include minimist dependency + code
  --dir           the directory, default 'bin'
```

With `--minimist` the file includes [arg parsing](templates/bin-minimist.js).

### html

Stubs out a simple [HTML5 template](templates/index.html) at the given file, or defaults to `index.html`.

```sh
quick-html [entry]
  [entry]    the output file, default index.html
```

### budo

Add [budo](https://github.com/mattdesl/budo) to your package.json.

```sh
quick-budo
```

Result in package.json:

```
"start": "budo index.js:bundle.js --live"
```

You can specify `-b` or `--babel` for babelify, and `-a` or `--auto` for installify. Use `--no-dir` to avoid adding a directory to budo, or `--dir public/` for your own site directory. Use `--glslify` to add glslify transform.

```sh
# babelify + installify
quick-budo demo.js:bundle.js -b --no-dir
```

The above command installs budo and sets up the following:

```
"start": "budo demo.js:bundle.js --live -- -t babelify"
```

If babel is specified, the following `.babelrc` file is also written:

```js
{
  "presets": [
    [
      "babel-preset-env", {
        "useBuiltIns": "usage"
      }
    ]
  ]
}
```

Also see [babelify](#babelify) if you would rather have it listed as a package.json configuration (so you don't need to repeat the flag for `build` scripts).

### component

Create a folder with a script, css and template file.

```sh
quick-component ./src/components/my-comp
```

Options:

```
quick-component [path] [opts]
  [path]      the folder that will be created
  --css, -c   the name for the style file (default style.css)
  --script, -s   the name for the script file (default index.js)
  --template, -t   the name for the template file (default template.html)
```

## rc configuration

You can add a `.quick-stubrc` file in your `$HOME` directory to change the command that is run with `npm install`. For example, to [npm-install-analytics](https://github.com/mattdesl/npm-install-analytics):

```json
{
  "command": "npm-install-analytics"
}
```

Other configurations may be added at a later point.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/quick-stub/blob/master/LICENSE.md) for details.

repository: mattdesl/quick-stub

gha_language: JavaScript

repo_name: mattdesl/quick-stub


text:
### convex function

Go back to the [[AI Glossary]]

A function in which the region above the graph of the function is a convex set. The prototypical convex function is shaped something like the letter U. For example, the following are all convex functions:

![Graphical representations of convex functions](https://i.imgur.com/Z6QiYcV.png)

A typical convex function is shaped like the letter 'U'.

By contrast, the following function is not convex. Notice how the region above the graph is not a convex set:

![A graphical representation of a non-convex function](https://i.imgur.com/2PwYxag.png)

A strictly convex function has exactly one local minimum point, which is also the global minimum point. The classic U-shaped functions are strictly convex functions. However, some convex functions (for example, straight lines) are not U-shaped.

A lot of the common loss functions, including the following, are convex functions:

- L2 loss
- Log Loss
- L1 regularization
- L2 regularization

Many variations of gradient descent are guaranteed to find a point close to the minimum of a strictly convex function. Similarly, many variations of stochastic gradient descent have a high probability (though, not a guarantee) of finding a point close to the minimum of a strictly convex function.

The sum of two convex functions (for example, L2 loss + L1 regularization) is a convex function.

Deep models are never convex functions. Remarkably, algorithms designed for convex optimization tend to find reasonably good solutions on deep networks anyway, even though those solutions are not guaranteed to be a global minimum.

url: https://raw.githubusercontent.com/KGBicheno/KGB_Agora/70ea95c9d38ab2f31abbd510691bb4c050a6cb3b/Artificial Intelligence/Introduction to AI/Week 3 - Introduction/Definitions/Convex_Function.md


text:
grunt-angular
=============

Modular angular scaffolding for compartmentalizing your angular js application. It uses Grunt to build the directory structure on the fly.

Grunt tasks read from 'src' folder and generate angular specific 'dist' folder with controllers, directives, services etc.

Steps to set up
===============

1. Open Terminal.
2. Run 'git clone https://github.com/ankuronweb/grunt-angular' to clone the repo.
3. cd to grunt-angular folder.
4. Run 'npm install' to install node dependencies.
5. Run 'grunt'to produce minified, concatenated files inside dist.
OR
Run 'grunt dev' to produce debuggable code.

repository: ankuronweb/grunt-angular

repo_name: ankuronweb/grunt-angular


text:
# Mac OS X Dev Setup

This document describes how I set up my developer environment on a new MacBook or iMac. We will set up [Node](http://nodejs.org/) (JavaScript), [Python](http://www.python.org/), and [Ruby](http://www.ruby-lang.org/) environments, mainly for JavaScript and Python development. Even if you don't program in all three, it is good to have them as many command-line tools use one of them. As you read  and follow these steps, feel free to send me any feedback or comments you may have.

## System update

First thing you need to do, on any OS actually, is update the system! For that: **Apple Icon > Software Update...**

## Manually install xcode from app store

## Get the dotfiles and start setup

	$ curl -fsSL https://raw.github.com/aavnsh/laptop-setup/master/remote-setup.sh | sh 2>&1 | tee /tmp/laptop.log

## System preferences

If this is a new computer, there are a couple tweaks I like to make to the System Preferences. Feel free to follow these, or to ignore them, depending on your personal preferences.

Most preferences/installs are taken care of by my osx customization script.
You can check your old mac's preferences by looking at the defaults for e.g `defaults find trackpad` and some will be manually changed like below

## Installers

I use a combination of [homebrew](https://github.com/Homebrew/brew) (with [cask](https://caskroom.github.io/) and [mas](https://github.com/argon/mas)) for performing software installs.
An important dependency before Homebrew can work is **Xcode** which we manually installed previously.

### Usage

To install a package (or **Formula** in Homebrew vocabulary) simply type:

    $ brew install <formula>

To update Homebrew's directory of formulae, run:

    $ brew update

**Note**: I've seen that command fail sometimes because of a bug. If that ever happens, run the following (when you have Git installed):

    $ cd /usr/local
    $ git fetch origin
    $ git reset --hard origin/master

To see if any of your packages need to be updated:

    $ brew outdated

To update a package:

    $ brew upgrade <formula>

Homebrew keeps older versions of packages installed, in case you want to roll back. That rarely is necessary, so you can do some cleanup to get rid of those old versions:

    $ brew cleanup

To see what you have installed (with their version numbers):

    $ brew list --versions

## A better Terminal - [iTerm2](http://www.iterm2.com/)

Change some preferences from **iTerm > Preferences...**:

- Tab **General** section **Closing**
	- uncheck **Confirm closing multiple sessions**
	- **Confirm "Quit iTerm2 (Cmd+Q)" command**
- Tab **Profiles**
	- create a new one with the "+" icon, and rename it to your first name for example.
	- select **Other Actions... > Set as Default**.
	- Section **Window**, change the size to **Columns: 125** and **Rows: 35**.
	- Section **Miscellaneous** Check **If showing profile name...** option

### A Good Coding Font - Consolas

I really like the Consolas font for coding. Being a Microsoft (!) font, it is not installed by default. Since we're going to be looking at a lot of terminal output and code, let's install it now.

There are two ways we can install it. If you bought **Microsoft Office for Mac**, install that and Consolas will be installed as well.

If you don't have Office, follow these steps:

    $ brew install cabextract
    $ cd ~/Downloads
    $ mkdir consolas
    $ cd consolas
    $ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
    $ cabextract PowerPointViewer.exe
    $ cabextract ppviewer.cab
    $ open CONSOLA*.TTF

And click **Install Font**. Thanks to Alexander Zhuravlev for his [post](http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x).

### Making terminal more beautiful

In **iTerm > Preferences...**, under the tab **Profiles**, section **Text**, change both fonts to **Consolas 13pt**.

Download [Solarized](http://ethanschoonover.com/solarized) color scheme. Unzip the archive. In it you will find the `iterm2-colors-solarized` folder with 2 files.

- In **iTerm2 Preferences**, under **Profiles** and **Colors**, go to **Load Presets... > Import...**, find and open the two **.itermcolors** files we downloaded and

(Thanks to Mathias Bynens for his awesome [dotfiles](https://github.com/mathiasbynens/dotfiles).)

## A good editor - [Sublime Text](http://www.sublimetext.com/).

Just like the terminal, let's configure our editor a little. Go to **Sublime Text 2 > Preferences > Settings - User** and paste the following in the file that just opened:

```json
{
    "font_face": "Consolas",
    "font_size": 13,
    "rulers":
    [
        79
    ],
    "highlight_line": true,
    "bold_folder_labels": true,
    "highlight_modified_tabs": true,
    "tab_size": 2,
    "translate_tabs_to_spaces": true,
    "word_wrap": false,
    "indent_to_bracket": true
}
```

You can create a override for a specific language files e.g Python. Open the .py file and go to **Sublime Text 2 > Preferences > Settings - More > Syntax Specific - User** to paste in:

```json
{
    "tab_size": 4
}
```

Lets install the [Soda Theme](https://github.com/buymeasoda/soda-theme). To install it, run:

    $ cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
    $ git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"

Then go to **Sublime Text 2 > Preferences > Settings - User** and add the following two lines:

    "theme": "Soda Dark.sublime-theme",
    "soda_classic_tabs": true

Restart Sublime Text for all changes to take effect (Note: on the Mac, closing all windows doesn't close the application, you need to hit **Cmd+Q**).

To be consistent with my terminal, go to **Sublime Text 2 > Preferences > Color Scheme > Solarized (Dark)**.

Install syntax highlighting support for more languages:

    $ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
    $ git clone https://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
    $ git clone https://github.com/miksago/jade-tmbundle Jade
    $ git clone https://github.com/danro/LESS-sublime.git LESS
    $ git clone -b SublimeText2 https://github.com/kuroir/SCSS.tmbundle.git SCSS
    $ git clone https://github.com/nrw/sublime-text-handlebars Handlebars

Let's create a shortcut so we can launch Sublime Text from the command-line:

    $ cd ~
    $ mkdir bin
    $ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Now I can open a file with `$ subl myfile.py` or start a new project in the current directory with `$ subl .`.

### Extend Sublime's Functionality
- Install [Package Control](https://packagecontrol.io/installation)
- Open Package Control `Command+Shift+p`
	- Add [Pretty JSON](https://packagecontrol.io/packages/Pretty%20JSON) Package

## Python

OS X, like Linux, ships with [Python](http://python.org/) already installed. But you don't want to mess with the system Python (some system tools rely on it, etc.), so we'll install our own version with Homebrew. It will also allow us to get the very latest version of Python 2.7.

The following command will install Python 2.7 and any dependencies required (it can take a few minutes to build everything):

    $ brew install python

When finished, you should get a summary in the terminal. Running `$ which python` should output `/usr/local/bin/python`.

It also installed [Pip]() (and its dependency [Distribute]()), which is the package manager for Python. Let's upgrade them both:

    $ pip install --upgrade distribute
    $ pip install --upgrade pip

Executable scripts from Python packages you install will be put in `/usr/local/share/python`, so let's add it to the `$PATH`. To do so, we'll create a `.path` text file in the home directory (I've already set up `.bash_profile` to call this file):

    $ cd ~
    $ subl .path

And add these lines to `.path`:

```bash
PATH=/usr/local/share/python:$PATH
export PATH
```

Save the file and open a new terminal to take the new `$PATH` into account (everytime you open a terminal, `.bash_profile` gets loaded).

### Pip Usage

Here are a couple Pip commands to get you started. To install a Python package:

    $ pip install <package>

To upgrade a package:

    $ pip install --upgrade <package>

To see what's installed:

    $ pip freeze

To uninstall a package:

    $ pip uninstall <package>

## Virtualenv

[Virtualenv](http://www.virtualenv.org/) is a tool that creates an isolated Python environment for each of your projects. For a particular project, instead of installing required packages globally, it is best to install them in an isolated folder in the project (say a folder named `venv`), that will be managed by virtualenv.

The advantage is that different projects might require different versions of packages, and it would be hard to manage that if you install packages globally. It also allows you to keep your global `/usr/local/lib/python2.7/site-packages` folder clean, containing only critical or big packages that you always need (like IPython, Numpy).

### Install

To install virtualenv, simply run:

    $ pip install virtualenv

### Usage

Let's say you have a project in a directory called `myproject`. To set up virtualenv for that project:

    $ cd myproject/
    $ virtualenv venv --distribute

If you want your virtualenv to also inherit globally installed packages (like IPython or Numpy mentioned above), use:

    $ virtualenv venv --distribute --system-site-packages

These commands create a `venv` subdirectory in your project where everything is installed. You need to **activate** it first though (in every terminal where you are working on your project):

    $ source venv/bin/activate

You should see a `(venv)` appear at the beginning of your terminal prompt indicating that you are working inside the virtualenv. Now when you install something:

    $ pip install <package>

It will get installed in the `venv` folder, and not conflict with other projects.

**Important**: Remember to add `venv` to your project's `.gitignore` file so you don't include all of that in your source code!

As mentioned earlier, I like to install big packages (like Numpy), or packages I always use (like IPython) globally. All the rest I install in a virtualenv.

## IPython

[IPython](http://ipython.org/) is an awesome project which provides a much better Python shell than the one you get from running `$ python` in the command-line. It has many cool functions (running Unix commands from the Python shell, easy copy & paste, creating Matplotlib charts in-line, etc.) and I'll let you refer to the [documentation](http://ipython.org/ipython-doc/stable/index.html) to discover them.

### Install

Before we install IPython, we'll need to get some dependencies. Run the following:

    $ brew update # Always good to do
    $ brew install zeromq # Necessary for pyzmq
    $ brew install pyqt # Necessary for the qtconsole

It may take a few minutes to build these.

Once it's done, we can install IPython with all the available options:

    $ pip install ipython[zmq,qtconsole,notebook,test]

### Usage

You can launch IPython from the command line with `$ ipython`, but what's more interesting is to use its [QT Console](http://ipython.org/ipython-doc/stable/interactive/qtconsole.html). Launch the QT Console by running:

    $ ipython qtconsole

You can also customize the font it uses:

    $ ipython qtconsole --ConsoleWidget.font_family="Consolas" --ConsoleWidget.font_size=13

And since I'm lazy and I don't want to type or copy & paste that all the time, I'm going to create an alias for it. Create a `.extra` text file in your home directory with `$ subl ~/.extra` (I've set up `.bash_profile` to load `.extra`), and add the following line:

```bash
alias ipy='ipython qtconsole --ConsoleWidget.font_family="Consolas" --ConsoleWidget.font_size=13'
```

Open a fresh terminal. Now when you run `$ ipy`, it will launch the QT Console with your configured options.

To use the in-line Matplotlib functionality (nice for scientific computing), run `$ ipy --pylab=inline`.

## Numpy and Scipy

The [Numpy](http://numpy.scipy.org/) and [Scipy](http://www.scipy.org/SciPy) scientific libraries for Python are always a little tricky to install from source because they have all these dependencies they need to build correctly. Luckily for us, [Samuel John](http://www.samueljohn.de/) has put together some [Homebrew formulae](https://github.com/samueljohn/homebrew-python) to make it easier to install these Python libraries.

First, grab the special formulae (which are not part of Homebrew core):

    $ brew tap samueljohn/python
    $ brew tap homebrew/science

Then, install the `gfortran` dependency (now in `gcc`) which we will need to build the libraries:

    $ brew install gcc

Finally, you can install Numpy and Scipy with:

    $ brew install numpy
    $ brew install scipy

(It may take a few minutes to build.)

## MySQL

### Install

We will install [MySQL](http://www.mysql.com/) using Homebrew, which will also install some header files needed for MySQL bindings in different programming languages (MySQL-Python for one).

To install, run:

    $ brew update # Always good to do
    $ brew install mysql

As you can see in the ouput from Homebrew, before we can use MySQL we first need to set it up with:

    $ unset TMPDIR
    $ mkdir /usr/local/var
    $ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

### Usage

To start the MySQL server, use the `mysql.server` tool:

    $ mysql.server start

To stop it when you are done, run:

    $ mysql.server stop

You can see the different commands available for `mysql.server` with:

    $ mysql.server --help

To connect with the command-line client, run:

    $ mysql -uroot

(Use `exit` to quit the MySQL shell.)

**Note**: By default, the MySQL user `root` has no password. It doesn't really matter for a local development database. If you wish to change it though, you can use `$ mysqladmin -u root password 'new-password'`.

### MySQL Workbench

In terms of a GUI client for MySQL, I'm used to the official and free [MySQL Workbench](http://www.mysql.com/products/workbench/). But feel free to use whichever you prefer.

You can find the MySQL Workbench download [here](http://www.mysql.com/downloads/workbench/). (**Note**: It will ask you to sign in, you don't need to, just click on "No thanks, just start my download!" at the bottom.)

## Node.js & NVM

When installing Ruby, best practice is to use [NVM](https://github.com/creationix/nvm) (Node Version Manager)

    $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | NVM_DIR="$HOME/.nvm"  bash
    $ nvm install 6 # or the current LTS

We may need to tell npm where to find the Xcode Command Line Tools, by running:

    $ sudo xcode-select -switch /usr/bin

(If Xcode Command Line Tools were installed by Xcode, try instead:)

    $ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Node modules are installed locally in the `node_modules` folder of each project by default, but there are at least two that are worth installing globally. Those are [CoffeeScript](http://coffeescript.org/) and [Grunt](http://gruntjs.com/):

    $ npm install -g coffee-script
    $ npm install -g grunt-cli
    $ npm install -g gulp

### Npm usage

To install a package:

    $ npm install <package> # Install locally
    $ npm install -g <package> # Install globally

To install a package and save it in your project's `package.json` file:

    $ npm install <package> --save

To see what's installed:

    $ npm list # Local
    $ npm list -g # Global

To find outdated packages (locally or globally):

    $ npm outdated [-g]

To upgrade all or a particular package:

    $ npm update [<package>]

To uninstall a package:

    $ npm uninstall <package>

##JSHint

JSHint is a JavaScript developer's best friend.

If the extra credit assignment to install Sublime Package Manager was completed, JSHint can be run as part of Sublime Text.

Install JSHint via npm (global install preferred)

    $ npm install -g jshint

Follow additional instructions on the [JSHint Package Manager page](https://sublime.wbond.net/packages/JSHint) or [build it manually](https://github.com/jshint/jshint).

## Ruby and RVM

Like Python, [Ruby](http://www.ruby-lang.org/) is already installed on Unix systems. But we don't want to mess around with that installation. More importantly, we want to be able to use the latest version of Ruby.

### Install

When installing Ruby, best practice is to use [RVM](https://rvm.io/) (Ruby Version Manager) which allows you to manage multiple versions of Ruby on the same machine. Installing RVM, as well as the latest version of Ruby, is very easy. Just run:

    $ curl -L https://get.rvm.io | bash -s stable --ruby

When it is done, both RVM and a fresh version of Ruby 2.0 are installed. The following line was also automatically added to your `.bash_profile`:

```bash
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
```

I prefer to move that line to the `.extra` file, keeping my `.bash_profile` clean. I suggest you do the same.

After that, start a new terminal and run:

    $ type rvm | head -1

You should get the output `rvm is a function`.

### Usage

The following command will show you which versions of Ruby you have installed:

    $ rvm list

The one that was just installed, Ruby 2.0, should be set as default. When managing multiple versions, you switch between them with:

    $ rvm use system # Switch back to system install (1.8)
    $ rvm use 2.0.0 --default # Switch to 2.0.0 and sets it as default

Run the following to make sure the version you want is being used (in our case, the just-installed Ruby 1.9.3):

    $ which ruby
    $ ruby --version

You can install another version with:

    $ rvm install 1.9.3

To update RVM itself, use:

    $ rvm get stable

[RubyGems](http://rubygems.org/), the Ruby package manager, was also installed:

    $ which gem

Update to its latest version with:

    $ gem update --system

To install a "gem" (Ruby package), run:

    $ gem install <gemname>

To install without generating the documentation for each gem (faster):

    $ gem install <gemname> --no-document

To see what gems you have installed:

    $ gem list

To check if any installed gems are outdated:

    $ gem outdated

To update all gems or a particular gem:

    $ gem update [<gemname>]

RubyGems keeps old versions of gems, so feel free to do come cleaning after updating:

    $ gem cleanup

I mainly use Ruby for the CSS pre-processor [Compass](http://compass-style.org/), which is built on top of [Sass](http://sass-lang.com/):

    $ gem install compass --no-document

## LESS

CSS preprocessors are becoming quite popular, the most popular processors are [LESS](http://lesscss.org/) and [SASS](http://sass-lang.com). Preprocessing is a lot like compiling code for CSS. It allows you to reuse CSS in many different ways. Let's start out with using LESS as a basic preprocessor, it's used by a lot of popular CSS frameworks like [Bootstrap](http://getbootstrap.com/).

### Install

To install LESS you have to use NPM / Node, which you installed earlier using Homebrew. In the terminal use:

    $ npm install less --global

Note: the `--global` flag is optional but it prevents having to mess around with file paths. You can install without the flag, just know what you're doing.

You can check that it installed properly by using:

    $ lessc --version

This should output some information about the compiler:

    lessc 1.5.1 (LESS Compiler) [JavaScript]

Okay, LESS is installed and running. Great!

### Usage

There's a lot of different ways to use LESS. Generally I use it to compile my stylesheet locally. You can do that by using this command in the terminal:

    $ lessc template.less template.css

The two options are the "input" and "output" files for the compiler. The command looks in the current directory for the LESS stylesheet, compiles it, and outputs it to the second file in the same directory. You can add in paths to keep your project files organized:

    $ lessc less/template.less css/template.css

Read more about LESS on their page here: http://lesscss.org/

## Heroku

[Heroku](http://www.heroku.com/), if you're not already familiar with it, is a [Platform-as-a-Service](http://en.wikipedia.org/wiki/Platform_as_a_service) (PaaS) that makes it really easy to deploy your apps online. There are other similar solutions out there, but Heroku was among the first and is currently the most popular. Not only does it make a developer's life easier, but I find that having Heroku deployment in mind when building an app forces you to follow modern app development [best practices](http://www.12factor.net/).

### Install

Assuming that you have an account (sign up if you don't), let's install the [Heroku Client](https://devcenter.heroku.com/articles/using-the-cli) for the command-line. Heroku offers a Mac OS X installer, the [Heroku Toolbelt](https://toolbelt.heroku.com/), that includes the client. But for these kind of tools, I prefer using Homebrew. It allows us to keep better track of what we have installed. Luckily for us, Homebrew includes a `heroku-toolbelt` formula:

    $ brew install heroku-toolbelt

The formula might not have the latest version of the Heroku Client, which is updated pretty often. Let's update it now:

    $ heroku update

Don't be afraid to run `heroku update` every now and then to always have the most recent version.

### Usage

Login to your Heroku account using your email and password:

    $ heroku login

If this is a new account, and since you don't already have a public **SSH key** in your `~/.ssh` directory, it will offer to create one for you. Say yes! It will also upload the key to your Heroku account, which will allow you to deploy apps from this computer.

If it didn't offer create the SSH key for you (i.e. your Heroku account already has SSH keys associated with it), you can do so manually by running:

     $ mkdir ~/.ssh
     $ ssh-keygen -t rsa

Keep the default file name and skip the passphrase by just hitting Enter both times. Then, add the key to your Heroku account:

    $ heroku keys:add

Once the key business is done, you're ready to deploy apps! Heroku has a great [Getting Started](https://devcenter.heroku.com/articles/python) guide, so I'll let you refer to that (the one linked here is for Python, but there is one for every popular language). Heroku uses Git to push code for deployment, so make sure your app is under Git version control. A quick cheat sheet (if you've used Heroku before):

    $ cd myapp/
    $ heroku create myapp
    $ git push heroku master
    $ heroku ps
    $ heroku logs -t

The [Heroku Dev Center](https://devcenter.heroku.com/) is full of great resources, so be sure to check it out!

## MongoDB

[MongoDB](http://www.mongodb.org/) is a popular [NoSQL](http://en.wikipedia.org/wiki/NoSQL) database.

### Install

Installing it is very easy through Homebrew:

    $ brew update
    $ brew install mongo

### Usage

In a terminal, start the MongoDB server:

    $ mongod

In another terminal, connect to the database with the Mongo shell using:

    $ mongo

I'll let you refer to MongoDB's [Getting Started](http://docs.mongodb.org/manual/tutorial/getting-started/) guide for more!

## Redis

[Redis](http://redis.io/) is a blazing fast, in-memory, key-value store, that uses the disk for persistence. It's kind of like a NoSQL database, but there are a lot of [cool things](http://oldblog.antirez.com/post/take-advantage-of-redis-adding-it-to-your-stack.html) that you can do with it that would be hard or inefficient with other database solutions. For example, it's often used as session management or caching by web apps, but it has many other uses.

### Install

To install Redis, use Homebrew:

    $ brew update
    $ brew install redis

### Usage

Start a local Redis server using the default configuration settings with:

    $ redis-server

For advanced usage, you can tweak the configuration file at `/usr/local/etc/redis.conf` (I suggest making a backup first), and use those settings with:

    $ redis-server /usr/local/etc/redis.conf

In another terminal, connect to the server with the Redis command-line interface using:

    $ redis-cli

I'll let you refer to Redis' [documentation](http://redis.io/documentation) or other tutorials for more information.

## Elasticsearch

As it says on the box, [Elasticsearch](http://www.elasticsearch.org/) is a "powerful open source, distributed real-time search and analytics engine". It uses an HTTP REST API, making it really easy to work with from any programming language.

You can use elasticsearch for such cool things as real-time search results, autocomplete, recommendations, machine learning, and more.

### Install

Elasticsearch runs on Java, so check if you have it installed by running:

```bash
java -version
```

If Java isn't installed yet, a window will appear prompting you to install it. Go ahead and click "Install".

Next, install elasticsearch with:

```bash
$ brew install elasticsearch
```

**Note**: Elasticsearch also has a `plugin` program that gets moved to your `PATH`. I find that too generic of a name, so I rename it to `elasticsearch-plugin` by running (will need to do that again if you update elasticsearch):

```bash
$ mv /usr/local/bin/plugin /usr/local/bin/elasticsearch-plugin
```

Below I will use `elasticsearch-plugin`, just replace it with `plugin` if you haven't followed this step.

As you guessed, you can add plugins to elasticsearch. A popular one is [elasticsearch-head](http://mobz.github.io/elasticsearch-head/), which gives you a web interface to the REST API. Install it with:

```bash
$ elasticsearch-plugin --install mobz/elasticsearch-head
```

### Usage

Start a local elasticsearch server with:

```bash
$ elasticsearch -f
```

(The `-f` option tells it to run in the foreground, so you can stop it with `Ctrl+C`.)

Test that the server is working correctly by running:

```bash
$ curl -XGET 'http://localhost:9200/'
```

If you installed the elasticsearch-head plugin, you can visit its interface at `http://localhost:9200/_plugin/head/`.

Elasticsearch's [documentation](http://www.elasticsearch.org/guide/) is more of a reference. To get started, I suggest reading some of the blog posts linked on this [StackOverflow answer](http://stackoverflow.com/questions/11593035/beginners-guide-to-elasticsearch/11767610#11767610).

## Projects folder

This really depends on how you want to organize your files, but I like to put all my version-controlled projects in `~/projects-venv`. Other documents I may have, or things not yet under version control, I like to put in `~/Dropbox` (if you have Dropbox installed), or `~/Documents`.

## Apps

Here is a quick list of some apps I use, and that you might find useful as well:

- [Dropbox](https://www.dropbox.com/): File syncing to the cloud.
- [Google Drive](https://drive.google.com/): File syncing to the cloud too! esp when you use Google Docs to collaborate with others (edit a document with multiple people in real-time!).
- [MacDown](http://macdown.uranusjr.com): A simple [Markdown](http://daringfireball.net/projects/markdown/) editor. In fact, this `README.md` file (possibly the most important file of a GitHub repo) is indeed in Markdown, and edited in MacDown
- commander-one is a much better file explorer than finder
- github-desktop
- [Alfred](https://www.alfredapp.com/help/getting-started/)
- OneNote - For Notes
- Caffeine
- F.lux
- CloudPlane
- and others - please check the Brewfile in the setup scripts
- https://mailcatcher.me/ for a developer smtp server + gui
## Credits
[nicolashery](https://github.com/nicolashery/mac-dev-setup)

repository: aavnsh/laptop-setup

repo_name: aavnsh/laptop-setup


text:
# 👋 HEYfi my mailbox

[HEY.com](https://hey.com) is a brilliant mail service made by [basecamp](https://basecamp.com).
By introducing some key elements and processes it makes working with mails nice again.

Unfortunately it does not support using own domains, so I would like to apply some of the ideas to my mailbox.

## (some) Key Elements

### Screener

You decide which mail can reach you, by categorizing every sender as screened positiv or negative.

### 👋 Imbox

Only mails from positively screened senders are a going to in.

### 🗞 Reply Later

From the Imbox you can decide to read a mail later and move it out of your focus temporarily.

### 📌 Set aside

Mails you want to access frequently or more directly without much searching you can set aside.

### 🗄 Paper Trail

Receipts, orders, invoices are collected in a paper trail.

### 🗞 The Feed

All newsletters & marketing mails you screened positive are going into the feed to read later like a newsfeed or timeline on social media.

## How to HEYfi my mailbox on
- [fastmail](/services/fastmail.md)


text:
# Physma globiferum Hue SPECIES

#### Status
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Bull. Soc. bot. Fr. 14: 333 (1914)

#### Original name
Physma globiferum Hue

### Remarks
null

repository: mdoering/backbone

path: /life/Fungi/Ascomycota/Lecanoromycetes/Peltigerales/Pannariaceae/Pannaria/Pannaria lurida/ Syn. Physma globiferum/README.md

repo_name: mdoering/backbone