text:
---
layout: post
title: Garmin Footpod and running in Maastricht
date: 2014-03-15 15:09:11.000000000 +01:00
comments: true
categories:
- Running
- Training
tags: []
status: publish
type: post
published: true
meta:
  _edit_last: '1'
  _thumbnail_id: '864'
  _layout: inherit
  _wpas_done_all: '1'
  _wpas_mess: "[blog] Garmin Footpod and running in Maastricht http://wp.me/p3PyW1-dV"
  _wpas_skip_5746966: '1'
author:
  login: arjen
  email<EMAIL_ADDRESS>  display_name: Arjen Wiersma
  first_name: Arjen
  last_name: Wiersma
---

On march 7th it was my birthday. As customary with birthdays I received several presents. The first was a Garmin Footpod and the second a trip to the city of Maastricht. Lets take a look at the Garmin Footpod in this post.

Garmin Footpod

A footpod is a sensor that you attach to your shoelaces. Over at DC Rainmaker there is a long article detailing all you ever wanted to know about footpods. Basically it looks as follows:

You attach it to your shoe and on your Forerunner 620 you go into your system settings and add a sensor (footpod). From then on the watch will take the data from the sensor into account. But why would you need it? The forerunner does an awesome job of taking care of so many statistics, so why an additional device? Well, basically getting the current pace from GPS is kinda slow in the watch. Perhaps it is a firmware thing, but the below 2 videos from Landorrun show the effect of the footpod.

As you see, with GPS it takes a while to get back to the real tempo. This is very annoying when performing interval runs, as you never have the right tempo on the watch when changing between paces. Now take a look when a footpod is added to the mix:

Putting this to the test gave some interesting results. I have workouts with intervals programmed into my watch. Each interval switches to a screen with the pace and the time needed. Interestingly it is not the lap pace that seems to be displayed here, so it is not correct. I found I had to switch to another screen displaying the current lap pace to get the right result. I have to perform some more tests, but if my results stick I will file a bug report.

Yesterday Garmin released firmware 2.6, so I will see if it is fixed in it.

Maastricht

The second gift was a weekend in the city of maastricht. We went on a nice 70 minute slow (140 bpm) run.

We ran past old castles.

Along the river 'Maas' on which row boats were training.

Over 2 of the 4 bridges connecting both parts of the city.

And back to the old inner city which still has the old city walls.

All in all a beautiful city with lots of possibilities to go for a run!

Training

It has been nearly 2 weeks since my race report on Rondje Goutum. Since then I did the following training runs:

Tuesday 6am, 40 minutes in Zone 2

A slow run in heart rate zone 2.

Thursday 6:30 pm, 9 intervals at 4:45 min/km

An intense set of intervals at 4:45 min/km. I find the first few to be ok, but after the 4th it gets really hard.

Saturday, 70 minutes at 140 bpm

Running around Maastricht with an heart rate of 140 bpm. Together with my wife we spent 70 minutes exploring the banks of the Maas.

Tuesday 6am, 5 km progressive

The first training of the sort. Each kilometer has to be done faster then the last one. I set out at a pace of 6 min/km and finished at 5:00 min/km, each time increasing the pace with 10 seconds or so. Turns out is quite hard to pace yourselves.

Friday 6pm, 10 intervals at 4:45 min/km

The intervals are becoming easier. I find that I can now easily do 6 intervals before starting to feel it in my legs.

repository: credmp/so-simple-theme

repo_name: credmp/so-simple-theme


text:
#hembu

hembu is a block community management platform built with meteor

##Running hembu

######install packages

meteor update

######create settings file
cp server/settings.json.sample server/settings.json

######Run
ROOT_URL=[localhost:3000 or where ever you are running hembu] meteor --settings server/settings.json

license: MIT

repository: erkkaha/hembu

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: erkkaha/hembu


text:
---
id: 34
title: Async keyword alternative
date: 2012-11-03T09:09:00+00:00
author: filip
layout: post
guid: http://filipfracz.net.holly.arvixe.com/?p=34
permalink: /2012/11/async-keyword-alternative/
tumblr_filipfracz_permalink:
  - http://filipfracz.tumblr.com/post/63249700887/async-keyword-alternative
  - http://filipfracz.tumblr.com/post/63249700887/async-keyword-alternative
tumblr_filipfracz_id:
  - "63249700887"
  - "63249700887"
categories:
  - Programming
  - Uncategorized
---
Unfortunately, both MonoTouch and Mono for Android still don't support the async keyword. Raw TPL is rather inconvenient to use. You have to remember to catch exceptions, return faulted tasks, etc. ContinueWith can also be inefficient due to thread switching.

Today while browsing the interwebs I came across Brad Wilson's [blog post](http://bradwilson.typepad.com/blog/2012/04/tpl-and-servers-pt4.html "TPL") which led me to these [two](http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/6b5687093715#src%2fCommon%2fTaskHelpers.cs) [files](http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/6b5687093715#src%2fCommon%2fTaskHelpers.cs). [TaskHelpers](http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/6b5687093715#src%2fCommon%2fTaskHelpers.cs) are (no pun intended) very very helpful! The extension methods emulate the await goodness pretty well.

I modified them a little bit. [Here is a gist](https://gist.github.com/4681026).

repository: itsff/website

gha_language: CSS

repo_name: itsff/website


text:
---
layout: page
title: Cold-atom experimental platform
description: Schleier-Smith lab, Stanford University, 2015-2021
img: assets/img/thumbnails/experiment_project_small.jpg
importance: 1
category: research
---

For my PhD in the Stanford University Physics Department, I worked on a design and construction of a flexible experimental platform for quantum simulation and quantum metrology experiments. The goal was to create an experiment with the ability to support several research paradigms (high-precision measurement and investigation of quantum many-body systems).

During the design stage of the project, I became passionate about using my physics knowledge to gain experience in several engineering disciplines including experience in vacuum systems, machining, and optics design to successfully develop the experimental system. After completing the setup, I worked on the troubleshooting, testing and optimization of the system that resulted in our first experimental results. In the later stages of the experiment development, my focus was on continuing maintenance, while also working on a Python-based data analysis suite to analyze image-based data obtained from the experiment.

gha_language: HTML


text:
# Contributions
Thanks for thinking on contributions! Every little piece of help always goes a long way, read below of how to setup and submit a pull request!

## Setting Up
First, you will need to have ESLint and TypeScript installed on your system to continue the process. You can install them using ``npm i -g eslint typescript``.

- Fork the repository [here](https://github.com/auguwu/docs/fork)
- Clone the repository to your local machine (``git clone https://github.com/USERNAME/docs``)
- Change the directory to the cloned repo (``cd docs``) and create a seperate branch (``git checkout -b <branch>``)
- Install any local dependencies from NPM (``npm i``)
- Update the codebase or documentation
  - Run ``npm run lint`` to check for any code errors/warnings, this follows the ESLint configuration [here](https://github.com/auguwu/eslint-config).
  - Run ``npm run build`` to compile TypeScript and check for any compliation errors
- Then, submit your [pull request](https://github.com/auguwu/disney-rpc/compare) and wait a few minutes or a few hours for the maintainers to look at your Pull Request and ask for any changes or it'll be merged.

repository: AugustArchive/disney-rpc

repo_name: AugustArchive/disney-rpc


text:
---
title: "S M Stirling Author"
created_at: Thu Sep  8 05:40:22 MDT 2016
kind: article
tags:
  - author
  - sm_stirling_author
  - books
---

wikipedia.org article
S. M. Stirling bibliography

wikipedia.org article
S. M. Stirling biography

### orderofbooks.com article Order of S.M. Stirling Books

S.M. Stirling is a Canadian-American author of science fiction, fantasy
and alternate history novels. He writes The Fifth Millennium, Draka,
Raj Whitehall, The Change and several other series. He has also written
for series he didn’t create, such as Terminator 2, The Ship Who Sang,
Riftwar and others. His books focus on military-based cultures, cultural
values, technology and strong female characters.

S.M. Stirling became a published author in 1985 with the novel
Snowbrother, beginning his Fifth Millennium series. Below is a list of
S.M. Stirling’s books in order of when they were originally published:

#### Fifth Millennium Books

Snowbrother	(1985)

The Sharpest Edge

The Cage	(1989)

Shadow's Son	(1991)

Saber and Shadow	(1992)

#### Draka Books

Marching Through Georgia	(1988)

Under the Yoke	(1989)

The Stone Dogs	(1990)

Drakon	(1996)

Drakas!	(2000)


text:
---
id: d01-intro
title: Introduction
---

Grieved by the lives lost as a result of this pandemic and inspired by the need for disrupting
systems of racial and economic inequality within marginalized communities, we are designing a
crowdsourcing platform for the general public to contribute ideas, share personal stories,
memorialize loved ones, and examine statistics related to our collective COVID-19 experience.

## How?

The COVID-19 Impact Dashboard includes an open source database featuring at-a-glance data that makes
it easy to trace the progression of the pandemic. In addition, we will gather human-centered soft
data contributions in the form of personalized memorials and community voices to influence
political action. By developing a local rendering of the impact of the pandemic over time, we will
be able to motivate and sustain action. We believe we can better assess impact and make change by
seeking input from a wide variety of collaborators, including other coders, designers, journalists,
activists and data artists.

## Why?

The purpose of this project is to provide a “living” platform of crowdsourced information that will enable us to collectively:

- Mourn and memorialize the thousands dying everyday from the COVID-19 pandemic
- Assess the impact on the families and communities of the deceased
- Build enduring institutions to mitigate the suffering caused by the pandemic and address systemic inequalities exposed by the pandemic

## Contact Us

[Contact us to provide your feedback and to stay informed of updates](https://jhtid.typeform.com/to/RxahXQJX)

[COVID-19 Impact Dashboard](https://epvisual.com/COVID-19-Impact/Dashboard/)

[COVID-19 Impact Project on github](https://github.com/EP-Visual-Design/COVID-19-Impact-Project.git)

## Sponsored by:

[EP Visual Design, Inc.](http://epvisual.com)

## Additional funding:

[EPV Foundation, Inc.]()

## Special Thanks

A special thanks to the team at EP Visual Design.

- Phil Sinatra
- Jervis Thompson
- Bridget Musolino
- Kaelyn Douville
- Eric Horst

<!--
## Dev notes
```
# Double failure!
[2020-08-18-neg-failure](/img/2020-08-18-neg-failure.png)
```
Not obvious how to link to image in blog

# Disable credits page in docus/sidebars.js
- // 'd07-credits',

-->

gha_license_id: MIT


text:
# gochimp
A cors solution for interacting with mailchimp from a frontend.

This is an example of how to communicate with the mailchimp api using a cors middleware.  You can put your mailchimp api key and list id in the config.toml, as well as the origin you wish to allow communications from.

You can build this using go build -o chimp cmd/gochimp/main.go, then run the resulting binary.

I usually run something like this at, support.my-domain.tld.  It can be run on the same server using nginx as a reverse proxy, which will allow you to run your front end website on the same server.

You can run this long term using systemd.

To actually get the count from the api you'll need to implement MemberCount in internal/stats/repo, associated direction in the comments of that method.

repository: kendellfab/gochimp

repo_name: kendellfab/gochimp


text:
# MarioKart
Mario Kart iOS game feat. panning, scaling, rotating and then sending Mario zooming off the screen! 🏎

### User Stories

- [x] User can move karts around the screen using a pan gesture.
- [x] User can adjust the size of a cart using a pinch gesture.
- [x] User can rotate a cart using a rotation gesture.
- [x] User can double tap a kart to make it race (animate) off the screen.
- [x] User can long press the background to reset the karts.

### App Walkthough GIF

## License

    Copyright [2019] [Jason Stephen]

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

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

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.# tipCalculator


text:
# cluster-static-server
![Version](https://img.shields.io/github/package-json/v/aalfiann/cluster-static-server)
[![Build Status](https://travis-ci.com/aalfiann/cluster-static-server.svg?branch=master)](https://travis-ci.com/aalfiann/cluster-static-server)
[![Coverage Status](https://coveralls.io/repos/github/aalfiann/cluster-static-server/badge.svg?branch=master)](https://coveralls.io/github/aalfiann/cluster-static-server?branch=master)
[![Known Vulnerabilities](https://snyk.io//test/github/aalfiann/cluster-static-server/badge.svg?targetFile=package.json)](https://snyk.io//test/github/aalfiann/cluster-static-server?targetFile=package.json)
[![dependencies Status](https://david-dm.org/aalfiann/cluster-static-server/status.svg)](https://david-dm.org/aalfiann/cluster-static-server)
![License](https://img.shields.io/github/license/aalfiann/cluster-static-server)
Cluster Static Server based on Fastify NodeJS.

## Description
`Static Server` is a static web server, or stack, consists of a computer (hardware) with an HTTP server (software). We call it `"static"` because the server sends its hosted files `"as-is"` to your browser.

## Why
The main problem of a static server is when you have limit with your server storage. Because this problem, many people going to buy the expensive cloud storage for his startup business. But I don't want to, so I create this cluster-static-server.

- **I want an Easy Management**
  This cluster static server is included with a Rest API to manage your static files without having to touch your server. Also with this API, you are able to create your custom application.

- **I want to Scale Out**
  Add more server machine for your storage. So you have unlimited static server storage.

- **I want to start with small investment**
  This cluster static server was created with Fastify NodeJS Framework which is the fastest and very low overhead of any NodeJS framework out there. You can start with single or multiple shared hosting to implement this cluster static server.

## Features
- Cluster Storage
- Cluster CPU
- Upload File
- Remote Upload File
- Get File
- Delete File
- Cleanup Temporary File
- Status All Nodes

### Get Started
1. Clone or Download this repo.
2. Extract it.
3. Go to the extracted directory.
4. Run `$ npm install`.
5. Done

### How to run the server
- To start master server `$ npm run master` or `$ node server-master.js`.
- To start node server `$ npm run node` or `$ node server-node.js`.

**Note :**
- You are able to start master and node server in same machine server with different port. But, actualy Master and Node server should be on different machine server so you will get the best performance.

### Example API
We include the `postman.json` file in this source for an example how to use API. Just import it to your postman application and then you can learn from it.

## Documentation
The documentation is on our [Wiki](https://github.com/aalfiann/cluster-static-server/wiki).

repository: aalfiann/cluster-static-server

repo_name: aalfiann/cluster-static-server


text:
---
title: Decoding nested values with property wrappers
date: 2020-02-13
description: "Property wrappers is one of the recent Swift proposals that have been welcomed probably the most by the community. Let's see how property wrappers can be used to solve one decoding edge case as an example - decoding deeply nested values."
tags: Swift
---

Property wrappers is one of the recent Swift proposals that have been welcomed probably the most by the community. To be fair though they don't bring anything relly revolutionary to the way we write code. For instance in the context of decoding we could use wrapper types from day one. The main difference that property wrappers make (let's forget about their projected value feature) in this context and which makes using them much more attractive is ability to refer to a wrapped value as it was not wrapped. But that makes all the difference. So let's see how property wrappers can be used to solve one decoding edge case as an example - decoding deeply nested values.

## The problem

It's common that when decoding some type we want to get access to some value deep down the chain of nested objects. The most trivial approach to do that would be to declare all the intermediate types and properties so that compiler can generate all the code for us. But we, developers, are lazy and don't like to write boilerplate code that we won't use otherwise. Also this approach means that we would need to access these nested values through a long chain of properties, or we would need to write even more boilerplate to incapsulate that.

Wouldn't be nice if we could decode nested values without all these intermediate types and properties baggage? It turns out we can do that and it is pretty easy to do without even fighting the standard library (almost).

## Decoding a single nested value

Let's say we have a JSON of the following format:

```
{
    "id": "1",
    "user": {
        "details": {
            "address": "Apple St."
        }
    }
}
```

And we want to decode it into the following struct:

```swift
struct Contact: Decodable {
    let id: String
    let address: String
}
```

Out of the box compiler won't generate the code that would be able to decode such JSON in this struct as it does not know about intermediate `"user"` and `"details"` keys. Without declaring all the intermediate data structures we would need to implement decoding manually like this:

```swift
enum CodingKeys: String, CodingKey {
    case id
    case user
    case details
    case address
}

init(from decoder: Decoder) throws {
    let values = try decoder.container(keyedBy: CodingKeys.self)

    self.id = try values.decode(String.self, forKey: .id)
    self.address = try values
        .nestedContainer(keyedBy: CodingKeys.self, forKey: .user)
        .nestedContainer(keyedBy: CodingKeys.self, forKey: .details)
        .decode(String.self, forKey: .address)
}
```

As you see we not only have to implement all the decoding code but also define all the coding keys ourselves. It's not a hard thing to do but can be a lot of typing. Ideally we don't want to implement decoding and to define all the coding keys manually.

To start let's highlight what's missing for the compiler to generate this code for us. First thing that is missing is intermediate coding keys. Compiler generates coding keys based on the stored properties of our type, so in our case it will generate `id` and `address` keys, but `details` and `user` keys will be missing.

Next thing that is missing is a link between the `address` property and its key path in the JSON structure. Compiler does not know that to extract `address` value it needs to go through `user` and `details` objects first. If we will be able to provide this link to the compiler somehow then we will be able to remove our custom decoding constructor and just rely on compiler generated code.

So what we need to do now is to somehow abstract this code:

```swift
self.address = try values
    .nestedContainer(keyedBy: CodingKeys.self, forKey: .user)
    .nestedContainer(keyedBy: CodingKeys.self, forKey: .details)
    .decode(String.self, forKey: .address)
```

To do that we need to know the order of the keys and their values. In this case the order is `.user`, `.details`, `.address`. Then we need to know the type of the property we are decoding, which is a `String`.

When compiler generates decoding code for us it generates calls to the methods of `KeyedDecodingContainer` which all look like `func decode<T>(_: T.Type, forKey key: Key) throws -> T`. To decode `address` property compiler will generate a call to `decode(String.self, forKey: .address)`. So there seem to be no direct way for us to inject the missing keys. And here comes the wrapper.

To hold the intermediate keys that compiler needs to use to generate code we can define a special wrapper type, let's call it `NestedDecodable`:

```swift
struct NestedDecodable<T: Decodable>: Decodable {
    let wrappedValue: T
    let keys: [CodingKey]
}
```

Now we can declare our address property as wrapped in this type:

```swift
let address = NestedDecodable<String>(
    keys: [
        CodingKeys.user,
        CodingKeys.details,
        CodingKeys.address
    ]
)
```

This though won't work as this property will be initialised even before invoking a decoder and we don't have wrapped value to pass to it. So instead we can only declare its type as wrapped into `NestedDecodable`:

```swift
let address = NestedDecodable<String>
```

But now we don't have a way to specify the keys... We will make it right later but for now let's leave it as it is and move on to the decoding container.

With the code we have so far compiler will generate the code that will try to decode address with `decode(NestedDecodable<String>.self, forKey: .address)`. As `NestedDecodable` and it's wrapped value are as well decodable types then compiler will generate decoding initialiser for it as well, which will try to decode its wrapped value and coding keys. But both of these properties are not present in the JSON so we can't rely on compiler generated code as it is now.

Instead we can define a specialised decoding function on `KeyedDecodingContainer` that would decode values of this type with an extension:

```swift
extension KeyedDecodingContainer {
    func decode<T>(_: NestedDecodable<T>.Type, forKey key: Key) throws -> NestedDecodable<T> {
        ...
    }
}
```

Here we would want to decode the value and return it wrapped into the `NestedDecodable`.

```swift
extension KeyedDecodingContainer {
    func decode<T>(_: NestedDecodable<T>.Type, forKey key: Key) throws -> NestedDecodable<T> {
        let wrappedValue = ...
        return NestedDecodable(wrappedValue: wrappedValue)
    }
}
```

For that we would need to adjust a constructor of `NestedDecodable` to accept wrapped value:

```swift
struct NestedDecodable<T>: Decodable {
    let wrappedValue: T
    init(wrappedValue: T) {
        self.wrappedValue = wrappedValue
    }
}
```

But now we don't really have a place where to store the nested keys values. As a matter of fact we don't really need them to be stored in `NestedDecodable` any more as we would need to use them before we even create an instance of `NestedDecodable`. But without this instance the only thing we have is the type `NestedDecodable<T>.Type`.

How can we get the list of nested keys when we have only information about types? Remember that coding keys are enums (technically it's not a requirement). How knowing an enum type can we get a list of enum values? Sounds familiar? Right, it's `CaseIterable`:

```swift
enum CodingKeys: String, CodingKey, CaseIterable {
    case id
    case user
    case details
    case address
}

CodingKeys.allCases == [.id, .user, .details, .address]
```

Almost what we need, except we have all the keys here, but when decoding `address` we need only `user`, `details` and `address`. Also we need to have these keys exactly in this order as this is the order we would need to go through the JSON. We still need to have `id` key for `id` property, so let's define a separate type for address keys:

```swift
struct Contact {
    ....

    enum CodingKeys: String, CodingKey {
        case id
    }

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case user, details, address
    }
}

AddressCodingKeys.allCases == [.user, .details, .address]
```

Great! Now we need to make our `NestedDecodable` type aware about these extra coding keys type, which we can do by adding another generic parameter to it:

```swift
struct NestedDecodable<T, Keys: CodingKey & CaseIterable>: Decodable {
    ...
}

struct Contact: Decodable {
    let id: String
    let address: NestedDecodable<String, AddressCodingKeys>

    enum CodingKeys: String, CodingKey {
        case id
    }

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case user, details, address
    }
}
```

With that we need to update the signature of our `KeyedDecodingContainer` extension and we can finally access nested coding keys:

```swift
extension KeyedDecodingContainer {
    func decode<T, NestedKeys>(_: NestedDecodable<T, NestedKeys>.Type, forKey key: Key) throws -> NestedDecodable<T, NestedKeys> {
        let keys = NestedKeys.allCases
        let wrappedValue = ...
        return NestedDecodable(wrappedValue: wrappedValue)
    }
}
```

Now we have everything to start to decode our values. First we would need to get hold of the nested container for `user` key, then its nested container for `details` key and finally we would be able to decode the `address` value. As this is a generic method we don't really know how many nested keys we will have and what will be their actual values, so our method should be generic enough to be able to decode any value with any number of nested keys. For that we will simply iterate over the list of keys and get a nested container for each of the key until we rich the last one which we will use to finally decode the value:

```swift
var container: KeydDecodingContainer<NestedKeys>
NestedKeys.allCases.dropLast().forEach { key in
    container = try container.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
}
let wrappedValue = try container.decode(T.self, forKey: NestedKeys.lastCase!)
return NestedDecodable(wrappedValue: wrappedValue)
```

Unfortunatelly this won't work because when we get the nested container for the first key we don't have a `container` instance initialised to call `nestedContainer` on. We only have `self` which is a container itself, but it has a different type `KeyedDecodingContainer<Key>` as `Key` and `NestedKeys` are different types. So if we will try to use `self` as initial value `var container: KeyedDecodingContainer<NestedKeys> = self` the types will mismatch. But as soon as we have a first nested container we will always have `KeyedDecodingContainer<NestedKeys>` down the way. Seems like we need to handle the first key separately. So let's do that:

```swift
var container = try self.nestedContainer(keyedBy: NestedKeys.self, forKey: NestedKeys.allCases.first!)
NestedKeys.allCases.dropFirst().dropLast().forEach { key in
    container = try container.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
}
let wrappedValue = try container.decode(String.self, forKey: NestedKeys.lastCase!)
return NestedDecodable(wrappedValue: wrappedValue)
```

This still won't compile though - to call `self.nestedContainer` we need to pass it a key value that is of container's key type, in this case it's `Key` (at runtime it will be `Contact.CodingKeys`), but `NestedKeys.allCases.first` is a `NestedKey`...

There is also another problem that right now we only have an `id` key defined in the `Contact.CodingKeys`. So compiler will complain that a key for `address` property is missing. Let's add it then.

```swift
enum CodingKeys: String, CodingKey {
    case id
    case address
}
```

Now compiler will call our extension `decode` method with the `address` key and we can use it instead of the `NestedKeys.allCases.first` to get the first nested container. But we need to make sure we set the raw value of this key to the actual root key, which is `"user"` in our case. With that we won't need `user` key in `Contact.AddressCodingKeys` any more:

```swift
enum CodingKeys: String, CodingKey {
    case id
    case address = "user"
}

enum AddressCodingKeys: String, CodingKey, CaseIterable {
    case details, address
}

extension KeyedDecodingContainer {
    func decode<T, NestedKeys>(_: NestedDecodable<T, NestedKeys>.Type, forKey key: Key) throws -> NestedDecodable<T, NestedKeys> {
        var container = try self.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
        NestedKeys.allCases.dropLast().forEach { key in
            container = try container.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
        }
        let wrappedValue = try container.decode(String.self, forKey: NestedKeys.lastCase!)
        return NestedDecodable(wrappedValue: wrappedValue)
    }
}
```

This will finally compile and actually work in runtime! It looks a bit weird that we have two `address` keys but one of them is actually a `"user"` key, but that's the way to make compiler happy.

Let's sum up all the code we have right now to see that it's actually not that much:

```swift
struct Contact: Decodable {
    let id: String
    let address: NestedDecodable<String, AddressCodingKeys>

    enum CodingKeys: String, CodingKey {
        case id
        case address = "user"
    }

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case details, address
    }
}

struct NestedDecodable<T, Keys: CodingKey & CaseIterable>: Decodable {
    let wrappedValue: T
    init(wrappedValue: T) {
        self.wrappedValue = wrappedValue
    }
}

extension KeyedDecodingContainer {
    func decode<T, NestedKeys>(_: NestedDecodable<T, NestedKeys>.Type, forKey key: Key) throws -> NestedDecodable<T, NestedKeys> {
        guard NestedKeys.allCases.isEmpty == false else { throw ... }

        var container = try self.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
        NestedKeys.allCases.dropLast().forEach { key in
            container = try container.nestedContainer(keyedBy: NestedKeys.self, forKey: key)
        }
        let wrappedValue = try container.decode(String.self, forKey: NestedKeys.lastCase!)
        return NestedDecodable(wrappedValue: wrappedValue)
    }
}

extension CaseIterable {
    static var lastCase: Self? {
        guard allCases.isEmpty == false else { return nil }
        let lastIndex = allCases.index(allCases.endIndex, offsetBy: -1)
        return allCases[lastIndex]
    }
}
```

Now we can decode our `Contact` type and access its address. The only drawback is that `address` property is not a `String` any more but a `NestedDecodable<String, Contact.AddressCodingKeys>`. We still can access the actual string quite easily with `address.wrappedValue`, but we now would need to do that everywhere, which is nasty.

By now you already noticed thought that our `NestedDecodable` type perfectly matches property wrapper requirements, which is a `wrappedValue` property and `init(wrappedValue:)` initialiser. So we can go on and annotate it without changing anything else:

```swift
@propertyWrapper
struct NestedDecodable<T, Keys: CodingKey & CaseIterable>: Decodable {
    let wrappedValue: T
    init(wrappedValue: T) {
        self.wrappedValue = wrappedValue
    }
}
```

Now we can change how we declare our `address` property and with that we can access it directly as a string without even knowing that it was wrapped in the first place:

```swift
struct Contact: Decodable {
    let id: String
    @NestedDecodable<String, AddressCodingKeys>
    let address: String

    enum CodingKeys: String, CodingKey {
        case id
        case address = "user"
    }

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case details, address
    }
}

let contact = try JSONDecoder().decode(Contact.self, from: jsonData)
contact.address == "Apple St."
```

And that's the main "magic" of property wrappers.

## Decoding multiple nested value

Now when we can decode a single nested value we can declare as many `NestedDecodable` properties as we want, we can even completely get rid of any nested types in our data models and make them all flat (in real life you wouldn't do that of course). Let's try to add another nested property, let's say a name. Our JSON will look like this:

```
{
    "id": "1",
    "user": {
        "details": {
            "address": "Apple St."
            "name": "Jhon Appleseed"
        }
    }
}
```

We will need to add a new property "annotated" with `NestedDecodable` wrapper and coding keys for it:

```swift
struct Contact: Decodable {
    let id: String
    @NestedDecodable<String, AddressCodingKeys>
    let address: String
    @NestedDecodable<String, NameCodingKeys>
    let name: String

    enum CodingKeys: String, CodingKey {
        case id
        case address = "user"
        case name = "user"
    }

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case details, address
    }

    enum NameCodingKeys: String, CodingKey, CaseIterable {
        case details, name
    }
}
```

This looks fine but unfortunately does not work as different enum cases can't have the same raw values... So to be able to decode nested values with the same root we need a different way to define their common root key. The only feasible way to do that is to define it separately in each nested keys enum:

```swift
enum CodingKeys: String, CodingKey {
    case id
}

enum AddressCodingKeys: String, CodingKey, CaseIterable {
    case user, details, address
}

enum NameCodingKeys: String, CodingKey, CaseIterable {
    case user, details, name
}
```

With that we again have a problem that `CodingKeys` does not define all the keys for all the properties in the `Contact` type. But now as we don't need to change their raw values we can leave it to compiler to generate these keys for us and remove `CodingKeys` type completely and only leave nested keys enums. But this means that we can't use compiler generated keys for `address` and `name` when decoding these properties, as their raw values won't be `"user"` any more. We need to use `user` keys from `AddressCodingKeys` and `NameCodingKeys` respectively. But we can't use these keys as they are not `Contact.CodingKeys`...

Sounds like we are in a dead end. Notice though that all our keys are enums based on `String` raw values. So using the raw value `"user"` we can create either `CodingKeys.user` key, or `NameCodingKeys.user` or `AddressCodingKeys.user`. So what we need to restore our decoding code is to take the first key in `NestedKeys`, get its string value and use it to create a `Key` value. If the raw values of these enum cases match, then this convertion will work perfectly (and if does not - we throw):

```swift
let rootKey = Key(stringValue: NestedKeys.allCases.first!.stringValue)
```

With that we can fix our decoding method:

```swift
extension KeyedDecodingContainer {
    func decode<T, NestedKeys>(_: NestedDecodable<T, NestedKeys>.Type, forKey key: Key) throws -> NestedDecodable<T, NestedKeys> {
        guard NestedKeys.allCases.isEmpty == false else { throw ... }

        let wrappedValue = try containerForNestedKey().decode(T.self, forKey: NestedKeys.lastCase!)
        return NestedDecodable(wrappedValue: wrappedValue)
    }

    private func containerForNestedKey<K: CodingKey & CaseIterable>() throws -> KeyedDecodingContainer<K> {
        guard let rootKey = Key(stringValue: K.allCases.first!.stringValue) else { throw ... }

        var container = try self.nestedContainer(keyedBy: K.self, forKey: rootKey)
        if K.allCases.count > 1 {
            try K.allCases.dropFirst().dropLast().forEach { (key) in
                container = try container.nestedContainer(keyedBy: K.self, forKey: key)
            }
        }
        return container
    }
}
```

That's fine, it compiles now. But we still have one last issue - we still don't have a `CodingKeys.user` key. If we try to define it manually compiler will complain that there is no `Contact.user` property. If we don't do that then compiler won't generate this key for us, so our trick with converting keys from one type to another won't work at runtime. So we have nothing to do but to declare a `user` property to let compiler generate a `user` key for us:

```swift
struct Contact: Decodable {
    let id: String
    @NestedDecodable<String, AddressCodingKeys>
    let address: String
    @NestedDecodable<String, NameCodingKeys>
    let name: String

    private let user: ...
}
```

But what should be its type? We don't actually want to decode anything into this property and we definetely don't want to specify it's full type which is `[String: [String: String]]`. We could do that but it will break whole decoding as soon as we start to have nested values of any other types - its type will become `[String: [String: Any]]` for which compiler won't be able to generate decoding code at all.

So as we don't want to have any value in this `user` property can we declare it just as `Void`? We could but `Void` is not `Decodable` and we can't extend it to conform to any protocol. But what we can do is to define our own `Void`. In the end it's just a struct with no members.

```swift
struct Unit: Decodable {
    init() {}
    init(from decoder: Decoder) {}
}

struct Contact: Decodable {
    let id: String
    @NestedDecodable<String, AddressCodingKeys>
    let address: String
    @NestedDecodable<String, NameCodingKeys>
    let name: String

    private let user: Unit
}
```

(We could name this type something like `RootKeyPlaceholder` to make its purpose more clear in this context, but `Unit` is a good general type that can be used for other purposes as well)

And now we are really done. Complier will generate a `user` key for us, will automatically decode "nothing" into it and we then will be able to convert our key types and have multiple properties nested under the same root key.

Let's recap and see the final version of the code:

```swift
struct Contact: Decodable {
    let id: String
    @NestedDecodable<String, AddressCodingKeys>
    let address: String
    @NestedDecodable<String, NameCodingKeys>
    let name: String

    private let user: Unit

    enum AddressCodingKeys: String, CodingKey, CaseIterable {
        case user, details, address
    }

    enum NameCodingKeys: String, CodingKey, CaseIterable {
        case user, details, name
    }
}

struct NestedDecodable<T, Keys: CodingKey & CaseIterable>: Decodable {
    let wrappedValue: T
    init(wrappedValue: T) {
        self.wrappedValue = wrappedValue
    }
}

extension KeyedDecodingContainer {
    func decode<T, NestedKeys>(_: NestedDecodable<T, NestedKeys>.Type, forKey key: Key) throws -> NestedDecodable<T, NestedKeys> {
        guard NestedKeys.allCases.isEmpty == false else { throw ... }

        let wrappedValue = try containerForNestedKey().decode(T.self, forKey: NestedKeys.lastCase!)
        return NestedDecodable(wrappedValue: wrappedValue)
    }

    private func containerForNestedKey<K: CodingKey & CaseIterable>() throws -> KeyedDecodingContainer<K> {
        guard let rootKey = Key(stringValue: K.allCases.first!.stringValue) else { throw ... }

        var container = try self.nestedContainer(keyedBy: K.self, forKey: rootKey)
        if K.allCases.count > 1 {
            try K.allCases.dropFirst().dropLast().forEach { (key) in
                container = try container.nestedContainer(keyedBy: K.self, forKey: key)
            }
        }
        return container
    }
}

extension CaseIterable {
    static var lastCase: Self? {
        guard allCases.isEmpty == false else { return nil }
        let lastIndex = allCases.index(allCases.endIndex, offsetBy: -1)
        return allCases[lastIndex]
    }
}

struct Unit: Decodable {
    init() {}
    init(from decoder: Decoder) {}
}
```

## Conclusion

Note that if we have just one nested property per root key we still can use the first version of the code. On the other hand we then will need to define all our keys manually just to provide few custom values, so if there are a lot of properties and just a few nested properties it might be easier to use the second approach. Then we will only need to add `Unit` properties for our root keys. Unfortunately it's not a completely safe solution as we can still make a typo in the name of this property and even in cases for nested keys and it will be possible to catch this only at runtime. But on the other hand Codable is inherently unsafe as we still can have a mismatch between JSON keys and properties names. So this seems like an acceptable nuance.

As an excercise you can now try to implement `Encodable` and `Codable` for encoding nested values. Or you can go and see the full code that supports both encoding and decoding [here](https://gist.github.com/ilyapuchka/52356678ca87b1303a161cecdcf1a240).

branch_name: refs/heads/develop

gha_language: JavaScript


text:
# [Chanakya Projects](https://praneethmendu.github.io/chanakya-projects/)

## Built using :

Hosted on [Github Pages](https://pages.github.com)

Theme from [Start Bootstrap](https://startbootstrap.com), created and maintained by [David Miller](http://davidmiller.io/), Owner of [Blackrock Digital](http://blackrockdigital.io/).

[Bootstrap](http://getbootstrap.com/) framework created by [Mark Otto](https://twitter.com/mdo) and [Jacob Thorton](https://twitter.com/fat).

Images

repository: praneethmendu/chanakya-projects

repo_name: praneethmendu/chanakya-projects


text:
# Function Flow
A low cost, lightweight workflow orchestration framework based on Cloud Functions.

## Background
In many data and machine learning projects, we need to have an infrastructure that can manage our “workflows” or “data pipelines”. For example, consider a workflow like this:

```ingest data from GCS -> generate features with user data -> call AutoML to get predictions -> send results to Google Ads```

The workflows are usually in the form of a DAG, where each task can depend on a few other tasks. A task can be run only if all of its dependencies are successful.

One option is to use [Cloud Composer](https://cloud.google.com/composer) to orchestrate the tasks, which can manage task dependencies automatically. Unfortunately Cloud Composer needs an always-on cluster(>= 3 compute engines) to run and costs a few hundred USD/month (even if not running anything) which is not acceptable by developers who only run the workflow a few times per month.

This solution builds workflows on top of Cloud Functions, offers similar task dependency management ability to Cloud Composer, and is much cheaper and more lightweight.

## Example
Here is a simple example of using function flow.

This example job contains four tasks from task 1 to task 4. The dependency is

```
task1 --> task2 --> task4
      \-> task3 -/
```

The four tasks will be scheduled according to the dependencies defined in the @task decorator.

```python
import json
import logging
from typing import Dict

from workflows import futures
from workflows import tasks
from google.cloud import bigquery
import google.auth

# Create this BQ table to run the example. See `Deployment` section for details.
TEST_BQ_TABLE_NAME = 'test_dataset.test_table'

example_job = tasks.Job(name='test_job',
                        schedule_topic='SCHEDULE')

@example_job.task(task_id='step1')
def task1(**unused_context: Dict[str, str]) -> str:
  """Task 1: a simple task that returns a string."""
  return 'result1'

@example_job.task(task_id='step2', deps=['step1'])
def task2(**unused_context: Dict[str, str]) -> str:
  """Task 2: a simple task that returns a string."""
  return 'result2'

@example_job.task(task_id='step3', deps=['step1'])
def task3(**unused_context: Dict[str, str]) -> str:
  """Task 3: a BigQuery asynchronous job."""
  _, project = google.auth.default()
  dst_table_id = f'{project}.{TEST_BQ_TABLE_NAME}'
  client = bigquery.Client()
  job_config = bigquery.QueryJobConfig(
      destination=dst_table_id,
      write_disposition=bigquery.job.WriteDisposition.WRITE_TRUNCATE)

  sql = f"""
      SELECT id, content
      FROM `{project}.{TEST_BQ_TABLE_NAME}`
  """

  query_job = client.query(sql, job_config=job_config)
  bq_job_id = query_job.job_id
  return futures.BigQueryFuture(bq_job_id)

@example_job.task(task_id='step4', deps=['step2', 'step3'])
def task4(job: tasks.Job, **unused_context: Dict[str, str]) -> str:
  """Task 4: a job that checks the result of task 2."""
  result2 = job.get_task_result('step2')
  logging.info('in task4, got task2 result: %s', result2)
  assert result2 == 'result2'
  return 'result4'

# The cloud function to schedule next tasks to run.
scheduler = example_job.make_scheduler()

# The cloud function triggered by external events(e.g. finished bigquery jobs)
external_event_listener = example_job.make_external_event_listener()

def start(unused_request: 'flask.Request') -> str:
  """The workflow entry point."""
  example_job.start()
  return json.dumps({'id': example_job.id})
```

## Deployment
To run the example, first create a table called `test_dataset.test_table` in your BigQuery, and add some fake data.
The table schema should be `(id: String, content: String)`.
To deploy the previous example, save the code as `main.py` and run the following commands:

```
gcloud functions deploy start --runtime python37 --trigger-http --source workflow
gcloud functions deploy scheduler --runtime python37 --trigger-topic SCHEDULE --source workflow
gcloud functions deploy external_event_listener --runtime python37 --trigger-topic SCHEDULE_EXTERNAL_EVENTS --source workflow
```

The workflow can then be started by calling the `start` Cloud Function. (Cloud
Functions supports many ways of invocation including HTTP, PubSub and others.
See https://cloud.google.com/functions/docs/calling for details.)


text:
# Candida abiesophila Kurtzman SPECIES

#### Status
ACCEPTED

#### According to
Index Fungorum

#### Published in
FEMS Yeast Res. 6(2): 295 (2006)

#### Original name
Candida abiesophila Kurtzman

### Remarks
null

repository: mdoering/backbone

repo_name: mdoering/backbone


text:
# [ACM Bootcamp](https://github.com/Chitkara-ACM/ACM-Bootcamp)

Official Repository by **Chitkara ACM** for ACM Bootcamp Flutter Projects Submissions.

## Submission Procedure
Read the following steps properly for proper submission of your project. Missing out any step or performing it wrongly can lead to unsuccessful submission.

### Step 1
#### Fork this repository

### Step 2
#### Create a New Folder within the forked repository, with the 'folder name' being your 'Name'

## Contents of the folder
+ All project directories.
+ All the projects folders with their individual names, should be contain inside (Yours name Folder)
+ Attach a screenshot of your app in the respective readme file of the project

### Step 3
Create a Pull Request only after you have completed more the one project,
You can complete your work on the local machine and then upload your project folder in the forked repository and proceed to create a Pull Request.

### Resources
##### You can also refer to following links, To Know more about Git and Github.

[Git Tutorial](https://www.digitalocean.com/community/tutorials/how-to-contribute-to-open-source-getting-started-with-git)

[Git CheatSheet](https://www.digitalocean.com/community/cheatsheets/how-to-use-git-a-reference-guide)

[Creating Pull Request](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github)

[Rebasing and Updating Pull Request](https://www.digitalocean.com/community/tutorials/how-to-rebase-and-update-a-pull-request)

### Drive link :
https://drive.google.com/drive/u/0/folders/1oBJLM99hycMbyzzdEHYssTuat6MfjCRg

repository: Chitkara-ACM/ACM-Bootcamp

branch_name: refs/heads/main

gha_language: Dart

repo_name: Chitkara-ACM/ACM-Bootcamp


text:
You can do so by filing trade marks, patents or designs.

Learn more about them in our [Start-up Guide](/start-a-business/protect-your-ideas/).

### e-Services for Trade marks & Intellectual Property (IP)

**Intellectual Property Office of Singapore (IPOS)**

- [Apply for ASEAN Patent Examination Co-operation (ASPEC)](https://www.ipos.gov.sg/docs/default-source/protecting-your-ideas/patent/aspec-request-form-version-1.doc?sfvrsn=2af67859_4){:target="_blank"}{:rel="noopener"}

Submit a request to join this regional acceleration programme that helps speed up the patent grant process.

- [Apply for Patent Cooperation Treaty (PCT)](https://pct.wipo.int/authpage/signin.xhtml?goto=https%3A%2F%2Fpct.wipo.int%3A443%2FePCT%2F){:target="_blank"}{:rel="noopener"}

File for an international application under PCT directly with IPOS. PCT facilitates patent protection for an invention in multiple countries through one application.

- [Make appointment with IP business clinic](https://form.gov.sg/#!/5e1d1d26a457ea00129e4f61){:target="_blank"}{:rel="noopener"}

Book an appointment with a private business consultant on IP strategies and options for businesses. Areas of expertise include IP strategy, franchising and licensing, audits and valuation etc.

- [Make Appointment with IP Legal Clinic](https://go.gov.sg/iplegalclinic){:target="_blank"}{:rel="noopener"}

Book a consultation on intellectual property infringement or opposition.

- [Make appointment with IPOS](https://form.gov.sg/#!/5e16bc778967b800114d7e81){:target="_blank"}{:rel="noopener"}

Book an appointment with IPOS for questions about your application or available options.

- [Search for IP](https://ip2sg.ipos.gov.sg/RPS/WP/CM/SearchSimple/IP.aspx?SearchCategory=TM#){:target="_blank"}{:rel="noopener"}

Search for existing IP applications and registrations in IPOS' database.

- [File your trade mark](https://ip2sg.ipos.gov.sg/Layouts/RPSWP/RPSLogin/SPLogin.aspx){:target="_blank"}{:rel="noopener"}

File an application to register a trade mark with IPOS.

- [File your patent](https://ip2sg.ipos.gov.sg/RPS/RPSLogin/SPLogin.aspx){:target="_blank"}{:rel="noopener"}

File an application for a patent directly with IPOS.

- [File your design](https://ip2sg.ipos.gov.sg/RPS/RPSLogin/SPLogin.aspx){:target="_blank"}{:rel="noopener"}

File an application for a design in Singapore.

- IPOS Go (Available on [Google Play](https://play.google.com/store/apps/details?id=sg.ipos.mobile){:target="_blank"}{:rel="noopener"} and the [App Store](https://apps.apple.com/us/app/ipos-go/id1475896971){:target="_blank"}{:rel="noopener"})

Download IPOS' mobile app to apply for and renew IP registrations, and use other e-services. Available on Google Play and the App Store.

---

### Related links

{% include panels.html panels=site.data.protect_your_ideas_links %}

repository: isomerpages/govtech-gobusiness

branch_name: refs/heads/staging

gha_license_id: NOASSERTION

repo_name: isomerpages/govtech-gobusiness


text:
# Preamble Detection Test

<!-- In the IEEE 802.11 standard, each device should detect and extract the information in the preamble  to be able to determine whether the signal is noise or not. In addition, to avoid the packets collision during the transmission. The frame length in the preamble should be determined, where the device can know the period to be silent within. In this test, we check the compliance of commercial WiFi networking devices to the IEEE 802.11 standard. -->

The goal of this work is to develop an experimental
hardware testbed for verifying the compliance of the commercial
Unit Under Test (UUT)  with the preamble  frames that share the same communication  channel in IEEE 802.11 standard. In this experiment, we use  Universal Software Radio Peripheral (USRP) to capture and down-convert the Wi-Fi frames to the base-band. The captured data  by the USRP is utilized to extract the behavior of  different UUTs when they receive the preamble frames. The  standard states that each device should detect and extract the information in the preamble  to be able to determine whether the signal is noise or not. Moreover, to avoid the packets collision during the transmission. The frame length in the preamble should be determined, where the device can obtain the silent period to stop transmitting. In this test, we check the compliance of commercial WiFi networking devices to the IEEE 802.11 standard.

**Note**: This project is under active development, and a stable release branch has not yet been established.
The ```master``` branch is where the most stable version can be found, but interface and functionality contained therein are not yet guaranteed to be consistent or fully operational.

## Hardware Requirements

The following is a list of essential components for the preamble detection test:

* One or more wireless networking devices, known as the Unit(s) Under Test (UUTs) with USB and/or Gigabit Ethernet LAN connectivity
* One or two modern computers with USB 3.0 and Gigabit Ethernet ports (see Installation and Test Setup for the single-machine method)
* A software-defined radio capable of transmitting and receiving on the same wireless bands as the UUTs
* An anechoic chamber, or alternatively a series of shielded cabling to connect the devices in use

Preamble test was originally developed and tested using the [Ettus Research X300](https://www.ettus.com/all-products/X300-KIT/) software-defined radio device, which is the core measurement tool that senses the wireless channel and collects the data for further processing. No other devices are currently supported (although additional devices are on the roadmap). The (UUT) in a typical test setup is a either a commercially-available USB WiFi device, or a wireless router.

Below is a diagram showing an example test setup previously used at the Carleton Broadband Networks Laboratory:

![alt text](docs/images/System_model.jpg "  Preambl Test Setup ")

## Software Requirements

Preamble test was written and tested on systems running Fedora 28 and Ubuntu 16.04, but it should work on any modern Linux operating system with the following installed:

* Python 3 (written and tested on 3.6.5 and later 3.7.x)
* Gnuradio (for the core writeIQ script)
* Matlab software
* Install the communication toolbox on Matlab

<!--
Additionally, one script (```utils/writeIQ.py```) is currently written in Python 2, but will be updated as part of the project goals.
Early versions of the tool relied upon the use of the [MATLAB Engine for Python](https://www.mathworks.com/help/matlab/matlab-engine-for-python.html); however a significant effort was undertaken by the members of the Carleton University Broadband Networks Laboratory to rewrite the prototypical scripts in Python 3. Copies of the original MATLAB code are contained in the ```matlab``` folder for reference.-->

## Test Setup
Network Setup:
1. Connect the client PC to the Access point via Ethernet
2. Establish a wireless connection from the server PC to the Access point
3. Enable the IPERF traffic on the server PC
4. Start the IPERF traffic from the client PC to the server PC

USRP Setup:

We use two USRPs, namely, Jammer (Tx) and  Sampler (Rx)

Jammer:
1. Connect the Jammer according to the aforementioned figure
2. Using MATLAB, generate special IQ components  to be sent by the Jammer
3. Run sendIQ.py to send the IQ components

Sampler:
1. Connect the Sampler according to the aforementioned figure
2. Run writeIQ.py for x amount of seconds (preferably 2 seconds) to sample the medium
3. The IQ components will be stored in a (---.bin) file

Processing:
1. Using MATLAB, edit the MAC address of the UUT (UUT_MAC) in windowAnalyze_p2.m
2- Upload the (---.bin) file that has the received combined signals
2. Run windowAnalyze to process the samples and obtain the results

## Test Examples

We provide two examples for the preamble detection test. As seen in the passed test below, the UUT succeeded to detect the preamble and stoped transmitting until the end of the preamble.
![alt text](docs/images/pass_test.jpg "  Passed test  )

<!--<img src= "docs/images/pass_test.jpg " width="200" height="200">-->

While in the failed test, the UUT intervened the communication channel and transmitted in the silent period.
![alt text](docs/images/failed_test.jpg "  Failed test ")

## Authors

* **Ammar Alhosainy**
* **Shady Elkamhawy**
* **Yousef Alnagar**


text:
# Java-Design-Patterns
Java Design Patterns

## what does it do
Two main usages: Common Platform and Best Practices

+ Common Platform - A standard terminology and are specific to particular scenario. For example, a singleton design pattern signifies use of single object so all developers familiar with single design pattern will make use of single object and they can tell each other that program is following a singleton pattern.
+ Best Practices - The best solutions to certain problems faced during software development. Learning these patterns helps unexperienced developers to learn software design in an easy and faster way.

## what is it
- Common Java Design Patterns
- CREATED : Apr 15, 2018 (2014)

## technology used
Java

## ambition of project
understand design patterns classified in four categories: Creational, Structural Behavioral, and J2EE design patterns.

## stage
IN DEVELOPMENT

## known issues / thing not properly done

## Table of Content
- what does it do
- what is it
- technology used
- ambition of project
- stage
- known issues/ thing not properly done
- quick start
- status
- what's included
- bug and feature request
- running documentation locally
- pervious releases
- contributing
- community
- versioning
- creators
- thanks/backers/sponsors
- copyright and license

## quick start
Quick setup — if you’ve done this kind of thing before

or

Get started by creating a new file or uploading an existing file. We recommend every repository include a README, LICENSE, and .gitignore.
…or create a new repository on the command line

echo "# Java-Design-Patterns" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/keeyanajones/Java-Design-Patterns.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/keeyanajones/Java-Design-Patterns.git
git push -u origin master

…or import code from another repository

You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
ProTip! Use the URL for this page when adding GitHub as a remote.

## status
- STATUS : LOCAL TEST 6/7/2020 04:49:47 (as of 6/7/2020 08:49:47 Coordinated Universal Time (UTC) )

## what's included
- Creational Patterns :
to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case.
- Structural Patterns :
class and object composition. Inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
- Behavioral Patterns :
communication between objects.
- J2EE Patterns :
the presentation tier. These patterns are identified by Sun Java Center.

## bug and feature request

## running documentation locally

## previous releases

## contributing

## community

## versioning

## creators
 - 2020 Keeyana Jones

## thanks/backers/sponsors

## copyright and license
 - MIT License Copyright (c) 2020 Keeyana Jones

repository: keeyanajones/Java-Design-Patterns

repo_name: keeyanajones/Java-Design-Patterns


text:
![gablogo][gablogo]

# Lab 4 - Docker Container part 2

## Goal

In the previous lab, you deployed the container manually but it would be awesome if we could automate the process so each time you'd checkin a code update, Azure DevOps would compile the code, deploy it to a container and push it to Azure Container Registry (ACR) automatically.  Like in the previous lab, the Web App will be updated using a Webhook.

Magical! To do so, let's start by creating a new pipeline.

## Let's code!

### Create a new pipeline

Head to dev.azure.com, click on the **Pipelines** menu and the **New Pipeline** button.

![01][01]

Click on the **Use the Visual Designer** link.

![02][02]

Select **Azure Repos Git** and the team project you created earlier.

![03][03]

Select the **Docker Container template**.  This template has 2 steps that needs to be configured: Build and Push.

![04][04]

### Configure the Build step

Let's configure the Build step.  Select your **subscription** and your **Azure Container Registry**.

![05][05]

Locate the **Dockerfile** in your project.

![06][06]

### Configure the Push step

Let's now configure the Push step that will push the container to ACR.  Click on the **Push an Image** step.

![07][07]

Select your **subscription** and your **Azure Container Registry**.  Check **Include Latest Tag**.

![08][08]

Click on **Save**.  You’ll be prompted for a location in your repo, accept the defaults and click **Save**.

![09][09]

### Enable continuous integration

Click on the **Triggers** tab and check **Enable continuous integration**.

![10][10]

### Configure the Web App

In the Web App created in the previous lab, change the container settings to pint to the container located in the Azure Container Registry that was just built by the pipeline.  The startup file is **GABCDemo.dll**.  Set **Continuous Deployment** to On.

### Test the Web App

Launch a browser and test the app.

### Commit a change

Back in **Code**, make a simple change to a page, commit and push the change.  The pipeline will pick the change, build the code, create a container and deploy it to ACR.  The Web App will pick the change using the Webhook and pull the new container.

## Reference

[Deploy to an Azure Web App for Containers](https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-docker-webapp?WT.mc_id=globalazure-github-frbouche&view=azdevops)

## End
[Previous Lab](../Lab3/README.md)
[Next Lab](../Lab5/README.md)

[gablogo]: ../medias/GlobalAzureBootcamp2019.png "Global Azure Bootcamp 2019"
[01]: medias/Lab4-01.png
[02]: medias/Lab4-02.png
[03]: medias/Lab4-03.png
[04]: medias/Lab4-04.png
[05]: medias/Lab4-05.png
[06]: medias/Lab4-06.png
[07]: medias/Lab4-07.png
[08]: medias/Lab4-08.png
[09]: medias/Lab4-09.png
[10]: medias/Lab4-10.png


text:
# swiftLib
Natural Language Date Parser Library in XCode

This takes the code from [Core](https://github.com/momentlib/core) and allows xcode to do the compiling for you.

**To get the Library**

1. Build the library for both simulator and ios.
2. Run lipo command to combine them
3. Add the result to your project

lipo -create /path/to/Debug-iphoneos/libmomentLib.a /path/to/Debug-iphonesimulator/libmomentLib.a -output libcombined.a

repository: momentlib/swiftLib

repo_name: momentlib/swiftLib


text:
# Data dive:

 This repository contains scripts and data for the ODM data dive.

## Scoot loop data:

Open Data Manchester have been scraping data on Greater Manchester's SCOOT (Split Cycle Offset Optimisation Technique) loop system from the [TfGM developer portal](https://developer.tfgm.com).

 - You can download the database as a .bacpac file [here](https://odmblob.blob.core.windows.net/dbdumps/odm-2021-2-18-19-0.bacpac).

 - [Sam](https://github.com/sam-odm) has queried the db for some sample scoot data available in csv files, which you can find [here](https://github.com/OpenDataManchester/data/tree/master/themes/Our%20Streets%20Chorlton/TfGM%20Scoot%20Loop/Data).

 - `cleaned_scoots.csv` is the above data merged, cleaned, and with loop information added.

 - `Cleaning_scoots.R` contains the code for automating merging, cleaning, and adding loop info used to generate `cleaned_scoots.csv`. I t may be usefull if you want to query the db yourself.

 - `loop_info.csv` contains information on the location and ID of each loop, you can also find usefull diagrams as pdf files [here](https://github.com/OpenDataManchester/data/tree/master/themes/Our%20Streets%20Chorlton/TfGM%20Scoot%20Loop)

 - `Creating Shapefiles.R` contains code for creating shapefiles from the loop info.

 - `scoot_linestring` contains shapefiles for all the SCOOT loops in Greater Manchester, represented as linestrings.

 - `loop_map.html` is an interactive map of the SCOOT network.

**Data collected:**

Scoot name,
Description,
Time,
Congestion percentage,
Current flow,
Average speed,
Link travel time,
Start latitude,
Start longitude,
End latitude,
End longitude


text:
---
hrs_structure:
  division: '2'
  volume: '8'
  title: '22'
  chapter: '412'
  section: '412:1-100'
type: hrs_section
tags:
  - Business
menu:
  hrs:
    identifier: HRS_0412-0001-0100
    parent: HRS0412
    name: '412:1-100 Short title'
weight: 23005
title: Short title
full_title: '412:1-100 Short title'
---
**ARTICLE 1\. GENERAL PROVISIONS**

**§412:1-100 Short title.** This chapter shall be known and may be cited as the Code of Financial Institutions. [L 1993, c 350, pt of §1]

repository: SamMade/BlueAndKrabby

repo_name: SamMade/BlueAndKrabby


text:
# [FIXME: 1, 2, 3, 4](https://www.codewars.com/kata/fixme-1-2-3-4 "https://www.codewars.com/kata/5b13c699af73864aa7000031")

The code provided is supposed to simply return the named number as an integer.

But it's not working properly.

## Task

Fix the bug so we can all go home early.

## Notes

* Don't try to modify the `getNumber` API. It returns an enum.

repository: ParanoidUser/codewars-handbook

gha_language: Java

repo_name: ParanoidUser/codewars-handbook


text:
# smssplit
UI to explain how messages are split in SMS

Use here: https://chadselph.github.io/smssplit/

**Caveat**: Different sms gateways and different mobile operators across the world sometimes do things differently, this is just an example that can usually explain why your message got split. Hint: it's usually because of a punctuation mark or whitespace that isn't encodable in GSM.

Here's a [Python API](https://github.com/chrisconlon-klaviyo/sms-toolkit) based on this algorithm.

repository: chadselph/smssplit

branch_name: refs/heads/gh-pages

repo_name: chadselph/smssplit


text:
# Show

```sh
$ gem list
$ gem list D # Filter to names starting with string.
```

```sh
$ bundle list
```

```sh
$ gem environment
```

repository: korenmiklos/dev-cheatsheets

repo_name: korenmiklos/dev-cheatsheets


text:
# FT857-CAT

Fork from [Philippe F6CZV version](https://github.com/Phil-f6czv/Arduino-FT857-CAT).

## Origial description

A display of some Yaesu FT-857’s parameters was developed for a 4×20 LCD screen.
The software implements via the serial link the FT-857 CAT (Computer Aided Transceiver) controls and additional readings of the transceiver’s EEPROM.
The developments were made from a source code developed for Arduino by VE3BUX.
See my web site for more details (https://f6czv.fr)
73
Philippe F6CZV

## My changes
* Support of **Arduino** (SoftwareSerial) and **ESP 32** (HardwareSerial)
* Reword code and renaming of few functions


text:
<!--
Copyright The Shipwright Contributors

SPDX-License-Identifier: Apache-2.0
-->

---
title: webhook-validation
authors:
  - "@ImJasonH"
reviewers:
  - "@gmontero"
  - "@zhangtbj"
approvers:
  - "@qu1queee"
  - "@adamkaplan"
creation-date: 2020-03-19
last-updated: 2020-03-19
status: provisional
---

# Webhook Validation

## Release Signoff Checklist

- [ ] Enhancement is `implementable`
- [ ] Design details are appropriately documented from clear requirements
- [ ] Test plan is defined
- [ ] Graduation criteria for dev preview, tech preview, GA
- [ ] User-facing documentation is created in [docs](/docs/)

## Open Questions [optional]

Do we want to require that operators run another job to synchronously validate client requests?

Do we want to rely on Knative's webhook packages, or write our own code to manage certs ourselves?
Is there anything already out there in controller-gen we should be using?

## Summary

Kubernetes provides facilities to inject synchronous validation of CRUD operations from clients for specified types, such as Shipwright's CRD types.

Webhooks can also mutate incoming requests, including setting default values and converting between versions of CRDs. These features should be considered later, and are not described in this proposal.

We should take advantage of these features and include a webhook validation deployment in the Shipwright installation to provide this functionality.

## Motivation

Today, when a user creates a resource (e.g., a Build, BuildRun, etc.), they are immediately stored in the cluster's etcd storage, and the Shipwright controller begins reconciling the object.

If the controller finds that the resource is invalid, it updates the resource's `.status` to indicate this state and stops reconciling it.

Examples of invalid resources include:

- a BuildRun referencing a Build that doesn't exist
- a BuildRun referencing a ServiceAccount that doesn't exist
- a Build referencing a (Cluster)BuildStrategy that doesn't exist
- a BuildStrategy containing zero steps

(This is a partial list, and new validation can be assumed to be added over time as the Shipwright API evolves.)

By allowing invalid resources to be accepted and stored, we require clients to watch or poll all resources to ensure their request was valid, and we add to the API surface of resources that otherwise would not need to report a status, like a Build.

Always accepting and storing resources, even invalid ones, can also lead to additional storage of known-invalid objects, which clutter the user experience and can lead to confusion, and in extreme cases, cluster resource exhaustion.

Mixing reconciliation and validation code in the controller also complicates our codebase, leading to PRs like https://github.com/shipwright-io/build/pull/641 which add new validation-centric statuses that the user must watch for.
As we add new validation scenarios, we currently add new `Reason` strings that clients must be aware of, which is cumbersome and won't scale indefinitely.

### Goals

Enforce synchronous validation via a new Deployment and a [ValidatingAdmissionWebhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook), and remove validation-centric logic from the reconciler.

The reconciler should be able to assume in many cases that the resource it is reconciling has already been validated.

### Non-Goals

- Include a mutating or defaulting or conversion webhook.
  If we decide these are useful, we can add them in future proposals.

## Proposal

Rely on [kubebuilder's webhook support](https://book.kubebuilder.io/cronjob-tutorial/webhook-implementation.html) to add a new webhook validation controller, and include it in Shipwright's default installation as a K8s Deployment.

### Implementation Details/Notes/Constraints [optional]

#### Certificates

The webhook deployment will also need to manage certificates since K8s webhook requests are sent over HTTPS.
Setting up these certificates securely can be cumbersome.

The [Knative](https://knative.dev) project has [some libraries to make this management easier](https://github.com/knative/pkg/tree/main/webhook) by taking care of cert generation, registration and refreshing, but mixing Knative-style components and existing `controller-gen`/KubeBuilder-style components might make complicate development.

#### Webhook Availability

Once registered, if the K8s API server can't reach the defined webhook service, _all_ requests will fail for registered CRD types.
The webhook deployment is stateless, so it can be easily replicated and scheduled across multiple nodes to ensure availability in the case of node failure.

### Risks and Mitigations

Clients that expect to have requests accepted and asynchronously validated might be surprised to find the API synchronously rejecting their invalid requests instead.
We should communicate this change to users and operators in release notes and in mailing list announcements, and be available to answer any questions.

## Design Details

### Test Plan

Our current tests to validate resources should be mostly reusable; validation logic itself isn't going anywhere, just moving.

Any tests that we have that assume an invalid resource will be accepted and eventually reconciled should be updated to expect immediate failure.

### Version Skew Strategy

A user who has previously installed a version of Shipwright that did not synchronously validate might have invalid resources in their etcd storage, and our controller may be asked to reconcile them.
Basic validation logic should remain in the reconciler, but either update a status to indicate invalidity, or merely log and ignore invalid resources.

During installation or upgrade of Shipwright components, the webhook job and the reconciling controller job might briefly run two versions of validation code, so we should be careful to consider this as we add (or remove, or refactor) validation support over time.
In practice, Tekton hasn't experienced significant issues with this, but I wanted to call it out because it's possible.

## Implementation History

Major milestones in the life cycle of a proposal should be tracked in `Implementation History`.

## Drawbacks

This requires us to build a new component in the Shipwright installation, and for the operator component to operate it.

## Alternatives

Continue to validate asynchronously, which probably requires investing more in scaling the addition and documentation of validation failures.

repository: gabemontero/build

repo_name: gabemontero/build


text:
# Magento — Cloudflare — By [JetRails](https://jetrails.com)
> Interact with popular Cloudflare features though Magento's backend portal.

![](https://img.shields.io/badge/License-MIT-orange.svg?style=for-the-badge)
![](https://img.shields.io/badge/Version-1.3.0-orange.svg?style=for-the-badge)
![](https://img.shields.io/badge/Stability-Stable-orange.svg?style=for-the-badge)
![](https://img.shields.io/badge/Magento-1-orange.svg?style=for-the-badge)

## Documentation

The user manual can be found in [here](https://learn.jetrails.com/article/magento-1-cloudflare-extension).  The user manual goes through the installation process as well as explains all the features that comes with this plugin. For furthur support, please email [development@jetrails.com](mailto://development@jetrails.com).

## Build System

This extension uses __Gulp__ as it's build system.  Gulp is a package that can be easily downloaded using __NPM__ or __Yarn__.  Once this repository is cloned, run `npm install gulp -g` followed by `npm install` or `yarn install` to install Gulp and all Gulp modules used within this build system.  Please refer to the following table for a description of some useful Gulp commands. A typical Gulp command takes the following form: `gulp <command>`.

| Command   | Description                                                                             |
|-----------|-----------------------------------------------------------------------------------------|
|   `init`  | Creates build, staging, and distribution directories                                    |
|  `clean`  | Deletes build and distribution directories                                              |
|   `bump`  | Bumps version number in source files to reflect version found in package.json           |
|  `build`  | Builds and copies files from source directory to the build directory                    |
|  `deploy` | Copies files from build directory to the staging directory                              |
|  `watch`  | Watches files in source directory and executes `deploy` on file change                  |
| `package` | Updates package.xml with file hashes and packages extension into distribution directory |

## Docker Environment

This project comes with a [docker-compose.yml](docker-compose.yml) and a [docker-sync.yml](docker-sync.yml) file, which can be used to spin up a Magento 1 development environment. In order to use docker, please make sure you have **Docker**, **Docker Compose**, and **Docker Sync** installed. For information about configuring this docker environment, please refer to it's Github repository which can be found [here](https://github.com/jetrails/docker-magento-alpine).

repository: jetrails/magento-cloudflare

gha_language: PHP

repo_name: jetrails/magento-cloudflare


text:
Qrpc
====
[![Build Status](https://travis-ci.org/andrasq/node-qrpc.svg?branch=master)](https://travis-ci.org/andrasq/node-qrpc)
[![Coverage Status](https://coveralls.io/repos/github/andrasq/node-qrpc/badge.svg?branch=master)](https://coveralls.io/github/andrasq/node-qrpc?branch=master)

Qrpc is a very fast remote procedure call package.

Features:

- low latency, 0.05 ms round trip
- high throughput, 0.013 ms per call avg
- efficient connection sharing with call and response multiplexing
- out-of-order call completion
- a single call can receive multiple responses, to stream response in chunks
- request/response or one-way message sending
- message is any serializable json object or a Buffer
- can use user-specified serialization function
- wire protocol is newline terminated strings
- fast transfers of binary data in Buffers
- familiar middleware-like `handler(req, res, next)` message handler signature
- familiar `function(err, ret)` client callback signature
- familiar `createServer` / `listen` / `connect` usage
- can communicate over sockets, streams, or pretty much anything with `read` and `write` methods
- very small, with minimal dependencies

Summary
-------

The rpc system consists of one or more clients making calls and a server that
processes the calls and sends back responses.  Each call includes an optional
argument; each response returns a data item and an optional error.

Any of the serializable JavaScript data types may be sent and received
(numbers, strings, arrays, objects, booleans, null), as well as Buffers.
Special objects (Date, RegExp, etc) lose their special properties across the
rpc call.  Undefined can not be serialized, and undefined fields are omitted.

Calls are transmitted and run in the order made (even though they may finish out of
order).  In particular, this means that receipt of a stream of one-way messages can
be explicitly verified by inserting a callback-ed call into the message stream.
(Eg the verifier in a logging server could make an rpc call to flush the data,
thus ensuring that data has been both received and persisted.)

Server:

    var qrpc = require('qrpc')
    var server = qrpc.createServer()
    server.addHandler('echo', function(req, res, next) {
        // echo sends two response messages
        var err = null
        res.write('test ran!')      // first response
        next(err, req.m)            // final response
    })
    server.listen(1337, function() {
        console.log("qrpc listening on port 1337")
    })

Client:

    var client = qrpc.connect(1337, 'localhost', function() {
        client.call('echo', {a: 1, b: 'test'}, function(err, ret) {
            // client callback is invoked on every response message
            console.log("reply from server:", ret)
            // => reply from server: 'test ran!'
            // => reply from server: { a: 1, b: 'test' }
        })
        client.call('echo', new Buffer("test"), function(err, ret) {
            console.log("reply from server:", ret)
            // => reply from server: 'test ran!'
            // => reply from server: <Buffer 74 65 73 74>
        })
    })

Benchmark
---------

Qrpc can sustain 200k calls per second.  Full end-to-end throughput measured at the
client is around 160k round-trip calls per second.  Timings on a 32-bit i7-6700k
Skylake at 4410 MHz running Linux 3.16-amd64.  (64-bit kernel with 32-bit apps:
double the memory of a full 64-bit system for free!)

    $ node-v6.10.2 test/benchmark.js

    rpc: listening on 1337
    echo data: { a: 1, b: 2, c: 3, d: 4, e: 5 }
    ----
    parallel: 50000 calls in 314 ms
    series: 20000 calls in 697 ms
    send to endpoint: 100000 in 38 ms
    retrieved 100000 data in 245 ms
    retrieved 20000 1k Buffers in 82 ms
    parallel 1k buffers: 20000 in 228 ms
    wrapped parallel: 50000 calls in 452 ms
    parallel 1K object: 20000 calls in 1032 ms
    logged 100000 200B lines in 483 ms syncing every 250 lines

Here are the original timings on the old AMD 3600 MHz Phenom II running the
same Linux 3.16.0-amd64:

    $ node-v0.10.29 test/benchmark.js

    rpc: listening on 1337
    echo data: { a: 1, b: 2, c: 3, d: 4, e: 5 }
    parallel: 50000 calls in 780 ms
    series: 20000 calls in 1130 ms
    send to endpoint: 100000 in 87 ms
    retrieved 100000 data in 825 ms
    retrieved 20000 1k Buffers in 342 ms

The parallel rate is call throughput -- the rpc server decodes the calls,
process them, and encodes and send the response.  The times shown above include
the client-side formatting and sending of the rpc messages; the server time to
process the 50000 calls (read request, decode, dispatch, process, encode, write
response) is 250 ms; the 780 ms shown above includes the client time to format
and send send the request and to read, decode and deliver the response.

The series time is handling latency -- it is all-inclusive back-to-back round-trip
time; each call is made only after the previous response has been received.

The send rate is the number of calls processed by the server, not including
data prep time (but yes including the time to transmit, decode, and dispatch).
Send-only mode is one-way message passing:  the data will be acted on by the
server but no acknowledgement, status or error is returned.

Retrieval is getting multiple responses for one request, for chunked data
fetching.  These tests make one call for every 10,000 responses, one data item
(or one Buffer) per response.

The logging benchmark ships 200-byte log lines to the server with one-way messages,
and every 250 lines makes a round-trip rpc call to sync them, ie to ensure that all
preceding lines have been successfully received and persisted.  `qrpc` servers
process calls in transmission order, so for the sync to have been received all
preceding calls must have been received as well.

Note that the logging test uses `socket.setNoDelay()` to turn off the Nagle algorithm
on the client side.  With Nagle enbaled, only 25 sync calls get through per second, ie
the throughput drops from 200k lines/sec to 25 * 250 = 6.25k lines/sec.

Qrpc Server
-----------

The server listens for incoming messages, processes them, and returns the
responses.

Calls are tagged with a the handler name string.  Each handler appears similar
to a framework middleware step, taking a request, response and next callback.

The response is returned via the next() callback, or via res.write() and
res.end().  Any number of write() calls may be used, each will send a response
message that will be pass to the client call's callback.  end() and next()
both send a final message and close the call.  Once the call is closed, no
more responses must be sent.

write() and end() return data.  Errors may be returned with next().  Qrpc
restores error objects so the client callback receives instanceof Error (note:
these errors occurred in the handler code on the server, not on the client)

Calls may be kept open indefinitely, but each open call uses memory while
holding on to the callback.

Calls do not time out.  Write errors on the server side will not be noticed by
the client.  Timeout-based error handling is up to the application.  (But see
the Todo list below)

### server = qrpc.createServer( [options][, callback(socket)] )

Create a new server.  Returns the QrpcServer object.

The callback, if specified, will be invoked on every connection to the rpc
server with the connected socket.  This makes it possible for the server to
tune the socket settings.

Options:

- `json_encode` - the object serializer function to use (default `JSON.stringify`)
- `json_decode` - the object deserializer to use (default `JSON.parse`)

### server.addHandler( handlerName, handlerFunction(req, res, next) )

Define the code that will process calls of type `handlerName`.

A handler receives 3 parameters just like a middleware stack function: the
call object (`req`), the response object (`res`), and a callback `next` that
can be used to return errors and/or data.

The `req` object has a field `.m` that contains the object passed to the call, if
any, and a field `.id` that is the unique caller-side id of the call.

The `res` object has methods `write(data [,cb])` and `end([data] [,cb])` that reply to
the caller with the provided data. Each reply will be delivered to the client
callback.  Buffers are sent and received as base64 Buffers, other objects as
JSON serialized strings.  End() will send the reply, if any, then close the
call.  After the call is closed, no more replies can be sent.

### server.addHandlerNoResponse( handlerName, handlerFunction(req, res) )

Define the code that will handle messages of type `handlerName`.

NoResponse handlers are endpoints for one-way messages, not full RPC calls.  They process
messages, but do not return a response to the caller.  One-way message passing
is a much more efficient way to push data for eg reporting or stats delivery.
The handler function should not declare the `next` argument as a reminder that
no response will be returned to the caller.  A no-op `next` function is passed
to the handler, though, just in case.

Calling endpoints is one-way message passing:  the data will be acted on by the
server but no acknowledgement, status or error is returned.  This offers a very
fast pipelined path to ship data.

NOTE:  The client _must_ _not_ pass a callback function when calling a message
endoint, because this would leak memory.  Endpoint calls will never be closed by
the sender, so the callback context would never be freed.

### server.listen( port, [whenListening()] )

Start listening for calls.  Incoming calls will invoke the appropritae
handlers.

If the whenListening callback is provided, it will be invoked once the server
is listening for incoming calls.

### server.close( )

Stop listening for calls.

    var server = qrpc.createServer()
    server.addHandler('echo', function(req, res, next) {
        // echo server, return our arguments
        next(null, req.m)
    })
    server.listen(1337)

### server.wrap( object [,methods] [,options] )

Make the methods of the object callable by rpc.  Adds handlers for the methods
whose names are in the `methods` array (all function properties by default).  The
handlers will expect the method arguments list in `req.m` and will return a list
with all arguments returned by the method callback.

To wrap functions, pass an object with the functions as named properties.

Options:

- `prefix` - build the rpc handler name by prepending `prefix` to the method name.  The default is just the method name.

Qrpc Client
-----------

The client makes calls to the server, and consumes the responses.  A single
request can result in more than one response; qrpc sends all requests and
responses over a single socket (multiplexes) and steers each response to its
correct destination.

### client = qrpc.connect( port|options, [host,] whenConnected(clientSocket) )

Connect to the qrpc server listening on host:port (or 'localhost':port if host
is not specified).  Returns the QrpcClient object.

If provided, the newly created net.socket will be passed to the whenConnected
callback for socket configuration and tuning.

Once connected, calls may be made with client.call()

Instead of port (or port and host) an options object can be passed which is
then passed to `net.connect()`.

Options:

- `port` - port to connect to (required, no default)
- `host` - host to connect to (default 'localhost')
- plus all other valid `net.connect()` options

In addition, QrpcClient recognizes:

- `json_encode` - the object serializer function to use (default JSON.stringify)
- `json_decode` - the object deserializer to use (default JSON.parse)

### client.call( handlerName, [data,] [callback(err, replyData)] )

Invoke the handler named _handlerName_, and return the server reply via the
callback.  Handlers are registered on the server with addHandler().  Data is
optional; if any data is specified, it is passed in the call to the server in
`req.m` unless it is a `Buffer`, which is passed in `req.b`.

Omitting the callback sends a one-way message to the server.  Any response
received from the server will be discarded.

Note: `Buffers` maybe be sent only standalone.  Sending an object that has as a
Buffer as a property will arrive as a JSON.stringified Buffer `string`and not as an
`instanceof Buffer`.

### client.close( )

Disconnect from the qrpc server.  Any subsequent calls will return a "write
after end" error to their callback.

    client = qrpc.connect(1337, 'localhost', function whenConnected() {
        client.call('echo', {i: 123, t: 'test'}, function(err, ret) {
            console.log("echo =>", err, ret)
        })
    }

    // produces "echo => null, { i: 123, t: 'test' }"

### client.wrap( object [,methods] [,options] )

Return an object with methods names as in the `methods` array (or all function
properties on `object`) that will invoke the corresponding handlers on the
qrpc server.

To wrap functions, pass an object with the functions as named properties.

Options:

- `prefix` - build the rpc handlerName by prepending `prefix` to the method name

Under The Hood
--------------

Qrpc is implemented as streaming message passing with call multiplexing.
Each message is a newline terminated string sent to the server.  Messages
are batched for efficiency, and arrive at the server in large chunks.  The
server splits the stream, decodes each message, and invokes each handler.

Messages are sent to named handlers; the handlers are registered with the
server using the `addHandler` method.  Every handler takes the same arguments,
a middleware stack-like `(req, res, next)`:  the request bundle (the message
itself), the response object, and a callback that can return a response and is
used to return errors.

The response object can be used to send replies back to the caller.  The
`write` method sends a reply message and keeps the call open for more
replies later.  The `end` method sends an optional final reply and closes
the call.  End without an argument just closes the call by sending a special
empty message back to the client.  Calling the handler callback `cb(err,
data)` is equivalent to calling `end(data)`, except it will return the error
too, if any.  A single call can result in more than once response;
coordinating the responses is up to the application.

Responses arrive at the caller in the same newline terminated text format,
also in batches, over the same bidirectional connection.  The calling
library splits the batches, decodes the responses, demultiplexes the replies
to match them to their originating call, and invokes the call's callback
function with the error and data from reply message.

Calls are multiplexed, and may complete out of order.  Each message is
tagged with a unique call id to identify which call's callback is to process
the reply.

The RPC service is implemented using the `QrpcServer` and `QrpcClient` classes.
They communicate over any bidirectional EventEmitter
stream or object with a `write()` method.  A customized RPC can be built over
non-socket non-socket streams, which is how the unit tests work.

To build an rpc service using QrpcServer and QrpcClient
on top of net sockets the way `qrpc` does:

    // create qrpc server
    var server = new qrpc.QrpcServer()
    var netServer = net.createServer(function(socket) {
        // have the server read rpc calls from the first arg
        // and write responses to the second arg
        server.setSource(socket, socket)
    })
    server.setListenFunc(function(port, cb){ netServer.listen(port, cb) })
    server.setCloseFunc(function(){ netServer.close() })

    // create qrpc client to talk to the server
    var client = new qrpc.QrpcClient()
    var socket = net.connect(1337, 'localhost')
    client.setTarget(socket, socket)

### Message Format

Qrpc requests and responses are sent as simple serialized json objects,
one per line:

    {
        v: 1,               // protocol version, 1: json bundle
        id: id,             // unique call id to match replies to calls
        n: name,            // call name string, in request only
        e: error            // returned error, in response only
        s: status           // response status, one of
                            //   'ok' (on write()),
                            //   'end' (on end()),
                            //   'err' (server error; means end)
        m: message          // object payload, in call or response
        b: blob             // base64 encoded buffer payload
    }

Related Work
------------

- [qrpc](https://npmjs.com/package/qrpc) - 60k calls / sec round-trip, 1m messages / sec dispatched
- [rpc-stream](https://npmjs.com/package/rpc-stream) - 16k calls / sec
- [dnode](https://npmjs.com/package/dnode) - 14k calls / sec light load, throughput drops sharply with load
- [fast](https://npmjs.com/package/fast) - 12k calls / sec
- X [mrpc](https://www.npmjs.com/package/mrpc) - npm install failed (C++ compile errors)
- X [kamote](https://www.npmjs.com/package/kamote) - hangs on concurrent calls (v0.0.2)
- X [fast-rpc](https://www.npmjs.com/package/fast-rpc) - just a placeholder since 2013 (v0.0.0)

Todo
----

- more unit tests
- server should periodically yield to the event loop
- support call timeouts for more convenient error detection and cleanup (client-side and server-side both)
  Make server track running calls with timestamp, set done calls = undefined, periodically copy over object to gc properties,
  only the "olds" object could have timed-out calls.
- think about how to gc or time out callbacks that have been abandoned by the server (call not closed)
- maybe make the the client and server pipable event emitters
- provide a `client.send()` method to send to an endpoint without a callback
- ? allow pre- and post-handler functions to be registered, for shared processing
  (eg for authentication and stats logging)
- ? allow multi-step handlers (ie an array of functions, each taking req-res-next)
- option to auto-reconnect if connection drops
- way to test whether connection was dropped since last test (counter? or connection id?)
  to check whether datagrams got there ok
- Use Cases readme section to discuss rpc, send datagrams to server (addHandlerNoResponse),
  data retrieval (multiple replies from server)
- support `qrpc.*` out-of-band calls for client-server metadata, setup/config/etc
- support request cancellation (`qrpc.cancel(id)` call, processed asap out-of-band)

repository: andrasq/node-qrpc

repo_name: andrasq/node-qrpc


text:
---
layout: post
category : meetups
tagline: Getting started with APIs
tags : [PowerShell, Core Concepts, APIs]
img : meetups/2020-04-15.jpg
img-mobile :
img2 :
img3 :
author : RTPSUG
title2 :
title3 :
css:
js:
bgcolor: ff5a71
keywords: PowerShell, Core Concepts, APIs
canonical: https://fullit.github.io
---
{% include JB/setup %}

In today's world of connected computers, using PowerShell is not limited to managing only your computer or the others on your network. It is possible to manage computers across the globe and consume information from the internet all from your PowerShell cmd prompt.

<!--more-->

This month Jonathan Moss will be showing how you can use APIs to retrieve data and make changes to a computer that could be next door or half way across the world!

Jonathan Moss [@jwmoss](https://twitter.com/jwmoss) is a senior system engineer for a financial company in the Raleigh Area. His daily activities require him to interact with various systems on his network, in the cloud and across the internet. One of the ways he does this is through the use of APIs.

Jonathan will demonstrate the basics of working with APIs, give you some tips and tricks on how to work efficiently and finish up with a demo of how he was able to access the data on a Tesla Model S electric car with PowerShell all through the APIs provided with the car!

Want to know what time this meeting is in your [time zone](https://everytimezone.com/s/c898ba97)?

This is a live-streamed event that will be posted on YouTube afterward. By attending this meeting, you agree to allow us to use any recordings of yourself for later use and posted in public forums such as YouTube and Reddit. We record all of our meetings and place the recordings on our YouTube channel a few days after our meetings.

The remote connection information for [our meeting](https://www.meetup.com/Research-Triangle-PowerShell-Users-Group/events/269944787/) will be sent approximately 3 hrs prior to the start of the meeting to all members who RSVP yes to this meeting.


text:
# HistoryBuffer
Simple history with repeat and undo functionalities

Nuget: https://www.nuget.org/packages/HistoryBuffer/

Build:
[![Build status](https://ci.appveyor.com/api/projects/status/6x4si3ifaae9hyl0?svg=true)](https://ci.appveyor.com/project/damian-krychowski/historybuffer)

repository: damian-krychowski/HistoryBuffer

repo_name: damian-krychowski/HistoryBuffer