text:
# NGEmu
NGEmu is a HLE N-Gage emulator written in C++.

IRC channel: #NGEmu on Freenode

## Status
**Development halted** until we can obtain the **N-Gage specific SDK**.
If you've got the SDK, parts of it or any leads for obtaining it, please contact tambre either on our IRC channel (#NGEmu on Freenode) or at ![](https://i.imgur.com/bPYEQsM.png)

**But why?**
Since a NGEmu is a HLE emulator, we depend on ordinals for functions being correct. We currently have been using IDs generated from the 1st Edition S60 SDK, but these don't match up with what the game actually passes as arguments. To avoid incorrect implementation and problems down the road, the progress is halted for now.

Other than that, some basic game code runs.

## System Requirements
* Modern 64-bit CPU
* Vulkan compatible graphics card
* 64-bit OS

## Compiling
NGEmu can be currently only compiled using Visual Studio 2015 on a Windows computer. Linux support is planned for the future.

repository: basecq/NGEmu

repo_name: basecq/NGEmu


text:
# IonQ API Service

IonQ's API provides a way to execute quantum circuits on IonQ's trapped ion quantum computers
or on cloud based simulators.  As of April 2021, this access is restricted to partners.
See [Access and Authentication](access.md) for details of access.

## Service class

The main entrance for accessing IonQ's API are instances of the `cirq_ionq.Service` class.
These objects need to be initialized with an api key, see
[Access and Authentication](access.md) for details.

The basic steps for running a quantum circuit in a blocking manner are:

1. Create a circuit to run.
2. Create a `cirq_ionq.Service` with proper authentication and endpoints.
3. Submit this circuit to run on the service and await the results of this call.
(Or alternatively use asynchronous jobs and processing)
4. Transform the results in a form that is most useful for your analysis.

Here is a simple example of this flow:

```python
import cirq
import cirq_ionq as ionq

# A circuit that applies a square root of NOT and then a measurement.
qubit = cirq.LineQubit(0)
circuit = cirq.Circuit(
    cirq.X(qubit)**0.5,            # Square root of NOT.
    cirq.measure(qubit, key='x')   # Measurement store in key 'x'
)

# Create a ionq.Service object.
# Replace API_KEY with your api key.
# Alternatively, if you have the IONQ_API_KEY environment
# variable set, you can omit specifying this api_key parameters.
service = ionq.Service(api_key=API_KEY)

# Run a program against the service. This method will block execution until
# the result is returned (determined by periodically polling the IonQ API).
result = service.run(circuit=circuit, repetitions=100, target='qpu')

# The return object of run is a cirq.Result object.
# From this object, you can get a histogram of results.
histogram = result.histogram(key='x')
print(f'Histogram: {histogram}')

# You can also get the data as a pandas frame.
print(f'Data:\n{result.data}')
```
This produces output (will vary due to quantum randomness!)

```
Histogram: Counter({0: 53, 1: 47})
Data:
    x
0   0
1   0
2   0
3   0
4   0
.. ..
95  1
96  1
97  1
98  1
99  1

[100 rows x 1 columns]
```

## Service options

In addition to the `api_key`, there are some other options which are
useful for configuring the service.  These are passed as arguments
when creating a `cirq_ionq.Service` object.

* `remote_host`: The location of the api in the form of an url. If this is None,
then this instance will use the environment variable `IONQ_REMOTE_HOST`. If that
variable is not set, then this uses `https://api.ionq.co/{api_version}`.
* `default_target`: this is a string of either `simulator` or `qpu`. By setting this you do not have to specify a target every time you run a job using `run`, `create_job` or via the `sampler` interface.  A helpful pattern is to create two services with defaults for the simulator and for the QPU separately.
* `api_version`: Version of the api. Defaults to 'v0.1'.
* `max_retry_seconds`: The API will pull with exponential backoff for completed jobs.  By specifying this you can change the number of seconds before this retry gives up.  It is common to set this to a very small number when, for example, wanting to fail fast, or to be set very long for long running jobs.

## Next steps

[Learn how to build circuits for the API](circuits.md)

[How to use the service API](jobs.md)

[Get information about QPUs from IonQ calibrations](calibrations.md)

repository: vtomole/Cirq

branch_name: refs/heads/master

extension: md

gha_language: Python

license_type: permissive

repo_name: vtomole/Cirq


text:
**TPS Keyword Interact** (Based on *mt_keyword_interact* by CWz aka ChaosWormz)

**License:** MIT

**Description:**

This mod automatically grants interact to player who enter a keyword in chat. Presumably they have "accepted the rules" or followed other steps laid out by the server admin before obtaining said keyword, which is provided to them by the tps_signs mod.

**Supports [tps_signs](https://github.com/Cat5TV/tps_signs):** if you use the two mods together, you can change your keyword (or let a cronjob do it for you) at any time and the sign will automatically change to the new keyword without having to restart or reconnect.

**Supplements:**

*cron.sh* (Linux) - Call this script from cron to automatically change the server's keyword from the list in keywords.txt
Usage:
```
./cron.sh random   # generate a random keyword
./cron.sh keyword  # generate a random word selected from keywords.txt
```

**For the keyword to work the *nointeract* privilege must be granted to players by default.**

Old commands (many soon to be deprecated! Left for reference only ... for now):

/setkeyword [new keyword]

Required privs: server

Description: set a new keyword that will take effect after next restart.

/getkeyword

Description: Used to get the current keyword. this command is restricted to basic_privs and server

/send_spawn

Description: Used to send all player who do not have interact back to spawn.

Required privs: basic_privs

/yesinteract

Description: manually grant a player interact and do what the keyword does.

Required privs: basic_privs

license: MIT

gha_language: Lua


text:
# Julia

> exploring Julia!

---

  - a flexible dynamic language,
  - appropriate for scientific and numerical computing,
  - with performance comparable to traditional statically-typed languages.

About:

We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

Start here

  Author:  Praveen T.N

  Julia Version:  1.0.0

gha_language: Jupyter Notebook

gha_license_id: MIT


text:
# CUBA React Core

Contains core components and utilities for CUBA Platform frontend clients based on React and React Native.

Documentation and API reference can be found [here](https://cuba-platform.github.io/frontend).

repository: vyacheslav-pushkin/frontend

repo_name: vyacheslav-pushkin/frontend


text:
![Build and Test](https://github.com/anaghesh-muruli/Commander-API/workflows/Build/badge.svg)
![Limit complexity](https://github.com/anaghesh-muruli/Commander-API/workflows/Limit%20complexity/badge.svg)
![GitHub last commit](https://img.shields.io/github/last-commit/anaghesh-muruli/Commander-API)
![GitHub top language](https://img.shields.io/github/languages/top/anaghesh-muruli/Commander-API)
# Commander-API
API to manage platform commands which are used most frequently

## Index
1. [Tech stack](#Techstack)
2. [APIs](#APIs)
3. [Topics covered](#Topicscovered)

## Tech stack
a. ASP .NET Core 3.1

b. MS SQL Server 10.0

## APIs

| **SL. No** | **HTTP Method** | **API URL**         | **Description**          | **Success Response**           | **Failure Response**         |
|------------|-----------------|---------------------|--------------------------|--------------------------------|-------------------------------|
| 1          | GET             | api/commands        | Get all Commands         | 200 status code with "OK"      | 400 status code 'BAD REQUEST' |
| 2          | GET             | api/commands/\{id\} | Get Command by id        | 200 status code with "OK"      | 400 status code 'BAD REQUEST' |
| 3          | POST            | api/commands        | Add a Command            | 201 status code with "CREATED" | 400 status code 'BAD REQUEST' |
| 4          | PUT             | api/commands/\{id\} | Update a Command         | 204 status code 'NO CONTENT'   | 400 status code 'BAD REQUEST' |
| 5          | PATCH           | api/commands/\{id\} | Partial Update a Command | 204 status code 'NO CONTENT'   | 400 status code 'BAD REQUEST' |
| 6          | DELETE          | api/commands/\{id\} | Delete a Command         | 204 status code 'NO CONTENT'   | 400 status code 'BAD REQUEST' |

## Topics covered
a.	Fundamentals of C#

b.	Introduction to .NET

c.	Application architecture

d.	CLR and class Library

e.	Dependency Injection

f.	Service lifetimes

g.	Creating Domain models

h.	Migrations, DBContext

i.	Understanding RabbitMQ Service Bus

j.	Creating microservice using MongoDB (Theory)

repository: anaghesh-muruli/Commander-API

branch_name: refs/heads/main

repo_name: anaghesh-muruli/Commander-API


text:
#### Install Packages

```
composer install
```

#### Copy .env file

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

#### Set Database Detail
```
.env
```

#### Migrate Database
```
php artisan migrate
```

#### Install NPM Dependencies

```
npm install
```

#### Start Laravel Project

```
php artisan serve
```

```
npm run watch
```

# Connect with Us

-   [Site](https://appwrk.com/)

repository: markus-appwrk/transactions

repo_name: markus-appwrk/transactions


text:
# Best Bank Portugal Connect [![NuGet](https://img.shields.io/nuget/v/BestBankPortugalConnect.svg)](https://www.nuget.org/packages/BestBankPortugalConnect/)
The ***Best Bank Portugal Connect*** is a C# SDK (.NET/.NET Core) that helps (*a lot!*) to connect to the [Open Banking API](https://openbankproject.com/) of the portuguese bank [Banco Best](https://www.bancobest.pt/) (Best Bank). The Banco Best is the first bank to implement the [PSD2 (Payment Services Directive)](https://www.evry.com/en/news/articles/psd2-the-directive-that-will-change-banking-as-we-know-it/) in Portugal.

With this SDK is possible to make **Android** and **iOS** applications using [Xamarin](https://visualstudio.microsoft.com/xamarin/). Not just mobile applications, since that [.NET Framework](https://www.microsoft.com/net/download/dotnet-framework-runtime) and [.NET Core](https://en.wikipedia.org/wiki/ASP.NET_Core) works on a wide places, it's possible to use this SDK in these places too.

This library helps to:

* :euro: Get bank accounts **balances**.
* :credit_card: Get bank account and credit card **moviments**.
* :money_with_wings: Make **transferences** between two bank accounts.
* :money_with_wings: Make **payments**.
* :passport_control: Authorization Flow (OAuth 2)

## Usage

The main entry point for the API is to create a valid [BestBankConnector](https://github.com/Liques/BestBankPortugalConnect/wiki/BestBankConnector) object:

```csharp

// Set your application details
var app = new Application(appConsumer, appSecret, Environment.Sandbox);
// Set the user Access Token (In this case this user already made the whole OAUth 2 previously)
var user = new User(accessToken);

// Setup a BestBankConnector object
var api = new BestBankConnector(user, app);
// Get for example the account balance
var balance = api.Balance();
```

#### Authorization flow

This SDK also simplify the painful OAuth 2.0 authorization flow with the [AuthorizationFlow](https://github.com/Liques/BestBankPortugalConnect/wiki/AuthorizationFlow) object:

```csharp

// Step 1: Gets the URL Login where the Banco Best costumer will authorize the app to access his accounts
var url = AuthorizationFlow.GetBankLoginUrl(app,@"http:\\www.httpbin.org\get");

// .... Wait the costumer back to the application ... //

// Step 2: Gets the user Access Token based on a temporary code returned after the costumer authorization
var accessToken = AuthorizationFlow.GetUserAccessToken(app, temporaryCode);

```

## Documentation

You can access the official SDK documentaion [here on the repository wiki](https://github.com/Liques/BestBankPortugalConnect/wiki). Also, if you take a look at the repository files, there is a [.NET Core console app example](https://github.com/Liques/BestBankPortugalConnect/tree/master/ExampleConsoleApp) where you could see step by step examples from the authorization flow to a balance request.

## Download

The Best Bank Portugal Connect is available as a NuGet package: [![NuGet](https://img.shields.io/nuget/v/BestBankPortugalConnect.svg)](https://www.nuget.org/packages/BestBankPortugalConnect/)

> ``` PM> Install-Package BestBankPortugalConnect ```

repository: Liques/BestBankPortugalConnect

gha_language: C#

repo_name: Liques/BestBankPortugalConnect


text:
# Development Guide

## Prerequisites

### Tools
- make
- [go](https://golang.org/dl/) version v1.13+.
- [docker](https://docs.docker.com/install/) version 17.03+.

### Other tools
This repo uses other tools for development, building and testing.
These tools are installed with `make install-tools`:
- controller-gen
- golangci-lint
- mockgen
- conversion-gen
- kubebuilder
- [kustomize](https://github.com/kubernetes-sigs/kustomize)
- addlicense
- misspell
- [kind](https://github.com/kubernetes-sigs/kind)

### Cluster
- Access to a Kubernetes v1.11.3+ cluster.

## Development

### Fork and Clone

Fork [Application Repo](https://github.com/kubernetes-sigs/application).
Then clone your fork locally.

```bash
mkdir -p $GOPATH/src/sigs.k8s.io
cd $GOPATH/src/sigs.k8s.io

GITHUBID=<githubid>
git clone git@github.com:${GITHUBID}/application.git $GOPATH/src/sigs.k8s.io/application
```

### Cluster access
For running e2e tests and development testing you need access to a cluster. You could create a cluster with your cloud provider and ensure the `kubeconfig` points to the cluster.

##### Local cluster
For local testing you could create a `kind`.

```bash
# this created a kind cluster and updates kubeconfig to point to it
make e2e-setup
```
### Building the controller binary

```bash
# make or make all will build
make

# individual run make targets
#
# generate code
make generate

# create manifests
make manifests

# Inject license header to all generated files
make license

# building the kube-app-manager
make bin/kube-app-manager
```

### Running tests
After making changes use these targets to test locally.

##### unit tests
```bash
# running unitests
make test
```

##### e2e tests
```bash
# running e2e tests

# If your kubeconfig points to your test cluster skip this step
# This will create a kind cluster for testing
make e2e-setup

# run e2e tests
make e2e-test

# Tear down kind cluster
make e2e-cleanup
```

### Building controller docker
To build the controller into an image named `image` use the following command.

NOTE:
`CONTROLLER_IMG` is optional. The default value is `gcr.io/$(shell gcloud config get-value project)/kube-app-manager`

```commandline
make docker-build CONTROLLER_IMG=<image>
```

To push the controller image, run:
```commandline
make docker-push CONTROLLER_IMG=<image>
```

### Installing CRD in the cluster
Once kubeconfig is setup with a cluster.
```bash
make install
```
### Deploying the controller in cluster

- This will install the controller into the application-system namespace and with the default RBAC permissions.
- It will also install the Application CRD.
- Ensure the docker image is built and pushed first.

```commandline
make deploy CONTROLLER_IMG=<image>
```

## Using the Application CRD

The application CRD can be used both via manifests and programmatically.

### Manifests

The docs directory contains an example [manifest](docs/examples/wordpress/application.yaml) that shows how to you can integrate the Application CRD with a [WordPress deployment](docs/examples/wordpress).

The Application object uses StatefulSets and Services. It also contains some other relevant metadata describing wordpress application. Notice that each Service and StatefulSet is labeled such that Application's Selector matches the labels. The additional labels on the Applications components come from the recommended application labels and annotations.

```bash
# Deploying the example

make deploy-wordpress
kubectl get application

# cleanup
make undeploy-wordpress
```
### Programmatically

Kubebuilder provides a client to get, create, update and delete resources and this also works for application resources. This is documented in the kubebuilder book: https://book.kubebuilder.io/

Create a client:
```go
kubeClient, err := client.New(config)
```

Get an application resource:
```go
object := &applicationsv1beta1.Application{}
objectKey := types.NamespacedName{
    Namespace: "namespace",
    Name: "name",
}
err = kubeClient.Get(context.TODO(), objectKey, object)
```

Create a new application resource:
```go
app := &applicationsv1beta1.Application{
	...
}
err = kubeClient.Create(context.TODO(), app)
```

repository: nan-yu/application

repo_name: nan-yu/application


text:
---
type: rule
archivedreason:
title: Reports - Do you understand the implied contract (promises) between Members of the Scrum Team?
guid: fb1bc78b-73be-4cf6-acec-755a074625cb
uri: reports-do-you-understand-the-implied-contract-promises-between-members-of-the-scrum-team
created: 2010-04-14T06:50:19.0000000Z
authors: []
related: []
redirects:
- reports-do-you-understand-the-implied-contract-(promises)-between-members-of-the-scrum-team

---

Member of the Scrum Team should understand their responsibilities and respect the implicit contract (promises) they have made.

| **Role** | **Promises** |
| --- | --- |
| The Organization |

the team that there are stakeholders (including subject matter experts) who will help when needed

the team that there are stakeholders (including subject matter experts) who will help when needed

they will help the Scrum Master in the removal of impediments to the Scrum team’s progress

the team that they will not change priorities or constraints in the middle of a sprint without team’s consent

that being on a Scrum team will not hurt the members’ careers

not to divert team members to other work on a Scrum Day during a sprint

 |
| Product Owner |

to supply an initial product backlog

to prioritize the product backlog when needed

to be responsive to requests for feedback and clarification

empowered “voice of the customer” will be provided to answer business domain questions promptly (minutes or hours, not days)

to attend every Review, Retrospective

not to change priorities or scope during a sprint

not to direct team members to do work not agreed and planned at the beginning of the sprint

 |
| Scrum Master |

to keep the team healthy by focusing on the removal of impediments, both internal and external

to protect the team from external distractions

 |
| The Team |

that its work will be transparent, that it will make decisions and solve problems as a group, and that no individual team member will be left behind

to take prioritization and scope from the product owner on the team driving the team based on stakeholders interests

to use the stakeholders’ time wisely, by focusing on questions that are relevant to the work being done now

to do quality work the best way they know how within the constraints set forth by the organization

to deliver demonstrable product at the end of every sprint for review and validation by the stakeholders

to endeavor to become multi-skilled by sharing and pairing and not relying on experts on the team for specific functions

 |
| Team Member |

to bring issues, problems, impediments and realities encountered to the team

to be available and working with the team on every defined Scrum Day of a sprint in which they committed and any required absences will be scheduled before the beginning of the sprint

to attend every Scrum, Review, Retrospective & Planning Meeting

to refer any external request that will take more than 15 minutes of Scrum Day time to the Scrum Master

 |


text:
Crowdsourced assessment of common genetic contribution to predicting anti-TNF treatment response in rheumatoid arthritis.
=========================================================================================================================

  [@wikidata:Q37201814]

# Highlights

A rigorous community- based assessment of the utility of SNP data for predicting anti-TNF treatment efficacy in RA patients was performed in the context of a DREAM Challenge (http://www.synapse.org/RA_ Challenge). An open challenge framework enabled the comparative evaluation of predictions developed by 73 research groups.

tudy design and challenge parameters. This study was
performed as an open analytical challenge using the DREAM framework11–14 (DREAM Challenges website; www.dreamchallenges. org) as a mechanism to test predictions developed across a variety of state-of-the-art methodologies

participants were provided with SNP data collected on 2,706 anti-TNF-treated RA patients6 (Supplementary Table 1) with which to develop predictive models

# Comments

# Links

 * [Scholia Profile](https://scholia.toolforge.org/work/Q37201814)
 * [Wikidata](https://www.wikidata.org/wiki/Q37201814)
 * [TABernacle](https://tabernacle.toolforge.org/?#/tab/manual/Q37201814/P921%3BP4510)

license: Unlicense

gha_license_id: NOASSERTION


text:
# Predict fluctuations in currency quote using [Prophet](https://facebookincubator.github.io/prophet/)
![the forecast example](images/forecast_example.png)

## Overview
Let's try build model with help of [Prophet](https://facebookincubator.github.io/prophet/) to prеditi
fluctuations in currency quotes. For current example I took currency pair UAH/USD for date range 2012-2017.
Data was getting from https://www.investing.com/currencies/usd-uah-historical-data
The forecast looks quite realistic, the forecast components give some ideas about seasonality.
The time series forecast can be used as a feature for another machine learning models.

[Prophet](https://facebookincubator.github.io/prophet/) works pretty well from the box.
You can easily build a model for forecasting time series.
Also [Prophet](https://facebookincubator.github.io/prophet/docs/quick_start.html) several the hyperparameters,
that can help you improve your model.

There are build in tools for visualization of the prediction. You can visulaizate the forecast and the forecast components.
The visualization of the forecast components can help make interesting conclusions about seasonality.

![the forecast components](images/yearly_seasonality.png)

## Dependencies
* Python 3.5
* [Prophet](https://facebookincubator.github.io/prophet/)
* [scikit-learn](http://scikit-learn.org/stable/)
* [plotly](https://plot.ly/python/offline/)

repository: levabd/prophet-finance-prediction

repo_name: levabd/prophet-finance-prediction


text:
---
layout: post
section-type: post
title: Iceland - Part 4
category: Travel
tags: [ 'Iceland' ]
---

### Day 4: Eastern Fjords

In the morning, we drove through a bunch of small eastern fjord towns, some of which ended up being
more industrial and sad than cute. I imagine they're substantially different for the summer tourist
season? And the snow which turned into a whiteout blizzard certainly didn't help.

We then drove to Egilsstadir, where we spent the day. Highlights there included a folk museum that
opened just for us (given lack of tourists they probably kept lights off by default).  I had been looking for one all week,
as Iceland is so famous for them. Aaron pointed that we looked pretty sketchy driving around
in the fog, with me pointing my camera out to snap pictures. Thankfully no one branded us as
terrorists.

Finally, out of the sad Icelandic wilderness came an oasis of cheap and wonderful food with a
beautiful logo too, a supermarket named Bonus!

![](http://www.ilariamogno.com/photo/images/Iceland_in_winter_Day1_Blue_Lagoon,_Horse_Riding,_and_Pingvellir/images/Bonus_Iceland.JPG)

Of course, we realized after that actually, all the food was basically normal American prices, so darn.
We took the opportunity to buy gifts for friends back home, and were advised to buy licorice by a
store associate - everyone in Iceland seems obsessed with licorice. Sadly my friends and I both
ended up thinking the stuff totally vile, so most of my licorice went to Aaron who strangely
likes it.

The dinner we made that day was better than average, as we bought meat for the first time at Bonus!
Also, another guest staying at the hostel offered us some vegetable stew, which while a bit sketchy
looking, we graciously accepted. I was really missing vegetables at that point (pasta and PB&J
is not a great diet).
We then made an attempt to drink the schnapps we purchased at the airport, but unfortunately found it
no more palatable than the brandy...needing to chase with peanut butter (classy, I know).

That night we watched *Kick Ass*, and before turning in, danced, prayed, and
sacrificed for good weather the next day,
as the next stretch of road was extremely iffy. The Icelandic road service has a real time
[map](http://www.road.is/travel-info/road-conditions-and-weather/the-entire-country/island1e.html)
of road conditions, and the upcoming leg to Lake Myvatn was more often than not impassable to vehicles
like ours in the month prior. In hindsight, this probably should've made us more wary of driving all
of Route 1, but I think at the time we just decided that we would drive back around (clockwise)
if this part stayed impassable.

Other sights: Skrioklaustur (monastery ruins), Lagarfljot (lake), and Hallormsstaoaskogur (forest).


text:
# [Area of a Square](https://www.codewars.com/kata/5748838ce2fab90b86001b1a)

Complete the function that calculates the area of the red square, when the length of the circular arc `A` is given as the input. Return the result rounded to two decimals.

![Graph](http://i.imgur.com/nJrae8n.png)

Note: use the π value provided in your language (`Math::PI`, `M_PI`, `math.pi`, etc)

---

## Tags

- Games
- Puzzles

repository: marcobiedermann/codewars

path: /kata/8 kyu/area-of-a-square/readme.md

gha_language: TypeScript

repo_name: marcobiedermann/codewars


text:
# @dbarone/parser
A parser generator that can generate LL(1) parsers. The source code for this project is available from https://github.com/davidbarone/parser-js. The npm package can be accessed from: https://www.npmjs.com/package/@dbarone/parser.

## Getting Started
Download the package from the npm repository via the CLI:

```
npm install @dbarone/parser
```

Then, add the following into your script:

``` javascript
let { Parser, Visitor } = require("@dbarone/parser");

const fooBarBazGrammar = () => {
  return `
    FOO     = "FOO";
    BAR     = "BAR";
    BAZ     = "BAZ";
    fb      = :FOO,:BAR*;
    fbb     = ITEMS:fb,ITEMS:BAZ*;`;
};

const fooBarBazVisitor = () => {
  let state = {};
  let tokens = [];
  state["items"] = tokens;

  let visitor = new Visitor(state);

  visitor.addVisitor("fbb", (v, n) => {
    v.state.items = n.properties["ITEMS"];
  });

  return visitor;
};

let parser = new Parser(fooBarBazGrammar(), "fbb", (sender, args) => {});
let ast = parser.parse("FOOBARBARBARBAZ");
console.log(ast.prettyPrint());

let visitor = fooBarBazVisitor();
ast.walk(visitor);
console.log(`Number of FooBarBaz tokens found = ${visitor.state.items.length}`);
```

Run the script:

```
node ./src/index.js
```

You should see a simple abstract syntax tree generated in the console, and the result of processing the tree:

```
+- fbb
   +- "ITEMS" FOO [FOO]
   +- "ITEMS" BAR [BAR]
   +- "ITEMS" BAR [BAR]
   +- "ITEMS" BAR [BAR]
   +- "ITEMS" BAZ [BAZ]

Number of FooBarBaz tokens found = 5
```

If you've got this, then congratulations, you've created your first parser! Read on to find out how to can use this package to create parsers for all kinds of languages and DSLs.

## Summary
This is a parser generator that can generate LL(1) parsers, i.e. left-recursion, leftmost derivation parsers with single token lookahead. The generated parsers work in a brute-force fashion, with backtracking, and will parse context-free grammars. It is a very simplistic parser generator, and is intended for generating simple grammars or domain-specific languages (DSLs). The following services are provided:
- Lexically analyse the input into a series of tokens (tokenising)
- Parse the tokens into an abstract syntax tree (parsing)
- Navigating through the abstract syntax tree, using a visitor class (walking the abstract syntax tree)

The target use case for this parser generator is for processing inputs that are slightly too complex for regular expressions alone, and where the user does not want the overhead of an industrial strength or commercial parser generator toolkit. The benefits of this parser generator are:
- Extremely small / simple to understand
- Does not require any build-time code generation tasks.

Grammars are specified using a very friendly BNF-ish syntax which will be familiar to users of other parser toolkits. The `Parser` class provides the main functionality, and includes `tokenise` and `parse` methods. An abstract syntax tree is represented by the `Node` class, which also contains a `walk` method to navigate the abstract syntax tree.

For processing the input (through an abstract syntax tree), a special `Visitor` class is provided. Hooks into different parts of the tree can be easily coded by creating visitor handlers (again, all this can be done directly from your code without any pre-processing code generation steps).

## Grammar
A grammar is used to define the language for the parser. This grammar is created using 'BNF-ish' (BNF/EBNF) syntax, for example:
```
/* Lexer Rules */

AND             = "\bAND\b";
OR              = "\bOR\b";
EQ_OP           = "\bEQ\b";
NE_OP           = "\bNE\b";
LT_OP           = "\bLT\b";
LE_OP           = "\bLE\b";
GT_OP           = "\bGT\b";
GE_OP           = "\bGE\b";
LEFT_PAREN      = "[(]";
RIGHT_PAREN     = "[)]";
COMMA           = ",";
IN              = "\b(IN)\b";
CONTAINS        = "\bCONTAINS\b";
BETWEEN         = "\bBETWEEN\b";
ISBLANK         = "\bISBLANK\b";
NOT             = "\bNOT\b";
LITERAL_STRING  = "['][^']*[']";
LITERAL_NUMBER  = "[+-]?((\d+(\.\d*)?)|(\.\d+))";
IDENTIFIER      = "[A-Z_][A-Z_0-9]*";
WHITESPACE      = "\s+";

/*Parser Rules */

comparison_operator =   :EQ_OP | :NE_OP | :LT_OP | :LE_OP | :GT_OP | :GE_OP;
comparison_operand  =   :LITERAL_STRING | :LITERAL_NUMBER | :IDENTIFIER;
comparison_predicate=   LHV:comparison_operand, OPERATOR:comparison_operator, RHV:comparison_operand;
in_factor           =   COMMA!, :comparison_operand;
in_predicate        =   LHV:comparison_operand, NOT:NOT?, IN!, LEFT_PAREN!, RHV:comparison_operand, RHV:in_factor*, RIGHT_PAREN!;
between_predicate   =   LHV:comparison_operand, NOT:NOT?, BETWEEN!, OP1:comparison_operand, AND!, OP2:comparison_operand;
contains_predicate  =   LHV:comparison_operand, NOT:NOT?, CONTAINS!, RHV:comparison_operand;
blank_predicate     =   LHV:comparison_operand, NOT:NOT?, ISBLANK;
predicate           =   :comparison_predicate | :in_predicate | :between_predicate | :contains_predicate | :blank_predicate;
boolean_primary     =   :predicate;
boolean_primary     =   LEFT_PAREN!, CONDITION:search_condition, RIGHT_PAREN!;
boolean_factor      =   AND!, :boolean_primary;
boolean_term        =   AND:boolean_primary, AND:boolean_factor*;
search_factor       =   OR!, :boolean_term;
search_condition    =   OR:boolean_term, OR:search_factor*;";
```
The above grammar specifies an 'SQL-ish' grammar for constructing a 'filter' expression. The grammar includes terminal and non terminal rules. Within the parser, terminal rules are called lexer rules, and non-terminal rules are called parser rules. Multiple alternate expansions of a rule can be separated by '|', and a series of symbols are separated by a comma. The full set of symbols allows in the grammar is shown below:

|  Symbol   | Description                               |
| :-------: | :---------------------------------------- |
|     =     | Assignment of production rule             |
|     :     | Alias/rewrite modifier                    |
|    \|     | Alternate expansion                       |
|     ,     | Sequence / contanenation                  |
|     ;     | Termination of rule                       |
| /\*...\*/ | Comment                                   |
|   (...)   | Subrule                                   |
|     ?     | Symbol modifier - 0 or 1 times (optional) |
|     +     | Symbol modifier - 1 or more times         |
|     *     | Symbol modifier - 0 or more times         |
|     !     | Symbol modifier - ignore result from ast  |

## Internal Representation of Production Rules
The BNF-ish grammar is converted internally to a collection of production rule objects each represented by the `ProductionRule` class. An example of how the production rules are generated internally is shown below:
```
    private get bnfGrammar(): ProductionRule[] {
        return [
            // Lexer Rules
            new ProductionRule("COMMENT", "([/][*]).*([*][/])"),    // comments
            new ProductionRule("EQ", "="),                          // definition
            new ProductionRule("COMMA", "[,]"),                     // concatenation
            new ProductionRule("COLON", "[:]"),                     // rewrite / aliasing
            new ProductionRule("SEMICOLON", ";"),                   // termination
            new ProductionRule("MODIFIER", "[?!+*]"),               // modifies the symbol
            new ProductionRule("OR", "[|]"),                       // alternation
            new ProductionRule("QUOTEDLITERAL", '"(?:[^"]|\\.)*"'),
            new ProductionRule("IDENTIFIER", "[a-zA-Z][a-zA-Z0-9_']+"),
            new ProductionRule("NEWLINE", "\n"),
            new ProductionRule("LPAREN", "[(]"),
            new ProductionRule("RPAREN", "[)]"),

            // Parser Rules
            new ProductionRule("alias", ":IDENTIFIER?", ":COLON"),
            new ProductionRule("subrule", "LPAREN!", ":parserSymbolsExpr", "RPAREN!"),
            new ProductionRule("symbol", "ALIAS:alias?", "SUBRULE:subrule", "MODIFIER:MODIFIER?"),
            new ProductionRule("symbol", "ALIAS:alias?", "IDENTIFIER:IDENTIFIER", "MODIFIER:MODIFIER?"),
            new ProductionRule("parserSymbolTerm", ":symbol"),
            new ProductionRule("parserSymbolFactor", "COMMA!", ":symbol"),
            new ProductionRule("parserSymbolExpr", "SYMBOL:parserSymbolTerm", "SYMBOL:parserSymbolFactor*"),
            new ProductionRule("parserSymbolsFactor", "OR!", ":parserSymbolExpr"),
            new ProductionRule("parserSymbolsExpr", "ALTERNATE:parserSymbolExpr", "ALTERNATE:parserSymbolsFactor*"),
            new ProductionRule("rule", "RULE:IDENTIFIER", "EQ!", "EXPANSION:QUOTEDLITERAL", "SEMICOLON!"),      // Lexer rule
            new ProductionRule("rule", "RULE:IDENTIFIER", "EQ!", "EXPANSION:parserSymbolsExpr", "SEMICOLON!"),  // Parser rule
            new ProductionRule("grammar", "RULES:rule+")
        ];
    }
```
(The above is actually the grammar for specifying the 'BNF-ish' grammar used by this tool)

Each line specifies an 'expansion' rule. Rules can be either:
- Lexer rules
- Production rules

Rules are named using alpha-numeric characters, or the underscore character. Rule names must start with an alpha character. Lexer rules are defined as requiring an uppercase first character, and parser rules must start with a lower case character.

Lexer rules define terminal symbols in the grammar. Every possible terminal symbol must be defined explicitly as a lexer rule (Parser rules cannot use literal symbols). Each lexer rule maps to a single literal expansion only. The expansion is written using a regex. For lexer rules, the ordering in the grammar is important. If a set of characters can be matched by 2 or more lexer rules, the most specific rule must be specified first.

Parser rules define non-terminal symbols. Parser rules define expansions to a set of lexer rules or other parser rules. The general format of a parser symbol is:

`(alias(:))symbol(modifier)`

The alias and modifier parts are options. In a simple case, the symbol is the name of another rule (either lexer or parser rule). symbols in a parser rule can be other parser rules which in turn expand into other parser rules, and hence in this fashion a complex grammar can be specified.

## Subrules
In general, a parser rule specifies a set of expansion symbols. Each of these must be another production rule (either lexer rule or parser rule). Alternatively, rules can be 'inlined' within a production rule using the parentheses `(...)`. These have the effect of creating an anonymous parser rule. Subrules can be used in place of explicit rules to make the grammar more consise. For example, a simple grammar to define a numeric expression without left recursion could be written as:
```
NUMBER_LITERAL  = ""\d+"";
PLUS_OP         = ""\+"";
MINUS_OP        = ""\-"";
MUL_OP          = ""\*"";
DIV_OP          = ""\/"";
LPAREN         = ""\("";
RPAREN         = ""\)"";
expression      = minus_plus_expr | term;
minus_plus_expr = TERMS:term, TERMS:minus_plus_expr_*;
minus_plus_expr_
                = OP:MINUS_OP, term | OP:PLUS_OP, term;
term            = mul_div_term | factor;
mul_div_term    = FACTORS:factor, FACTORS:mul_div_term_*;
mul_div_term_   = OP:DIV_OP, factor | OP:MUL_OP, factor;
factor          = primary | PLUS_OP, primary | MINUS_OP, primary;
primary         = NUMBER_LITERAL | LPAREN, expression, RPAREN;";
```
Using subrules, this can be rewritten as:
```
NUMBER_LITERAL  = ""\d+"";
PLUS_OP         = ""\+"";
MINUS_OP        = ""\-"";
MUL_OP          = ""\*"";
DIV_OP          = ""\/"";
LPAREN         = ""\("";
RPAREN         = ""\)"";
expression      = TERMS:(:term, :(OP:MINUS_OP, term | OP:PLUS_OP, term)*);
term            = FACTORS:(:factor, :(OP:DIV_OP, factor | OP:MUL_OP, factor)*);
factor          = primary | PLUS_OP, primary | MINUS_OP, primary;
primary         = NUMBER_LITERAL | LPAREN, expression, RPAREN;";
```
On the downside, subrules get automatically generated in the grammar, and cannot be easily referenced in the abstract syntax tree. When rules are explicitly defined in the grammar, the rule names become the names of the nodes in the abstract syntax tree, and these same names are used by the visitor to match appropriate nodes. Subrules cannot be easily matched by the visitor. In general it is not recommended to make deeply nested subrules. Subrules should be used only for simple inline expansions.

## Tokeniser
The tokeniser uses regex expressions as rules. Any valid JavaScript regular expression can be used. Note that every string token in your input must be defined as a lexer rule. There is no support for literal tokens defined in parser rules. All parser rules must reference either other parser rules, or lexer rules.

## Tree Generation and Rule Modifiers
The result of the `Parser.parse()` method is an abstract syntax tree. The structure of the tree is designed to be close to the grammar. for example, given a grammar:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FOO,PLUS,BAR;
fbb     = fb,PLUS,BAZ;
```
and and input of:
`FOO+BAR+BAZ`

Then the input gets parsed into a tree as follows:
```
             fbb
              |
        -------------
        |     |     |
        fb   PLUS  BAZ
        |
   -----------
   |    |    |
  FOO  PLUS BAR
```
In general, a non-terminal node is represented using the `Node` class, and terminal / leaf nodes are represented using the `Token` class. The `name` property provides the name of non-terminal nodes, and the `tokenName` property provides the name of tokens (the `tokenValue` provides the actual value of a token). This is the default behaviour without specifying any aliases or modification rules.

In the above example, FOO, PLUS, BAR, and BAZ are all represented by `Token` objects. Each `Node` object contains a `properties` object which provides access to the child / leaf nodes. By default, the key of each property is the same as the child name. Therefore, to access the input value "FOO" in the tree, you would use:

`fbb.properties["fb"].properties["FOO"].tokenValue`

### Ignoring Items
Sometimes you need to manipulate the tree. The first way to manipulate the tree is by ignoring nodes. In the example above, the PLUS symbols don't really add much semantics to the tree. We can have the parser remove these completely, by changing the grammar to:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FOO,PLUS!,BAR;
fbb     = fb,PLUS!,BAZ;
```
The resulting tree would be:
```
             fbb
              |
        -------------
        |           |
        fb         BAZ
        |
   -----------
   |         |
  FOO       BAR
```
### Aliases / Rewrites of Symbols
Another way of manipulating the tree is to rename properties. This is done via the `alias:symbol` syntax. for example, if we change the grammar to be:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FB1:FOO,PLUS!,FB2:BAR;
fbb     = fb,PLUS!,BAZ;
```
The tree is changed as follows:
```
             fbb
              |
        -------------
        |           |
        fb         BAZ
        |
   -----------
   |         |
  FB1       FB2
```
Note how the properties of the 'fb' node have been changed. The contents of these are still the same (i.e. FOO and BAR), but the *names* have changed. All this does is change the keys used in the Properties dictionary. If a rule uses the same alias for more than one symbol, then the results are automatically grouped into a collection. For example, using a grammar:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FB:FOO,PLUS!,FB:BAR;
fbb     = fb,PLUS!,BAZ;
```
(Note both symbols in the 'fb' rule are now aliased to 'FB'), the following tree is formed:
```
             fbb
              |
        -------------
        |           |
        fb         BAZ
        |
        FB
```
In this case, the object referenced at `fbb.properties["fb"].properties["FB"]` is of type `Token[]` and contains both FOO and BAR.

A special renaming case is to use a blank name, for example:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = :FOO,PLUS!,:BAR;
fbb     = fb,PLUS!,BAZ;
```
Here, for the 'fb' rule, we've removed the aliases, but kept the colon (read as: 'rename to empty'). By *not* providing a property name, instead of creating a node under fb, the objects get collapsed up the tree, so the new tree looks like this:
```
             fbb
              |
        -------------
        |           |
        fb         BAZ
```
In this example, the `Token[]` object has been collapsed up the tree, and is now referenced at `fbb.properties["fb"]`.

*Note that a constraint exists that a rule must not contain a mixture of blank/non blank aliases. If a blank alias is specified, then ALL symbols in the rule must also have a blank alias.*

Making a further modification to the grammar:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = :FOO,PLUS!,:BAR;
fbb     = ITEMS:fb,PLUS!,ITEMS:BAZ;
```
Results in the tree being flattened further:
```
             fbb
              |
            ITEMS
```
In this case, the ITEMS node (referenced by `fbb.properties["ITEMS"]` contains a collection of the 3 items, ['FOO', 'BAR', 'BAZ']).

### Optional Modifier
Another modifier is the 'optional' modifier (? or *). These allow input to be optional. For example, changing the original grammar to:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FOO,PLUS?,BAR;
fbb     = fb,PLUS?,BAZ;
```
Then the any of the following inputs will be parsed correctly:
```
FOO+BAR+BAZ
FOO+BARBAZ
FOOBAR+BAZ
FOOBARBAZ
```
When an optional symbol is not matched, then no child is inserted into the tree.

### Many Modifier
The 'many' modifiers (+ and *) allow a symbol to be repeated more than once. For example:
```
FOO     = "FOO";
BAR     = "BAR";
BAZ     = "BAZ";
PLUS    = "[+]";
fb      = FOO+,PLUS,BAR*;
fbb     = fb,PLUS,BAZ;
```
will match:
```
FOO+BAR+BAZ
FOOFOO+BAR+BAZ
FOOFOOFOO+BAR+BAZ
FOO++BAZ
FOO+BARBAR+BAZ
FOO+BARBARBAR+BAZ
```
When a symbol is modified with the 'many' modifiers, they still occupy a single node or child property in the tree. However, the contents of the node becomes an Array object which can be iterated over.

## Ordering of rules
the order of rules is important. As the parser adopts a brute force approach, it will continue looking for matching rules until the first match. Subsequent rules will be ignored. If a failure occurs at a nested position, the parser will backtrack from the point of failure, and continue looking for matching rules. If all paths are attempted without a match, parsing of the input fails.

## Left Recursion
The JavaScript version of the parser does **not** support left recursion. A rule is directly left recursive if it has a form where the left most symbol is itself, for example:

`a = a b | C;`

However, the parser supports repeated (many) rules, and the left-recursive grammar shown above can be easily rewritten thus:

`a : C b*`

Additionally, the alias modification rules mean that C & B can be 'aliased' in the tree for improved semantics.

## Abstract syntax tree structure
The abstract syntax tree structure uses `Node` objects to represent non-terminal nodes, and `Token` objects to represent terminal nodes. Each `Node` object has a properties collection. This properties collection contains all the child symbols gathered during parsing. The property names are the node names, or the aliases (if specified). The properties collection create the tree structure. The properties collection can contain `Node` objects, `Token` objects, or lists of them.

## Processing a Tree Using the Visitor Class
A `Visitor` class is included which allows for an abstract syntax tree to be processed. A new visitor implementation is created using:

`let visitor = new Visitor(initialState)`

The `initialState` parameter is used to provide any initial state to the tree processing function. Visitor handlers are then added. A visitor typically processes a portion of the tree:

`visitor.addVisitor(ruleName, (visitor, node)=> {...});`

The first parameter is the name of the rule which is processed by the handler. The second parameter is a function which takes 2 parameters:
- The `Visitor` class
- The current `Node` object being evaluated
The body of this function is then free to process the node in any way.

State can be persisted across handlers by using the `state` property.

Visitors do not need to be written for every rule / node type. By default if no visitor is found for a node, the default behaviour is for the engine to recursively visit every node property within the parent node.

## Debugging
The `Parser` class exposes a property `logHandler` which if specified, enables the caller to output logging information related to the parsing algorithm.

Additionally, a pretty-print extension method is available to display the abstract syntax tree in a user-friendly format. The tree can be displayed for any node by calling:

`node.prettyPrint();`

For example, using the SQL-ish grammar example (included in the unit tests), an input of:

`(country EQ 'UK' AND sex EQ 'F') OR (country EQ 'Italy')`

Generates a tree as follows:

```
+- search_condition
   +- boolean_term
   |  +- boolean_primary
   |     +- search_condition
   |        +- boolean_term
   |           +- comparison_predicate
   |           |  +- "LHV" IDENTIFIER [country]
   |           |  +- "OPERATOR" EQ_OP [EQ]
   |           |  +- "RHV" LITERAL_STRING ['UK']
   |           +- comparison_predicate
   |              +- "LHV" IDENTIFIER [sex]
   |              +- "OPERATOR" EQ_OP [EQ]
   |              +- "RHV" LITERAL_STRING ['F']
   +- boolean_term
      +- boolean_primary
         +- search_condition
            +- boolean_term
               +- comparison_predicate
                  +- "LHV" IDENTIFIER [country]
                  +- "OPERATOR" EQ_OP [EQ]
                  +- "RHV" LITERAL_STRING ['Italy']
```

## Unit Tests
A set of unit tests is included in the project. As well as testing the accuracy of the system, these tests show how the parser is used. Test examples include:
- **ExpressionTests**: A simple numeric expression parser for +,-,*,/ operators as well as parentheses.
- **FooBarBazTests**: A very simple grammar.
- **SqlishTests**: A simple SQL-like grammar.
- **SubRuleTests**: A version of the ExpressionTests grammar using subrules

--- end ---

repository: davidbarone/parser-js

repo_name: davidbarone/parser-js


text:
#day-now

Day-now gets current month,day,year and displays them based on some filters.

##Usage

```js
var today=require('day-now');
console.log(today.getCurrentDay("nz"));
// days without zeroes in front,3
console.log(today.getCurrentDay("nz"));
//days with zero in front,03
console.log(today.getCurrentMonth("mnu"));
//month with its number,04
console.log(today.getCurrentMonth("mna"));
//month with its name,April
console.log(today.getCurrentDate("nm"," "));
//month name, 3 April 2018 and delimteter " "
console.log(today.getCurrentDate("us","-"));
// us system and - between, 04-03-2018
console.log(today.getCurrentDate("eu","/"));
// eu system and / between,03/04/2018
```
##Licence

Apache 2.0

repository: KwstasBol/day-now

repo_name: KwstasBol/day-now


text:
---
layout: post
title: TorchServe with GRPC Secure
---

Created: September 17, 2022 6:06 PM

In the previous [article](https://iammohitm.github.io/TorchServe-with-gRPC/), I set out steps to serve a torch model using torchserve and communicate over gRPC. However, the communication between client and the server was over an insecure channel. This may not be an ideal scenario if you are working with any confidential data. This article will set out steps to communicate with torch serve with gRPC over a secure channel.

## Prerequisites

The prerequisite is that you have been through this [article](https://iammohitm.github.io/TorchServe-with-gRPC/). Essentially, you should:

1. Have a .mar file generated
2. And compiled python output of the torchserve grpc proto files

To recap, the following is the file structure

```bash
project_root_folder
|__torchserve_grpc
	|__ model_store
		|__digit_model.mar
	|__model_weights
		|__digitcnn_state_dict.pth
	|__images
		|__test.png
	|__handler.py
	|__model.py
	|__inference.proto
	|__management.proto
	|__inference_pb2.py
	|__inference_pb2_grpc.py
	|__management_pb2.py
	|__management_pb2_grpc.py
  |__grpc_client.py
```

## Generating the keys and certificates

- The Common Name (CN) is important. Apparently, the CN for server certificate must differ from CA certificate

[OpenSSL - error 18 at 0 depth lookup:self signed certificate](https://stackoverflow.com/a/19738223/8727339)

- In step 3, the CN value should be the domain name or IP address of the server. Here I have used <IP_ADDRESS> for generality.

```bash
rm *.pem
# create a CA's private key and certificate

export country="UK"
export state="London"
export location="London"
export ipaddress="<IP_ADDRESS>"
export<EMAIL_ADDRESS>export org="Mo"
export org_unit="CV"

echo "1) Generate CA's private key and certificate"
# openssl req -x509 -newkey rsa:4096 -days 365 -keyout ca-key.pem -out ca-cert.pem

openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout ca-key.pem -out ca-cert.pem -subj "/C=${country}/ST=${state}/L=${location}/O=${org}/OU=${org_unit}/CN=random/emailAddress=${email}"

# The -x509 option is used to tell openssl to output a self-signed certificate instead of a certificate request. We need self signed because we are the CA. The private key is ca-key.pem and certificate is ca-cert.pem

# The above command will ask to provide certain identify information
echo "CA's self-signed certificate"
openssl x509 -in ca-cert.pem -noout -text

# /C is for Country
# /ST is for State or province
# /L is for Locality name or city
# /O is for Organisation
# /OU is for Organisation Unit
# /CN is for Common Name or domain name
# /emailAddress is for email address

echo "2) Generate web server's private key and CSR"
# Note: You can change the hostname parameter to the name or IP address of a server on your network, it just needs to match the server name that you connect to with the client.

# openssl req -newkey rsa:4096 -keyout server-key.pem -out server-req.pem

openssl req -newkey rsa:4096 -nodes -keyout server-key.pem -out server-req.pem -subj "/C=${country}/ST=${state}/L=${location}/O=${org}/OU=${org_unit}/CN=${ipaddress}/emailAddress=${email}"

# The above command will generated the encrypted private key and a CSR

echo "3) Sign server's CSR"

openssl x509 -req -in server-req.pem -days 365 -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile server-ext.cnf

echo "4) Verifying certificate"

openssl verify -CAfile ca-cert.pem server-cert.pem
```

**`server-ext.cnf`**

```bash
subjectAltName=IP:<IP_ADDRESS>
```

## Editing Config.Properties

Change address to use https and set the enable_grpc_ssl, private_key_file and certificate_file

```bash
max_request_size=655350000
max_response_size=655350000
inference_address=https://<IP_ADDRESS>:8080
management_address=https://<IP_ADDRESS>:8081
metrics_address=https://<IP_ADDRESS>:8082
grpc_inference_port=7070
grpc_management_port=7071

enable_grpc_ssl=true

private_key_file=torchserve_grpc/ssl/server-key.pem
certificate_file=torchserve_grpc/ssl/server-cert.pem
```

## Start the server

```bash
torchserve --start --model-store model_store --models all --ts-config configs/config.properties
```

## Check Models Served

```bash
curl https://<IP_ADDRESS>:8081/models --cacert torchserve_grpc/ssl/ca-cert.pem
```

In the `grpc_client.py` from previous [article](https://www.notion.so/TorchServe-with-GRPC-04c5cf2339d141b188cfe8ec95866187), add:

```python
def get_secure_management_stub():
    with open("torchserve_grpc/ssl/ca-cert.pem", 'rb') as f:
        creds= grpc.ssl_channel_credentials(f.read())
    channel = grpc.secure_channel('<IP_ADDRESS>:7071', credentials=creds)
    stub = management_pb2_grpc.ManagementAPIsServiceStub(channel)
    return stub

def get_secure_inference_stub():
    with open("torchserve_grpc/ssl/ca-cert.pem", 'rb') as f:
        creds= grpc.ssl_channel_credentials(f.read())
    channel = grpc.secure_channel('<IP_ADDRESS>:7070', credentials=creds)
    stub = inference_pb2_grpc.InferenceAPIsServiceStub(channel)
    return stub

```

Test using

```python
if __name__ == '__main__':
    inference_stub = get_secure_inference_stub()
    management_stub = get_secure_management_stub()

    output = list_models(management_stub)
    print(f"output: {output.msg}")

    prediction = make_prediction(inference_stub, "torchserve_grpc/images/test.png")

    print(prediction)
```

Output

```bash
output: {
  "models": [
    {
      "modelName": "digitmodel",
      "modelUrl": "digit-model.mar"
    }
  ]
}
prediction: "8"
```

## Resources

[How to create & sign SSL/TLS certificates](https://dev.to/techschoolguru/how-to-create-sign-ssl-tls-certificates-2aai)

[https://github.com/joekottke/python-grpc-ssl](https://github.com/joekottke/python-grpc-ssl)

If you have any questions about this page, please feel free to<EMAIL_ADDRESS>me. If this helped you, please consider [buying me a coffee](https://www.buymeacoffee.com/mohitmotwani)

url: https://raw.githubusercontent.com/IamMohitM/IamMohitM.github.io/f9aa769adb72066580e06648425524e73b1385ac/_posts/2023-4-20-Torch Serve with Secure gRPC.md


text:
## 🎵 Playerctl <!-- {docsify-ignore} -->

This is a signal module in which you can connect to certain bling signals to grab playerctl info. Currently, this is what it supports:

- Song title and artist
- Album art (the path this module downloaded the art to)
- If playing or not
- Position
- Song length
- If there are no players on

This module relies on `playerctl` and `curl`. If you have this module disabled, you won't need those programs. With this module, you can create a widget like below without worrying about the backend.

![](https://user-images.githubusercontent.com/33443763/107377569-fa807900-6a9f-11eb-93c1-174c58eb7bf1.png)

*screenshot by [javacafe](https://github.com/JavaCafe01)*

### Usage

To enable: `bling.signal.playerctl.enable()`

To disable: `bling.signal.playerctl.disable()`

Here are the signals available:

```lua
-- bling::playerctl::status     -- first line is the signal
--      playing  (boolean)      -- indented lines are function parameters
--      player_name (string)
-- bling::playerctl::title_artist_album
--      title  (string)
--      artist  (string)
--      album_path  (string)
--      player_name (string)
-- bling::playerctl::position
--      interval_sec  (number)
--      length_sec  (number)
--      player_name (string)
-- bling::playerctl::no_players
--      (No parameters)
```

### Example Implementation

Lets say we have an imagebox. If I wanted to set the imagebox to show the album art, all I have to do is this:
```lua
local art = wibox.widget {
    image = "default_image.png",
    resize = true,
    forced_height = dpi(80),
    forced_width = dpi(80),
    widget = wibox.widget.imagebox
}

local name_widget = wibox.widget {
    markup = 'No players',
    align = 'center',
    valign = 'center',
    widget = wibox.widget.textbox
}

local title_widget = wibox.widget {
    markup = 'Nothing Playing',
    align = 'center',
    valign = 'center',
    widget = wibox.widget.textbox
}

local artist_widget = wibox.widget {
    markup = 'Nothing Playing',
    align = 'center',
    valign = 'center',
    widget = wibox.widget.textbox
}

-- Get Song Info
awesome.connect_signal("bling::playerctl::title_artist_album",
                       function(title, artist, art_path, player_name)
    -- Set art widget
    art:set_image(gears.surface.load_uncached(art_path))

    -- Set player name, title and artist widgets
    name_widget:set_markup_silently(player_name)
    title_widget:set_markup_silently(title)
    artist_widget:set_markup_silently(artist)
end)
```
Thats all! You don't even have to worry about updating the widgets, the signals will handle that for you.

Here's another example in which you get a notification with the album art, title, and artist whenever the song changes.

```lua
local naughty = require("naughty")

awesome.connect_signal("bling::playerctl::title_artist_album",
                       function(title, artist, art_path, player_name)
    naughty.notify({title = title, text = artist, image = art_path})
end)
```

### Theme Variables and Configuration
By default, this module will output signals from the most recently active player. If you wish to customize the behavior furthur, the following configuration options are available depending on the selected backend. Here is a summary of the two backends and which configuration options they support.

| Option              | playerctl_cli      | playerctl_lib      |
| ------------------- | ------------------ | ------------------ |
| backend             | :heavy_check_mark: | :heavy_check_mark: |
| ignore              |                    | :heavy_check_mark: |
| player              |                    | :heavy_check_mark: |
| update_on_activity  |                    | :heavy_check_mark: |
| interval            | :heavy_check_mark: | :heavy_check_mark: |

- `backend`: This is a string containing the name of the backend that will be used to produce the playerctl signals, either `playerctl_cli` or `playertl_lib`. `playerctl_cli` is used by default because it is supported on most if not all systems. That said, if the playerctl package for your distribution supports the `playerctl_lib` backend, it is recommended, because it supports all the configuration options as seen in the table above and uses less system resources. If you are not sure if your package supports the `playerctl_lib` backend you can simply try it and will receive an error message from Awesome upon calling `bling.signal.playerctl.enable()` if it is not supported. See the examples below for how to set configuration options.

- `ignore`: This option is either a string with a single name or a table of strings containing names of players that will be ignored by this module. It is empty by default.

- `player`: This option is either a string with a single name or a table of strings containing names of players this module will emit signals for. It also acts as a way to prioritize certain players over others with players listed earlier in the table being preferred over players listed later. The special name `%any` can be used once to match any player not found in the list. It is empty by default.

- `update_on_activity`: This option is a boolean that, when true, will cause the module to output signals from the most recently active player while still adhering to the player priority specified with the `player` option. If `false`, the module will output signals from the player that started first, again, while still adhering to the player priority. It is `true` by default.

- `interval`: This option is a number specifying the update interval for fetching the player position. It is 1 by default.

These options can be set through a call to `bling.signal.playerctl.enable()` or these theme variables:
```lua
theme.playerctl_backend = "playerctl_cli"
theme.playerctl_ignore = {}
theme.playerctl_player = {}
theme.playerctl_update_on_activity = true
theme.playerctl_position_update_interval = 1
```

#### Example Configurations
```lua
-- Prioritize ncspot over all other players and ignore firefox players (e.g. YouTube and Twitch tabs) completely
bling.signal.playerctl.enable {
    backend = "playerctl_lib",
    ignore = "firefox",
    player = {"ncspot", "%any"}
}

-- OR in your theme file:
-- Same config as above but with theme variables
theme.playerctl_backend = "playerctl_lib"
theme.playerctl_ignore = "firefox"
theme.playerctl_player = {"ncspot", "%any"}

-- Prioritize vlc over all other players and deprioritize spotify
theme.playerctl_backend = "playerctl_lib"
theme.playerctl_player = {"vlc", "%any", "spotify"}

-- Disable priority of most recently active players
theme.playerctl_backend = "playerctl_lib"
theme.playerctl_update_on_activity = false

-- Only emit the position signal every 2 seconds
theme.playerctl_position_update_interval = 2
```

repository: polarmutex/dotfiles

repo_name: polarmutex/dotfiles


text:
# The case for fusion

Cheaper than renovating SF MOMA and the Bay Bridge
Why we need fusion and how we can have it for less less than you think

Malcolm Handley, [Strong Atomics](https://strong-atomics.com)

---

# We need lots of clean energy

- The physics of greenhouse gases is very simple: CO2 warms the planet
- Energy usage will probably [double by 2100](https://globalchange.mit.edu/publications/signature/2014-energy-and-climate-outlook)
- World market for energy is ~$1T

note:
- Energy is closely connected to prosperity. A world with more wealthy people
    will need more energy.
- Market size comes from global energy use of 1.5e17 Wh
  (https://en.wikipedia.org/wiki/World_energy_consumption) and a low estimate of
  $0.01 per kWh.

---

# Solutions

- Renewables
- Storage
- Efficiency
- Grid improvements

note:
Renewables and storage are getting cheaper, giving people hope.
And efficiency improvements often pay for themselves.
We should do all of these things, but they aren't enough.

---

# But it doesn't work

- [Bad assumptions](http://m.pnas.org/content/114/26/6722.full.pdf?with-ds=yes)
- [80% of a grid that's too small](http://denning.atmos.colostate.edu/ats543/Grid/MacDonald.supplementary.nclimate2921-s1.pdf)
- [Climate Change without the Hot Air](https://www.withouthotair.com/)

note:
Bad assumptions:
- how fast we can update every building in the world
- the cost of borrowing money (they use a figure that's about half of the real cost)

80% of a grid that's too small:
- optimistic paper that still relies on gas and nuclear for 20% of electricity
- doesn't figure in the grown in electricity demand from electrifying other
  energy usage

Climate Change without the Hot Air:
- Shows just how hard it is for the UK to run off renewables

---

# Nuclear

  | Fission | Fusion <!-- .element: class="fragment" data-fragment-index="5" -->
- | ------- | ------
Method | Splitting atoms <!-- .element: class="fragment" data-fragment-index="0" --> | Combining atoms <!-- .element: class="fragment" data-fragment-index="6" -->
Waste | Long-lived <!-- .element: class="fragment" data-fragment-index="1" --> | Short-lived <!-- .element: class="fragment" data-fragment-index="7" -->
Meltdown | Possible <!-- .element: class="fragment" data-fragment-index="2" --> | Impossible <!-- .element: class="fragment" data-fragment-index="8" -->
Proliferation | High <!-- .element: class="fragment" data-fragment-index="3" --> | Low <!-- .element: class="fragment" data-fragment-index="9" -->
Cost | High <!-- .element: class="fragment" data-fragment-index="4" --> | Cheaper <!-- .element: class="fragment" data-fragment-index="10" -->

note:

Fission:
- At the moment we are closing our nuclear reactors, not building new ones
- Carbon-free, but a host of problems
- Even the best new reactor designs typically only solve one or two of these
  problems.

Fusion:
- How it works, triple product
- MCF and ICF
- Abundant fuel - water and lithium
- So, what's not to like?

---

# Broken promises

- No net energy yet
- Expensive progress
- ITER: $20B, 2100

note:
- Before we talk about why this is exciting, let's recap why most people have
  dismissed it.
- More energy in than out
- Making this worse, people have been claiming that tokamaks were close to
  breakeven for decades. After each experiment failed to get to breakeven, the
  projected cost and time for the next one were larger.
- Tokamaks, generally considered the leading MCF approach, struggle with plasma
  instabilities, heat loss, size/cost, material challenges and a host of others.
- The flagship in this space is ITER, an international collaboration in France.
  It only gets a low density plasma so to make a useful amount of energy it
  needs to be large. And that makes it slow and expensive. It will cost tens of
  B$ and aims to put energy on the grid in 2100.

#todo graph of tokamak costs

---

# What's changed?

![https://i.imgur.com/BN0pz.png](https://i.imgur.com/BN0pz.png) <!-- .element height="50%" width="50%" -->

---

# What's changed?

- Exponential progress
- New tools/tech
- Alternative approaches
- Designed to be practical
- Private companies

note:
- tech: learned about plasma, faster computers, better simulations, better
  magnets, active control

---

# New approaches

- Magnetic: MIT ARC, CTFusion, Tokamak Energy
- Inertial: First Light Fusion
- Magneto inertial: Tri Alpha, Helion, General Fusion, Zap, MIFTI, HyperJet,
  CFS
- Electrostatics: EMC2, Fusion One
- Fission/fusion hybrid: Apollo Fusion

note:
MIF:
- confine and compress the fuel partly with magnetism and partly with inertia
- sounds crazy - you now have to do two hard things instead of one
- but by using both approaches you don't have to go to the extreme on either one
- and that lets you save a lot of money
- the magnetic field also helps to confine the plasma, and its heat, which makes
  it easier to reach breakeven
- 1% of the cost of magneto or inertial

---

# Results

![http://ieeexplore.ieee.org/document/4448409/](./pitches/assets/u-cost-curve.png)

note:
- graph shows what an MIF design might cost
- Zap's results support this

---

# What's wrong?

- Government money goes to ITER
- DOE: politics
- Google X: ROI timelines
- Breakthough Energy Ventures: still getting started
- Track record and disagreement scare investors

note:
- US and Russia in a race for fusion, doubled down on tokamaks

---

# Portfolio approach

- Start with 4-7 approaches
- Narrow the portfolio over time

note:
- This diversity of approaches is good, enables a portfolio
- A sensible investor would invest in a portfolio of these approaches
- NASA TRLs and a portfolio approach

---

# Portfolio approach

Milestone <!-- .element: class="fragment" data-fragment-index="1" --> | Cost/time <!-- .element: class="fragment" data-fragment-index="1" -->      | Comparison <!-- .element: class="fragment" data-fragment-index="2" -->
----------|-----------|-----------
Breakeven <!-- .element: class="fragment" data-fragment-index="1" --> | 10 years, $500M <!-- .element: class="fragment" data-fragment-index="1" -->| Renovating SF MOMA, $600M <!-- .element: class="fragment" data-fragment-index="2" -->
Reactor <!-- .element: class="fragment" data-fragment-index="1" -->   | 10 years, $2B <!-- .element: class="fragment" data-fragment-index="1" -->  | Bay bridge retrofit, $6B <!-- .element: class="fragment" data-fragment-index="2" -->

note:
- Costs and times are based on the time required for similar tasks based on
  research that ARPA-E did.

---

# Recap

- World market for energy is ~$1T, doubling by 2100
- We need clean, dispatchable energy
- Fusion is promising but underinvested
- $500M/10 years to get to breakeven
- IPO likely after that

Smart investment for the world and for profit

note:
- If we have fusion we can simplify our energy system, with less reliance on
  storage, demand management, etc.

---

# [Strong Atomics](https://strong-atomics.com)

- Strong Atomics invests in plausible, practical designs <!-- .element: class="fragment" -->
- ~$4.5M in three approaches  <!-- .element: class="fragment" -->
- Next raise: ~$40M for more seeds and A rounds <!-- .element: class="fragment" -->
- Science advisors: Scott Hsu, Will Regan <!-- .element: class="fragment" -->

note:
- This is the only fusion portfolio
- We are well positioned to lead in this space
- and to realize outsized returns from being early

repository: malcolmredheron/strong-atomics-slides

repo_name: malcolmredheron/strong-atomics-slides


text:
Refer to github commit log: https://github.com/voltrue2/gracelog/commit/3280a91e71ac292b3887c3a0b564b776278aa78a

#### Bug Fix: remote logging was broken

Refer to github commit log: https://github.com/voltrue2/gracelog/commit/549bf4113170f18fd68d6a0c1515472e758a16ac

## Deprecated

None

## Removed

None

***

## Version 0.5.2

## Added

None

## Changed

#### Fixed: Removed unnecessary console.log() from the code

## Deprecated

None

## Removed

None

***

## Version 0.5.1

## Added

#### oneFile<bool> option added to config object

If set `true`, file logging will be combined into one file instead of multipule files per logging level.

## Changed

None

## Deprecated

None

## Removed

None

## Version 0.4.1

## Added

None

## Changed

#### .table() now displays parsed object instead of [Object object]

#### .table() truncates strings longer than 50

## Deprecated

None

## Removed

None

***

## Version 0.4.0

## Added

None

## Changed

#### Log file rotation name is now accurate to the log data in each file

#### Bug fix in auto flushing

The bug was that if there was no buffered log to flush in one level, it was exiting the auto flush w/o flushing the other level.

## Deprecated

None

## Removed

None

***

## Version 0.3.0

## Added

#### Added useTimestamp to configuration object

By given `useTimestamp`(Boolean) in the configuration object, the logger users Unix timestamp instead of the server local time.

**NOTE**: File rotation still uses server local time for file names.

## Changed

None

## Deprecated

None

## Removed

None

***

## Version 0.2.3

## Added

None

## Changed

#### outputs null and undefined

## Deprecated

None

## Removed

None

***

## Version 0.2.2

## Added

None

## Changed

#### logging a null value in the same line

#### Now uses wrapper functions for events instead of creating extra events

## Deprecated

None

## Removed

None

***

## Version 0.2.1

## Added

None

## Changed

#### Bug fix in .table() for 0 as a value

## Deprecated

None

## Removed

None

***

## Version 0.2.0

## Added

#### new dependency wcwidth added

## Changed

#### The character length issue with multibyte characters for .table() fixed

## Deprecated

None

## Removed

None

***

## Version 0.1.21

## Added

None

## Changed

#### Bug fix in .table()

The length of the (index) is now correctly measured.

## Deprecated

None

## Removed

None

***

## Version 0.1.20

## Added

None

## Changed

#### Default config improved

If no logging method found (console, file, or remote), it now falls back to use console as the default logging method.

## Deprecated

None

## Removed

None

***

## Version 0.1.19

## Added

None

## Changed

#### Bug fix in auto-default configurations

The logging for auto-default configurations caused uncaught exception.

## Deprecated

None

## Removed

None

***

## Version 0.1.18

## Added

## Changed

#### Improved support for CJK characters for .table()

## Deprecated

None

## Removed

None

***

## Version 0.1.17

## Added

## Changed

#### Bug fix in .table

Objects/arrays with different number of properties in each element created an incorrect tables.

This has been fixed.

## Deprecated

None

## Removed

None

***

## Version 0.1.16

## Added

## Changed

#### Support for multi-byte characters for .table()

## Deprecated

None

## Removed

None

***

## Version 0.1.15

## Added

#### .table() added to output objects as tables

The logging level is `debug`

## Changed

None

## Deprecated

None

## Removed

None

***

## Version 0.1.14

## Added

None

## Changed

#### Update README for remote logging via UDP

#### Added new unit tests

***

## Version 0.1.13

## Added

None

## Changed

#### Fix to default log name in some cases

The issue with file path containing no `(` solved.

***

## Version 0.1.12

## Added

None

## Changed

#### Default log name can now detect its own file name and ignores it

***

## Version 0.1.11

## Added

None

## Changed

#### create function does not require log name any more.

`gracelog.create([*logName])` does not require a `string` `logName`.

If `logName` is not provided, `gracelog` will default the log name to the file name of the script calling `.create()`.

***

## Version 0.1.10

## Added

#### Removed auto-creation of lost write stream for file logging added in version 0.1.8

The added new feature in version 0.1.8 was unstable in Linux Fedora. Thus removed for now.

This is for file logging.

## Changed

None

## Deprecated

None

## Removed

None

***

## Version 0.1.8

## Added

#### Added auto-creation of lost write stream if the target log files are removed or renamed

This is file for logging.

repository: colopl/gracelog

branch_name: refs/heads/develop

gha_language: JavaScript

repo_name: colopl/gracelog


text:
---
title: 'Redis'
summary: 'Redis metrics and logging'
dashboard:
  - desc: 'Redis Dashboard'
    path: 'dashboard/en/redis'

monitor:
  - desc: 'Redis Monitor'
    path: 'monitor/en/redis'
---

<!-- markdownlint-disable MD025 -->
# Redis
<!-- markdownlint-enable -->

---

{{.AvailableArchs}}

---

Redis indicator collector, which collects the following data:

- Turn on AOF data persistence and collect relevant metrics
- RDB data persistence metrics
- Slowlog monitoring metrics
- bigkey scan monitoring
- Master-slave replication

## Configuration {#config}

Already tested version:

- [x] 7.0.11
- [x] 6.2.12
- [x] 5.0.14
- [x] 4.0.14

### Precondition {#reqirement}

- Redis version v5.0+

When collecting data under the master-slave architecture, please configure the host information of the slave node for data collection, and you can get the metric information related to the master-slave.

Create Monitor User

redis6.0+ goes to the rediss-cli command line, create the user and authorize

```sql
ACL SETUSER username >password
ACL SETUSER username on +@dangerous
ACL SETUSER username on +ping
```

<!-- markdownlint-disable MD046 -->
=== "Host Installation"

    Go to the `conf.d/{{.Catalog}}` directory under the DataKit installation directory, copy `{{.InputName}}.conf.sample` and name it `{{.InputName}}.conf`. Examples are as follows:

    ```toml
    {{ CodeBlock .InputSample 4 }}
    ```

    After configuration, [restart DataKit](datakit-service-how-to.md#manage-service).

=== "Kubernetes"

    The collector can now be turned on by [ConfigMap injection collector configuration](datakit-daemonset-deploy.md#configmap-setting).

---

???+ attention

    If it is Alibaba Cloud Redis and the corresponding username and PASSWORD are set, the `<PASSWORD>` should be set to `your-user:your-password`, such as `datakit:Pa55W0rd`.
<!-- markdownlint-enable -->

### Log Collection {#redis-logging}

To collect Redis logs, you need to open the log file `redis.config` output configuration in Redis:

```toml
[inputs.redis.log]
    # Log path needs to be filled with absolute path
    files = ["/var/log/redis/*.log"]
```

???+ attention

    When configuring log collection, you need to install the DataKit on the same host as the Redis service, or otherwise mount the log on the DataKit machine.

    In K8s, Redis logs can be exposed to stdout, and DataKit can automatically find its corresponding log.

## Metrics {#metric}

For all of the following data collections, a global tag named `host` is appended by default (the tag value is the host name of the DataKit), or other tags can be specified in the configuration by `[inputs.redis.tags]`:

``` toml
 [inputs.redis.tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"
  # ...
```

{{ range $i, $m := .Measurements }}

{{if eq $m.Type "metric"}}

#### `{{$m.Name}}`

{{$m.Desc}}

- tag

{{$m.TagsMarkdownTable}}

- feld list

{{$m.FieldsMarkdownTable}} {{end}}

{{ end }}

## Logging {#logging}

[:octicons-tag-24: Version-1.4.6](changelog.md#cl-1.4.6)

{{ range $i, $m := .Measurements }}

{{if eq $m.Type "logging"}}

#### `{{$m.Name}}`

{{$m.Desc}}

- tag

{{$m.TagsMarkdownTable}}

- field list

{{$m.FieldsMarkdownTable}} {{end}}

{{ end }}

### Logging Pipeline {#pipeline}

The original log is:

```
122:M 14 May 2019 19:11:40.164 * Background saving terminated with success
```

The list of cut fields is as follows:

| Field Name  | Field Value                                 | Description                                  |
| ----------- | ------------------------------------------- | -------------------------------------------- |
| `pid`       | `122`                                       | process id                                   |
| `role`      | `M`                                         | role                                         |
| `serverity` | `*`                                         | service                                      |
| `statu`     | `notice`                                    | log level                                    |
| `msg`       | `Background saving terminated with success` | log content                                  |
| `time`      | `1557861100164000000`                       | Nanosecond timestamp (as line protocol time) |

repository: GuanceCloud/datakit

gha_language: Go

repo_name: GuanceCloud/datakit


text:
# Mongoosastic
A [mongoose](http://mongoosejs.com/) plugin that indexes models into [elasticsearch](http://www.elasticsearch.org/). I kept
running into cases where I needed full text search capabilities in my
mongodb based models only to discover mongodb has none. In addition to
full text search, I also needed the ability to filter ranges of data
points in the searches and even highlight matches. For these reasons,
elastic search was a perfect fit and hence this project.

## Installation

```bash
npm install mongoosastic

```

Or add it to your package.json

## Usage

To make a model indexed into elastic search simply add the plugin.

```javascript
var mongoose     = require('mongoose')
  , mongoosastic = require('mongoosastic')
  , Schema       = mongoose.Schema

var User = new Schema({
    name: String
  , email: String
  , city: String
})

User.plugin(mongoosastic)
```

This will by default simply use the pluralization of the model name as the index
while using the model name itself as the type. So if you create a new
User object and save it, you can see it by navigating to
http://localhost:9200/users/user/_search (this assumes elasticsearch is
running locally on port 9200).

The default behavior is all fields get indexed into elasticsearch. This can be a little wasteful especially considering that
the document is now just being duplicated between mongodb and
elasticsearch so you should consider opting to index only certain fields by specifying ''es_indexed'' on the
fields you want to store:

```javascript
var User = new Schema({
    name: {type:String, es_indexed:true}
  , email: String
  , city: String
})

User.plugin(mongoosastic)
```

In this case only the name field
will be indexed for searching.

Finally, adding the plugin will add a new method to the model called
search which can be used to make simple to complex searches.

```javascript

User.search({query:"john"}, function(err, results) {
  // results here
});

```
### Per Field Options
Schemas can be configured to have special options per field. These match
with the existing [field mapping configurations](http://www.elasticsearch.org/guide/reference/mapping/core-types.html) defined by elasticsearch with the only difference being they are all prefixed by "es_".

So for example. If you wanted to index a book model and have the boost
for title set to 2.0 (giving it greater priority when searching) you'd
define it as follows:

```javascript
var BookSchema = new Schema({
    title: {type:String, es_boost:2.0}
  , author: {type:String, es_null_value:"Unknown Author"}
  , publicationDate: {type:Date, es_type:'date'}
});

```
This example uses a few other mapping fields... such as null_value and
type (which overrides whatever value the schema type is, useful if you
want stronger typing such as float).

### Advanced Queries
The full query DSL of elasticsearch is exposed through the search
method. For example, if you wanted to find all people between ages 21
and 30:

```javascript
Person.search({
  query:{
    range: {
      age:{
        from:21
      , to: 30
      }
    }
  }
}, function(err, people){
   // all the people who fit the age group are here!
});

```

See the elasticsearch [Query DSL](http://www.elasticsearch.org/guide/reference/query-dsl/) docs for more information.

### Hydration
By default objects returned from performing a search will be the objects
as is in elastic search. This is useful in cases where only what was
indexed needs to be displayed (think a list of results) while the actual
mongoose object contains the full data when viewing one of the results.

However, if you want the results to be actual mongoose objects you can
provide {hydrate:true} as the second argument to a search call.

```javascript

User.search({query:"john"}, {hydrate:true}, function(err, results) {
  // results here
});

```

Note this will be a degree slower as it will perform an elasticsearch
query and then do a query against mongodb for all the ids returned from
the search result.

You can also default this to always be the case by providing it as a
plugin option:

```javascript
var User = new Schema({
    name: {type:String, es_indexed:true}
  , email: String
  , city: String
})

User.plugin(mongoosastic, {hydrate:true})
```

### Model.plugin(mongoosastic, options)

Options are:

* `index` - the index in elastic search to use. Defaults to the
  pluralization of the model name.
* `type`  - the type this model represents in elastic search. Defaults
  to the model name.
* `host` - the host elastic search is running on
* `hydrate` - whether or not to lookup results in mongodb before
  returning results from a search. Defaults to false.

#### Specifying Different Index and Type
Perhaps you have an existing index and you want to specify the index and
type used to index your document? No problem!!

```javascript
var SupervisorSchema = new Schema({
  name: String
, department: String
});

SupervisorSchema.plugin(mongoosastic, {index: 'employees', type:'manager'});

var Supervisor = mongoose.model('supervisor', SupervisorSchema);

```

## License
Copyright (c) 2012 James R. Carr<EMAIL_ADDRESS>
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:
# gce-launcher

This is a Chrome extension to make it easy to launch GCE servers as development
boxes and automatically shut them down when not using them.

This repo contains the Chrome extension code as well as a Go program that checks
for the heartbeats sent by the extension.

![](https://i.imgur.com/jvR7Wep.png)

## Install the daemon and enable the systemd service
```sh
go build -v . && sudo cp ./gce-launcher /usr/local/bin && sudo cp ./gce-launcher.service /etc/systemd/system && sudo systemctl daemon-reload && sudo systemctl enable gce-launcher && sudo systemctl restart gce-launcher
```


text:
# **Lane Lines P1**
[![Udacity - Self-Driving Car NanoDegree](https://s3.amazonaws.com/udacity-sdc/github/shield-carnd.svg)](http://www.udacity.com/drive)

P1.ipynb is a python code that could identify the lane in the source images or the source videos.

<img src="test_images_output/solidYellowCurve.jpg_out.jpg" width="480" alt="Combined Image" />

## Installation

**Step 1:** Set up the [CarND Term1 Starter Kit](https://github.com/udacity/CarND-Term1-Starter-Kit/blob/master/README.md).

**Step 2:** Open the code in a Jupyter Notebook

`> jupyter notebook`

## Known Bugs
* The predicted lane line might not the be center of the lane line in the image. In the video, the lane line would show up 45 deg offset from the image in some frame.
* The image color shown in the notebook & the output file might not match. Known bugs as for OpenCV default color format is BGR.


text:
> [Go to French version](/fr/Règlements/Textes%20réglementaires/2017/5.md)

# Transfer of Duties Order

**SI/2017-5**

Enabling authorities:
- [PUBLIC SERVICE REARRANGEMENT AND TRANSFER OF DUTIES ACT](/en/Acts/Revised%20Statutes%20of%20Canada/P/P-34.md)

Date registered: 22 February 2017

----------

His Excellency the Governor General in Council, on the recommendation of the Prime Minister, pursuant to paragraph 2(a)[a] of the [Public Service Rearrangement and Transfer of Duties Act](/en/Acts/Revised%20Statutes%20of%20Canada/P/P-34.md)[b], transfers from the Minister of Industry to the Minister of State styled the Minister of Small Business and Tourism the powers, duties and functions of the Minister of Industry under the [Canadian Tourism Commission Act](/en/Acts/Statutes%20of%20Canada/2000/c.%2028.md)[c].

a: S.C. 2003, c. 22, s. 207

b: R.S., c. P-34

c: S.C. 2000, c. 28

repository: TravisMadill/CanadianLaws

repo_name: TravisMadill/CanadianLaws


text:
##<iron-url-history>

`iron-url-history` is a Polymer element that allow storing navigation history while clicking in single page application.
This element share history between all the instances of the `iron-url-history` tag.
Can be imported in a custom element allowing to store navigation redirection ( like clicking and redirecting to the href on a `a` tag ).
`iron-url-history` store the navigation url, the date of redirection and, if present, a "user defined" additional paramenter. That will allow to
share additional information aboute navigation timeline.

The following methods are available for call:

| Method | Inputs | Outputs | Description |
| --- | --- | --- | --- |
| `goto` | url (string) | null | Simulate href redirection and store the url in navigation history |
| `pushLocation` | url (string), adds (object) | null | Push the url into navigation history and store additional user's defined information about that |
| `getCurrent` | null | { url (string), date (date), adds (object) } | Get the current view information |
| `getBack` | null | { url (string), date (date), adds (object) } | Get the previous view information |
| `getForward` | null | { url (string), date (date), adds (object) } | Get the previous view information |
| `getHistory` | null | [ { url (string), date (date), adds (object) } ] | Get the entire view history information |

To install the component with the Bower, just run:

`bower install --save iron-url-history`

Example:

```html
<link rel="import" href="./iron-url-history.html">

<iron-url-history id="history" history={{history}}></iron-url-history>
```

An example on how to include the `iron-url-history` tag inside a custom link element is provided inside the `tag-a-history` tag ( also used inside the demo page ).

For a working sample about the `iron-url-history` tag check the [DEMO PAGE](http://alessiocarrafa.it/polymer-elements/iron-url-history/demo.html)

repository: alessiocarrafa/iron-url-history

repo_name: alessiocarrafa/iron-url-history


text:
# LinkedIn 2nd Connections Crawler  ![](https://img.shields.io/badge/License-MIT-green)
  ## Table of Content
  * [Description](##Description)
  * [Requirements](##Requirements)
  * [Installation Instructions](##Installation-Instructions)
  * [Usage Instructions](##Usage-Information)
  * [Contribution Guidelines](##Contribution-Guidelines)
  * [Bugs and Further Development](##Bugs-and-Further-Development)
  * [Questions](##Questions)

  ## Description
  I've decided to discontinue this project, as I've learned that this type of code is in violation of the [LinkedIn User Agreement](https://www.linkedin.com/help/linkedin/answer/56347/prohibited-software-and-extensions?lang=en).  However, I thought the code may still be of use as an example to the community.  Use this code at your own risk.

  This is a crawler for getting information of your secondary connections on LinkedIn.  When you have defined te company, and entered in your username and password in the app.js, you will get an Object consisting of all of your secondary connections in that company and your best connection.

  ## Requirements
  You will need both a LinkedIn account and a Sales Navigator account for this program to work.

  ## Installation Instructions
  Do a git pull to a folder to start using.  Note that you will need to do a npm install as well.  Note also that you need to enter into the app.js the company that you are searching for, and your username and password before starting the program.

  ## Usage Information
  Type node app.js to start the program.  You will need to enter in your text code to log into your account.  Then the automation will start.

  ## Contribution Guidelines
  This project is subjected to [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](code_of_conduct.md).

  ## License
  This project and the application(s) hereinto is(are) covered under the MIT License.

  ## Bugs and Further Development
  * The company name must be entered with replacing spaces by "%2520" and "&" by "%2526".
  *  Another further development could be for a user interface.

  ## Questions
  For any questions about this project, please first visit my Github repo [here](https://github.com/alzcheng).
  If the answers are not found in my repo, you can email me directly at<EMAIL_ADDRESS>


text:
---
title: CIDR Block
date: "2021-06-05T00:00:00.121Z"
template: "post"
draft: false
slug: "networking-cidr"
category: "AWS Networking"
tags:
  - "Networking"
  - "Primer"
  - "AWS"
description: "Ever wondered what is a CIDR block while creating VPC and how to allocate IP addresses to the subnets."
socialImage: "/media/networking-series-cidr.png"
---
### Introduction

Before working in serverless technologies, most of the applications I worked on were hosted on-prem. I used to interact with the infrastructure team and the questions they ask were sometimes not understandable to the application developers. The talk about firewall, ip addresses, ssl, ftp, connect direct connections are too much to comprehend initially. With serverless applications development though the application developer need not have to know about these terminologies, its good to understand what's behind the scenes.

![Networking Series](/media/networking-series-cidr.png)

AWS opens the doors for the application developers to know about the networking configuration used by their application. Usually in an on-prem applications the networking services are managed by a different team and the developers are not aware of the configuration. The interaction typically happens where the network team share the snippets of the logs whenever an error occurred connecting to our application. But with more applications being developed on cloud services, developers can atleast access the lower environment configurations (dev or staging) which is usually mimicked to production. Let us start the series by getting to know what is a CIDR Block

### CIDR Block (Classless Inter-Domain Routing)

![CIDR](/media/vpc-creation-cidr.png)

While creating VPC in AWS, the second step (Refer image above) is to provide the IP CIDR block i.e the range of IP addresses to be allocated to this VPC. It is of the format <IP_ADDRESS>/16 (IP address followed by / and a number). Most of us knew the IP address format but what does this number signify in CIDR Block.

- CIDR is an industry standard.
- The number is the number of bits in an IP address that must match to be considered as part of the selected CIDR block.
- Each IP Segment i.e the number between the dots is of eight bits that makes the entire segment consisting of 32 bits.
- Let us take the ip address `<IP_ADDRESS>` and represent them in binary as `0000 1010. 0000 0000. 0000 0000. 0000 0000`.
- Let us take the CIDR block notation as `<IP_ADDRESS>/16`.  The number here mentions that any ip address that has the first 16 digits matched is part of this CIDR IP block. Since the first 16 bits has to remain unchanged, it leaves room for the rest of the 16 digits to take any value. Hence 216 `65536` ip addresses are available in this range.

### Additional Resources
https://www.colocationamerica.com/ip-calculator

url: https://raw.githubusercontent.com/pradheepap/pradheepa/d513d39999abccd88a94360dc524106fa3cc1c32/content/posts/2021-06-05---Networking Series - CIDR Block copy.md

repository: pradheepap/pradheepa

repo_name: pradheepap/pradheepa


text:
ocaml-pbs
=========

Wrapper around PBS commands, and maybe some day protocol implementation

Modules (available through the pack module `Pbs` or directly with their `Pbs_` name):

- `Script` (a.k.a `Pbs_script`): functions to generate PBS scripts
- `Qstat` (a.k.a. `Pbs_qstat`) parse and manipulate the output of the `qstat` command

license: ISC

repository: smondet/pbs

gha_language: OCaml

repo_name: smondet/pbs


text:
## Visual Studio Code (Current Fav)

> Installation: https://code.visualstudio.com/docs/setup/linux#_installation <br>
> http://vscodecandothat.com/

> Recommended Packages

* `Atom Keymap`
* `Auto Import`
* `Code Runner`
* `Debugger for Chrome`
* `Guides`
* `npm`
* `Open in browser`
* `Path intellisense`
* `Prettier` -> Also set `editor.formatOnSave: true`
* `Settings sync`
* `vscode-icons`

> Custom file Syntax higlighting

```
"files.associations": {
        "*.abcd": "javascript"
    }
```

## Atom editor

> Install Atom

* sudo add-apt-repository ppa:webupd8team/atom
* sudo apt-get update
* sudo apt-get install atom

> Install packages

**Note: For any description, open same named package on `atom.io`**

* `language-babel`
* `emmet`
* `atom-beautify`
* `docblockr`
* `highlight-selected`
* `minimap`
* `minimap-highlight-selected`
* `linter` (Disabled for now)
  * `linter-eslint` (Disabled for now)
  * `linter-csslint` (Disabled for now)
* `git-blame`
* `seti-ui`
* `monokai-seti`
* `open-recent`
* `rest-client`
* `color-picker`
* `atom-comb-css`
* `merge-conflicts`
* `file-icons`
* `fonts`
* `autocomplete-paths`
* `terminal-plus`
* `atom-ide-ui`
* `ide-typescript`

> Syntax highlighting custom

```
"*":
  core:
    customFileTypes:
      "source.js.jsx": [
        "phnx"
        "phnxapp"
        "phnxdef"
      ]
```

## Sublime Text

> Following are the plugins that makes the life easier for development

#### Package Control [Link](https://sublime.wbond.net/installation)

* Easily manage adding and removing packages from Sublime

#### Babel [Link](https://github.com/babel/babel-sublime)

* Syntax highlighting for es6 codes
* Adds on top of the default JS highlighting

#### SideBar Enchancements [Link](https://github.com/titoBouzout/SideBarEnhancements/tree/st3)

* Adds lots of extra functionality to the default sidebar like - open in terminal, browser, Add folder to project

#### Emmet [Link](http://emmet.io/)

* It allows you to write html n css faster with short abbrevations
* Tab/Ctrl + E to expand abbrev

#### Git [Link](https://github.com/kemayo/sublime-text-git)

* Adds a bunch of Git commands to the command palette (Ctrl + Shift + P)

#### GitGutter [Link](https://github.com/jisaacks/GitGutter)

* Shows git diffs on the left side behind the line numbers

#### All Autocomplete [Link](https://github.com/alienhard/SublimeAllAutocomplete)

* This plugin adds auto completing ability from across all open files

#### DocBlockr [Link](https://github.com/spadgos/sublime-jsdocs)

* Helps you easily write comments by auto collecting all the params
* Trigger is /\*\* and enter

#### Javascript Beautify [Link]()

* Javascript auto format using Ctrl + Alt + F

repository: Aftabnack/awesome-links

repo_name: Aftabnack/awesome-links