text:
# Multi-Tenancy Network

Xiaoning Ding, Hong Chen

## Introduction

This document is a part of the multi-tenancy design documents in Arktos. It describes network-related design changes to support multi-tenancy, including network model, backward-compatibility, DNS and service changes, etc.

Please refer to other design documents in the "multi-tenancy" document directory if you want to learn about other parts in the multi-tenancy design.

## Network Isolation

following resources are network related, which need to be isolated inside network boundary:

* Pod (with regarding to IP address & connectivity)
* Service (including DNS service, and kubernetes service)
* Endpoints / EndpointSlice
* Ingress / egress
* Network Policy

See below illustrative diagram for isolation across networks:
![network resource isolation disgram](images/network-resource-isolation.png)

Network isolation is achieved with a new API object: network:

* Every pod is associated with a certain network object. If not specified it will be associated to a default network object, which is created when a space is initialized.
* A pod can only communicate with pods within the same network.
* Every network has its own DNS service. An associated DNS service is automatically created when a new network object is created. (**tbd: decide when to deploy the actual DNS server pods**)
* As a general rule, all network related resources are associated with the network object, and semantically residing within the network scope.

Pods in a network __should__ be able to access API server nodes by their IP addresses - this is required for access to kubernetes service. Network providers need to satisfy this prerequisite.

(**TBD: is it possible to leverage the fact that pods are running on hosts which are already on the node network(e.g. pod being dual-homed with one nic dedicated for node network access)?**)

### Network Object

A network object contains its type and type-specific configurations. It is not a namespace-scoped object, one network object can be shared by applications spanning multiple namespaces within a space.

It is defined using CRD by [crd-network.yaml](../../../pkg/controller/artifacts/crd-network.yaml)

The "type" field is the only mandatory field in a network object. It indicates network provider that allocates & manages the network resources. In particular, _flat_ type is reserved for canonical k8s flat networking model where various community cni plugins can be used as the underlying network provider.

A command-line parameter named "default-network-template-path" of tenant controller will decide which default network will be created for a new space.

For flat network env, each space should still have its own default network, as kube-dns service is isolated across tenants.

The content of default network template file should reflect the Network object in json format, with ```{{.}}``` the replacement of tenant name, like
```json
{
    "metadata": {
        "name": "default",
        "finalizers": ["arktos.futurewei.com/network"]
    },
    "spec": {
        "type": "vpc",
        "vpcID": "{{.}}-default-network"
    }
}
```

Below is the definition of a flat network:

```yaml
apiVersion: arktos.futurewei.com/v1
kind: Network
metadata:
  name: default
spec:
  type: flat
```

And here is a sample of a VPC network:

```yaml
apiVersion: arktos.futurewei.com/v1
kind: Network
metadata:
  name: vpc-1
spec:
  type: vpc
  vpcID: vpc-1a2b3c4d
```
When a pod is attached to the default network, nothing is needed in pod spec:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
      - containerPort: 443
```
When a pod is attached to a certain network, it needs to set its "network" using labels:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    arktos.futurewei.com/network: vpc-1
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
      - containerPort: 443
```

When a pod is attached to a certain network and it wants to specify subnet or IP, it can be expressed using annotations:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    arktos.futurewei.com/network: vpc-1
  annotations:
    arktos.futurewei.com/nic: {"name": "eth0", "ip": "<IP_ADDRESS>"}
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
      - containerPort: 443
```

Here annotation arktos.futurewei.com/nic is for user to provide optional information about pod nic. The recognized keys of element include:

|key|exemplary value|
|---:|---:|
|name|eth0|
|subnet|subnet-1, or <IP_ADDRESS>/26|
|ip|<IP_ADDRESS>|

If these settings are set on a pod attached to a flat network, the settings will be ignored by the flat network controller and also the corresponding CNI plugins, as the existing cni plugins used in flat network have no support for such extension yet.

(**TBD: for a flat network, can we automatically limit its communication scope to that network?**)

(**TBD: do we plan to support multiple network providers? How would it impact the type definition?**)

### Network Controller

A network controller watches its interesting network objects based on network type.

A flat network controller only initializes the DNS service and deployment for a new network, and also deletes them when a network object is removed. It doesn't do anything else.

A VPC network controller will call VPC service provider to allocate ports for newly created pods and deallocate ports when pods are deleted, in addition to the DNS service initialization and removal that's done in flat network controller.

### DNS

Each network has its own DNS service, which only contains the DNS entries of pods in that that network, regardless of network type.

The reasons that DNS service is per-network instead of per-space are:

* For VPC networks IPs could be overlapped. A pod with resolved IP <IP_ADDRESS> could be in different networks. Therefore it's useless for the DNS clients.
* VPC networks are isolated by nature. It will be difficult to have a shared DNS pod that's accessible to pods in various VPC networks.

(**TBD: is it possible to have _shared_ DNS able to serve multiple network?**)

### Service

#### Type definition

Service objects associate to network via label arktos.futurewei.com/network. By default, "network" is the default network of the tenant.

```yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
  labels:
    arktos.futurewei.com/network: my-network
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
```

#### Naming Problem & Solution

Services, as one of the critical network related resource types, are within the network boundary. There is no cluster wide shared services for a tenant, as both the virtual IP address and the associated endpoints are all scoped within a single network.

Putting service type in tenant level is out of primacy as it has following flaws:
1. service IP address has to be the same across all networks, which implies some range of service IP needs to be predefined as shared across networks of a tenant (tenant manageability burden);
1. associating network-agnostic service to network-specific endpoints would introduce significant inconsistency;
1. kubectl query for service (e.g. ```kubectl describe service```) has no way to return meaningful content of endpoints.

The well-known services (default/kubernetes, kube-system/kube-dns) present some problem here. Service kubernetes has tenant/namespace(default) scope in current implementation, unable to have multiple kubernets services with each of them in one network due to name conflict. The same rational applies to kube-dns.
docs/design-proposals/multi-tenancy/images/network-resource-isolation.png
One solution is to making its name colliding space to tenant+namespace+network, which is also breaking and inconsistent with other types (e.g. introducing network as one more parameter to call kubectl get service).

Another solution is to change their name to schema that can uniquely differentiate by combining with network name; this is awkward and breaking in general.

One plausible remedy is making stringent containment of network to namespaces - resources in one namespace belongs solely to one network; one network can accommodate multiple namespace. This cannot handle the default/kubernetes service problem, as it is of default namespace.

None of the two of above seems ideal. However, the latter, fiddling with the service name, if coupled with trick applicable only to kubernetes & kube-dns, seems pragmatic and practical. The idea is suffixing service name with network name (e.g. kubernetes_mynetwork), also answering query for kubernetes with that of kubernetes_mynetwork (by alias record or other form of dynamic technique), so that pods are able to look up them without using the network-suffixed names. This approach is not flexible and depending on dns ability; it works fine with limited number of well-known aliases, though. coreDNS, one of the most commonly used dns server binaries, has such dynamic aliasing ability.

One of the confusions is ```kubectl get service kubenetes``` would fail with no such resource error - this is breaking, but for good reason - to remind users of service resource being network specific in our system. However, pods are able to query DNS for kubernetes without caring about the new name schema as they are network related and able to locate the proper DNS service in the interesting network scope.

#### Service IP

Service IP address is allocated from the network-specific pool.

These are two types of service IP pool:

##### Arktos managed pool
Service IP addresses are explicitly managed by Arktos for every network. Each network might have different range of service IPs.

Service IPAM is provided through 2 changes:

1. each network object specifies its service IP range;

    ```yaml
    apiVersion: v1
    kind: Network
    metadata:
      name: default
    spec:
      type: flat
      service:
        cidrs:
        - <IP_ADDRESS>/16
        - <IP_ADDRESS>/24
    ```

1. on service creation, the current service IP address assignment mechanism is used - in scope of individual network instead of the whole cluster, though.

##### Network provider managed pool
Service IP addresses are implicitly managed by the capable network provider. Network object can have the service IP cidr (or not); at best for information - Arktos delegates IPAM to the external network provider, via network/service controller (detailed design TBD) interacting with the external network provider.

(**TBD: Can we support network provider to mutate service IP after it has been assigned? If so, how does the mutation propagate to Arktos?**)

Network object specifies service IPAM as *external*:

    apiVersion: v1
    kind: Network
    metadata:
      name: default
    spec:
      type: flat
      service:
        ipam: external

(**TBD: consider support for user can provide hints about service IP address**)

#### Semantic support

For flat typed networks, regular kube-proxy may be used to provide pod access to service.

For VPC-isolated networking, service IP support has to be provided w/o relying on iptable/IPVS rules on host netns. In other words, traditional kube-proxy can not used in VPC-isolated networking. A dedicated controller may be employed to establish & maintain service IP/pod IP mappings.
(**TBD: more details required**)

### Endpoints
Each endpoints object associates with a network, the same as its service.

For the services of _kubernetes_ and _kube-dns_ (in fact they are kubernetes-{network} and kube-dns-{network}), there are two special set of endpoints objects:

* kubernetes related EPs

They are in default namespace, named as kubernetes-{network}, for the kubernetes service of the network.

Query for default-ns scoped kubernetes-{network} shall get back the proper content based on the cluster kubernetes endpoints object. System does not duplicate such endpoints; instead it derives content based on the cluster kubernetes endpoints. This would incurs quite some code change to kube-apiserver.

Updates originated from regular tenants are disallowed.

Alternative is to duplicate in every network, when network is being provisioned. It is burdensome to keep all synced to the root one (which is maintained by api-server).

* kube-dns related EPs

They are in kube-system namespace, named as kube-dns-{network}, for the kube-dns service of the network.

kube-dns-{network} shall be managed by Endpoints controller just like a regular endpoints.

__EndpointSlices__, the new type introduced in k8s v1.17, is out of current scope.

### Network Policy

Network policies are used to depict the desired network security within Arktos. Without any network policy in place, Arktos allows any pod to access other pods, across all tenants and namespaces for a flat typed network environment. VPC typed network environment, on the other hand, does provide strong tenant level network security even in the absence of any network policy in place.

Without any syntax change, Existing k8s network policy specifications provide support for enforcing tenant scoped network security. Allowing access across tenant boundary is currently not supported within Arktos.

Network-isolation mode makes more sense in most cases. Below is an example for specific network, my-network, in one namespace. Similar network policies need to apply to other namespaces, too.
```yaml
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
  namesapce: bar
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: network-isolated-policy-for-my-network
  namesapce: bar
spec:
  podSelector:
    matchLabels:
      arktos.futurewei.com/network: my-network
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: my-network
  egress:
  - to:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: my-network
```

For the default network, isolation can be achieved by:
```yaml
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
  namesapce: bar
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: implicit-default-network-isolated-policy
  namesapce: bar
spec:
  podSelector:
    matchExpressions:
    - key: arktos.futurewei.com/network
      operator: DoesNotExist
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: default
  - from:
    - namespaceSelector: {}
    - podSelector:
        matchExpressions:
        - key: arktos.futurewei.com/network
        operator: DoesNotExist
  egress:
  - to:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: my-network
  - to:
    - namespaceSelector: {}
    - podSelector:
        matchExpressions:
        - key: arktos.futurewei.com/network
        operator: DoesNotExist
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: explcit-default-network-isolated-policy
  namesapce: bar
spec:
  podSelector:
    matchLabels:
      arktos.futurewei.com/network: default
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: default
  - from:
    - namespaceSelector: {}
    - podSelector:
        matchExpressions:
        - key: arktos.futurewei.com/network
        operator: DoesNotExist
  egress:
  - to:
    - namespaceSelector: {}
    - podSelector:
        matchLabels:
          arktos.futurewei.com/network: my-network
  - to:
    - namespaceSelector: {}
    - podSelector:
        matchExpressions:
        - key: arktos.futurewei.com/network
        operator: DoesNotExist
```

Of course, network policies can be specified for finer-grained network security inside network scope.

(**TBD: consider automatic creation of network policies to ease management**)

(**TBD: consider support of across-tenant network connectivity**)

#### K8S network policy enforcement

K8S community provides support for various plugins which enforce the network policies (such as Calico, Cilium, kube-router, etc.). Out of the box, these would not work within multi-tenant Arktos environment. For example, Calico may wrongly get entries from backend storage based on namespace + pod + interface name. Some of them may work within multi-tenant Arkstos environment if the controller deployed is in the form of a daemonset for each tenant. Kube-router seems very promising, we will evaluate Kube-router once Arktos fully functional multi-tenant environment is in place.

### Ingress/egress
(**TBD: more details required**)

## CNI spec
CNI_ARGS is leveraged for Arktos workload runtime to pass information on to the cni plugin of the network type.

According to the spec, the value of CNI_ARGS env var is alphanumeric key-value pairs separated by semicolons, e.g. "IPV4=<IP_ADDRESS>;VPCID=mizar-12345".

Arktos workload runtime will put whatever is the pod annotation of "arktos.futurewei.com/cni-args" to CNI_ARGS as defined in cni spec.

The network controller of the vpc network type is typically responsible for annotating pods properly with the relevant information.

## Architectural Views

Components not decided yet in the current phase are not included as part of the overall architecture views.

### Data model

![Data model view](images/network-data-model.png)

### Module Decomposition

![Module Decomposition view](images/network-module-decomposition.png)

### Runtime component relationship

![C&C view](images/network-c-and-c.png)

### Key Scenario: Tenant & DNS provisioning

![tenant & DNS provision](images/network-scenario-tenant-init.png)

### Activity Flow: Pod Creation to Running status

![Pod-activity-diag](images/pod-activity-diagram.png)

1. On pod creation, using a custom admission control, annotate new pod with arktos.futurewei.com/network-readiness=false as hint for the scheduler. For flat network type, such annotation is not required as its operator typically has no network preparation work to do.
2. It is the network controller's responsibility to do whatever network resource preparation for the pod. If pod has hint of arktos.futurewei.com/nic annoation, it should honor that.
3. If applicable network resource preparation completes successfully, it is the network controller's responsibility to clean up the annotation arktos.futurewei.com/network-readiness=false afterwards in case it is present.
4. It is the network controller's responsibility to annotate pod with proper information that the cni plugin needs in term of CNI-ARGS. Arktos system just picks up the annotation value and passes it on when calling cni plugin.

repository: VonRosenchild/arktos

repo_name: VonRosenchild/arktos


text:
# Symfony Bundle to use the MondialRelay API

## Description
This package uses [QuentinBontemps/php-mondialrelay-api](https://github.com/QuentinBontemps/php-mondialrelay-api).

This client allow to use the [Mondial Relay Soap API](https://api.mondialrelay.com/Web_Services.asmx) with Symfony.

Installation
============

Applications that use Symfony Flex
----------------------------------

Open a command console, enter your project directory and execute:

```console
$ composer require ernadoo/mondial-relay-bundle
```

Applications that don't use Symfony Flex
----------------------------------------

### Step 1: Download the Bundle

Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:

```console
$ composer require ernadoo/mondial-relay-bundle
```

This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

### Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles
in the `config/bundles.php` file of your project:

```php
// config/bundles.php

return [
    // ...
    Ernadoo\MondialRelayBundle\ErnadooMondialRelayBundle::class => ['all' => true],
];
```

### Step 3: Configure the Bundle

```yaml
# config/packages/ernadoo_mondial_relay.yaml
ernadoo_mondial_relay:
    api:
        wsdl: https://api.mondialrelay.com/Web_Services.asmx?WSDL
        options:
            trace: '%kernel.debug%'
            #keep_alive : false
            #cache_wsdl : !php/const WSDL_CACHE_NONE

        credentials:
            customer_code:
            secret_key:
            brand_id:
```

## Usage

```php
# src\Controller\DefaultController.php
<?php

namespace App\Controller;

use MondialRelay\ApiClient;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class DefaultController extends AbstractController
{
	public function findDeliveryPoints(ApiClient $mondialRelayClient)
	{
		$shops = $mondialRelayClient->findDeliveryPoints([
		    'Pays'            => 'FR',
		    'Ville'           => 'Paris',
		    'CP'              => '75000',
		    'DelaiEnvoi'      => "0",
		    'RayonRecherche'  => '20',
		    'NombreResultats' => '10',
		]);
	}
}
```

## Contribution
Contributions are always welcome.

license: MIT

repository: ErnadoO/mondial-relay-bundle

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: ErnadoO/mondial-relay-bundle


text:
# API RESY Node JS

API Rest full in Node JS with scalability, reuse and separation of responsibilities.

## Running
To start and run the project/server, simply run the following command in your root directory:

```
npm start
```

## Sample endpoints

### Views
 - `/` - Default route that redirects to the home page
 - `/home` - Render the home page sample

### API
 - `/api/v1/hotels` - Post all hotels, for filter of name or stars send in the body request a JSON :

 ```
{"filter":
  {
	  "name" : "",
	  "stars" : ""
  }
}
 ```

repository: WillWebDesign/apirestnode

repo_name: WillWebDesign/apirestnode


text:
## Step 1: Install the CLI.
```
npm install -g @angular/cli@latest
```

## Step 2: Create a new project.
```
ng new my-project
```

The new command creates a project with a build system for your Angular app.

## Step 3: Install Atomic dependencies.
Install Angular Material, Angular CDK, Angular Flexbox and Lodash
```
npm install --save @angular/material @angular/cdk @angular/flex-layout lodash
```

**package.json**
```json
...

"dependencies": {
  ...
    "@angular/animations": "^5.1.2",
    "@angular/common": "^5.2.1",
    "@angular/core": "^5.2.1",
    "@angular/forms": "^5.2.1",
    "@angular/router": "^5.2.1",
    "@angular/cdk": "^5.1.0",
    "@angular/material": "^5.1.0",
    "@angular/flex-layout": "^2.0.0-beta.12",
    "lodash": "^4.17.4"
  ...
}

...
```

For more information about how to get started with Angular Material, check out the [Angular Material getting started guide](https://material.angular.io/guide/getting-started)

## Step 4: Install Atomic.
Atomic  is available as an npm package.
```
npm install --save atomic-ui
```

## Step 5: Import the Atomic Core NgModule.
```typescript
import { AtomicLayoutModule, AtomicScrollbarModule /*, any other modules */ } from 'atomic-ui';

@NgModule({
  imports: [
    AtomicLayoutModule,
    AtomicScrollbarModule,
  ],
  ...
})
export class AppModule { }
```

## Step 6: Include the core, theme and typography:
This is **required** to apply all of the core, theme and typography styles to your application.

See the [material theming guide](https://github.com/angular/material2/blob/master/guides/theming.md) and the
[material typography guide](https://github.com/angular/material2/blob/master/guides/typography.md) for instructions.

A theme file is a simple Sass file that defines your palettes and passes them to mixins that output the corresponding
styles. A typical theme file will look something like this:

```scss
@import '~@angular/material/_theming';
@include mat-core();

@import "~atomic-ui/core/at-styles/helpers";
@import "~atomic-ui/core/at-styles/theming";

// Define the default theme.
$default-primary: mat-palette($mat-indigo);
$default-accent: mat-palette($mat-pink, A200, A100, A400);
$default-theme: mat-light-theme($default-primary, $default-accent);

// Include the default theme styles.
@include angular-material-theme($default-theme);

// This design depends on the selection of the material colors palette
.at-sidenat-button.active {
  color: map-get($default-primary, 400) !important;
}

@include atomic-theme($theme);

```

You only need this single Sass file; you do not need to use Sass to style the rest of your app.

repository: dbartumeu/atomic-ui

repo_name: dbartumeu/atomic-ui


text:
# Overlaybd

Overlaybd (overlay block device) is a novel layering block-level image format, which is design for container, secure container and applicable to virtual machine. And it is an open-source implementation of paper [DADI: Block-Level Image Service for Agile and Elastic Application Deployment. USENIX ATC'20"](https://www.usenix.org/conference/atc20/presentation/li-huiba).

Overlaybd was first proposed by Alibaba Cloud and widely used in Alibaba cloud services. It became a sub-project of containerd in 2021.

As an image format, overlaybd has 2 core component:

- Overlaybd is a layering image format, provideing a merged view of a sequence of block-based layers as a virtual block device. [SPEC](https://containerd.github.io/overlaybd/#/specs/lsmt.md)

- Zfile is a compression file format which support seekalbe online decompression. [SPEC](https://containerd.github.io/overlaybd/#/specs/zfile.md)

# Components

## Overlaybd service

[GitHub](https://github.com/containerd/overlaybd)

Sub-project of containerd, contains the storage service of overlaybd image format, provideing a merged view of a sequence of block-based layers as a virtual block device.
Now this service contains an implementation of overlaybd based on [TCMU](https://www.kernel.org/doc/Documentation/target/tcmu-design.txt), and will provide an implementation based on [ublk](https://docs.kernel.org/block/ublk.html) in the future.

This service is based on [PhotonLibOS](https://github.com/alibaba/PhotonLibOS), which is a high-efficiency LibOS framework.

## Accelerated container image

[GitHub](https://github.com/containerd/accelerated-container-image)
[Getting started](https://github.com/containerd/accelerated-container-image/blob/main/docs/QUICKSTART.md)

Sub-project of containerd, which is a solution of remote container image by fetching image data on-demand without downloading and unpacking the whole image before the container starts. This repositry contains a containerd snapshotter and image conversion tools for overlaybd.

## P2P data distribution

[GitHub](https://github.com/data-accelerator/dadi-p2proxy)

Use p2p protocol to speed up HTTP file download for registry in large-scale clusters.

# Key features

## High Performace

Overlaybd is a block-device-based image format, which has much lower complexity than filesystem-based implementations. For example, cross-layer hardlink and non-copy commands like chown are very complex for filesystem-based image without copying up, but is natively supported by overlaybd.

## High Reliability

Overlaybd outputs virtual block devices through TCMU, which is a linux kernel module and widely supported in most operation systems.
Overlaybd backstore can recover from failures or crashes, which is difficult for FUSE-based image formats.

# Community

For sync communication catch us in the #overlaybd slack channels on Cloud Native Computing Foundation's (CNCF) slack - cloud-native.slack.com. Everyone is welcome to join and chat. [Get Invite to CNCF slack.](https://communityinviter.com/apps/cloud-native/cncf)

repository: Coldwings/overlaybd

branch_name: refs/heads/main

repo_name: Coldwings/overlaybd


text:
# PermissionsKt

[![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-PermissionsKt-green.svg?style=flat )]( https://android-arsenal.com/details/1/6809 )

Handle Android Runtime Permissions in Kotlin way

## How to add
PermissionsKt is published with [JitPack.io](https://jitpack.io).
To add this library to your project, add these lines to your build.gradle

```
repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'com.github.sembozdemir:PermissionsKt:1.0.0'
}
```

## How to use

- #### Prepare Manifest

Add the permission to `AndroidManifest.xml`.

`<uses-permission android:name="android.permission.CAMERA"/>`

- #### Ask for permission

It is so simple. Just ask for permission you want anywhere on your Activity.

```
askPermissions(Manifest.permission.CAMERA) {
    onGranted {
        showCamera()
    }
}
```

- #### Call delegated function

Call delegated extension function on `onRequestPermissionsResult`.

```
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
    handlePermissionsResult(requestCode, permissions, grantResults)
}
```

- #### Other callbacks

You may also listen `onDenied`, `onShowRationale`, `onNeverAskAgain` callbacks if you need. Call `request.retry()` on action after showing rationale message on `onShowRationale`.

```
askPermissions(Manifest.permission.CAMERA) {
    onGranted {
        showCamera()
    }

    onDenied {
        Log.d(TAG, "Camera permission is denied.")
    }

    onShowRationale { request ->
        Snackbar.make(rootView, "You should grant Camera permission", Snackbar.LENGTH_INDEFINITE)
                .setAction("Retry") { request.retry() }
                .show()
    }

    onNeverAskAgain {
        Log.d(TAG, "Never ask again for Camera permission")
    }
}
```

- #### Multiple permissions

You may also ask for multiple permissions at the same time.

```
askPermissions(Manifest.permission.CALL_PHONE, Manifest.permission.READ_SMS) {
    onGranted {
        makeCall()
        sendSms()
    }

    onDenied { permissions ->
        permissions.forEach {
            when (it) {
                Manifest.permission.CALL_PHONE -> Log.d(TAG, "Call Phone is denied")
                Manifest.permission.READ_SMS -> Log.d(TAG, "Read Sms is denied")
            }
        }
    }

    onShowRationale { request ->
        Snackbar.make(rootView, "You should grant Call Phone and Read Sms permissions, Snackbar.LENGTH_INDEFINITE)
                .setAction("Retry") { request.retry() }
                .show()
    }

    onNeverAskAgain { permissions ->
        permissions.forEach {
            when (it) {
                Manifest.permission.CALL_PHONE -> Log.d(TAG, "Never ask again for Call Phone")
                Manifest.permission.READ_SMS -> Log.d(TAG, "Never ask again for Read Sms")
            }
        }
    }
}
```

---

You could view `sample` module for more details.

## Licence
The MIT License (MIT)

Copyright (c) 2018 Semih Bozdemir

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

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

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


text:
### Project Overview

 In this project we will be exploring the publicly available data from LendingClub.com. Lending Club connects people who need money (borrowers) with people who have money (investors). As an investor one would want to invest in people who showed a profile of having a high probability of paying the amount back

### Learnings from the project

 I applied simple DecisionTree Classifier on this project and found if we do the hyperparameter tuning, we can get the better result.

### Approach taken to solve the problem

 - Checked the data which was there in the dataset
- Analysed the box plot and count plot to find the mean and data distribution
- divided the dataset into numerical and categorical columns
- converted categorical columns to numerical one's using label encoding
- Applied Decision tree classifier without any hyper parameter tuning and checked the result
- Then applied hyper meter to see if acc can be better and found out it got better wiht min sample leaf and max depth limitation


text:
# lsa
## Introduction
lsa is simple **Live Stream Analyzer** running in console.

lsa is based on FFmpeg, gmf, and termui

## Usage
``` bash
./lsa live_stream_url
```

Output example(RTMP):

Output example(HLS):

## How to build
Add ffmpeg library path to pkgconfig pth:
``` bash
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ffmpeg/lib/pkgconfig/
```

Ensure, that PKG_CONFIG_PATH contains path to ffmpeg's pkgconfig folder.
``` bash
pkg-config --libs libavformat
```

It should print valid path to the avformat library.

repository: WJZMC/lsa

repo_name: WJZMC/lsa


text:
+++
image_alt = "Leafy seadrgon at the Georgia Aquarium"
image_url =<EMAIL_ADDRESS>published_at = 2023-05-02T11:57:48+02:00
title = "Atlanta, Job Queues, Batch-wise Operations"
+++

I'm back from Atlanta, and now in Paris.

This was the first time I'd ever been to Atlanta, or anywhere in  Georgia for that matter. Trying to pick a hotel, I pulled up Google Maps as I usually do to cross-reference the locations of hotels with those of parks and other areas of interest, only to find to my dismay that Atlanta appeared to have precious little in the way of either.

A lot of cities are shaped around a major geographic feature like a waterfront (San Francisco, Vancouver), river (London, Paris, Chicago, Calgary, countless others), or large park (Manhattan, Berlin). Downtown Atlanta is shaped around a highway. And the only green to be found in the vicinity are a large stadium (a park on technicality), pseudo-park to commemorate the '96 Olympics, and a little space next door to hold World of Coca-Cola, a theme park built around everybody's favorite sugary confection, which yes, is really a thing.

But it wasn't as bad as the maps made it look. Knowing nothing about Georgia, I was surprised as I stepped off the plane to find the area surrounded by tall, stately trees, made up of magnolias, dogwoods, Southern pines, and oaks. One of Atlanta's nicknames is "city in a forest", and although it'd be a stretch to apply the moniker to downtown, it shows through in the surrounding area.

The third largest aquarium in the world (and formerly, largest) is in Atlanta, and its signature feature is a 6.3 million gallon tank holding a plethora of aquatic life including whale sharks, which I wrote about [in sequences 046](/sequences/046). Its extensive collection contains everything from hammerheads, dolphins, and belugas, to the mesmerizingly gorgeous [leafy seadragons](https://en.wikipedia.org/wiki/Leafy_seadragon) pictured above.

By the end of the trip I had a daily morning run that took me passed Centennial Park, around the aquarium and World of Coca-Coca, and down through the campus of Georgia Tech (which is very pretty). Thoroughly enjoyable.

---

## You can't take the name out of the conference, but you can take the conference out of the name (#railsconf)

The ostensible reason for being in Atlanta was RailsConf, of which I've grown skeptical over the years.

Its organizing committee took a hard ideological turn a while back, and although the effects of such are long  the long effects of it are starting to show. Infamously, last year DHH, the creator of Rails, was [uninvited from the conference](https://world.hey.com/dhh/no-railsconf-faa7935e) for making _shocking_ and _offensive_ public statements, like that people at work should do work instead of fighting with each other about politics. Absolutely outrageous -- he deserved worse. Also in 2022, RubyConf (also organized by Ruby Central) announced they were giving up a $500k deposit so they could move the conference from Houston to San Diego, because as we all know, the state of Texas and all 30 million souls that call it home, are evil. Money well spent. Naturally, vaccine passports were still in full effect at RailsConf in mid-2023 -- not for anything to do with Covid control, but in noble pursuit of making sure that no undesirables guilty of wrongthink could be in attendance.

Programming-wise, the subject matter has shifted away from the technical towards an emphasis on soft skills. Common themes were mentorship, job progression, and unionization, which might all be fine, except for those confused few who might've come to RailsConf to learn about Rails, there wasn't much of an alternate tech track to opt into instead. (This is generally true but not completely -- my commendations to the great technical talks that snuck in past the review board.)

The name "RailsConf" is an institution, but time may be demonstrating that it's only possible for so long to run a successful conference that is ostensibly about one subject, but which is largely in pursuit of unrelated objectives. The exhibitor floor this year was pared down again even compared to last, which had already been modest. The crowds were sparse, the yawning expanse of the job boards unnervingly empty, and one couldn't help but get the feeling that the echoing halls of the Atlanta venue were oversized compared to the number of people there.

Ruby/Rails may not be the most cutting edge technology anymore, but it's still its own interesting little niche inside of a broader ecosystem, and even in 2023, the most complete web framework in existence. It'd be a shame not to try and nurture the vibrant community that cares deeply about it. Last November, the [Rails Foundation was created](https://rubyonrails.org/2022/11/14/the-rails-foundation) with a seed of one million dollars from its eight founding members: Cookpad, Doximity, Fleetio, GitHub, Intercom, Procore, Shopify, and 37Signals. Later this year it'll hold [the first ever Rails World](https://rubyonrails.org/2023/4/6/rails-world-is-coming) in Amsterdam, limited to 650 tickets this year, but presumably aiming to provide a more focused (and dare I say, more inclusive) alternative to the Ruby Central encumbents.

I'm cautiously optimistic about the new event. It could just be the phoenix-from-the-ashes resurrection that the Rails community needs.

---

## Job queues and the hallway track (#job-queues)

As with most conferences, the best track was the hallway track, and I could some good discussions with a few people, notably around job queues (for which some selection bias might've been present). A few recent links on the subject:

* [Building a simple dynamic job scheduler with Sidekiq](https://www.tines.com/blog/building-a-simple-dynamic-job-scheduler-with-sidekiq), in which it was found that a stateless scheduler wasn't up to the task due to the possibility of it crashing, missing the hour in which it was supposed to work, and losing scheduled jobs. The solution was to move to a Postgres-based scheduler.

* [Why we ditched RabbitMQ and replaced it with a postgres queue](https://www.prequel.co/blog/sql-maxis-why-we-ditched-rabbitmq-and-replaced-it-with-a-postgres-queue), in which RabbitMQ's job prefetching feature, assuming jobs to all be short-lived, ended up holding jobs hostage for hours as they were stuck behind a slow job at the worker's head.

I got a chance to catch up with someone who worked the Heroku API team after my own time under the mast, and asked about its job queue.

During my tenure the project had moved from Delayed Job to Queue Classic to [Que](https://github.com/que-rb/que) as we tracked the new hotness in the ecosystem. Having a job queue in Postgres was interesting for minimizing dependencies and the possibilities around transaction consistency, but the years before I left had been plagued by [major queue bloat problems](/postgres-queues) caused by long-running queries initiated by other teams, filling the queue's index with dead tuples and making it inordinately expensive for workers to find live jobs. We'd found a tentative workaround that worked reasonably well, but the whole scheme was calling out to be rearchitected.

## Why the queue matters (#why)

It might not be intuitively obvious why a job queue and its steady health were of critical importance, but they were. A primary function of the queue was to push slower operations like network calls out of the synchronous API path, thereby keeping the API responsiveness while (in theory anyway) not taking any hit to UX.

One example of an out-of-band call were to register domains for new Heroku apps, linked back to the Heroku router. Every app creation would get a background job that'd perform:

```
POST https://maestro.heroku.com/domains/serene-example-4269
```

A struggling queue meant delayed domain registrations, which meant that new apps might not be able to serve requests for many minutes after being created. Similar delays would occur for activating new app releases and deprovisioning add-ons.

<img<EMAIL_ADDRESS>alt="Another shot of the leafy seadragon at the Georgia Aquarium" class="wide" loading="lazy">

## Batch-wise operations (#batch-wise)

Heroku's queueing problems weren't so technically challenging that they couldn't be fixed, but these days I find myself wondering whether we couldn't have made life easier for ourselves by shifting the paradigm.

This style of high volume queue where jobs are queued frequently and expected to be worked quickly works okay when all systems are green, but is anti-fragile in that it degenerates badly when they're not. Index bloating aside, even when we resolved the immediate problem by killing a long-running transaction, a large backlog had been enqueued, and since jobs are worked one by one, it took time to work it back down to zero.

The service I operate nowadays doesn't have a job queue. Instead, we have single, dedicated worker goroutines that fulfill specific async tasks. This might otherwise be scary because it'd be easy for a single goroutine to fall behind in the presence of a large amount of work, but each one's been specifically written to operate efficiently by batched work into as few operations as possible, and then running what can't be batched in parallel. Concretely:

* Selects are all done together instead using `id = any(@id::uuid[])` to avoid chatty round trips to the database that could easily number in the thousands.

* Updates and inserts are batched using the normal `INSERT INTO tbl VALUES ('a', 1), ('b', 2), ('c, 3)` or upsert. We use ULIDs as IDs in most places for [faster and more index-friendly insertion](/nanoglyphs/026-ids).

* When invoking remote APIs we'd use batch APIs where provided. Batch APIs are so rare as to be practically non-existent though, so we use [`errgroup` as a worker pool](https://pkg.go.dev/golang.org/x/sync/errgroup) to crunch through these invocations in parallel.

Selecting a batch is always constrained by a `LIMIT` clause so that in case of an enormous large backlog, we can always make sure that we're making forward progress instead of timing out trying to select or update a degenerately large data set.

``` sql
-- name: EmailNotificationGetUnsent :many
SELECT *
FROM email_notification
WHERE email_to IS NOT NULL
    AND sent_at IS NULL
ORDER BY id
LIMIT @max;
```

Workers go to sleep between loops if they don't have anything to do, but we have a framework for waking them via `pg_notify` to tell them there's work avaialble. So if this had been in use for the Heroku case, the API request that created a new app would wake the DNS worker to make sure that new records were registered in a timely matter.

### Example: Sending mail (#sending-mail)

Here's some sample code for our worker that sends mail. An initial select pulls up to 100 email notifications that are ready to go out:

``` go
const emailNotificationSenderMaxPerRun = 100

notifications, err := queries.EmailNotificationGetUnsent(ctx,
    emailNotificationSenderMaxPerRun)
if err != nil {
    return nil, xerrors.Errorf("error getting unsent notifications: %w", err)
}
```

Then select other data that'll be needed to send everything in the batch:

``` go
notificationAttachments, err := queries.EmailNotificationAttachmentGetByEmailNotificationID(ctx,
    sliceutil.Map(notifications, func(n dbsqlc.EmailNotification) uuid.UUID { return n.ID }))
if err != nil {
    return nil, xerrors.Errorf("error getting email notification attachments: %w", err)
}

// email notification ID -> slice of attachments
notificationAttachmentsMap := make(map[uuid.UUID][]dbsqlc.EmailNotificationAttachment)
```

Email notifications may have attachments, so use an `errgroup` to pull all the ones we'll need down from S3:

``` go
errGroup, ctx := errgroup.WithContext(ctx)
errGroup.SetLimit(awsclient.MaxParallelRequests)

for _, attachment := range notificationAttachments {
    ...

    errGroup.Go(func() error {
        out, err := w.awsClient.S3_GetObject(ctx, &s3.GetObjectInput{
            Bucket: ptrutil.Ptr(awsclient.S3Bucket),
            Key:    ptrutil.Ptr(attachmentS3Key),
        })
        if err != nil {
            return xerrors.Errorf("error getting attachment with key %q from S3: %w",
                attachmentS3Key, err)
        }
```

And similary, send each notification up to Mailgun in a parallel `errgroup`. Results are _not_ updated as a batch in this case because Mailgun's API offers no way of guaranteeing idempotency, and we want to be as careful as possible to avoid double-sending mail:

``` go
for _, notification := range notifications {
    ...

    errGroup.Go(func() error {
        message := w.mailgunClient.NewMessage(notification.EmailFrom, notification.Subject,
            notification.BodyHTML, notification.BodyText, notification.EmailTo)

        if attachments, ok := notificationAttachmentsMap[notification.ID]; ok {
            for _, attachment := range attachments {
                message.AddBufferAttachment(attachment.Filename, attachmentsDataMap[attachment.S3Key])
            }
        }

        _, id, err := w.mailgunClient.Send(ctx, message)
        if err != nil {
            return xerrors.Errorf("error sending message: %w", err)
        }

        _, err = queries.EmailNotificationUpdate(ctx, dbsqlc.EmailNotificationUpdateParams{
            ID:                       notification.ID,
            MailgunMessageIDDoUpdate: true,
            MailgunMessageID:         sql.NullString{String: id, Valid: true},
            SentAtDoUpdate:           true,
            SentAt:                   sql.NullTime{Time: time.Now(), Valid: true},
        })
        if err != nil {
            return xerrors.Errorf("error updating notification: %w", err)
        }
```

API clients should be configured with reasonably aggressive timeouts so that a single slow invocation can't delay an entire batch from finishing.

I'd never claim that anything in software is a panacea, but am fairly confident that between batch-wise operations and Go's speed, most of our workers wouldn't have much trouble burning down backlogs even in the millions if it ever came to that.

## Queues, like everything, ossify (#queue-ossification)

Back to meeting another ex-Heroku employee during the hallway track: naturally, I was excited to hear about what had come next for the Heroku API job queue. An upgrade to the newer and more bloat-resistant version of Que? Sidekiq combined with a [transactional job drain](/job-drain)? A total shift away from high-throughput single-function work and over to more efficient batch-wise operations?

But I'd forgotten my own theses around architectural longevity and [the Lindy effect](https://en.wikipedia.org/wiki/Lindy_effect):

> by which the future life expectancy of some non-perishable things, like a technology or an idea, is proportional to their current age. Thus, the Lindy effect proposes the longer a period something has survived to exist or be used in the present, the longer its remaining life expectancy.

Due to a combination of chronic trouble with headcount and overwhelming weight of sheer inertia, that job queue never changed, becoming yet another case study for the [the disproportionate influence of early tech decisions](/fragments/early-tech-decisions).

---

I'm in Europe for the whole month of May, making my way from Paris to London to Berlin.

I'm off to a good start, having totally forgotten over the last three years that outlets over here are not the same as outlets in North America, left my Euro-to-US outlet dongle at home, and not being able to charge any of the myriad of gizmos that I brought along with me. This morning I begin a pilgrimage towards Notre-Dame in search of a fabled site called "FNAC" which may be able to sell me one at a price that doesn't make me wish I'd never left my own continent, and on French Labour Day no less.

Until next week.

repository: brandur/sorg

gha_language: Go

gha_license_id: MIT

repo_name: brandur/sorg


text:
# Benchmarker <img src="https://cloud.githubusercontent.com/assets/5122822/8385821/b88ae08e-1c68-11e5-871f-5dafca6d4b26.png" height="60" width="60"/>

[![Join the chat at https://gitter.im/koustuvsinha/benchmarker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/koustuvsinha/benchmarker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Why rely on others benchmarking reports when you can test it out in your own device? Welcome to Benchmarker, your one stop app for micro-benchmarking databases and comparing performance statistics on the go, so that you can make a well-informed decision in your next superhit app.

## Motivation
Test and publish a detailed performance report on various databases and ORM's supported on the Android Platform such that developers can make an informed choice

## Roadmap
* Generate performance / throughput test cases for db types
* Monitor and report the performance statistics for comparision
* Full Material Design

## Target DB/ORM's
### Databases
- [x] [Android SQLite](http://developer.android.com/training/basics/data-storage/databases.html)
- [x] [Realm](http://realm.io)
- [x] [SnappyDB](https://github.com/nhachicha/SnappyDB)
- [x] [Couchbase Lite](http://developer.couchbase.com/mobile/index.html)

### ORM's *(based on SQLite)*
- [ ] [GreenDAO](http://greendao-orm.com)
- [ ] [OrmLite](http://ormlite.com/sqlite_java_android_orm.shtml)
- [ ] [SugarORM](http://satyan.github.io/sugar/index.html)
- [ ] [ActiveAndroid](http://www.activeandroid.com/)
- [ ] [DBFlow](https://github.com/Raizlabs/DBFlow)

*Checkmarks indicate test cases updated till now*

**NB** : My main motivation was to test out the performance of sqlite in comparision with several new and upcoming nosql databases. If you would like to help me out setting up the various ORM tests, view this [issue](https://github.com/koustuvsinha/benchmarker/issues/18)

## Further Planning
* Display detailed performance test report on separate webpage
* Publish in Google Play
* Real Time performance updates

## Results
You can find the initial benchmarking results in [here](RESULTS.md)

## Contributing
Being a newcomer into the Android World, contributions of any form are wholeheartedly welcome!
Read the [Contributing Guidelines](DEVELOPMENT.md#contribution-guidelines) and if you are a first time Android Developer read the [Tools to download](DEVELOPMENT.md#tools-to-download)

## Credits
Thanks to the projects mentioned in the [dependencies](DEVELOPMENT.md#dependencies) section for providing such amazing libraries to work with!

## License
[MIT](LICENSE.md)

repository: koustuvsinha/benchmarker

gha_language: Java

repo_name: koustuvsinha/benchmarker


text:
# CWL-Quick-Start
Short demo of a cwl workflow

- Introduction
- Checkpoint Q&A
- Walk through
  - Preview - running workflow and creating  workflow input object
   - Rabix
   - Command line
  - Show workflow componenets
    - Input section
    - Step -> go to tool
  - Show and run tool - prefilled link to container
  - Create tool from template

Learning goals:
- Understand the value of a structured workflow system
- CWL as standard
- Platforms supporting CWL
- How does CWL benefit the researcher - from batch to CWL

repository: manabuishii/cwl-intro-gui-workshop

repo_name: manabuishii/cwl-intro-gui-workshop


text:
# NullabilityStats
Commandline tool that gives an estimate per-folder how many lines of code hasn't been nullability annotated

Assumes the entire project has Nullability turned on, and counts files where nullability support has been turned off.
Does a best guess estimate on lines of code (ignoring usings, namespace, `{}`, empty lines and comments), and gives stats per-folder to be able to measure progress on adding nullability annotations.

### Install:

```
dotnet tool install dotMorten.NullabilityStats -g
```

### Usage:
 ```
   nullstats <-d depth> <-f folder(s)> <-c csvfile>
      -d: Depth to output stats for (files below are still counted). Skip or set to -1 for no limit
      -f: Folder to processs (separate by ; or use multiple -f parameters for several folders). Default is current directory.
      -c: File name for CSV report

    No parameters: current folder, no limit, no csv file.
   ```

repository: fredatgithub/NullabilityStats

repo_name: fredatgithub/NullabilityStats


text:
# ansible-role-optimization-sysctl

Ansible role for general sysctl optimization

### Prerequisites

* Make sure that you understand what the variables in the settings do.

### Supported OS

* CentOS 7

## Deployment

Example playbook named optimization-sysctl.yml:

```
- hosts: web
  roles:
    - 'ansible-role-optimization-sysctl'
```

Configure your vars in vars/main.yml. After that simply run your playbook:

```
ansible-playbook -i '<TARGET_HOST_IP>,' playbooks/optimization-sysctl.yml
```

## Built With

* [Ansible 2.8](https://docs.ansible.com/ansible/2.8/index.html)

## Authors

* **Valentin Dzhorov** - *Initial work* - [vdzhorov](https://github.com/vdzhorov)

## Company

* **Delta.BG**

## License

This project is licensed under the MIT License.


text:
---
title: API Reference

language_tabs: # must be one of https://git.io/vQNgJ
  - php
  - shell

toc_footers:
  - Sign Up for a Developer Key
  - Documentation Powered by Slate

includes:
  - errors

search: false
---

# Introduction

The Golfana Golf Course DB API is organized around REST. Our API has predictable, resource-oriented URLs,
accepts form-encoded request bodies, returns JSON-encoded responses and uses standard HTTP response codes,
authentication and verbs.

You can view code examples in the dark area to the right and you can switch the programming language of
the examples with the tabs in the top right.

The Golfana Golf Course DB API can be used in test or in live mode. The access token you use to authenticate
the request determines whether the request is test mode or live mode.

This API documentation page was created with [Slate](https://github.com/lord/slate) and heavily inspired by [Stripe's API documentation](https://stripe.com/docs/api).

# HTTP Clients

## PHP HTTP Client

```php
<?php
# We use GuzzleHttp in all our examples.
$client = new \GuzzleHttp\Client(
    [
        'http_errors'   => false,   # Do not throw exceptions when receiving protocol errors.
        'base_uri'      => 'https://api.golfana.local:444/golfcoursedb/v1/' # Note the forward slash at the end
    ]);
```

All PHP examples use [GuzzleHttp](http://docs.guzzlephp.org/en/stable/) to create a HTTP client, which is easily installed
with [Compose](http://docs.guzzlephp.org/en/stable/overview.html#installation). The parameters passed to GuzzleHttp
in the examples are optional and may of course be adjusted to suite your specific needs.

If you want to use another HTTP Client library than GuzzleHttp, please note that the Golfana Golf Course DB API expects PSR-7
compliant messages.

## Shell HTTP Client

All shell examples use [curl](https://curl.haxx.se/)

# Authentication

The Golfana Golf Course DB API uses access tokens to authenticate requests. You can view and manage your access tokens in the **Golfana Golf Course DB settings**.

Your access tokens carry many privileges, so please keep them secure! Do not share your access tokens in publicly accessible areas such as GitHub, client-side code, and so forth.

Authentication to the API is performed via **bearer authentication** and all API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

```php
<?php
# Make sure to assign either your test or your live access token to $apiAccessToken.
$headers = ['Authorization' => 'Bearer ' . $apiAccessToken];

$response = $client->request('GET', 'golfclubs/info', ['headers' => $headers]);

if ($response->getStatusCode() !== 200)
{
  # Do something with the error.
}

$result = json_decode((string)$response->getBody(), true);

# Do something with the result.
```
```shell
curl -X GET https://test.golfana.local:444/golfcoursedb/v1/info \
     -H 'Authorization: Bearer <apiAccessToken>'
```

# Errors

> Error codes:

The Golfana Golf Course DB API uses conventional HTTP response codes to indicate the success or failure of an API request.
In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the
information provided (e.g., a required parameter was omitted, the access token was invalid, etc.). Codes in the 5xx
range indicate an error with the Golfana servers (these are rare).

# Endpoints
## info
Detailed information about the golf course database.
## countrydata/:countryCode
```php
<?php
$headers = ['Authorization' => 'Bearer ' . $apiAccessToken];

$response = $client->request('GET', 'golfclubs/countrydata/NL', ['headers' => $headers]);

$result = json_decode((string)$response->getBody(), true);

print_r($result);
/*
    [
        'version'       =>  2
        'timezones'     =>  [
                                ['timezone` => `America/New_York`],
                                ['timezone` => `America/Detroit`],
                                .....
                            ],
        'stateCodes'    =>  [
                                [
                                    'stateCode'     => 'US-AL',
                                    'name'          => 'Alabama',
                                    'type'          => 'state',
                                    'otherNames'    =>  []
                                ],
                                [
                                    'stateCode'     => 'US-AK',
                                    'name'          => 'Alaska',
                                    'type'          => 'state',
                                    'otherNames'    =>  []
                                ],
                                .....
                            ]
    ]
*/
```

> The above command returns JSON structured like this:

```json
[
  {
    "id": 1,
    "name": "Fluffums",
    "breed": "calico",
    "fluffiness": 6,
    "cuteness": 7
  },
  {
    "id": 2,
    "name": "Max",
    "breed": "unknown",
    "fluffiness": 5,
    "cuteness": 10
  }
]
```

Timezone and subdivision information for a specific country.

The Golfana Golf Course DB contains a stateCode for each golf club.  We have compiled one using various resources, primarily https://www.iso.org/obp/ui/#iso:pub:PUB500001:en

This information is typically used in search filters, for example a search for all golf clubs in Arkansas in the United States.
It goes without saying that it is important that the state codes you use to search match the ones in the Golfana Golf Course DB.

Please cache the country data on the fly. Each response contains a version number which you can use to determine if your cache
needs to be updated.

### Query Parameters

Parameter | Description
--------- | ------- | -----------
countrycode | The ISO 3166-1 country code for which you want the data.

### Country data

Parameter | Description
--------- | ------- | -----------
countrycode | The ISO 3166-1 country code for which you want the data.

## golfclubs/search
Search for golf clubs in our database.

## Get All Kittens

```ruby
require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get
```

```python
import kittn

api = kittn.authorize('meowmeowmeow')
api.kittens.get()
```

```shell
curl "http://example.com/api/kittens"
  -H "Authorization: meowmeowmeow"
```

```javascript
const kittn = require('kittn');

let api = kittn.authorize('meowmeowmeow');
let kittens = api.kittens.get();
```

> The above command returns JSON structured like this:

```json
[
  {
    "id": 1,
    "name": "Fluffums",
    "breed": "calico",
    "fluffiness": 6,
    "cuteness": 7
  },
  {
    "id": 2,
    "name": "Max",
    "breed": "unknown",
    "fluffiness": 5,
    "cuteness": 10
  }
]
```

This endpoint retrieves all kittens.

### HTTP Request

`GET http://example.com/api/kittens`

### Query Parameters

Parameter | Default | Description
--------- | ------- | -----------
include_cats | false | If set to true, the result will also include cats.
available | true | If set to false, the result will include kittens that have already been adopted.

Remember — a happy kitten is an authenticated kitten!

## Get a Specific Kitten

```ruby
require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get(2)
```

```python
import kittn

api = kittn.authorize('meowmeowmeow')
api.kittens.get(2)
```

```shell
curl "http://example.com/api/kittens/2"
  -H "Authorization: meowmeowmeow"
```

```javascript
const kittn = require('kittn');

let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.get(2);
```

> The above command returns JSON structured like this:

```json
{
  "id": 2,
  "name": "Max",
  "breed": "unknown",
  "fluffiness": 5,
  "cuteness": 10
}
```

This endpoint retrieves a specific kitten.

Inside HTML code blocks like this one, you can't use Markdown, so use <code> blocks to denote code.

### HTTP Request

`GET http://example.com/kittens/<ID>`

### URL Parameters

Parameter | Description
--------- | -----------
ID | The ID of the kitten to retrieve

## Delete a Specific Kitten

```ruby
require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.delete(2)
```

```python
import kittn

api = kittn.authorize('meowmeowmeow')
api.kittens.delete(2)
```

```shell
curl "http://example.com/api/kittens/2"
  -X DELETE
  -H "Authorization: meowmeowmeow"
```

```javascript
const kittn = require('kittn');

let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.delete(2);
```

> The above command returns JSON structured like this:

```json
{
  "id": 2,
  "deleted" : ":("
}
```

This endpoint deletes a specific kitten.

### HTTP Request

`DELETE http://example.com/kittens/<ID>`

### URL Parameters

Parameter | Description
--------- | -----------
ID | The ID of the kitten to delete

repository: ghdi/slate

repo_name: ghdi/slate


text:
# Hermes
### Technology stack

*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>*<EMAIL_ADDRESS>
### Project introduce

The Hermes codebase uses [create-react-app](https://github.com/facebook/create-react-app). Simply cloning the repo and running `npm install` will get everything set up, and running `npm start` will let you run the application live.

**Notice**

1. The back end's logic is naïve. It has no ability to cope with cookie or jwt. Do not use the same design idea of HTTP request in *Hermes* in your development. Unfortunately, the solution now is actually hacking
2. [Back end API](https://github.com/Ddd1101/BPM_2018Fall/blob/master/hw3/README.md).
3. The back end doesn't support CORS, so if you want to try *Hermes* on loacalhost, make sure you have disabled web security. See [here](https://github.com/zhongxia245/blog/issues/28).

### Feature list

- [x] login, log out, sign up
- [x] check/update profile
- [x] check articles
- [x] check an article state
- [x] post a new article
- [x] update/delete a article
- [x] filter articles by tag

### Screenshots

**Main View**

![mainview](https://github.com/linxuyalun/BPM-lab/blob/master/screenshots/mainview.gif?raw=true)

**Login**

![login.gif](https://github.com/linxuyalun/BPM-lab/blob/master/screenshots/login.gif?raw=true)

**New Post**

![newPost](https://github.com/linxuyalun/BPM-lab/blob/master/screenshots/newPost.gif?raw=true)

**An Article**

![article](https://github.com/linxuyalun/BPM-lab/blob/master/screenshots/article.gif?raw=true)

**Profile**

![profile](https://github.com/linxuyalun/BPM-lab/blob/master/screenshots/profile.gif?raw=true)

repository: linxuyalun/hermes

repo_name: linxuyalun/hermes


text:
+++
title = "1.5 Making Your Stack Configurable"
chapter = false
weight = 40
+++

Right now, the bucket's contents are hard-coded. Next, you'll make the location of the contents configurable, and add support for populating the bucket with an entire directory's worth of contents.

## Step 1 — Adding a Config Variable

Instead of hard-coding the `"site"` directory, we will use configuration to make it easy to change the location without editing the program.

Create a file `config.ts` and add this to it:

```typescript
import { Config } from "@pulumi/pulumi";

const config = new Config();
export const siteDir = config.require("siteDir");
```

## Step 2 — Populating the Bucket Based on Config

Add this line to your `index.ts` file's import statements:

```typescript
import { siteDir } from "./config";
```

And replace the hard-coded `"site"` parameter with this imported `siteDir` variable:

```typescript
const myObject = new aws.s3.BucketObject("index.html", {
    acl: "public-read",
    bucket: myBucket,
    contentType: "text/html",
    source: path.join(siteDir, "index.html"),
});
```

{{% notice info %}}
The `index.ts` file should now have the following contents:
{{% /notice %}}
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as path from "path";
import { siteDir } from "./config";

const myBucket = new aws.s3.Bucket("my-bucket", {
    website: {
        indexDocument: "index.html",
    },
});

const myObject = new aws.s3.BucketObject("index.html", {
    acl: "public-read",
    bucket: myBucket,
    contentType: "text/html",
    source: path.join(siteDir, "index.html"),
});

export const bucketName = myBucket.bucket;
export const bucketEndpoint = pulumi.interpolate`http://${myBucket.websiteEndpoint}`;
```

To make matters interesting, rename the `site` directory to `www`:

```bash
mv site www
```

## Step 3 — Deploying the Changes

Now, deploy your changes. To do so, first configure your stack. If you don't, you'll get an error:

```bash
pulumi up
```

This results in an error like the following:

```
error: Missing required configuration variable 'iac-workshop:siteDir'
    please set a value using the command `pulumi config set iac-workshop:siteDir <value>`
```

Configure the `iac-workshop:siteDir` variable very much like the `aws:region` variable:

```bash
pulumi config set iac-workshop:siteDir www
```

On the next `pulumi up`, Pulumi detects that the path has changed and will perform a simple update:

```
Updating (dev):

     Type                    Name              Status      Info
     pulumi:pulumi:Stack     iac-workshop-dev
 ~   └─ aws:s3:BucketObject  index.html        updated     [diff: ~source]

Outputs:
    bucketEndpoint: "http://my-bucket-aca82a7.s3-website-us-west-1.amazonaws.com"
    bucketName    : "my-bucket-aca82a7"

Resources:
    ~ 1 updated
    2 unchanged

Duration: 3s

Permalink: https://app.pulumi.com/joeduffy/iac-workshop/dev/updates/5
```

## Step 4 — Add More Files

Instead of hard-coding the set of files, you will now change the program to read the entire contents of the `www` directory. The `mime` NPM package dynamically detects content types and `node-dir` recursively scans directories. Install these packages:

```
npm install mime @types/mime node-dir @types/node-dir
```

Add import statements for the new packages:

```typescript
import * as mime from "mime";
import * as nodedir from "node-dir";
```

> The<EMAIL_ADDRESS>packages are not imported. They are only there to ensure compile-time TypeScript checking.

Now replace the object allocation with this code:

```typescript
const files = nodedir.files(siteDir, { sync: true });
for (const file of files) {
    const name = file.substring(siteDir.length+1);
    const myObject = new aws.s3.BucketObject(name, {
        acl: "public-read",
        bucket: myBucket,
        contentType: mime.getType(file) || undefined,
        source: file,
    });
}
```

Add a new file, `about.html`, to the `www` directory:

```
<html>
    <p>Infrastructure as code using real languages is powerful.</p>
</html>
```

{{% notice info %}}
The `index.ts` file should now have the following contents:
{{% /notice %}}
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as path from "path";
import { siteDir } from "./config";
import * as mime from "mime";
import * as nodedir from "node-dir";

const myBucket = new aws.s3.Bucket("my-bucket", {
    website: {
        indexDocument: "index.html",
    },
});

const files = nodedir.files(siteDir, { sync: true });
for (const file of files) {
    const name = file.substring(siteDir.length+1);
    const myObject = new aws.s3.BucketObject(name, {
        acl: "public-read",
        bucket: myBucket,
        contentType: mime.getType(file) || undefined,
        source: file,
    });
}

export const bucketName = myBucket.bucket;
export const bucketEndpoint = pulumi.interpolate`http://${myBucket.websiteEndpoint}`;
```

Perform a deployment:

```bash
pulumi up
```

You will see a single new object created for the `www/about.html` file:

```
Updating (dev):

     Type                    Name              Status
     pulumi:pulumi:Stack     iac-workshop-dev
 +   └─ aws:s3:BucketObject  about.html        created
...
```

Now fetch it:

```bash
curl $(pulumi stack output bucketEndpoint)/about.html
```

And you will see the contents added above.

repository: jaxxstorm/aws-modernization-with-pulumi

gha_language: CSS

gha_license_id: NOASSERTION

repo_name: jaxxstorm/aws-modernization-with-pulumi


text:
nysc-membership
===============

North York Senior's Centre Membership app by Team Superior
http://nysc.herokuapp.com/participants/sign_in

*****************
*TA INSTRUCTIONS*
*****************

The following link will take you to our project`s github webpage:

http://csc301h-fall2013.github.io/nysc-membership/

Click the link and scroll down to the bottom of the page, there you will find deliverables for each Sprint.

This will take you to another webpage where you will find all preliminary sprint deliverables (must be logged in
with sufficient permissions to view the following links).


text:
# pyevmasm
[![Build Status](https://github.com/crytic/pyevmasm/workflows/CI/badge.svg)](https://github.com/crytic/pyevmasm/actions?query=workflow%3ACI)

[![PyPI version](https://badge.fury.io/py/pyevmasm.svg)](https://badge.fury.io/py/pyevmasm)
[![Slack Status](https://empireslacking.herokuapp.com/badge.svg)](https://empireslacking.herokuapp.com)

pyevmasm is an assembler and disassembler library for the Ethereum Virtual Machine (EVM). It includes a commandline utility and a Python API.

## CLI Examples with evmasm

`evmasm` is a commandline utility that uses pyevmasm to assemble or disassemble EVM:

```
usage: evmasm [-h] (-a | -d | -t) [-bi] [-bo] [-i [INPUT]] [-o [OUTPUT]] [-f FORK]

pyevmasm the EVM assembler and disassembler

optional arguments:
  -h, --help            show this help message and exit
  -a, --assemble        Assemble EVM instructions to opcodes
  -d, --disassemble     Disassemble EVM to opcodes
  -t, --print-opcode-table
                        List supported EVM opcodes
  -bi, --binary-input   Binary input mode (-d only)
  -bo, --binary-output  Binary output mode (-a only)
  -i [INPUT], --input [INPUT]
                        Input file, default=stdin
  -o [OUTPUT], --output [OUTPUT]
                        Output file, default=stdout
  -f FORK, --fork FORK  Fork, default: byzantium. Possible: frontier,
                        homestead, tangerine_whistle, spurious_dragon,
                        byzantium, constantinople, serenity. Also an unsigned
                        block number is accepted to select the fork.
```

Disassembling the preamble of compiled contract:

```
$ echo -n "608060405260043610603f57600035" | evmasm -d
00000000: PUSH1 0x80
00000002: PUSH1 0x40
00000004: MSTORE
00000005: PUSH1 0x4
00000007: CALLDATASIZE
00000008: LT
00000009: PUSH1 0x3f
0000000b: JUMPI
0000000c: PUSH1 0x0
0000000e: CALLDATALOAD
```

## Python API Examples

```
>>> from pyevmasm import instruction_tables, disassemble_hex, disassemble_all, assemble_hex
>>> instruction_table = instruction_tables['byzantium']
>>> instruction_table[20]
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
>>> instruction_table['EQ']
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
>>> instrs = list(disassemble_all(binascii.unhexlify('608060405260043610603f57600035')))
>>> instrs.insert(1, instruction_table['JUMPI'])
>>> a = assemble_hex(instrs)
>>> a
'0x60805760405260043610603f57600035'
>>> print(disassemble_hex(a))
PUSH1 0x80
JUMPI
PUSH1 0x40
MSTORE
...
>>> assemble_hex('PUSH1 0x40\nMSTORE\n')
'0x604052'
```

# Installation

Python >=2.7 or Python >=3.3 is required.

Install the latest stable version using pip:
```
pip install pyevmasm
```

Or, install the library from source:
```
git clone https://github.com/trailofbits/pyevmasm
cd pyevmasm
python setup.py install --user
```

## Documentation

[https://pyevmasm.readthedocs.io](https://pyevmasm.readthedocs.io)

New issues, feature requests, and contributions are welcome. Join us in #ethereum channel on the [Empire Hacking Slack](https://empireslacking.herokuapp.com) to discuss Ethereum security tool development.

repository: crytic/pyevmasm

gha_language: Python

repo_name: crytic/pyevmasm


text:
# Harmonic_Balance
A set of Python-based Harmonic Balance solvers.

Please see the [manual](https://josephcslater.github.io/harmonic_balance/)


text:
# TensorFlow Keras Callback Class for Dynatrace Monitoring

This simple TensorFlow Keras callback class is intended to collect AI model metrics
during the model training, testing and prediction stages and send those to your
Dynatrace monitoring environment.

Usage is:
``` { .python }
dt_callback = DynatraceKerasCallback(metricprefix='tensorflow', modelname='toxiccomment', url='https://your.live.dynatrace.com/api/v2/metrics/ingest', apitoken='yoursecret')

model.fit(
    x=train_texts, y=target,
    epochs=100,
    callbacks=[dt_callback],
    )
```

Find all the TensorFlow reported metrics within your Dynatrace metric browser, as shown below:

![](metrics.png)

Now you can chart your models performance within a dashboard.

![](chart.png)


text:
The harness and configurations in this folder show memory safety of
QueueGenericCreate, given the assumption made in the harness.

The principal assumption is that (uxItemSize * uxQueueLength) + sizeof(Queue_t)
does not overflow.

This proof is a work-in-progress.  Proof assumptions are described in
the harness.  The proof also assumes the following functions are
memory safe and have no side effects relevant to the memory safety of
this function:

* vPortEnterCritical
* vPortExitCritical

repository: LibreWireless/amazon-freertos-uno

gha_language: C

repo_name: LibreWireless/amazon-freertos-uno


text:
# Exercise 2: A Reactive Agent for the Pickup and Delivery Problem

| Exercise       | Company   | Vehicles | Tasks | Planner |
| -------------- |:---------:|:--------:|:-----:|:-------:|
| Reactive agent | 1 company | N reactive agents move thorugh topology, sensing tasks | Spread out in the topology | Reactive planner: sensing function of tasks; selects actions on the basis of a learned state-action table |

## Documentation
Overleaf link [here](https://www.overleaf.com/1615262219smrybvqdjzrs).

## A **Reactive Agent** for the Pickup and Delivery Problem
In this exercise, we will learn to use a reactive agent to solve the **Pickup and Delivery Problem**. For that, we will implement a _reinforcement learning algorithm (RLA)_ to compute an optimal strategy off-line. This strategy is then used by the agent to travel through the network.

### What is Pickup and Delivery Problem (PDP)?
- Constrained (multiple) travelling Salesman Problem
- Logistic company with a fleet of trucks
- **Goals**:
    - satisfy the customer requests: loads have to be transported from their origin location to their delivery point
    - optimize profit
- **Constraints**:
    - the cost of the vehicles and crews
    - the fuel capacities
    - etc.
- Real problem: companies are applying agent technology to Logistics

<center>

| Classical Approach      | Agent Systems             |
| ----------------------- |:-------------------------:|
| Large hierarchical apps | Societies od Small Agents |
| Batch                   | Real-time                 |
| Sequential Processing   | Concurrent                |
| Follow instructions     | Negotiations on-the-fly   |
| Static                  | Dynamic                   |

</center>

- **Environment**:
    - Topology of Cities: city (node), road (edge)
    - Coordinates and distances
    - Not dynamic

- **Customer requests**:
    - Tasks are spread over the topology

- **Transportation tasks**:
    - Pickup city
    - Delivery city
    - Weight in KG
    - Reward in CHF

- **Logistic companies (1+)**:
    - Owns 1+ trucks
    - Fulfill customer requests

- **Lifecycle**:
    - Working without interruption until all tasks are delivered
    - Exception: reactive agent will travel all the time

- **Vehicles**:
    - Fixed load capacity
    - 1+ tasks at a time
    - Starting place
    - Obliged to deliver a task to its destination
    - Cost for a specific task: `function(route)`

- **Planners/Behaviors**:
    - **Brain** of the intelligent agent
    - decide what to do at every time step

### What is LogistPlatform?
- A simulation platform for the PDP
- Implements the PDP as presented
- Built on RePast:
    - Discrete scheduler
    - Dynamic visualization
- Version: 1.0
- 3 configuration files:
    - `topology.xml` - specifies the routes
    - `reactive.xml` - specifies the framework setup, e.g. the classpath to behaviors, number of agents and their parameters
    - `tasks.xml` - specifies the probabilities/tasks
- Helps implement custom agent behaviors:
    - Act upon signals and generate appropriate responses
    - Interface with the platform in order to create more sophisticated behaviors (e.g. auction)

### What is Reactive Agent?
- Simple behaviors that react to the stimuli (e.g. stimuli from sensor on the robot) from the environment.

![Reactive Agent](img/reactive_agent.png)

### Reactive Agent Architecture?
- Vehicles as **reactive agents**
- **Percepts** from the environment (state):
    - route?
    - city?
    - task?
- **Actions** the agent can take:
    - move in a direction according to the topology
    - pickup a task
    - deliver a task
- 3 steps:
    1. Learn offline the actions to take (**strategy**) in order to optimally search and deliver tasks (using _reinforcement learning algorithm (RLA)_ - **Markov Decission Processes (MDP**))
    2. Using the learned strategy, **travel** through the network
    3. When a task has been **picked up**, **deliver** it on the shortest path (given in platform implementation)

### Assumptions
We make the following assumption about the reactive agent :
1. The vehicle starts from its home city and can move freely through the network.
2. When the vehicle arrives in a city, it finds out whether or not a task is available in that city. The vehicle sees at most 1 task!
3. If a task is available, the agent can decide to:
    - pick up the task and deliver it, or it can
    - refuse the task and move to another city (without load)
4. If no task is available or if the task was refused, the vehicle moves along a route to a neighboring city.
5. The vehicle can transport only 1 task at a time.
6. The agent receives a reward for each task that it delivers and pays a cost for each kilometer that it travels. Since the agent tries to maximize its profit, it will always deliver a task on the shortest path. Must deliver it, and on the shortest path (given by the platform).
7. A task which was refused disappears immediately. The next time the agent moves to that city a new task is generated according to the probability distribution. So, there exists a probability distribution of the tasks.

---
# Implementation

## Applyting reinforcement learning (Markov Decision Processes) to learn an optimal strategy
An intelligent reactive agent can improve its performance by learning to optimally respond to the percepts received. Using reinforcement learning the agent can learn to react optimally on the basis of a **probability distribution** of the tasks in the network. This approach assumes that the probability distribution is _known_. The learning phase is done offline before the agent travels through the network.

The following steps should therefore be taken :
1. On the basis of a probability distribution of the tasks, **learn** offline the actions to take in order to handle tasks optimally. MDP Solver: offline, before agent travels! So, learn **optimal strategy** (i.e. make a table) to move in the network and deliver tasks.
2. Use the created table (the strategy) to travel through the network and to quickly fetch the best response to a given state of the world.
3. As soon as a task has been picked up, deliver it on the shortest path to the destination city. (This is already implemented by the platform.)

At the beginning there are two tables:
- `p(i, j)`: The probability that in city `i` there is a task to be transported to city `j`.
- `r(i, j)`: The (average) reward for a task that is transported from city `i` to city `j`.

### Timeline:
- **Beforehand**: These tables are created from the task set settings in the configuration file and can be accessed through the `TaskDistribution` object that is given during setup. So, tasks `t_ij` have been created with the probability `p_ij` and a variation reward around `r_ij`.
- **At runtime**: Task from the current city `i` to some other city `j` will be created with probability `p(i, j)` and will have a reward of `r(i, j)`.

## Implementing the Reinforcement Learning Algorithm (RLA)
In this exercise, we must implement the offline reinforcement learning algorithm. The first thing that we need to do (and this is the most difficult part of this exercise) is to define (on paper !) :
- An adequate **state** representation of the world
- Which **actions** we can take in each state, and
    - the corresponding **state transition**,
    - the **probability of the transition** and
    - the **reward of the transition**.

Remember that a reactive agent chooses an action depending **only** on its perceived state of the world. So, be very careful and test an representation on paper before we start programming !

Furthermore, we need to define:
- `Best(S)`: vector indicating the best action from a state
- `V(S)`: the corresponding accumulated value; we must learn `V(S)` by value iteration:

![Value Iteration](img/value_iteration.png)

### Data Structures
- `V(S)`: vector indicating the discounted sum of the rewards to be earned (on expectation) by following that solution from state `s`.
- `R(s, a)`: table that indicates the rewards for taking action `a` being in state `s`.
- `T(s, a, s0)`: table which defines the probability to arrive in state `s0` given that we are in state `s` and that we take action `a`, i.e. `T(s, a, s0) = Pr{s0|s, a}`.
- `γ`: discount factor that ensures the algorithm converges; it must be between 0 and 1, preferably close to 1.

![Q-table](img/q_table.png)

At each iteration, update `Q(s, a)` and `V(S)`. The algorithm stops whenever there is no more a change in `V(S)`. When we have learned `V(S)`, the agent can start to move through the topology following the actions indicated in `V(S)`.

## Task
- [ ] Define:
    - state representation `s`
    - possible actions `a`
    - reward table `R(s, a)`
    - probability transition table `T(s, a, s0)` - this is the hardest and most crucial part of the exercise.
- [ ] Implement the offline reinforcement learning algorithm for determining the actions to take in order to search and deliver tasks optimally. This algorithm should be executed before the vehicles start moving.
- [ ] Run simulations of one, two and three agents using an optimally learned strategy `V(S)`. Look at the performance graph of the agents. How does it change for different discount factors? Explain an results. Test limit cases.

## Hints
There is a seperate document that elaborates the relevant parts of the LogistPlatform for this exercise.
- Do note that there is a continuous supply of tasks and that the simulation will run forever. Use the exit button from the Repast UI to shutdown the platform cleanly.
- The prepared package comes with various configuration files that allow we to test the solution. Feel free to change them and see how it affects the program. When we hand-in the solution please make sure that we correctly set the discount factor and any other user-defined values (if we use them).
- The task distribution can be given a seed in order to make the task generation deterministic. This is invaluable when doing code debugging, but please test the program with other seeds, too. If the program has just crashed look at the `history.xml` file - it contains a detailed history of events. If we reuse the seed values provided there (by changing the configuration file) we should be able to repeat the crash.
- The graph that we see when running the logist platform gives the reward per kilometer after each action and this is **NOT** a function that we need to optimize, RLA optimizes another function.

## Run Simulation
For 1 agent (called reactive-random):

```
java -jar lib/logist.jar config/reactive.xml reactive-random
```

For 3 agents (all called the same, reactive-random):
```
java -jar lib/logist.jar config/reactive.xml reactive-random reactive-random reactive-random
```

Our implementation (with the configuration that is currently in the repo):
```
ava -jar lib/logist.jar config/reactive.xml reactive-rla-99 reactive-rla-95 reactive-rla reactive-rla-50 reactive-rla-15 reactive-random
```
![Our implementation](img/our_implementation.gif)

Note: the inicial parameters can affect the results. Also, there can be a better implementation which gives a bigger difference between the performace of a true reactive agent and random one.

---
# Submission

## Instructions
1.  Download the skeleton files for the reactive exercise
2.  Import the project in Eclipse (or another IDE, for example Netbeans).
3.  Reference the library logist and the other libraries that we downloaded from the moodle page for this exercise
4.  Link the javadoc for the logist library
5.  Read carefully the documentation for logist - there we can find instructions how to execute the platform
6.  Write an agent
7.  The name of the agent (in agents.xml) that represents an final solution should be reactive-rla
8.  Make sure that we fulfill the requirements for the solution given in the exercise description
9.  Perform some simulations and analyze the performance of an reactive agent according to the instructions given in the latex template for the report
10.	Create a folder named "doc" in the project
11. Write documentation using the latex template and place it into a doc folder that we created. The pdf should be named lastname1-lastname2-ex2.pdf. The report should not be longer than 3 pages.
12.	Zip the folder lastname1-lastname2-ex2 (without the libraries) and submit it on moodle

## Deliverables (Due on Tuesday 08.10.2019, 23:55) :
- A report in PDF describing an state representation, where code and the results obtained with an solution.
_The report should be based on a latex template that is given on the exercise description moodle page._
- the name of an agent (in `agents.xml`) that represents an final solution should be `reactive-rla`
- rename the reactive folder to _lastname1-lastname2-ex2_
- create a directory called doc within this folder and place the report in this folder
- create a zipfile _lastname1-lastname2-ex2.zip_ containing everything in the _lastname1-lastname2-ex2_ folder.

repository: JelenaBanjac/intelligent-agents

repo_name: JelenaBanjac/intelligent-agents


text:
# MaterialColors

A project to extends Pharo colors's classes with the [Material Design](https://en.wikipedia.org/wiki/Material_Design) recommandations.

- [Documentation](#documentation)
  * [Version management](#version-management)
  * [Install MaterialColors](#install-materialcolors)
  * [Resources](#resources)
  * [Smalltalk versions compatibility](#smalltalk-versions-compatibility)
  * [Contact](#contact)

# Documentation

## Version management

This project use semantic versionning to define the releases. This mean that each stable release of the project will get associate a version number of the form `vX.Y.Z`.

- **X** define the major version number
- **Y** define the minor version number
- **Z** define the patch version number

When a release contains only bug fixes, the patch number increase. When the release contains new features backward compatibles, the minor version increase. When the release contains breaking changes, the major version increase.

Thus, it should be safe to depend on a fixed major version and moving minor version of this project.

## Install MaterialColors

To install MaterialColors on your Pharo image you can just execute the following script:

```Smalltalk
    Metacello new
    	githubUser: 'DuneSt' project: 'MaterialColors' commitish: 'master' path: 'src';
    	baseline: 'MaterialColors';
    	load
```

To add MaterialColors to your baseline just add this:

```Smalltalk
    spec
    	baseline: 'MaterialColors'
    	with: [ spec repository: 'github://DuneSt/MaterialColors:master/src' ]
```

Note that you can replace the #master by another branch as #development or a tag as #v2.0.0 or #v2.0.? or #v2.x.x .

## Resources

This project aim to help developers to follow Material Design recommandations about colors.

To learn those recommandation please refer to [https://material.io/design/color/](https://material.io/design/color/)

## Smalltalk versions compatibility

| MDL version 	| Compatible Pharo versions 	| Compatible Gemstone versions 	|
|-------------	|---------------------------	|---------------------------	|
| 1.0.x       	| Pharo 50, 60, 61          	| None                      	|
| 1.1.x       	| Pharo 50, 60, 61          	| None                       	|
| 1.2.x       	| Pharo 50, 60, 61          	| Gemstone 3.4.x (*)        	|
| 2.x.x       	| Pharo 61, 70, 80, 90, 10        	| None				        	|

(*) This version of Gemstone is tested. Older versions might work but we did not tested it.

## Contact

If you have any question or problem do not hesitate to open an issue or contact cyril (a) ferlicot.me

repository: DuneSt/MaterialColors

branch_name: refs/heads/development

gha_language: Smalltalk

repo_name: DuneSt/MaterialColors


text:
---
layout: post
title: "Mandriva has announced the release of Mandriva Enterprise Server 5.1"
description: ""
category: "Archive"
tags: []
---
{% include JB/setup %}
DistroWatch.com reports that Mandriva has announced the release of Mandriva Enterprise Server 5.1, a commercial Linux distribution with 5-year maintenance support!

## Press release

  “
The first update of Mandriva Enterprise Server (MES) 5, the simple and innovative Linux server, is available today. Coming with plenty of technology enhancements, hardware support scope and software list have been increased. Mandriva Enterprise Server 5 aims to be innovative in order to make infrastructure management even easier. The main focus of MES 5.1 is on virtualization. MES 5.1 improves integration of KVM technology (Kernel-based Virtual Machine) together with an administration tool for a simple management. MES 5.1 also includes an installation wizard and Mandriva Directory Server (MDS).  “

## Release Meta

See the release announcement and visit the product page for further information. Mandriva Enterprise Server 5.1 is available for purchase from the company's online store (starting at â‚¬299 with one year of support); a trial edition is available for download from here (registration required).


text:
//[sdk](../../../index.md)/[com.selligent.sdk](../index.md)/[SMManager](index.md)/[getInAppMessages](get-in-app-messages.md)

# getInAppMessages

[androidJvm]\
open fun [getInAppMessages](get-in-app-messages.md)(callbackEvent: [SMInAppMessageReturn](../-s-m-in-app-message-return/index.md))

Gets the list of all [SMInAppMessage](../-s-m-in-app-message/index.md) currently stored by the SDK, unfiltered. Use this method if you want to display the In-App messages yourself. Note: the messages retrieved using this method are the exact content of the In-App message cache. If you started the SDK with the value None for SMSettings.ClearCacheIntervalValue, it means there is no cache for the In-App messages and, therefore, this will return an empty array. In that case, you must rely only on the observer to retrieve the In-App messages.

#### Parameters

androidJvm

| | |
|---|---|
| callbackEvent | The event that will be called when the messages are retrieved. It will be passed an [ArrayList](https://developer.android.com/reference/kotlin/java/util/ArrayList.html) of [SMInAppMessage](../-s-m-in-app-message/index.md) |


text:
# Episode 022: 复制订阅相关的二三事

- Hosted by Penghui Li
- Recorded on 08/23/2020

![](/image/022.png)

## Table of Content

- 00:02:00 - Week review
- 00:14:00 - Geo replication
- 00:22:00 - Replicated subscription
- 00:47:30 - Q&A

## Reference

- Recorded video: https://www.bilibili.com/video/BV1T741147B6?p=21
- Tech blog: https://mp.weixin.qq.com/s/uiS9POboM_IqYSHPeIuE-g


text:
# java-fundamentals

# Lab 2

- Created multiple classes and tests for each one as designated per instruction
- IntelliJ was key to success which ultimately relies on the gradle being set-up properly

# Lab 3

- Created the first method for weather
- IntelliJ has been fixed and gradle works as expected
- Linter created for this lab
- When it runs, the linter should keep the code written within a strict set of parameters to help write clear and concise code now and ing   the future when using IntelliJ

# Lab 4
- Serge's Repo contains our work which can be found below:
- https://github.com/sergeyvoytov/bitmap-transformer

# Lab 6
## Part 1
- I worked with Serge today on this lab and used online resources as well
- Create a restaurant class
- Created a review class
- Create the review class about a restaurant
- Lastly added an add review
- Did not get to stretch goals

## Part 2
- I created new classes for shop, theater, and theater review
- In conjunction with those classes, I created test for each
- I refactored the existing code show data could be shared across via inheritance
- Tests all checked out and really found out how much Java hates differing spaces between messages (expected and actual)

# Lab 8
## Partnered with Annie
- I worked with Annie today on this lab and used online resources as well
- Used the file recentquotes.json to show random popular book quotes
- Made a program that use GSON to parse the .json file
- The only functionality was to show the quote and the author when it ran
- The app can choose one quote each time it is ran
-


text:
# Sage Intacct SDK for .NET Examples

This project is meant to be used with the [Sage Intacct SDK for .NET guides][sdk-guide-url].

## Issues

We kindly ask you refer to the [Sage Intacct Developer Support Resources][dev-support] page.

[dev-support]: https://developer.intacct.com/support/
[sdk-guide-url]: https://developer.intacct.com/tools/sdk-net/
[sdk-repo]: https://github.com/Intacct/intacct-sdk-net

repository: AnasUsmany/intacct-sdk-net-examples

repo_name: AnasUsmany/intacct-sdk-net-examples


text:
# Hemera-slackbot

Simple wrapper around [slack-bot-api](https://github.com/mishk0/slack-bot-api) allows you to send messages to slack users, groups and more with hemera.

[![npm](https://img.shields.io/npm/v/hemera-slackbot.svg?maxAge=3600)](https://www.npmjs.com/package/hemera-slackbot)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](#badge)

## Usage

```js
const hemera = new Hemera(nats)
hemera.use(hemeraSlackbot, {
  token: '<your-token>', // Add a bot https://my.slack.com/services/new/bot and put the token
  name: 'myBot'
})
```

## RTM (Real-time-messaging)

```js
hemera.act({
      topic: 'slackbot',
      cmd: 'subscribe',
      maxMessages$: -1,
    (err, req) => {
      // all ingoing events https://api.slack.com/rtm
  })
```

# API

See [slack-bot-api](https://github.com/mishk0/slack-bot-api#methods) for an overview of all available methods. We pass it one to one.

## Why?

Slack is one of the most popular chat services and provide a great integration for many services. It's no secret that it can improve the flow of information in teams. Be notified of critical system or business errors anytime and anywhere. Emails are annoying!

* An important user has canceled his subscription -> notify me!
* We reached the first 10000 Users -> notify us!
* The server respond with 500 -> notify emergency group!
* ...

## Credits

Idea by [OsoianMarcel](https://github.com/OsoianMarcel)

repository: hemerajs/hemera

gha_language: JavaScript

repo_name: hemerajs/hemera