text:
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/vince-scarpa/responsibleAPI/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/vince-scarpa/responsibleAPI/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/vince-scarpa/responsibleAPI/badges/build.png?b=master)](https://scrutinizer-ci.com/g/vince-scarpa/responsibleAPI/build-status/master)
![Packagist Downloads](https://img.shields.io/packagist/dm/vince-scarpa/responsibleapi)
# ResponsibleAPI RESTfull API
Responsible API is a secure PHP RESTfull application that allows easy HTTP requests from\
external requests fused by Json Web Tokens (JWT).\
[ResponsibleSDK](https://github.com/vince-scarpa/responsibleSDK "ResponsibleAPI software development kit") is recommended to connect to the ResponsibleAPI\

### Development
Version 1.4\
This repo is open for contributions.

Features include:
1. **JWT**
    - to sign each request

2. **Rate limiting**
    - to limit requests to a timed window frame and options to allow unlimited requests

3. **The Leaky bucket algorithm**
    - used for request throttling

## Requirements
PHP 7.x\
[Composer](https://getcomposer.org/doc/00-intro.md "Composer install")\
[ResponsibleSDK](https://github.com/vince-scarpa/responsibleSDK "ResponsibleAPI software development kit") [recommended]

## Installation
Install composer if not already\
    https://getcomposer.org/doc/00-intro.md

Install ResponsibleSDK [recommended for quick example]
    https://github.com/vince-scarpa/responsibleSDK

```
$ cd <responsible sdk directory>
$ git clone https://github.com/vince-scarpa/responsibleAPI.git
$ composer install
```
## Setup
In order for the ResponsibleAPI to initiate we need to add some basic configurations
1. Import the example sql file
2. Use or Create a `.config` file
### Setup your storage
The ResponsibleAPI uses MySQL as Database storage, run the supplied `responsible.sql` file to install the required tables

### Setup a config file
If you didn't get a `.config` file shipped in this repo then you'll need to create one.\
In the repo root directory run the following or anyway you know to create and write to files
```
$ cd <responsible sdk directory>
$ mkdir config
$ touch config/.config
```
Your file structure should look like this
* responsibleAPI
    * config
        * .config
    * src
        * (...)

Edit your new `.config` file and paste the below code, change all credentials to reflect your storage\
Note: The MASTER_KEY is the global "secret key" for system use to sign requests.\
To generate a strong secret I recommend using a strong password generator, this has no length limit but do note you probably want to stick to 32bytes. The only tested characters are;
```
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`-=~!@#$%^&*()_+,./?;[]{}\|
```

```
DB_TYPE = 'mysql'
DB_PORT = '3306'
DB_NAME = '<YOUR_DB_NAME>'
DB_USER = '<YOUR_DB_USER_NAME>'
DB_PASSWORD = '<YOUR_DB_PASSWORD>'
DB_HOST = '<YOUR_DB_HOST>'

MASTER_KEY = '<YOUR_MASTER_SECRET>'
```

## Basic usage
#### Setting up our API server
```php
<?php
/**
 * Composer Autoloader
 */
require __DIR__ . '/responsibleAPI/vendor/autoload.php';

/**
 * Load Responsible API core
 */
require __DIR__ . '/responsibleAPI/src/responsible.php';

/**
 * Load Responsible API core
 */
use responsible\responsible;

// Initiate the API with no options, let ResponsibleAPI take care of all defaults
$responsible = responsible::API();

// Print the response
$responsible::response(true);
```
What does the above example give us? well, nothing really...\
Just a `permissions denied` message and a server waiting for real requests.\
To access the ResponsibleAPI server via requests you'll need to run the ResponsibleSDK, this can be found @\
https://github.com/vince-scarpa/responsibleSDK or any other HTTP request method you're comfortable with

### Options
Add options

```php
$options = array(
    /**
     * Output type
     */
    'requestType' => 'json', // json, array, object, xml, html, debug

    /**
     * Headers
     */
    // Max control age header "Access-Control-Max-Age"
    'maxWindow' => 86400, // Defaults to 3600 (1 hour)

    /**
     * Add custom headers
     * Custom headers must be create in the below format
     * nothing will happen if not, no errors no added headers
     */
    'addHeaders' => array(
        ['x-my-new-responsible-api', '1.2'],
    ),

    /**
     * JWT refresh options
     */
    'jwt' => [
        'leeway' => 10, // n seconds leeway for expiry
        'issuedAt' => time(),
        'expires' => time() + 300,
        'notBeFor' => 'issuedAt', // issuedAt, or e.g (time()+10)
    ],

    /**
     * Rate limiter
     */
    'rateLimit' => 1000, // API call Limit
    'rateWindow' => 'MINUTE', // Window timeframe SECOND, MINUTE, HOUR, DAY, [CUSTOM/ A POSITIVE INTEGER]

    /**
     * --- Warning ---
     *
     * This will override any rate limits
     * No maximum calls will be set and the Responsible API
     * can run for as many calls and as often as you like
     * This should only be used for system admin calls
     */
    'unlimited' => false, // Unlimited API calls true / false or don't include to default to false

    /**
     * Leaky bucket
     *
     */
    'leak' => true, // Use token bucket "defaults to true"
    'leakRate' => 'default', // slow, medium, normal, default, fast or custom positive integer

    /**
     * Customise a middle ware class directory
     */
    'classRoute' => [
        'directory' => __DIR__ . '/src/service/endpoints', // ABSOLUTE_PATH_STRING, __DIR__ ect...,
        'namespace' => 'backmagic',
    ]
);
$responsible = responsible::API($options);
```

repository: vince-scarpa/responsibleAPI

gha_language: PHP

repo_name: vince-scarpa/responsibleAPI


text:
Read 05
Duckett: HTML and CSS chapter 10
To help understand how CSS works you need to imagine a box around each HTML element.
Block level elements focus on the
Inline focuses on the
CSS works by associating rules with HTML elements
CSS rule contains 2 parts
Selector- indicates which element the rule applies to
Declaration- indicates how the HTML element should be styled
CSS declaration sits inside {} made of 2 parts
Property- indicates what part of the element you want to change, ie: color, font, width, height and border
Values- chooses specifically what you want the property to be. ie: Arial, yellow
CSS foreground color-color of the text inside an element
CSS background color-color of the background

[My Git Hub Page](https://jennifer4450.github.io/LearningJournal/)

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# 🎲 Dice on ice
Dice on ice is a mini-project developed as a challenge in the [javascript-mini-projects](https://github.com/thinkswell/javascript-mini-projects) project to create a javaScript app without using a framework.

![Screenshot of the project](dicegame.png)

### 🚀 Live

[Live here](https://dice-rolling-game.vercel.app/)

## 👓 Features

- Rolling of dice
- Hold the score
- Functional animations

## 📜 Rules
- Each player is allowed to roll the dice till the dice shows one
- As soon as dice shows one all the cumulative scores till now becomes zero
- If the player holds the score, then his/her score is added to his permanent final score
- The first player to score a permanent score of 50 wins!!

## ⚙ Compiling

```bash
🚀 Initialize node
$ npm i

👨💻 Development
$ npm run dev

📯 Distribution
$ npm run build
```

## 🎫 License

All parts of this repository are free to tinkering under the [open-source MIT license](https://github.com/MLousdal/webTemplate/blob/main/LICENSE).

license: MIT,Unlicense

detected_licenses: MIT Unlicense

gha_language: JavaScript

gha_license_id: Unlicense


text:
---
############################# Static ############################
layout: "product"
date: 2021-04-27T09:31:06+03:00
draft: false

product: "Translation"
product_tag: "translation"
platform: "Java"
platform_tag: "java"

############################# Head ############################
head_title: "Java Word & Excel Document Translation SDK & REST API"
head_description: "Java document translation Cloud SDK & REST API. Translate English text to & from French, German, Chinese, Italian, Spanish, Russian, Arabic, Polish and Portuguese languages."

############################# Header ############################
title: "Document Translation REST API & Java SDK"
description: "Add features of documents and plain text translation in your Java applications using Cloud REST API. Accurately translate content between 10 most widely used business languages."
button:
    enable: true

############################# SubMenu ############################
submenu:
    enable: true

    left:
        img_alt: "GroupDocs.Translation Cloud SDK for Java"
        image: "/sdk/272x272/groupdocs_translation-for-java.webp"
        product: "GroupDocs.Translation"
        platform: "Java"

    middle:
        button:
            # button loop
            - link: "#overview"
              text: "Overview"

            # button loop
            - link: "#features"
              text: "Features"

            # button loop
            - link: "https://docs.groupdocs.cloud/translation/release-notes/"
              text: "Release Notes"

            # button loop
            - link: "https://purchase.groupdocs.cloud/pricing"
              text: "Pricing"

    right:
        link_download: "https://groupdocscloud.github.io/"
        link_learn: "https://docs.groupdocs.cloud/translation/"
        link_buy: "https://purchase.groupdocs.cloud/buy"

############################# Overview ############################
overview:
    enable: true
    content: |
      GroupDocs.Translation Cloud SDK for Java makes it simple for developers translating the contents on Microsoft Word, Excel, PowerPoint and plain text documents without using any external software. The API employs a smart neural machine translation approach to translate text from Microsoft Word documents (paragraphs, tables, image captions, headers, footers, footnotes, endnotes), Excel Worksheets (charts, tables, cells, pivot tables) and PowerPoint presentations (text frames, header, footer, shapes, charts, smartart) into 22 language pairs. The SDK supports converting English text from supported document formats to and from French, German, Chinese, Italian, Spanish, Russian, Arabic, Polish and Portuguese languages while keeping the original document structure undisturbed.

      GroupDocs.Translation REST API can easily integrate into existing systems thus managing the low-level details of API requests and handling responses to boost up the overall productivity. You just need to pass out request parameters (path of source file name, format & folder, choose the language pair to translate between, mention the name of translated file, folder and location of the target file to be stored) and get the documents translated by adding a few lines of code.
    tabs:
      enable: true

      ## TAB ONE ##
      tab_one:
        description: |
          An overview of the main features supported by GroupDocs.Translation Cloud for Java.

        left:
          enable: true
          icon: "fas fa-crop"
          title: "Documents Translation"
          content: |
            * Translate Plain Text
            * Translate Word Documents
            * Translate Excel Worksheets
            * Translate PowerPoint Slides
        right:
          enable: true
          icon: "fas fa-file-alt"
          title: "Supported Languages"
          content: |
            * French to German & vice versa
            * French to Italian & vice versa
            * English to French & vice versa
            * English to Deutsch & vice versa
            * English to Chinese & vice versa
            * English to Spainish & vice versa
            * English to Italian & vice versa
            * English to Russian & vice versa
            * English to Arabic & vice versa
            * English to Polish & vice versa
            * English to Portuguese & vice versa

      ## TAB TWO ##
      tab_two:
        description: |
          GroupDocs.Translation Cloud SDK for Java supports a number of document formats.

        left:
          enable: true
          table:
            # table loop
            - title: "Microsoft Office Formats"
              content: |
                * **Word**: DOC, DOCX, DOCM
                * **Excel**:  XLS, XLSX, XLSM
                * **PowerPoint**: PPT, PPTX, PPTM

      ## TAB THREE ##
      tab_three:
        description: |
          GroupDocs.Translation Cloud for cURL - some of the supported languages and platforms.

        left:
          enable: true
          table:
            # table loop
            - icon: "fab fa-windows"
              title: "Operating Systems"
              content: |
                * Microsoft Windows Desktop
                * Microsoft Windows Server
                * Linux
                * MacOS

            # table loop
            - icon: "fas fa-code"
              title: "Supported Frameworks"
              content: |
                * Java 7 (1.7) and above

        right:
          enable: true
          table:
            # table loop
            - icon: "fas fa-cogs"
              title: "Development Environments"
              content: |
                * NetBeans
                * IntelliJ IDEA
                * Eclipse
            # table loop
            - icon: "fas fa-tools"
              title: "Build Automation Tool"
              content: |
                * Maven

############################# Features ############################
features:
    enable: true
    title: "Advanced Document Translation REST API Features"

    feature:
      # feature loop
      - icon: "fas fa-language"
        content: "Supports 10 languages and 22 language pairs"

      # feature loop
      - icon: "fas fa-copy"
        content: "Translation of tables in Word & PowerPoint documents"

      # feature loop
      - icon: "fas fa-file-alt"
        content: "Translation of headers and footers in Word & PowerPoint documents"

      # feature loop
      - icon: "fas fa-copy"
        content: "Translation of footnotes and endnotes in Word document"

      # feature loop
      - icon: "fas fa-file-image"
        content: "Translation of image captions in Word documents"

      # feature loop
      - icon: "fas fa-file-powerpoint"
        content: "Translation of Text Frames, Charts & Slides within PowerPoint Presentations"

      # feature loop
      - icon: "fas fa-file-excel"
        content: "Translation of cells containing text in Excel workbooks"

      # feature loop
      - icon: "fas fa-chart-bar"
        content: "Translation of charts in Excel workbooks"

      # feature loop
      - icon: "fas fa-table"
        content: "Translation of tables in Excel workbooks"
      # feature loop
      - icon: "fas fa-random"
        content: "Translation of pivot tables in Excel workbooks"
      # feature loop
      - icon: "fas fa-lock"
        content: "APIs are secured and require authentication"
      # feature loop
      - icon: "fas fa-list"
        content: "API explorer based on swagger collection"

    more_feature:
      # more_feature_loop
      - title: "Get Started with Document Translation REST API"
        content: "GroupDocs.Translation Cloud API comes with detailed developer guides and live code examples for all major programming languages to start working with API features in no time. Simply create a free account at GroupDocs Cloud, get APP SID & Key information to communicate with GroupDocs Cloud API and you are ready to make an API request on any platform using cURL commands or the SDKs of your choice."

      # more_feature_loop
      - title: "Translate Word document - Java"
        content: |

          ```java
            //Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).

            import com.GroupDocs.translate.api.*;
            import com.GroupDocs.translate.Configuration;

            private static void setUpConfig() throws Exception {
                Configuration.setAPP_SID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
                Configuration.setAPI_KEY("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                }

            public String TranslateDocument() {
                String name = "test.docx";
                String folder = "";
                String pair = "en-fr";
                String format = "docx";
                String storage = "First Storage";
                String saveFile = "translation.docx";
                String savePath = "";
                boolean masters = false;
                ArrayList elements = new ArrayList();
                FileInfo fileInfo = new FileInfo(name, folder, pair, format, storage, saveFile, savePath, masters, elements);
                TranslationDocumentRequest translationDocumentRequest = new TranslationDocumentRequest(fileInfo.toString());
                TranslateDocumentResponse translateDocumentResponse = TranslationApi.TranslateDocument(translationDocumentRequest)
                return translateDocumentResponse.message;
            }
          ```
      # more_feature_loop
      - title: "Any Language, Platform and Storage Service Provider"
        content: "GroupDocs.Translation for Cloud is a REST based API that can easily be integrated with any language or platform, capable to manage HTTP requests and responses. It supports all popular cloud storage services such as Google Cloud, Drive, DropBox and Amazon S3 to interact without any dependencies."

      # more_feature_loop
      - title: "Translate plain text - Java"
        content: |

          ```shell
            //Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).

            import com.GroupDocs.translate.api.*;
            import com.GroupDocs.translate.Configuration;

            private static void setUpConfig() throws Exception {
                Configuration.setAPP_SID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
                Configuration.setAPI_KEY("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                }

            static String TranslateText() {
                pair = "en-fr";
                text = "Text to translate";
                TextInfo textInfo = new TextInfo(pair, text);
                TranslationTextRequest translationTextRequest = new TranslationTextRequest(TextInfo.toString());
                TranslationTextResponse translateTextResponse = TranslationApi.TranslateText(translationTextRequest);
                return translateTextResponse.translation;
            }
          ```
      # more_feature_loop
      - title: "Security and Authentication"
        content: "The GroupDocs.Translation Cloud API is SSL secured and the authentication requests require a signature and AppSID query parameters or OAuth 2.0 authorization header."

############################# Support ############################
support:
    enable: true

############################# Solutions ############################
solutions:
    enable: true
    title: "GroupDocs.Translation Cloud also offers document translation SDKs for other languages as listed below:"

    solution:
        # solution loop
        - img_alt: "GroupDocs.Viewer Cloud SDK for cURL"
          image: "/sdk/272x272/groupdocs_translation-for-curl.webp"
          product: "GroupDocs.Viewer"
          platform: "cURL"
          link: "/translation/curl/"

        # solution loop
        - img_alt: "GroupDocs.Viewer Cloud SDK for .NET"
          image: "/sdk/272x272/groupdocs_translation-for-net.webp"
          product: "GroupDocs.Viewer"
          platform: ".NET"
          link: "/translation/net/"

        # solution loop
        - img_alt: "GroupDocs.Viewer Cloud SDK for Java"
          image: "/sdk/272x272/groupdocs_translation-for-java.webp"
          product: "GroupDocs.Viewer"
          platform: "Java"
          link: "/translation/java/"

        # solution loop
        - img_alt: "GroupDocs.Viewer Cloud SDK for Python"
          image: "/sdk/272x272/groupdocs_translation-for-python.webp"
          product: "GroupDocs.Viewer"
          platform: "Python"
          link: "/translation/python/"

############################# Back to top ###############################
back_to_top:
  enable: true
---

repository: khozam/groupdocscloud

branch_name: refs/heads/main

repo_name: khozam/groupdocscloud


text:
---
layout: post
title: Domain-Adversial Training of Neural Network
---

Domain-Adversial is a new representation learning approach for domain adaptation, in which data at training and test time come from similar but different distributions.The hypothesis is, for effective domain transfer to be achieved, predictions must be made based on features that cannot discriminate between the training (source) and test (target) domains.
[reference paper](https://arxiv.org/pdf/1505.07818.pdf)

gha_language: CSS

gha_license_id: MIT


text:
# Classification with Gated Residual and Variable Selection Networks

**Author:** [Khalid Salama](https://www.linkedin.com/in/khalid-salama-24403144/)

**Date created:** 2021/02/10

**Last modified:** 2021/02/10

**Description:** Using Gated Residual and Variable Selection Networks for income level prediction.

 [**View in Colab**](https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/structured_data/ipynb/classification_with_grn_and_vsn.ipynb)  • [**GitHub source**](https://github.com/keras-team/keras-io/blob/master/examples/structured_data/classification_with_grn_and_vsn.py)

---
## Introduction

This example demonstrates the use of Gated
Residual Networks (GRN) and Variable Selection Networks (VSN), proposed by
Bryan Lim et al. in
[Temporal Fusion Transformers (TFT) for Interpretable Multi-horizon Time Series Forecasting](https://arxiv.org/abs/1912.09363),
for structured data classification. GRNs give the flexibility to the model to apply
non-linear processing only where needed. VSNs allow the model to softly remove any
unnecessary noisy inputs which could negatively impact performance.
Together, those techniques help improving the learning capacity of deep neural
network models.

Note that this example implements only the GRN and VSN components described in
in the paper, rather than the whole TFT model, as GRN and VSN can be useful on
their own for structured data learning tasks.

To run the code you need to use TensorFlow 2.3 or higher.

---
## The dataset

This example uses the
[United States Census Income Dataset](https://archive.ics.uci.edu/ml/datasets/Census-Income+%28KDD%29)
provided by the
[UC Irvine Machine Learning Repository](https://archive.ics.uci.edu/ml/index.php).
The task is binary classification to determine whether a person makes over 50K a year.

The dataset includes ~300K instances with 41 input features: 7 numerical features
and 34 categorical features.

---
## Setup

```python
import math
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
```

---
## Prepare the data

First we load the data from the UCI Machine Learning Repository into a Pandas DataFrame.

```python
# Column names.
CSV_HEADER = [
    "age",
    "class_of_worker",
    "detailed_industry_recode",
    "detailed_occupation_recode",
    "education",
    "wage_per_hour",
    "enroll_in_edu_inst_last_wk",
    "marital_stat",
    "major_industry_code",
    "major_occupation_code",
    "race",
    "hispanic_origin",
    "sex",
    "member_of_a_labor_union",
    "reason_for_unemployment",
    "full_or_part_time_employment_stat",
    "capital_gains",
    "capital_losses",
    "dividends_from_stocks",
    "tax_filer_stat",
    "region_of_previous_residence",
    "state_of_previous_residence",
    "detailed_household_and_family_stat",
    "detailed_household_summary_in_household",
    "instance_weight",
    "migration_code-change_in_msa",
    "migration_code-change_in_reg",
    "migration_code-move_within_reg",
    "live_in_this_house_1_year_ago",
    "migration_prev_res_in_sunbelt",
    "num_persons_worked_for_employer",
    "family_members_under_18",
    "country_of_birth_father",
    "country_of_birth_mother",
    "country_of_birth_self",
    "citizenship",
    "own_business_or_self_employed",
    "fill_inc_questionnaire_for_veteran's_admin",
    "veterans_benefits",
    "weeks_worked_in_year",
    "year",
    "income_level",
]

data_url = "https://archive.ics.uci.edu/ml/machine-learning-databases/census-income-mld/census-income.data.gz"
data = pd.read_csv(data_url, header=None, names=CSV_HEADER)

test_data_url = "https://archive.ics.uci.edu/ml/machine-learning-databases/census-income-mld/census-income.test.gz"
test_data = pd.read_csv(test_data_url, header=None, names=CSV_HEADER)

print(f"Data shape: {data.shape}")
print(f"Test data shape: {test_data.shape}")

```

```
Data shape: (199523, 42)
Test data shape: (99762, 42)

```

We convert the target column from string to integer.

```python
data["income_level"] = data["income_level"].apply(
    lambda x: 0 if x == " - 50000." else 1
)
test_data["income_level"] = test_data["income_level"].apply(
    lambda x: 0 if x == " - 50000." else 1
)

```

Then, We split the dataset into train and validation sets.

```python
random_selection = np.random.rand(len(data.index)) <= 0.85
train_data = data[random_selection]
valid_data = data[~random_selection]

```

Finally we store the train and test data splits locally to CSV files.

```python
train_data_file = "train_data.csv"
valid_data_file = "valid_data.csv"
test_data_file = "test_data.csv"

train_data.to_csv(train_data_file, index=False, header=False)
valid_data.to_csv(valid_data_file, index=False, header=False)
test_data.to_csv(test_data_file, index=False, header=False)
```

---
## Define dataset metadata

Here, we define the metadata of the dataset that will be useful for reading and
parsing the data into input features, and encoding the input features with respect
to their types.

```python
# Target feature name.
TARGET_FEATURE_NAME = "income_level"
# Weight column name.
WEIGHT_COLUMN_NAME = "instance_weight"
# Numeric feature names.
NUMERIC_FEATURE_NAMES = [
    "age",
    "wage_per_hour",
    "capital_gains",
    "capital_losses",
    "dividends_from_stocks",
    "num_persons_worked_for_employer",
    "weeks_worked_in_year",
]
# Categorical features and their vocabulary lists.
# Note that we add 'v=' as a prefix to all categorical feature values to make
# sure that they are treated as strings.
CATEGORICAL_FEATURES_WITH_VOCABULARY = {
    feature_name: sorted([str(value) for value in list(data[feature_name].unique())])
    for feature_name in CSV_HEADER
    if feature_name
    not in list(NUMERIC_FEATURE_NAMES + [WEIGHT_COLUMN_NAME, TARGET_FEATURE_NAME])
}
# All features names.
FEATURE_NAMES = NUMERIC_FEATURE_NAMES + list(
    CATEGORICAL_FEATURES_WITH_VOCABULARY.keys()
)
# Feature default values.
COLUMN_DEFAULTS = [
    [0.0]
    if feature_name in NUMERIC_FEATURE_NAMES + [TARGET_FEATURE_NAME, WEIGHT_COLUMN_NAME]
    else ["NA"]
    for feature_name in CSV_HEADER
]
```

---
## Create a `tf.data.Dataset` for training and evaluation

We create an input function to read and parse the file, and convert features and
labels into a [`tf.data.Dataset`](https://www.tensorflow.org/guide/datasets) for
training and evaluation.

```python
from tensorflow.keras.layers import StringLookup

def process(features, target):
    for feature_name in features:
        if feature_name in CATEGORICAL_FEATURES_WITH_VOCABULARY:
            # Cast categorical feature values to string.
            features[feature_name] = tf.cast(features[feature_name], tf.dtypes.string)
    # Get the instance weight.
    weight = features.pop(WEIGHT_COLUMN_NAME)
    return features, target, weight

def get_dataset_from_csv(csv_file_path, shuffle=False, batch_size=128):

    dataset = tf.data.experimental.make_csv_dataset(
        csv_file_path,
        batch_size=batch_size,
        column_names=CSV_HEADER,
        column_defaults=COLUMN_DEFAULTS,
        label_name=TARGET_FEATURE_NAME,
        num_epochs=1,
        header=False,
        shuffle=shuffle,
    ).map(process)

    return dataset

```

---
## Create model inputs

```python

def create_model_inputs():
    inputs = {}
    for feature_name in FEATURE_NAMES:
        if feature_name in NUMERIC_FEATURE_NAMES:
            inputs[feature_name] = layers.Input(
                name=feature_name, shape=(), dtype=tf.float32
            )
        else:
            inputs[feature_name] = layers.Input(
                name=feature_name, shape=(), dtype=tf.string
            )
    return inputs

```

---
## Encode input features

For categorical features, we encode them using `layers.Embedding` using the
`encoding_size` as the embedding dimensions. For the numerical features,
we apply linear transformation using `layers.Dense` to project each feature into
`encoding_size`-dimensional vector. Thus, all the encoded features will have the
same dimensionality.

```python

def encode_inputs(inputs, encoding_size):
    encoded_features = []
    for feature_name in inputs:
        if feature_name in CATEGORICAL_FEATURES_WITH_VOCABULARY:
            vocabulary = CATEGORICAL_FEATURES_WITH_VOCABULARY[feature_name]
            # Create a lookup to convert a string values to an integer indices.
            # Since we are not using a mask token nor expecting any out of vocabulary
            # (oov) token, we set mask_token to None and  num_oov_indices to 0.
            index = StringLookup(
                vocabulary=vocabulary, mask_token=None, num_oov_indices=0
            )
            # Convert the string input values into integer indices.
            value_index = index(inputs[feature_name])
            # Create an embedding layer with the specified dimensions
            embedding_ecoder = layers.Embedding(
                input_dim=len(vocabulary), output_dim=encoding_size
            )
            # Convert the index values to embedding representations.
            encoded_feature = embedding_ecoder(value_index)
        else:
            # Project the numeric feature to encoding_size using linear transformation.
            encoded_feature = tf.expand_dims(inputs[feature_name], -1)
            encoded_feature = layers.Dense(units=encoding_size)(encoded_feature)
        encoded_features.append(encoded_feature)
    return encoded_features

```

---
## Implement the Gated Linear Unit

[Gated Linear Units (GLUs)](https://arxiv.org/abs/1612.08083) provide the
flexibility to suppress input that are not relevant for a given task.

```python

class GatedLinearUnit(layers.Layer):
    def __init__(self, units):
        super(GatedLinearUnit, self).__init__()
        self.linear = layers.Dense(units)
        self.sigmoid = layers.Dense(units, activation="sigmoid")

    def call(self, inputs):
        return self.linear(inputs) * self.sigmoid(inputs)

```

---
## Implement the Gated Residual Network

The Gated Residual Network (GRN) works as follows:

1. Applies the nonlinear ELU transformation to the inputs.
2. Applies linear transformation followed by dropout.
4. Applies GLU and adds the original inputs to the output of the GLU to perform skip
(residual) connection.
6. Applies layer normalization and produces the output.

```python

class GatedResidualNetwork(layers.Layer):
    def __init__(self, units, dropout_rate):
        super(GatedResidualNetwork, self).__init__()
        self.units = units
        self.elu_dense = layers.Dense(units, activation="elu")
        self.linear_dense = layers.Dense(units)
        self.dropout = layers.Dropout(dropout_rate)
        self.gated_linear_unit = GatedLinearUnit(units)
        self.layer_norm = layers.LayerNormalization()
        self.project = layers.Dense(units)

    def call(self, inputs):
        x = self.elu_dense(inputs)
        x = self.linear_dense(x)
        x = self.dropout(x)
        if inputs.shape[-1] != self.units:
            inputs = self.project(inputs)
        x = inputs + self.gated_linear_unit(x)
        x = self.layer_norm(x)
        return x

```

---
## Implement the Variable Selection Network

The Variable Selection Network (VSN) works as follows:

1. Applies a GRN to each feature individually.
2. Applies a GRN on the concatenation of all the features, followed by a softmax to
produce feature weights.
3. Produces a weighted sum of the output of the individual GRN.

Note that the output of the VSN is [batch_size, encoding_size], regardless of the
number of the input features.

```python

class VariableSelection(layers.Layer):
    def __init__(self, num_features, units, dropout_rate):
        super(VariableSelection, self).__init__()
        self.grns = list()
        # Create a GRN for each feature independently
        for idx in range(num_features):
            grn = GatedResidualNetwork(units, dropout_rate)
            self.grns.append(grn)
        # Create a GRN for the concatenation of all the features
        self.grn_concat = GatedResidualNetwork(units, dropout_rate)
        self.softmax = layers.Dense(units=num_features, activation="softmax")

    def call(self, inputs):
        v = layers.concatenate(inputs)
        v = self.grn_concat(v)
        v = tf.expand_dims(self.softmax(v), axis=-1)

        x = []
        for idx, input in enumerate(inputs):
            x.append(self.grns[idx](input))
        x = tf.stack(x, axis=1)

        outputs = tf.squeeze(tf.matmul(v, x, transpose_a=True), axis=1)
        return outputs

```

---
## Create Gated Residual and Variable Selection Networks model

```python

def create_model(encoding_size):
    inputs = create_model_inputs()
    feature_list = encode_inputs(inputs, encoding_size)
    num_features = len(feature_list)

    features = VariableSelection(num_features, encoding_size, dropout_rate)(
        feature_list
    )

    outputs = layers.Dense(units=1, activation="sigmoid")(features)
    model = keras.Model(inputs=inputs, outputs=outputs)
    return model

```

---
## Compile, train, and evaluate the model

```python
learning_rate = 0.001
dropout_rate = 0.15
batch_size = 265
num_epochs = 20
encoding_size = 16

model = create_model(encoding_size)
model.compile(
    optimizer=keras.optimizers.Adam(learning_rate=learning_rate),
    loss=keras.losses.BinaryCrossentropy(),
    metrics=[keras.metrics.BinaryAccuracy(name="accuracy")],
)

# Create an early stopping callback.
early_stopping = tf.keras.callbacks.EarlyStopping(
    monitor="val_loss", patience=5, restore_best_weights=True
)

print("Start training the model...")
train_dataset = get_dataset_from_csv(
    train_data_file, shuffle=True, batch_size=batch_size
)
valid_dataset = get_dataset_from_csv(valid_data_file, batch_size=batch_size)
model.fit(
    train_dataset,
    epochs=num_epochs,
    validation_data=valid_dataset,
    callbacks=[early_stopping],
)
print("Model training finished.")

print("Evaluating model performance...")
test_dataset = get_dataset_from_csv(test_data_file, batch_size=batch_size)
_, accuracy = model.evaluate(test_dataset)
print(f"Test accuracy: {round(accuracy * 100, 2)}%")
```

```
Start training the model...
Epoch 1/20
641/641 [==============================] - 26s 22ms/step - loss: 317.7028 - accuracy: 0.9353 - val_loss: 230.1805 - val_accuracy: 0.9497
Epoch 2/20
641/641 [==============================] - 13s 19ms/step - loss: 231.4161 - accuracy: 0.9506 - val_loss: 224.7825 - val_accuracy: 0.9498
Epoch 3/20
641/641 [==============================] - 12s 19ms/step - loss: 226.8173 - accuracy: 0.9503 - val_loss: 223.0818 - val_accuracy: 0.9508
Epoch 4/20
641/641 [==============================] - 13s 19ms/step - loss: 224.1516 - accuracy: 0.9507 - val_loss: 221.8637 - val_accuracy: 0.9509
Epoch 5/20
641/641 [==============================] - 13s 19ms/step - loss: 223.9696 - accuracy: 0.9507 - val_loss: 217.8728 - val_accuracy: 0.9513
Epoch 6/20
641/641 [==============================] - 13s 19ms/step - loss: 220.7267 - accuracy: 0.9508 - val_loss: 220.2448 - val_accuracy: 0.9516
Epoch 7/20
641/641 [==============================] - 13s 19ms/step - loss: 219.7464 - accuracy: 0.9514 - val_loss: 216.4628 - val_accuracy: 0.9516
Epoch 8/20
641/641 [==============================] - 13s 19ms/step - loss: 218.7294 - accuracy: 0.9517 - val_loss: 215.2192 - val_accuracy: 0.9519
Epoch 9/20
641/641 [==============================] - 12s 19ms/step - loss: 218.3938 - accuracy: 0.9516 - val_loss: 217.1790 - val_accuracy: 0.9514
Epoch 10/20
641/641 [==============================] - 13s 19ms/step - loss: 217.2871 - accuracy: 0.9522 - val_loss: 213.4623 - val_accuracy: 0.9523
Epoch 11/20
641/641 [==============================] - 13s 19ms/step - loss: 215.0476 - accuracy: 0.9522 - val_loss: 211.6762 - val_accuracy: 0.9523
Epoch 12/20
641/641 [==============================] - 13s 19ms/step - loss: 213.2402 - accuracy: 0.9527 - val_loss: 212.2001 - val_accuracy: 0.9525
Epoch 13/20
641/641 [==============================] - 13s 20ms/step - loss: 212.8123 - accuracy: 0.9530 - val_loss: 207.9878 - val_accuracy: 0.9538
Epoch 14/20
641/641 [==============================] - 13s 19ms/step - loss: 208.4605 - accuracy: 0.9541 - val_loss: 208.0063 - val_accuracy: 0.9543
Epoch 15/20
641/641 [==============================] - 13s 19ms/step - loss: 211.9185 - accuracy: 0.9533 - val_loss: 208.2112 - val_accuracy: 0.9540
Epoch 16/20
641/641 [==============================] - 13s 19ms/step - loss: 207.7694 - accuracy: 0.9544 - val_loss: 207.3279 - val_accuracy: 0.9547
Epoch 17/20
641/641 [==============================] - 13s 19ms/step - loss: 208.6964 - accuracy: 0.9540 - val_loss: 204.3082 - val_accuracy: 0.9553
Epoch 18/20
641/641 [==============================] - 13s 19ms/step - loss: 207.2199 - accuracy: 0.9547 - val_loss: 206.4799 - val_accuracy: 0.9549
Epoch 19/20
641/641 [==============================] - 13s 19ms/step - loss: 206.7960 - accuracy: 0.9548 - val_loss: 206.0898 - val_accuracy: 0.9555
Epoch 20/20
641/641 [==============================] - 13s 20ms/step - loss: 206.2721 - accuracy: 0.9547 - val_loss: 206.6541 - val_accuracy: 0.9549
Model training finished.
Evaluating model performance...
377/377 [==============================] - 5s 11ms/step - loss: 206.3511 - accuracy: 0.9541
Test accuracy: 95.41%

```

You should achieve more than 95% accuracy on the test set.

To increase the learning capacity of the model, you can try increasing the
`encoding_size` value, or stacking multiple GRN layers on top of the VSN layer.
This may require to also increase the `dropout_rate` value to avoid overfitting.

repository: amshrbo/keras-io

repo_name: amshrbo/keras-io


text:
# Messenger-bot

![Latest Version released](https://img.shields.io/github/release/PaulRosset/messenger-bot.svg)

Build a nodejs bot in 10 minutes !

## Setting-up the environment

__The easiest method and gain time is to use the heroku web server.__

In first, Sign up to heroku on their website : https://www.heroku.com.

Then, download the CLI toolbelt of Heroku here : https://toolbelt.heroku.com

Test it inside your terminal with :
```
$ heroku
```

__Now, you can clone the project__

Type in your terminal :

```
$ git clone https://github.com/PaulRosset/messenger-bot.git
$ cd messenger-bot
$ npm install
```

Then, set up the Heroku env :

In first, connect your Heroku account with :

```
$ heroku login
```

And now :

```
$ git init
$ git add --all
$ git commit -am "Initial commit"
$ heroku create
$ git push heroku master
```
These multiples commands, send the express app online thanks to heroku web server (commit/deploy).

In the project at the root, you got a Procfile, which look like this :

```
web node bot.js
```
This command tell to heroku to run your __bot.js__ which is used to launch our express web server

__Setting up Facebook app__

Now, go to : https://developers.facebook.com/apps/

1. Create a new app

2. Go to messenger tab, then setup a webhook, a popin will appear to ask :
   - The url of your web app that heroku deployed online, don't forget to specify the route 'webhook', which is the route that facebook will use to 'curl' to connect both sides (Facebook and Heroku sides).

 	    Example : https://nameofherokuapp.herokuapp.com/webhook/

   - The second parameter, important to specify is the token verification, fill with anything. This will be used by facebook's curl to verify the authenticity of the app's owner.

 	    Example :
```
app.get('/webhook/', function (req, res) {
    if (req.query['hub.verify_token'] === '<TOKEN_U_CHOOSE>') {
            res.send(req.query['hub.challenge'])
        }
       res.send('Invalid Token')
     });
```
   - Finally, check all fields, then, you are done with facebook configuration.

3. Now, go to the Generate token section in facebook app dashboard to get your access_token. A bot is in fact a Facebook Page, there you have to create a page, before generating the access_token.

4.

You can go to the page of the bot and then speak to the bot thanks to messenger by typing the name of keys containing in __/utils/request.js__, the bot will answer with the value containing in the keys.

But, your bot isn't doing much things ...

 ## Go further

 To go further, meet me to [Messanger Bot Advanced](https://github.com/PaulRosset/messanger-bot-advanced.git) (Soon)

 We will implement __Wit.ai__ an API to understand natural language but also integrate the __Strategies Pattern__.

 ## Tips

 1. Each time, you do change in your app, you have to redeploy, there is a tiny script in bin/deploy.sh to deploy quickly.

 2. In __/bodyJson/__ you have multiple examples of returned file from messenger's json, when your ask something to the bot.

## Author

Paul Rosset

## License

MIT

repository: PaulRosset/messenger-bot

repo_name: PaulRosset/messenger-bot


text:
---
title: "glide.basicauth.required.xml"
description: "Property"
---

Description: Require authorization for incoming XML requests.

Value: `true`

repository: ASHISH-SERVICENOW/sn

repo_name: ASHISH-SERVICENOW/sn


text:
---
layout: recipes
title:  " Cognac and Mustard Sauce"
type: "beef"
picture: ../assets/img/c_and_m_sauce.jpg
ingredients :
  Vegetable oil: 1 tablespoon
  Minced shallots: 2
  Chicken broth: 1 cup
  Cognac: 1/3 cup
  Whole-grain mustard: 1 tablespoon
  Fresh lemon juice: 1 tablespoon
  Unsalted butter cut into three pieces: 3 tablespoons
  Minced fresh tarragon: 2 teaspoons
  Salt and Pepper: as needed
instructions:
  - Add the oil to the skillet and return to medium-high heat until shimmering. Add the shallots and cook until softened, about two minutes. Stir in the broth and cognac, scraping up any browned bits, and simmer until thickened, about five minutes. Stir in the mustard and lemon juice and any accumulated meat juice. Turn the heat to low and whisk in the butter, one piece at a time. Off the heat, stirring the tarragon and season with salt and pepper to taste. Spoon sauce over steaks or chops before serving.
prep-time: none
cook-time: 10 min
serves: 8
source: America's Test Kitchen Cookbook
difficulty: easy
blurb: Serve over your favorite steak for a delicious addition to dinner!
---

branch_name: refs/heads/gh-pages

gha_language: SCSS


text:
# Extending

VuePress default theme is widely used by users, so it is designed to be extendable, allowing users to make their own customization with ease.

VuePress provides basic ability to extend a theme, but different themes may have different features to be extended. Thus, if you are using a community theme, you'd better refer to the theme's own documentation for how to extending it.

## Layout Slots

Default theme's `Layout` provides some slots:

- `navbar`
- `navbar-before`
- `navbar-after`
- `sidebar`
- `sidebar-top`
- `sidebar-bottom`
- `page`
- `page-top`
- `page-bottom`
- `page-content-top`
- `page-content-bottom`

With the help of them, you can add or replace content easily. Here comes an example to introduce how to extend default theme with layout slots.

Firstly, create a client config file `.vuepress/client.ts`:

```ts
import { defineClientConfig } from '@vuepress/client'
import Layout from './layouts/Layout.vue'

export default defineClientConfig({
  layouts: {
    Layout,
  },
})
```

Next, create the `.vuepress/layouts/Layout.vue`, and make use of the slots that provided by the `Layout` of default theme:

```vue
<script setup>
import ParentLayout from<EMAIL_ADDRESS></script>

<template>
  <ParentLayout>
    <template #page-bottom>
      <div class="my-footer">This is my custom page footer</div>
    </template>
  </ParentLayout>
</template>

<style lang="css">
.my-footer {
  text-align: center;
}
</style>
```

Then the default `Layout` layout has been overridden by your own local layout, which will add a custom footer to every normal pages in default theme (excluding homepage):

![extending-a-theme](/images/cookbook/extending-a-theme-01.png)

## Components Replacement

The layout slots are useful, but sometimes you might find it's not flexible enough. Default theme also provides the ability to replace a single component.

Default theme has registered [alias](../plugin-api.md#alias) for every [non-global components](https://github.com/vuepress/vuepress-next/tree/main/ecosystem/theme-default/src/client/components) with a `@theme` prefix. For example, the alias of `HomeFooter.vue` is<EMAIL_ADDRESS>
Then, if you want to replace the `HomeFooter.vue` component, just override the alias in your config file `.vuepress/config.ts`:

```ts
import { getDirname, path } from '@vuepress/utils'
import { defaultTheme, defineUserConfig } from 'vuepress'

const __dirname = getDirname(import.meta.url)

export default defineUserConfig({
  theme: defaultTheme(),
  alias: {
<EMAIL_ADDRESS>path.resolve(__dirname, './components/MyHomeFooter.vue'),
  },
})
```

## Developing a Child Theme

Instead of extending the default theme directly in `.vuepress/config.ts` and `.vuepress/client.ts`, you can also develop your own theme extending the default theme:

```ts
import type { Theme } from '@vuepress/core'
import { defaultTheme, type DefaultThemeOptions } from '@vuepress/theme-default'
import { getDirname, path } from '@vuepress/utils'

const __dirname = getDirname(import.meta.url)

export const childTheme = (options: DefaultThemeOptions): Theme => {
  return {
    name: 'vuepress-theme-child',
    extends: defaultTheme(options),

    // override layouts in child theme's client config file
    clientConfigFile: path.resolve(__dirname, './client.js'),

    // override component alias
    alias: {
<EMAIL_ADDRESS>path.resolve(__dirname, './components/MyHomeFooter.vue'),
    },
  }
}
```


text:
# crowd-source-js
JS library for interacting with UCD library crowd source databases.  Including crowd-source-db (PGR/Postgres), Firestore and UCD FIN/DAMS

# Overview

![crowd-source-js overview](./docs/crowd-source-js-overview.png)

# Method Overview

## Crowd Inputs
- get approved by item (PGR)
  - gets all approved inputs for item
  - will trigger update events for individual inputs and item
- get approved by id (PGR)
- set approved (PGR/Firestore)
  - add input to pgr, remove from firestore
- add pending (Firestore)
  - add pending input to firestore
- remove pending (Firestore)
  - remove a pending crowd input.
  - Must be admin or owned by user
- update pending (Firestore)
  - update a pending crowd input.
  - Must be admin or owned by user
- get pending (Firestore)
- get pending by item (Firestore)
  - get all pending inputs for item
  - will trigger update events for individual inputs and item
- listen pending by item (Firestore)
  - get pushed updates of all inputs for item
  - will trigger update events for individual inputs and item
  - if input is deleted, will check if it was approved.  Fires approved update event if it was
- unlisten pending by item (Firestores)
  - stop listing to push update of inputs for item

## Items
- get by id (ElasticSearch)
- search (ElasticSearch)
  - supports text, filters, limit, offsets, etc
- get crowd info (PGR)
  - get crowd information for item, ex: editable, completed
- update crowd info (PGR)
  - update the crowd information for item (admin only)
- get crowd child stats (PGR)
  - given a item id, get summary of crowd info for all child items

## Presence

- set user id (Firestore)
  - set the user id to be automatically associated with all presence objects
- update presence (Firestore)
  - add or update a new presence object.  Will automatically add userId, uid
    and appId to object.  Used to listen for realtime updates of user presence.
- remove presence (Firestore)
  - remove a presence object

*Note: the PresenceService will listen to firebase authentication events and remove presence on logout.  The service will also set handlers so on disconnect, presence objects are removed.

## Auth

- userLogin
  - Given a user Firebase jwt token and PGR jwt token, store tokens and run firebase login function.
- anonymousLogin (Google Cloud Function)
  - Use the Google Cloud Function service to generate anonymous user firebase and pgr tokens.  Then login user to firebase with token and finally store tokens

## Auth0

Auth0 is an optional extension for including Auth0 as a authentication and authorization source.  Note the AuthModel just requires JWTs signed with applications Firebase and PGR accounts.  This Auth0Model provides support for; logging in via Auth0 Lock UI, running Auth0 Lock authentication flow, generating Firebase and PGR JWTs from Auth0 JWT.  The generated JWTs are then passed to the AuthModel userLogin() function.

Note.  Perhaps this should be broken out to it's own JS library?

- login (Auth0 Lock)
  - Show the Auth0 Lock widget starting the login flow
- isRedirect
  - is the current hash in the windows url a redirect from Auth0?  If so, continue the login flow
- loginJwt (Google Cloud Function)
  - Continue Auth0 login flow after new Auth0 JWT is issued.  Given a Auth0 JWT, use the Google Cloud Function service to generate Firebase and PGR JWTs from Auth0 JWT.  Roles provided in Auth0 JWT will be automatically associated to Firebase/PGR JWTs.
- initAuthRenewAuth0/autoRenew (PostMessage Iframe)
  - both of these functions should be called by isRedirect(true).  The true flag will initiate a silent login flow for user if the url hash is not in the middle of a Auth0 login.  Silent logins will take a access token that is about to expire and generate a new one.

# Authentication

## crowd-source-db (PostgREST/PostreSQL)

PostgREST authenticates via a Bearer JWT token in the Authorization header.  Use the AuthModel.userLogin() function to set tokens.  The JWT should have the following payload:

```js
{
  username : '',
  role : ''
}
```

Where role is empty, 'anon', 'editor' or 'admin'.  JWTs can be minted for PGR using the jsonwebtoken library.

```js
const jwt = require('jsonwebtoken');
let token = jwt.sign({username, role}, 'secret');
```

## Firestore

Firebase has several authentication methods but the JWT token method is highly recommended.  The payload for the token should include the following flags:

```js
{
  isAnonymous : false,
  isAdmin : false
}
```

You should use the firebase-admin library with a Google/Firebase Service Account to mint the tokens.  You should also take care to set the user account custom claims when you mint a token (See /firebase/functions/lib/auth.js _generateFirebaseToken()).  This ensures claims are associated with the acutal user account (Not just the JWT) and are very helpful for using the firebase user management APIs. Once firebase is authenticated with the token, no further action is required.

```js
const admin = require('firebase-admin');
const serviceAccount = require('./service-account.json');

(async function() {
  let userId = 'alice';
  let claim = {
    isAdmin : true
  }

  try {
    let user = (await firebase.auth().getUser(userId)).toJSON();
    if( !deepEqual(claim, user.customClaims) ) {
      await firebase.auth().setCustomUserClaims(userId, claim);
    }
  } catch(e) {
    await firebase.auth().createUser({uid: userId});
    await firebase.auth().setCustomUserClaims(userId, claim);
  }

  await firebase.auth().createCustomToken(userId, claim);
})();
```

## FIN / DAMS

The DAMS Elastic Search API is public and does not require authentication.

# Auth0

Here is the standard authentication flow with Auth0

![crowd-source-js auth flow](./docs/crowd-source-js-auth-flow.png)

repository: ucd-library/crowd-source-js

repo_name: ucd-library/crowd-source-js


text:
2423\. Remove Letter To Equalize Frequency

Easy

You are given a **0-indexed** string `word`, consisting of lowercase English letters. You need to select **one** index and **remove** the letter at that index from `word` so that the **frequency** of every letter present in `word` is equal.

Return `true` _if it is possible to remove one letter so that the frequency of all letters in_ `word` _are equal, and_ `false` _otherwise_.

**Note:**

*   The **frequency** of a letter `x` is the number of times it occurs in the string.
*   You **must** remove exactly one letter and cannot chose to do nothing.

**Example 1:**

**Input:** word = "abcc"

**Output:** true

**Explanation:** Select index 3 and delete it: word becomes "abc" and each character has a frequency of 1.

**Example 2:**

**Input:** word = "aazz"

**Output:** false

**Explanation:** We must delete a character, so either the frequency of "a" is 1 and the frequency of "z" is 2, or vice versa. It is impossible to make all present letters have equal frequency.

**Constraints:**

*   `2 <= word.length <= 100`
*   `word` consists of lowercase English letters only.

repository: javadev/LeetCode-in-Java

gha_language: Java

repo_name: javadev/LeetCode-in-Java


text:
# ὑπεναντίος, α, ον .

<!-- Status: S2=NeedsFinalCheck -->
<!-- Lexica used for edits: BDAG, FFM, LN, A-S -->

## Word data

* Strongs: G52270.

* Alternate spellings:

* Principle Parts:

* Part of speech:

[Noun predicate_adj](http://ugg.readthedocs.io/en/latest/noun_predicate_adj.html),
[Noun substantive_adj](http://ugg.readthedocs.io/en/latest/noun_substantive_adj.html).

* Instances in the New Testament: 2.

* All Scriptures cited: Yes.

## Etymology:

* LXX/Hebrew glosses:

* Time Period/Ancient Authors:

* Related words:

* Antonyms for all senses:

* Synonyms for all senses:

## Senses:

### Sense 1.0:

#### Definition:

Contrary to, opposed to

#### Glosses:

stand against, opposed, adversaries

#### Explanation:

#### Citations:

;[ἐξαλείψας](../G18130/01.md) [τὸ](../G35880/01.md) [καθ’](../G25960/01.md) [ἡμῶν](../G14730/01.md) [χειρόγραφον](../G54980/01.md) [τοῖς](../G35880/01.md) [δόγμασιν](../G13780/01.md) [ὃ](../G37390/01.md) [ἦν](../G99999/01.md) ὑπεναντίον [ἡμῖν](../G14730/01.md) [καὶ](../G25320/01.md) [αὐτὸ](../G08460/01.md) [ἦρκεν](../G01420/01.md) [ἐκ](../G15370/01.md) [τοῦ](../G35880/01.md) [μέσου](../G33190/01.md) [προσηλώσας](../G43380/01.md) [αὐτὸ](../G08460/01.md) [τῷ](../G35880/01.md) [σταυρῷ](../G47160/01.md),
;"He canceled the written record of debts that stood against us with its regulations. He took it away by nailing it to the cross.":
[Col 2:14](col 2:14),  [Heb 10:27](heb 10:27).

repository: mandolyte/uw-obsidian

repo_name: mandolyte/uw-obsidian


text:
# argtracer

<!-- badges: start -->
<!-- badges: end -->

The goal of argtracer is to collect R-eal values that are arguments and return values of function calls in the executable code from a corpus of CRAN packages

## Installation

TBC

<!-- ``` r -->
<!-- install.packages("lazr") -->
<!-- ``` -->

## Example

This example traces the arguments and return values that are associated with the call to stringr::str_detectrecursively

``` r
library(argtracer)

trace_args({
    stringr::str_detect("ab", "a")
})
```

repository: hyeyoungshin/argtracer

repo_name: hyeyoungshin/argtracer


text:
# Unit tests for roslaunch_to_dot

Use the following steps In order to add a new unit test module:

    1. Create a new python module under this (tests) directory
    2. Inside of the python module create a new class that sublasses unittest.TestCase
    3. Edit run_tests.py and import the python module you created along with all of the others
    4. Run the unit tests again

gha_language: Python


text:
Sequential Learning Paper

|  Year | Category  | Title  |
|---|---|---|
| NIPS2014	  | Seq2Seq with RNN  | [Sequence to Sequence Learning with Neural Networks](#nipsd2014)  |
| ICLR2015  | Attention and bi-RNN  | [Neural Machine Translation by Jointly Learning to Align and Translate](#iclr2015)  |
| ICML2015 | Hard and Soft attention | [Show, attend and tell: neural image caption generation with visual attention](#icml2015) |
| EMNLP2015 | Attention based NMT | [Effective Approaches to Attention-based Neural Machine Translation](#emnlp2015) |
| ACL2016  | Self-attention with LSTM  | [Long Short-Term Memory-Networks for Machine Reading](#acl2016)  |
| ICML2017 | Positional Encoding | [Convolutional Sequence to Sequence Learning](#icml2017) |
| NIPS2017  | Transformer with multi-head attention | [Attention Is All You Need](#nips2017)  |
| 2018    | GPT-1 | [Improving Language Understanding by Generative Pre-Training](#gpt1) |
| NAACL-HLT2019 | BERT | [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](#naacl2019) |
| 2019 | GPT-2 | [ Language models are unsupervised multitask learners](#gpt2) |
| NIPS2020 | GPT-3 | [Language Models are Few-Shot Learners](#nips2020) |

## [Sequence to Sequence Learning with Neural Networks](https://papers.nips.cc/paper/5346-sequence-to-sequence-learning-with-neural-networks.pdf)

Proposed neural machine translation and proposed the encoding/decoding architecture. The input first go through an encoder (Multilayer LSTM) to encode the information into a fixed length memory, then the information in the fixed length memory are feed to the decoder to get the output. Additionally, the model was feed with input sentence in the reverse order. The argument is that the reverse order can make it easy for SGD to "establish communication" between the input and the output. **This could be true for later words in the input sentence, but the information of the earlier words will loss even more, as they are further from the targets. However, the overall benefits are larger than the drawbacks.**

## [Neural Machine Translation by Jointly Learning to Align and Translate](https://arxiv.org/pdf/1409.0473.pdf)

Address the limitation of fixed length memory by extend the memory storage with an attention network (a feed forward net with 1 hidden layer). Additionally, both encoder/decoder are using bi-directional RNN to provide both the pre-context and post-context of the current target.

The output of the network is quantified as $g(y_{i-1}, s_i, c_i)$, where $s_i$ is the hidden state of the decoder and $c_i$ is the context vector, which is calculated as the weighted sum of the hidden states of the encoders, i.e. $c_i = \sum_{j=1}^{T_x} \alpha_{ij} h_j$. $\alpha_{ij}$ is the weight of hidden state of encoder at time j respect to the output of the decoder at time i, which is quantified as $\alpha_{ij} = softmax(e_{ik}). $e_{ik}$ is the output of the attention network (a MLP) by feeding $s_{i-1}$ and $h_k$ $e_{ik} = a(s_{i-1}, h_k)$.

## [Effective Approaches to Attention-based Neural Machine Translation](https://www.aclweb.org/anthology/D15-1166.pdf)

Proposed the global and local attention and integrate them into NMT.

For global attention, all the hidden state of the encoder are used when deriving the context vector $c_t$, i.e. $c_t = \frac{1}{n} \sum a_t \bar{h}_s$ ($\bar{h}_s$ as the source hidden state).

The alignment vector $a_t$ is quantified as the alignment function $a_t(s) = \frac{exp(score(h_t, \bar{h}_s))}{\sum_{s'}exp(score(h_t, \bar{h}_s))}$, where $score(h_t, \bar{h}_s) = h_t^T \bar{h}_s$ (dot) or $h_t^T W_a \bar{h}_s$ (general) or $W_a [h_t; \bar{h}_s]$ (concat). Once obtained the context vector $c_t$, the attentional hidden state of the target $\tilde{h}_t = tanh(W_c [c_t; h_t])$, and the final output $p(y_t | y_{<t}, x) = softmax(W_s \tilde{h}_t)$.

For local attention, $c_t$ is derived as the weighted average of the set of source hidden states within the window $[p_t - D, p_t + D]$, where $p_t$ is the aligned position for target word at time $t$ as $p_t$. There are two ways of setting $p_t$: 1) Monotonic alignment (local-m) by simply set $p_t = t$. 2) Predictive alignment (local-p) by set $p_t = S * sigmoid(v^T_p tanh(W_p h_t))$, where $v^T_p$ and $W_p$ are the parameters. The weight of each source hidden state $\bar{h}_s$ is then quantified as $a_t(s) = align(h_t, \bar{h}_s) exp (-\frac{(s-p_t)^2}{2\sigma_2})$, where $\sigma = \frac{D}{2}$.

## [Show, attend and tell: neural image caption generation with visual attention](https://www.aclweb.org/anthology/D15-1166.pdf)

TBA

## [Long Short-Term Memory-Networks for Machine Reading](https://arxiv.org/pdf/1601.06733.pdf)

Addressed the limitations of recurrent NNs: 1) Gradient vanish/exploding; 2) Unable to keep long term memory for earlier input in the sequence; 3) No reasoning over structure and no explicit relationship information retained among input tokens.

Improved the LSTM by keep all the history of the cell states $C = (c_1,...,c_{t-1})$ and the hidden states $H=(h1,...,h_{t-1})$. And the new cell state and hidden state are calculated based on the entire history in a weighted sum approach, i.e. $\tilde{h_t} = \sum_{i=1}^{t-1} s_i^t h_i$, where $s^t_i = softmax(a_i^t)$ and $a^t_i = v^T tanh(W_h h_i + W_x x_t + W_{\tilde{h}}\tilde{h_{t-1}})$.

## [Convolutional Sequence to Sequence Learning](https://arxiv.org/pdf/1705.03122.pdf)

Proposed a method that to conduct seq2seq learning entirely based on CNN. The benefit of leveraging CNN is to achieve the maximal parallelism during model training/inference.

TBA

## [Attention Is All You Need](http://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf)

Abandon recurrent NN and only use feed forward and attention mechanism for feature extraction for sequential data.

TBA

## [Improving Language Understanding by Generative Pre-Training](https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf)

TBA

## [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://www.aclweb.org/anthology/N19-1423.pdf)

TBA

## [Language Models are Unsupervised Multitask Learners](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)

TBA

## [Language Models are Few-Shot Learners](https://arxiv.org/pdf/2005.14165.pdf)

TBA

gha_language: Jupyter Notebook


text:
---
layout: post
title: "Population pyramid charts for the States of India"
description: "Population pyramid charts, and some observations about inter-state variation in age and sex distributions"
tag:
  - rstats
  - demographics
  - ggplot
---

I looked for [Population pyramid](https://en.wikipedia.org/wiki/Population_pyramid) charts for individual states online, to explore the inter-state variation in distributions of age and sex distributions, but couldn't find any. I was able to find the 2011 Census data at [data.gov.in](https://data.gov.in), and so, I started working on making some the population pyramid charts myself.

# Source Code
The data, code and the generated images are available at [github.com/sainathadapa/population-pyramid-states-india](https://github.com/sainathadapa/population-pyramid-states-india). Please feel free to create an issue at the github repo or comment here if any part of the code is unclear.

# Population Pyramid charts
While creating the charts, I remembered reading about the questionable utility of population distribution charts before, and after a little bit of searching, found [this post](http://www.randalolson.com/2015/07/14/rethinking-the-population-pyramid/) by Randal Olson. I created the standard pyramid chart for each state, and also a couple of charts described in the Randal Olson's post.

Here are the Population distribution charts for  the state of Andhra Pradesh (including Telangana):

You can find the graphs for all the states and union territories [here]({{ site.baseurl }}{% link _posts/2016-12-11-pop-charts-all.md %}).

# Population distribution charts for all the states, sorted by mean age:
This chart can be helpful in understanding the variation in age mix between different states.

Another chart, this time with traditional population pyramids:

# Chart to understand the variation in sex ratio among different age groups and states

*Post updated on 2018-05-08*


text:
---
layout: page
title: RoSE 2022
subtitle: Official web page of the 4th edition of the RoSE international workshop
---

# 4th International Workshop on Robotics Software Engineering (RoSE'22)

- Co-located with [ICSE 2022](https://conf.researchr.org/home/icse-2022)
- Virtual
- May 9, 2022
- Hosted on [Zoom](https://rwth.zoom.us/j/98769076002)

## Theme & Goals
Increasingly, challenging domains employ robotic applications. Yet, Robotics still is one of the most challenging domains for software engineering. Deploying robotics applications requires integrating solutions from experts of various domains, including navigation, path planning, manipulation, localization, human-robot interaction, etc. Integration of modules contributed by respective domain experts is one of the key challenges in engineering software-centric systems, yet only one of the cross-cutting software concerns crucial to robotics. As robots often operate in dynamic, partially observable environments additional challenges include adaptability, robustness, safety, and security.

The goal of RoSE 2022 is to bring together researchers from participating domains with practitioners to identify new frontiers in robotics software engineering, discuss challenges raised by real-world applications, and transfer latest insights from research to industry. RoSE 2022 will solicit contributions from both academic and industrial participants, thus fostering active synergy between the two communities.

## Topics of Interest

RoSE 2022 seeks contributions addressing, but not limited to, the following
topics related to robotics software engineering:
- Analysis of challenges in robotic software engineering
- Architectures that lead to reusable robotic software
- Challenges for defining and integrating domain-specific languages for the design of robotic systems
- Continuous integration and deployment in robotics
- Identification and analysis of design principles promoting quality of service (e.g., performance, energy efficiency)
- Engineering the collaboration of multiple (heterogeneous) robots
- Machine learning for safety-critical robotic systems
- Metrics to measure non-functional properties (e.g., robustness, availability, etc.) and their application in robotic software
- Best practices in engineering robotic software
- Variability, modularity, and reusability in robotic software
- Validation and verification of robotic software
- Processes and tools supporting the engineering and development of robotic systems
- State-of-the-art research projects, innovative ideas, and field-based studies in robotic software engineering
- Lessons learned in the engineering and deployment of large-scale, real-world integrated robot

## Keynotes

We are happy to host the following keynote speaker:

[Kristina Wagner](https://www.linkedin.com/in/dr-kristina-wagner/) - Senior Vice President Technology and Innovation Center & Director iiQKA (The Robot X-perience) at [KUKA AG](https://www.kuka.com/en-de)

## Workshop Program

**RoSE '22 is hosted on [Zoom](https://rwth.zoom.us/j/98769076002)**

Times are displayed in Central European Summer Time (CEST): Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna.

| Time | Title | Who |
| --- |  --- | --- |
| 10:00 AM | **Welcome to RoSE '22** | Ivano Malavolta |
| 10:15 | **iiQKA: KUKA’s new Operating System and Ecosystem** | Kristina Wagner |
| 11:00 | **Session 1:  Software architecture & robot programming** | *Chair: Andreas Angerer* |
| | On Structuring Energy-aware Sequence-control Software | Reynaldo Cobos Mendez, Eddo Hobert, Douwe Dresscher and Jan Broenink |
| | Software Architecture For Deformable Linear Object Manipulation: A Shape Manipulation Case Study | Manuel Zürn, Markus Wnuk, Armin Lechler and Alexander Verl |
| |  A skill fault model for autonomous systems | Gabriela Catalán Medina, Jérémie Guiochet, Charles Lesire and Augustin Manecy |
| | Dynamic Allocation of Service Robot Resources to an Order Picking Task Considering Functional and Non-Functional Properties | Timo Blender and Christian Schlegel |
| 12:00 | **Lunch break** | |
| 01:00 PM | **Session 2: Tomorrows' roboticists & robotic development toolchains** | *Chair: Ivano Malavolta* |
| |  An Experience Report on Challenges in Learning the Robot Operating System | Paulo Canelas, Miguel Tavares, Ricardo Cordeiro, Alcides Fonseca and Christopher S. Timperley |
| |  Should Robotics Engineering Education Include Software Engineering Education? | Milda Zizyte and Trenton Tabor |
| |  Towards flexible Runtime Monitoring Support for ROS-based Applications | Marco Stadler, Michael Vierhauser and Jane Cleland-Huang |
| |  Automated Extraction and Checking of Property Models from Source Code for Robot Swarms | Ettore Merlo, Carlo Pinciroli, Jacopo Panerati, Michalis Famelis and Giovanni Beltrame |
| | Evaluating PDDL for programming production cells: a case study | Christoph Mayr-Dorn, Alexander Egyed, Mario Winterer, Christian Salomon and Harald Fürschuß |
| 02:15 | **Break** | |
| 02:45 | **Interactive Session:** The evolution of RoSE | All participants, *Chair: Andreas Wortmann* |
| 03:45 | **Wrap-up & end of RoSE '22** | |

## Submission Guidelines

Prospective participants are invited to submit
- research papers presenting novel contributions on advancing software engineering in robotics (max. 8 pages);
- challenge showcase papers describing robotics challenges considered insufficiently addressed from an industry perspective (max. 6 pages);
- lessons learned papers describing lessons learned in the collaboration between the two communities of software engineering and robotics (max. 6 pages);
- vision papers on the future of software engineering in robotics (max. 4 pages);
- tool and project papers on software engineering in robotics (max. 4 pages).

Workshop papers must follow the [ICSE 2022 Format and Submission Guideline](https://conf.researchr.org/track/icse-2022/icse-2022-papers#Call-for-Papers), but will use a *single blind* submission process. All submitted papers will be reviewed on the basis of technical quality, relevance, significance, and clarity by the program committee. All workshop papers should be submitted electronically in PDF format through the [EasyChair workshop website](https://easychair.org/conferences/?conf=rose2022). Accepted papers will become part of the workshop proceedings.

## Important Dates
- Workshop paper submissions due: January 14, 2022 January 21, 2022 (AoE time)
- Notification to authors: February 25, 2022 (AoE time)
- Camera-ready copies due: March 18, 2022 March 22, 2022 (AoE time)
- Workshop: May 9, 2022

## Organizing Committee
- [Andreas Angerer](https://xitaso.com/) (XITASO GmbH, Germany)
- [Federico Ciccozzi](http://www.es.mdh.se/staff/266-Federico_Ciccozzi) (Mälardalen University, Sweden)
- [Ivano Malavolta](http://www.ivanomalavolta.com) (Vrije Universiteit Amsterdam, The Netherlands)
- [Andreas Wortmann](http://www.wortmann.ac/) (University of Stuttgart, Germany)

## Program Committee
* Alwin Hoffmann, XITASO GmbH, Germany
* Andrzej Wasowski, IT University of Copenhagen, Denmark
* Arne Nordmann, Robert Bosch GmbH, Germany
* Carlos Hernandez Corbato, TU Delft, The Netherlands
* Charles Lesire-Cabaniols, French Aerospace lab (ONERA), France
* Daniel Sykes, Ocado Technology, UK
* Darko Bozhinoski, Université libre de Bruxelles, Belgium
* David Garlan, Carnegie Mellon University, USA
* Davide Brugali, Università degli Studi di Bergamo, Italy
* Davide Di Ruscio, Università degli Studi dell'Aquila, Italy
* Ettore Merlo, Ecole Polytechnique of Montreal, Canada
* Floris Erich, National Institute of Advanced Industrial Science and Technology, Japan
* Holger Giese, Hasso Plattner Institute at the University of Potsdam, Germany
* Jan Broenink, University of Twente, The Netherlands
* Javier Camara, University of York, UK
* Jesús Martínez, Universidad de Málaga, Spain
* Juergen Dingel, Queen's University, Canada
* Michel Albonico, Vrije Universiteit Amsterdam, The Netherlands
* Moritz Tenorth, Magazino GmbH, Germany
* Nadia Hammoudeh Garcia, Fraunhofer Institute for Manufacturing Engineering and Automation IPA, Germany
* Nico Hochgeschwender, University of Applied Sciences Bonn-Rhein-Sieg, Germany
* Patrizio Pelliccione, Gran Sasso Science Institute, Italy
* Ricardo Sanz, Universidad Politecnica de Madrid, Spain
* Rogardt Heldal, HLV, Norway
* Sebastian Wrede, CoR-Lab, Bielefeld University, Germany
* Sebastiano Panichella, Zurich University of Applied Science (ZHAW), Germany
* Simos Gerasimou, York University, UK
* Ulrik Schultz, University of Southern Denmark, Denmark
* Trenton Tabor, Carnegie Mellon University, USA

## Call for Papers
- [Call for Papers (PDF)](https://github.com/rose-workshops/rose-workshops.github.io/raw/master/downloads/ROSE_2022_cfp.pdf)


text:
# Multi-Explore
Code for [*Coordinated Exploration via Intrinsic Rewards for Multi-Agent Reinforcement Learning*](https://arxiv.org/abs/1905.12127) (Iqbal and Sha, arXiv 1905.12127)

## Requirements
* Python 3.7.3
* [OpenAI baselines](https://github.com/openai/baselines), commit hash: 98257ef8c9bd23a24a330731ae54ed086d9ce4a7
* [PyTorch](http://pytorch.org/), version: 1.2.0
* [OpenAI Gym](https://github.com/openai/gym), version: 0.14.0
* [ViZDoom](https://github.com/mwydmuch/ViZDoom), version: 1.1.7
* [Tensorboard](https://github.com/tensorflow/tensorboard), version: 1.14.0 and [Tensorboard-Pytorch](https://github.com/lanpa/tensorboard-pytorch), version: 1.8 (for logging)

The versions are what were used in this project but are not necessarily strict requirements.

## How to Run

All training code is contained within `main.py`. To view options simply run:

```
python main.py --help
```

All hyperparameters can be found in the Appendix of the paper. Default hyperparameters are for Task 1 in the GridWorld environment using 2 agents.

## Citing our work

If you use this repo in your work, please consider citing the corresponding paper:

```
@article{iqbal2019coordinated,
  title={Coordinated Exploration via Intrinsic Rewards for Multi-Agent Reinforcement Learning},
  author={Iqbal, Shariq and Sha, Fei},
  journal={arXiv preprint arXiv:1905.12127},
  year={2019}
}
```

repository: PeterZs/Multi-Explore

repo_name: PeterZs/Multi-Explore


text:
---
layout: page
title: Lean Prover Zulip Chat Archive
permalink: archive/113488general/93712lists.html
---

## [general](index.html)
### [lists](93712lists.html)

#### [Andrew Ashworth (Feb 28 2018 at 02:57)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123069986):
```lean
theorem append_inj : ∀ {s₁ s₂ t₁ t₂ : list α}, s₁ ++ t₁ = s₂ ++ t₂ → length s₁ = length s₂ → s₁ = s₂ ∧ t₁ = t₂
| []      []      t₁ t₂ h hl := ⟨rfl, h⟩
| (a::s₁) []      t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl
| []      (b::s₂) t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl.symm
| (a::s₁) (b::s₂) t₁ t₂ h hl := list.no_confusion h $ λab hap,
  let ⟨e1, e2⟩ := @append_inj s₁ s₂ t₁ t₂ hap (succ.inj hl) in
  by rw [ab, e1, e2]; exact ⟨rfl, rfl⟩
```
why is `length s1 = length s2` required explicitly as a hypothesis?

#### [Mario Carneiro (Feb 28 2018 at 02:58)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070028):
It's not true otherwise

#### [Andrew Ashworth (Feb 28 2018 at 03:01)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070123):
ahh. i guess you'd only have a weaker conclusion without the length requirement, that two lists exist that are subsets of `s1 ++ t1`

#### [Mario Carneiro (Feb 28 2018 at 03:02)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070167):
Of course that's a trivial consequence, `s1` and `t1` are such

#### [Simon Hudon (Feb 28 2018 at 03:02)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070172):
If you don't want the length assumption, you could prove `s0 ++ t0 = s1 ++ t1 -> s0 = t0 -> s1 = t1`

#### [Mario Carneiro (Feb 28 2018 at 03:03)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070183):
I guess that follows from this pretty easily, since if `s0 = t0` then `length s0 = length t0`

#### [Simon Hudon (Feb 28 2018 at 03:04)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070223):
Yeah, you're right! What was I thinking :stuck_out_tongue:

#### [Andrew Ashworth (Feb 28 2018 at 03:04)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070224):
yeah it's something i'm having an issue with, I'm trying to prove that list reversal is injective from scratch

#### [Mario Carneiro (Feb 28 2018 at 03:04)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070226):
The easiest way is to note that `reverse` is an involution

#### [Andrew Ashworth (Feb 28 2018 at 03:05)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070245):
```lean
lemma rev_involutive : ∀ l : list ℕ, rev (rev l) = l
| nil := rfl
| (x::xs) := by simp [*, rev, rev_step, rev_distrib]
```

#### [Mario Carneiro (Feb 28 2018 at 03:06)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070293):
actually, another way, using that theorem, is to use the mirror version that assumes `length t1 = length t2`; then you get that `concat` is injective since the right parts have length 1

#### [Andrew Ashworth (Feb 28 2018 at 03:07)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070304):
somebody had a prose proof in a conference paper i'm reading of how you can automatically prove injectivity of list reversal, and it's not working for me, haha

#### [Andrew Ashworth (Feb 28 2018 at 03:08)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070355):
the concat def is really slick in core lib, i was trying to avoid using it

#### [Andrew Ashworth (Feb 28 2018 at 03:14)](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/lists/near/123070515):
EDIT: I can't read good, they assume the lengths are equal in the pseudocode figure


text:
# AirRivet Pods

__AirRivet__ is a service layer build in Swift by using generics. The idea is that you have `Air` which is a class that performs the request for an `Environment`. To do this it needs a Type called `Rivet` that can be handeled over the `Air` 🤔. So how do we make this `Rivet` Type?

`AnyThing` can be a `Rivet` if they are `Rivetable`. `Rivetable` is a combination of protocols that the Rivet (Type) has to conform to. The `Rivet` is `Rivetable` if:

- `Mitigatable` -> Receive requests to make anything that can go wrong less severe.
- `Parsable` -> You get Dictionaries that you use to set the variables
- `EnvironmentConfigurable` -> We could get the data over the `Air` from a _production_ or a _development_ environment
	- There is also a special case where the environment is `Mockable` then your request are loaded from local files _(dummy files)_
- `UniqueAble` -> If your `AnyThing` is in a _collection_ you can find your entitiy by complying to `UniqueAble`

If you do the above (there are default implementation provided in the example).

repository: fousa/ios-air-rivet

repo_name: fousa/ios-air-rivet


text:
**Deploy policies and workflows to maintain application security at the scale of a repository.**

The policy takes part in awareness by communicating useful information:
- [.github/SECURITY.md](.github/SECURITY.md)
  - communicate application security policy

The workflow automates the maintenance of application security:
- [.github/workflows/dependabot.yml](.github/workflows/dependabot.yml)
  - maintain open-source dependencies with **Dependabot** (https://github.com/dependabot)
- [.github/workflows/nuclei.yml](.github/workflows/nuclei.yml)
  - maintain dynamic application security testing with **Nuclei** (https://github.com/projectdiscovery/nuclei)
- [.github/workflows/codeql.yml](.github/workflows/codeql.yml)
  - maintain static application security testing with **CodeQL** (https://github.com/github/codeql)

The DAST and SAST workflows send data to Slack and DataDog for further investigation.

repository: mejoiom/appsec-actions

repo_name: mejoiom/appsec-actions


text:
---
title: Release Notes for 0.1.7 PREVIEW
sidebar: overview_sidebar
keywords: introduction
permalink: rn_0107p.html
toc: false
tags: [getting_started]
folder: introduction
---

### 0.1.7 PREVIEW

Version | Handle  | Phase | State           | Release Date | Stability
--------|---------|-------|-----------------|--------------|----------------
0.1.7   | PREVIEW | Alpha | Released | 05/04/2019   | Volatile

The 0.1.7 PREVIEW release has the following highlights:

* A Detailed work through of a complex workflow was added to the GP Connect section
* A new section for appointment management (Cancel and Rebook) was created
  * This includes a section on technical architecture and workflow
* New content for the demonstrator guidance was added


text:
Core Estimator
==============

Core Estimator is a cross-browser polyfill for [navigator.hardwareConcurrency](https://html.spec.whatwg.org/multipage/workers.html#navigator.hardwareconcurrency).

The estimator works by performing a timing attack that runs different numbers of simultaneous web workers. It measures the time it takes to run a single worker and compares this to the time it takes to run an increasing number of workers. As soon as this measurement starts to increase excessively, it has found the maximum number of web workers which can be run simultaneously without degrading performance.

[Live demo](http://wg.oftn.org/projects/core-estimator/demo/)
-----------

Core Estimator only provides an estimate of the number of cores on your machine. The value may fluctuate depending on the system load caused by other programs currently running.

API
---

void navigator.getHardwareConcurrency(function callback(int cores), optional function progress(int min, int max, int cores))

Estimates the number of cores and passes the estimate to the callback. If navigator.hardwareConcurrency is is already available (either native API or it was previously estimated), it immediately calls the callback. Use progress if you're interested in the progress of the estimation as it completes.

int navigator.hardwareConcurrency

Either the number of logical or physical CPU cores the user's device has. Which it is depends on if estimation is used. If the browser does not natively support navigator.hardwareConcurrency, this will only be available after running navigator.getHardwareConcurrency() once.

Using Core Estimator
--------------------

To install, place `core-estimator.js`, `workload.js`, and the `nacl_module` folder in the same public directory.

Include `<script src="/path/to/core-estimator.js"></script>` in the pages you wish to use the Core Estimator API.

Supported browsers
------------------

* Firefox
* Firefox 48 (Native)
* Chrome (Native)
* Safari (Native)
* Internet Explorer 10+
* Opera (Native)
* Edge (Native)

Forward compatibility
---------------------

In the future, when browser vendors implement `navigator.hardwareConcurrency` natively, Core Estimator will automatically detect and use the native method instead of estimating the number of cores.

repository: michaelhansroul/CAPTEUR

repo_name: michaelhansroul/CAPTEUR


text:
# cgm_flask

Installation and Run
in terminal:

`$ pip3 install -r requirements.txt`

Requires cgm_flask directory in PYTHONPATH

in terminal in cgm_flask directory:

`$ export PYTHONPATH=$PWD`

Starting App:

`$ export FLASK_APP=run.py`

`$ flask run`

Viewing output: localhost:5000/api/devices

To view the SQL databases:

`$mySQL -u USER -p [return]
$[key symbol] type PW [return]
$show databases`

Example POST route:

`$ http POST :5000/api/devices model=notTotesFake manufacturerID=3030XYZ user_id=1`

  yields:
    HTTP/1.0 200 OK
    Content-Length: 153
    Content-Type: application/json
    Date: Tue, 05 Sep 2017 05:29:30 GMT
    Server: Werkzeug/0.12.2 Python/3.6.1

    {
        "data": {
            "device: ": {
                "id": 3,
                "manufacturerID": "3030XYZ",
                "model": "notTotesFake"
            }
        },
        "message": "New device created"
    }

To migrate data (update db). We are using flask-migrate to manage the
database. flask-migrate will create a table named "alembic_version" in your database.

`$ flask db migrate` (does nothing useful after the first use. It compares the models.py to the database state. Then it writes a file that tells the db how to go from current state to the state we want. It stores the file name in the alembic_versions table in the db. It DOES create a new file in migrations/versions.)

`$ flask db upgrade` (up-grades the db to have the useful stuff)

TESTS!!

remove any __pycache__ files from /test to ensure that
previous tests do not give false positive/negative

`$ export PYTHONPATH=$PWD`

`pytest`


text:
# Licensearch - API no longer available

This gem hooks into the licensearch.com API for state licenses.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'licensearch'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install licensearch

## Usage

You must set the token environment variable to use this gem.

1. Sign up at http://www.licensearch.com
2. Get your token and set it as follows: `export TOKEN=abc123`
3. Query away!

```ruby
require 'licensearch'

Florida::Business.query({name: 'test'})
```

## Development

API docs can be found here: http://www.licensearch.com/build/index.html

Running specs: `rspec spec`

## Contributing

Please make an issue with a bug.

Please read the docs (http://www.licensearch.com/build/index.html) and contribute to building out this gem.

## License

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


text:
---
layout: post
title:  "jupyter 小试"
date:   2017-11-30
tags: [note]
commentIssueId: 65
---

## Install jupyter
* Download `get-pip.py` from [https://bootstrap.pypa.io/get-pip.py](https://bootstrap.pypa.io/get-pip.py)
* `sudo python get-pip.py`
* `pip install --user jupyter`
* `cd /Users/xxx/Library/Python/2.7/bin`
* `./jupyter notebook`

## References
* [pip](https://pip.pypa.io/en/stable/installing/)
* [jupyter](http://jupyter.org/install.html)

repository: zhoukekestar/notes

gha_language: HTML

repo_name: zhoukekestar/notes


text:
---
layout: post
title:  "Overlooked Tools: xclip"
categories: command-line
tags: ubuntu linux xclip command clipboard overlooked
---

If you have ever had a need to move the output of a Linux console command to your clipboard, `xclip` is the solution!

To copy a file's contents to the standard "ctl+c/v" clipboard buffer issue you can following this command:

```bash
xclip -sel clip your-file-path
```

The most useful feature is reading from a stdin pipe:

```bash
head my-file-path | xclip -sel clip
```

...and then your ready to paste into an email or Slack chat.

This functionality is especially useful for programatically providing 2-factor authentication tokens to command-line or browser based logins!


text:
# Azure template for instantiating and deploying a standalone Red Hat JBoss EAP on OCP on Azure

**NOTE: This template creates an ephemeral instance of OpenShift Container Platform and Red Hat JBoss EAP. You are responsible for backing up any data that you want to save while using this instance**

1. Create a Single VM OpenShift deployment using the Azure Portal

------

This template deploys OpenShift Container Platform on Azure.

![Console](images/parameters.png)

#### Subscription
Accept the default subscription ID value. Note: this field is not shown in the picture above.

#### Resource Group
Select "Create new" resource group if one does not currently exist. Enter "ocp" or a name of your choosing in the input field.

#### Location
The geographic location in which to deploy OpenShift Container Platform.

#### Admin User
Supply a username which will be used for SSH access,OpenShift Container Platform web console, JBoss EAP Admin .

#### Admin Password
Supply a password which will be used for the Openshift Container Platform web console.

#### Rhsm User
Red Hat user name to be used for system registration.

#### Rhsm Password
Red Hat password to be used for system registration.

#### Rhsm Pool
Subscription pool to be used for the installation. This apha-numeric value can be found under https://access.redhat.com/management/products

#### Ssh Key Data
You will need a SSH RSA public key for access if one currently does not exist on your system. Please supply your Public SSH key only.
For example, in Linux the key can be located at ~/.ssh/id_rsa.pub. Make sure to copy and paste the **ENTIRE** contents of the file ~/.ssh/id_rsa.pub into this input field.

#### Vm Size
Specify a VM size. A default value is provided. If another size or type of vm is required ensure that the Location contains that instance type.

Once all of these values are set, then check the box to "Agree to the terms and conditions" and then click the Purchase button.

**Acknowledgements: Thanks to the following individuals for the base template: Daniel Falkner, Glenn West, Harold Wong, and Ivan McKinley**

2. Deploy OpenShift Openshift Container Platform template to Azure

A notification will pop up in the top right notifying you of the deployment:

The deployment will take about 50 minutes. Once completed, the notification will display:

Click on "Go to resource group" button in the notification above to open up the window for the origin resource group (or you can also click on the "Resource groups" under "Favorites" on the leftmost vertical Azure portal menu, and then click on "ocp" to open the ocp resource group). You will see the following:

On the top right of the origin resource group window, you will see a heading "Deployments".  Click on "1 Succeeded" under this heading to see the deployments:

Now, click on the "Microsoft.Template" link to display the contents of the template.  Then click on the "Outputs" to see the URL of the OpenShift Origin console:

At this point, copy the string from the "OPENSHIFTCONSOLE" field, open a browser window and paste the string in the Address field. If your browser warns you about the site being insecure, go ahead and continue to the insecure site.  At this point, you should see the login prompt to log in to the all-in-one OpenShift Origin cluster:

For Username and Password, the "Admin User" and "Admin Password" you supplied in the template above. Click on "Log In" and you should see:

Once you login into the Openshift Console, you shoud have a preconfigured project listed on the right hand side of the console

Click on Applications, select Deployments and from the table on the right click on dukes,select the #1 Deployment and you will be able to see the number of instances/pods that are running of the application, status, creation date,configuration, etc.

To access the webapp go to Applications and select Routes. Routes is the way Openshift Container Platform exposes services at a host name, you shoud see the url for dukes. Click on it and goto the context dukes.

You should see the webapp dukes. You have just installed Openshift Container Platform, Red Hat Enterprise Application Paltform and a webapp called dukes.


text:
Sunshine Watch Face
===================
Watch Face for the Sunshine app. Project 6 of Android Programming Nanodegree by Udacity.

Synchronizes weather information from OpenWeatherMap on Android Phones and Tablets.
Create an api key from OpenWeatherMap and import it to gradle.properties like:
MyOpenWeatherMapApiKey="myKey"

License
-------
http://www.apache.org/licenses/LICENSE-2.0

repository: pdrogfer/Sunshine-Watch-Face

repo_name: pdrogfer/Sunshine-Watch-Face


text:
# CRUD interface for tables

A few tables can be edited manually from the admin panel. This allows **News** items
to be posted, **species** to be edited (e.g. change color, add description). Furthermore,
names of **methods** (which appear on the website) can be altered or corrected when required.

## Condition Tissue table

One feature that can be enabled only through the CRUD interface is the comparative heatmap and heatmaps in phylogenetic trees. In the Condition Tissue table, set the field **in_tree** to true for tissues you want to compare. Note that this will **only** work for broad categories defined through the **Tissue Specificity** section (and will result in errors when **Condition Specificity** is used).

repository: sepro/CoNekT

repo_name: sepro/CoNekT


text:
# san Integration Pack
## Configuration
Copy the example configuration in [san.yaml.example](./san.yaml.example) to
`/opt/stackstorm/configs/san.yaml` and edit as required.

It must contain:

```
fortinet_ip - Your Fortigate appliance IP address
fortinet_username - Fortigate Firewall Username
fortinet_password - Fortigate Firewall Password
```

You can also use dynamic values from the data store. See the
[docs](https://docs.stackstorm.com/reference/pack_configs.html) for more info.

Example configuration:

```yaml
---
  fortinet_ip: "<IP_ADDRESS>"
  fortinet_username: "admin"
  fortinet_password: "admin"
```

**Note** : When modifying the configuration in `/opt/stackstorm/configs/` please
           remember to tell StackStorm to load these new values by running
           `st2ctl reload --register-configs`

## Actions

The following actions are supported:
* ``fortinet_add_address_to_group``
* ``fortinet_create_firewall_rules``
* ``create_firewall_policy``
* ``get_list_firewall_services``
* ``install_policy_package``

## Workflow:

The following Workflow are supported:
* ``create_firewall_policy``
* ``fortinet_firewall_wf``
* ``checkpoint_firewall_wf``
* ``paloalto_firewall_wf``

repository: esans/EWC-packs

repo_name: esans/EWC-packs


text:
#The Blog

Simple app that displays blog posts

- The project was setup with configuration files in order to facilitates the edition of some settings as the API base url.
- The project uses the Ivorywhite framework as an abstraction to the network client library. The Ivorywhite framework is under development by me as well in a different repo.
- The Services module has the implementations of the Ivorywhite protocols and the BlogApi service used by the main app.
- There is a specific worker for downloading images, it is called ImageWorker. The image cache is injected to this worker in order to avoid redownloading the displayed images.
- It is assumed that all posts have an imageURL. If this url is broken some way, the app displays an image placeholder. I'd rather display a different cell with no imageView.
- I concentrated the unit tests on the business logic, that being said, the total test coverage is still low, around 24%.
- The Services and DesignSystem frameworks were created in a project subfolder in order to keep the code in one repo. The only exception is the Ivorywhite module as it is in development as a separated project.

## Installation

Run the following command in the directory of the TheBlog and Services projects in order to install the dependency.

```ogdl
carthage bootstrap
```

App icon made by Flat Icons - https://www.flaticon.com

repository: marcio-garcia/TheBlog

repo_name: marcio-garcia/TheBlog


text:
![Minter SDK header](/docs/mintersdkhead.png)

[![](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)

## Notice

This software is in beta. At the moment, the smart contracts
that OpenMinter uses have **not** been formally audited. Please
use this software at your own risk.

## Minter SDK

Minter SDK offers a set of tools and libraries to bring creation, management, and sales of NFTs to any application.

Minter SDK aims to include the following
- A collection of NFT and marketplace smart contracts with configurable admin permissions
- Typescript bindings to enable easy integration into popular web frameworks
- An NPM module that allows users to interact with tokens programmatically
- A CLI for minting and configuring NFT / marketplace contracts
- [DIDkit](https://www.spruceid.com/didkit) integration for verified creator credentials

## Smart Contracts

### [Minter Collection](contracts/ligo/src/minter_collection)
Customizable smart contracts for minting FA2 NFTs as collections.

### [English Auction](contracts/ligo/src/english_auction)
An implementation of an English auction marketplace that allows users to initiate auctions of NFTs in either tez or FA2. There are
two versions of this contract: one with administration capabilities and one without. For now, in the positive case, this means that
a configured administrator is responsible for configuring and managing access to important entrypoints.

### [Fixed Price Sale](contracts/ligo/src/fixed_price_sale)
An implementation of an NFT marketplace that allows users to initiate NFT sales at a fixed price in tez or FA2. These contracts can be configured based on a range of administrative options.

### [Ticket-based NFTs](contracts/ligo/src/tickets)

**EXPERIMENTAL** An implementation of NFTs using tickets and a dutch auction example, along with wallet contracts for the NFTs.
*Please note: tickets are a new Tezos feature and care should be taken when using them as they have not been heavily tested in production.*

### Work-in-progress

#### Edition contracts ([WIP](https://github.com/tqtezos/minter-sdk/pull/46))

#### Meta-transaction based minting / sales ([WIP](https://github.com/tqtezos/minter-sdk/pull/33))

#### Fractional Ownership ([WIP](https://github.com/tqtezos/smart-contracts/pull/57))

#### Royalties and Profit-splitting ([WIP](https://github.com/tqtezos/minter-sdk/pull/40))


text:
# Crypto Chat

It is simple web-based messenger that provides end-2-end encryption based on
WebAssembly build of libsodium. It was made as part of my school project
related to cryptography and open for usage and education.

It consists 2 parts:

* Backend
* Fronten

## Backend

It is small NodeJS based app. It transfer encrypted messenges form client to client and when new clients connect
it notifies connected client about it to update roster.

It is based on Socket.io.

## Frontend

It is based on React and uses Materialize CSS to provide responsive and modern looking UI.
For cryptography it uses WebAssembly build of libsodium.

repository: kotyagood/crypto-chat

repo_name: kotyagood/crypto-chat