text:
iter
====

  Iter is a functional helper library for ES6 iterables. It's API is similiar to
Underscore JS, with a few key differences. First it'll Iterate over any ES6
iterable or iterator, or any transpiled iterable or iterator from the Traceur
ES6 Transpiler. Second, it's lazy by default...

Getting Started
===============

In NodeJS
---------
  In your project directory run:
    npm install --save es6-iter

  Start your Node program with the command line argument --harmony. Then use it
like so:
    var iter = require('es6-iter').iter;

    // A convoluted way to print 'Hello World'
    iter(function*() { yield 'hello world!' })
      .forEach(function(string) {
        console.log(string);
      })
      .array();

In the Browser
--------------

### Installing It
  If you have Bower installed, in your project directory run:

    bower install es6-iter

  If you have Git installed, in your project directory run:

    git clone https://github.com/jdt/es6-iter

  Otherwise find the download repo button on this page and save it to your
project directory.

### Consuming It

#### Inside an ES6 JS File

  Loading Iter in any ES6 environment is the simplest way to get the library.

    import iter from 'es6-iter/src/iter';
    console.log(iter([1,2,3]).array()); // Prints 1, 2, 3

#### With System Polyfill from Traceur

  You can load Iter as a script that injects it's packages into the System
polyfill used by Traceur. This is the suggested way to consume Iter in an ES5
JS environment given you have to load the Traceur runtime as a dependency to
Iter. To do this you include the runtime and bundled script in your HTML page:

    <script src="es6-iter/node_modules/traceur/bin/traceur-runtime.js"></script>
    <script src="es6-iter/out/system/iter.js"></script>
    <script>
      (function() {
        console.log(iter([1,2,3]).array()); // Prints 1, 2, 3
      })();
    </script>

#### With AMD

  Add iter and traceur-runtime to your requirejs config as a package:

    requirejs.config({
      paths: {
        'traceur': 'es6-iter/node_modules/traceur/bin/traceur-runtime'
      },
      packages: [
        { name: 'iter', main: 'index.js', location: 'es6-iter/out/amd', }
      ]
    })

  Use it in any of your modules like so:

    define(['iter'], function(iter) {
      iter = iter.iter;

      // Prints 1, 2, 3
      console.log(iter([1,2,3]).array());
    })


text:
---
title: secuinside CTF Quals 2013 bigfile of secret writeup
author: ray
layout: post
permalink: /secuinside-ctf-quals-2013-bigfile-of-secret-writeup/
categories:
  - Uncategorized
---
The file to download is huge, but we can use an HTTP range request to download the last part of the file. `curl` has a dedicated option to specify the `Range` header:

    curl -r -500 http://<IP_ADDRESS>/secret_memo.txt

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
unix-utilities
==============

Various small Unix utilities for ~/bin

These are all meant to work on ubuntu 13.10.
Most but not all will work on other Unix distributions.
If you have patches to make them work elsewhere, send them via pull request or another convenient method.

Some of them are simple bash scripts, others are written in ruby and require proper libraries to be installed.

Inspired by https://github.com/taw/unix-utilities

gha_license_id: MIT


text:
Hackathon Starter REST
=======================

[![Dependency Status](https://david-dm.org/avoup/hackathon-starter-rest/status.svg?style=flat)](https://david-dm.org/avoup/hackathon-starter-rest) [![devDependencies Status](https://david-dm.org/avoup/hackathon-starter-rest/dev-status.svg)](https://david-dm.org/avoup/hackathon-starter-rest?type=dev) [![Build Status](https://travis-ci.com/avoup/hackathon-starter-rest.svg?branch=master)](https://travis-ci.com/github/avoup/hackathon-starter-rest)

Inspired by https://github.com/sahat/hackathon-starter

A boilerplate for **Node.js** REST api.

When starting a new project until you get to the best part of it you have to go through setting it up and adding all the necessary features like authentication with json web token, social authentication, deciding on json request/response format and the list goes on.

Goal of hackathon-starter-REST (HSR) is to skip through all this steps and get to the interesting part of a project quicker.

The code is as simple as it gets, it is thoroughly documented and can be easily changed to suit your needs.

Table of Contents
-----------------

- [Hackathon Starter REST](#hackathon-starter-rest)
  - [Table of Contents](#table-of-contents)
  - [Features](#features)
  - [Prerequisites](#prerequisites)
  - [Getting Started](#getting-started)
  - [API Keys](#api-keys)
  - [Project Structure](#project-structure)
  - [List of Packages](#list-of-packages)
    - [Dependencies](#dependencies)
    - [devDependencies](#devdependencies)
  - [API Endpoints, requests and responses](#api-endpoints-requests-and-responses)
    - [Login](#login)
    - [Signup](#signup)
    - [Resend verification mail](#resend-verification-mail)
    - [Verify email](#verify-email)
    - [Forgot password](#forgot-password)
    - [Reset password](#reset-password)
  - [Deployment](#deployment)
    - [Deployment to Heroku](#deployment-to-heroku)
    - [Hosted MongoDB Atlas](#hosted-mongodb-atlas)
  - [Contributing](#contributing)
  - [License](#license)

Features
--------

- **Local Authentication**
- **OAuth 2.0 Authentication**
  - Google
  - more will be added...
- **Account Management**
  - Forgot password
  - Reset password
  - Verification via email using jwt (sendgrid)
  - Auth via jwt
- **JSON:API request/response structure**
- **File upload**
- **Global error handler**

**Note**: list is not exhaustive and more features will be added.

Prerequisites
-------------

- [MongoDB](https://www.mongodb.com/download-center/community) *
- [Node.js](http://nodejs.org) *
- [Git](https://git-scm.com/)

**Note**: required prerequisites are marked by *

Getting Started
---------------

In your terminal type:

```bash
# Clone from Github
git clone https://github.com/avoup/hackathon-starter-REST.git myproject

# Change directory
cd myproject

# Install NPM dependencies
npm install

# Start your app
# Regularly
npm start
# In development mode (starts nodemon)
npm run dev
```

API Keys
------------------

In order to use OAuth methods and APIs in the project, you will have to obtain credentials and set them as environment variables in .env file.

**Note:** The app will read environment variables from .env file not .env.example file. You can use.env.example file to set up your .env file.

- Visit Google Cloud Console
- Click on the **Create Project** button
- Enter *Project Name*, then click on **Create** button
- Then click on *APIs & auth* in the sidebar and select *API* tab
- Click on **Google+ API** under *Social APIs*, then click **Enable API**
- Click on **Google Drive API** under *G Suite*, then click **Enable API**
- Click on **Google Sheets API** under *G Suite*, then click **Enable API**
- Next, under *APIs & auth* in the sidebar click on *Credentials* tab
- Click on **Create new Client ID** button
- Select *Web Application* and click on **Configure Consent Screen**
- Fill out the required fields then click on **Save**
- In the *Create Client ID* modal dialog:
 - **Application Type**: Web Application
 - **Authorized Javascript origins**: http://localhost:8080
 - **Authorized redirect URI**: http://localhost:8080/auth/google/callback
- Click on **Create Client ID** button
- Copy and paste *Client ID* and *Client secret* keys into `.env`

**Note:** When you ready to deploy to production don't forget to
add your new URL to *Authorized Javascript origins* and *Authorized redirect URI*,
e.g. `http://my-awesome-app.herokuapp.com` and
`http://my-awesome-app.herokuapp.com/auth/google/callback` respectively.
The same goes for other providers.

You can use SendGrid for sending emails.  The developer tier allows you to send 100 free emails per day.  As an Alternative to SendGrid, you may also choose to use an SMTP service provider.  If using SendGrid:
- Go to https://sendgrid.com/user/signup
- Sign up and **confirm** your account via the *activation email*
- Then enter your SendGrid *API Key* into `.env` file as SENDGRID_API_KEY

Project Structure
-----------------

| Name                   | Description                                                  |
| ---------------------- | ------------------------------------------------------------ |
| **config**/passport.js | Passport authentication strategies.                          |
| **controllers**/       | Controllers.                                                 |
| **models**/User.js     | Mongoose schema and model for User.                          |
| .env.example           | Environmental variables example file.                        |
| .gitignore             | Folder and files to be ignored by git.                       |
| .travis.yml            | Configuration file for build and test on travis-ci.          |
| app.js                 | The main application file.                                   |
| package.json           | NPM dependencies.                                            |
| package-lock.json      | Contains exact versions of NPM dependencies in package.json. |

List of Packages
----------------

### Dependencies
| Package                | Description                                        |
| ---------------------- | -------------------------------------------------- |
| @sendgrid/mail         | Library for using Sendgrid api                     |
| bcryptjs               | Library for hashing and salting user passwords     |
| chalk                  | For stileing terminal output.                      |
| compression            | For compressing response data                      |
| cors                   | For enabling cors                                  |
| dotenv                 | For loading environment variables from .env file   |
| express                | Express js                                         |
| helmet                 | For setting http headers                           |
| jsonwebtoken           | For generating and decripting jwt tokens           |
| mongoose               | For connecting to a mongodb                        |
| morgan                 | For logging requests                               |
| multer                 | For handling file uploads                          |
| passport               | For handling authentication                        |
| passport-google-oauth2 | For handling google auth                           |
| passport-jwt           | For authenticating using jwt                       |
| passport-local         | For handling authentication with mail and password |
| validator              | For validating and sanitizing request data         |

### devDependencies
| Package   | Description                            |
| --------- | -------------------------------------- |
| chai      | Assertion library                      |
| mocha     | Test framework                         |
| nodemon   | For restarting server on change        |
| sinon     | Standalone test spies, stubs and mocks |
| supertest | HTTP testing                           |

API Endpoints, requests and responses
----------

### Login

`POST /auth/login` - Post email and password and get jwt token

Controller: `controllers/auth.js - postLogin`

Request:
```json
Content-Type: application/json
Accept: application/json

{
  "data": {
    "attributes": {
      "email"<EMAIL_ADDRESS>      "password": "1234"
    }
  }
}
```
**Success** response:
```json
Content-Type: application/json
201 OK

{
  "data": {
    "type": "jwt bearer token",
    "id": "<JWT.TOKEN>",
    "attributes": {
      "expiresIn": "1h"
    }
  }
}
```
**Fail** response:
```json
Content-Type: application/json
401 Unauthorized

{
    "meta": {
        "path": "/auth/login"
    },
    "errors": [
        {
            "status": "422",
            "title": "validationerror",
            "detail": "Invalid password."
        }
    ]
}
```

### Signup

`POST /auth/signup` - Registers user and sends verification email, user won't be able to login until email is verified. It can be disabled by not calling ```sendVerify``` function in signup controller and setting ```isVerified: true``` when creating new user.

Controller: `controllers/auth.js - postSignup`

| Property          | Description                         |
| ----------------- | ----------------------------------- |
| email *           | email address                       |
| password *        | password                            |
| confirmPassword * | confirm password                    |
| redirect          | URL for email verification redirect |

\* - required property

Request:
```json
Content-Type: application/json
Accept: application/json

{
  "data": {
    "attributes": {
        "email"<EMAIL_ADDRESS>        "password": "1234",
        "confirmPassword": "1234",
        "redirect": "http://domain.com/"
    }
  }
}
```
**Success** response:
```json
204 No Content
```

**Fail** response:
```json
Content-Type: application/json
422 Unprocessable Entity

{
    "meta": {
        "path": "/auth/signup"
    },
    "errors": [
        {
            "source": {
                "pointer": "/data/attributes/confirmPassword"
            },
            "status": 422,
            "title": "validationerror",
            "detail": "Passwords do not match"
        }
    ]
}
```

### Resend verification mail

`POST /auth/resend` - Resends verification mail. It's using jwt token. As you can't manually invalidate jwt token, previously sent tokens will be valid too until they expire, expiration time can be set in .env file.

Controller: `controllers/auth.js - resendVerify`

| Property | Description                         |
| -------- | ----------------------------------- |
| email *  | email address                       |
| redirect | URL for email verification redirect |

\* - required properties

Request:
```json
Content-Type: application/json
Accept: application/json

{
  "data": {
    "type": "users",
    "attributes": {
        "email"<EMAIL_ADDRESS>        "redirect": "http://domain.com/"
    }
  }
}
```
**Success** response:
```json
204 No Content
```

**Fail** response:
```json
Content-Type: application/json
422 Unprocessable Entity

{
    "meta": {
        "path": "/auth/resend"
    },
    "errors": [
        {
            "status": "422",
            "title": "Error",
            "detail": "Email is already verified."
        }
    ]
}
```

### Verify email

`GET /auth/verify?token=<jwt.token>` - Verifies mail if valid jwt token is provided.

Controller: `controllers/auth.js - verifyEmail`

| Query   | Description |
| ------- | ----------- |
| token * | JWT token   |

\* - required properties

### Forgot password

`POST /auth/forgot` - If account with the provided email exists sends password reset token to that email.

Controller: `controllers/auth.js - forgotPassword`

| Property | Description                     |
| -------- | ------------------------------- |
| email *  | email address                   |
| redirect | URL for password reset redirect |

\* - required properties

**Note**: redirect page should be capable of extracting query `?token` from url and making POST request for password reset (see `POST /auth/reset`).

Request:
```json
Content-Type: application/json
Accept: application/json

{
  "data": {
    "attributes": {
        "email"<EMAIL_ADDRESS>        "redirect": "http://somedomain.com/password-reset/"
    }
  }
}
```
**Success** response:
```json
204 No Content
```

**Fail** response:
```json
Content-Type: application/json
422 Unprocessable Entity

{
    "meta": {
        "path": "/auth/forgot"
    },
    "errors": [
        {
            "status": "404",
            "title": "notfound",
            "detail": "Account with that email address was not found"
        }
    ]
}
```

### Reset password

`POST /auth/reset` - Resets password. Forgot password request adds `?token` query to redirect url. It should be extracted by password reset page and put into post body (example can be seen in `examples/password-reset/` directory).

Controller: `controllers/auth.js - resetPassword`

| Property          | Description                     |
| ----------------- | ------------------------------- |
| password *        | new password                    |
| confirmPassword * | confirm new password            |
| token *           | JWT password reset token        |

\* - required properties

Request:
```json
Content-Type: application/json
Accept: application/json

{
  "data": {
    "attributes": {
        "password": "1234",
        "confirmPassword": "1234",
        "token": "<JWT.TOKEN>"
    }
  }
}
```
**Success** response:
```json
204 No Content
```

**Fail** response:
```json
Content-Type: application/json
401 Unauthorized

{
    "meta": {
        "path": "/auth/reset"
    },
    "errors": [
        {
            "status": 401,
            "title": "jwttokeninvalid",
            "detail": "Provided jwt token is invalid"
        }
    ]
}
```

Deployment
----------

The app is easily deployable to any cloud or conventional hosting provider as it does not require any special permissions or prerequisites.

That said you might find these instructions helpful:

### Deployment to Heroku

- Download and install [Heroku Toolbelt](https://toolbelt.heroku.com/)
- In a terminal, run `heroku login` and enter your Heroku credentials
- From *your app* directory run `heroku create`
- Use the command `heroku config:set KEY=val` to set the different environment variables (KEY=val) for your application (i.e.  `heroku config:set BASE_URL=[heroku App Name].herokuapp.com` or `heroku config:set MONGODB_URI=mongodb://dbuser:<password>@cluster0-shard-00-00-sdf32.mongodb.net:27017,cluster0-shard-00-01-sdf32.mongodb.net:27017/<dbname>?ssl=true&retryWrites=true&w=majority` (see Hosted MongoDB Atlas below), etc.)  Make sure to set the environment variables for SENDGRID_USER, SENDGRID_PASSWORD, and any other API that you are using as well.
- Lastly, do `git push heroku master`.

Please note that you may also use the [Herko Dashboard](https://dashboard.heroku.com) to set or modify the configurations for your application.

---

### Hosted MongoDB Atlas

- Go to [https://www.mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas)
- Click the green **Get started free** button
- Fill in your information then hit **Get started free**
- You will be redirected to Create New Cluster page.
- Select a **Cloud Provider and Region** (such as AWS and a free tier region)
- Select cluster Tier to Free forever **Shared** Cluster
- Give Cluster a name (default: Cluster0)
- Click on green **:zap:Create Cluster button**
- Now, to access your database you need to create a DB user. To create a new MongoDB user, from the **Clusters view**, select the **Security tab**
- Under the **MongoDB Users** tab, click on **+Add New User**
- Fill in a username and password and give it either **Atlas Admin** User Privilege
- Next, you will need to create an IP address whitelist and obtain the connection URI.  In the Clusters view, under the cluster details (i.e. SANDBOX - Cluster0), click on the **CONNECT** button.
- Under section **(1) Check the IP Whitelist**, click on **ALLOW ACCESS FROM ANYWHERE**. The form will add a field with `<IP_ADDRESS>/0`.  Click **SAVE** to save the `<IP_ADDRESS>/0` whitelist.
- Under section **(2) Choose a connection method**, click on **Connect Your Application**
- In the new screen, select **Node.js** as Driver and version **3.6 or later**.
- Finally, copy the URI connection string and replace the URI in MONGODB_URI of `.env.example` with this URI string.  Make sure to replace the <PASSWORD> with the db User password that you created under the Security tab.
- Note that after some of the steps in the Atlas UI, you may see a banner stating `We are deploying your changes`.  You will need to wait for the deployment to finish before using the DB in your application.

**Note:** As an alternative to MongoDB Atlas, there is also [Compose](https://www.compose.io/).

---

Contributing
------------

If you find any error in code, or have an idea for more optimal solution for some parts of the code, please either open an issue or submit a pull request.
Contributions are welcome!

License
-------

MIT License

Copyright (c) 2021 avoup

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

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

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

repository: avoup/hackathon-starter-REST

repo_name: avoup/hackathon-starter-REST


text:
# Dataset and source code for `Efficient Solution Methods for a General $r$-interdiction Median Problem with Fortification`

## Cite
To cite this data, please cite the research article {`!link to be added`} and the data itself, using the following DOI.

Below is the BibTex for citing this version of the data.

  >
  ```
  @article{Data.IJOC.2021.GRIMF,
    author =        {Kaike Zhang, Xueping Li and Mingzhou Jin},
    publisher =     {INFORMS Journal on Computing},
    title =         {Efficient Solution Methods for a General $r$-interdiction Median Problem with Fortification},
    year =          {2021},
    doi =           {`TBD`},
    url =           {https://github.com/ILABUTK/IJOC-General-RIMF},
  }
  ```

![Bi-level Problem](/bi-level_problem.png)

## Dataset
Data used in this paper can be found in the `input` folder.
Each file corresponds to an instance with specified number of nodes or cities.
The first line is the number of cities `n`.
Next `n` lines, each line specifies a city in the order of:
 - index (int)
 - demand (float)
 - emergency cost (float)
 - fixed facility cost (float)
 - latitude (float)
 - longitude (float)

## Source Code
Code is written in `Scala` and can be run with Scala IDEs, no addition package needed, but you may need to configure the path so `CPLEX` can be recognized. Result tables are gathered by running corresponding files.

- Table 3
   - `AttackProblemCompareMain.scala`
   - `AttackProblemCompareMainLinear.scala`

- Table 4, Table 5
   - `AttackProblemVaryMain.scala`

- Table 6, Table 7
   - `CompareRIMPSolverZhu.scala`
   - `RIMPSolverCuttingPlane.scala`
   - `RIMPSolverTreeSearch.scala`

- Table 8, Table 9
   - `CompareRIMPSolversP0.scala`

repository: ILABUTK/IJOC-General-RIMF

branch_name: refs/heads/main

repo_name: ILABUTK/IJOC-General-RIMF


text:
# Weight

The weight of an object is the total [gravitational force](newtons_law_of_gravitation.md) excreted on the object by all the other objects in the universe.

If an object is at the surface of the earth we can neglect all the other forces.

If the earth would be a symmetric sphere with radius $R_E$ and mass $m_E$ the weight of an small object with mass $m$ at the surface of the earth would be.

$$
w = F_g = \frac{G m m_E}{R^2_E}
$$

From this we can derive the gravitational constant:

$$
w = mg \\
mg = \frac{Gmm_e}{R^2_E} \\
g = \frac{Gm_E}{R^2_E}
$$

Here we can see that the gravitational constant is independent of the objects weight and depends only on the mass of Earth (or other celestial object) and its Radius.

The weight of an object decreases with the square of its distance from earth center.


text:
# 007 Game

## Pickle

In a game of Lingo, there is a hidden word, five characters long. The object of the game is to find this word by guessing, and in return receive two kinds of clues:
- 1) the characters that are fully correct, with respect to identity as well as to position, and
- 2) the characters that are indeed present in the word, but which are placed in the wrong position.
Write a program with which one can play Lingo.

Use square brackets to mark characters correct in the sense of 1), and ordinary parentheses to mark characters correct in the sense of 2).
Assuming, for example, that the program conceals the word "tiger", you should be able to interact with it in the following way:

import lingo

snake

Clue: snak(e)

fiest

Clue: f[i](e)s(t)

times

Clue: [t][i]m[e]s

tiger

Clue: [t][i][g][e][r]


text:
todo
====

A very minimalistic console todo list in Lua.

## Installation

Rename the file to `todo` and `chmod +x` it to make it executable. Then place or link it somewhere in your PATH.

##Usage:
<pre>
`todo` lists all todos.
`todo add "[task]"` add a task.
`todo rm [#num]` remove a task by number.
`todo -h` display usage instructions.
</pre>

repository: bruston/todo

repo_name: bruston/todo


text:
---
layout: post
title:  "Terminal multiplexer minimal tutorial"
categories: [utils]
tags: [utils, productivity]
d3: False
---

`Terminal multiplexer` is a software that can multiplex several separate pseudoterminal-based login sessions inside one terminal.

Main features:

1. **Persistence** - similar to `nohup`, permits to disconnect and reconnect without terminating running processes
2. **Multiple windows** - split-screens, several windows to have several terminals on one screen.
3. **Session sharing** - multiple users can connect to the same session.

Let's consider one popular **T**erminal **Mu**lteple**x**er - `tmux`.

<!--more-->

## Installation

`sudo apt-get install tmux`

## Basic abstractions

* Session - aggregate and controls several terminals and processes
* Window - can be split into several `panes`, a session can have multiple windows.
* Pane - `window` can be divided into `panes`
* Control key - every control command will look like  `*PREFIX KEY* + *COMMAND KEY*` where `PREFIX KEY` is `Ctrl+B` by default. In this tutorial, I will use `C-b` instead of `Ctrl+B`

## Basic functionalities

Here are some basic functionalities:

* when ssh is disconnected session will persist
* sessions for different tasks
* connect to the shell of different user

## Panes

`C-b`  + `%`   =  split left/right

`C-b`  + `"`  =  split up / down

`C-b` + `left/right`  = go to prev/next pane

`exit`  or `C-d`  = close pane

## Windows

`C-b` + `c`  = new window

`C-b` + `p/n`  = go to prev/next window

`C-b` + `<number>` = go to window `<number>`

## Sessions

`C-b` + `d`   = detach session

`tmux ls`  = list of sessions

`tmux attach -t 0`  = attach to session 0

`tmux new -s database` = create session named "database"

## Mouse control

Add this to `.tmux.conf`

{% highlight bash %}
# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on

# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
{% endhighlight %}

## Shared sessions

`tmux` can also create `shared sessions` and different users can attach to this session at the same time.

Create
{% highlight bash %}
tmux -S /tmp/socket_name new -s session_name
{% endhighlight%}

Modify socket permissions to get access for other users in group `tmux`
{% highlight bash %}
chgrp tmux /tmp/socket_name
{% endhighlight %}

Attach
{% highlight bash %}
tmux -S /tmp/socket_name attach -t session_name
{% endhighlight%}

Attach Read-only
{% highlight bash %}
tmux -S /tmp/socket_name attach -t session_name -r
{% endhighlight%}

? Problem: two users connected to a shared session will use the same session. Active pane and window are connected to the session, so they won't be able to look at different windows at the same time, and type in different panes simultaneously.

! Solution: `grouped sessions`

## Grouped sessions

`grouped sessions` allow to share windows and panes between sessions and work in different windows and panes.

{% highlight bash %}
tmux new-session -s grouped_session
{% endhighlight%}

{% highlight bash %}
tmux new-session -t grouped_session -s group_subsession
{% endhighlight%}

## Usage optimized

Here we will discuss some configurations and best practices to foster usage of tmux and make it more transparent and easier

### Some hack to organize multiuser interaction with shared sessions

Shared sessions are implemented with unix sockets, and there is no functionality to look at all shared sessions.
To organize shared sessions on the server for a small team we can do the following:

{% highlight bash %}
sudo adgroup tmux

sudo usermod -a -G tmux <USERS>
sudo mkdir - mode=u+rwx,g+rws,o-rwx /var/tmux_sessions
sudo chown user:tmux /var/tmux_sessions
{% endhighlight%}

Where `<USERS>` means add all necessary users manually or list all users with other utils.

Then we can add some sh-scripts to `start`, `attach` and `list` shared sessions.

{% highlight bash %}
#!/bin/sh
SESSION_NAME=$1
tmux -S /var/tmux_sessions/$SESSION_NAME attach -t $SESSION_NAME
#!/bin/bash
ls -l /var/tmux_sessions/ | grep ^s | awk '{print substr($9, 1, length($9)-1) " (" $3 ")" }'
#!/bin/sh
SESSION_NAME=$1
tmux -S /var/tmux_sessions/$SESSION_NAME new -s $SESSION_NAME
chgrp tmux /var/tmux_sessions/$SESSION_NAME
{% endhighlight%}

[wemux](https://github.com/zolrath/wemux/) - some wrapper on top of tmux for multiuser access (TODO: check if it works on Ubuntu)

## Links

1. [tmux cheatsheet](https://gist.github.com/MohamedAlaa/2961058)
2.


text:
---
layout: post
title: "Towards Linearization Machine Learning Algorithms"
date: 2019-08-14 12:01:46
categories: arXiv_AI
tags: arXiv_AI Classification Prediction
author: Steve Tueno
mathjax: true
---

* content
{:toc}

##### Abstract
This paper is about a machine learning approach based on the multilinear projection of an unknown function (or probability distribution) to be estimated towards a linear (or multilinear) dimensional space E'. The proposal transforms the problem of predicting the target of an observation x into a problem of determining a consensus among the k nearest neighbors of x's image within the dimensional space E'. The algorithms that concretize it allow both regression and binary classification. Implementations carried out using Scala/Spark and assessed on a dozen LIBSVM datasets have demonstrated improvements in prediction accuracies in comparison with other prediction algorithms implemented within Spark MLLib such as multilayer perceptrons, logistic regression classifiers and random forests.

##### Abstract (translated by Google)

##### URL
[http://arxiv.org/abs/1908.06871](http://arxiv.org/abs/1908.06871)

##### PDF
[http://arxiv.org/pdf/1908.06871](http://arxiv.org/pdf/1908.06871)


text:
---
title: SplitLines
tags: string,beginner
---

Splits a multiline string into an array of lines.

- Use `string.Split()` with all forms of the newline separator to split the string into an array of strings.

```csharp
using System.Collections.Generic;

public static partial class _30s
{
  public static string[] SplitLines(string s)
  {
    return s.Split(new [] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
  }
}
```

```csharp
string s = "This\nis a\nmultiline\nstring.\n";

_30s.SplitLines(s); // {"This", "is a", "multiline", "string." , ""}
```


text:
# iOSLuckyWheel
[![Version](https://img.shields.io/cocoapods/v/iOSLuckyWheel.svg?style=flat)](https://cocoapods.org/pods/iOSLuckyWheel)
[![License](https://img.shields.io/cocoapods/l/SmoothPicker.svg?style=flat)](https://cocoapods.org/pods/SmoothPicker)
[![Platform](https://img.shields.io/cocoapods/p/iOSLuckyWheel.svg?style=flat)](https://cocoapods.org/pods/iOSLuckyWheel)
[![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://swift.org/)

An iOS Lucky wheel with customizable text and text colors and section colors and very easy to integrate

![Alt Text](https://media.giphy.com/media/RHIqv3l88Ewczkju60/giphy.gif)

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements

## Installation

iOSLuckyWheel is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod 'iOSLuckyWheel'
```
# Usage

Create the view extending LuckWheel by frame

```
import iOSLuckyWheel
class ViewController: UIViewController,LuckyWheelDataSource,LuckyWheelDelegate {
    var wheel :LuckyWheel?
    override func viewDidLoad() {
        super.viewDidLoad()
        wheel = LuckyWheel(frame: CGRect(x: 0, y: 0, width: view.frame.width - 40 , height: 300))
        wheel?.delegate = self
        wheel?.dataSource = self
        wheel?.center = self.view.center
        wheel?.setTarget(section: 5)
        wheel?.animateLanding = true
        self.view.addSubview(wheel!)
    }
    func numberOfSections() -> Int {
        return 8
    }
    func itemsForSections() -> [WheelItem] {
        let item = WheelItem(title: "Welcome to iOS Lucky Wheel", titleColor: UIColor.white, itemColor: UIColor.blue)
        return [item,item,item,item,item,item,item,item]
    }
    func wheelDidChangeValue(_ newValue: Int) {
        print(newValue)
    }

}
```

## Data Source
```
func numberOfSections() ->Int // number of wheel sections
func itemsForSections() -> [WheelItem] // the items to be displayed
```
## Delegate
```
func wheelDidChangeValue(_ newValue: Int) // the selected section  postion
@objc optional func lastAnimation() ->CABasicAnimation // custom animation after landing
@objc optional func landingPostion() ->LandingPostion  // the landing postion [top,bottom,left,right]
```
the landing position is the direction where the wheel stops after selecting a section

## properties
```
public func setTarget(section:Int) // set landing target
public var infinteRotation = false // to rotate infinitely
public var animateLanding = false // to whether animate after landing or not.
public func manualRotation(aCircleTime: Double) // manual rotation with time
public func stop() // manual Stop
```

## Authors

* **Ahmed Nasser** - [AvaVaas](https://github.com/AvaVaas)

## License

iOSLuckyWheel is available under the MIT license. See the LICENSE file for more info.

repository: AhmedNasserSh/iOSLuckyWheel

repo_name: AhmedNasserSh/iOSLuckyWheel


text:
# rand-quote plugin

Displays a random quote taken from [quotationspage.com](http://www.quotationspage.com/random.php)

Created by [Eduardo San Martin Morote, aka Posva](https://posva.github.io)

## Usage

Add the plugin to the plugins array in your zshrc file and restart zsh:

```zsh
plugins=(... rand-quote)
```

Then, run `quote` to get a new random quote.

repository: ohmyzsh/ohmyzsh

gha_language: Shell

repo_name: ohmyzsh/ohmyzsh


text:
---
type: "tv-episode"
Description: "15 Factor Applications on Kubernetes"
aliases: ["/tv/tanzu-tuesdays/18"]
hosts: ["Bob Brindley","Tiffany Jernigan","Paul Czarkowski"]
guests: ["DaShaun Carter"]
Date: "2020-08-11T13:00:00-07:00"
PublishDate: "2020-04-01T00:00:00-07:00"
minutes: 120
episode: "18"
# wget -O static/images/tv/episodes/tanzu-tuesdays/0018-yt.jpg https://img.youtube.com/vi/YoZ2qY2BsMg/mqdefault.jpg
episode_banner: "/images/tv/episodes/tanzu-tuesdays/0018-yt.jpg"
episode_image: "/images/tv/episodes/tanzu-tuesdays/0018-yt.jpg"
images: ["/images/tv/episodes/tanzu-tuesdays/0018-yt.jpg"]
title: "15 Factor Applications on Kubernetes with DaShaun Carter"
youtube: "YoZ2qY2BsMg"
truncate: ""
twitch: "vmwaretanzu"
---

Perhaps you have heard of 12-factor apps, cloud-native, or 15-factor apps. Maybe you have wondered if cloud-native was right for you. In this session we will explore how to deliver apps using this methodology on Kubernetes. We will start by explaining the 15-factors. We will also review the cloud native features that are built into Kubernetes. Then we will create a new application, for Kubernetes, and demonstrate how to make it "15 factor cloud native on Kubernetes"!

repository: Weimankow/tanzu-dev-portal

repo_name: Weimankow/tanzu-dev-portal


text:
# singletons

Helps create and manage families of singletons based on customizable conditions

  * [Use case](#use-case)
  * [SingletonFactory syntax](#singletonfactory-syntax)
  * [Special syntax: `Singleton(singleton)`](#special-syntax-singletonsingleton)
  * [Function `key(...args)`](#function-keyargs)
  * [Function `singleton(key)`](#function-singletonkey)
  * [Function `get(...args)`](#function-getargs)
  * [Function `looseKey(...args)`](#function-loosekeyargs)
  * [Function `looseGet(...args)`](#function-loosegetargs)
  * [Preprocessing arguments](#preprocessing-arguments)
  * [Postprocessing an instance](#postprocessing-an-instance)
  * [Spreadable singletons](#spreadable-singletons)
  * [Passing custom arguments](#passing-custom-arguments)
  * [License](#license)

## Use case

Sometimes your functions handle data that match one-to-one to an object, but you don't have that object in the scope, and don't want to create a new one (especially if the object has states that could already have been mutated).

SingletonFactory is provided by module 'singletons'. Given a constructor and a set of options hinting at what to expect, it returns a Singleton function that will always return the same object constructed once from the passed constructor and the same set of arguments (strict equality).

## SingletonFactory syntax

SingletonFactory takes generally two arguments. The first one specifies the constructor for the singletons, and the second one is a function or an array with at least as many arguments or elements as you expect data to index your objects. For example if it matters to you that methods be considered different if they are not bound to the same object, then you will need two arguments: One indexing the object and one indexing the method.

If you provide a function, it should take as arguments your indexes and return a unique key as a string. But if you provide an array of options, a custom function will be generated for you using module [keyfunc](https://www.npmjs.com/package/keyfunc).

In the latter case, options should hint on the nature of the expected indexing data. Keywords are 'object', 'literal', 'property', 'option', 'array', 'set' and 'ignore' used as in the following example:

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor () {}
};

const Singleton = SingletonFactory(
  Class, // Constructor for the singletons
  [
    'object', // First argument must be an object matched strictly
    'literal', // Second argument can be anything matched literally
    {property: 'color'}, // Third argument and all subsequent ones can be
    // anything matched literally from their property 'id' downwards
    'array', // Fourth argument is an array of 'object'
    'set', // Fifth argument is a set of 'object'
    'ignore', // Sixth argument is ignored
    {
      type: 'option',
      sub: {
        id: 'literal',
        name: 'literal',
      },
    }, // Seventh argument is an object with properties id and name matched
    // at the level of its propeties
  ]
);

const obj = {id: 1};
const obj2 = {id: 2, name: 'Alice'};
const s1 = Singleton(console, 'log', {color: 'red'}, [console, obj],
  [console, obj], console, obj2);
const s2 = Singleton(console, 'log', {color: 'red'}, [console, obj],
  [obj, console], 'dummy', {id: 2, name: 'Alice'});

s1 === s2;
s1; // instanceof(Class);
```

For advanced combinations of hints, of which there are many, see [keyfunc](https://www.npmjs.com/package/keyfunc) documentation.

## Special syntax: `Singleton(singleton)`

Some types can be initialized either from a set of data or from another instance. In order for a Singleton function not to get confused, each created singleton stores its key with a specific symbol associated uniquely to the Singleton function.

When a Singleton function is passed a singleton with its own symbol, it just returns it without any further processing, as expected from a singleton.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor () {}
};

const Singleton = SingletonFactory(Class, ['object']);

const option1 = {color: 'red'};

const s1 = Singleton(option1);
const s2 = Singleton(option1);
const s3 = Singleton(s1);

s1 === s2;
s1 === s3;
```

## Function `key(...args)`

The generated Singleton function has a property `key` that returns the
generated key for any given set of arguments.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor () {}
};

const Singleton = SingletonFactory(
  Class,
  [
    'object',
  ]
);

Singleton.key(console) === 'o1';
Singleton.key(new Class()) === 'o2';
Singleton.key(console) === 'o1';
Singleton.key(new Class()) === 'o3';
```

## Function `singleton(key)`

The generated Singleton function has a property `singleton` that returns the singleton referenced by a specific key.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor () {}
};

const Singleton = SingletonFactory(
  Class,
  [
    'object',
  ]
);

const s1 = Singleton(console);

Singleton.singleton('o1') === s1;
```

## Function `get(...args)`

The generated Singleton function has a property `get` that returns the singleton for any given set of arguments. This is actually the behavior of the Singleton function too, except that the latter would create the asked for singleton on the fly if it doesn't find it. Therefore use rather `Singleton.get` if you don't want to create singletons that are not found.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor () {}
};

const Singleton = SingletonFactory(
  Class,
  [
    'object',
  ]
);
const s1 = Singleton(console);

Singleton.get(console) === s1;
Singleton.get(Number); // undefined;
```

## Function `looseKey(...args)`

Whereas `key` requires an exact match, `looseKey` will preprocess its arguments with the same helpers you provided for `Singleton`, then only it will return the generated key.

Never use this function within one of your preprocessing helpers, as you would enter an infinite loop resulting in a maximum call stack size error.

```js
import {SingletonFactory} from 'singletons';
import sig from 'sig';

class Class {
  constructor (str) {
    this.str = str;
  }
};

const Singleton = SingletonFactory(
  Class,
  ['literal'],
  {
    customArgs: [
      [String, {
        convert (arg) {
          return arg.match(/!$/) ? arg : arg + '!';
        },
      }],
    ],
  }
);

Singleton.key('hello') === sig('hello');
Singleton.key('hello!') === sig('hello!');

Singleton.looseKey('hello') === sig('hello!');
Singleton.looseKey('hello!') === sig('hello!');
```

## Function `looseGet(...args)`

Whereas `get` requires an exact match, `looseGet` will preprocess its arguments with the same helpers you provided for `Singleton`, then only it will return the found singleton or nothing if the preprocessed args still match nothing.

Never use this function within one of your preprocessing helpers, as you would enter an infinite loop resulting in a maximum call stack size error.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor (str) {
    this.str = str;
  }
};

const Singleton = SingletonFactory(
  Class,
  ['literal'],
  {
    customArgs: [
      [String, {
        convert (arg) {
          return arg.match(/!$/) ? arg : arg + '!';
        },
      }],
    ],
  }
);
const s1 = Singleton('hello');

Singleton.get('hello'); // undefined;
Singleton.get('hello!') === s1;

Singleton.looseGet('hello') === s1;
Singleton.looseGet('hello!') === s1;
Singleton.looseGet('hello!!'); // undefined;
```

## Preprocessing arguments

`SingletonFactory` can take a third argument, allowing to pass it a preprocessing function. This is useful when one has to handle inputs that don't match directly the provided hints, especially when passing already created singletons. On the one hand, passing a single singleton is handled by default (see [Special syntax: Singleton(singleton)](#special-syntax-singletonsingleton)). But on the other hand one may want to handle passing more than one singleton in conjunction with option 'rest: true'. This requires preprocessing, as shown in the example below.

```js
import {SingletonFactory} from 'singletons';

class Class {
  constructor (...chunks) {
    this.chunk = chunks.reduce(
      (str, chunk) => str + chunk, '');
  }
}

const Singleton = SingletonFactory(Class, [{type: 'literal', rest: true}], {
  preprocess: function (args) {
    return args.map(arg => {
      if (arg.chunk) {
        return arg.chunk;
      }
      return arg;
    });
  },
});
const refSingleton = SingletonFactory(Class,
  [{type: 'literal', rest: true}]);

const chunk1 = 'foo';
const chunk2 = 'bar';

const s1 = Singleton(chunk1);
const s2 = Singleton(chunk2);
const s3 = Singleton(chunk1, chunk2);
const s4 = Singleton(s1, s2);

s1 !== s2;
s1 !== s3;
s3 === s4;

const t1 = refSingleton(chunk1);
const t2 = refSingleton(chunk2);
const t3 = refSingleton(chunk1, chunk2);
const t4 = refSingleton(t1, t2);

t1 !== t2;
t1 !== t3;
t3 !== t4;
```

## Postprocessing an instance

Sometimes, you want to update your singleton on invocation. This is not advised as it can have side effects, but for example if you ignore some arguments using the type 'ignore', then whatever you use for these arguments on invocation will be discarded from the second call onwards, since the singleton will just be recalled and the constructor not called again. That's probably unwanted behavior and the option postprocess gives an opportunity to correct that.

To pass that option, use the third argument of the SingletonFactory. This option must be an object with property 'postprocess' as a function that takes all the arguments passed to the singleton as a single array argument. Use `this` to refer to the actual singleton instance.

```js
import {SingletonFactory} from 'singletons';

class Person {
  constructor (firstname, lastname, options) {
    this.firstname = firstname;
    this.lastname = lastname;
    this.where = options.where;
  }
}

const Inhabitant = SingletonFactory(Person, [
  'literal', 'literal', 'ignore',
], {
  postprocess: function (args) {
    if (args && args[2] && args[2].where) {
      this.where = args[2].where;
    }
  },
});

const annie = new Inhabitant('Annie', 'Smith', {where: 'Los Angeles'});

annie.where === 'Los Angeles';
annie === Inhabitant('Annie', 'Smith');
annie.where === 'Los Angeles';
annie === Inhabitant('Annie', 'Smith', {where: 'New York'});
annie.where === 'New York';
```

## Spreadable singletons

Some singletons are wrappers around collections. You may want to create new ones by merging two or more. You can do it by using the `customArgs:spread` or `customArgs:shallowSpread` options (see [Passing custom arguments](#passing-custom-arguments)) in conjunction with the type you used as first argument in the factory.

But when that type is not accessible (that is you cannot create the Singleton function and are only allowed to configure it through an interface that hides the type from you), you can still have the merging functionality by using options `spread` and `shallowSpread` (provided the interface doesn't further filter the options you pass to SingletonFactory).

```js
import {SingletonFactory} from 'singletons';

function hidingFunction (options) {
  class Person {
    constructor (name) {
      this.name = name;
    }
  }

  class Persons {
    constructor (...names) {
      this.persons = names.map(name => new Person(name));
    }

    getNames () {
      return this.persons.map(person => person.name);
    }
  }

  return SingletonFactory(Persons, [{
    type: 'literal',
    rest: true,
  }], Object.assign({
    customArgs: [
      [Person, {
        convert (person) {
          return person.name;
        },
      }],

      [Array, {
        spread: true,
      }],
    ],
  }, options));
}

const Crowd = hidingFunction({
  spread (crowd) {
    return crowd.persons;
  },
});

const c1 = new Crowd('Nancy');
const c2 = new Crowd('Harry', 'Johnny', 'Sally');
const c3 = ['Peter', 'Paul', 'Pauline', 'Louis'];

const crowd = new Crowd('Sam', c1, c2, c3);

expect(crowd.getNames()).to.eql([
  'Sam', 'Nancy',
  'Harry', 'Johnny', 'Sally',
  'Peter', 'Paul', 'Pauline', 'Louis',
]);
```

## Passing custom arguments

On top of [preprocessing](#preprocessing-arguments) or [postprocessing](#postprocessing-an-instance) as a whole, you may need even finer control, such as when your singletons have only loosely related structures.

For example, a contact is definitely a singleton, is uniquely identified with a few parameters but may have many more associated. As ways to handle them blow up, you need dynamically to make your singletons understand how to construct themselves, or update themselves. The whole point of `singletons` is to be able to access your data through a finite set of unique, intuitive parameters, so neither maps with object keys, arrays of references, integer indexing will work, but on the other hand, you can't any more create your singletons straightforwardly with static, ordered parameters.

So you may also pass `customArgs` as third argument. It is an array of 2-sized arrays. The first element is a custom class, the second a literal object with several possible options as functions to process the arguments of your custom type:

* `convert`: Arguments of your custom type are replaced by the output of this function. If this option is not set, the custom arguments are not passed through as singleton parameters, but they are still considered for postprocessing.
* `reduce`: All arguments of your custom type are reduced to one argument of the same type or another before postprocessing, but after all other operations. If you need to reduce first, either use `[`preprocess`](#preprocessing-arguments)`, or reduce them outside and pass only the result of the reduction (of a regular type or of a new custom type created just for the occasion!).
* `spread`: Arguments of your custom type are converted to lists of regular initializing args that are spread in place in the sequence of all init args, recursively. Beware of cyclical references. You may prefer to use `shallowSpread` instead.
* `shallowSpread`: Arguments of your custom type are converted to lists of regular initializing args that are spread in place in the sequence of all init args. Just the init args are affected. You won't enter an infinite loop if there are cyclical references.
* `postprocess`: What to do with your custom or reduced types once your singleton is created or updated.

If you need to spread arguments deeply but they cross-reference, you must use [`preprocess`](#preprocessing-arguments) instead of `customArgs:spread` and you must work out some circumvoluted logic on your own. Good luck!

```js
import {SingletonFactory} from 'singletons';

class Name {
  constructor (name) {
    this.name = name;
    this.friends = new Set();
  }
}

class Age {
  constructor (age) {
    this.age = age;
  }
}

class Gender {
  constructor (gender) {
    this.gender = gender;
  }
}

class Country {
  constructor (country) {
    this.country = country;
  }
}

class Friend {
  constructor (friend) {
    this.friend = friend;
  }
}

const Contact = SingletonFactory(Name, ['literal'], {
  customArgs: [
    [Name, {
      convert ({name}) {
        return name;
      },
    }],
    [Age, {
      postprocess ({age}) {
        this.age = age;
      },
    }],
    [Gender, {
      postprocess ({gender}) {
        this.gender = gender;
      },
    }],
    [Country, {
      postprocess ({country}) {
        this.country = country;
      },
    }],
    [Friend, {
      reduce (friends) {
        return friends.map(friend => friend.friend);
      },
      postprocess (friends) {
        friends.forEach(friend => this.friends.add(new Contact(friend)));
      },
    }],
  ],
});

const paul = new Contact('Paul');
const paula = new Contact(new Name('Paula'), new Gender('female'));
const john = new Contact(new Country('England'), 'John', new Age(55));

paul.name === 'Paul';
paula.name === 'Paula';
john.name === 'John';

paula.gender === 'female';
john.age === 55;
john.country === 'England';

expect(new Contact('John', new Gender('male'), new Age(56),
  new Country('France'), new Friend('Paula'),
  new Friend('Paul'))).to.equal(john);
john.gender === 'male';
john.age === 56;
john.country === 'France';

john.friends.has(paula); // true;
john.friends.has(paul); // true;
john.friends.size === 2;

const Friends = SingletonFactory(Array, [{
  type: 'literal',
  rest: true,
}], {
  customArgs: [
    [Name, {
      spread (contact) {
        return Array.from(contact.friends || []).map(
          contact => new Friend(contact.name));
      },
    }],
    [Friend, {
      convert (friend) {
        return friend.friend;
      },
    }],
  ],
});

const friends = new Friends(john);
expect(friends).to.eql(['Paula', 'Paul']);

const Friends2 = SingletonFactory(Array, [{
  type: 'literal',
  rest: true,
}], {
  customArgs: [
    [Name, {
      shallowSpread (contact) {
        return Array.from(contact.friends || []);
      },
      convert (contact) {
        return contact.name;
      },
    }],
  ],
});

const friends2 = new Friends2(john);
expect(friends2).to.eql(['Paula', 'Paul']);
```

## License

singletons is [MIT licensed](./LICENSE).

© 2016-2017 [Jason<EMAIL_ADDRESS>

repository: jlenoble/singletons

repo_name: jlenoble/singletons


text:
The Connect Four model, originally from the mCRL2 example directory.
===

```
./monolithic_init.sh
./monolithic_mcrl2.sh
```
Result:
```
[16:15:05 verbose] done with state space generation (22 levels, 7039582 states and 15175974 transitions)
575.93 user, 0.47 system, 575.96 elapsed -- Max VSize = 583704KB, Max RSS = 539424KB
```
Then LTSmin:
```
./monolithic_ltsmin_mc.sh
```
Result:
```
lps2lts-mc( 0/ 4): Explored 7039582 states 15175974 transitions, fanout: 2.156
lps2lts-mc( 0/ 4): Total exploration time 66.640 sec (66.640 sec minimum, 66.640 sec on average)
lps2lts-mc( 0/ 4): States per second: 105636, Transitions per second: 227731
lps2lts-mc( 0/ 4):
lps2lts-mc( 0/ 4): Queue width: 8B, total height: 1119986, memory: 8.54MB
lps2lts-mc( 0/ 4): Tree memory: 54.5MB, 8.1 B/state, compr.: 9.4%
lps2lts-mc( 0/ 4): Tree fill ratio (roots/leafs): 10.0%/0.0%
lps2lts-mc( 0/ 4): Stored 15 string chucks using 0MB
lps2lts-mc( 0/ 4): Total memory used for chunk indexing: 0MB
lps2lts-mc( 0/ 4): Est. total memory use: 63.0MB (~520.5MB paged-in)
297.52 user, 2.63 system, 76.76 elapsed -- Max VSize = 6023892KB, Max RSS = 5680KB
```
Symbolic:
```
./monolithic_ltsmin_sym.sh
```
Result:
```
lps2lts-sym: state space has 7039582 (~7.04e+06) states, 72598 BDD nodes
1229.18 user, 678.86 system, 485.86 elapsed -- Max VSize = 6027028KB, Max RSS = 5848KB
```

Alternative specification:
```
./separate_init.sh
./separate_ltsmin_sym.sh
```
Result:
```
lps2lts-sym: state space has 5464758 (~5.46e+06) states, 4389 BDD nodes
1.25 user, 0.35 system, 0.50 elapsed -- Max VSize = 6027028KB, Max RSS = 5864KB
```

Larger instance:
```
memtime lps2lts-sym --mcrl2=-rjitty -rgs four7.lps --vset=lddmc --order=par-prev --lddmc-tablesize=27
```
Result:
```
lps2lts-sym: Exploration took 3268 group checks and 3268 next state calls
lps2lts-sym: reachability took 246.690 real 3907.080 user 27.900 sys
lps2lts-sym: counting visited states...
lps2lts-sym: counting took 361334.125 real 5769535.500 user 3467.490 sys
lps2lts-sym: state space has<PHONE_NUMBER>7102 (~7.02e+13) states, 113351 BDD nodes
5773458.21 user, 3495.83 system, 361581.93 elapsed -- Max VSize = 74276476KB, Max RSS = 5792KB
```
Note that currently counting states in LDDmc is very slow -- an issue which is being worked on.
Also, memtime does not give a good estimate for the amount of memory used by the multi-core tools.


text:
# The World's Best Audiobook

Audiobook player + sample content

[Live demo](https://marisademeglio.github.io/worlds-best-audiobook/web/library/)

## Scope

Demonstrate playback of three types of audiobooks, all developed according to the [W3C Audiobooks](https://www.w3.org/TR/audiobooks/) standard.

## Goal

Show how web standards make your audio books better.

## Features

### Audiobooks
* Shows the cover and plays from beginning to end
* Access to table of contents while listening
* User controls for volume, rate, play/pause
* Jump forward/back by 30 seconds
* Remembers last-read position
* Set bookmarks, named automatically by chapter + offset

### Audiobooks + HTML

* All of the features above, PLUS
* HTML page displayed during playback
* Change the font size

### Audiobooks + Synchronized narration

* All of the above, PLUS
* Synchronized highlight of the HTML sentences or paragraphs during playback
* Optional "Caption" mode
* Instead of moving in 30 second increments, move by sentence
* Click phrase to start playback
* Change highlight color (settings)

## About this demo

* Runs in a web browser
* Employs principles of web accessibility
* Built with HTML/CSS/Vanilla JS
* Uses [audiobooks-js](https://marisademeglio.github.io/audiobooks-js) library

## Run it locally

1. Check out the code
2. Start a server: `npx http-serve -c-1`
3. Go to `http://localhost:8080/web/library/`
4. Click a title.

repository: SkyrookieYu/worlds-best-audiobook

repo_name: SkyrookieYu/worlds-best-audiobook


text:
# `TradeCallee`

callee contract to trade on 0x.

## Functions:

- `constructor(address _exchange, address _weth, address _controller) (public)`

- `callFunction(address payable _sender, bytes _data) (external)`

- `fallback() (external)`

### Function `constructor(address _exchange, address _weth, address _controller) public`

### Function `callFunction(address payable _sender, bytes _data) external`

fill 0x order

#### Parameters:

- `_sender`: the original sender who wants to trade on 0x

- `_data`: abi-encoded order, fillamount, signature and _sender. fee payer is the address we pull weth from.

### Function `fallback() external`

fallback function which allow ETH to be sent to this contract


text:
# Powerline Analyzer

This program can analyze powerline based on following modes:

1. Single Circuit and No Bundle
2. Single Circuit and Bundle
3. Two Circuit and No Bundle
4. Two Circuit and Bundle

The outputs of analysis are **Voltage Regulation** and **Efficiency** of power system.

**Note:**
You only need to run **Main_File.m** and no need to open **PSA.m**. Because PSA.m is a function called in the Main_File.m.

Any feedback is kindly appreciated.

repository: dayitachaudhuri/Powerline-Analyzer

repo_name: dayitachaudhuri/Powerline-Analyzer


text:
## Features

- Effeciently publishes Home-Assistant events to Elasticsearch using the Bulk API
- Automatically maintains Indexes and Index Templates using Index Lifecycle Management ("ILM")
- Supports [X-Pack Security](https://www.elastic.co/products/x-pack/security) via optional username and password
- Tracks the Elasticsearch cluster health in the `sensor.es_cluster_health` sensor
- Exclude specific entities or groups from publishing

## Compatibility

- Elasticsearch 8.0+, 7.11+ (Self or [Cloud](https://www.elastic.co/cloud) hosted). [Version `0.4.0`](https://github.com/legrego/homeassistant-elasticsearch/releases/tag/v0.4.0) includes support for older versions of Elasticsearch.
- [Elastic Common Schema version 1.0.0](https://github.com/elastic/ecs/releases/tag/v1.0.0)
- [Home Assistant Community Store](https://github.com/custom-components/hacs)
- Home Assistant 2022.4+

## Getting Started

The Elasticsearch component requires, well, [Elasticsearch](https://www.elastic.co/products/elasticsearch)!
This component will not host or configure Elasticsearch for you, but there are many ways to run your own cluster.
Elasticsearch is open source and free to use: just bring your own hardware!
Elastic has a [great setup guide](https://www.elastic.co/start) if you need help getting your first cluster up and running.

If you don't want to maintain your own cluster, then give the [Elastic Cloud](https://www.elastic.co/cloud) a try! There is a free trial available to get you started.

## Setup (preferred method)

This component supports interactive configuration via Home Assistant's integration configuration page.
This will be the only supported configuration method in the future.

1. Restart Home-assistant once you've completed the installation instrictions above.
2. From the `Integrations` configuration menu, add a new `Elasticsearch` integration. ![img](assets/add-integration.png)
3. Provide connection information and optionally credentials to begin setup. ![img](assets/configure-integration.png)
4. Once the integration is setup, you may tweak all settings via the "Options" button on the integrations page.
   ![img](assets/publish-options.png)

## Setup (deprecated method)

This component supports yaml-based configuration, but this is deprecated, and will be removed in a future release. Please migrate to the UI-based approach outlined above. Please file an issue if you have any trouble migrating to the new setup process.

1. Copy the contents of `custom_components` to your `$HASS_CONFIG/custom_components` directory, where `$HASS_CONFIG` is the location on your machine where Home-Assistant lives.
   Example: `/home/pi/.homeassistant` and `/home/pi/.homeassistant/custom_components`. You may have to create the `custom_components` directory yourself.
2. Configure the component in `$HASS_CONFIG/configuration.yaml` (see Configuration section below)
3. Restart Home-Assistant

### Expected file structure

```
.homeassistant/
|-- custom_components/
|   |-- elasticsearch/
|       |-- __init__.py
|       |-- const.py
|       |-- es_doc_publisher.py
|       |-- ...etc...
|       |-- index_mapping.json
|       |-- sensor.py

```

See https://github.com/legrego/homeassistant-elasticsearch for a complete list of configuration options.

repository: legrego/homeassistant-elasticsearch

gha_language: Python

repo_name: legrego/homeassistant-elasticsearch


text:
# Data visualization legend layer

**Purpose**: Legend is required for explaining the data visualization used for each layer. If the legend contains language-specific elements, localized legends shall be made available in each localized capabilities document.

**Prerequisites**

* [Schema validation](http://inspire.ec.europa.eu/id/ats/view-service/3.11/WMTS/schema-validation)
* [Layer style name](http://inspire.ec.europa.eu/id/ats/view-service/3.11/WMTS/layer-style-name)

**Test method**
For each Layer element:

* Check that for each [Style element](#Style):
  * There exists a non-empty [href attribute](#href). Let the value of the attibute be ```href```.
  * Retrieve the resource at the URL in ```href```. If the download is successful and a non-empty image file returned:
    * If the [Format](#format) equals 'image/gif' or 'image/png':
      * the downloaded resource must be a valid image of these image formats correspondingly. If it is, pass the test. If not, fail the test for this Style.
    * Otherwise, pass the test for this Style.
  * Otherwise, fail the test for this Style.

**Reference(s)**

* [TG VS](http://inspire.ec.europa.eu/id/ats/view-service/3.11/WMTS/README#ref_TG_VS), chapter <IP_ADDRESS>.4.9, Requirement 91

**Test type**: Automated

**Notes**

* Note that it's generally not required for the validator to recognize the image formats of the downloaded legend files in order to pass the test.

## Contextual XPath references

The namespace prefixes used as described in [README.md](http://inspire.ec.europa.eu/id/ats/view-service/3.11/WMTS/README#namespaces).

Abbreviation                                               |  XPath expression (relative to Capabilities)
---------------------------------------------------------- | -------------------------------------------------------------------------
Style  | ./wmts:Contents/wmts:Layer/wmts:Style
HREF attribute  | /wmts:Contents/wmts:Layer/wmts:Style/wmts:LegendURL[@xlink:href]
Format  | ./wmts:Contents/wmts:Layer/wmts:Style/wmts:LegendURL[@format]

repository: pabloibz/view-service

repo_name: pabloibz/view-service


text:
# Keep this file small, we want to measure bat startup time, not speed of Markdown highlighting!

The Markdown syntax definition references ~18 other syntaxes, so without lazy-loading, it will be slow to load.

repository: sharkdp/bat

gha_language: Rust

repo_name: sharkdp/bat


text:
# ESRtool

Port of the PS2 Homebrew tool [esr-disc-patcher-cli](https://github.com/ali-raheem/esrtool-legacy). Based on [Tatsh's original work posted on PSX-Scene](https://web.archive.org/web/20150919031500/http://psx-scene.com/forums/f164/esr-disc-patcher-linux-mac-qt4-port-60096/).

These older versions contain several bugs, at least one of which is potentially exploitable. This tool is safer in that regard at least.

# Installation

Either you can clone this repo and build in the usual way with `cargo build --release`. Or use `cargo install esrtool` to install it from [crates.io](https://crates.io/crates/esrtool).

# Usage

## Patching

Patching is done in place to maintain drop in compatibility with exisitng tools. But it is **lossy** maintain a clean rip of your discs for archive.

`esrtool p PATH_TO_ISO`

## Unpatching

`esrtool u PATH_TO_ISO`

**NOTE:** Unpatching is not clean, do not use it to store copies of the ISO. Instead maintain a clean one. Data is lost during the patching process. Infact many other tools I've tested drop junk into the file including potentially private environment data.

# License

MIT Licensed to fit with similar software. Also note notice in other ESR patching tools below.

repository: ali-raheem/esrtool

repo_name: ali-raheem/esrtool


text:
---
layout: default
title: Generating stubs using buf
nav_order: 0
parent: Generating stubs
grand_parent: Tutorials
---

# Generating stubs using buf

[Buf](https://github.com/bufbuild/buf) is a tool that provides various protobuf utilities such as linting, breaking change detection and generation. Please find installation instructions on [https://docs.buf.build/installation/](https://docs.buf.build/installation/).

It is configured through a `buf.yaml` file that should be checked in to the root of your Protobuf file hierarchy. Buf will automatically read this file if present. Configuration can also be provided via the command-line flag `--config`, which accepts a path to a `.json` or `.yaml` file, or direct JSON or YAML data. As opposed to `protoc`, where all `.proto` files are manually specified on the command-line, buf operates by recursively discovering all `.proto` files under configuration and building them.

The following is an example of a valid configuration, and you would put it in the root of your Protobuf file hierarchy, e.g. in `proto/buf.yaml` relative to the root of your repository.

```yaml
version: v1
name: buf.build/myuser/myrepo
```

To generate type and gRPC stubs for Go, create the file `buf.gen.yaml`:

```yaml
version: v1
plugins:
  - plugin: go
    out: proto
    opt: paths=source_relative
  - plugin: go-grpc
    out: proto
    opt: paths=source_relative
```

We use the `go` and `go-grpc` plugins to generate Go types and gRPC service definitions. We're outputting the generated files relative to the `proto` folder, and we're using the `paths=source_relative` option, which means that the generated files will appear in the same directory as the source `.proto` file.

Then run

```sh
$ buf generate
```

This will have generated a `*.pb.go` and a `*_grpc.pb.go` file for each protobuf package in our `proto` file hierarchy.

[Next](../creating_main.go.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 }

repository: grpc-ecosystem/grpc-gateway

gha_language: Go

repo_name: grpc-ecosystem/grpc-gateway


text:
---
layout: relation
title: 'vocative'
shortdef: 'vocative'
udver: '2'
---

The `vocative` relation is used when someone is being addressed directly in a dialogue.  Interlanguage links updated Út 9. května 2023, 20:04:34 CEST -->

repository: UniversalDependencies/docs

branch_name: refs/heads/pages-source

gha_language: HTML

repo_name: UniversalDependencies/docs


text:
<p align="center">

</p>

Tutorial: [FCB Token](https://medium.com/bitfwd/how-to-issue-your-own-token-on-ethereum-in-less-than-20-minutes-ac1f8f022793)

This FCB will take you through the steps of issuing your first ERC20 token on the Ethereum network using a single smart contract and MyEtherWallet.

This repo contains the sample solidity file:
```
contracts/erc20_tutorial.sol
```

Feel free to leave any issues and we will get back to you and help you out :)


text:
+++
title = "NRES / STAT 803 Week 2"
date = "2017-08-21T00:00:00Z"
math = false
highlight = false
weight = 803020

# Optional featured image (relative to `static/img/` folder).
[header]

caption = ""

+++

## Linear Model Review II

This week you will continue to review the concept of the linear model. This week will also see the first online paper discussion.

1. View videos by Wednesday, 10 am.

    * [Evaluating Assumptions](https://youtu.be/E27HcS9QaT0).

    * [Limits of the linear regression (not what it sounds like!)](https://youtu.be/MQbvvydPSyg).

2. Paper discussions board by Tuesday week 3.

    * Read Guthery and Bingham (2007) (See Files | Readings on Canvas for pdf).
      Post a quote that stimulated your interest, surprised you, or that you disagree with. Then comment on *at least* two other people's quotes. Once you have comments from two other people, post the reason why you picked that quote.

3. Online Friday 11 am, [lab #2](lab_2/), Q&A.

4. [Week 2 Homework](homework_2/).


text:
# JenTab
Matching Tabular Data to Knowledge Graphs

* Target Knowledge Graph (KG) is **Wikidata**
* Participant at [SemTab 2020: Semantic Web Challenge on Tabular Data to Knowledge Graph Matching](https://www.cs.ox.ac.uk/isg/challenges/sem-tab/2020/index.html)
* Solves the Semantic Table Annotation (STA) tasks
    * Cell Entity Annotation (CEA)
    * Column Type Annotation (CTA)
    * Column Property Annotation (CPA)

![tasks image!](images/tasks.png)

## Architecture
![architecture image!](images/architecture.png)

The image above shows the distributed architecture of JenTab. Here you are a brief description of each service:
* **Manager**: a central node, is responsible for load balancing and collects results, errors and audit records.
* **Runner**: client node which handles the communication among
    * pre-processing services (Clean Cells, Type Prediction )
    * Approach
    * Manager
* **Clean Cells**: aims at cells cleaning in terms of, either generic fix (encoding issues and data clean up) or by more specific cleaning based on the column type.
* **Type Prediction**: Classifies the table column into one of 4 types, those with Wikidata equivalence (QUANTITY, STRING, DATE and OBJECT)
    * OBJECT is our most important type, we look for cells annotation mappings for this type.
* **Lookup** & **Endpoint**: are proxies for the publicly available Wikidata lookup and endpoint. There, we perform our fuzzy search and SPARQL queries.
* **Generic Strategy**: pre-computed service, our primary solution handling miss-spellings.
* **Approach**: Encapsulates our pipeline in terms of several calls across the dependent services.

## Assets
[assets](/assets) folder conatins all the required materials by services. For example:
* The pre-trained word2vec model for AutoCorrect services.
* How the data should be organized, in terms of tables and targets.
* ... more details in the [ReadMe.md](/assets/README.md)
* Make sure that you have structured the **assets** folder before the **Quick Setup**

## Quick Setup
The fastest way to get JenTab up and running is via docker setup, with the following order.

1. Manager
```
cd services
docker-compose -f docker-compose.manager.yml up
```
2. Other services ```docker-compose -f docker-compose.yml up```
3. Runner ```python run.py```. Make sure that you point to the correct directory using ```cd /Runner```

* Note1: for basic understanding of docker commands, please visit the official documentation of [docker](https://docs.docker.com/get-started/).
* Note2: We also support native execution, but, in this case, you will setup each service on its own. So, we refer to:
    * each folder of each service under [services](/services).
    * [services.md](services/Services.md) summarizes the currently used services and their ports.

## Results

* [Submitted Solution Files](https://github.com/fusion-jena/JenTab_solution_files)
* [Pre-computed databases for Generic Strategy](https://github.com/fusion-jena/JenTab_precomputed_lookup)

## Materials
* Nora Abdelmageed, Sirko Schindler. **JenTab: A Toolkit for Semantic Table Annotations**. ([Accepted Paper](https://openreview.net/pdf?id=aZUGsoLdpa))
* Nora Abdelmageed, Sirko Schindler. **JenTab: Matching Tabular Data to Knowledge Graphs**. ([paper](http://ceur-ws.org/Vol-2775/paper4.pdf))
* [Ontology Matching workshop](http://om2020.ontologymatching.org/#prg) on 2 November 2020 ([video slides](https://drive.google.com/file/d/1LZzb4x2ay_Vys0qLP4t3rjiwgv368RJ5/view))

## Citation
`
@article{abdelmageed2021jentab,
  title={JenTab: A Toolkit for Semantic Table Annotations},
  author={Abdelmageed, Nora and Schindler, Sirko},
  booktitle={Knowledge Graph Construction (KGC) Workshop ESWC 2021, Accepted}
  year={2021}
}
`

`@inproceedings{abdelmageed2020jentab,
  title={Jentab: Matching tabular data to knowledge graphs},
  author={Abdelmageed, Nora and Schindler, Sirko},
  booktitle={The 19th International Semantic Web Conference (ISWC)},
  year={2020}
}
`

repository: muhammad-abbady/JenTab

repo_name: muhammad-abbady/JenTab


text:
# Server side extensions

Qlik's Server Side Extension feature enables you to extend the engine with custom calculations.

There are two ways you can do this; by defining custom functions, and by enabling runtime script evaluation.

## Functions

[Intro](https://github.com/qlik-oss/server-side-extension/blob/master/docs/writing_a_plugin.md#function-evaluation)

Functions are defined based on the input type you expect them to have and could be one of scalar, aggregation or tensor.

To explain them, we're going to assume we have the following data model:

Product group | Product | Sales
---|---|---
Snack|Chips|19
Snack|Popcorn|11
Snack|Cookies|18
Dairy|Cheese|12

```basic
LOAD * Inline [
Product group,Product,Sales
Snack, Chips, 19
Snack, Popcorn, 11
Snack, Cookies, 18
Dairy, Cheese, 12
];
```

Data in SSE is received in the shape of `bundle`s:

```js
const bundle = {
  rows: [{
    duals: [{ // columns
      numData, // numerical value of the dual
      strData, // string value of the dual
    }, /* ... */]
  }, /* ... */]
];
```

### Tensor (and Scalar)

Tensor is used when there is a one-to-one relationship between the fields in the cube and the expressions you provide to the SSE function.

If we use _Product group_ as dimension and pass in _sum(Sales)_ as a parameter to the function, we would receive one bundle with one row per _Product group_:

- `[48, 12]`

**Example**

The following example returns the value 'green' if the value of the expression _sum(Sales)_ is > 20, otherwise it returns 'red'.

The expression:

```basic
sse.color(sum(Sales));
```

The SSE function:
```js
function greenOrRed(request) {
  request.on('data', (bundle) => {
    const rows = [];
    bundle.rows.forEach((row) => {
      rows.push({ // for each row in the input bundle
        duals: [{ // we add one row to the output, containing only one dual
          // that dual must contain 'strData' because the return type of this function is STRING
          strData: row.duals[0].numData > 20 ? 'green' : 'red' // numData is expected to be valid since the dataType of the first param is NUMERIC
        ],
      });
    });
    request.write({ rows }); // send data back to Qlik engine
  }
}

// register the function
server.addFunction(greenOrRed, {
  functionType: q.sse.FunctionType.TENSOR,
  returnType: q.sse.DataType.STRING,
  name: 'color', // optional, if not specified the name will be the function itself ('greenOrRed')
  params: [{
    name: 'first',
    dataType: q.sse.DataType.NUMERIC
  }]
})
```

### Aggregation

Aggregation is used when there is a one-to-many relationship between the fields in the cube and the expressions you provide to the SSE function. Common use cases are calculating sum, avg, concatenation etc.

If we use _Product group_ as dimension and pass in _Sales_ as a parameter to the function, we would receive three bundles:

- For _Product group_ `'Snacks'`: `[19, 11, 18]`
- For _Product group_ `'Dairy'`: `[12]`
- For _total_: `[19, 11, 18, 12]`

**Example**

If we want to calculate the _sum_ of _Sales_ for each _Product group_, we simply aggregate the rows in each bundle:

```js
(bundle) => {
  let v = 0;
  bundle.rows.forEach((row) => {
    row.duals.forEach((dual) => {
      v += dual.numData;
    });
  });
  request.write({
    rows: [{ // return only one row, containing one dual
      duals: [{ numData: v }],
    }],
  });
}
```

## Script evaluation

Note! Enabling script evaluation is dangerous!

[Intro](https://github.com/qlik-oss/server-side-extension/blob/master/docs/writing_a_plugin.md#script-evaluation)

Script evaluation makes it easy to run some basic arithmetic and string manipulation.

To simplify the access to values inside scripts:

- bundles are first remapped into an `args` parameter. The values inside `args` are:
  - strings when parameter type is STRING
  - numbers when parameter type is NUMERIC
  - dual when parameter type is DUAL
- the script is evaluated by wrapping it inside a function:
  ```js
  function(args, params, common) {
    // script evaluated here
  }
  ```
  - `args` may be one of
    - `(string | number | dual)[][]` - when any of the `*Aggr` functions are called
    - `(string | number | dual)[]`
  - `params` <[Parameter](https://github.com/qlik-oss/server-side-extension/blob/master/docs/SSE_Protocol.md#qlik.sse.Parameter)[]>
  - `common` <[CommonRequestHeader](https://github.com/qlik-oss/server-side-extension/blob/master/docs/SSE_Protocol.md#qlik.sse.CommonRequestHeader)>
- values are then remapped back to appropriate bundles

**Example**

Calculate the sum of _Sales_ per _Product Group_:

```basic
HelloSSE.ScriptAggr('return args.reduce((prev, curr) => (prev + curr[0]), 0)', 'Sales')
```

In this example we're using one of the `*Aggr` functions, the value of `args` will then be:

- For _Product group_ `'Snacks'`: `[[19], [11], [18]]`
- For _Product group_ `'Dairy'`: `[[12]]`
- For _total_: `[[19], [11], [18], [12]`

**Example**

Return 'green' if the value of the expression _sum(Sales)_ is > 20, otherwise return 'red'.

```basic
sse.ScriptEvalExStr('N', 'return args[0] > 20 ? "green" : "red"', sum(Sales));
```

`args` will in this case be:

- For _Product group_ `'Snacks'`: `[48]`
- For _Product group_ `'Dairy'`: `[12]`

In this example, we use `*Ex` because we want to get the numeric value of `sum(Sales)` by specifying `N` as the first parameter. The values inside `args` will therefore be the `numData` part of the `dual`. We use `*Str` because we want a `string` as output.

repository: izlotnik/qlik-sse

repo_name: izlotnik/qlik-sse


text:
# Mailscript templates: GitHub action failure to notification

You can use this template to trigger OS level notifications whenever a GitHub action run fails.

In this template we will achieve this by redirecting github emails through a mailscript email address (or the subset related to a particular github org), then setting a workflow that forwards from that address to a mailscript daemon running on your local machine. The daemon will run a `node.js` script that bridges to the OS for notifications.

## Preparation

This template assumes you have `node.js v14` or higher installed.

Ensure you have the latest version of the mailscript cli:

```sh
npm install -g mailscript
```

Clone this repo locally and `cd` into its root. Install the node dependencies with:

```sh
npm install
```

Mailscript configuration can be setup on the command line or by importing from a yaml file.
Both are detailed bellow.

## Setup from Yaml

This repo includes a `./config.yml` file that on import will:

* Setup a github specific email address under your domain<EMAIL_ADDRESS>e.g<EMAIL_ADDRESS>* Setup a trigger that will filter out emails that are not Github Action run failures, by setting a rule that based on the metadata that Mailscript adds to github emails.
* Setup two actions
  * One to forward to the email address you used to sign up to Mailscript
  * One to send an email to a Mailscript daemon running on your local machine - the daemon will identify itself as `mylaptop`
* Finally two workflows are setup:
  * One to forward all emails coming into the<EMAIL_ADDRESS>address onto you signup account email address
  * One to forward Github Action run fail emails to the Mailscript daemon running on your local machine

The yaml file includes two mailscript specific variables: `$username` and `$account-email-address`. On import the cli will substitute the `username` associated
with your account, and for `$account-email-address` it will use the email address
used to signup to mailscript.

To import a mailscript yaml file:

```sh
mailscript sync:import --path ./config.yml
```

The config.yml is included here inline for convenience.

```yml
version: '0.2'
addresses:
<EMAIL_ADDRESS>    keys:
      - name: owner
        read: true
        write: true
triggers:
  - name: github-action-failed
    composition:
      - criteria:
          github.pr.buildFailed: true
actions:
  - name: mylaptop
    type: daemon
    config:
      daemon: mylaptop
  - name: forward-to-personal-email
    type: mailscript-email
    config:
      key: owner
      from<EMAIL_ADDRESS>      forward: $account-email-address
      type: forward
workflows:
  - name: forward-github-to-personal
    input<EMAIL_ADDRESS>    action: forward-to-personal-email
  - name: github-action-failures-to-daemon
    input<EMAIL_ADDRESS>    trigger: github-action-failed-trigger
    action: mylaptop
```

## Manual setup

Each of the elements in the config.yml above can be created with individual commands
at the command line.

First, setup a new mailscript address specifically for dealing with github emails (replacing `<username>` text with your mailscript username):

```sh
mailscript addresses:add --address<EMAIL_ADDRESS>```

Setup a trigger that will filter out emails that are not Github Action Run failed emails:

```sh
mailscript triggers:add \
  --name github-action-failed \
  --property github.pr.buildFailed \
  --equals true
```

Configure two actions, one to forward to your preferred email address, the other to send
emails to a named mailscript daemon (i.e. `mylaptop`) that can be run on your local machine (replace `<username>` and `<preferred-email-address>`):

```sh
mailscript actions:add \
  --name mylaptop \
  --daemon mylaptop

mailscript actions:add \
  --name forward-to-personal-email \
  --forward <preferred-email-address> \
  --from<EMAIL_ADDRESS>```

Setup a workflow that will use the existing `forward-github-to-personal` action to redirect all emails coming into<EMAIL_ADDRESS>to your preferred
email address, this will allow us to verify the mailscript address on GitHub (replace `<username>`):

```sh
mailscript workflows:add \
  --name forward-github-to-personal \
  --input<EMAIL_ADDRESS>\
  --action forward-to-personal-email
```

Create a workflow for send `Github Action run failed` emails to a named daemon to be run
on your local machine:

```sh
mailscript workflows:add \
  --name github-action-failures-to-daemon \
  --input<EMAIL_ADDRESS>\
  --trigger github-action-failed \
  --action mylaptop
```

Setup a workflow that waits for PR failed emails:

## Setup on Github

To send Github emails via mailscript before being forwarded on to your preferred
email address, we configure the<EMAIL_ADDRESS>as an allowed
email in GitHub.

After logging into GitHub, navigate to the email settings page:

https://github.com/settings/emails

Add the mailscript email address<EMAIL_ADDRESS>as an allowed github email via `Add email address`:

![Email Settings](./images/github_email_settings.png "Email Settings")

Github will send a verification email to the<EMAIL_ADDRESS>this will be forwarded on to your preferred email address as defined
in the workflow `forward-github-to-personal`.

Verify the sent email.

Once verified you can use<EMAIL_ADDRESS>for some or all of your github notifications. This is done under the `Notificaitons` tab:

https://github.com/settings/notifications

At the bottom of the page is the `Custom routing` section. You can choose which organizations to redirect via the mailscript address:

![Email Settings](./images/github_notification_settings.png "Email Settings")

Once redirected the two workflows will kick in forwarding the github emails
to your preferred account but directing build failures to your local daemon.

## Setup the local daemon

Run a local daemon using the daemon named in the workflow (i.e. `mylaptop`) that triggers the `notify.js` script whenever a `Github Action run failed` email is received:

```sh
mailscript daemon --daemon mylaptop --command "node ./notify.js"
```

The contents of the emails is passed to the script as stringified json within the environment variable `payload`.

repository: dnsxyz/cli

repo_name: dnsxyz/cli


text:
# windows-builder

An experimental Windows builder for Cloud Build.

## Getting started

If you are new to Google Cloud Build, we recommend you start by visiting the [manage resources page](https://console.cloud.google.com/cloud-resource-manager) in the Cloud Console, [enable billing](https://cloud.google.com/billing/docs/how-to/modify-project), [enable the Cloud Build API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com), and [install the Cloud SDK](https://cloud.google.com/sdk/docs/).

Grant Compute Engine permissions to your Cloud Build service account:

```sh
gcloud services enable compute.googleapis.com
export PROJECT=$(gcloud info --format='value(config.project)')
export MEMBER=$(gcloud projects describe $PROJECT --format<EMAIL_ADDRESS>gcloud projects add-iam-policy-binding $PROJECT --member=serviceAccount:$MEMBER --role='roles/compute.admin'
gcloud projects add-iam-policy-binding $PROJECT --member=serviceAccount:$MEMBER --role='roles/iam.serviceAccountUser'
```

Clone this repository and build the builder:
```sh
gcloud builds submit --config=builder/cloudbuild.yaml builder/
```

Then, refer to the builder in your project's `cloudbuild.yaml`.  To spin up an ephemeral `n1-standard-1` VM on Compute Engine, simply provide the command you wish to execute.  Your Cloud Build workspace is synchronized to `C:\workspace` at server startup.

```yaml
steps:
- name: 'gcr.io/$PROJECT_ID/windows-builder'
  args: [ '--command', '<command goes here>' ]
```

To use a custom Windows image, specify the image URL using the `--image` argument.

```yaml
steps:
- name: 'gcr.io/$PROJECT_ID/windows-builder'
  args: [ '--command', '<command goes here>',
          '--image', 'projects/$PROJECT_ID/global/images/my-windows-image']
```

The VM is configured by the builder and then deleted automatically at the end of the build.  Command is executed by `cmd.exe`; in most cases it will be a build script.

To use an existing Windows server instead, also provide the hostname, username and password:

```yaml
steps:
- name: 'gcr.io/$PROJECT_ID/windows-builder'
  args: [ '--hostname', 'host.domain.net',
          '--username', 'myuser',
          '--password', 's3cret',
          '--command', '<command goes here>' ]
```

You can also provide the VPC, Subnetwork, Region, and Zone parameters to specify where to create the VM:

```yaml
steps:
- name: 'gcr.io/$PROJECT_ID/windows-builder'
  args: [ '--network', '<network-name>',
          '--subnetwork', '<subnetwork-name>',
          '--region', '<region>',
          '--zone', '<zone>',
          '--command', '<command goes here>' ]
```

As the remote copy command provided is very slow if you have a number of files in your workspace, it is also possible to avoid copying the workspace (you can use GCS to copy the workspace instead):

```yaml
steps:
- name: 'gcr.io/$PROJECT_ID/windows-builder'
  args: [ '--network', '<network-name>',
          '--subnetwork', '<subnetwork-name>',
          '--region', '<region>',
          '--zone', '<zone>',
          '--not-copy-workspace',
          '--command', '<command goes here>' ]
```

Your server must support Basic Authentication (username and password) and your network must allow access from the internet on TCP port 5986.  Do not submit plaintext passwords in your build configuration: instead, use [encrypted credentials](https://cloud.google.com/cloud-build/docs/securing-builds/use-encrypted-secrets-credentials) secured with Cloud KMS.  In addition, you must clear up your workspace directory after use, and take care to manage concurrent builds.

## Examples

Several example builds are provided:

* [images/example](images/example) prints "Hello World!" from Windows
* [images/go-windows](images/go-windows) builds a Windows Go builder container
  image
* [images/go-example](images/go-example) builds a very simple Go application
  into a deployable Windows container.  This relies on the Windows Go builder
  from the step above.
* [images/docker-windows](images/docker-windows) builds a Windows container with
  a Docker executable inside - useful for building containers within a
  Docker context itself.
* [images/multi-arch_1909_2019](images/multi-arch_1909_2019) builds a multi-arch Windows container from servercore 1909 & ltsc2019.

## Performance

Starting an ephemeral VM on Compute Engine takes about 3 min 31 sec, broken down as follows:

| Step | Duration | Elapsed | Fraction |
|------|----------|---------|----------|
| Create new Compute Engine instance | 7 sec | 7 sec | 3% |
| Wait for password reset | 37 sec | 45 sec | 21% |
| Wait for Windows to finish booting | 2 min 39 sec | 3 min 24 sec | 76% |

Frequent builds will benefit from creating a persistent Windows VM.  To do this, see `scripts/start_windows.sh`.

Downloading and expanding archives is a common build step.  While Powershell offers functionality to do this (the `Expand-Archive` cmdlet) there are known performance issues.  See [PowerShell Archive issue #32](https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/32).

## Security

`windows-builder` communicates with the remote server using WinRM over HTTPS.  Basic authentication using username and password is currently supported.

For ephemeral VMs on Compute Engine, the initial password reset is performed [using public key cryptography](https://cloud.google.com/compute/docs/instances/windows/automate-pw-generation).  The cleartext password is never sent over an unencrypted connection, and is stored in memory for the duration of the build.

The latest version of Windows Server 2019 DC Core for Containers (patched 2019-12-10) is currently used.

By default, windows-builder creates an ingress firewall rule to open tcp:5986.  This allows windows-builder to communicate
with windows GCE instance over WinRM.  It's possible to avoid an external access by using a [private worker pool](https://cloud.google.com/build/docs/private-pools/private-pools-overview) and peering
it with your private VPC network.  With such set up windows-builder can communicate with GCE instance(s) over an internal network.  To do that you will need to [set up](https://cloud.google.com/build/docs/private-pools/set-up-private-pool-environment) your GCP network, create a [private worker pool](https://cloud.google.com/build/docs/private-pools/create-manage-private-pools), configure [Private Google Access](https://cloud.google.com/vpc/docs/configure-private-google-access), [configure](https://cloud.google.com/build/docs/private-pools/run-builds-in-private-pool) your builder to use a private worker pool, and use --use-internal-network windows-builder option in your cloudbuild.yaml.

Using internal network option precludes windows-builder from creating an external ip address for windows GCE instance.
You can use --create-external-ip (can only be used in conjunction with --use-internal-network) which would override the
default behavior and create an external IP address.  This can be useful in case you want to be able to RDP to your
GCE instance(s).

## Docker builds

Windows supports [two different types](https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container) of containers: "Windows Server containers", similar to the traditional Linux container, and "Hyper-V containers", which rely on Virtual Machines.  This code uses Windows Server containers, and as a result both the major and minor version of Windows must match between container and host.

The package manager in Windows Server 1803 provides Docker 17.06.  However to run a Docker executable inside a Docker container as Cloud Build typically does, version 17.09 or higher is required to bind-mount the named pipe: see [this pull request](https://github.com/StefanScherer/insider-docker-machine/pull/1).  e.g., `docker run -v '\.\pipe\docker_engine:\.\pipe\docker_engine' ...`

## Debugging WinRM

To debug issues with WinRM, Python users may find the [PyWinRM package](https://github.com/diyan/pywinrm) helpful, for example:

```python
from winrm.protocol import Protocol
p = Protocol(
    endpoint='https://<ip address>:5986/wsman',
    username=<username>,
    password=<password>,
    server_cert_validation='ignore')
shell_id = p.open_shell()
command_id = p.run_command(shell_id, 'ipconfig', ['/all'])
std_out, std_err, status_code = p.get_command_output(shell_id, command_id)
p.cleanup_command(shell_id, command_id)
p.close_shell(shell_id)
```


text:
# Generate 1password throwaways

Generates a CSV export containing rows of `Title`, `Username`, `Password`, `Notes`,
which can be imported into a 1Password vault ready to use for a throwaway account.

The `Notes` field contains suggestions for *full name*, *address*, *phone*, *birth date*, *occupation*, and *company*.

```sh
$ ./generate-1password-throwaways.py --identities data/identities.test
"vrmb untidyguitar","untidyguitar","Ljxfwcjrzijjql0-","Hallie L Gracia

2142 Columbia Mine Road
Monongah
WV 26554

304-534-7284

1981-05-23

Production cost estimator
Lawn N Order Garden Care
"
```

## Prerequisites

1. The `data/identities` folder should contain any number of fake identities in `.json` files,
2. as created by https://www.fakenamegenerator.com/ eg. using https://fakeid.now.sh/

3. The `ppg` command should return a fresh password, eg. by cloning https://github.com/aliclark/pragmatic-password-generator and creating a symlink `ppg` to `ppg.py` in the executable path

## Usage

```
usage: generate-1password-throwaways.py [-h] [--birth-year year] [--birth-year-variance years] [--identities directory] [--uk]

Generate throwaway logins for 1password.

optional arguments:
  -h, --help            show this help message and exit
  --birth-year year     birth year, which will be rounded down to the nearest 5 years
  --birth-year-variance years
                        number of random years to add or remove from birth year
  --identities directory
                        directory where the identity json files reside
  --uk                  use United Kingdom formatting, eg. for dates
```

* The `birth-year` default is `1980`
* The `birth-year-variance` default is `2`
* The `identities` default is `data/identities`


text:
---
title: Comprehensions in Python
description: Let's learn about comprehensions in Python
date: 2020-08-31
---

Python does not stop to surprise me. I am currently exploring comprehensions and decided to share some tips about it.
This is an exciting and powerful feature that allows us to write expressive code in a single line. Comprehension creates new sequences (lists, dictionaries, sets...) using sequences already defined.

**List Comprehension** can be used to replace for loops.

Suppose we want to create a list of squares of even numbers. The first thing that comes in mind would be using for loop, like the one below:

```Python
#Iterating over a list using for loop
new_list = []
for n in range(10):
      if n % 2 == 0:
         new_list.append(n**2)
print(new_list)

#output
[0, 4, 16, 36, 64]
```
Let’s see how to rewrite it in a single line of code

```Python
#Iterating over a list using list comprehension
new_list = [n ** 2 for n in range(10) if n % 2 == 0]
print(new_list)

#output
[0, 4, 16, 36, 64]
```
A basic form of List Comprehension is made as follows:
`new_list = [expression for item in list]`

In case of our example where we used conditional logic:
`new_list = [expression for item in list (if conditional)]`

**Dictionary Comprehension** is similar, but we need the key: value pairs to create a dictionary.

```Python
#Dictionary Comprehension
new_dict = {n: n ** 2 for n in range(10) if n % 2 == 0}
print(new_dict)

#output
{0: 0, 2: 4, 4: 16, 6: 36, 8: 64}
```
Less popular is **Set Comprehension**, which works in a similar way. It returns a set, which means the elements inside cannot contain any duplicates.

```Python
#Set Comprehension
numbers = [10, 10, 20, 30, 12, -20]
new_set = {n**2 for n in numbers}
print(new_set)

#output
{100, 144, 400, 900}
```

List comprehension can help us to write elegant code, but sometimes it is not the right choice. We should avoid writing long list comprehensions in one line to ensure that our final code is readable. Otherwise, it’s better to choose an alternative approach.

You can learn more about Comprehensions [here](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions)

gha_language: Vue