text:
# Spark

This document explains how to get started using SparkToolkit with Spark.

## Get and Initialize Spark Client Instance

```ruby
spark_client = SparkToolkit::Spark::Client.new(hadoop_conf)
```
## Set config metadate
```ruby
spark_conf = spark_client.get_spark_conf
spark_conf.set_app_name "example"
```

## Submit Spark Job

```ruby
# example of submit pi python job
args = ["--class", "org.apache.spark.deploy.PythonRunner",
        "--primary-py-file", "pi.py",
        "--arg", 2]
spark_conf.yarn_deploy_mode(:cluster) # or :client
spark_client.is_python_job(true)
spark_client.avtive_kerberos # If you want to submit job to secure cluster
# Submit your job to YARN and get its app_id for query
yarn_app_id = spark_client.yarn_submit(args)
# Or run as client, print all output into console
spark_client.yarn_run(args)
```


text:
# Autofix for ScalaTest 3.0.x
This scalafix rule will rewrite your ScalaTest code to eliminate most of the deprecation warnings
introduced in ScalaTest 3.0.8. The deprecations were primarily renames of packages containing integrations with
third-party libraries, such as JUnit, TestNG, Java mocking frameworks, Selenium, and ScalaCheck. The purpose
of these renames in 3.0.8 is to prepare the way for modularization of these third-party integrations in
ScalaTest 3.1.0. This will allow the third-party integrations to be versioned independently with ScalaTest.

To use this plugin with sbt, please follow these steps ([Maven](https://github.com/evis/scalafix-maven-plugin)
and [Mill](https://github.com/joan38/mill-scalafix) plugins are also available):

  - Add `sbt-scalafix` to your `project/plugins.sbt` (a [newer version](https://github.com/scalacenter/sbt-scalafix/releases) might be required for the latest Scala releases):

```
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.18-1")
```

  - If you have `-Xfatal-warnings` set, comment it out for the scalafix process, because otherwise
    the deprecation warnings will stop your build before autofix is given a chance to fix them.

```
// scalacOptions += "-Xfatal-warnings"
```

  - Enable scalafix for the current sbt session:

```
sbt> scalafixEnable
```

  - In the sbt prompt, issue the following command to have autofix applied to your main & test source files:

```
sbt> scalafixAll dependency:RenameDeprecatedPackage@org.scalatest:autofix:3.0.8-1
```

  - Check the changes made with `git diff`.

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3] - 2021-11-30
### Changed
- Dropped PHP5 support

## [1.0.2] - 2021-05-28
### Fixed
- only start session if not already started

## [1.0.1] - 2020-03-06
### Fixed
- php notice undefined `HTTP_ACCEPT_LANGUAGE` e.g. if script called via CLI or cURL without any header information

license: MIT

repository: pleinx/php-multilang-any

gha_language: PHP

repo_name: pleinx/php-multilang-any


text:
# dat.gui-midi-control

`STATUS: Abandoned`

**⚠ - Replaced by [@mollerse/midi-control](https://github.com/mollerse/midi-control)**

dat.gui with added functionality for controlling params with a midi device.

This is something I use for personal projects and will not be maintained as a proper library. Use at own risk.

If you want something maintaned, have a look at [`gregsadetsky/dat.gui.midi`](https://github.com/gregsadetsky/dat.gui.midi).


text:
# Exercise 5

1. Append Book mutation. Add the ability to append a book to the list of books.

2. Create a mutation to update a book to be connected to different author. How do you want to pass in author data?

3. Add mutations for adding and deleting employees.

- To do the delete, use the array filter method...


text:
---
title: 'PetIBM: toolbox and applications of the immersed-boundary method on distributed-memory architectures'
tags:
  - Computational Fluid Dynamics
  - Immersed-Boundary Method
  - PETSc
  - GPU
  - NVIDIA AmgX
authors:
 - name: Pi-Yueh Chuang
   orcid: 0000-0001-6330-2709
   affiliation: 1
 - name: Olivier Mesnard
   orcid: 0000-0001-5335-7853
   affiliation: 1
 - name: Anush Krishnan
   orcid: 0000-0001-6409-7022
   affiliation: 2
 - name: Lorena A. Barba
   orcid: 0000-0001-5812-2711
   affiliation: 1
affiliations:
 - name: Department of Mechanical and Aerospace Engineering, The George Washington University, Washington, DC, USA
   index: 1
 - name: nuTonomy Inc., Cambridge, MA, USA (previously at Boston University)
   index: 2
date: 25 January 2018
bibliography: paper.bib
---

# Summary

PetIBM is a C++ library with ready-to-use application codes to solve the two- and three-dimensional incompressible Navier-Stokes equations on fixed structured Cartesian grids with an immersed-boundary method (IBM).
PetIBM runs on distributed-memory architectures and can be used to compute the flow around multiple moving rigid immersed boundaries (with prescribed kinematics).

In the IBM framework, a collection of Lagrangian markers defines the immersed boundary (where boundary conditions are enforced) and the fluid equations are solved over the extended domain (including the body domain).
The Eulerian mesh remains unmodified when computing the flow around multiple moving immersed bodies, which removes the need for remeshing at every time step.

It implements two immersed-boundary algorithms: the immersed-boundary projection method (@taira_colonius_2007) and its decoupled version (@li_et_al_2016).

Other open-source software packages offer immersed-boundary solvers: for example, IBAMR (@griffith_et_al_2007, @bhalla_et_al_2013) is a long-standing C++ library with MPI parallelization that also provides adaptive mesh refinement.
It can handle deforming immersed bodies and has been used in a variety of scenarios, including cardiac fluid dynamics, swimming, insect flight, and others.
PetIBM and IBAMR use different immersed-boundary schemes, however. We developed PetIBM to work with the immersed-boundary projection method, which is based on the fully discrete formulation of Perot on staggered grids and thus eliminates the need for pressure boundary conditions, which have caused many headaches for CFD practitioners (@gresho_sani_1987, @sani_gresho_1994).
PetIBM features an operator-based design, providing routines to create and manipulate discrete operators (e.g., gradient, divergence, Laplacian, convection, diffusion, etc.), so it can be used as a toolbox for researching new solution methods.
It is also capable of using graphics processing unit (GPU) architectures, a feature missing from other software, as far as we know.
A previous project implementing immersed-boundary methods on GPU architecture is cuIBM (@krishnan_et_al_2017), but it is limited to two-dimensional problems that fit on a single GPU device.

PetIBM is written in C++ and relies on the PETSc library (@petsc_1997, @petsc_user_ref_2017) for data structures and parallel routines to run on memory-distributed architectures.
PetIBM can solve one or several linear systems on multiple distributed CUDA-capable GPU devices with the NVIDIA AmgX library and AmgXWrapper (@chuang_barba_2017).
The software package includes extended documentation as well as many examples to guide users.

PetIBM has already been used to generate results published in @mesnard_barba_2017, a full replication of a study on the aerodynamics of a gliding snake species (@krishnan_et_al_2014).
PetIBM is currently used to compute the three-dimensional flow of a gliding-snake model on the cloud platform Microsoft Azure.

## Appendix: mathematical formulation

PetIBM solves the Navier-Stokes equations on an extended discretization grid that includes the interior of the immersed boundary.
To model the presence of the boundary, a forcing term is added to the momentum equation and an additional equation for the no-slip condition completes the system.
Variants of the immersed-boundary method (IBM) depend on how one models the forcing.
In PetIBM, we use regularized-delta functions to transfer data between the Eulerian grid and the Lagrangian boundary points.
The system of equations is:

\begin{equation}
\begin{cases}
\frac{\partial \mathbf{u}}{\partial t} + \mathbf{u} \cdot \nabla \mathbf{u} = -\nabla p + \frac{1}{Re} \nabla^2 \mathbf{u} + \int_{s}{\mathbf{f} \left( \mathbf{\xi} \left( \mathit{s}, \mathit{t} \right) \right) \delta \left( \mathbf{\xi} - \mathbf{x} \right)} d\mathit{s} \\
\nabla \cdot \mathbf{u} = 0 \\
\mathbf{u} \left( \mathbf{\xi} \left( \mathit{s}, t \right) \right) = \int_{\mathbf{x}}{\mathbf{u} \left( \mathbf{x} \right)} \delta \left( \mathbf{x} - \mathbf{\xi} \right) d\mathbf{x}
\end{cases}
\end{equation}

where $\mathbf{u}$ is the velocity field, $p$ is the fluid pressure, and $Re$ is the Reynolds number.

Currently, PetIBM provides two application codes implementing different versions of the IBM: (1) an immersed-boundary projection method (IBPM) based on the work of @taira_colonius_2007 and (2) a decoupled version of the IBPM proposed by @li_et_al_2016.
Those two methods fit into the framework of the projection approach of @perot_1993.
The equations are fully discretized (space and time) to form an algebraic system to be solved for the velocity $u^{n+1}$, the pressure field $\phi$, and the Lagrangian forces $\tilde{f}$.
The discretized system is:

\begin{equation}
\left[
\begin{matrix}
A & G & H \\
D & 0 & 0 \\
E & 0 & 0
\end{matrix}
\right]
\left(
\begin{matrix}
u^{n+1} \\
\phi \\
\tilde{f}
\end{matrix}
\right)
=
\left(
\begin{matrix}
r^n \\
0 \\
u_B^{n+1}
\end{matrix}
\right)
+
\left(
\begin{matrix}
bc_1 \\
bc_2 \\
0
\end{matrix}
\right)
\end{equation}

where $D$, $G$, and $A$ are the divergence, gradient, and implicit operators, respectively.
$E$ and $H$ are the interpolation and spreading operators, respectively, used to transfer the data between the Eulerian grid and the Lagrangian boundary points.
On the right-hand side, $r^n$ gathers all the explicit terms and $u_B^{n+1}$ is the known (prescribed) boundary velocity; $bc_1$ and $bc_2$ contain the boundary terms that arise from the discretization of momentum and continuity equations, respectively.

In the IBPM, we solve a modified Poisson system for the pressure field and Lagrangian forces, coupled together.
This way, the divergence-free condition and no-slip constraint are simultaneously enforced on the velocity field at the end of the time step.
The fully discretized system can be cast into the following:

\begin{equation}
\left[
\begin{matrix}
A & Q_2 \\
Q_1 & 0
\end{matrix}
\right]
\left(
\begin{matrix}
u^{n+1} \\
\lambda
\end{matrix}
\right)
=
\left(
\begin{matrix}
r_1 \\
r_2
\end{matrix}
\right)
\end{equation}

with

\begin{equation*}
Q_1 \equiv \left[ \begin{matrix} D \\ E \end{matrix} \right] ;\
Q_2 \equiv \left[ G, H \right] ;\
\lambda \equiv \left( \begin{matrix} \phi \\ \tilde{f} \end{matrix} \right) ;\
r_1 \equiv r^n + bc_1 ;\
r_2 \equiv \left( \begin{matrix} bc_2 \\ u_B^{n+1} \end{matrix} \right)
\end{equation*}

In practice, we never form the full system.
Instead, we apply a block-LU decomposition as follows:

\begin{equation}
\left[
\begin{matrix}
A & 0 \\
Q_1 & -Q_1A^{-1}Q_2
\end{matrix}
\right]
\left[
\begin{matrix}
I & A^{-1}Q_2 \\
0 & I
\end{matrix}
\right]
\left(
\begin{matrix}
u^{n+1} \\
\lambda
\end{matrix}
\right)
=
\left[
\begin{matrix}
A & 0 \\
Q_1 & -Q_1A^{-1}Q_2
\end{matrix}
\right]
\left(
\begin{matrix}
u^* \\
\lambda
\end{matrix}
\right)
=
\left(
\begin{matrix}
r_1 \\
r_2
\end{matrix}
\right)
\end{equation}

Thus, we retrieve the sequence of operations of the traditional projection method.
We solve a system for an intermediate velocity field that is corrected, after solving a modified Poisson system for the variable $\lambda$, to enforce the divergence-free condition and the no-slip constraint at the location of the immersed boundary.
The sequence is:

\begin{align}
& A u^* = r_1 \\
& Q_1A^{-1}Q_2 \lambda = Q_1 u^* - r_2 \\
& u^{n+1} = u^* - A^{-1}Q_1 \lambda
\end{align}

The IBPM implemented in PetIBM solves, at every time step, Equations (5) to (6).
(Note: the inverse of the implicit operator $A^{-1}$ is approximated by a finite Taylor series expansion.)

The IBPM requires solving, at each time step, an expensive modified Poisson system, $Q_1A^{-1}Q_2$, whose non-zero structure changes when the location of the immersed boundary is moving.
In the PetIBM implementation of the decoupled IBPM, we apply a second block-LU decomposition to decouple the pressure field from the Lagrangian forces and recover a classical Poisson system.
The fully discretized algebraic system can be cast into:

\begin{equation}
\left[
\begin{matrix}
A & H & G \\
E & 0 & 0 \\
D & 0 & 0
\end{matrix}
\right]
\left(
\begin{matrix}
u^{n+1} \\
\tilde{f} \\
\phi
\end{matrix}
\right)
=
\left(
\begin{matrix}
r^n \\
u_B^{n+1} \\
0
\end{matrix}
\right)
+
\left(
\begin{matrix}
bc_1 \\
0 \\
bc_2
\end{matrix}
\right)
\end{equation}

The velocity $u^{n+1}$ and the Lagrangian forces $\tilde{f}$ are coupled together to form a new unknown $\gamma^{n+1}$, as follows:

\begin{equation}
\left[
\begin{matrix}
\bar{A} & \bar{G} \\
\bar{D} & 0
\end{matrix}
\right]
\left(
\begin{matrix}
\gamma^{n+1} \\
\phi
\end{matrix}
\right)
=
\left(
\begin{matrix}
\bar{r_1} \\
\bar{r_2}
\end{matrix}
\right)
\end{equation}

where

\begin{equation*}
\bar{A} \equiv \left[ \begin{matrix} A & H \\ E & 0 \end{matrix} \right] ;\
\bar{G} \equiv \left[ \begin{matrix} G \\ 0 \end{matrix} \right] ;\
\bar{D} \equiv \left[ \begin{matrix} D & 0 \end{matrix} \right]
\end{equation*}

and

\begin{equation*}
\gamma^{n+1} \equiv \left( \begin{matrix} u^{n+1} \\ \tilde{f} \end{matrix}\right) ;\
\bar{r_1} \equiv \left( \begin{matrix} r_n + bc_1 \\ u_B^{n+1} \end{matrix}\right) ;\
\bar{r_2} \equiv bc_2
\end{equation*}

Two successive block-LU decompositions are applied to decouple the Lagrangian forces $\tilde{f}$ from $\gamma^{n+1}$ and to decouple the velocity from the pressure field.

The first block-LU decomposition decouples the pressure field from the new unknown $\gamma^{n+1}$:

\begin{equation}
\left[
\begin{matrix}
\bar{A} & 0 \\
\bar{D} & -\bar{D}\bar{A}^{-1}\bar{G}
\end{matrix}
\right]
\left[
\begin{matrix}
I & \bar{A}^{-1}\bar{G} \\
0 & I
\end{matrix}
\right]
\left(
\begin{matrix}
\gamma^{n+1} \\
\phi
\end{matrix}
\right)
=
\left[
\begin{matrix}
\bar{A} & 0 \\
\bar{D} & -\bar{D}\bar{A}^{-1}\bar{G}
\end{matrix}
\right]
\left(
\begin{matrix}
\gamma^* \\
\phi
\end{matrix}
\right)
=
\left(
\begin{matrix}
\bar{r_1} \\
\bar{r_2}
\end{matrix}
\right)
\end{equation}

which leads to the following sequence of operations:

\begin{align}
& \bar{A} \gamma^* = \bar{r_1} \\
& \bar{D}\bar{A}^{-1}\bar{G} \phi = \bar{D} \gamma^* - \bar{r_2} \\
& \gamma^{n+1} = \gamma^* - \bar{A}^{-1}\bar{G} \phi
\end{align}

A second block-LU decomposition is applied to the first equation above:

\begin{equation}
\left[
\begin{matrix}
A & 0 \\
E & -EA^{-1}H
\end{matrix}
\right]
\left[
\begin{matrix}
I & A^{-1}H \\
0 & I
\end{matrix}
\right]
\left(
\begin{matrix}
u^* \\
\tilde{f}
\end{matrix}
\right)
=
\left[
\begin{matrix}
A & 0 \\
E & -EA^{-1}H
\end{matrix}
\right]
\left(
\begin{matrix}
u^{* *} \\
\tilde{f}
\end{matrix}
\right)
=
\left(
\begin{matrix}
r^n + bc_1 \\
u_B^{n+1}
\end{matrix}
\right)
\end{equation}

and we end up with the following sequence:

\begin{align}
& A u^{* *} = r^n + bc_1 \\
& EA^{-1}H \tilde{f} = E u^{* *} - u_B^{n+1} \\
& u^* = u^{* *} - A^{-1}H \tilde{f}
\end{align}

The decoupled version of the IBPM implemented in PetIBM solves, at every time step, Equations (15) to (17) followed by Equations (12) and (13).

# References

repository: barbagroup/PetIBM

repo_name: barbagroup/PetIBM


text:
# eslint-config-with-prettier

These are my default ESLint and Prettier settings ⚡

> Based on [`Upstatement`](https://github.com/Upstatement)'s [`ESLint`](https://eslint.org/) and [`prettier`](https://prettier.io) configurations.
> Check their documentation on [`Prettier configuration`](https://www.npmjs.com/package/@upstatement/prettier-config) and [`ESLint configuration`](https://www.npmjs.com/package/@upstatement/eslint-config).

## Installation

1. We need to install everything needed by the config:

```sh
# using npx

npx install-peerdeps --dev @ryuuto829/eslint-config-with-prettier

# OR using npm

npm install --save-dev @ryuuto829/eslint-config-with-prettier eslint babel-eslint prettier eslint-config-prettier eslint-plugin-prettier

# OR using yarn

yarn add --dev @ryuuto829/eslint-config-with-prettier eslint babel-eslint prettier eslint-config-prettier eslint-plugin-prettier
```

2. Create an `.eslintrc` file at the root of your project with the following:

```json
{
  "extends": ["@ryuuto829/eslint-config-with-prettier"]
}
```

3. Create a `prettier.config.js` file at the root of your project that contains:

```js
module.exports = require('@ryuuto829/eslint-config-with-prettier/prettier');
```

4. (Optional) Add `.editorconfig` file to the root of the project:

```pl
# This file is for unifying the coding style for different editors and IDEs
# Read more: http://editorConfig.org

# Top-most EditorConfig file
root = true

# Global
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
```

5. (Optional) You can add two scripts to your `package.json` to lint and/or fix:

```json
"scripts": {
  "lint": "eslint .",
  "lint:fix": "eslint . --fix"
},
```

## Using with React

1. Install additional dependencies:

```sh
# If project includes deafult config

yarn add --dev eslint-plugin-react eslint-plugin-jsx-a11y

# OR initiate empty project with react config

yarn add --dev @ryuuto829/eslint-config-with-prettier eslint babel-eslint prettier eslint-config-prettier eslint-plugin-react eslint-plugin-jsx-a11y
```

2. Create an `.eslintrc` file at the root of your project with the following:

```json
{
  "extends": ["@ryuuto829/eslint-config-with-prettier/react"]
}
```

## Pre-commit Hook

You can use [`lint-staged`](https://github.com/okonet/lint-staged) with [`husky`](https://github.com/typicode/husky), which manages git hooks and automatically fix your errors on commit.

1. Install following dependencies:

```sh
yarn add --dev lint-staged husky
```

2. Update your `package.json` like this:

```json
"husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,jsx,ts,tsx,css,json,md}": [
      "prettier --write"
    ],
    "*.js": [
      "eslint --fix"
    ]
  }
```

## Specifying Environments

```json
{
  "extends": ["@ryuuto829/eslint-config-with-prettier"],
  "env": {
    "browser": true,
    "node": true,
    "jest": true
  }
}
```

## Integration with Visual Studio Code

1. Install Prettier extension: `View → Extensions` then find and install Prettier - Code formatter.
2. Install the ESLint extension: `View → Extensions` then find and install ESLint.
3. Reload the editor.
4. In your user settings:

```js
// Format on save with Prettier rules
"editor.formatOnSave": true,
// Tell the ESLint plugin to run on save
"editor.codeActionsOnSave": { "source.fixAll.eslint": true }
```

license: ISC


text:
---
layout: post
title:  "Useful Git Stats Part 2"
date:   2015-02-08 14:00:00
categories: code
---

So [last time]({{ site.baseurl }}/code/useful-git-stats/) I posted about a way to find out how much code you've written since a given period of time. That ends up printing something like:

```21 files changed, 403 insertions(+), 92 deletions(-)```.

But today I was writing up a blog post recapping development over a long period of time and wanted to figure out how many commits I had pushed since my last post. Now I could have done this by counting through 8 pages of commits on github or scroll through the output of `git log` but I figured there'd be a better way.

After a quick search I found the command `git shortlog` which prints out a list of the all the contributors for the current repo with a list of their commits. Combine this with the `--since` flag which parses date strings like "2014-09-22T00:00:00-00:00" as well as human readable strings like "one week", and you have a pretty awesome way to see how many commits you've pushed to a repo in a given period of time.

So to get the number of commits I pushed in the last week I'd do:

```$ git shortlog --since="last week"```

Which for my game repo outputted:

<img class="not-even-baked"  src="{{ site.baseurl }}/images/useful-git-stats-2-1.png">

You can shorten this even more by passing the -s flag if you just care about the number and don't need the list of commits outputted afterwards. I.e. `git shortlog -s --since="last week"` which would then just output: ```17 Stefan Valentin```


text:
# sftp-rest-client
A REST endpoint to perform SFTP operations on any accessible server from the microservice's location.

You can use this service when you need a files be pulled from a remote servers which you
do not have access, but a central location can be configured to. Just run this
service on the central location and issue REST calls to either transfer the file,
or echo it back on HTTP.

> Note of caution: Echoing binary files over HTTP may have unforeseen issues.
> Recommended to use pulling to local location as file itself.

repository: dialoglk/sftp-rest-client

gha_language: Java

gha_license_id: MIT

repo_name: dialoglk/sftp-rest-client


text:
## 6. IMPLEMENTED PROTOTYPE

The prototype of the whole Edge Gateway system is composed by three elements:

* The Edge Gateway
* The environmental weather station
* The Energy measure station

The main components of the Edge Gateway are:

* Rasperry PI 3-B board
* An I2C Temperature/humidity sensor directly connected to the RPI 3
* A 16GB microSD class 10 card used to store the OS.
* A customized version of the Arch Linux OS for RPI. The customization add the following features:
	* *Access Point* mode for the Wifi needed for the first system configuration and the connection of external stations;
	* Management tools for Docker containers and the pre-installed Git repositories;
	* The script for the automatic start of Docker containers at boot time;

* Demo code for microservices:
	* dispatcher (EDGE_dispatcher) to send gathered data to the cloud;
	* weahter handler (FEINSTAUB_publisher) to implement the interface to the environmental weather station;
	* energy handler (IOTAWATT_publisher) to interface to the energy station;
	* test handler (HTU21D_publisher) for the directly connected HTU21D sensor for temperature and humidity data recording;
	* Docker container with a running InfluxDB database;
	* Docker container with a running instance of Grafana to enable the local visualization of data
	* Docker container with the local brocker of MQTT messages of Mosquitto handlers

The prototype has been integrated with two measure system after a phase of evaluation and testing and, in the case of the environmental weather station, a firmware customization/extension to add new functionalities.
The integrated systems are:

* Energy monitoring system IotaWatt, with 5 current probes e 1 voltage probe connected to the main electrical panel and to the HVAC;
* Environmental weather station Stuttgart Fine Dust Sensor (Feinstub code) with:
	* Argent system anemometer and wind direction sensor;
	* Davis anemometer and wind direction sensor;
	* Argent system rain gauge sensor;
	* Hydreon RG11 infrared rain sensor;
	* temperature/Humidity sensro DHT22;
	* Nova Fitness SDS11 particulate sensor for PM10 and PM 2.5

Edge Gateway with  HTU21D test sensor                            |
--------------------------------------------------------------------- |
![Edge Gateway con il sensore di prova HTU21D](../../img/edge-htu21d.jpg) |

Environmental weather station with particulate and temperature/humidity sensor                                     |
------------------------------------------------------------------------------------------------- |
![La stazione meteo/ambientale col sensore di particolato e T/H](../../img/outdoor-meteo-station.jpg) |

Argent system anemometer, wind direction and rain gauge sensor                           |
------------------------------------------------------------------ |
![Sensori vento e pioggia Argent System](../../img/argent-system.jpg) |

Davis anemometer, wind direction sensors                   |
--------------------------------------------------- |
![Anemomentro e Segnavento Davis](../../img/davis.jpg)  |

Energy monitoring station IotaWatt  connected to the main electrical panel                        |
-------------------------------------------------------------------------------------- |
![La stazione di monitoraggio elettrico IotaWatt installata](../../img/iotawatt-panel.jpg) |

Laboratory testing of the standalone solution with the Edge Gateway and environmental weather station                              |
------------------------------------------------------------------------------------------------------------ |
![Testing in laboratorio della soluzione standalone Edge Gateway – Stazione Meteo](../../img/edge-meteo-lab.jpg) |

repository: tdm-project/tdm-edge

repo_name: tdm-project/tdm-edge


text:
+++
canonical = "https://elogii.com/blog/how-to-choose-delivery-driver-app/"
categories = ["Delivery Management Software"]
date = 2021-03-05T11:00:00Z
description = "If the driver app is a key feature you’re looking for in delivery management software, in this post will show you exactly how to choose the delivery driver app."
image = "/blog/uploads/how-to-choose-delivery-driver-app.jpg"
tags = ["Delivery Route Planner", "Delivery Schedules", "Last Mile Delivery", "Electronic Proof of Delivery", "Driver Management", "Driver App"]
title = "How to Choose a Delivery Driver App?"
titletag = "How to Choose a Delivery Driver App?"
type = "post"

+++
In this article, you’ll see how exactly to choose the Delivery Driver App.

Specifically, we’ll show you:

* What a delivery driver app is in the first place
* How do these kinds of apps work in real life
* The benefits of using one in your last-mile delivery
* And what to look for when choosing one

So if the driver app is a key feature you’re looking for in delivery management software, this post will help you make a better decision.

Let's get started.

## What is a delivery driver app?

**The delivery driver app** is one of two components of the [**driver route planning software**](https://elogii.com/blog/driver-route-planning-software/).

The other one is the **delivery management platform** (or dashboard).

![delivery management platform](/blog/uploads/delivery-driver-management-platform.png)

The app is specifically designed for drivers. It has tools and features that make it easier for drivers to carry out their tasks.

![delivery driver app](/blog/uploads/delivery-driver-app.png)

The app enables drivers, couriers, and other field agents **to access data about their routes, schedules, and tasks** while they’re delivering goods or services to your customers.

The apps also should include tools, such as **onboard navigation, automated reporting, and electronic proof of delivery (ePOD)**.

But at the same time, the delivery driver app benefits route planners and delivery operations managers.

**The app is integrated with the software.** The in-device [**geolocation**](https://developers.google.com/maps/documentation/javascript/geolocation#:\~:text=Open%20in%20JSFiddle-,What%20is%20Geolocation%3F,is%20a%20device%2Dspecific%20API.) allows users to track the positions of drivers on the map.

This allows planners and managers to **use the software dynamically**. They can use the system to schedule new orders, adjust routes, or dispatch drivers, all in real-time.

## How do delivery driver apps work?

The app is a blend of various tools, including task management, reporting, ePOD, in-app chat, and navigation.

Think, Google Maps but with a much richer environment.

So while it’s difficult to do [**route optimization using Google Maps**](https://elogii.com/blog/route-optimization-using-google-maps/), with this software it isn’t.

**The delivery driver app is integrated with the route planning software.**

As soon as you map the routes and stops for a driver, the system uploads the information directly to the app.

**Drivers can't change the data using the app.** Instead, they can only access it.

Technically, they use it as a task management system to see what they need to do and how to do it based on your plans.

The app also relies on mobile data, geocoding, and GPS to locate the device on the map.

This enables you to **track driver progress in real-time**, without the need for any onboard vehicle telematics. But it can integrate with telematics systems, as well.

Other than that, the driver delivery app works like any other app you have on your phone.

You download the app via Google Play (for Android devices) and the Apple Store (for iOS).

Then, you install it on the device and connect it to your main account.

You can then use the dashboard to manage users (drivers and delivery agents) and create assignments.

The app displays all of that information on a map. (Which you can integrate with Google Maps or Waze, as well)

While the in-app menu gives drivers access to tools they need to complete these tasks.

## The benefits of Delivery Driver Apps

[**Delivery management software**](https://elogii.com/blog/what-is-delivery-management-software/) works in any business environment.

You can use it regardless of the size and complexity of your last mile.

It works well in a number of different scenarios, including food delivery, [**pharmacy delivery**](https://elogii.com/blog/uninterrupted-pharmacy-delivery/), or [**field service operations**](https://elogii.com/blog/how-do-you-successfully-manage-your-field-service-using-software/).

The software also works with both internal and external delivery fleets. So you can use it even if you rely on third-party logistics providers.

Besides that, there are many other advantages of using driver route optimization software. And the apps that support it.

So let’s find out what they are.

Here are seven benefits of delivery driver apps:

### #1 Removes the need for manual dispatch

Are you still [**manually planning deliveries**](https://elogii.com/blog/are-you-still-planning-manually/)?

Let's be honest for a second: manual dispatching is a thing of the past.

It’s impossible to think that any e-commerce would be possible without automation.

It’s just as impossible to think that Amazon other retail giants would be where they are without it.

And in 2020, it became clear just how important technology was, as businesses relied on [**delivery software to survive COVID-19**](https://elogii.com/blog/the-state-of-delivery-in-time-of-the-coronavirus/).

That’s why automation is the most significant feature of delivery management software.

Besides route planning, optimization, scheduling, **the software also enables automated dispatch thanks to the delivery driver app**.

Because you don’t have to use paper to create driver schedules, drivers can receive daily workloads much faster.

**The app streamlines internal communication** as well.

So, instead of physically dispatching each driver to a drop-off location, all you have to do is create a new task on the dashboard. While the system uploads it onto their app.

This means you don’t have to rely on fixed routes anymore.

You can plan deliveries as soon as an order request arrives, which drastically raises your rate of fulfillment.

### #2 Better driver navigation

A delivery driver app isn’t a run-of-the-mill navigation system.

Instead of distance and calculating the shortest path between point A and point B, **the software determines the quickest route between two stops**.

![route optimization](/blog/uploads/route-optimization-in-london.jpg)

This improves navigation, as drivers spend less time on the road by avoiding situations that affect the speed of fulfillment, such as traffic congestion.

From a business point of view, this means **lower cost per delivery** and **increased operational capacity**.

(Even [**when delivery demand exceeds your capacity**](https://elogii.com/blog/how-to-improve-last-mile-delivery-when-demand-exceeds-your-capacity/))

But the driver app allows drivers to navigate the last mile more efficiently, as well.

The maps on the apps use GPS and [**geocoding**](https://en.wikipedia.org/wiki/Address_geocoding), which means **the maps are always up-to-date**.

Drivers can rely on the routes you plan for them because they are always accurate. And that means fewer missed deliveries due to incorrect directions.

Likewise, this type of software takes [**a cloud-first approach to delivery logistics**](https://elogii.com/blog/adopting-the-cloud-first-approach-to-delivery-logistics/).

[**Cloud technology**](https://www.gartner.com/en/information-technology/insights/cloud-strategy) allows you to store historical data and use it to improve navigation beyond the streets.

Drivers can find return customers simply because other drivers have already delivered orders to them.

And in urban environments, that can shave off minutes from the time it takes to locate customers in residential and office buildings.

### #3 On-demand order and customer information

The interest in on-demand delivery has been increasing steadily over the last few years.

Today, **70% of customers** are willing to pay more for faster, more convenient delivery, according to [**delivery statistics**](https://elogii.com/blog/delivery-statistics-2020/).

While [**57% of those customers**](https://www.statista.com/statistics/817130/major-services-logistics-customers-demand-for-in-last-mile-delivery/) also demand _same-day_ delivery.

So that means you’ll have to increase your delivery offer to include additional options besides standard delivery.

And without the help of software, your company won't be able to provide this kind of delivery experience.

### #4 Less communication between teams

With the help of driver management software, your teams won't lose any time on unnecessary communication.

Delivery driver mobile app streamlines communication between teams with the help of the **onboard chat**.

Drivers can use the chat for internal communication with customer support and dispatch. But only in situations where it’s absolutely necessary.

For example, if a driver’s vehicle has problems on the road, he can use it to contact the maintenance team directly. (Without the need to go through standard channels)

**Dispatchers can modify routes without actually having to speak to the drivers.**

While dispatch doesn’t remain blind to the driver’s activities.

They can track the location of drivers automatically via the map on their dashboard:

But also receive reports as soon as drivers complete a task.

### #5 Enables driver-customer communication

The onboard chat also allows drivers to **get in touch with customers** using a mobile app for drivers.

This allows your business to [**use delivery management software to improve customer experience**](https://elogii.com/blog/delivery-management-software-and-customer-experience/).

For example, as a driver sets off to a drop-off location, he can send quick messages to customers telling them that he’s on his way.

[**Customers love direct communication**](https://www.entrepreneur.com/article/293994) like this because it gives them a sense of greater value.

Customers will feel as if they’re doing business with a human being rather than a company.

And that can lead to **repeat business**, simply because they already know who they’re dealing with.

### #6 Up-to-the-minute reporting

The delivery driver app allows **real-time updates directly to dispatch**.

This gives you a critical feedback loop when the drivers set off on their routes. But it also helps you stay on top of the operations.

When a driver is running late, for instance, or something surprising happens on the road, you can see this and alert customers about the delay.

This helps ease any tension on the customer’s part and makes life easier for your drivers.

### #7 Electronic proof of delivery

**Proof of delivery (POD)** is important documentation that confirms that an item has been delivered to a customer. Just like a receipt.

But unlike traditional PODs, delivery driver apps have a built-in [**electronic (or digital) proof of delivery (ePOD)**](https://elogii.com/blog/electronic-proof-of-delivery-epod-how-does-it-improve-logistics-operations/).

![electronic proof of delivery](/blog/uploads/electronic-proof-of-delivery-epod.png)

So instead of collecting paper forms from customers and then handing them over at the end of a workday, **drivers can send ePODs as soon as they get them**.

Drivers can collect delivery confirmations by using several different methods:

* Taking electronic signatures
* Taking photographs
* Scanning QR and barcodes
* Getting unique alphanumeric codes
* Filling out forms and notes

All of this means that drivers can spend less time at the customer’s door, which improves their output.

While at the same time, it removes any delays usually associated with manual reporting.

And because all ePODs are stored on the cloud, dispatchers and fleet managers can easily access them whenever they need to.

## How to choose the best driver app?

Now that you know how route optimization software can benefit your delivery, it’s time to choose the best solution for your business.

One way to go about this is to look at the driver app.

To help you, we’ve listed the main features you should keep in mind when choosing the best driver app for your drivers.

Let’s take a look.

### #1 Choose the software first, and the app second

Before you even start thinking about the delivery driver app you need to **choose the right software**.

To do that, you should **evaluate your operations**:

* How many vehicles do you have in your fleet?
* How many do you want to add in the future?
* How many deliveries do you handle on average?
* What are your goals for your delivery operations?
* What do you wish to achieve with the software?

Taking the time to fully understand your delivery will help you learn [**how to choose the right delivery management software**](https://elogii.com/blog/how-to-choose-delivery-management-software/) for your business.

And if you choose a quality software solution, it’s bound to have a solid delivery driver app, as well.

### #2 You shouldn’t have to pay extra for it

We can’t stress this enough:

**You should NEVER have to pay an extra fee to get access to the delivery driver app.**

You’re already paying a lot of money to use the software. And the app is an [**essential component of route optimization solutions**](https://elogii.com/blog/essential-components-of-a-route-optimization-solution/).

So if your provider wants to charge extra, or the app isn’t free to download, it’s better to walk away.

> Here’s a complete rundown of how much [**delivery management software cost**](https://elogii.com/blog/delivery-management-software-cost/).

### #3 It should work on all devices (iOS and Android)

Delivery driver apps have to be available for all of your drivers.

So, when you’re evaluating what apps to choose, make sure that the [**route optimization app works for Android and iOS**](https://elogii.com/blog/route-optimization-apps-android-iphone/).

This ensures that everyone on your team can use the device. And that you won’t have to invest additional resources to equip simply because you want to automate your delivery.

### #4 It should integrate with other apps

**The software should be able to integrate with any third-party apps that you use.**

When it comes to the dashboard, you should be able to use [**APIs**](https://en.wikipedia.org/wiki/API) to connect it with a number of different solutions.

Primarily, you should make sure that it can integrate with a **CRM**, like Shopify or Salesforce.

But other tools such as a **supply chain, inventory,** and **warehouse management systems**.

This allows you to centralize your delivery operations, making it easier to upload data to the app.

But you should also be able to integrate the app with other smartphone apps.

Most importantly, you should have the option to connect it to Google Maps or Waze.

![driver app map](/blog/uploads/driverapp.png)

This gives drivers a familiar environment and makes it easier for them to transition to the app.

### #5 It should support external teams

What type of delivery do you operate? Do you have an in-house delivery fleet? Or do you outsource and subscribe to a dedicated third-party logistics provider?

Whatever the case, the delivery driver app you end up choosing should support both [**internal and external delivery fleets**](https://elogii.com/blog/internal-vs-external-delivery-fleet-everything-you-need-to-know/).

If you outsource the delivery fleet, this can help you protect the reputation of your business.

But it also helps you to **monitor the performance and cost of the external fleet**.

This safeguards your delivery against additional costs. And it helps you maintain quality customer service.

If you own and operate the delivery fleet yourself, this enables you to **streamline fulfillment**. And take advantage of all the benefits we’ve mentioned before.

## How much does driver route planning software cost?

The average price of driver route planning and optimization software is **$182.35 per month.**

But, to be clear:

**The cost will vary from provider to provider.**

The price you end up paying for the software will depend on your contract, its length, how you want to be charged, and the capabilities you want to have.

**But it will also depend on your delivery.**

Primarily, providers may increase the price based on the type of delivery you own, its size, complexity, the area in which you operate, as well as your delivery volumes.

Keep all of this in mind when you start researching for solutions.

## How to choose driver management software?

This is a difficult question.

Besides price, there is a lot to take into account when choosing driver management software.

Lucky for you, we can help.

**Here are the nine free guides that will show you exactly what we do to optimize the last mile and dominate delivery logistics:**

1\. The definitive and complete guide to [**Route Optimization Software**](https://elogii.com/blog/guide-to-route-optimization-software/)

2\. How to choose [**the best route optimization software**](https://elogii.com/blog/best-route-optimization-software/) for your business

3\. [**What’s the Difference Between Route Planning and Route Optimization?**](https://elogii.com/blog/difference-between-route-planning-and-route-optimization/)

4\. [**Biggest Delivery Challenges for eCommerce**](https://elogii.com/blog/biggest-challenges-for-ecommerce-delivery/) (and How to Solve Them)

5\. All of the ways software helps you achieve [**last-mile e-commerce delivery success**](https://elogii.com/blog/last-mile-e-commerce-delivery-success/)

6\. [**Delivery management software for small business**](https://elogii.com/blog/delivery-management-software-for-small-business/) and the reasons to use it

7\. [**Delivery Management Platforms**](https://elogii.com/blog/delivery-management-platforms/ "delivery management platforms")

8\. How we dominate [**reverse logistics and eCommerce returns**](https://elogii.com/blog/reverse-logistics-and-ecommerce-returns/)

9\. [**Grocery Delivery Software**](https://elogii.com/blog/grocery-delivery-software/): The Definitive Guide

## See how it works in action

[**_eLogii_**](https://elogii.com/) _is an end-to-end cloud-based delivery management platform. Our powerful solution solves the biggest challenges of modern distribution and field service businesses, including: route optimization, planning and execution._

[**_BOOK YOUR DEMO_**](https://elogii.com/book-demo) _in less than 2 minutes. Fill out a quick form and one of our experts will get in touch with you to show you how our solution works in action. The demo is tailored specifically to your business needs._

_Start saving time and money in your operations today!_

repository: leobudima/elogii-blog

repo_name: leobudima/elogii-blog


text:
---
layout: article
title: "Plausible: GDPR, CCPA and cookie law compliant site analytics"
description: Plausible provides cookie-less web analytics without collecting
  personal data and while respecting the privacy of website visitors. This is
  our data policy.
permalink: /data-policy
---
Even though the purpose of [Plausible Analytics](https://plausible.io) is to track the usage of a website, this can still be done without collecting any personal data or personally identifiable information (PII), without using cookies and while respecting the privacy of the website visitors.

Here's a closer look at our data policy, the information that we do collect, what we use it for and steps we've taken to comply with the cookie law and the privacy regulations such as the GDPR, CCPA and PECR.

## First thing first: What we collect and what we use it for

The goal of Plausible is to track overall trends in your website traffic, it is not to track individual visitors. We don’t collect or store any personal or identifiable data. All of the data that we do collect is aggregated data only and it has no personal information.

We measure only the most essential data points and nothing else. All the metrics we do collect fit on one single page. Here is the complete list of what we collect and store about your website visitors:

| Data point | Example | Comment |
|---|---|---|---|---|
| **Page URL** | _https://yoursite.com/pricing_ | We track the page URL of each page view on your website. We use this to show you which pages have been viewed and how many times a particular page has been viewed.

The hostname and path are collected. Query parameters are discarded, except for these special query parameters: `ref=`, `source=` and `utm_source=`. |
| **HTTP Referer** | _https://facebook.com_ | We use the referrer string to show you the number of visitors referred to your website from links on other sites. |
| **Browser** | _Chrome_ | We use this to show you what browsers people use when visiting your website. This is derived from the User-Agent HTTP header. The full User-Agent is discarded. |
| **Operating system** | _macOS_ | We use this to show you what operating systems people use when visiting your website. We only show the brand of the operating system and don't include the version number or any other details. This is derived from the User-Agent HTTP header. The full User-Agent is discarded. |
| **Device type**  | _Desktop_ | We use this to show you what devices people use when visiting your website. This is derived from window.innerWidth. The actual width of the browser in pixels is discarded. |
| **Visitor Country**  | _United Kingdom_ | We look up the visitor's country using their IP address. We do not track anything more granular than the country of origin and the IP address of the visitor is discarded. We never store IP addresses in our database or logs. |

## How we count unique users without cookies

Counting unique visitors is an integral part of web analytics. Known methods include:
1. Storing a cookie with random identifier on the visitor's device
2. Counting unique IP addresses (often coupled with User-Agent)
3. Browser fingerprinting
4. Abusing the browser cache e.g. [Etag tracking](https://www.futurehosting.com/blog/etags-allow-tracking-without-cookies/)

Each method has its problems and they are all covered by different privacy laws. Plausible attempts to strike a reasonable balance between de-duplicating pageviews and staying respectful of visitor privacy. We do not attempt to generate a device-persistent identifier because they are considered personal data under GDPR.

Instead, we generate a daily changing identifier using the visitor's IP address and User Agent. To anonymize these datapoints, we run them through a hash function with a rotating salt.

```
hash(daily_salt + website_domain + ip_address + user_agent)
```

This generates a random string of letters and numbers that is used to calculate unique visitor numbers for the day. Old salts are deleted to avoid the possibility of linking visitor information from one day to the next. Forgetting used salts also removes the possibility of the original IP addresses being revealed in a brute-force attack.

In our testing, using IP addresses to count visitors is remarkably accurate when compared to using a cookie. In some cases it might even be more accurate than using a cookie because some visitors block cookies altogether.

The biggest limitation with this approach is that we cannot do good retention analysis with Plausible. We cannot show stats like _New vs Returning visitors_ because they rely on having a persistent user identifier.

_Disclaimer:_ We're not lawyers. The information in this post is our view on things and it's here to help give you an introduction to the different privacy regulations and how Plausible is built to help you comply with them. We encourage you to discuss specific issues with your lawyer if you have any concerns.

## Data ownership of your web analytics

By using Plausible, you keep 100% ownership of your website data. Although when using our hosted service, your site analytics are stored on our server in the cloud, you remain completely in control of your site data and you fully own all of your data too:

* Your website data is not shared with advertising companies or any other companies in general.
* Your website data is not sent to any third-parties at all.
* Your website data is not mined and harvested for personal and behavioral trends.
* Your website data is not monetized.

## Why should I trust you?

Plausible is a fully [open-source website analytics tool](https://plausible.io/open-source-website-analytics). Our source code is available and accessible [on GitHub](https://github.com/plausible/analytics/) so you can read it and review it to ensure our code does what we say.

## GDPR, CCPA and PECR compliant web analytics

By using Plausible, you don't need to have any GDPR, CCPA or PECR prompts and you don't need a complex privacy policy about your use of analytics and cookies. With Plausible, you are not tracking any personal data after all. Your visitors can enjoy your site without any annoyances and distractions.

You can [sign up for a 30-day free trial](https://plausible.io/register) and explore our privacy-friendly and GDPR, CCPA and PECR compliant site analytics. You don't need to remove your current analytics provider either until you've tested Plausible and figured out if you like our product.

repository: scflode/website

repo_name: scflode/website


text:
# TODO

- [ ] Display() should probably take in an int for indent level
    - That way subsequent calls will have the proper indentation
    - Maybe just jsonify it so we can make test programs?
- [ ] Parser should use lexer spans for better error messages
- [ ] Separate out logic in ast, and parser
    - Separate files for different nodes for ast
    - Separate files for private vs public vs utils
- [ ] Have Parser Print out to stdout with indentation
    - Include 'b' test programs to see if parser is working well
- [ ] Refactor and cleanup code in lexer, ast, and parser
    - Make functions make more sense, add helpers where necessary
- [ ] Add more ast and parser tests
- [ ] Generate some form of docs, whether to stdout or HTML
- [ ] Start analyzing how this will translate to go
- [ ] Will need to add back imports at some point
- [ ] For loop parsing should work pretty much like python or go
    - `blue - for i in 1 .. 10 {`
    - `go - for i := 0; i < 10; i++ {`
    - `python - for i in range(10):`
    - We want to be able to define for loops in a similar way, no parens should be needed
- [ ] If expressions should not need parens
- [ ] Global vars for some things like ENV, ARGV, STDOUT, STDIN, STDERR, etc.
- [ ] Proper immutability
- [ ] Remove lambdas, just use `fun() {}`
- [ ] support all functions using dot call syntax ie:
    ```
        fun hello(arg1, arg2) {
            println("hello #{arg1} and #{arg2}")
        }

        val x = "Brice"
        val y = "Name"

        x.hello(y)
    ```
- [ ] Dont really want `null` can we possibly use optionals? Some()/None?
- [ ] Printing formatting and easy of use debugging printing like `"#{=obj}"`
    - the `=` sign here should show the string version of the object, or something along those lines

## Future TODOs

- [ ] Figure out errors and how they will be handled
- [ ] Robust CLI for building, getting packages, running from CLI
- [ ] Reading input from cli
- [ ] http client/server - should be easy to get content from page
- [ ] regex
    - [ ] Builtin regex like JS/ruby?  `/.*word$/g`
- [ ] File IO
- [ ] Shell commands (maybe some cross platform alternatives in go with unix names ie. `rm`, `ls`, etc.)
- [ ] Multiple assignment `val x, var y = get_two_values(); val a, b = get_two_values();`
- [ ] Make sure default args work
- [ ] Test framework builtin
- [ ] Doc framework builtin
    - [ ] Should be easy enough to use, maybe like python where you can type `help()` to get info
- [ ] Simple GUI setup that works with build, using fyne?
- [ ] Config reading and writing - maybe use `.toml`?
- [ ] To/From JSON easily - maybe custom operator - probably just a function
- [ ] Automating browser?
- [ ] Types?
- [ ] Definitely want arbitrary precision numbers but easy to use like python
- [ ] Symbols? (`:symbol_name`)
- [ ] Enums? - Maybe this works with symbols/match somehow?
- [ ] Async code, channels, send and receive
- [ ] Package Manager
- [ ] Integrating with Go code
- [ ] Datetime library
- [ ] CLI library
- [ ] Mnesia like in memory db, something like redis but for this lang specifically
- [ ] Supervisors and OTP like concepts?
- [ ] ORM/SQL support - builtin support for sqlite would be nice
- [ ] Embed all to one binary
- [ ] Macros of some sort?
- [ ] Benchmarks - use builtin go?
- [ ] Performance test the implementation and improve
- [ ] Self host?? - realistically this isnt necessary but it would give a lot of insight into anything missing

repository: brice-v/blue-old

branch_name: refs/heads/main

repo_name: brice-v/blue-old


text:
---
layout: default
title: Visitor (GoF)
parent: Behavioral Design Patterns
nav_order: 3100
permalink: /behavioral/visitor
---

# The Visitor Design Pattern

The Visitor Design Pattern is designed to separate the algorithm from the object and to apply it to a group of similar types.
{: .fs-6 .fw-300 }

---

## What problems does it solve?
It provides a mechanism to separate the algorithm from the object and to apply it to many different types.

Glossary:
- Visitor - an interfaces or abstract class to define the visitor behavior (the visit methods)
- Concrete Visitor - implements the concrete operations/ algorithms
- Visitable - declares the behavior of the classes that can be "visited", acts as an entry point for visitors
- Concrete Visitable - the concrete classes should implement the behavior when "visited" by the visitor
- Object Structure - a collection or a complex structure, that contains the "elements" that can be visited

You can use it with a collection/ complex structure or without.

## Pros:
- you can define new operation without changing current implementation of the classes
- you can add new operation without changing the code of the class hierarchy
- algorithm implementation will be externalized and more reusable
- implements the open/closed principle of the SOLID design principles

## Cons:
- you should know the return type in advance
- hard to modify the return type later

**One Type that may apply many algorithms = Strategy**
**Many Types that can apply many algorithms = Visitor**

## How to recognize it?
If there are two different abstract/interface types, which have methods and the one actually calls
the method of the other to execute the desired strategy on it.
```java
// use the complex shape to calculate the total area
ComplexShape c1 = new ComplexShape();
c1.add(new Circle(3));
c1.add(new Circle(6));
c1.add(new Circle(9));
c1.add(new Rectangle(12, 2));
c1.add(new Hexagon(2));
c1.calcTotalArea();
```

## Scenarios
* When you have to perform the same operation on multiple classes, that build a complex structure, but you could
not implement it in the parent class, because not all of the subclasses support it.
In this case, you can extract the operation/ algorithm in external class and reuse it, where applicable.
* When you don't want to add a method to a parent class

## Examples from Java API
```
javax.lang.model.element.AnnotationValue and AnnotationValueVisitor
javax.lang.model.element.Element and ElementVisitor
javax.lang.model.type.TypeMirror and TypeVisitor
java.nio.file.FileVisitor and SimpleFileVisitor
javax.faces.component.visit.VisitContext and VisitCallback
```
## Scenarios
* If you want to apply same operation on all elements of some aggregate structure,
but elements might be of different types and the algorithm may vary for the concrete types
* If many distinct and unrelated operations need to be performed on objects in an object structure
* To define new operations over the elements of a structure, but you don't want to modify the existing classes

### Example 1
We need an app that can calculate the area of dynamic complex shapes, built from other "simple" shapes.
Later, we will extend the functionality and some of the shapes will do specific operations like "print".

[Source Code](https://github.com/Iretha/ebook-design-patterns/tree/master/src/com/smdev/behavioral/visitor)

1). Create an visitable interface for the Area Calculator, that knows how to "accept" visitors ot this type
```java
public interface VisitablePrint {

    void accept(VisitorPrint visitor);
}
```
2). Create the "simple" shapes we are going to support and implement the interface

2.1).Circle
```java
@ToString
public class Circle implements VisitableAreaCalc {

    @Getter
    private  double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double accept(VisitorAreaCalc visitor) {
        return visitor.visit(this);
    }
}
```
2.2).Hexagon
```java
@ToString
public class Hexagon implements VisitableAreaCalc {

    @Getter
    private int side;

    public Hexagon(int side) {
        this.side = side;
    }

    @Override
    public double accept(VisitorAreaCalc visitor) {
        return visitor.visit(this);
    }
}
```
2.3). Rectangle
```java
@ToString
public class Rectangle implements VisitableAreaCalc {

    @Getter
    private int width;

    @Getter
    private int height;

    public Rectangle(int width, int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public double accept(VisitorAreaCalc visitor) {
        return visitor.visit(this);
    }

    public void accept(VisitorPrint visitor) {
        visitor.visit(this);
    }
}
```
3). Add the implementation of the Area Calculator Visitor - this is the implementation of the algorithms, extracted from the classes
```java
public class VisitorAreaCalcImpl implements VisitorAreaCalc {

    @Override
    public double visit(Rectangle shape) {
        double area = shape.getWidth() * shape.getHeight();
        System.out.println("Area of " + shape + " is " + area);
        return area;
    }

    @Override
    public double visit(Circle shape) {
        double area = Math.PI * Math.pow(shape.getRadius(), 2);
        System.out.println("Area of " + shape + " is " + area);
        return area;
    }

    @Override
    public double visit(Hexagon shape) {
        double area = (3 * Math.sqrt(3) * Math.pow(shape.getSide(), 2)) / 2;
        System.out.println("Area of " + shape + " is " + area);
        return area;
    }
}
```
4). Let's extend the functionality and add a visitor for printing the shape
```java
public interface VisitorPrint {

    void visit(Rectangle rectangle);
}
```
5). Add the visitable interface for printing
```java
public interface VisitablePrint {

    void accept(VisitorPrint visitor);
}
```
6). Implement the visitable for a specific shape
```java
@ToString
public class Rectangle implements VisitableAreaCalc, VisitablePrint {

    @Getter
    private int width;

    @Getter
    private int height;

    public Rectangle(int width, int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public double accept(VisitorAreaCalc visitor) {
        return visitor.visit(this);
    }

    public void accept(VisitorPrint visitor) {
        visitor.visit(this);
    }
}
```
7). Implement the print mechanism
```java
public class VisitorPrintImpl implements VisitorPrint {
    @Override
    public void visit(Rectangle rectangle) {
        for (int h = 0; h < rectangle.getHeight(); h++) {
            for (int w = 0; w < rectangle.getWidth(); w++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
```
8). Create a complex shape
```java
public class ComplexShape {

    private List<VisitableAreaCalc> items = new ArrayList<>();

    public void add(VisitableAreaCalc shape) {
        this.items.add(shape);
    }

    public void calcTotalArea() {
        VisitorAreaCalc areaCalculator = new VisitorAreaCalcImpl();

        double area = 0;
        for (VisitableAreaCalc shape : this.items) {
            area += shape.accept(areaCalculator);
        }

        System.out.println("Total area: " + area);
    }
}
```
9). Create a demo class
```java
public class _Main {

    public static void main(String[] args) {
        // calculate the area of a single shape
        (new Circle(3)).accept(new VisitorAreaCalcImpl());

        // print a single shape
        (new Rectangle(12, 4)).accept(new VisitorPrintImpl());

        // use the complex shape to calculate the total area
        ComplexShape c1 = new ComplexShape();
        c1.add(new Circle(3));
        c1.add(new Circle(6));
        c1.add(new Circle(9));
        c1.add(new Rectangle(12, 2));
        c1.add(new Hexagon(2));
        c1.calcTotalArea();
    }
}
```
Output:
```java
Area of Circle(radius=3.0) is 28.274333882308138
************
************
************
************
Area of Circle(radius=3.0) is 28.274333882308138
Area of Circle(radius=6.0) is<PHONE_NUMBER>2923255
Area of Circle(radius=9.0) is<PHONE_NUMBER>4077323
Area of Rectangle(width=12, height=2) is 24.0
Area of Hexagon(side=2) is 10.392304845413264
Total area:<PHONE_NUMBER>977272
```

repository: Iretha/design-patterns

repo_name: Iretha/design-patterns


text:
---
title:    Intro to Open-source Bug Bounty
date:     2021-04-05 09:30:20 +07:00
tags:     [open-source, bug bounty, huntr, mailtrain, directory traversal]
---

Hello mates, this is my first write-up.

Let's keep it simple, most of the people who are reading this might have struggled a lot or is still fighting to find his/her first bug.
Well I've a good news for you, it's all about how you can earn some extra bucks with open-source bug bounty. Yeah, you heard that right - bounty for vulnerabilities in open-source projects.

Introducing [huntr.dev], a bug bounty board for securing open-source code, it helps the open-source community to disclose and fix security issues and get paid to do it. I've been using it for few months and the experience is pretty amazing. I was able to disclose over 40 and fixed over 90 security issues (including npm packages that has 250k average downloads per week). 2 CVE IDs were assigned to me for my findings in packages [nested-object-assign] and [apexcharts]. Check them out here!

- [CVE-2021-23329]{:target="_blank"}
- [CVE-2021-23327]{:target="_blank"}

If you like reading code or want to secure the open-source code (but for some $$$😅), join [huntr][huntr.dev] now!

Enough with that, let's jump into one of my recent disclosures in huntr which was a **Directory Traversal** vulnerability in the [repo][Mailtrain-repo] of the well known newsletter platform [Mailtrain].

I usually choose JavaScript/Node.js apps and packages as my targets (because I love JS😄, it's best to try to hunt in languages/frameworks that you love). Github of course, grep.app and npmjs are my go-to resources for finding targets. For example if you want web apps built with **express.js**, search `require('express')` in github. Use filters to get recently active projects.

I was reading code of all the Mailtrain's routes to identify available features. One of the route handlers is `routes/reports.js` [source][vulnerable-source]{:target="_blank"}

{% highlight javascript %}
78    router.get('/create', passport.csrfProtection, (req, res) => {
79      const reqData = req.query;
80      // ...
102       if (!reportTemplateId) {
103           res.render('reports/create-select-template', reqData);
104       }
105     // ...
115   });
{% endhighlight %}

If you are little bit familiar with **express.js**, you would say that the line 103 simply renders a template named `create-select-template`. And what about `reqData`? Yeah that's right, it's an object that has all the query string parameters passed to this route. So basically it is whatever a user gives as GET parameters.

But this simple line of code doesn't seems to be vulnerable to anything right?

![morpheus-meme](morpheus.jpg){:width="60%"}

When I saw this, one of the write-ups I read few months ago came into my mind. If you are interested in knowing about the root cause of the issue, read it [here][write-up]{:target="_blank"} (you'll be amazed to see how a simple feature can be turned into a critical vulnerability if misused).

**TL;DR**: If an express server is using `hbs` as view engine for server-side rendering and it allowes user-constructed query string parameters without validation to get passed to express's `render()` function, an attacker can use parameter called `layout` to read arbitrary files in the web server.

If you read the source above, you can see that it uses `hbs`. At this moment, I was sure it is vulnerable. To test it, I setup Mailtrain locally. Since access to this route requires authentication, the default creds from the repo can be used. With a little curiosity, I gave the `layout` parameter and got what I expected.

![poc0](poc0.gif){:alt="PoC"}

PoC 01

![hehe-boi-meme](hehe-boi.jpg){:width="60%"}

Yeah! Directory traversal🔥. With that, reading local files was easy as...

![poc1](poc1.gif){:alt="PoC"}

PoC 02

I quickly disclosed this [issue][disclosure]{:target="_blank"} and also opened a [PR][fix]{:target="_blank"} with fix. The fix is simple. Instead of allowing to pass all query string parameters, allow only what is necessary.

![fix-diff](diff.png)

Change diff

Within few days, the maintainer of Mailtrain reviewed and accepted it. And I got the💰.

![secured-meme](secured.jpg){:width="60%"}

I've also requested a CVE for this bug and waiting to hear back from the CNA.

That's all for now. Stay safe❤.

[huntr.dev]: https://huntr.dev
[nested-object-assign]: https://www.npmjs.com/package/nested-object-assign
[apexcharts]: https://www.npmjs.com/package/apexcharts
[CVE-2021-23327]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23327
[CVE-2021-23329]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23329
[Mailtrain]: https://mailtrain.org
[Mailtrain-repo]: https://github.com/Mailtrain-org/mailtrain
[vulnerable-source]: https://github.com/Mailtrain-org/mailtrain/blob/1d34f4f14d02c2d5794e37d0431118e0e41e4e71/routes/reports.js#L78
[write-up]: https://blog.shoebpatel.com/2021/01/23/The-Secret-Parameter-LFR-and-Potential-RCE-in-NodeJS-Apps/
[disclosure]: https://huntr.dev/bounties/1-other-mailtrain/
[fix]: https://github.com/Mailtrain-org/mailtrain/pull/1029
[diff]: https://github.com/Mailtrain-org/mailtrain/pull/1029/files

repository: arjunshibu/blog

gha_language: SCSS

repo_name: arjunshibu/blog


text:
*Fast & simple storage - a Dart LevelDB wrapper*

Introduction
------------

**[LevelDB](https://github.com/google/leveldb)** is a simple key/value data store built by Google, inspired by BigTable. It's used in Google
Chrome and many other products. LevelDB supports arbitrary byte arrays as both keys and values, singular *get*, *put* and *delete*
operations, *batched put and delete*, bi-directional iterators and simple compression using the very fast
[Snappy](http://google.github.io/snappy/) algorithm.

**leveldb_dart** aims to expose the features of LevelDB in a **Dart-friendly way**.

LevelDB stores entries **sorted lexicographically by keys**. This makes [LevelDB.getItems](https://www.dartdocs.org/documentation/leveldb/latest/leveldb/LevelDB/getItems.html) a very powerful query mechanism.

Platform Support
----------------

- [x] Modern 64-bit Linux platforms (e.g. Fedora 25, 26, Ubuntu 14.04, 15.10)
- [x] Mac OS X

Unsupported platforms:

- [ ] Android (See [issue #12](https://github.com/adamlofts/leveldb_dart/issues/12))
- [ ] Windows (Not supported in base library [issue #466](https://github.com/google/leveldb/issues/466))

Basic usage
-----------

Add `leveldb` to your `pubspec.yaml` file.

```
name: myproject
dependencies:
  leveldb:
```

Open a database and read/write some keys and values..

```
import 'dart:async';
import 'package:leveldb/leveldb.dart';

Future main() async {
  LevelDB<String, String> db = await LevelDB.openUtf8("/tmp/testdb");
  db.put("abc", "def");
  String value = db.get("abc");
  print("value is $value"); // value2 is def
}
```
Check out [example/main.dart](https://github.com/adamlofts/leveldb_dart/blob/master/example/main.dart) to see how to read, write and iterate over keys and values.

Documentation
-------------

API Documentation is available at https://www.dartdocs.org/documentation/leveldb/latest/

Isolates (Threads)
------------------

*leveldb_dart* supports access to a database from multiple isolates by passing
`shared: true` to the
[LevelDB.open](https://www.dartdocs.org/documentation/leveldb/latest/leveldb/LevelDB/open.html) function. The `LevelDB` object
returned by this function will share an underlying reference to the object in other isolates and changes will
be visible between isolates.

See [example/isolate.dart](https://github.com/adamlofts/leveldb_dart/blob/master/example/isolate.dart) for an example of using a database from multiple isolates (OS threads).

Feature Support
---------------

- [x] Read and write keys
- [x] Forward iteration
- [x] Multi-isolate
- [ ] Backward iteration
- [ ] Snapshots
- [ ] Bulk get / put

Custom Encoding and Decoding
----------------------------

By default you can use `LevelDB.openUtf8` to open a database with `String` keys and values which are encoded in UTF8. The `dart:codec` library
can be used to create databases with custom encodings. See [example/json.dart](https://github.com/adamlofts/leveldb_dart/blob/master/example/json.dart)
for an example which stores dart objects to the database via JSON encoding.

gha_language: Dart


text:
---
title: Fish Rules Day 80
date: 04-12-2021
published: true
---

Watch of the day: [“Generate Leads”][1]

## Biz & Marketing

Generated the TOS and privacy policy for the new commercial app.  If you haven’t tried this site, it’s a huge time saver: [Iubenda][2].

Signed up for that super annoying LinkedIN Sales tool that lets you spam people about connecting so I can sell them things…and then hit up 100 or so people in Mass. that are related to bait and tackle stores, charter boat, and marinas. 🤷♂

## Dev

Sent out invites to the commercial beta.  Also added the following to the commercial app:
- Report violation
- Fix measurement tile
- Explainer for quota measurement
- Tweak fuzzy search for species

[1]:	https://www.ycombinator.com/library/9n-how-to-generate-leads
[2]:	http://iubenda.refr.cc/PP9WNZ6


text:
<!--
The information we ask for below is IMPORTANT. It will help us help you faster.
Please FOLLOW THE ISSUE TEMPLATE unless you have a good reason not to, and help avoid wasting everyone's time.

Please also make sure you are using the latest Composer version. You can get the latest with `composer self-update`
or even try the latest dev build with `composer self-update --snapshot` to see if the bug was perhaps already fixed but not released yet.
-->

My `composer.json`:

```json
...replace me...
```

Output of `composer diagnose`:

```
...replace me...
```

When I run this command: <!-- run it with `-vvv` added to it ideally to get full debug output -->

```
...replace me...
```

I get the following output: <!-- FULL OUTPUT please, not just what you think is relevant -->

```
...replace me...
```

And I expected this to happen:

repository: composer/composer

repo_name: composer/composer


text:
# @mattetti/custom-api-documenter a fork of @microsoft/api-documenter

This tool can be used to generate an online API reference manual for your TypeScript library.
It reads the *.api.json data files produced by [API Extractor](https://api-extractor.com/),
and then generates files in [Markdown](https://en.wikipedia.org/wiki/Markdown) format with some HTML.

For usage information, see the
[Generating Docs](https://api-extractor.com/pages/setup/generating_docs/) article from the API Extractor
documentation.

## Customization

The markdown renderer was customized to better render API docs using
[hugo](https://gohugo.io/) and to allow for a different file structure.

Custom json options not available in the original api-documenter markdown:

- uriRoot: so the doc can generate links for api docs not hosted at the root of the domain.
- onlyPackagesStartingWith: a string used to filter packages to document, useful when you want to publish only document some packages.

```
{
  "outputTarget": "markdown",
  "newlineKind": "lf",
  "uriRoot": "/apis",
  "onlyPackagesStartingWith": "@mything"
}
```

repository: mattetti/custom-api-documenter

gha_language: TypeScript

gha_license_id: NOASSERTION

repo_name: mattetti/custom-api-documenter


text:
# kryo-support

This is a small library to make the [Kryo](https://github.com/EsotericSoftware/kryo) serialization framework easier
to use. By using this we ensure that:

* All projects use the same Kryo settings
* All projects depend on the same version of Kryo

## Responsible persons
Mario Camou<EMAIL_ADDRESS>Sebastian Garn<EMAIL_ADDRESS>
## Usage

The kryo-support package is published to [Bintray](https://bintray.com/yetu/maven/kryo-support). To be able to use it,
you need to add the repository to your `pom.xml`:

```xml
<repositories>
  <repository>
    <id>bintray</id>
    <url>http://dl.bintray.com/yetu/maven</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>
```

Once you have done that you need to add the following dependency:

```xml
  <dependency>
	<groupId>com.yetu.kryo-support</groupId>
	<artifactId>kryo-support</artifactId>
    <version>0.1.4</version>
  </dependency>
```

This is an example of how to use `kryo-support` from within your code:

```java
import com.esotericsoftware.kryo.serializers.TaggedFieldSerializer.Tag;
import com.yetu.kryo_support.KryoSupport;
import com.yetu.kryo_support.Message;

public class TestMessage extends Message { // All messages must extend the Message class;
    @Tag(1) int field1; // This field will be serialized (note the @Tag annotation). Tag IDs must be unique within each class.
    int field2; // This field will not be serialized

    private TestMessage() { } // There must be a default constructor

    public TestMessage (int field1, int field2) {
        this.field1 = field1;
        this.field2 = field2;
    }
}

public class Example {
    public static void main(String args[]) {
        KryoSupport.register(TestMessage.class, 1); // ID numbers must be unique

        TestMessage message = new TestMessage(42, 4242);

        byte[] bytes = KryoSupport.marshall(message);
        TestMessage result = (TestMessage)KryoSupport.unmarshall(bytes);
    }
}
```

For more examples and usage details, look at the tests and the JavaDocs.

## Publication

Publishing to Bintray uses the `maven-release-plugin`. You can learn more at http://veithen.github.io/2013/05/26/github-bintray-maven-release-plugin.html.

In short, once you have added your credentials to your `$HOME/.m2/settings.xml`, you need to first go to
https://bintray.com/yetu/maven/kryo-support, create the new version (using the `New Version` link) and then do the
following:

```
$ mvn -B release:prepare
$ mvn -B release:perform
```

This will only work if the version number in your `pom.xml` is a SNAPSHOT version. It will remove the -SNAPSHOT before
publishing and then increment the release number and add SNAPSHOT to it (i.e., 1.0.0-SNAPSHOT is released as 1.0.0 and
the POM is left with 1.0.1-SNAPSHOT).

Once you have performed the release, you need to go to https://bintray.com/yetu/maven/kryo-support again and publish it.

repository: yetu/kryo-support

repo_name: yetu/kryo-support


text:
## **Graph [Symbol.Iterator]**
### There are three type of iterator
### **1. 'bfs'**
- basic iterator
- Breadth first search starting from this._iterStart
### **2. 'dfs'**
- Depth first search starting from this._iterStart
### **3. 'dijkstra'**
- Dijkstra search by starting from this._iterStart
- the weight is added by this._weightAddFunc.
- the weight of route is compared by this._weightCompFunc

### **setIterType**
By 'setIterType' method, you can set iterator type.
```
directedGraph = new DirectedGraph(['1', '2', '3', '4', '5', '6'],
      [['1', '2', 1], ['2', '3', 2], ['4', '2', 1], ['2', '6', 5], ['4', '5', 2],
        ['6', '5', 4], ['5', '3', 2], ['3', '6', 2]]);
directedGraph.setIterType('dijkstra');
[...directedGraph]
directedGraph.setIterType('dfs');
[...directedGraph]
directedGraph.setIterType('bfs');
[...directedGraph]
```

### **setIterStart**
Determine where to start iterator.
Parameter is start node.
```
directedGraph.setIterStart('1');
[...directedGraph]

directedGraph.setIterType('dijkstra');
directedGraph.setIterStart('4');
[...directedGraph]
```

### **setWeightAddFunc, setWeightCompFunc**
For 'dijkstra' search, set the way to add weight and compare weight.

repository: hongjisung/DataStructure

gha_language: JavaScript

repo_name: hongjisung/DataStructure


text:
# Multiple Blink
Now that we have blinked at least 1 LED, what about blinking multiple LEDS at the same time? The minimum that you need to develop is blinking at least two LEDs at two different rates. Although I am not going to give you a speed, you should probably pick a rate which is visible to a standard human. I really hope that you take this further and perform some of the extra work for this part of the lab exercise.

 I would recommend either making a copy of this file or taking a screen shot. There might be a copy of all of these README's in a folder on the top level depending on the exercise.

## Extra Work
When you take a look at the development boards, you are limited to what is built into the platform.

### Even More LEDs
Since up to this point you should have hopefully noticed that you are simply just controlling each pin on your processor. So... what is keeping you from putting an LED on each pin? Can you actually control the speed of each of these LEDs?

### Patterned Lights
If you can control a ton of LEDs, what is keeping you from having a little fun? Why not try and make something like a moving face or other moving object in lights. *CAUTION* I would only do this if you have finished the rest of the lab.

### UART Pattern Control
If you have been using UART, could you set which LEDs are on or off based off some UART command? Would you want to send an Array over UART such as [1 0 1 0] or would you want to send a byte that corresponds to the status? Can you not only say which LEDs are on, but also tell them to blink at a particular rate if they were on (so LED1 Blink every 100ms)?


text:
# Ember Calendly

Features

1. User should see the text field filled out with the current date in the format of "MM/DD/YYYY"
2. User should see the calendar widget with the current date highlighted.
3. User should be able to move between months using the arrow icons
4. User should be able to click on any date, and the text field should show the new date

## Requirements

- Node.js v12.16.1
- npm

## Getting Started

- Install npm packages: `npm install`
- Run the server: `npm start`
- Visit the site: `http://localhost:4200`

repository: DonKennethVitug/ember-calendly

repo_name: DonKennethVitug/ember-calendly


text:
[![Build Status](https://travis-ci.org/Cleafy/elasticsearch6-http-basic.svg?branch=master)](https://github.com/Cleafy/elasticsearch6-http-basic)

# HTTP Basic auth for ElasticSearch 6.x

This plugin provides an extension of ElasticSearchs HTTP Transport module to enable **HTTP basic authentication** and/or
**Ip based authentication**.

Requesting `/` does not request authentication to simplify health check configuration.

There is no way to configure this on a per index basis.

## Version Mapping

|     Http Basic Plugin       | elasticsearch                |
|-----------------------------|------------------------------|
| v1.0.0                      |                       6.2.4+ |

## Installation

Download the desired version from https://github.com/AlanYoun/elasticsearch6-http-basic/releases

## Configuration

Once the plugin is installed it can be configured in the [elasticsearch modules configuration file](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html#settings). See the [elasticserach directory layout information](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-dir-layout.html) for more information about the default paths of an ES installation.

| Setting key              | Default value        | Notes                                                        |
| ------------------------ | -------------------- | ------------------------------------------------------------ |
| `http.basic.enabled`     | true                 | 是否打开授权                                                 |
| `http.basic.username`    | admin                | 用户名                                                       |
| `http.basic.password`    | admin_pw             | 密码                                                         |
| `http.basic.log`         | false                | enables plugin logging to ES log. Unauthenticated requests are |
| `http.basic.ipwhitelist` | localhost、<IP_ADDRESS> | 在此列表中的ip，可以不输入带入用户名密码即可访问es服务，用英文逗号,分割（如果启动es报错就在项目application.properties文件添加白名单） |
**Be aware that the password is stored in plain text.**

## Http basic authentication

see [this article](https://en.wikipedia.org/wiki/Basic_access_authentication)

## Configuration example

The following code enables plugin logging, sets user and password.提醒：属性的:后面需要加一个空格！！！

```
http.basic.enable: true
http.basic.log: true
http.basic.username: some_user
http.basic.password: some_password
http.basic.ipwhitelist: ip1,ip2,ip3
```

如果elasticsearch没有http.basic.ipwhitelist参数（启动会报错）就通过`resource/application.properties`文件配置，具体如下

```
http.basic.ipwhitelist=<IP_ADDRESS>,<IP_ADDRESS>
```

## Testing

**note:** localhost is a whitelisted ip as default.
Considering a default configuration with **my_username** and **my_password** configured.

Correct credentials
```
$ curl -v --user my_username:my_password no_local_host:9200/foo # works (returns 200) (if credentials are set in configuration)
```

Wrong credentials
```
$ curl -v --user my_username:wrong_password no_local_host:9200/    # health check, returns 200 with  "{\"OK\":{}}" although Unauthorized
$ curl -v --user my_username:password no_local_host:9200/foo       # returns 401
```


text:
---
layout: post
image: img/writing.jpg
author: [Helmut]
tags:
  - Migration
exc: Work In Progress Migration
title: "Flash ActionScript Inheritance"
date: "2006-08-18"
categories:
  - "flashmx"
---

So I am trying to figure out the following piece of code:

\[as\]

in Application.as
import Log;
class Application
{
private var \_log:Log; // force mtasc to compile Log.as

function Application(createdBy)
{
// Re-assigment of \_root to Application instance
createdBy.\_\_proto\_\_ = this.\_\_proto\_\_;
createdBy.\_\_constructor\_\_ = Application;
this = createdBy;

setup();
}
public function setup()
{
TRACE("hello world");
}
public static function main(createdBy:MovieClip)
{
var app = new Application(createdBy);
}
}; // end of class

\[/as\]

found here:

[http://www.osflash.org/pipermail/osflash\_osflash.org/2005-August/002165.html](http://www.osflash.org/pipermail/osflash_osflash.org/2005-August/002165.html "Code Link")

So far I have been recommended to read the following article:

[http://www.quantumwave.com/flash/inheritance.html](http://www.quantumwave.com/flash/inheritance.html)

The article well covers the subject of inheritance in Flash 5 and MX. My only concern is that as the article points out using inheritance in this way it will be only an overload to the application. ..to be continued

repository: helmutgranda/nextjs-helmutgranda

repo_name: helmutgranda/nextjs-helmutgranda


text:
---
layout: page
title: Fragile vase
tagline: online game
tags : [work, games]
---
{% include JB/setup %}

Get a vase by removing the boxes one by one. In some levels you have to show smartness, in others instead of direct
solution, you need to trick the physics, in order to place a vase on the top of iron box, what makes the game
interesting, dynamical and different from similar games.

---

You can [play this game online](/works/fragile_vase.html)

---

####Screens:
![My helpful screenshot]({{ site.url }}/assets/works/FragileVaseMain.png)

![My helpful screenshot]({{ site.url }}/assets/works/FragileVase1Level.png)

![My helpful screenshot]({{ site.url }}/assets/works/FragileVaseAction.png)


text:
# README_Generator
###### Description

Using Node.js this app creates clean, professional README's easily and quickly from user inputs in the command line. This app exists to save time for the developer to focus more attention on the application.

# Demo

## Table of Contents (Optional)
* [Top of Page](#description)
* [Gif](#description)
* [Installation](#installation)
* [Usage](#usage)
* [Credits](#credits)
* [License](#license)
* [Contributing](#contributing)
* [Tests](#tests)
* [Contacts](#contacts)

## Installation
1. Clone or Download
2. This app requires you link to a personal access token to your github allowing access to your user email address
3. On navigation to correct file install packages npm i
4. Done. Time to use it.
undefined

## Usage
1. From command line type node index.js
2. Follow the prompts as requested

## Credits
TerrenceMM2 helped with sequencing the code to work with the axios call.

## License
This project is licensed under The MIT License.

## Contributing
All contributions and suggestions are welcome! For direct contributions, please fork the repository and file a pull request.

## Tests

## Contacts

* Name: Matt Turner (mwturner611)
* e-mail<EMAIL_ADDRESS>* [LinkedIn](https://www.linkedin.com/in/matt-turner-ba328211a/)


text:
# EVO - Evolutionary Variational Optimization of Generative Models
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/ambv/black)

This repository contains the implementation of the EBSC and ES3C algorithms described in the paper [1]. Examples how to setup and run the algorithms can be found [here](/examples). You may also check out our `tvo` package which features PyTorch implementations of the algorithms, and which is available [here](https://github.com/tvlearn/tvo).

## Installation

We recommend [Anaconda](https://www.anaconda.com/) to manage the installation. Create a new environment to bundle the packages required:

```bash
$ conda create -c conda-forge -c anaconda -n evo python=2.7.15 pip pytables imageio
```

You can also install a Python 3 version instead, but note that the results described in [1] for EBSC and ES3C were produced by running in Python 2.

The implementations of the algorithms are parallelized using `mpi4py`, which requires a system level installtion of MPI. Run one of the following commands, depending on your system, to install:

```
$ brew install mpich  # MacOS
$ sudo apt install mpich  # Ubuntu
```

Please consult the official documentation of [mpi4py](https://mpi4py.readthedocs.io/en/stable/install.html) and [MPICH](https://www.mpich.org/documentation/guides/) if you need help.

Once MPICH is installed, you are ready to install mpi4py and further required packages by running:

```bash
$ pip install -r requirements.txt
```

Running the examples furthermore requires the `tvutil` package, for which installation instructions can be found [here](https://github.com/tvlearn/tvutil).

Finally, you are ready to install `evo`:

```bash
$ python setup.py install
```

__Remark__:

For code formatting and analysis, we use `black` and `pylama`. These tools can be installed via:

```bash
$ pip3 install black[python2] pylama
```

## Reference

[1] Jakob Drefs, Enrico Guiraud, Jörg Lücke. Evolutionary Variational Optimization of Generative Models. _Journal of Machine Learning Research_ 23(21):1-51, 2022. [(online access)](https://www.jmlr.org/papers/v23/20-233.html)

repository: tvlearn/evo

gha_language: Python

repo_name: tvlearn/evo


text:
**[How To Batch Deletes In MySQL Via orphanRemoval=true](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchDeleteOrphanRemoval)**

**Description:** Batch deletes in MySQL via `orphanRemoval=true`.

**Note:** Spring `deleteAllInBatch()` and `deleteInBatch()` don't use batching. The first one simply triggers a `delete from entity_name` statement, while the second one triggers a `delete from entity_name where id=? or id=? or id=? ...` statement. Rely on `delete()` method.

**Key points:**\
     - in this example, we have a `Tournament` entity and each tournament can have several `TennisPlayer` (*one-to-many*)\
     - first, we use `orphanRemoval=true` and only `CascadeType.PERSIST` and `CascadeType.MERGE`\
     - second, we dissociate all `TennisPlayer` from the corresponding `Tournament`\
     - third, we explicitly (manually) flush the persistent context (this will delete in batch all `TennisPlayer` thanks to `orphanRemoval=true`; if this is set to `false`, you will obtain a bunch of updates instead of deletes)\
     - forth, we delete all `Tournament` via the `delete()` method (since we have dissaciated all `TennisPlayer`, the `Tournament` deletion will take advantage of batching as well)

**Output example:**

![](https://github.com/AnghelLeonard/Hibernate-SpringBoot/blob/master/HibernateSpringBootBatchDeleteOrphanRemoval/batch_delete.png)

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

**You may like to try as well:**


text:
# Custom Validator
GenFx provides a validation model that lets you provide validation for properties and components as a whole.  This ensures a component is using values that it expects which is useful when you are building shareable components for others to use or if you just want to make sure you don't mistakenly configure your own components.

## Property Validator
In the first part of this tutorial, we're going to author a validator for integer properties that ensures the property can only be set to an even number.

Since this validator is meant for properties, we'll derive our class from [PropertyValidator](xref:GenFx.Validation.PropertyValidator) and implement its [IsValid](xref:GenFx.Validation.PropertyValidator.IsValid(System.Object,System.String,System.Object,System.String@)) method:

    public class EvenNumberValidator : PropertyValidator
    {
        public override bool IsValid(object value, string propertyName,
            object owner, out string errorMessage)
        {
            if (!(value is int))
            {
                errorMessage = propertyName + " was not set to an Int32 value.";
                return false;
            }
            else if ((int)value % 2)
            {
                errorMessage = propertyName + " must be set to an even number.";
                return false;
            }

            errorMessage = null;
            return true;
        }
    }

Now that we have a validator, we can use it one of two ways:
* Define a custom attribute class that can be used for the properties to which we want to apply this validation.
* Make use of the built-in [CustomPropertyValidatorAttribute](xref:GenFx.Validation.CustomPropertyValidatorAttribute) that can target any kind of property validator.

Let's explore both of these options to see how they work.  First, let's create a custom attribute class.  GenFx provides a convenient base class for property validator attributes to make this a pretty simple implementation:

    [AttributeUsage(AttributeTargets.Property)]
    public class EvenNumberValidatorAttribute : PropertyValidatorAttribute
    {
        protected override PropertyValidator CreateValidator()
        {
            return new EvenNumberValidator();
        }
    }

This is how that attribute would be used on a component property:

    private int myProperty;

    [EvenNumberValidator]
    public int MyProperty
    {
        get { return this.myProperty; }
        set { this.SetProperty(ref this.myProperty, value); }
    }

Invocation of the `EvenNumberValidator` would automatically occur when [SetProperty](xref:GenFx.GeneticComponent.SetProperty``1(``0@,``0,System.String)) is called to ensure the value is valid.

The other approach to take is to use [CustomPropertyValidatorAttribute](xref:GenFx.Validation.CustomPropertyValidatorAttribute) instead of defining our own custom attribute.  This approach doesn't yield as elegant of an API, especially if your validator requires arguments, but it's a quick way to get things up and running.  Here is how that would look:

    private int myProperty;

    [CustomPropertyValidator(typeof(EvenNumberValidator)]
    public int MyProperty
    {
        get { return this.myProperty; }
        set { this.SetProperty(ref this.myProperty, value); }
    }

## Component Validator
Let's move on to the next type of validator that you can customize: component validator.  With a component validator, you validate the component as a whole; it's not tied to a specific property as is the case with a property validator.

In this part of the tutorial, we'll define a component validator which validates that one integer property is greater than another integer property.  A component validator is appropriate for this scenario instead of a property validator because a property validator would validate the property immediately when it is set.  Depending on the order in which the properties are set, you could have a validation error before the consuming code was able to set the next property to the appropriate value.

Since this validator is meant for the whole component, we'll derive our class from [ComponentValidator](xref:GenFx.Validation.ComponentValidator) and implement its [IsValid](xref:GenFx.Validation.ComponentValidator.IsValid(GenFx.GeneticComponent,System.String@)) method.  For simplicity of the tutorial, we'll implement it such that the validator knows the type of the component from which it will be used.  Here's the code:

    public class GreaterThanValidator : ComponentValidator
    {
        public override bool IsValid(GeneticComponent component, out string errorMessage)
        {
            MyGeneticEntity entity = (MyGeneticEntity)component;

            if (entity.Value1 <= entity.Value2)
            {
                errorMessage = "Value1 must be greater than Value2.";
                return false;
            }

            errorMessage = null;
            return true;
        }
    }

Now that we have a validator, we can use it one of two ways:
* Define a custom attribute class that can be used for the component to which we want to apply this validation.
* Make use of the built-in [CustomComponentValidatorAttribute](xref:GenFx.Validation.CustomComponentValidatorAttribute) that can target any kind of component validator.

Let's explore both of these options to see how they work.  First, let's create a custom attribute class.  GenFx provides a convenient base class for component validator attributes to make this a pretty simple implementation:

    [AttributeUsage(AttributeTargets.Class)]
    public class GreaterThanValidatorAttribute : ComponentValidatorAttribute
    {
        protected override ComponentValidator CreateValidator()
        {
            return new GreaterThanValidator();
        }
    }

This is how that attribute would be used on a component:

    [GreaterThanValidator]
    public class MyGeneticEntity : GeneticEntity
    {
        private string value1;
        private string value2;

        public int Value1
        {
            get { return this.value1; }
            set { this.SetProperty(ref this.value1, value); }
        }

        public int Value2
        {
            get { return this.value1; }
            set { this.SetProperty(ref this.value1, value); }
        }
    }

Invocation of the `GreaterThanValidator` would automatically occur when the GA is initialized.

The other approach to take is to use [CustomComponentValidatorAttribute](xref:GenFx.Validation.CustomComponentValidatorAttribute) instead of defining our own custom attribute.  This approach doesn't yield as elegant of an API, especially if your validator requires arguments, but it's a quick way to get things up and running.  Here is how that would look:

    [CustomComponentValidator(typeof(GreaterThanValidator))]
    public class MyGeneticEntity : GeneticEntity
    {
        /* Same code as before... */
    }

To learn more about the validation API, check out the the [Validation namespace](xref:GenFx.Validation).

gha_language: C#


text:
## Description
Shutdown your pc after X minutes and play a Spotify playlist during 10 minutes (default).

## How to use it
#### Setting a playlist
To change the spotify playlist, change the URI variable. In order to get your playlist URI, go to Spotify, right click over your playlist and click on "Copy Spotify URI"
#### Time options
##### Passing one integer:
The integer means how many minutes will pass before to start the playlist. After that, your computer will shutdown after 10 minutes

###### Example:

  pss 5       ->     Music starts to play after 5 minutes and your pc is shutdown after 10 minutes (default)

Passing two integers:
The first one means like the previous one. The second means how many minutes will be playing spotify before to shutdown

###### Example:

  pss 5 8     ->     Music starts to play after 5 minutes and your pc is shutdown after 8 minutes

##### *** Note: 'pss' is the name of the script!

#### To stop
If you want stop the count down, just write pss stop. This command will kill all process associated to the script, stop your music and cancel shutdown.

##### *** Note: if you change the script name, make sure to change the variable called 'COMMAND_NAME', or the process won't be closed